I've tried to set the permissions on a specific channel (defined before) but it doesn't work. I want the channel to be a specific one and not one based on await ctx.channel.set_permissions(role, send_messages=False)
Here's my line that I use to set the permission that doesn't work. Channel is the ID of a specific channel:
await channel.set_permissions(role, overwrite = None, send_messages=False)
You need to get the channel object with the id before you try to call set_permissions
. Also, you can't mix overwrite
with other permission kwargs.
channel
being the channel's id:
channel_obj = bot.get_channel(channel)
await channel_obj.set_permissions(role, send_messages=False)
Instead of overwrite=None, send_messages=False
you can do:
overwrite = discord.PermissionOverwrite()
overwrite.send_messages = False
await channel_obj.set_permissions(role, overwrite=overwrite)