【发布时间】:2020-01-11 06:01:41
【问题描述】:
我在处理这个命令事件时遇到了麻烦。我想播放一个名为options.ogg 的声音,机器人可以加入语音通道并正常播放音频,但之后会产生错误InvalidArgument: The channel provided must be a voice channel。我尝试阅读它,但我无法理解它是如何工作的。所以基本上我希望机器人播放那个声音,然后将所有成员从它加入的语音聊天移到另一个语音聊天。
@client.command(pass_context=True)
async def selfdestruct(ctx):
author = ctx.message.author
voice_chat = author.voice_channel
vc = await client.join_voice_channel(voice_chat)
channel = '282328034474983425'
player = vc.create_ffmpeg_player('C:\sound\options.ogg', after=lambda:
print('done'))
player.start()
while not player.is_done():
await asyncio.sleep(1)
# disconnect after the player has finished
player.stop()
await vc.disconnect()
await client.move_member(author, channel)
【问题讨论】:
-
在 1.3.0a 的当前 API 文档中,客户端似乎没有
move_member()方法。话虽如此,当前的文档显示它应该是member.move_to()。通道也应转换为整数。您可能还想尝试channel = client.get_channel(channel_id_goes_here)之类的东西 - 看看discordpy.readthedocs.io/en/latest/api.html#member。如果这不能解决您的问题,我可以提供进一步的代码更新。
标签: python python-3.x discord.py discord.py-rewrite