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 toolkit9mo 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
jay9mo ago
1. get said channel 2. .send()
Aryxst
AryxstOP9mo ago
can you show me an example?
jay
jay9mo ago
either guild.channels.cache.get if channels are cached or guild.channels.fetch
d.js docs
d.js docs9mo 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
AryxstOP9mo ago
a send method doesnt exists on my channel
monbrey
monbrey9mo ago
Then it isn't a text channel
Aryxst
AryxstOP9mo ago
No description
jay
jay9mo ago
maybe provide a id?
monbrey
monbrey9mo ago
You're using TypeScript so you need to typeguard it
Aryxst
AryxstOP9mo ago
No description
Aryxst
AryxstOP9mo ago
how?
monbrey
monbrey9mo ago
Check it's type channel.type === ChannelType.GuildText Or use .isTextBased()
Aryxst
AryxstOP9mo ago
typescript...
No description
Aryxst
AryxstOP9mo ago
i forgor, ty
Want results from more Discord servers?
Add your server