繁体   English   中英

如何使机器人前缀在 discord.js 上不区分大小写?

[英]How do i make the bots prefix not case sensitive on discord.js?

我有一个 discord 机器人,它的前缀是“Arm”(空格是),我想让它不区分大小写,这样使用起来就不那么烦人了。

我已经尝试过这个线程中的解决方案( 有没有办法让我的前缀不区分大小写(Discord.js) ),但它们似乎没有用

这是我的一些代码

const config = require("./config.json");

client.on("message", async message => {

if(message.author.bot) return;
 
if(!message.content.startsWith(config.prefix)) return; 

这是我的配置

{ 
  "token"  : "Token here",
  "prefix" : "Arm "
}

代替

if(!message.content.startsWith(config.prefix)) return;

if(message.content.slice(0, config.prefix.length).toLowerCase() !== config.prefix) return; 

并将前缀从"Arm "更改为"arm "

暂无
暂无

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

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