【发布时间】:2018-09-07 03:01:57
【问题描述】:
我为我的 discord 机器人发出了一个命令,它会从 youtube 上的视频中播放一些声音。如果您第一次打电话给她,此功能效果很好,但第二次我收到错误,我的机器人已连接到此语音通道。 所以我在他播放视频后尝试断开机器人,但没有成功。
功能:
@bot.command(pass_context=True)
async def video(ctx, msg):
author = ctx.message.author
voice_channel = author.voice_channel
vc = await bot.join_voice_channel(voice_channel)
player = await vc.create_ytdl_player(url)
player.start()
await vc.disconnect() #not good, the video not playing
没有await vc.disconnect() 的错误:
yield from injected(*ctx.args, **ctx.kwargs)
File "/usr/local/lib/python3.6/dist-packages/discord/ext/commands/core.py", line 54, in wrapped
raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: Already connected to a voice channel in this server
感谢帮助^^祝你有美好的一天!
【问题讨论】: