[英]Discordjs v14 TypeError: (intermediate value).setColor is not a function
I am trying to create a command where it returns an embedded message when /ping command is typed and I am getting this error.我正在尝试创建一个命令,当输入 /ping 命令时它会返回嵌入的消息并且我收到此错误。
.setColor("#FF0000")
^
TypeError: (intermediate value).setColor is not a function
at Object.run (C:\Users\dhart\Desktop\Projects\ExistentialThreat\commands\Info\ping.js:9:8)
at Client.<anonymous> (C:\Users\dhart\Desktop\Projects\ExistentialThreat\events\interactionCreate.js:24:9)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
My code is:我的代码是:
const { Embed } = require("discord.js");
module.exports = {
name: "ping",
description: "Returns websocket latency",
run: async (client, interaction) => {
const embed = new Embed()
.setColor("#FF0000")
.setTitle("🏓 Pong!")
.setDescription(`Latency : ${client.ws.ping}ms`)
.setTimestamp()
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` });
interaction.followUp({ embeds: [embed] });
},
};
Idk how to fix this and I would appreciate some help.我知道如何解决这个问题,我将不胜感激。
In discord.js v14 MessageEmbed
has been renamed to EmbedBuilder
.在 discord.js v14 中
MessageEmbed
已重命名为EmbedBuilder
。 As MessageEmbed
is undefined, you receive that error.由于
MessageEmbed
未定义,您会收到该错误。
const { EmbedBuilder } = require('discord.js');
const embed = new EmbedBuilder()
.setColor("#FF0000")
.setTitle("🏓 Pong!")
.setDescription(`Latency : ${client.ws.ping}ms`)
.setTimestamp()
.setFooter({
text: `Requested by ${interaction.user.tag}`,
iconURL: `${interaction.user.displayAvatarURL()}`,
});
interaction.followUp({ embeds: [embed] });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.