简体   繁体   English

Discord.js,不能使 discord 嵌入到 module.exports 中

[英]Discord.js, can't make discord embeds inside module.exports

I need help with discord.js.我需要 discord.js 方面的帮助。 I can't use discord embeds inside module.exports.我不能使用 discord 嵌入到 module.exports 中。

const Discord = require("discord.js");

module.exports = {
   name: "quote",
   aliases: ["quote", "quotes"],
   cooldowns: 3000,
   description: "Generates a random quote",
   usage: "To generate a random quote",
   toggleOff: false,
   developersOnly: false,
   userpermissions: ["SEND_MESSAGES", "VIEW_CHANNEL"],
   botpermissions: ["ADMINISTRATOR"],
   run: async (client, message, args) => {
      const getNextQuote = shuffler(quotes);
      const random  = getNextQuote();
      const embed = new Discord.MessageEmbed()
        .setColor('FF0000')
        .setImage(message.author.avatarURL)
        .setTitle("This is a quote")
        .setDescription("This is quote number")
        message.channel.send(embed);
        
   }
}; 

Every time I run the code I get an error,每次我运行代码时都会出错,

DiscordAPIError: Cannot send an empty message DiscordAPIError:无法发送空消息

According to the official docs , you should wrap the embed like this:根据官方文档,您应该像这样包装嵌入:

channel.send({embeds: [embed]})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM