Skip song if voice_client is None

This commit is contained in:
ekzyis 2021-09-26 01:51:59 +02:00
parent abe268391f
commit 94d018246c
1 changed files with 7 additions and 0 deletions

View File

@ -60,6 +60,13 @@ class Music(commands.Cog):
try: try:
await self._queue_lock.acquire() await self._queue_lock.acquire()
ctx, song = await self._queue.get() ctx, song = await self._queue.get()
if ctx.voice_client is None:
# Bot is no longer in a voice channel.
# This could be the case because a stop command was issued.
# We will skip this (and possibly all remaining songs) in the queue
self._queue.task_done()
self._queue_lock.release()
continue
audio = discord.FFmpegPCMAudio(song.audio_url, **self._ffmpeg_options) audio = discord.FFmpegPCMAudio(song.audio_url, **self._ffmpeg_options)
def after(err): def after(err):