简体   繁体   English

是否可以使命令处理程序不区分大小写?

[英]Is it possible to make a command handler case-insensitive?

I have this command handler:我有这个命令处理程序:

bot.on("ready", () => {
    //Command Handler

    fs.readdir("./commands", (err, files) => {
        if (err) return console.log(err);
        let jsfile = files.filter((f) => f.split(".").pop() == "js");

        if (jsfile.length == 0) {
            return console.log("Could Not Find Any Commands!");
        }

        jsfile.forEach((f) => {
            let props = require(`./commands/${f}`);
            bot.commands.set(props.help.name, props);
        });
    });
});

I want to make it case insensitive, so commands would be easier to type, but I have no clue how.我想让它不区分大小写,这样命令会更容易输入,但我不知道怎么做。

Yes.是的。 Just use var input = original.toLowerCase();只需使用var input = original.toLowerCase(); to make your code lowercase.使您的代码小写。

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

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