I'm a beginner at coding. I'm making a node.js today, and it says there's a problem with the embed. I don't know why, but it doesn't work even if I use someone else's code. How should I solve this?
const { Permissions , MessageActionRow , MessageSelectMenu , MessageEmbed,Discord} = require('discord.js')
module.exports = {
name: 'command',
description: 'Embeds',
execute(message, args, Discord)
{
const newEmbed = new Discord.MessageEmbed()
.setColor('#ff0000')
.setTitle('Yes')
.setDescription('My Embed')
.setFooter('life is a lie');
interaction.channel.send({embeds : [embed]})
},
};
This happens. FYI, I shared the code in the Commandz folder, and the index folder had the same error, so I uploaded it. Help me!
CodePudding user response:
from your code:
const newEmbed = new Discord.MessageEmbed()
.setColor('#ff0000')
.setTitle('Yes')
.setDescription('My Embed')
.setFooter('life is a lie');
interaction.channel.send({embeds : [embed]})
change your Discord.MessageEmbed()
to MessageEmbed
since you type from your module as MessageEmbed
.
CodePudding user response:
You added a const function to newEmbed like this:
const newEmbed = new Discord.MessageEmbed()
But, you put interaction.channel.send({embeds : [embed]})
instead of interaction.channel.send({embeds : [newEmbed]})
What this did was it basically just used the const function and read its value. The embeds
part is always supposed to be the same, but the [newEmbed]
part should always be what you declared in your const function for the embed. Remember that for future embeds.
Here's your code modified by me:
const { Permissions , MessageActionRow , MessageSelectMenu , MessageEmbed, Discord } = require('discord.js');
module.exports = {
name: 'command',
description: 'Embeds',
execute(message, args, Discord)
{
const newEmbed = new MessageEmbed()
.setColor('#ff0000')
.setTitle('Yes')
.setDescription('My Embed')
.setFooter('life is a lie');
interaction.channel.send({embeds : [newEmbed]})
},
};
Have a good day!