How to send message to channel?
client.on('messageCreate', (message) => {
if (message.content === 'embed') {
const embed = new EmbedBuilder()
.setTitle('Embed title')
.setDescription('This is an embed desription')
.setColor('Random')
.addFields({
name: 'Field title',
value: 'Some random value',
inline: true,
});
//interaction.reply({ embeds: [embed] });
message.channel.send({ embeds: [embed] });
}
});
E:\Code)\DiscordBot\src\index.js:42
message.channel.send({ embeds: [embed] });
^
ReferenceError: message is not defined
at Client.<anonymous> (E:\Code)\DiscordBot\src\index.js:42:9)
at Client.emit (node:events:517:28)
at InteractionCreateAction.handle (E:\Code)\DiscordBot\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (E:\Code)\DiscordBot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (E:\Code)\DiscordBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (E:\Code)\DiscordBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12)
at WebSocketManager.emit (E:\Code)\DiscordBot\node_modules@vladfrangu\async_event_emitter\dist\index.js:282:31)
at WebSocketShard.<anonymous> (E:\Code)\DiscordBot\node_modules@discordjs\ws\dist\index.js:1173:51)
at WebSocketShard.emit (E:\Code)\DiscordBot\node_modules@vladfrangu\async_event_emitter\dist\index.js:282:31)
at WebSocketShard.onMessage (E:\Code)\DiscordBot\node_modules@discordjs\ws\dist\index.js:988:14)
Node.js v18.18.0
[nodemon] app crashed - waiting for file changes before starting..2 Replies
- 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!
- ✅
Marked as resolved by OPinteraction.channel.send()