关于 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’ 我正在使用重写分支。如何实现将人从任何语音通道移动到特定语音通道”监狱”?任何帮助将不胜感激:)。

  • “我从其他 stackoverflow 线程、github 线程和文档中尝试了很多解决方案”文档是否说这些东西中的任何一个都有 move_member 方法? stackoverflow 线程是否显示其中显示 move_member 的代码?他们说了什么?您尝试了哪些解决方案?
  • @KarlKnechtel 我尝试过的一些解决方案位于底部附近的问题中。我找到的所有解决方案都是 move_member 的不同变体,其中很多也适用于 discord.py 的旧分支。


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

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

1
await person.move_to(jail_vc,“Jail role”)


来源:https://www.codenong.com/62831696/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_9983.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?