Search code examples
node.jsdiscord.jscommando

Embed Command (Colors) (discord.js-commando)


I've got a problem about an Embed Command, I am trying to let users choose color codes in this Embed Command, But this is an error I'm having: RangeError: Argument type "colorcode" isn't registered. .

My Code:

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)
    }
};

.

Does anyone know how to replace colorcode?


Solution

  • Instead of type:'colorcode', use type: 'string', and don't forget to change:

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

    You could also go to the Repository of discord.js Commando and create a Issue/Feature Request to recommend adding a new type for Color/ColorResolveable.