-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
42 lines (35 loc) · 1.66 KB
/
utils.py
File metadata and controls
42 lines (35 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def play_song_function(ctx, discord, que):
# Architecture:
# call song -> check if playing -> not playing: play now
# |
# -> playing: wait
# Fixes randomly skipping music due to errors
ffmpeg_options = {
'options': '-vn',
"before_options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5"
}
print(f'First it is : {que.index[ctx.guild]}')
vcclient = ctx.voice_client
if not vcclient.is_playing():
# check if voice channel empty for timeout
guild_queue = que.guild[ctx.guild]
song = guild_queue[que.next_track(ctx)]
vcclient.play(discord.FFmpegPCMAudio(song["url"], **ffmpeg_options), after = lambda func: play_song_function(ctx, discord, que))
vcclient.source = discord.PCMVolumeTransformer(vcclient.source)
vcclient.source.volume = 1
print(f'middle it is : {que.index[ctx.guild]}')
print(f'last it is : {que.index[ctx.guild]}')
async def playall_song_function(ctx, discord, que):
vcclient = ctx.voice_client
ffmpeg_options = {
'options': '-vn',
"before_options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5"
}
print("playall_func")
print(f'index is : {que.index[ctx.guild]}')
if not vcclient.is_playing():
guild_queue = que.guild[ctx.guild]
payload = guild_queue[que.next_track(ctx)]
vcclient.play(discord.FFmpegPCMAudio(payload["url"], **ffmpeg_options), after = lambda func: play_song_function(ctx, discord, que))
vcclient.source = discord.PCMVolumeTransformer(vcclient.source)
vcclient.source.volume = 1