#missing permissions / permissions are already granted

32 messages · Page 1 of 1 (latest)

river fossil
#

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?

spare sandBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • 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!
river fossil
#
      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,
        });
      }```
wild swift
#

what's the full error including stack

river fossil
#

that's all i get

wild swift
#

There's more below it because that last line is cropped

#

It should include the API path

river fossil
#

the last line just shows the line of the code

#

which is this part

      } catch (e) {
>>>        channel = await inter.guild.channels.create({
#

the error stops there

viral siren
#

Your bot is missing one of the three permissions you try to add as allow overwrite there. Your bot can’t allow itself a permission it doesn’t already have

river fossil
#

it has all 3

#

sending messages in other channels with embeds works fine

river fossil
#

i got the extra part

viral siren
river fossil
#

PermissionsBitField { bitfield: 1808015873801975n }

river fossil
#

?

viral siren
river fossil
#

yes

viral siren
river fossil
viral siren
#

console.log(inter.guild.members.me.permissionsIn('841311039462572053') then

river fossil
#

it creates the channel, but it does not set the permissions

#

i take that back, it succeeds

viral siren
river fossil
#

the parent seems to be the issue

river fossil
#

PermissionsBitField { bitfield: 1808015873800951n }

viral siren
#

Yup, your bot is missing ViewChannel permissions on that

#

That’s why it can‘t grant that permission to anyone (including itself) to a child of that category

river fossil
#

alright, is there any way i can simplify that bitfield into permission names, for better understanding on my end?