Channel permissions

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"] }) )])
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? ```
15 Replies
d.js toolkit
d.js toolkit2y ago
• 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.
Ashish
AshishOP2y ago
Ashish
AshishOP2y ago
Could it be because it's editing someone's permission that is higher than the bot? Ah Hold on I'll check the code then 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 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. Sure
Ashish
AshishOP2y ago
Error
Ashish
AshishOP2y ago
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"] }]
})
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 According to the admins of the server, they have given every permission for the bot in the category it's trying to create, so I'd assume yes (it also has ManageChannels as it's role permission) Bruh i forgot to turn off the pings mb Yes, and I do have 2FA (since I am the bot owner) Ah, I think this is the problem The only thing that would confuse me now is if the bot has admin, it works perfectly And yes the owner does play that time (when the bot has admin) 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'
]
[
'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:
[
'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'
]
[
'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'
]
Bumping this. Anyone? Can anyone help me solve this issue please? I really don't know what I'm doing wrong here
It's Manny
It's Manny2y ago
Have you tried it in a separate test server? 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
Ashish
AshishOP2y ago
I tried it in my test server but the bot has admin there and it works I've confirmed, it's the permissions that's causing the issue Especially since I added ManageRoles to the client
It's Manny
It's Manny2y ago
The permissions as in the player's permissions? Or do you mean the bot?
Ashish
AshishOP2y ago
Okay I'll summarize what happened
It's Manny
It's Manny2y ago
Because your bot is creating a channel AND setting player permissions
Ashish
AshishOP2y ago
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"]
["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.
It's Manny
It's Manny2y ago
Ok so just to clarify the bot crashes when you set ManageRoles permission on the user or the bot itself?
Ashish
AshishOP2y ago
Bot itself These are the list of permissions the bot has in general and in the category it's trying to create the channel in
It's Manny
It's Manny2y ago
Yeah I couldn't say Sorry
Ashish
AshishOP2y ago
It's okay
Want results from more Discord servers?
Add your server