I am trying to print get embed message in discord, but this happens:
TypeError: Discord.RichEmbed is not a constructor
Here is my code:
const Discord = require('discord.js');
const bot = new Discord.Client();
const token = 'mytokenhere';
const prefix = '!';
bot.on('ready', () => {
console.log('This bot is online!');
});
bot.on('message', message => {
let args = message.content.substring(prefix.length).split(" ");
switch(args[0]) {
case 'pomoc':
message.channel.send('.')
break;
case 'cc':
if(!args[1]) return message.reply('Podaj 2 argument! (liczbe wiadomosci do skasowania)')
message.channel.bulkDelete(args[1]);
break;
case 'embed':
var embed = new Discord.RichEmbed()
.setAuthor(message.author.username)
.setDescription("Usuario rikolino.")
.setColor("#3535353")
.addField("Usuario", '${message.author.username}#${message.author.discriminator}')
.addField("ID", message.author.id)
.addField("Creación", message.author.createdAt);
message.channel.send({embed});
break;
}
});
bot.login(token);
I tried many other solutions, but the result is always the same, I really don't know where the problem is.
I am trying to print get embed message in discord, but this happens:
TypeError: Discord.RichEmbed is not a constructor
Here is my code:
const Discord = require('discord.js');
const bot = new Discord.Client();
const token = 'mytokenhere';
const prefix = '!';
bot.on('ready', () => {
console.log('This bot is online!');
});
bot.on('message', message => {
let args = message.content.substring(prefix.length).split(" ");
switch(args[0]) {
case 'pomoc':
message.channel.send('.')
break;
case 'cc':
if(!args[1]) return message.reply('Podaj 2 argument! (liczbe wiadomosci do skasowania)')
message.channel.bulkDelete(args[1]);
break;
case 'embed':
var embed = new Discord.RichEmbed()
.setAuthor(message.author.username)
.setDescription("Usuario rikolino.")
.setColor("#3535353")
.addField("Usuario", '${message.author.username}#${message.author.discriminator}')
.addField("ID", message.author.id)
.addField("Creación", message.author.createdAt);
message.channel.send({embed});
break;
}
});
bot.login(token);
I tried many other solutions, but the result is always the same, I really don't know where the problem is.
Share Improve this question edited Mar 14, 2020 at 15:35 Edric 26.8k13 gold badges87 silver badges95 bronze badges asked Mar 14, 2020 at 14:54 Szymon RudnikowskiSzymon Rudnikowski 311 gold badge1 silver badge4 bronze badges 1-
1
It looks like you should use
Discord.MessageEmbed
instead: discordjs.guide/popular-topics/… – Edric Commented Mar 14, 2020 at 15:32
4 Answers
Reset to default 7Discord.js
discord.js have update new Discord.MessageEmbed()
from new Discord.RichEmbed()
const embed = new Discord.MessageEmbed()
.setAuthor(message.author.username)
.setDescription("Usuario rikolino.")
.setColor("#3535353")
.addField("Usuario", '${message.author.username}#${message.author.discriminator}')
.addField("ID", message.author.id)
.addField("Creación", message.author.createdAt);
message.channel.send(embed);
Like Edric said, use MessageEmbed
instead:
var embed = new Discord.MessageEmbed()
.setAuthor(message.author.username)
.setDescription("Usuario rikolino.")
.setColor("#3535353")
.addField("Usuario", '${message.author.username}#${message.author.discriminator}')
.addField("ID", message.author.id)
.addField("Creación", message.author.createdAt);
message.channel.send(embed);
It looks like it's been renamed to MessageEmbed
in v12.
If you don't want to replace all of your existing code, you can use this workaround:
const { MessageEmbed: RichEmbed } = require("discord.js");
let embed = new RichEmbed().setTitle("Works the same");
Wherever you used RichEmbed();
use MessageEmbed();
instead