我一直在尝试为不和谐的bot设置一个静音命令和一个票证命令,但是我无法绕过权限覆盖。预先谢谢你
答案 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.")
参考:
TextChannel.overwrites_for()
-请记住,这可能会包含Role或User / Member对象。TextChannel.set_permissions()
Guild.text_channels