misc: readd poll and vote
This commit is contained in:
		
							parent
							
								
									2577a7e847
								
							
						
					
					
						commit
						ee3fa2dccd
					
				
					 1 changed files with 45 additions and 0 deletions
				
			
		| 
						 | 
					@ -212,3 +212,48 @@ fimg.callback = async function (msg, line) {
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
hf.registerCommand(fimg);
 | 
					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",
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					  };
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue