discord voice.play(source) doesnt do anything

19 hours ago 4
ARTICLE AD BOX

when i try to play audio from a youtube url, it doesnt play anything and it outputs [2026-02-06 22:11:21,663] {player.py:233} INFO - ffmpeg process 7252 successfully terminated with return code of 3436169992. into the server console. heres all of the code for this command, is there anything wrong with it? i looked at multiple examples and they all seem to be around the same.

@commands.command() async def play(self, ctx, *, arg): FFMPEG_OPTIONS = { "before_options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5 -probesize 200M", "options": "-vn", } ydl_opts = { 'format': 'bestaudio/best', 'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s', 'quiet': True, 'postprocessors': [{ 'key': 'FFmpegExtractAudio', 'preferredcodec': 'mp3', 'preferredquality': '192', }], } # Searches for the video with yt_dlp.YoutubeDL(ydl_opts) as ydl: try: requests.get(arg) except Exception as e: print(e) info = ydl.extract_info(f"ytsearch:{arg}", download=False)["entries"][0] else: info = ydl.sanitize_info(ydl.extract_info(arg, download=False)) url = info["url"] print(url) thumb = info["thumbnails"][0]["url"] title = info["title"] # Finds an available voice client for the bot. voice = ctx.guild.voice_client if not voice: await voice_channel.connect() voice = ctx.guild.voice_client await ctx.send(thumb) await ctx.send(f"Playing {title}") source = discord.FFmpegPCMAudio(source=source) voice.play(source)
Read Entire Article