channel filter

so im updating to v14.13.0 and im having problem with the serverinfo command i had this
(`:speech_balloon: Channels (${server.channels.cache.size})`, `Categories: ${server.channels.cache.filter(x => x.type === "category").size} | Text: ${server.channels.cache.filter(x => x.type === "text").size} | Voice: ${server.channels.cache.filter(x => x.type === "voice").size}`, true)
(`:speech_balloon: Channels (${server.channels.cache.size})`, `Categories: ${server.channels.cache.filter(x => x.type === "category").size} | Text: ${server.channels.cache.filter(x => x.type === "text").size} | Voice: ${server.channels.cache.filter(x => x.type === "voice").size}`, true)
and it worked, but now that i updated i made this
const categories = channels.filter(x => x.type === "category").size
const text = channels.filter(x => x.type === "text").size
const voice = channels.filter(x => x.type === "voice").size
console.log(categories, text, voice)
const categories = channels.filter(x => x.type === "category").size
const text = channels.filter(x => x.type === "text").size
const voice = channels.filter(x => x.type === "voice").size
console.log(categories, text, voice)
and everything gives me '0' but
server.channels.cache.size
server.channels.cache.size
the total channel count works, its the channel filters that aint working
5 Replies
d.js toolkit
d.js toolkit10mo 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!
Ferklen
Ferklen10mo ago
i also tried
const categories = server.channels.cache.filter(x => x.type === "GUILD_CATEGORY").size;
const text = server.channels.cache.filter(x => x.type === "GUILD_TEXT").size;
const voice = server.channels.cache.filter(x => x.type === "GUILD_VOICE").size;
console.log(categories, text, voice)
const categories = server.channels.cache.filter(x => x.type === "GUILD_CATEGORY").size;
const text = server.channels.cache.filter(x => x.type === "GUILD_TEXT").size;
const voice = server.channels.cache.filter(x => x.type === "GUILD_VOICE").size;
console.log(categories, text, voice)
and its still '0' i have this above
var server = message.guild;
const channels = await server.channels.fetch();
await server.channels.fetch();
var server = message.guild;
const channels = await server.channels.fetch();
await server.channels.fetch();
duck
duck10mo ago
that'd be because channel types are numbers now, and a number will never be strictly equal to a string if you haven't already, consider checking out the update guide
d.js docs
d.js docs10mo ago
guide Additional Information: Updating from v13 to v14 - Breaking Changes > Removal of method-based type guards read more
Ferklen
Ferklen10mo ago
ty