简体   繁体   English

Discord.py “机器人 object 没有属性‘move_member’

[英]Discord.py "Bot object has no attribute 'move_member'

With my bot, I am trying to make it so that when a person gets the 'Prisoner' role, the bot automatically moves them into the 'jail' voice channel if they are already in a voice channel.使用我的机器人,我试图做到这一点,当一个人获得“囚犯”角色时,如果他们已经在语音通道中,机器人会自动将他们移动到“监狱”语音通道中。 I have tried lots of solutions from other stackoverflow threads, github threads and the documentation but none of them work.我已经从其他 stackoverflow 线程、github 线程和文档中尝试了很多解决方案,但它们都不起作用。

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))

That code returns: 'Member object has no attribute 'move_member' Other things I have tried:该代码返回: 'Member object has no attribute 'move_member'我试过的其他事情:

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

And some other variations.以及其他一些变化。 The error is always 'something' has no attribute 'move_member' I am using the rewrite branch.错误总是'something' has no attribute 'move_member'我正在使用重写分支。 How can I implement moving a person from any voice channel into the specific voice channel 'jail'?如何实现将人从任何语音通道移动到特定语音通道“监狱”? Any help will be greatly appreciated:).任何帮助将不胜感激:)。

The function you're looking for is Discord.Member#move_to您正在寻找的 function 是Discord.Member#move_to

You need to pass a VoiceChannel as it's param for the task you want to do.您需要传递一个VoiceChannel ,因为它是您想要执行的任务的参数。 You may also provide a reason: str as the 2nd param.您还可以提供一个reason: str作为第二个参数。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 move_member()的Discord.py问题 - Discord.py trouble with move_member() discord.py: 'Bot' 对象没有属性 'get' 错误 - discord.py: 'Bot' object has no attribute 'get' error discord.py 'Bot' 对象没有属性 'send_message' - discord.py 'Bot' object has no attribute 'send_message' Discord.py - 'Member' 对象没有属性 'channel' - Discord.py - 'Member' object has no attribute 'channel' 成员 object 没有属性“作者” - discord.py - Member object has no attribute 'author' - discord.py AttributeError: 'Message' object 没有属性 'member' - Discord.py 重写 - AttributeError: 'Message' object has no attribute 'member' - Discord.py Rewrite discord.py bot 重写 AttributeError: 'Bot' object has no attribute 'send_message' - discord.py bot rewrite AttributeError: 'Bot' object has no attribute 'send_message' 经济机器人 | discord.py 重写 | 排行榜错误 - AttributeError: 'NoneType' object 没有属性 'name' - Economy Bot | discord.py rewrite | Leaderboard error - AttributeError: 'NoneType' object has no attribute 'name' 在 Discord.py 中 - 重写 AttributeError: 'Bot' object has no attribute 'voice_client_in' - In Discord.py - rewrite AttributeError: 'Bot' object has no attribute 'voice_client_in' 在 linux 上使用 discord.py 我收到错误“Bot”对象没有属性“join_voice_channel” - Using discord.py on linux I get the error 'Bot' object has no attribute 'join_voice_channel'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM