2

I'm trying to make a category on discord server using Discord Bot but I couldn't find the method or something on internet. Also I looked the "discord.js.org". Then I thought that isn't there any possibility to do that. So is there any way to make a category on discord servers?

0

6 Answers 6

6

discordjs v13 needs GUILD_CATEGORY instead of just "category"

message.guild.channels.create("Name", { type: "GUILD_CATEGORY" });
4

You need to use the .createChannel method and then enter „category“ as type of the channel

<guild>.createChannel("NAME OF THE CHANNEL", "category")
0
4

I would advice the usage of a promise as it adds a lot of functionality and safety to your code

guild.createChannel('new-category', {
  type: 'category',
  permissionsOverwrites: [{
    id: guild.id,
    deny: ['MANAGE_MESSAGES'],
    allow: ['SEND_MESSAGES']
  }]
})
  .then(console.log)
  .catch(console.error);

This allows you to create the channel with permissions and actually handle any errors like the channel already existing or your bot not being able to create said channel cause of its permissions assigned.

This is the proper way to do this.

Example to create channel

guild.createChannel('new-general', { type: 'text' })
  .then(console.log)
  .catch(console.error);
2

v12:

message.guild.channels.create('Category', { type: 'category' });
0

I have made a command code for you to use. Modify it and use it.

if(message.content === `${prefix}create-channel`) {
  message.guild.createChannel('name', {
    //Channel type (text || voice || category)
    type: 'text', 
    permissionsOverwrites: [{
      id: guild.id,
      deny: [],
      allow: ['SEND_MESSAGES']
    }]
  })
  .catch(console.error);
}
0

discordjs v14 needs ChannelType.GuildCategory and the name in the options

message.guild.channels.create({ name: "Name", type: ChannelType.GuildCategory });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.