关于 python:Discord.py “Bot 对象没有属性 ‘move_member’

Discord.py "Bot object has no attribute 'move_member'

使用我的机器人,我正在努力做到这一点,当一个人获得"囚犯"角色时,如果他们已经在语音通道中,机器人会自动将他们移动到"监狱"语音通道中。我已经从其他 stackoverflow 线程、github 线程和文档中尝试了很多解决方案,但它们都不起作用。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Jail(commands.Cog):
    def __init__(self, bot):
        self.bot = bot

@commands.command()
    async def jail(self, ctx, person: discord.Member):
        try:
            jailor = discord.utils.find(lambda r: r.name == 'Jailor', ctx.message.guild.roles)
            if jailor in ctx.author.roles:
                prisoner = discord.utils.find(lambda r: r.name == 'Prisoner', ctx.message.guild.roles)
                await person.add_roles(prisoner)

                jail_vc = self.bot.get_channel('jail')
                await person.move_member(jail_vc)

            else:
                await ctx.send("You need to have the Jailor role to use this command")

        except Exception as e:
            print(str(e))

该代码返回:'Member object has no attribute 'move_member' 我尝试过的其他事情:

  • 等待 self.bot.move_member(person, jail_vc)
  • 等待 commands.move_member(person, jail_vc)
  • 等待 command.move_member(person, jail_vc)
  • 等待 ctx.guild.move_member(person, jail_vc)

还有其他一些变化。错误总是 'something' has no attribute 'move_member' 我正在使用重写分支。如何实现将人从任何语音通道移动到特定语音通道"监狱"?任何帮助将不胜感激:)。


你正在寻找的函数是 Discord.Member#move_to

您需要传递一个 VoiceChannel 作为您要执行的任务的参数。您还可以提供 reason: str 作为第二个参数。

1
await person.move_to(jail_vc,"Jail role")