Reputation: 27
I have been trying to make a mute command and a ticket command for my discord bot but i can't wrap my head around permission overwrites. Thank you in advance
Upvotes: 1
Views: 8808
Reputation: 6944
Here's a command for editing a certain member's permissions server-wide (i.e. for each text channel the bot can see):
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.")
References:
TextChannel.overwrites_for()
- Keep in mind this can take in a Role or User/Member object.TextChannel.set_permissions()
Guild.text_channels
Upvotes: 4