Panda
Panda
DIAdiscord.js - Imagine an app
Created by Panda on 3/3/2025 in #djs-questions
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
3 replies
DIAdiscord.js - Imagine an app
Created by Panda on 1/3/2025 in #djs-questions
Formatting Discord Response Messages
Is there a way to modify the responses from Discord API wrapped by DiscordJS
GET /guilds/xxx/channels null -> 503 - Service Unavailable
GET /guilds/xxx/channels null -> 503 - Service Unavailable
If its possible, is there a way to define messages based on error code or URL patterns ?
9 replies