Reputation: 45
I have channel name, and want to find its id, and send a message in there. I have tried using both
bot.channels.cache.get('name', 'channel name here');
and
bot.channels.find('name', 'channel name here');
but neither of them seem to work. find()
returns an error "bot.channels.find is not a function", while cache.get()
returns nothing. Help?
Also, I have not been able to find any similar question with a working answer in here.
EDIT: I learned that cache.get()
requires the channel id, not its name. Still can't find out how to get channel id by its name though.
Upvotes: 1
Views: 9351
Reputation:
For v12:
bot.channels.cache.find(channel => channel.name === "channel_name_here");
<Collection>.find()
takes in a callback where each value of the collection is given.
With the upper code it gives us each channel object and we check if the name of that channel equals "channel_name_here"
Upvotes: 2