嵌入命令(颜色)(discord.js-commando)

时间:2019-03-30 14:31:44

标签: node.js discord.js commando

我在嵌入命令方面遇到问题,我试图让用户在此嵌入命令中选择颜色代码,但这是我遇到的错误:RangeError: Argument type "colorcode" isn't registered.

我的代码:

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

module.exports = class EmbedCommand extends Command {
    constructor(client) {
        super(client, {
            name: 'embed',
            group: 'extra commands',
            memberName: 'embed',
            description: 'Replies with the text you provide, But in Embed.',
            args: [
                {
                    key:"text",
                    prompt:"What Should the Embed Say?",
                    type:"string",
                },
                {
                    key:"color",
                    prompt:"What Color should the Embed be? (Use Color Codes.). Use RANDOM for Random Color. (Must Be All Caps!).",
                    type:'colorcode',
                }
            ]
        });    
    }

    run(msg, { text }) {
        msg.delete();
        let embed = new RichEmbed()
        .setTitle(text)
        .setColor(color)
        msg.embed(embed)
    }
};

有人知道如何替换colorcode吗?

1 个答案:

答案 0 :(得分:0)

使用type:'colorcode',而不是type: 'string',,并且不要忘记进行更改:

run(msg, { text }) {run(msg, { text, color }) {

您还可以转到discord.js Commando的{​​{3}}并创建一个Repository来建议为Color/ColorResolveable添加一个新类型。