#Bot can't give manage_permission in a channel without administrator permissions.

1 messages · Page 1 of 1 (latest)

grim carbon
#

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?

viscid mortar
#

Manage Roles permissions should do it

grim carbon
#

That's what I thought, but no dice

viscid mortar
#

I don't see manage_permission in the OAuth page

grim carbon
#

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

viscid mortar
#

what's the list of permissions your bot asks for?

grim carbon
#

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

rain shard
#

yeah thats a permission you can't auto set on the bot

#

ppl in the guild have to assign it

grim carbon
#

I figured

#

is there any way around that?

#

or do I just set administrator in oauth

rain shard
#

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

grim carbon
#

the problem with that is my bot creates the channel and then immediately sets permissions in it

rain shard
#

as long as the bot has manage_channel persm its fine then

grim carbon
#

so I'd have to ask a server admin to give the bot permissions as it creates the channel

#

defeating the whole point

grim carbon
#

I think since it's specifically giving manage_permissions it needs to specifically have manage_permissions

rain shard
#

i think its one of those weird role/member permission type things

grim carbon
#

wdym

rain shard
#

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

grim carbon
#

what does your bot do with the permissions?

rain shard
#

no i mean this

grim carbon
#

?

rain shard
#

see how its the bots user and not the bots role

grim carbon
#

right

rain shard
#

when i set the bots role permission for manage permissions it didnt work

#

but when i did the user it worked

grim carbon
#

well you can't set manage permissions in the role can you?

rain shard
#

so then once i did that the bot set it's own perms for that channel

grim carbon
#

that's the whole issue

rain shard
#

you can

#

unless u mean the bot setting itself then no

#

that's why u need to run a check

grim carbon
#

that's what I meant

rain shard
#

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

grim carbon
grim carbon
rain shard
#

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

grim carbon
#

that didn't work for me

#

my bot has manage_channel perms as per oauth

rain shard
#

are u creating it in a category that has overwrites?

grim carbon
#

nope

#

does your bot grant the manage_permissions role?

#

to someone else I mean

#

is that its purpose

rain shard
grim carbon
#

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

rain shard
#

is what my bot default perms are

grim carbon
#

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

rain shard
#

but you need the manage_channel perm to begin with if ur creating channels

grim carbon
#

right

rain shard
#

because the bot sets it own perms

#

thats why i run the check

viscid mortar
#

as I've seen in the internal code, manage_permissions equals to manage_roles since it's an alias

grim carbon
#

my bot definitely has manage_roles

rain shard
#

i dont think it does because by default my bot hs that perm and the check still fails.

grim carbon
#

still can't grant somebody manage_permissions

rain shard
#

can i see ur code?

grim carbon
#

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)```
rain shard
#

thats whats. you are setting the overwrites after u create the channel

#

you need to do it as you create it

grim carbon
#

I didn't think that was an option

#

can you show me what you mean

rain shard
#

you can set overwrites when u create the channel

grim carbon
#

how?

junior sorrelBOT
#
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...
rain shard
#

its a parameter

grim carbon
#

dang

rain shard
#

in the function

grim carbon
#

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

rain shard
#

huh?

#

u just

#

.create_text_channel(...., overwrites=overwrites)

grim carbon
#

right

#

but are those the overwrites for @ everyone?

#

or for my bot

#

or what

rain shard
#

no u specify who they are for

#

when u do the overwrites

grim carbon
#

set_permissions has a specific parameter for target

#

and then overwrites is a different parameter

rain shard
#
overwrites={
            inter.guild.me: disnake.PermissionOverwrite(view_channel=False)
        }
grim carbon
#

ah, thank you

rain shard
#

yup

grim carbon
# rain shard yup

no dice, it's the same as setting the permissions in a separate line

#

won't let me do it

rain shard
#

does it give u an error?

grim carbon
#

I have manage_channels and manage_roles

grim carbon
#

the error only gets called when I try to assign manage_permissions

#

if I comment manage_permissions out it works just fine

rain shard
#

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

grim carbon
#

yep

rain shard
#

which makes sense

grim carbon
#

if only manage_roles actually was equivalent to manage_permissions

#

then it wouldn't be an issue

rain shard
#

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

grim carbon
#

yeah true

rain shard
#

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

grim carbon
#

it'd just be nice if there was a way to allow for this in oauth

rain shard
#

that's where the check would come in

grim carbon
#

right

#

but a check would defeat the whole point of the bot

amber sedge
#

how so

grim carbon
#

at that point just make the server administrator make the channel for the user

rain shard
#

i mean the bot can still set other peoples perms

#

just beneath it's role

amber sedge
#

they try to create the channel, it fails because of perms, they give the bot the perms and try again, done?

rain shard
#

well

#

the issue with that is the channel needs to be created first

grim carbon
#

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

amber sedge
#

I don't think the situation would be any different tbh

grim carbon
#

that way when the channel is created my bot has manage_permissions

#

and it can then give the user manage_permissions

grim carbon
rain shard
#

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

grim carbon
#

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

rain shard
#

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

grim carbon
#

I don't think the height of the role matters for this, since it's channel permissions

rain shard
#

well it does because the you cant set someones permissions for anything if their role is higher than urs

grim carbon
#

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

rain shard
#

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

grim carbon
#

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

rain shard
#

but by discords definition

#

manage roles

#

allows u to change channel perms

#

lol

grim carbon
#

well yes

#

but only perms that you have

rain shard
#

oh i see what ur saying now

grim carbon
#

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

rain shard
#

i think too tho that permission

grim carbon
#

but only the channel perms that it already has

rain shard
#

is "newer"

grim carbon
#

yeah probably

rain shard
#

which could be why its not in oauth

grim carbon
#

if there were an oauth workaround thing that allowed you to have manage perms in all channels

#

that would be exactly what I need