【问题标题】:How to make bot move all members to another voice channel如何让机器人将所有成员移动到另一个语音频道
【发布时间】: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


【解决方案1】:

由于答案在评论中,我想我会在事后为其他人做一个官方的。

基本上,在这个特定问题中,个人试图使用当前文档中不存在的方法move_member()

建议使用member.move_to(),他们需要将频道从字符串id转换为整数id。

下面这行应该改成:

channel = '282328034474983425'

channel = client.get_channel(282328034474983425)

【讨论】:

    猜你喜欢
    • 2021-04-18
    • 2020-12-21
    • 1970-01-01
    • 2020-08-30
    • 2019-10-27
    • 2018-10-07
    • 1970-01-01
    • 2021-07-06
    • 2018-02-06
    相关资源
    最近更新 更多