Discord.py-rewrite has_role 命令错误(不是控制台错误)
Discord.py-rewrite has_role command error (not a console error)
大家好,这是我的 discord.py
代码
@commands.command()
async def kick(self, ctx, member: discord.Member, *, reason=None):
if commands.has_role('Server Manager'):
await member.kick(reason=reason)
else:
await ctx.send("Sorry! You don't have the permission for that")
如果我有 Server Manager
角色,我可以正常踢成员,但我的朋友还没有,他也可以用命令踢我不希望发生这种情况,所以请帮忙 :(.
这是一张支票,因此您可以像使用所有其他支票一样使用它 checks。这是一个例子:
@commands.command()
@commands.has_role("Server Manager")
async def kick(self, ctx, member: discord.Member, *, reason=None):
await member.kick(reason=reason)
这将让用户踢出该成员,或者在您的错误处理程序中引发 the docs. You would want to check for commands.MissingRole 中所述的错误。
大家好,这是我的 discord.py
代码@commands.command()
async def kick(self, ctx, member: discord.Member, *, reason=None):
if commands.has_role('Server Manager'):
await member.kick(reason=reason)
else:
await ctx.send("Sorry! You don't have the permission for that")
如果我有 Server Manager
角色,我可以正常踢成员,但我的朋友还没有,他也可以用命令踢我不希望发生这种情况,所以请帮忙 :(.
这是一张支票,因此您可以像使用所有其他支票一样使用它 checks。这是一个例子:
@commands.command()
@commands.has_role("Server Manager")
async def kick(self, ctx, member: discord.Member, *, reason=None):
await member.kick(reason=reason)
这将让用户踢出该成员,或者在您的错误处理程序中引发 the docs. You would want to check for commands.MissingRole 中所述的错误。