为什么我的踢腿命令不起作用? Python

时间:2020-12-20 16:48:23

标签: python discord discord.py

@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}")

我收到此错误

@client.command.has_permissions(administrator=True)

真正的未察觉意图

1 个答案:

答案 0 :(得分:0)

不是@client.command.has_permissions(),而是@commands.has_permissions(),并确保您导入了from discord.ext import commands

@client.command()
@commands.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 ctx.log_channel.send(f"{ctx.author.name} has kicked {member.display_name}")