Search code examples
node.jsdiscorddiscord.jsbotsembed

Type error; 'MessageEmbed" of undefined in discord.js


I cant understand why i am getting the error: TypeError: Cannot read property 'MessageEmbed' of undefined

Here is my code:

module.exports = {
name: 'help',
description: "this is the help command",
execute(message, args, Discord){
  const newEmbed = new Discord.MessageEmbed()
  .setColor('#304281')
  .setTitle('Commands')
  .setDescription('here are the commands'),
  .addFields(
    {name: '-help', value: 'The help command'},
    {name: '-ping', value: 'Ping pong**'}
  ),
  .setFooter('thanks for using the bot')

  message.channel.send(newEmbed);

Solution

  • I have fixed by adding a little code:

    const { MessageEmbed } = require('discord.js');
      const newEmbed = new MessageEmbed()
    

    after i did this it worked