How to get all channels in a guild?
it looks like there is no way to get all channels in a guild, some posts were referring to .cache but thats not a real solution, how can i do it?
44 Replies
- 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!Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
ye but then not all of the channels show up, only channels where messages were sent
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
really?
oh
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
so... i tried it and not all channels show up, most likely because they arent yet cached?
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
gimme a sec ill try again
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
oh okay
looks like it gives me only some general information about the dc server
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
That would be the manager, message.guild.channels.cache would show more information
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
wich one do you mean?
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
ah yes, message.guild.channels.cache shows a big amount of information, it sent also every thread
so not the channels 😦
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
edit: both, i have both, threads and channels
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
is it that you're looking for a collection of guild channels excluding threads?
yes
threads arent even channels are they?
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
and because they are, you'd want to filter the channel cache with
<Guild>.channels.cache.filter()
you're free to specifically check <Channel>.isThread()
or check for specific types by checking <Channel>.type
in case you weren't aware, categories are also channels, so if you were specifically just looking for text/voice channels, you'll want to filter those out as wellso isThread() gives me only threads right?
yes, so presumably you'd want to check that its not a thread
ye
smth like isTextchannel()?
are you only looking for text channels?
text and voice channels
im trying to modify their names
well you're likely also going to run into issues bulk editing channels
what exactly is all this for?
oh no...
im working on a bot that can apply themes and stuff for example adding an icon in front of every channel name
Yeah, that can get you rate limited real quickly
Channel renaming rate limit is very high
how high exactly? have no problem with putting a few seconds/minutes between each edit
Twice every 10 minutes
thats acceptable
so any idea how i can get text and voice channels?
You can filter using channel.type and ChannelType enum
yeah but isn't that per channel
even putting that aside, attempting to edit every channel in a guild has the potential to hit the global rate limit
what's the global rate limit?
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View