So for a typical command, let's say.. "!doWork", you can make a list of parameters (optional or required) that are passed in as a pipe-delimited list. For example:
!doWork @{selected|strength}|@{target|armorClass}
For the sake of this example, we'll say the selected token's character has a strength of 14 and the target has an AC of 21.
Which will get passed into the chat:message handler's callback function as the first argument's content property.
on('chat:message',function(msg){
if(msg.type === 'api'){
let command = msg.content;
if(command.indexOf(' ') > -1){
command = command.split(' ')[0];
commandArgs = msg.content.replace(command + ' ','').split('|');
}
if(commandComponents[0] === '!doWork'){
//commandArgs[0] === "14"
//commandArgs[1] === "21"
//Remember that these come in as strings, so if you want to do math on them, parseInt or parseFloat them first when you assign them.
//If you need arguments to be required and/or of a certain type, do all validation when you assign them. Failfast implementations help minimize resources consumed.
let strength, ac;
if(commandArgs[0]
&& strength = parseInt(commandArgs[0]) !== 'NaN'
&& commandArgs[1]
&& ac = parseInt(commandArgs[1]) !== 'NaN'){
(command code here)
//Note: I don't remember if assignments and boolean checks can be used in line like that in JS, but adjust accordingly if they can't.
}
}
}
})