My bot has a command which creates a channel and then grants the command user a bunch of permissions in that specific channel. As I have recently discovered, if the bot does not have the administrator permissions, it must have every permission that it grants or else that permission won't be granted. I thought this was fine, I'd just include my long list of permissions in oAuth, but one of the most important permissions to be given to the command user is manage_permissions, and this permission only applies to channels, not roles. This means I can't give my bot manage_permissions in oAuth unless I ask server owners to give my bot Administrator perms, which I'd like to avoid. Is there any way around this or do I just need to give my bot administrator?
#Bot can't give manage_permission in a channel without administrator permissions.
1 messages · Page 1 of 1 (latest)
Manage Roles permissions should do it
That's what I thought, but no dice
I don't see manage_permission in the OAuth page
that's because it doesn't exist
it's only for channels
the problem is discord coded in a rule that if you don't have administrator, you can't give somebody else a permission in a channel unless you also have that permission in the channel
the only way my bot could have that permission in the channel is if it was given particularly in the context of that channel (or administrator)
oAuth won't do it
what's the list of permissions your bot asks for?
well basically the idea of the bot is that you use the command and then you get a channel that you can do whatever you want with, so there are a lot. Obviously manage_permissions is very important in case the channel owner wanted to change other people's permissions (make the channel read-only, etc.) this is the list: py ownerPermissions = disnake.PermissionOverwrite( view_channel=True, connect=True, create_public_threads=True, create_private_threads=True, manage_channels=True, #manage_permissions=True, manage_webhooks=True, manage_messages=True, manage_threads=True, move_members=True, mute_members=True, deafen_members=True, priority_speaker=True, manage_events=True, )
manage_permissions is commented out because I wanted to see if it would work if it didn't try to assign that permission, and it did
yeah thats a permission you can't auto set on the bot
ppl in the guild have to assign it
thats why i run this
if not channel.permissions_for(inter.guild.me).manage_channels or not channel.permissions_for(inter.guild.me).manage_permissions:
e = disnake.Embed(
description=f"❎ Please make sure I have `manage channels` and `manage permissions` permissions to {channel.mention} then run `/setup` again.", color=disnake.Color.red())
return await inter.send(
embed=e, ephemeral=True
)
just do a check
and let the user know to add it
cause its per channel
the problem with that is my bot creates the channel and then immediately sets permissions in it
as long as the bot has manage_channel persm its fine then
so I'd have to ask a server admin to give the bot permissions as it creates the channel
defeating the whole point
it does, still no dice
I think since it's specifically giving manage_permissions it needs to specifically have manage_permissions
i think its one of those weird role/member permission type things
wdym
yesterday when tryna troubleshoot why my bot wasnt working for someone
i had to set the bot user permissions for the channel
and not the role itself
or else it acted if the bot still didn't have the permissions
what does your bot do with the permissions?
no i mean this
?
see how its the bots user and not the bots role
right
when i set the bots role permission for manage permissions it didnt work
but when i did the user it worked
well you can't set manage permissions in the role can you?
so then once i did that the bot set it's own perms for that channel
that's the whole issue
you can
unless u mean the bot setting itself then no
that's why u need to run a check
that's what I meant
there is no way around it other than just giving the bot admin which i advised against cause that alone scares ppl away from bots
like I said, a check woudln't work for my use case because each channel it uses set_permissions on is a unique brand-new channel
I know, that's why I was really hoping there was another way to do it
if the bot is creating the chanenl
then you can do it as long as it has manage channel perms
cause it's the bots channel
are u creating it in a category that has overwrites?
nope
does your bot grant the manage_permissions role?
to someone else I mean
is that its purpose
bc I think the disconnect here is while normally it would work with manage_roles or manage_channels, to specifically grant a permission the bot needs to have that specific permission
is what my bot default perms are
that's not really what I was asking
you've said you do a check
what do you need the check for
are you doing the same thing I'm doing
but you need the manage_channel perm to begin with if ur creating channels
right
as I've seen in the internal code, manage_permissions equals to manage_roles since it's an alias
my bot definitely has manage_roles
i dont think it does because by default my bot hs that perm and the check still fails.
still can't grant somebody manage_permissions
can i see ur code?
I already sent the permissions, here's the snippet of what isn't working
# create channel
if type == "# Text":
channel = await server.create_text_channel(title, topic=f"{description}Created by {user}", category=category)
elif type == "🔊 Voice":
channel = await server.create_voice_channel(title, category=category)
# set permissions
await channel.set_permissions(user, overwrite=ownerPermissions)```
thats whats. you are setting the overwrites after u create the channel
you need to do it as you create it
you can set overwrites when u create the channel
how?
await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., default_thread_slowmode_delay=..., default_auto_archive_duration=..., ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`TextChannel`](https://docs.disnake.dev/en/latest/api/channels.html#disnake.TextChannel "disnake.TextChannel") for the guild.
You need [`manage_channels`](https://docs.disnake.dev/en/latest/api/permissions.html#disnake.Permissions.manage_channels "disnake.Permissions.manage_channels") permission to create the channel.
The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.11)") of overwrites with the target (either a [`Member`](https://docs.disnake.dev/en/latest/api/members.html#disnake.Member "disnake.Member") or a [`Role`](https://docs.disnake.dev/en/latest/api/roles.html#disnake.Role "disnake.Role")) as the key and a [`PermissionOverwrite`](https://docs.disnake.dev/en/latest/api/permissions.html#disnake.PermissionOverwrite "disnake.PermissionOverwrite") as the value.
Note
Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://docs.disnake.dev/en/latest/api/channels.html#disnake.TextChannel.edit "disnake.TextChannel.edit") will be required to update the position of the channel in the channel list...
its a parameter
dang
in the function
I had no idea
should've read closer
alright, I'll try it and get back to you guys
wait, who would those overwrites apply to?
there's no user parameter
set_permissions has a specific parameter for target
and then overwrites is a different parameter
overwrites={
inter.guild.me: disnake.PermissionOverwrite(view_channel=False)
}
ah, thank you
yup
no dice, it's the same as setting the permissions in a separate line
won't let me do it
does it give u an error?
I have manage_channels and manage_roles
yes, disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
the error only gets called when I try to assign manage_permissions
if I comment manage_permissions out it works just fine
actually if u think ab it i think thats how it's intended to be
because unless u have admin
u cant set ur own channel permissions
yep
which makes sense
if only manage_roles actually was equivalent to manage_permissions
then it wouldn't be an issue
yeah im not sure why that's an alias because even users can't set their own permissions to a channel without admin and if u have admin u don't need to set ur permission
lol
doesn't actually make sense
i think it's more so to set permissions for other users beneath ur role
yeah true
because when the bot creates the channel it set's it own perms for it. but if you need to manage other perms for other users
it'd just be nice if there was a way to allow for this in oauth
that's where the check would come in
how so
at that point just make the server administrator make the channel for the user
they try to create the channel, it fails because of perms, they give the bot the perms and try again, done?
the issue isnt creating the channel, it's giving somebody perms in that channel
manage_permissions isn't in oauth
it only applies to channels
so my bot can only have manage_permissions if an admin grants it in a specific channel
which they can't do without the channel having been created before
I guess I technically could do it in category permissions
I may look into that
I don't think the situation would be any different tbh
that way when the channel is created my bot has manage_permissions
and it can then give the user manage_permissions
it'd still be a pain, the admin would have to set it for every single category manually
you can still set permissions
for ppl
in channels lol
without that perm while ur creating the channel. it just has to be beneath ur role
that's what manage_roles is for
I dont catch your meaning
I just checked, you can give the bot manage_permissions in categories
but is that better than just giving the bot administrator in oauth?
one is a lot of work for the server owner, and the other is a lot of trust from the server owner
yeah probably best bet
before creating the channel is to make sure the bot has manage_permissions for that category its creating the channel in
actually weird you cant even set the perms in overwrite while creating the channel even if the bots role is higher
I don't think the height of the role matters for this, since it's channel permissions
well it does because the you cant set someones permissions for anything if their role is higher than urs
just gonna do this
when the server owner adds the bot to their server, they can decide whether they want to give it administrator, or give it manage_permissions in ever category
i just don't understand what the issue actually is
cause by discords own words
yet when the bot creates a channel it cant give other ppl the manage_channel perm that is underneath its role
unless someone specifically grants it the manage_permissions perm. it's weird
no, it makes sense
I ran into the same thing with all the other perms
like it can't give somebody the view_channel perm in a specific channel unless the bot is explicitly given view_channel in oauth
to give a perm, you have to have the same perm
oh i see what ur saying now
like if I gave the bot every perm except for manage roles it couldn't change channel perms
but if it does have manage roles
it can change channel perms
i think too tho that permission
but only the channel perms that it already has
is "newer"
yeah probably
which could be why its not in oauth