Home > Mobile >  DiscordJS Error, Embed Message Within Command Handler
DiscordJS Error, Embed Message Within Command Handler

Time:03-14

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');
        }
    }
};```

CodePudding user response:

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.

  • Related