【问题标题】:To set Neutral Permission discord.py rewrite设置中性权限 discord.py rewrite
【发布时间】:2021-07-06 14:31:17
【问题描述】:

看,让我解释一下,假设我想允许用户在频道中发送消息,而他被拒绝发送消息。我想将他的权限设置为中立。但是,此代码允许用户发送消息。甚至他也有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}")

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    您只需执行None即可做到这一点

    # Always allowed
    = True
    
    # Neutral
    = None
    
    #Always denied
    = False
    

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-20
      • 1970-01-01
      • 2020-08-06
      • 1970-01-01
      • 2021-02-04
      • 1970-01-01
      • 2021-01-02
      • 2020-12-02
      相关资源
      最近更新 更多