简体   繁体   English

Discordjs v14 TypeError: (intermediate value).setColor 不是函数

[英]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.

相关问题 TypeError: (intermediate value).addField(...).setTitle(...).addFields(...).setColor(...).setThumbnail(...).addFooter is not a function - TypeError: (intermediate value).addField(…).setTitle(…).addFields(…).setColor(…).setThumbnail(…).addFooter is not a function DiscordJS v14 在嵌入中添加图像附件 - DiscordJS v14 Add Image Attachment in the embed DiscordJS v14 Slash 命令选项取决于选项 - DiscordJS v14 Slash commands option depends on option TypeError: interaction.options.getString 不是 function discord.js v14 错误 - TypeError: interaction.options.getString is not a function discord.js v14 error TypeError (discord.js v14) - SlashCommandbuilder 不是构造函数 - TypeError (discord.js v14) - SlashCommandbuilder is not a constructor TypeError:(中间值)。那么不是一个函数 - TypeError: (intermediate value).then is not a function TypeError: {(intermediate value)(intermediate value)}.then 不是函数 - TypeError: {(intermediate value)(intermediate value)}.then is not a function 错误 discord.js v14(类型错误:无法读取未定义的属性(读取“标志”)) - Erro discord.js v14 (TypeError: Cannot read properties of undefined (reading 'FLAGS')) 未捕获的类型错误:(中间值)(...)不是 function - Uncaught TypeError: (intermediate value)(...) is not a function TypeError:this [(((“ _” +(中间值))+“ _listener”)]不是函数 - TypeError: this[((“_” + (intermediate value)) + “_listener”)] is not a function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM