Reputation: 48
I honestly have no idea what's wrong or even how to phrase my question, my code looks good to me, but it's just simply not working. There are no errors, and once I use the play command it says [youtube] IPXIgEAGe4U: Downloading webpage
, which I'm pretty sure means that it should have worked. I have tried just doing a standard mp3 file as well to see if it was a problem with youtube_dl
but that didn't work either. I've also tried FFmpegPCMAudio
instead of the one I have there, and getting rid of the FFMPEG_OPTIONS
from the function arguments, but neither of those have worked. The only thing I can think of is I did something wrong with the voice_client
, or I did something wrong with discord.FFmpegOpusAudio.from_probe(url2, **FFMPEG_OPTIONS)
, but I can't find anything to help me so I resorted to coming here. My code for my play function is below.
@commands.command()
async def play(self, ctx, url):
ctx.voice_client.stop()
FFMPEG_OPTIONS = {'before_options': 'reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5'}
YDL_OPTIONS = {'format': '249/250/251'}
vc = ctx.voice_client
with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(url, download=False)
url2 = info['formats'][0]['url']
source = await discord.FFmpegOpusAudio.from_probe(url2, **FFMPEG_OPTIONS)
vc.play(source)
Upvotes: 2
Views: 179
Reputation: 1417
On this line:
FFMPEG_OPTIONS = {'before_options': 'reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5'}
You are missing a - before reconnect. It should be:
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5'}
.
Note that the bot must connect to voice channel before play command is run. It might be a good idea to ensure that from play command itself.
Upvotes: 1