Skip to content
Advertisement

Does anyone know how to create and delete a category with channels in Discord.js?

I am trying to get my discord bot to create a category that has 3 distinct channels, each with different permissions. I would also like a way to delete this category entirely at the end of my code. Any idea on how to do it?

Advertisement

Answer

There are multiple ways to do it. Here are 3 of them:

Putting parent in channel create options:

guild.channels.create("chan-name", {
  parent: "123456789012345678" // the ID of the category channel
})

Using CategoryChannel#createChannel()

category.createChannel("chan-name")

And lastly, not recommended though, is assigning after creation. It’s not recommended as it does 2 API requests rather than 1

let channel = await guild.channels.create("chan-name")
channel.setParent("category-id")
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement