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

时间:2020-08-13 19:58:52

标签: discord discord.py-rewrite

我想检查文本通道是否已将权限设置为某个值,特别是 send_messages 权限。基本上我想要这样的东西:

for xmlpath in df["XMLLink"]:
    print(xmlpath)

有什么提示吗?

1 个答案:

答案 0 :(得分:0)

您可以使用overwrites_for来获得角色的PermissionOverwrite

@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)