#Channel permissions

44 messages · Page 1 of 1 (latest)

coarse zodiac
#

So I have a bot that changes a bunch of people's permission for a channel. However, I am getting the following

DiscordAPIError[50013]: Missing Permissions

However the bot does have permissions (unless it's a person higher than them)

client.channels.cache.get(game.channel)?.permissionOverwrites.set([
    { id: guildId, deny: ["ViewChannel"] }, 
    ...game.players.filter(a => !game[`player_${a}`].name.startsWith("Player") && game[`player_${a}`].status === 'Alive').map(a => ({ id: a, allow: ["SendMessages", "ViewChannel", "ReadMessageHistory"], deny: ["AddReactions", "AttachFiles"] })), 
    ...game.players.filter(a => !game[`player_${a}`].name.startsWith("Player") && game[`player_${a}`].status === 'Dead').map(a => ({ id: a, allow: ["ViewChannel", "ReadMessageHistory"], deny: ["SendMessages", "AddReactions", "AttachFiles"] }) )])

Could it be because it's trying to edit someone's permission that is higher than the bot?

pulsar auroraBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

coarse zodiac
#

Could it be because it's editing someone's permission that is higher than the bot?

worthy pond
#

The bot also needs all permissions it tries to allow/deny on that channel itself. It’s irrelevant if the person/role they allow/deny is above them or not

coarse zodiac
#

Ah

#

Hold on I'll check the code then

coarse zodiac
#

Okay I confirmed myself. When the bot has admin perms it works.

When the bot has the following perms:

["ManageChannels", "SendMessages", "AttachFiles", "ViewChannel", "ReadMessageHistory", "EmbedLinks", "AddReactions"]

For that channel, it will fail to edit the perms later on

worthy pond
#

It also needs ManageRoles to add role overwrites (like everyone role)

coarse zodiac
#

Okay, I added that. Now it's giving me the same error upon creating the channel. Previously, the channel would be created and have errors when it would edit the perms later. Now it just errors when creating the channel.

worthy pond
#

And how do you create the channel?

#

Show the full error too (because it can’t be literally the same)

coarse zodiac
#

Sure

coarse zodiac
#
    let parent = [ChannelType.PublicThread, ChannelType.PrivateThread].includes(interaction.channel.type) ? interaction.channel.parent.parentId : interaction.channel.parentId

    let channel = await interaction.guild.channels.create({
        name: "mafia",
        parent,
        type: ChannelType.GuildText,
        permissionOverwrites: [...game.players.filter(a => !game[`player_${a}`].name.startsWith("Player")).map(a => ({ id: a, allow: ["ViewChannel", "ReadMessageHistory"], deny: ["SendMessages", "AddReactions", "AttachFiles"] })), { id: client.user.id, allow: ["ManageChannels", "ManageRoles", "SendMessages", "AttachFiles", "ViewChannel", "ReadMessageHistory", "EmbedLinks", "AddReactions"] }, { id: interaction.guildId, deny: ["ViewChannel"] }]
    })
#

The only thing I'd guess is coz the bot doesn't have manage perms / manage roles in the category the bot is trying to create. However, I've ensured that the bot has the manage perms permission enabled in the category the bots trying to create the channel in

worthy pond
#

And does it also have ManageChannels and all the permissions you try to allow/deny there?

coarse zodiac
#

Bruh i forgot to turn off the pings mb

worthy pond
coarse zodiac
worthy pond
#

Is the guild owner one of the players maybe? Since you can’t deny permissions from them

#

Oh, and you can’t allow those permissions in overwrite to your bot. If it has them on the category and aren’t denied on the channel it’ll have them anyway

coarse zodiac
#

The only thing that would confuse me now is if the bot has admin, it works perfectly

coarse zodiac
#

And yes the owner does play that time (when the bot has admin)

coarse zodiac
#

Permissions the bot has in general (their role)

[
'CreateInstantInvite',   'ManageChannels',
'AddReactions',          'Stream',
'ViewChannel',           'SendMessages',
'ManageMessages',        'EmbedLinks',
'AttachFiles',           'ReadMessageHistory',
'UseExternalEmojis',     'Connect',
'Speak',                 'UseVAD',
'ChangeNickname',        'ManageNicknames',
'ManageRoles',           'UseApplicationCommands',
'RequestToSpeak',        'UseExternalStickers',
'SendMessagesInThreads', 'UseSoundboard',
'UseExternalSounds',     'SendVoiceMessages'
]```

Permissions the bot has in this category:
```js
[
'CreateInstantInvite', 'ManageChannels',
'AddReactions',        'Stream',
'ViewChannel',         'SendMessages',
'SendTTSMessages',     'ManageMessages',
'EmbedLinks',          'AttachFiles',
'ReadMessageHistory',  'UseExternalEmojis',
'Connect',             'Speak',
'UseVAD',              'ChangeNickname',
'ManageNicknames',     'ManageRoles',
'ManageWebhooks',      'UseApplicationCommands',
'RequestToSpeak',      'ManageThreads',
'CreatePublicThreads', 'CreatePrivateThreads',
'UseExternalStickers', 'SendMessagesInThreads',
'UseSoundboard',       'UseExternalSounds',
'SendVoiceMessages'
 ]
coarse zodiac
#

Bumping this. Anyone?

coarse zodiac
#

Can anyone help me solve this issue please? I really don't know what I'm doing wrong here

cloud nexus
#

Well I'd try creating a channel without assigning the user permissions. See if that works or not.

Then set user permissions to the channel and see what's causing the error. It maybe that the bot is trying to set a channel permission that it, itself does not have

coarse zodiac
#

I tried it in my test server but the bot has admin there and it works

coarse zodiac
#

Especially since I added ManageRoles to the client

cloud nexus
#

The permissions as in the player's permissions?

#

Or do you mean the bot?

coarse zodiac
#

Okay I'll summarize what happened

cloud nexus
#

Because your bot is creating a channel AND setting player permissions

coarse zodiac
#

This is the flow.

  1. Bot creates a channel, and creates user permissions at the same time
  2. After about 45 sec to 1 min it's suppose to edit the perms based on whatever action happened.
  • What happened at first (approach 1):
    When I create the channel, I give the bot the following permissions:
["ManageChannels", "SendMessages", "AttachFiles", "ViewChannel", "ReadMessageHistory", "EmbedLinks", "AddReactions"]```

This successfully creates the channel and permissions. However when I edit the permissions later (step 2), I get an error saying `Missing Permissions`

- I changed the initial permissions (approach 2):
The permissions the client has when creating the channel is the same. It just has an additional permission which is `ManageRoles`. However the bot fails to create the channel giving the error `Missing Permissions`. This has something to do with setting the user perms.
cloud nexus
coarse zodiac
#

Bot itself

coarse zodiac
cloud nexus
#

Yeah I couldn't say

#

Sorry