i’m trying to get all channels and delete these channels of category in discord v14, but throw me an error:
client.channels.cache.get(…).children.forEach is not a function
client.channels.cache.get("1234567890123456")
.children.forEach(channel => {
channel.delete();
})
// client.channels.cache.get("1234567890123456") Works but didn't give me the channels.
Advertisement
Answer
CategoryChannel.children is type CategoryChannelChildManager, which doesn’t have a forEach method, so you can’t call forEach on it. CategoryChannelChildManager.cache is type Collection<Snowflake, GuildChannel>, which does has a forEach method, so you can call forEach on it.
client.channels.cache.get("1234567890123456")
.children.cache.forEach([channelId, channel]=> {
channel.delete();
})