@client.command()@commands.has_permissions(administrator=True)async def kick(ctx, member : discord.Member, *, reason=None): try: await member.kick(reason=reason) embed = discord.Embed(colour=maincolour) embed.title = f"**Member {member.mention} Kicked." embed.description = f"**Reason** » {reason}.\n**Status** » Successful!" await ctx.send(embed=embed) except: embed = discord.Embed(colour=maincolour) embed.title = "**Kick not successful." embed.description = "**Possible Errors:**\n» Insufficient Permissions (Requires Administrator)\n» Error with Bot." await ctx.send(embed=embed)在线上@commands.has_permissions(administrator=True)错误是'Command' object has no attribute 'has_permissions'。我该如何修复这个错误?这段代码适用于我的朋友。
1 回答
婷婷同学_
TA贡献1844条经验 获得超8个赞
该has_permissions属性不受命令控制。这才是正确的做法。
from discord.ext.commands import has_permissions, MissingPermissions
@client.command()
@has_permissions(administrator = True)
async def test(ctx):
pass
@test.error
async def test_error(error, ctx):
if isinstance(error, MissingPermissions):
await ctx.send("Looks like you don't have the permissions.")
添加回答
举报
0/150
提交
取消