Своя очередь на каждом сервере дискорд (Бот) [disnake.py]
у меня есть реализация музыкальной очереди в своем дискорд боте. Но проблема заключается в том, что переменная задается в самом начале кода и работает на разных серверах как одна общая, нужно сделать так, чтобы на каждом сервере дискорд была своя очередь, никак не могу разобраться, что мне для этого нужно?
queue = []
@commands.slash_command(name='play', description='')
async def play(self, inter, *, song):
global voice
if not inter.author.voice or not inter.author.voice.channel:
return await inter.response.send_message(random.choice(replies_user_not_voice))
channel = inter.author.voice.channel
voice = get(self.bot.voice_clients, guild=inter.guild)
if voice and voice.is_connected():
await voice.move_to(channel)
else:
voice = await channel.connect()
if not voice and not voice.is_connected():
return await inter.response.send_message('Голосовой канал недоступен..(')
queue.append(song)
with YoutubeDL(YDL_OPTIONS) as ydl:
if 'https://' in song:
info = ydl.extract_info(song, download=False)
else:
info = ydl.extract_info(f'ytsearch:{song}', download=False)['entries'][0]
if not voice.is_playing() and not voice.is_paused():
await inter.response.send_message(f"Включаю: {info.get('title')}")
if voice.is_playing() or voice.is_paused():
await inter.response.send_message(f"Добавляю в очередь: {info.get('title')}")
try:
while True:
with YoutubeDL(YDL_OPTIONS) as ydl:
if 'https://' in queue[0]:
info = ydl.extract_info(queue[0], download=False)
else:
info = ydl.extract_info(f'ytsearch:{queue[0]}', download=False)['entries'][0]
url = info['formats'][0]['url']
voice.play(disnake.FFmpegPCMAudio(executable='ffmpeg\\ffmpeg.exe', source=url, **FFMPEG_OPTIONS))
while voice.is_playing() or voice.is_paused():
await asyncio.sleep(2)
if not voice.is_playing() and not voice.is_paused():
queue.pop(0)
except:
pass