【发布时间】:2021-10-10 11:18:15
【问题描述】:
我正在尝试创建一个可以禁止服务器上的人和不在服务器上的人的命令。但是有一个问题:如果我使用async def ban(ctx, member: discord.Member, *, reason):来使用“roles”属性,那么它就无法禁止那些不在服务器上的人。如果我使用async def ban(ctx, member: discord.User, *, reason):,我将无法使用“角色”属性,因为它不是属性。
我为什么要这样做?我正在努力使服务器版主无法禁止具有版主角色的人
代码:
async def ban(ctx, member: discord.User = None, *, reason=None):
if get(ctx.author.roles, id=866038959980544050) or get(ctx.author.roles, id=866436325503008768) or get(
ctx.author.roles, id=866441730631008316) or ctx.author.guild_permissions.administrator: # Check if the author has the Role "Moderator", "Admin", etc.
if get(member.roles, id=867371024466968596) or get(member.roles, id=867132420489871411) and not ctx.author.guild_permissions.administrator: # Check if the member has the Role "Moderator", "Admin", etc.
await ctx.send("You cannot ban this user.")
【问题讨论】:
标签: python discord discord.py