SaboSuke
SaboSuke

Reputation: 792

How to fix RichEmbed Discord.js

I know the question exists but even though I looked into the other question and i used 'sendEmbed' instead of 'send' but nothing seems to work, if anyone can help with this error I'll be grateful :)

this is my code:

const Discord = require('discord.js');
const bot = new Discord.Client();
const token = "Removed For Security";

const PREFIX = "!";

bot.on('ready', () => {
    console.log("Bot is online");
})

bot.on('message', (msg) => {
    let args = msg.content.substring(PREFIX.length).split(" ");

    switch (args[0]) {
        case 'ping':
            msg.channel.send("pong!")
            break;
        case 'clear':
            if (!args[1])
                return msg.reply('Error please define second argument');
            msg.channel.bulkDelete(args[1]);
            break;
        case 'embed': {
            const embed = new Discord.RichEmbed()
                .addField('Player Name', msg.author.username)
            msg.channel.send(embed)
            break;
        }
    }
})

bot.login(token);

and this is the error:

C:\Users\isam\Desktop\discord bot\index.js:24
            const embed = new Discord.RichEmbed()
                          ^

TypeError: Discord.RichEmbed is not a constructor
    at Client.bot.on (C:\Users\isam\Desktop\discord bot\index.js:24:27)
    at Client.emit (events.js:193:13)
    at MessageCreateAction.handle (C:\Users\isam\Desktop\discord bot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
    at Object.module.exports [as MESSAGE_CREATE] (C:\Users\isam\Desktop\discord bot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
    at WebSocketManager.handlePacket (C:\Users\isam\Desktop\discord bot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
    at WebSocketShard.onPacket (C:\Users\isam\Desktop\discord bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
    at WebSocketShard.onMessage (C:\Users\isam\Desktop\discord bot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
    at WebSocket.onMessage (C:\Users\isam\Desktop\discord bot\node_modules\ws\lib\event-target.js:125:16)
    at WebSocket.emit (events.js:193:13)
    at Receiver.receiverOnMessage (C:\Users\isam\Desktop\discord bot\node_modules\ws\lib\websocket.js:800:20)

As you can see the error is in RichEmbed constructor, also my Discord.js version is '12.2.0', Any ideas?

Upvotes: 2

Views: 5796

Answers (2)

Picsou
Picsou

Reputation: 24

Discord.RichEmbed got removed in V12

try this :

const embed = new Discord.MessageEmbed()

//l'embed

msg.channel.send(embed)

Upvotes: 0

GottZ
GottZ

Reputation: 4947

Discord.RichEmbed got removed in v12.

just use Discord.MessageEmbed instead.

it's essentially the same. just a new name.

new docs: https://discord.js.org/#/docs/main/v12/class/MessageEmbed

Upvotes: 7

Related Questions