Access error using a channel deletion method

Yo. When I add my bot to the guild I request ManageChannels & ManageRoles permissions. Right now on my test server I found a rather strange error.
voiceChannel.delete()
.then(() => {
// posting result to logs
})
.catch((e) => {
console.error(e);
// posting error to logs
});
voiceChannel.delete()
.then(() => {
// posting result to logs
})
.catch((e) => {
console.error(e);
// posting error to logs
});
If I right now execute this function with current perms. The channel will be successfully deleted. --- I wanted to add a command to block this channel. I execute it like this:
voiceChannel.permissionOverwrites.cache.forEach(async (perm) => {
if (perm.type == OverwriteType.Role) {
if (perm.id != interaction.guild.members.me.roles?.botRole?.id) {
channel.permissionOverwrites.edit(perm.id, { 'Connect': dbChannel.locked }).catch(() => {});
} else {
// do nothing for now
}
}
});
voiceChannel.permissionOverwrites.cache.forEach(async (perm) => {
if (perm.type == OverwriteType.Role) {
if (perm.id != interaction.guild.members.me.roles?.botRole?.id) {
channel.permissionOverwrites.edit(perm.id, { 'Connect': dbChannel.locked }).catch(() => {});
} else {
// do nothing for now
}
}
});
But after executing this command, the bot loses the ability to delete this channel.
DiscordAPIError[50001]: Missing Access
...
{
rawError: { message: 'Missing Access', code: 50001 },
code: 50001,
status: 403,
method: 'DELETE',
url: 'https://discord.com/api/v10/channels/1013544243534504067',
requestBody: { files: undefined, json: undefined }
}
DiscordAPIError[50001]: Missing Access
...
{
rawError: { message: 'Missing Access', code: 50001 },
code: 50001,
status: 403,
method: 'DELETE',
url: 'https://discord.com/api/v10/channels/1013544243534504067',
requestBody: { files: undefined, json: undefined }
}
I checked the permissions of the bot before blocking the channel - and after. Didn't notice the difference.
2 Replies
d.js docs
d.js docs3y 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.
fenya
fenyaOP3y ago
Ok. I just solved this problem. Looking at djs code I noticed all requested perms. And I did not provide myself with "Connect"
get manageable() {
...
const bitfield = VoiceBasedChannelTypes.includes(this.type)
? PermissionFlagsBits.ManageChannels | PermissionFlagsBits.Connect
: PermissionFlagsBits.ViewChannel | PermissionFlagsBits.ManageChannels;
return permissions.has(bitfield, false);
}
get manageable() {
...
const bitfield = VoiceBasedChannelTypes.includes(this.type)
? PermissionFlagsBits.ManageChannels | PermissionFlagsBits.Connect
: PermissionFlagsBits.ViewChannel | PermissionFlagsBits.ManageChannels;
return permissions.has(bitfield, false);
}
Want results from more Discord servers?
Add your server