Python Discord.py“;Bot对象没有属性';移动#u成员';
在我的机器人中,我试图做到这样,当一个人获得“囚犯”角色时,如果他们已经在语音频道中,机器人会自动将他们移动到“监狱”语音频道。我从其他stackoverflow线程、github线程和文档中尝试了很多解决方案,但都不起作用Python Discord.py“;Bot对象没有属性';移动#u成员';,python,discord,Python,Discord,在我的机器人中,我试图做到这样,当一个人获得“囚犯”角色时,如果他们已经在语音频道中,机器人会自动将他们移动到“监狱”语音频道。我从其他stackoverflow线程、github线程和文档中尝试了很多解决方案,但都不起作用 class Jail(commands.Cog): def __init__(self, bot): self.bot = bot @commands.command() async def jail(self, ctx, person:
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对象没有属性“move\u Member”
我尝试过的其他方法:
- 等待
self.bot.move\u成员(个人、监狱\u vc)
- 等待
命令。移动成员(个人、监狱\u vc)
- 等待
命令。移动成员(个人、监狱\u vc)
- 等待ctx.guild.move成员(个人、监狱、vc)
还有其他一些变化。错误总是“something”没有属性“move\u member”我正在使用重写分支我如何实现将一个人从任何语音频道移动到特定语音频道“监狱”中?任何帮助都将不胜感激:)。您正在寻找的功能是 您需要传递一个
语音频道
,因为它是您想要执行的任务的参数。您还可以提供一个原因:str
作为第二个参数
等待某人。移动到(监狱角色)
“我从其他stackoverflow线程、github线程和文档中尝试了很多解决方案”文档中是否说这些东西都有move\u member
方法?stackoverflow线程是否在其中显示写有move\u member
的代码?他们怎么说?你尝试过什么解决方案?@KarlKnechtel我尝试过的一些解决方案在接近底部的问题中。我找到的所有解决方案都是move_成员的不同变体
,其中许多也适用于discord.py的旧分支。