设置中立权限discord.py重写

时间:2021-04-11 07:53:45

标签: python discord discord.py

看,让我解释一下,假设我想允许用户在频道中发送消息,而他被拒绝发送消息。我想将他的权限设置为中立。但是,此代码允许用户发送消息。甚至他也扮演着 Muted 的角色。

@commands.command(hidden=False)
@commands.has_permissions(kick_members=True)
@commands.bot_has_permissions(manage_channels=True, manage_permissions=True)
async def unblock(self, ctx, member : discord.Member, *, reason:str=None):
    """To allow the blocked user to send messages that channel."""
    guild = ctx.guild
    
    if member.permissions_in(ctx.channel).send_messages == True: await ctx.send(f"{ctx.author.mention} {member.name} is already unblocked. They can send message")
    else: await ctx.channel.set_permissions(member, send_messages=True, reason=f"Action requested by {ctx.author.name}({ctx.author.id}) || Reason: {reason}")

1 个答案:

答案 0 :(得分:0)

您只需执行 None

# Always allowed
= True

# Neutral
= None

#Always denied
= False

另外你也不需要== True,你可以直接删除它

if member.permissions_in(ctx.channel).send_messages: