Is there a quick and easy way to get a channels name by id?
this code drops an error so ig im doing it wrong
10 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!
- ✅
Marked as resolved by staffwell
message.channel
is already the channel, not an idwhen i log it its an id
but you can get a channel by id with
<Client>.channels.cache.get(<id>)
it definitely shouldn't be and your error suggests otherwisehmm
weird
well in this case you appear to be stringifying the channel object
it is weird that the first log isn't a channel mention
but in general your error behaves as expected for the expected value of
<Message>.channel
so this will return an actual channel/thread name instead of a mention right?
no, the channel cache contains
Channel
objects
you can access <GuildBasedChannel>.name
for non-dm channelsoh, its actually that easy 🙂 nice finally its working