我正试图得到一个机器人,可以加入一个语音聊天命令,然后播放一些从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))
目前没有回答
相关问题 更多 >
编程相关推荐