SbekS
SbekS

Reputation: 30

JS Discord Bot - Creating Channel With Specific Permissions ( v12+ )

I am currently writing a discord bot and i need it to create channel with specific permissions.

For example @everyone shouldn't have view_channel permission. What i have tried :

message.guild.channels.create("Channel Name", { type: "voice" })
                .then((newChannel) => { newChannel.overwritePermissions(
                        everyone.id,
                        {
                            VIEW_CHANNEL: false
                        });
                })

It creates the channel but permissions doesn't changing...
I am using "discord.js v12+" module.

Upvotes: 1

Views: 8174

Answers (1)

Vinicius
Vinicius

Reputation: 324

You can pass in the permissions when creating the channel

let everyoneRole = msg.guild.roles.cache.find(r => r.name === '@everyone');

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

Upvotes: 3

Related Questions