fix(commands/voice/queue): lock when queue_or_play

This commit is contained in:
Ryan 2024-12-30 18:06:47 -05:00
parent 73c1ebf9ee
commit 393403ef7d
Signed by: ErrorNoInternet
GPG Key ID: 2486BFB7B1E6A4A3
3 changed files with 10 additions and 4 deletions

View File

@ -63,7 +63,7 @@ async def queue_or_play(message):
not message.guild.voice_client.is_playing()
and not message.guild.voice_client.is_paused()
):
await message.channel.send(f"**now playing:** `{player.title}`")
await utils.reply(message, f"**now playing:** `{player.title}`")
play_next(message)
else:
await utils.reply(

View File

@ -1,3 +1,4 @@
import asyncio
import contextlib
import importlib
import inspect
@ -11,6 +12,7 @@ import commands
import constants
import core
import utils
from state import command_locks
async def on_message(message):
@ -93,6 +95,9 @@ async def on_message(message):
case C.LEAVE:
await commands.voice.leave(message)
case C.QUEUE | C.PLAY:
if message.guild.id not in command_locks:
command_locks[message.guild.id] = asyncio.Lock()
async with command_locks[message.guild.id]:
await commands.voice.queue_or_play(message)
case C.SKIP:
await commands.voice.skip(message)

View File

@ -2,11 +2,12 @@ import time
import disnake
start_time = time.time()
player_queue = {}
player_current = {}
command_locks = {}
intents = disnake.Intents.default()
intents.message_content = True
client = disnake.Client(intents=intents)
start_time = time.time()