此禁止命令不起作用...我该如何解决?

时间:2020-08-04 15:36:33

标签: 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:
        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()
    

1 个答案:

答案 0 :(得分:1)

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

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

这使您可以在不一定具有相同角色的多个服务器中使用该漫游器,并将其范围缩小到一定的权限。