【发布时间】:2021-05-14 21:20:25
【问题描述】:
我的 discord.py 机器人中有一个禁止命令。权限有效,因此如果您不是管理员,则无法禁止某人。但是,当管理员试图禁止其他管理员或高于他的角色时,它会起作用。我该怎么做才能让管理员只能禁止他们下面的角色?
@commands.command(description = 'Bans a specified member with an optional reason')
@commands.has_permissions(ban_members = True)
async def ban(self,ctx, member:discord.Member, *, reason = "unspecified reason"):
if member.id == ctx.author.id:
await ctx.send("You cannot ban yourself, sorry! :)")
return
else:
await member.ban(reason = reason)
reasonEmbed = discord.Embed(
description = f'????????♂️Succesfully banned {member.mention} for {reason}\n \n ',
colour = 0xFF0000
)
reasonEmbed.set_author(name=f"{member.name}" + "#"+ f"{member.discriminator}", icon_url='{}'.format(member.avatar_url))
reasonEmbed.set_footer(text=f"Banned by {ctx.author.name}", icon_url = '{}'.format(ctx.author.avatar_url))
await ctx.send(embed=reasonEmbed)
【问题讨论】:
标签: python discord discord.py