Javascript 如何修复RichEmbed Discord.js
我知道这个问题存在,但尽管我研究了另一个问题,并使用了“sendEmbed”而不是“send”,但似乎没有任何效果,如果有人能帮助解决此错误,我将不胜感激:) 这是我的代码:Javascript 如何修复RichEmbed Discord.js,javascript,discord,discord.js,Javascript,Discord,Discord.js,我知道这个问题存在,但尽管我研究了另一个问题,并使用了“sendEmbed”而不是“send”,但似乎没有任何效果,如果有人能帮助解决此错误,我将不胜感激:) 这是我的代码: const Discord = require('discord.js'); const bot = new Discord.Client(); const token = "Removed For Security"; const PREFIX = "!"; bot.on('ready', () => {
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);
这就是错误:
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)
正如您可以看到的,错误在RichEmbed构造函数中,我的Discord.js版本也是“12.2.0”,有什么想法吗?
Discord.richmbed
在v12中被删除
只需使用Discord.MessageEmbed
本质上是一样的。只是一个新名字
新文档:
Discord.RichEmbed
已在V12中删除
试试这个:
const embed = new Discord.MessageEmbed()
//l'embed
msg.channel.send(嵌入)您刚刚向所有人发送了您的令牌。如果你不想让其他人使用你的机器人,我强烈建议你生成一个新的机器人。这并不重要,因为我可以随时重新生成它。只是想确定:)是的,我知道,谢谢:)你在点击提交之前注意到了我的答案,对吗?:D