Akak72
Akak72

Reputation: 13

Discord.js specific channel

I have such a problem that I want to send a message via the bot only to a given channel. How can I do this?

Client.channels.cache.get(id).send(text)

This don't work

Upvotes: 0

Views: 56

Answers (1)

Giuliopime
Giuliopime

Reputation: 1187

You can do like so with discord.js v12:

let channel  = client.guilds.cache.get('ID_of_the_guild_in_which_the_channel_is_in').channels.cache.get('channel_ID');
if(channel) channel.send('your message');

Upvotes: 2

Related Questions