Home > Mobile >  Create a channel in specific category discord.js
Create a channel in specific category discord.js

Time:06-21

How can I create a channel in specific category? I tried this:

reaction.message.guild.channels.create(`ticket-${user.name}`).setParent(config.ticket_categorie)

But it created the channel at the top without any category.

CodePudding user response:

You can create a channel, and then assign it to x category like this:

reaction.message.guild.channels.create("CHANNEL_NAME")
  .then(channel => {
    channel.setParent("CATEGORY_ID");
  })
  .catch(err => {
    console.log(err)
  });

CodePudding user response:

I guess that if you use a .then in create and used setParent on the return of the create function (which is the channel) the category would be applied. This question mentions this, as well as a way of using it with the 12th version of the lib. Also you should use the category id at setParent, it seems you're using the name of the category, which could be the problem.

add channel to category

And according to this other link, you could use the parent option passed as the second parameter to the create function to provide a category id that the channel belongs: Use parent option with create

  • Related