missing permissions / permissions are already granted

Hey there, my bot is not able to create a channel. As the error suggests, it is missing some kind of permission, although it already has both manage roles and manage channels permissions to create the channel with permission overwrites. Is there any possible solution?
10 Replies
d.js toolkit
d.js toolkit5mo 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!
TehPig
TehPigOP5mo ago
if (
!inter.guild.members.me.permissions.has(
PermissionsBitField.Flags.ManageChannels
)
) {
return inter.reply({
content: 'missing manage channels',
ephemeral: true,
});
}
if (
!inter.guild.members.me.permissions.has(
PermissionsBitField.Flags.ManageRoles
)
) {
return inter.reply({
content: 'missing manage roles',
ephemeral: true,
});
}

try {
channel = await inter.guild.channels.create({
name: "test",
type: 0,
parent: inter.channel.parent.id,
permissionOverwrites: [
{
id: bot.user.id,
allow: [
PermissionsBitField.Flags.ViewChannel,
PermissionsBitField.Flags.SendMessages,
PermissionsBitField.Flags.EmbedLinks,
],
},
{
id: inter.guild.id,
allow: [PermissionsBitField.Flags.ViewChannel],
},
],
});
} catch (e) {
channel = await inter.guild.channels.create({
name: "test",
type: 0,
permissionOverwrites: [
{
id: bot.user.id,
allow: [
PermissionsBitField.Flags.ViewChannel,
PermissionsBitField.Flags.SendMessages,
PermissionsBitField.Flags.EmbedLinks,
],
},
{
id: inter.guild.id,
allow: [PermissionsBitField.Flags.ViewChannel],
},
],
});

return inter.reply({
content: 'unable to set parent',
ephemeral: true,
});
}
if (
!inter.guild.members.me.permissions.has(
PermissionsBitField.Flags.ManageChannels
)
) {
return inter.reply({
content: 'missing manage channels',
ephemeral: true,
});
}
if (
!inter.guild.members.me.permissions.has(
PermissionsBitField.Flags.ManageRoles
)
) {
return inter.reply({
content: 'missing manage roles',
ephemeral: true,
});
}

try {
channel = await inter.guild.channels.create({
name: "test",
type: 0,
parent: inter.channel.parent.id,
permissionOverwrites: [
{
id: bot.user.id,
allow: [
PermissionsBitField.Flags.ViewChannel,
PermissionsBitField.Flags.SendMessages,
PermissionsBitField.Flags.EmbedLinks,
],
},
{
id: inter.guild.id,
allow: [PermissionsBitField.Flags.ViewChannel],
},
],
});
} catch (e) {
channel = await inter.guild.channels.create({
name: "test",
type: 0,
permissionOverwrites: [
{
id: bot.user.id,
allow: [
PermissionsBitField.Flags.ViewChannel,
PermissionsBitField.Flags.SendMessages,
PermissionsBitField.Flags.EmbedLinks,
],
},
{
id: inter.guild.id,
allow: [PermissionsBitField.Flags.ViewChannel],
},
],
});

return inter.reply({
content: 'unable to set parent',
ephemeral: true,
});
}
Mark
Mark5mo ago
what's the full error including stack
TehPig
TehPigOP5mo ago
that's all i get
No description
Mark
Mark5mo ago
There's more below it because that last line is cropped It should include the API path
TehPig
TehPigOP5mo ago
the last line just shows the line of the code which is this part
} catch (e) {
>>> channel = await inter.guild.channels.create({
} catch (e) {
>>> channel = await inter.guild.channels.create({
the error stops there it has all 3 sending messages in other channels with embeds works fine
TehPig
TehPigOP5mo ago
i got the extra part
No description
TehPig
TehPigOP5mo ago
PermissionsBitField { bitfield: 1808015873801975n } ? yes
TehPig
TehPigOP5mo ago
No description
TehPig
TehPigOP5mo ago
it creates the channel, but it does not set the permissions i take that back, it succeeds the parent seems to be the issue PermissionsBitField { bitfield: 1808015873800951n } alright, is there any way i can simplify that bitfield into permission names, for better understanding on my end?
Want results from more Discord servers?
Add your server