get category name of channel

Is it possible to get the category name of a specific channel? I want to list channels for a web based auto complete and a category would be useful to display. Im currently using cached channels but with fetched channels .parent is as empty as without
6 Replies
d.js toolkit
d.js toolkit13mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Danial
Danial13mo ago
It'd be <Channel>.parent.name, can you show the code you're working with?
0x7d8
0x7d8OP13mo ago
ye, currently I have the following:
const channels = await ctr.useCache(`channels::${ctr["@"].server.id}`, () => ctr["@"].bot.execute(ctr["@"].server.discordId, (client, server) => {
const guild = client.guilds.cache.find((guild) => guild.id === server)!,
channels = guild.channels.cache.filter((channel) => channel.type === ChannelType.GuildText && channel.permissionsFor(client.user)?.has(PermissionFlagsBits.SendMessages))

return channels.map((channel) => ({ id: channel.id, name: channel.name }))
}), (t) => t(7.5).s())
const channels = await ctr.useCache(`channels::${ctr["@"].server.id}`, () => ctr["@"].bot.execute(ctr["@"].server.discordId, (client, server) => {
const guild = client.guilds.cache.find((guild) => guild.id === server)!,
channels = guild.channels.cache.filter((channel) => channel.type === ChannelType.GuildText && channel.permissionsFor(client.user)?.has(PermissionFlagsBits.SendMessages))

return channels.map((channel) => ({ id: channel.id, name: channel.name }))
}), (t) => t(7.5).s())
when adding the raw channel to the results, looking at the results parentId (and therefore parent too) is null
SpecialSauce
SpecialSauce13mo ago
Are you sure that channel has a parent? Is this for all channels?
0x7d8
0x7d8OP13mo ago
It seems to do this for all channels, yes it has a parent
Want results from more Discord servers?
Add your server