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 toolkit15mo 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
jay15mo ago
1. get said channel 2. .send()
Exefer
ExeferOP15mo ago
can you show me an example?
jay
jay15mo ago
either guild.channels.cache.get if channels are cached or guild.channels.fetch
d.js docs
d.js docs15mo 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
Exefer
ExeferOP15mo ago
a send method doesnt exists on my channel
monbrey
monbrey15mo ago
Then it isn't a text channel
Exefer
ExeferOP15mo ago
No description
jay
jay15mo ago
maybe provide a id?
monbrey
monbrey15mo ago
You're using TypeScript so you need to typeguard it
Exefer
ExeferOP15mo ago
No description
Exefer
ExeferOP15mo ago
how?
monbrey
monbrey15mo ago
Check it's type channel.type === ChannelType.GuildText Or use .isTextBased()
Exefer
ExeferOP15mo ago
typescript...
No description
Exefer
ExeferOP15mo ago
i forgor, ty

Did you find this page helpful?