问题
Here is my code -
@client.command()
@client.command.has_permissions(administrator=True)
async def kick(ctx, member: discord.Member):
await member.kick()
await ctx.message.add_reaction("✅")
await ctx.send(f"{member.name} has been kicked by {ctx.author.name}!")
await log_channel.send(f"{ctx.author.name} has kicked {member.display_name}")
It shows the following the following error -
Traceback (most recent call last):
File "C:/Users/Gacha/Desktop/Python Bot/bot.py", line 56, in <module>
@client.command.has_permissions(administrator=True)
AttributeError: 'function' object has no attribute 'has_permissions'
I dont know why its showing this, I saw someone using this and it worked for him. ;-;
回答1:
Its @commands.has_permissions(administrator=True)
instead of @client.command.has_permissions(administrator=True)
And I wonder where you saw someone else using it 🤔
来源:https://stackoverflow.com/questions/63480249/discord-py-how-to-set-a-kick-command-such-that-only-an-administrator-can-use-it