Reputation: 11
I'm trying to make an embed message using discord.js, but it doesn't work.
Here's my code:
client.on('message', message => {
if (message.content === 'how to embed') {
const embed = new MessageEmbed()
.setTitle('A slick little embed')
.setColor(0xff0000)
.setDescription('Hello, this is a slick embed!');
message.channel.send(embed);
}
});
Upvotes: 1
Views: 783
Reputation: 15
First of all you need to import or require the discord.js const discord = require('discord.js');
then
let embed = new discord.MessageEmbed()
//your embed settings
then you can send the embed.
Upvotes: 0
Reputation: 1
Change MessageEmbed() to Discord.MessageEmbed()
And make sure you have const Discord = require(‘discord.js’)
Upvotes: 0
Reputation: 1
Should be this:
const Discord = require("discord.js")
client.on('message', message => {
if (message.content === 'how to embed') {
const embed = new Discord.MessageEmbed()
.setTitle('A slick little embed')
.setColor(0xff0000)
.setDescription('Hello, this is a slick embed!');
message.channel.send(embed);
}
});
You were missing Discord.
MessageEmbed()
Upvotes: 0
Reputation: 656
In this code, you have to define the MessageEmbed. If you just used const Discord = require('discord.js');
, it will throw a ReferenceError that MessageEmbed is not defined. try new Discord.MessageEmbed()
or add const { MessageEmbed } = require('discord.js');
at the top of your code. It will work.
PS: Well I also had that problem when I first started discord.js bot
Upvotes: 3