如何检查文本频道的权限值?[discord.py]

如何检查文本频道的权限值?[discord.py],discord,discord.py-rewrite,Discord,Discord.py Rewrite,我想检查一个文本频道是否已经将权限设置为某个特定值,特别是发送\u消息权限。基本上我想要这样的东西: @bot.command() async def perm(ctx, channel : discord.TextChannel = None) if (send_messages = False): # If permission is set to false, print error message ctx.send("Permission is

我想检查一个文本频道是否已经将权限设置为某个特定值,特别是发送\u消息权限。基本上我想要这样的东西:

@bot.command()
async def perm(ctx, channel : discord.TextChannel = None)
if (send_messages = False):
        # If permission is set to false, print error message
        ctx.send("Permission is already set to false.")
else:
        # Else, set permission to false
        await ctx.channel.set_permissions(ctx.guild.default_role, send_messages=False)

有什么提示吗?

您可以使用
overwrites\u for
获取角色的权限

@bot.command()
async def perm(ctx, channel : discord.TextChannel):
    overwrite = channel.overwrites_for(ctx.guild.default_role)
    if overwrite.send_messages == False:
        ctx.send("Permission is already set to false.")
    else:
        await ctx.channel.set_permissions(ctx.guild.default_role, send_messages=False)

您可以使用
overwrites\u for
来获取角色的权限

@bot.command()
async def perm(ctx, channel : discord.TextChannel):
    overwrite = channel.overwrites_for(ctx.guild.default_role)
    if overwrite.send_messages == False:
        ctx.send("Permission is already set to false.")
    else:
        await ctx.channel.set_permissions(ctx.guild.default_role, send_messages=False)