【发布时间】:2021-05-24 07:59:43
【问题描述】:
我的 discord 机器人有问题。 (discord.py)
这是我的代码:
@bot.command()
async def mute(ctx):
muteRole = discord.Guild.get_role(845612659940524032)
if(message.author.kick_members == True):
return
else:
await ctx.send('You don\'t have the permission for that')
在我看来一切都是正确的。但是当我测试命令时,我总是得到这个错误:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: get_role() missing 1 required positional argument: 'role_id'
有人可以帮我吗?
【问题讨论】:
-
我的猜测是您正在尝试使用 Guild 类的非静态方法,并且您传递给
get_role的数字被解释为self参数,这将解释您的异常。你不应该从类 Guild 实例化吗?
标签: python discord discord.py