#permission overwrites please

1 messages · Page 1 of 1 (latest)

sturdy gobletBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

patent gazelle
patent gazelle
#

Example for a PermissionOverwrite Object. Without guarantee:

PermissionOverwrite(
  id=role.id #--> your role ID (or User ID)
  target=interactions.Role #--> the type: Role/User
  allow=[interactions.Permissions.VIEW_CHANNEL] #--> list of allowed Permissions
  deny=[interactions.Permissions.SEND_MESSAGES] #--> list of denied Permissions
)
patent gazelle
#

I´m not your bro

#

list of targets is not possible, as far i know

#

you have to create overwrite for each role

torpid yacht
#
overwrites = [ 
  PermissionOverwrite(id=ctx.guild.id,type=0,deny=Permissions.VIEW_CHANNEL),          # sets full privacy on ctx.guild.id
  PermissionOverwrite(id=ctx.author_id,type=1,allow=Permissions.VIEW_CHANNEL),        # sets view channel permission on ctx.author_id 
]
new_channel = await ctx.guild.create_text_channel(channel_name, permission_overwrites=overwrites)

type=0 -> ID is RoleID
type=1 -> ID is UserID

#

you have to assign a permission to each role/user

#

and I'm with you, the docs could be better at this point

#

I also needed some time to get into that function ^^

#

especially that you could use 0/1 as type instead of a complete role/user-object

patent gazelle
torpid yacht
#

yes, I needed some time to check this. espacially for that function

#

just want to say I can relate to OPs confusion

patent gazelle
#

I can understand the struggle cause there is no Guide for Permissions.
But with some programming logic its not the big problem.
In channel create function is PermissionOverwrite as typehint for overwrites.
if you look in the docs for this it is relativly easy

torpid yacht
#

yes, I think its more complicated for beginners rather then experienced coders
at least I was relative unexperienced as I was working the first time with that function / i.py

patent gazelle
#

looks good. good solution with list comp

#

The roles have ViewChannel already?

torpid yacht
#

I thought SEND_MESSAGES > VIEW_CHANNELS according to docs?

patent gazelle
#

i´m not sure. maybe this is enough

torpid yacht
#

it should

#

SEND_MESSAGES includes VIEW_CHANNEL permission

patent gazelle
#

ah ok. good to know

torpid yacht
#

at first, deny VIEW_CHANNEL also denies SEND_MESSAGES

#

no need to set it for the same role twice

#

dude, you asked since 3 days the same weird questions

#

try to use pipes to combine different permissions in one assignment

#

allow=Permissions.SEND_MESSAGES | Permissions.ATTACH_FILES

#

❤️