Python 如何使bot将所有成员移动到另一个语音频道
我在这个命令事件上遇到了麻烦。我想播放一个名为Python 如何使bot将所有成员移动到另一个语音频道,python,python-3.x,discord.py,discord.py-rewrite,Python,Python 3.x,Discord.py,Discord.py Rewrite,我在这个命令事件上遇到了麻烦。我想播放一个名为options.ogg的声音,bot可以加入语音频道并正常播放音频,但之后它会产生一个错误InvalidArgument:提供的频道必须是语音频道。我试着读了一下,但我很难理解它到底是如何工作的。所以基本上我想让机器人播放这个声音,然后将所有成员从它加入的语音聊天转移到另一个语音聊天 @client.command(pass_context=True) async def selfdestruct(ctx): author = ctx.m
options.ogg
的声音,bot可以加入语音频道并正常播放音频,但之后它会产生一个错误InvalidArgument:提供的频道必须是语音频道
。我试着读了一下,但我很难理解它到底是如何工作的。所以基本上我想让机器人播放这个声音,然后将所有成员从它加入的语音聊天转移到另一个语音聊天
@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)
因为答案在评论中,我想我会在事后为其他人做一个正式的评论 基本上,在这个特定的问题中,个人试图使用当前文档中不存在的方法
move\u member()
建议使用member.move_to()
,他们需要将频道从字符串id转换为整数id
以下行应更改为:
channel='2823280344474983425'
到
channel=client.get_channel(2823280344474983425)
在1.3.0a的当前API文档中,似乎没有客户端的move_member()
方法。尽管如此,当前文档显示它应该是成员。请移动到()
。通道还应转换为整数。您可能还想尝试类似于channel=client.get\u channel(channel\u id\u goes\u here)
-查看。如果这不能解决您的问题,我可以在我能够这样做的时候提供进一步的代码更新。