Home > Net >  Discord.js channel manage channel permissions
Discord.js channel manage channel permissions

Time:09-28

I'm having a little issue creating a new channel. I want to create a new channel using the following code:

message.guild.channels.create('channel name', {
  type: 'voice',
  permissionOverwrites: [
     {
       id: some_id,
       deny: ['VIEW_CHANNEL'],
    },
{
       id: bot_id,
       deny: ['MANAGE_CHANNEL'],
    },
  ],
})

However, I'm getting an error saying the bitfield of manage channel is invalid. I have tried to lookup a list of channel permissions but I couldn't find any.

Error : [Symbol(code)]: 'BITFIELD_INVALID'

Can anyone help me ?

CodePudding user response:

const { ChannelType, PermissionsBitField } = require('discord.js');

guild.channels.create({
    name: 'new-channel',
    type: ChannelType.GuildText,
    permissionOverwrites: [
        {
            id: interaction.guild.id,
            deny: [PermissionsBitField.Flags.ViewChannel],
        },
        {
            id: interaction.user.id,
            allow: [PermissionsBitField.Flags.ViewChannel],
        },
    ],
});

Discord.js@v14 has change all BitField check it out this link: https://discordjs.guide/popular-topics/permissions.html#adding-overwrites

  • Related