Question: In node js. I think I have an off by one? let totalOptions = 0; var reaction_numbers = [ u0030u20E3, u0031u20E3, u0032u20E3, u0033u20E3, u0034u20E3, u0035u20E3,

In node js. I think I have an off by one?

let totalOptions = 0;

var reaction_numbers = [

"\u0030\u20E3",

"\u0031\u20E3",

"\u0032\u20E3",

"\u0033\u20E3",

"\u0034\u20E3",

"\u0035\u20E3",

"\u0036\u20E3",

"\u0037\u20E3",

"\u0038\u20E3",

"\u0039\u20E3",

];

module.exports = async (msg, args) => {

num_matches = msg.content.match(/[,]/gi).length;

if (num_matches == 2) {

msg.channel.send("You need at least one choice");

} else {

let choices = "";

statement = args[0].split(",");

totalOptions = statement.length;

for (let i = 1; i

choices += "Option" + i + ": " + statement[i] + " ";

}

msg.channel.send("Question: " + statement[0] + " " + choices);

console.log(totalOptions);

msg.channel

.fetchMessages({ limit: 1 })

.then(async (messages) => {

let lastMessage = messages.first();

for (let i = 1; i

try {

await lastMessage.react(reaction_numbers[i]);

} catch (error) {

console.error("One of the emojis failed to react.");

}

}

})

.catch(console.error);

}

msg.channel.send(num_matches);

};

input: !poll hi,1,2,3 output:

In node js. I think I have an off by one? let

It should have been question: hi option 1 option 2 option 3 1 2 3

Question: 1 Option1: 2 Option2: 3 11 21 3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!