我的ban命令遇到问题,我的管理员可以互相禁止,我也不想这样做,但是我不确定如何在此处修复我的代码
#Ban command
@client.command()
@commands.has_permissions(ban_members=True)
async def ban(ctx, member : discord.Member, *, reason=None):
await member.ban(reason=reason)
await ctx.send(f'{user.mention} has been banned!')
我希望它使它像这样,但是对于python和idk来说我是一个新手,如何编写它(注释部分)
#Ban command
@client.command()
@commands.has_permissions(ban_members=True)
async def ban(ctx, member : discord.Member, *, reason=None):
#if mentioned user has the same role as the author:
await ctx.send('Cant ban Moderators/Admins')
else:
await member.ban(reason=reason)
await ctx.send(f'{user.mention} has been banned!')
答案 0 :(得分:0)
#Ban command
@client.command()
@commands.has_permissions(ban_members=True)
async def ban(ctx, member : discord.Member, *, reason=None):
check = False
for i in member.roles:
if i in ctx.author.roles[1:]:
check = True
if(check):
await ctx.send('Cant ban Moderators/Admins')
else:
await member.ban(reason=reason)
await ctx.send(f'{user.mention} has been banned!')