Inconsistent API Response ?

I have an Bot who should create an text channel Before creating the Channel, I check if the Bot has permission on the guild and additionally in the category I want to create the textchannel in Both of these checks return true
if (!await PermissionUtil.hasNeededDiscordPermissions(guild.members.me, PermissionsBitField.Flags.ManageChannels)) return null;
--
const missingPermissions = permissionArray.filter(permission => !member.permissions.has(permission)); --> Empty
--


if (category && !await PermissionUtil.hasNeededDiscordPermissionsInChannel(category, guild.members.me, [
PermissionsBitField.Flags.ViewChannel,
PermissionsBitField.Flags.ManageChannels,
])) return null;
--
const missingPermissions = permissionArray.filter(permission => !channel.permissionsFor(member, true)?.has(permission)); --> Empty
--
if (!await PermissionUtil.hasNeededDiscordPermissions(guild.members.me, PermissionsBitField.Flags.ManageChannels)) return null;
--
const missingPermissions = permissionArray.filter(permission => !member.permissions.has(permission)); --> Empty
--


if (category && !await PermissionUtil.hasNeededDiscordPermissionsInChannel(category, guild.members.me, [
PermissionsBitField.Flags.ViewChannel,
PermissionsBitField.Flags.ManageChannels,
])) return null;
--
const missingPermissions = permissionArray.filter(permission => !channel.permissionsFor(member, true)?.has(permission)); --> Empty
--
If the Bot now makes the request onto the guild
return await guild.channels.create({
name: name,
type: channelType,
parent: category,
permissionOverwrites: permissions,
reason: reason,
position: position,
})
return await guild.channels.create({
name: name,
type: channelType,
parent: category,
permissionOverwrites: permissions,
reason: reason,
position: position,
})
The API returns an "Permissions missing error" even tho the Bot has both according to the previous checks ?
Missing Permissions - *******
DiscordAPIError[50013]: Missing Permissions
at handleErrors (/home/container/node_modules/@discordjs/rest/dist/index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:1128:23)
at async SequentialHandler.queueRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:959:14)
at async _REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:1272:22)
at async GuildChannelManager.create (/home/container/node_modules/discord.js/src/managers/GuildChannelManager.js:183:18)
at async #createGuildChannel (/home/container/src/Utils/Discord/ChannelUtil.js:41:16)
at async ChannelUtil.createTextChannel (/home/container/src/Utils/Discord/ChannelUtil.js:95:16)
at async TicketChannelHandler.createTicketChannel (/home/container/src/Modules/Ticket/Handler/TicketChannelHandler.js:81:16)
at async TicketCreateHandler.createNewTicket (/home/container/src/Modules/Ticket/Handler/TicketCreateHandler.js:86:31)
Missing Permissions - *******
DiscordAPIError[50013]: Missing Permissions
at handleErrors (/home/container/node_modules/@discordjs/rest/dist/index.js:727:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.runRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:1128:23)
at async SequentialHandler.queueRequest (/home/container/node_modules/@discordjs/rest/dist/index.js:959:14)
at async _REST.request (/home/container/node_modules/@discordjs/rest/dist/index.js:1272:22)
at async GuildChannelManager.create (/home/container/node_modules/discord.js/src/managers/GuildChannelManager.js:183:18)
at async #createGuildChannel (/home/container/src/Utils/Discord/ChannelUtil.js:41:16)
at async ChannelUtil.createTextChannel (/home/container/src/Utils/Discord/ChannelUtil.js:95:16)
at async TicketChannelHandler.createTicketChannel (/home/container/src/Modules/Ticket/Handler/TicketChannelHandler.js:81:16)
at async TicketCreateHandler.createNewTicket (/home/container/src/Modules/Ticket/Handler/TicketCreateHandler.js:86:31)
Am I doing something wrong or is this an discord error ? FYI: If I give the Bot administrator it works like a charm, if he only has ManageChannel, ViewChannel and ManageRoles it wont work Discord.js: 14.17.3 Node: 20.10.0
2 Replies
d.js toolkit
d.js toolkit6d ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Rivera
Rivera4d ago
asdfafs

Did you find this page helpful?