[英]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'
我试过的其他事情:
self.bot.move_member(person, jail_vc)
self.bot.move_member(person, jail_vc)
commands.move_member(person, jail_vc)
commands.move_member(person, jail_vc)
command.move_member(person, jail_vc)
command.move_member(person, jail_vc)
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.