Discord Bot Embed 返回 "Cannot send empty message"

Discord Bot Embed returning "Cannot send empty message"

我一直在修改我的帮助命令,其中包括制作一个新的 Discord Embed 但每当我尝试 运行 命令时,它都会崩溃并使用

控制台

DiscordAPIError:无法发送空消息

我已经尝试重新制作嵌入(使用 this tool 因为它的所有嵌入都是使用它制作的)并多次查看它,至少对我来说没有明显的会导致错误。

我的代码:

module.exports = {
    
    name: 'help',
    description: 'Get help on anything from commands, to what the bot does! just not your homework..',
  syntax: '<Command>',

    execute(client, message, args) {
    const footerTxt = require('../config.json')
       const Embed = {
        "title": "HELP SEYMOUR! THE BOT IS ON FIRE!",
        "description": "Get help on anything from commands, to what the bot does! just not your homework..",
        "color": 9442302,
        "footer": {
          "icon_url": message.author.displayAvatarURL,
          "text": footerTxt + " | No mother it's just the northern lights"
        },
        "fields": [
          {
            "name": "Arguments",
            "value": "<> is optionable,\n[ ] is required. \n ```<Command>```"
          },
          {
            "name": "...Or is the bot actually on fire?",
            "value": "<> is optionable,\n[ ] is required. \n ```<Command>```"
          }
        ]
      };
      message.channel.send({ Embed });
}};

正在使用 Discord.JS v12

要在使用对象构建嵌入时发送嵌入,您只需:message.channel.send({ embed: Embed }),因此您的最终代码将是:

module.exports = {
    
    name: 'help',
    description: 'Get help on anything from commands, to what the bot does! just not your homework..',
  syntax: '<Command>',

    execute(client, message, args) {
    const footerTxt = require('../config.json')
       const Embed = {
        "title": "HELP SEYMOUR! THE BOT IS ON FIRE!",
        "description": "Get help on anything from commands, to what the bot does! just not your homework..",
        "color": 9442302,
        "footer": {
          "icon_url": message.author.displayAvatarURL,
          "text": footerTxt + " | No mother it's just the northern lights"
        },
        "fields": [
          {
            "name": "Arguments",
            "value": "<> is optionable,\n[ ] is required. \n ```<Command>```"
          },
          {
            "name": "...Or is the bot actually on fire?",
            "value": "<> is optionable,\n[ ] is required. \n ```<Command>```"
          }
        ]
      };
      message.channel.send({ embed: Embed });
}};

您可以在此处了解有关 discord.js v12 中嵌入的更多信息 => discord.js | v12

像往常一样,它总是容易被忽视的小事。 该问题是由 message.author.displayAvatarURL

中缺少括号引起的

最终代码为:

    
    name: 'help',
    description: 'Get help on anything from commands, to what the bot does! just not your homework..',
  syntax: '<Command>',

    execute(client, message, args) {
    const {footerTxt} = require('../config.json');
       const Embed = {
        "title": "HELP SEYMOUR! THE BOT IS ON FIRE!",
        "description": "Get help on anything from commands, to what the bot does! just not your homework..",
        "color": 9442302,
        "footer": {
          "icon_url": message.author.displayAvatarURL,
          "text": footerTxt + " | No mother it's just the northern lights"
        },
        "fields": [
          {
            "name": "Arguments",
            "value": "<> is optionable,\n[ ] is required. \n ```<Command>```"
          },
          {
            "name": "...Or is the bot actually on fire?",
            "value": "Join the [support server!]( )"
          }
        ]
      };
      message.channel.send({ Embed });
}};
"text": footerTxt + " | No mother it's just the northern lights"

变成

"text": `${footerTxt}` + " | No mother it's just the northern lights"

代码可能有效