如何获得对空前缀命令以及不正确命令的响应?

时间:2021-01-18 15:19:57

标签: javascript discord.js

    command(client, 'stats', message => {
        const args = message.content.slice(prefix.length).trim().split(' ');
        
        if (args.length == 0) {
            const embedStats = new Discord.MessageEmbed()
            .setTitle('Module Stats')
            .setDescription(`Please specify a module\n\*Example:\*\n\`${prefix}stats enrich\``)
            message.channel.send(embedStats);
        }

        else if (args.length > 0) {
        
            switch(args[1]){

                // stats mining boost
                case "miningboost":
                    const { linkMiningBoost } = linksMining
                    const { linkImgMiningBoost } = linksMining
                    const embedMiningBoost = new Discord.MessageEmbed()
                    .setTitle('Mining Boost')
                    .setDescription(`[Click for stats](${linkMiningBoost})`)
                    message.channel.send(embedMiningBoost);  
                break;

                // stats enrich
                case "enrich":
                    const { linkEnrich } = linksMining
                    const { linkImgEnrich } = linksMining
                    const embedEnrich = new Discord.MessageEmbed()
                    .setTitle('Enrich')
                    .setDescription(`[Click for stats](${linkEnrich})`)
                    message.channel.send(embedEnrich);   
                break;

                default:
                    const embedNoModule = new Discord.MessageEmbed()
                    .setTitle('Module Stats')
                    .setDescription(`Module not recognised`)
                    message.channel.send(embedNoModule);     
            }
        }
    })

这是我所拥有的。

我喜欢 3 个结果:

  • !stats - 发送 embedStats。
  • !stats rich/miningboost - 发送 embedEnrich/embedMiningBoost。
  • !stats anything - 发送 embedNoModule。

单独发送 !stats 目前给了我 embedNoModule,这是错误的。 有什么想法吗?

0 个答案:

没有答案