admin管理员组文章数量:1410737
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?
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?
Share Improve this question edited Jun 4, 2020 at 17:04 GottZ 4,9471 gold badge37 silver badges47 bronze badges asked Jun 4, 2020 at 16:42 SaboSukeSaboSuke 7921 gold badge9 silver badges27 bronze badges 4- You just sent your token to everyone. I would heavily remend you to generate a new one if you do not want your bot to be used by anyone else – Tenclea Commented Jun 4, 2020 at 16:48
- doesn't really matter since I can regenerate it anytime. – SaboSuke Commented Jun 4, 2020 at 16:49
- 1 Just wanted to be sure :) – Tenclea Commented Jun 4, 2020 at 16:51
- 1 Yea I know, thanks for that :) – SaboSuke Commented Jun 4, 2020 at 16:52
2 Answers
Reset to default 7Discord.RichEmbed
got removed in v12.
just use Discord.MessageEmbed
instead.
it's essentially the same. just a new name.
new docs: https://discord.js/#/docs/main/v12/class/MessageEmbed
Discord.RichEmbed
got removed in V12
try this :
const embed = new Discord.MessageEmbed()
//l'embed
msg.channel.send(embed)
本文标签: javascriptHow to fix RichEmbed DiscordjsStack Overflow
版权声明:本文标题:javascript - How to fix RichEmbed Discord.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744272177a2598235.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论