【问题标题】:how to make a command which sends an embed in a channel如何制作一个在频道中发送嵌入的命令
【发布时间】:2021-09-24 02:22:39
【问题描述】:

我正在开发一个私人不和谐机器人,使用库 discord.js。我目前正在使用replit.com 来编辑和托管机器人。我刚刚做了一个新命令,它应该在特定频道中发送嵌入。我试着做,但是当我运行它时,它给出了这个错误:

[FATAL] Possibly Unhandled Rejection at: Promise  Promise {
  <rejected> TypeError: Discord.MesageEmbed is not a constructor
      at Object.run (/home/runner/PrivateBo/Commands/Utility/welcome.js:8:17)
      at Client.<anonymous> (/home/runner/PrivateBot/welcome.js:107:13)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)
      at runNextTicks (internal/process/task_queues.js:66:3)
      at processImmediate (internal/timers.js:434:9)
}  reason:  Discord.MesageEmbed is not a constructor

这是我的文件的样子:

const Discord = require('discord.js');
const client = new Discord.Client();

module.exports = {
    name: "welcome",
    description: "welcomes a user",
    run: async (client, message, args) => {
    const member = message.mentions.members.first();
    let embed = new Discord.MesageEmbed()
    .setAuthor("Welcome")
    .setColor("RANDOM")
    .setDescription("Welcome member to the server! Please read <#placeholder> and chill here!")
    .setFooter("Regards, Staff Team")
  messaeg.channel.send(embed)
  }
}

【问题讨论】:

  • 基于错误,问题在于拼写错误:new Discord.MesageEmbed() - Discord.MessageEmbed() 不相关但很重要:messaeg.channel.send(embed) - message.channel.send(embed)
  • wdym 不相关?
  • 有没有更好的提及人的方式?
  • afaik 不,SO 中没有编程触发。我的意思是,这里的错字:messaeg.channel.send(embed) 不是失败的原因。然而。您附加的错误中提到的主要问题是没有已知方法MesageEmbed

标签: node.js discord discord.js bots


【解决方案1】:

修正new Discord.MesageEmbed()中的错字。

应该是Discord.MessageEmbed()

【讨论】:

    猜你喜欢
    • 2021-03-04
    • 2021-04-05
    • 2018-05-03
    • 2020-11-23
    • 2018-11-24
    • 2020-10-09
    • 2017-11-07
    • 2022-07-16
    • 2019-01-16
    相关资源
    最近更新 更多