#overwrite
1 messages · Page 1 of 1 (latest)
Hey! Once your issue is solved, press the button below to close this thread!
are you sure for_target and deny will always be functions
What is your python version?
3.12.3
I'm not sure what are you trying to achieve, but PermissionOverwrite.deny (return of interactions.PermissionOverwrite.for_target(guild.default_role)) is optional Permission class (so it can be None)
So, in other words, interactions.PermissionOverwrite.for_target(guild.default_role).deny == None
i wanna make a private text channel
that only the user who clicked a button can view, and ofc, the admins
channel = await ctx.guild.create_text_channel(name=f"{user.username}-certificate", permission_overwrites=overwrite)
overwrite = [
interactions.PermissionOverwrite.for_target(guild.default_role).deny(Permissions.VIEW_CHANNEL)
]
this is the overwrite array
what is the right aproach to do this?
you should check if the deny function is None
try
overwrite = interactions.PermissionOverwrite.for_target(guild.default_role)
overwrite.add_denies(Permissions.VIEW_CHANNEL)
ohh so i should use add_denies instead of deny
PUT::https://discord.com/api/v10/channels/1234521678420246528/permissions/636196991029739530: 403
Ignoring exception in Component(): HTTPException: 403|Forbidden || Missing Access
Ping me if it works
got this, and it did not create the channel
Check if your bot has enough perms to do the action
yes it does
its admin
tried changing to this
overwrite = [interactions.PermissionOverwrite.for_target(guild.default_role).add_denies(Permissions.VIEW_CHANNEL)]
got a whole different error
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\interactions\client\client.py", line 607, in _async_wrap
await _coro(_event, *_args, **_kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\interactions\models\internal\callback.py", line 32, in __call__
return await self.callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\Desktop\discordbot.py", line 52, in on_component
channel = await ctx.guild.create_text_channel(name=f"{user.username}-certificate", permission_overwrites=overwrite)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\interactions\models\discord\guild.py", line 1005, in create_text_channel
return await self.create_channel(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\interactions\models\discord\guild.py", line 964, in create_channel
models.process_permission_overwrites(permission_overwrites),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\interactions\models\discord\channel.py", line 2681, in process_permission_overwrites
return list(map(to_dict, overwrites))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\interactions\client\utils\serializer.py", line 41, in to_dict
attrs = fields(inst.__class__)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\site-packages\attr\_make.py", line 2055, in fields
raise NotAnAttrsClassError(msg)
attr.exceptions.NotAnAttrsClassError: <class 'NoneType'> is not an attrs-decorated class.
Because add_denies returns None, you need to pass overwrite object
Are you sure your bot role is higher than guild.default_role?
then back to this error
yes, it has admin permissions
wait, lemme try without overwrites
it should create a channel
it works, it creates a channel without overwrites, but the channel would be public
ok wait worked, but now only the server owner can see the channel, even the user who made it cant see it
tried this
overwrite = [interactions.PermissionOverwrite.for_target(guild.default_role), interactions.PermissionOverwrite.for_target(user)]
overwrite[0].add_denies(Permissions.VIEW_CHANNEL)
overwrite[1].add_allows(Permissions.VIEW_CHANNEL)
but still
but now only the server owner can see the channel
Any user with admin permissions can see any channel (even hidden)
Owner is basically a role with admin++ powers
For everything else, you just need to play with permissions
thats the issue, i tried to do this, but didnt work
i gave the ctx.user permission to view channel, but it didnt apply
A
and i made sure ctx.user isnt a none, its the actual user
when i click the button to create a channel, it shows for a second then disappears again