您如何使用权限覆盖? Discord.py重写

时间:2020-05-15 14:22:48

标签: python discord discord.py discord.py-rewrite

我一直在尝试为不和谐的bot设置一个静音命令和一个票证命令,但是我无法绕过权限覆盖。预先谢谢你

1 个答案:

答案 0 :(得分:2)

以下是用于在服务器范围内修改特定成员权限的命令(即,该漫游器可以看到的每个文本通道):

示例

import discord # if you get an error about discord not being defined, include this at the top

@bot.command()
async def mute(ctx, member: discord.Member):
    for channel in ctx.guild.text_channels:
        perms = channel.overwrites_for(member)
        perms.send_messages = False
        await channel.set_permissions(member, overwrite=perms, reason="Muted!")
    await ctx.send(f"{member} has been muted.")

参考: