Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

What is American Polity and Governance ?

Answered: 1 week ago

Question

understand the key issues concerning international assignments

Answered: 1 week ago