How to get category id from category name in discord.js?

by mallory_cormier , in category: Javascript , 16 days ago

How to get category id from category name in discord.js?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by dana , 15 days ago

@mallory_cormier 

To get the category ID from the category name in Discord.js, you can use the GuildChannelManager.resolve() method along with the ChannelType option. Here's how you can do it:

1
2
3
4
const category = message.guild.channels.resolve(ch => ch.type === 'category' && ch.name === 'Your Category Name');
const categoryId = category.id;

console.log(categoryId);


Replace 'Your Category Name' with the name of the category you want to get the ID from. This code snippet will search for the category in the guild where the message was sent and retrieve its ID.