Discord.py 此Ban命令不起作用。。。我怎样才能修好它?

Discord.py 此Ban命令不起作用。。。我怎样才能修好它?,discord.py,Discord.py,这是我的禁令!每次我想禁止某人,它不会通过其他人!老实说,除了if,它什么也不做!请帮忙 @bot.command() #ban (verified works) @commands.has_permissions(ban_members = True) async def ban(ctx, member : discord.Member, *, reason = None): if member == ctx.author or member.id == bot.user.id:

这是我的禁令!每次我想禁止某人,它不会通过其他人!老实说,除了if,它什么也不做!请帮忙

@bot.command() #ban (verified works)
@commands.has_permissions(ban_members = True)
async def ban(ctx, member : discord.Member, *, reason = None):
    if member == ctx.author or member.id == bot.user.id:
        await ctx.send("Unfortunatly I cannot do that!")
        return
    else:
        await ctx.send('Banned the member {}'.format(ctx.member.mention))
        await member.ban(reason = reason)
        await ctx.message.delete()
    

我建议不要使用角色来检查用户是否可以使用该命令,而是尝试使用类似以下内容:

@client.command()
@commands.has_permissions(ban_members=True)
async def ban(ctx, member : discord.Member,*,reason=None):
    try:
        await member.ban(reason=reason)
        embed = discord.Embed(description=f":white_check_mark: succesfully banned {member.mention}!",color=0x00ced1)
        await ctx.send(embed=embed)
    except:
        e2 = discord.Embed(description="You don't have permission to use this command",color=0xff0000)
        await ctx.send(embed=e2)

这允许您在多个服务器中使用bot,这些服务器不一定具有相同的角色,还可以将其缩小到某个权限。

if
行上调试代码,并检查其在这种情况下“卡住”的原因。