open-wa/wa-automate-nodejs
posted by danilocodes over 3 years agoposted by justClizz over 3 years agoposted by justClizz over 3 years ago
The issue has been closed
Question: How to detect word after command? #2234
justClizz posted onGitHub
How to detect word after command? Because I want to create a #ytinfo command with a link
How to detect word after command? Because I want to create a #ytinfo command with a link
I have this approach, dont know if its the best but works for me
const getMemberInfo = async (message) => {
let body = message.body.split(' '); // split message content on spaces
body.shift(); // remove first item from the result array (the first item is your command)
const member = body[0]; // then you can parse command args by its indexes of the array
if (!member) return false; // if body[0] is undefined it means that the command message has no args
// do your stuff with the args
};
How to detect word after command? Because I want to create a #ytinfo command with a link
I have this approach, dont know if its the best but works for me
const getMemberInfo = async (message) => { let body = message.body.split(' '); // split message content on spaces body.shift(); // remove first item from the result array (the first item is your command) const member = body[0]; // then you can parse command args by its indexes of the array if (!member) return false; // if body[0] is undefined it means that the command message has no args // do your stuff with the args };
ok thanks, i will try it
How to detect word after command? Because I want to create a #ytinfo command with a link
I have this approach, dont know if its the best but works for me
const getMemberInfo = async (message) => { let body = message.body.split(' '); // split message content on spaces body.shift(); // remove first item from the result array (the first item is your command) const member = body[0]; // then you can parse command args by its indexes of the array if (!member) return false; // if body[0] is undefined it means that the command message has no args // do your stuff with the args };
It works, thanks!