Reputation: 15
I'm getting an error "MessageEmbed is not a constructor" it works with only sending a message, but not with an embed. What could be this issue?
const MessageEmbed = require('discord.js');
const { Manager } = require('erela.js');
const nodes = require('./Nodes');
module.exports = (client) => {
client.manager = new Manager({
nodes,
send(id, payload) {
const guild = client.guilds.cache.get(id);
if (guild) guild.shard.send(payload);
}
})
.on('nodeConnect', node => console.log(`Node ${node.options.identifier} connected.`))
.on('nodeError', (node, error) => console.log(`Node ${node.options.identifier} had an error: ${error.message}.`))
.on('trackStart', (player, track) => {
client.channels.cache
.get(player.textChannel)
.send(new MessageEmbed().setDescription(`Now playing: \`${track.title}\``).setColor('ORANGE'));
})
.on('queueEnd', (player) => {
client.channels.cache
.get(player.textChannel)
.send(new MessageEmbed().setDescription('The queue has ended. Leaving the channel.').setColor('ORANGE'));
player.destroy();
});
};
Upvotes: 1
Views: 1615
Reputation: 737
const MessageEmbed = require("discord.js")
is incorrect. The correct way is:
const { MessageEmbed } = require("discord.js")
Note the {}
. The curly braces are a destructuring assignment. When you import or require discord.js, it is importing an object with everything in discordjs. By using destructuring assignment, you are only picking out the parts you require.
Upvotes: 1