Kai Kim
Kai Kim

Reputation: 15

How to get category ID from category name in Discord.js

How would I get the category ID from the Category Name? Im using discord.js 11.6.4. Currently I have

let category = message.guild.channels.find(cat=> cat.name === categoryName)

This currently on returns the category name based on the name, which is dumb. How would I find the ID using the name?

Upvotes: 1

Views: 9000

Answers (1)

Syntle
Syntle

Reputation: 5174

You can just use category.id since you've defined it as a variable.

Also, that could return any type of GuildChannel so if you want it to strictly be a category check it using if (category.type === "category")

Upvotes: 2

Related Questions