accepts message with ""
This commit is contained in:
@@ -28,8 +28,10 @@ class Command{
|
||||
}else if(this.requireInput){
|
||||
//the command requires input
|
||||
|
||||
|
||||
let splitCommand = this.command.split(' ');
|
||||
let splitMsg = msg.split(' ');
|
||||
let splitMsg = this._getInputMessage(message);
|
||||
|
||||
|
||||
//check the number of words both has
|
||||
//if not same then return false
|
||||
@@ -95,6 +97,19 @@ class Command{
|
||||
return input;
|
||||
}
|
||||
|
||||
_getInputMessage(msg){
|
||||
let split = msg.split(/['"]/g);
|
||||
if(split.length > 1)
|
||||
{
|
||||
let splitMsg = split[0].trim().split(' ');
|
||||
let inputs = split.slice(1).filter( el => el.trim() == "" ? null : el);
|
||||
splitMsg = splitMsg.concat(inputs);
|
||||
return splitMsg;
|
||||
}
|
||||
|
||||
return msg.split(' ');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports.Command = Command;
|
||||
|
||||
@@ -238,4 +238,5 @@ module.exports= onMessage = async (message, client) => {
|
||||
|
||||
|
||||
|
||||
|
||||
//export default onMessage;
|
||||
Reference in New Issue
Block a user