就像!L JohnGameRage#0000已将L赋予用户#0000
答案 0 :(得分:0)
构造参数的简单方法如下:
let full = message.content.substr(1).trim(); //remove the prefix
let split = full.split(/ +/g); //seperate the words in the String and put them into an array
let cmd = split[0]; //the command is the first word in the array
let args = split.slice(1); //the arguments are all words except for the first one
在您的示例中,L
是命令,JohnGameRage#0000
是第一个参数。
您可以像这样从数组中读取各个参数:
//Command = !L firstArg secondArg thirdArg fourthArg etc
cmd //returns 'L'
args[0] //returns 'firstArg'
args[1] //returns 'secondArg '
args[2] //returns 'thirdArg '
args[3] //returns 'fourthArg '
args[4] //returns 'etc'