Send message to specific channel

How can I send a message to a specific channel of my guild?
15 Replies
d.js toolkit
d.js toolkit12mo ago
- 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!
jay
jay12mo ago
1. get said channel 2. .send()
Aryxst
AryxstOP12mo ago
can you show me an example?
jay
jay12mo ago
either guild.channels.cache.get if channels are cached or guild.channels.fetch
d.js docs
d.js docs12mo ago
const channel = client.channels.cache.get("222086648706498562");
const channel = guild.channels.cache.find(channel => channel.name === "general");
const channel = client.channels.cache.get("222086648706498562");
const channel = guild.channels.cache.find(channel => channel.name === "general");
- Caches in discord.js are Collections which extend the native Map structure. - learn more
const channel = client.channels.cache.get("222086648706498562");
const channel = guild.channels.cache.find(channel => channel.name === "general");
const channel = client.channels.cache.get("222086648706498562");
const channel = guild.channels.cache.find(channel => channel.name === "general");
- Caches in discord.js are Collections which extend the native Map structure. - learn more
Aryxst
AryxstOP12mo ago
a send method doesnt exists on my channel
monbrey
monbrey12mo ago
Then it isn't a text channel
Aryxst
AryxstOP12mo ago
No description
jay
jay12mo ago
maybe provide a id?
monbrey
monbrey12mo ago
You're using TypeScript so you need to typeguard it
Aryxst
AryxstOP12mo ago
No description
Aryxst
AryxstOP12mo ago
how?
monbrey
monbrey12mo ago
Check it's type channel.type === ChannelType.GuildText Or use .isTextBased()
Aryxst
AryxstOP12mo ago
typescript...
No description
Aryxst
AryxstOP12mo ago
i forgor, ty

Did you find this page helpful?