【问题标题】:discord.js-commando TypeError: RichEmbed is not a constructordiscord.js-commando TypeError:RichEmbed 不是构造函数
【发布时间】:2020-10-05 01:06:42
【问题描述】:

我想用 discord.js-commando 发送嵌入,但是当我发送命令时它告诉我:

运行命令时出错:TypeError: RichEmbed is not a constructor 你不应该收到这样的错误。

这是我的代码

const { Command } = require('discord.js-commando');
const { RichEmbed } = require('discord.js');

module.exports = class EmbedCommand extends Command {
    constructor(client) {
        super(client, {
            name: 'embed',
            group: 'util',
            memberName: 'embed',
            description: 'Embeds the text you provide.',
            examples: ['embed Embeds are cool.'],
            args: [
                {
                    key: 'text',
                    prompt: 'What text would you like the bot to embed?',
                    type: 'string'
                }
            ]
        });    
    }

    run(msg, args) {
        const { text } = args;
        const embed = new RichEmbed()
            .setDescription(text)
            .setAuthor(msg.author.username, msg.author.displayAvatarURL)
            .setColor(0x00AE86)
            .setTimestamp();
        return msg.embed(embed);
    }
};

【问题讨论】:

    标签: discord.js


    【解决方案1】:

    如果您使用的是 discord.js v12+,则为 Discord.MessageEmbed()

    【讨论】:

      【解决方案2】:

      RichEmbed 在最新版本中称为 MessageEmbed。重命名应该没问题。

      【讨论】:

        猜你喜欢
        • 2020-06-15
        • 2021-11-29
        • 2018-07-21
        • 2020-09-04
        • 2021-08-17
        • 2020-12-31
        • 1970-01-01
        • 2021-01-16
        • 2013-12-25
        相关资源
        最近更新 更多