我正在尝试让一个机器人加入语音聊天,然后在youtube网址中播放音频。这是我的代码:
@client.command() async def play(ctx):
channel = ctx.message.author.voice.channel
voice_client = await channel.connect()
opts = {'format': 'bestaudio'}
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
with youtube_dl.YoutubeDL(opts) as ydl:
song_info = ydl.extract_info('video', download=False)
URL = song_info['formats'][0]['url']
voice_client.play(FFmpegPCMAudio(URL, **FFMPEG_OPTIONS))
不会引发任何错误,但只会显示[youtube]视频:正在下载网页