Discord.messageembed Is Not A Constructor
So recently I tried adding a command handler into my discord bot. All the commands that had Embeds came up with the error 'Discord.MessageEmbed is not a constructor'. this only hap
Solution 1:
It seems you're (not) passing down a Discord
variable to your execute
method and mix new Discord.MessageEmbed()
and new MessageEmbed()
(the one you're require
ing from discord-js
). Try to replace all new Discord.MessageEmbed()
with newMessageEmbed()
and it should work.
const { MessageEmbed } = require('discord.js');
module.exports = {
name: 'help',
description: 'Sets up a dynamic help message!',
asyncexecute(message, args, Discord, client) {
const purge = ':one:';
const music = ':two:';
const ban = ':three:';
const purgeembed = newMessageEmbed()
.setColor('RANDOM')
.setTitle('purge info')
.setDescription(
'this is a embed for more info about the purge command and how to use it',
)
.addFields(
{
name: ' ',
value:
'`this command allows a user to purge (delete) messages that are less than 14 days old`',
inline: true,
},
{ name: ' ', value: '%purge [number of messages < 1000]' },
)
.setFooter('check bellow for how it works 🔽 [unfinished]');
const musicembed = newMessageEmbed()
.setColor('RANDOM')
.setTitle('music info')
.setDescription(
'this is a embed for more info about the music command and how to use it',
)
.addFields(
{
name: ' ',
value:
'`this command allows a user to listen to music in a voice channel with alot of options like playing music from a link or by searching for the song through yt there is also a Queuing for music`',
inline: true,
},
{ name: ' ', value: '`assoiciated commands:`' },
{ name: ' ', value: '`......`', inline: true },
{ name: ' ', value: '`......`', inline: true },
{ name: ' ', value: '`......`', inline: true },
{ name: ' ', value: '`......`', inline: true },
{ name: ' ', value: '`......`', inline: true },
{ name: ' ', value: '`%...`' },
)
.setFooter('check bellow for how it works 🔽 [unfinished]');
const banembed = newMessageEmbed()
.setColor('RANDOM')
.setTitle('ban info')
.setDescription(
'this is a embed for more info about the ban command and how to use it',
)
.addFields(
{
name: ' ',
value: '`this command allows a moderator to ban a user`',
inline: true,
},
{
name: ' ',
value:
'`you can ban a user if you are a moderator but you need to give a reason to the owner first`',
},
{ name: ' ', value: '`%ban @user`' },
)
.setFooter('check bellow for how it works 🔽 [unfinished]');
let embed = newMessageEmbed()
.setColor('RANDOM')
.setTitle('Choose a reaction for more info about a command!')
.setDescription(
'Choosing a reaction will allow you to get more info about a specific command!\n\n' +
`${purge} for purge help\n\n` +
`${music} for music help\n\n` +
`${ban} for ban help\n\n`,
);
message.channel.send(embed).then((embedMessage) => {
embedMessage.react('1️⃣');
embedMessage.react('2️⃣');
embedMessage.react('3️⃣');
});
message.client.on('messageReactionAdd', (reaction, user) => {
if (user.id === '795613081295650837') {
} else {
if (reaction.emoji.name === '1️⃣') {
message.channel.bulkDelete(1);
setTimeout(function () {
message.channel.send(purgeembed);
}, 600);
}
if (reaction.emoji.name === '2️⃣') {
message.channel.bulkDelete(1);
setTimeout(function () {
message.channel.send(musicembed);
}, 600);
}
if (reaction.emoji.name === '3️⃣') {
message.channel.bulkDelete(1);
setTimeout(function () {
message.channel.send(banembed);
}, 600);
} else {
return;
}
}
});
},
};
Other option is to check how you call the execute
method in the main file. If you pass Discord
as the third argument, you don't need to use const { MessageEmbed } = require('discord.js'); on top
and only use new Discord.MessageEmbed()
s everywhere.
Post a Comment for "Discord.messageembed Is Not A Constructor"