I'm writing my first Discord bot. I want him to read a users message, and then send the message back, with words separated by emojis. So the effect would be something like this: https://i.stack.imgur.com/ysg4f.png
So this is theoretically working - I say theoretically, because I used completely ridiculous solution just to show what I'm aiming for:
if (message.substring(0, 2) == "m.") {
var args = message.substring(2).trim().split(/ +/g);
var cmd = args.shift().toLowerCase();
switch (cmd) {
// m.clap
case "clap":
bot.sendMessage({
to: channelID,
message:
":clap: " + args[0] + " :clap: " + args[1] + " :clap: " + args[2],
});
break;
}
}
So, obviously, this only works for max. three words sentences, and I need it to work for any length of the sentence.
I tried wrapping the "sendMessage" function in a for loop, iterating from 0 to args.length, but that makes the bot send each word in a separate message, obviously. And it won't let me put a for loop inside of the sendMessage function.
Any help would be greatly appreciated. Thank you!!!