gpt4 book ai didi

javascript - 如何修复 RichEmbed Discord.js

转载 作者:行者123 更新时间:2023-12-01 21:34:00 25 4
gpt4 key购买 nike

我知道这个问题存在,但即使我调查了另一个问题并且我使用了“sendEmbed”而不是“发送”,但似乎没有任何效果,如果有人可以帮助解决这个错误,我将不胜感激:)

这是我的代码:

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.RichEmbed 在 v12 中被移除。

只需使用 Discord.MessageEmbed 即可。

本质上是一样的。只是一个新名字。

新文档:https://discord.js.org/#/docs/main/v12/class/MessageEmbed

关于javascript - 如何修复 RichEmbed Discord.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62199891/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com