'DiscordJS Error, Embed Message Within Command Handler
I am trying to make my bot use an embed message however it will not work because i keep getting the Message not defined error
I have tried just using the author.bot but then it comes up with Author not defined, Something important to mention, I am using the command handler provided by the DiscordJS Guide and then i tried using the DiscordJS Guide for Embeds and it didnt work, thats basically how i ended up here
Code Below
const { SlashCommandBuilder } = require('@discordjs/builders');
const { MessageEmbed } = require('discord.js');
module.exports = {
data: new SlashCommandBuilder()
.setName('embed')
.setDescription('A W.I.P Embed'),
async execute(interaction) {
const Embed1 = new MessageEmbed().setTitle('Some title');
if (message.author.bot) {
Embed1.setColor('#7289da');
}
}
};```
Solution 1:[1]
This is because you are using a message object when the exported item is: interaction.
Change:
if (message.author.bot) {
Embed1.setColor('#7289da');
}
to:
if (interaction.user.bot) {
Embed1.setColor('#7289da');
}
There is no interaction.author and only a interaction.user, therefore is the only way to check if it's a bot.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Jeffplays2005 |
