How do I send Discord Embed?

I have a code that sends Discord Embed however does not see the MessageEmbed namespace what could be wrong?
// Import the necessary modules
const { Client, IntentsBitField, Partials, MessageEmbed } = require('discord.js');

// Create a new instance of a Discord client
const client = new Discord.Client();

// Define your bot's token here
const token = 'bottoken';

// Set up an event listener for when the bot is ready
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});

// Set up an event listener for incoming messages
client.on('messageCreate', async message => {
// Ignore messages from bots
if (message.author.bot) return;

// Create a new embedded message
const embed = new MessageEmbed()
.setColor('#0099ff') // Set the color of the embed
.setTitle('Example Embed') // Set the title of the embed
.setDescription('This is an example of an embedded message.') // Set the description of the embed
.setImage('https://example.com/image.png') // Set an image for the embed
.setTimestamp(); // Add a timestamp to the embed

// Send the embedded message to the same channel
message.channel.send(embed);
});

// Log in to Discord with your app's token
client.login(token);
// Import the necessary modules
const { Client, IntentsBitField, Partials, MessageEmbed } = require('discord.js');

// Create a new instance of a Discord client
const client = new Discord.Client();

// Define your bot's token here
const token = 'bottoken';

// Set up an event listener for when the bot is ready
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});

// Set up an event listener for incoming messages
client.on('messageCreate', async message => {
// Ignore messages from bots
if (message.author.bot) return;

// Create a new embedded message
const embed = new MessageEmbed()
.setColor('#0099ff') // Set the color of the embed
.setTitle('Example Embed') // Set the title of the embed
.setDescription('This is an example of an embedded message.') // Set the description of the embed
.setImage('https://example.com/image.png') // Set an image for the embed
.setTimestamp(); // Add a timestamp to the embed

// Send the embedded message to the same channel
message.channel.send(embed);
});

// Log in to Discord with your app's token
client.login(token);
ReferenceError: MessageEmbed is not defined
at Client.<anonymous> (D:\KJPiTechnologes\discordbots\moderator\src\index.js:69:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

TypeError: MessageEmbed is not a constructor
at Client.<anonymous> (D:\KJPiTechnologes\discordbots\moderator\src\index.js:69:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
ReferenceError: MessageEmbed is not defined
at Client.<anonymous> (D:\KJPiTechnologes\discordbots\moderator\src\index.js:69:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

TypeError: MessageEmbed is not a constructor
at Client.<anonymous> (D:\KJPiTechnologes\discordbots\moderator\src\index.js:69:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
5 Replies
d.js toolkit
d.js toolkit17mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
treble/luna
treble/luna17mo ago
its EmbedBuilder also thats chatgpt isnt it thats v12 code, combined with v13
d.js docs
d.js docs17mo ago
guide Home: What's new read more
treble/luna
treble/luna17mo ago
follow that and if you dont know any js, #resources
Dmitry Batkovich
Dmitry BatkovichOP17mo ago
thanks working
Want results from more Discord servers?
Add your server