如何使if(message.content.startsWith(''))检测到两件事

时间:2019-03-20 19:34:30

标签: javascript bots discord

所以我有代码

if (message.content.startsWith('')) 

在我的脚本中,我希望它能使它通过,以便它是大写还是小写。我尝试过

if(message.content.startsWith('>command', '>COMMAND')) 

但这没用。有人可以告诉我正确的密码吗?

2 个答案:

答案 0 :(得分:3)

您可以先将值更改为小写,然后再进行匹配

message.content.toLowerCase().startsWith(">command")

您可以使用搜索

message.content.seach(/^>command/i)

答案 1 :(得分:0)

RegExp#test与RegExp ^>command(其中^start anchor)和flag i一起使用来忽略大小写。

if(/^>command/i.test(message.content)))