Hello Stack Overflow community,
I'm working on a Discord bot in Python using the discord.py library that plays music from YouTube links. The bot is supposed to queue a song when the !play command is used while another song is currently playing. It plays the first song successfully but throws errors when trying to queue the next song and stops the current playback.
Here's a snippet of my code related to the play command:
# ... [other parts of the code] ...
@bot.command()
async def play(ctx, url):
global queue, current_song
# ... [code to process the command] ...
# This is the problematic part
if not ctx.voice_client.is_playing() and not ctx.voice_client.is_paused():
ctx.voice_client.play(discord.FFmpegPCMAudio(executable="ffmpeg", source=file_path), after=lambda e: asyncio.run_coroutine_threadsafe(play_next(ctx), ctx.bot.loop))
current_song = new_song
await ctx.send(f" Now playing: **{track_name}** by **{artist_name}**")
else:
queue.append(new_song)
await ctx.send(f" Added to queue: **{track_name}** by **{artist_name}**")
# ... [rest of the code] ...
When I run the !play command to add a song to the queue, the following errors occur:
[aac @ 000001e574714e80] Number of bands (55) exceeds limit (43).
Error while decoding stream #0:0: Invalid data found when processing input
# ... [other FFmpeg error messages] ...
[INFO] discord.player: ffmpeg process 7944 successfully terminated with return code of 0.
C:\Users\james\Desktop\Pycharm_Python\Mine egne projekter\temp: No such file or directory
[INFO] discord.player: ffmpeg process 9308 successfully terminated with return code of 1.
The first song plays fine, but the bot fails to queue the next song and stops the current song instead.
Can someone help me understand what might be causing these errors and how to fix them? Any insights or suggestions would be greatly appreciated.
Thank you!
I have updated FFmpeg to version 6.0, and the youtube_dl library is also up to date. The bot is running on a Windows system. I've tried several troubleshooting steps, including generating unique filenames for downloads to avoid conflicts, but the issue persists.