misc: readd poll and vote

This commit is contained in:
Cynthia Foxwell 2022-04-01 18:13:18 -06:00
parent 2577a7e847
commit ee3fa2dccd

View file

@ -212,3 +212,48 @@ fimg.callback = async function (msg, line) {
};
};
hf.registerCommand(fimg);
const poll = new Command("poll");
poll.category = CATEGORY;
poll.helpText = "Start a poll";
poll.usage = "[topic] [option 1] [option 2] [...option 3-10]";
poll.callback = async function (msg, line, topic, ...options) {
if (!line || !topic)
return 'Usage: hf!poll "topic" "option 1" "option 2" "...options 3-10"';
const arrOptions = [...options].slice(0, 10);
if (arrOptions.length < 2) return "A minimum of two options are required.";
const reactions = [];
let displayString = `**${msg.author.username}#${msg.aughtor.discriminator}** has started a poll:\n**__${topic}__**\n`;
for (let i = 0; i < arrOptions.length; i++) {
displayString +=
(i === 9 ? "\ud83d\udd1f" : `${i + 1}\u20e3`) +
": " +
arrOptions[i] +
"\n";
reactions[i] = i === 9 ? "\ud83d\udd1f" : `${i + 1}\u20e3`;
}
return {
content: displayString,
addReactions: reactions,
};
};
hf.registerCommand(poll);
const vote = new Command("vote");
vote.category = CATEGORY;
vote.helpText = "Start a yes/no vote";
vote.usage = "[topic]";
vote.callback = async function (msg, line) {
if (!line) return "No topic given.";
return {
content: `**${msg.author.username}#${msg.author.discriminator}** has started a vote:\n**__${line}__**\n<:ms_tick:503341995348066313>: Yes\n<:ms_cross:503341994974773250>: No`,
addReactions: [
":ms_tick:503341995348066313>:",
":ms_cross:503341994974773250",
],
};
};