mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-25 19:13:54 +00:00
Prepopulate reactions on voting skins
This commit is contained in:
parent
b33668bfb8
commit
cf7a7a5951
1 changed files with 17 additions and 6 deletions
|
|
@ -3,8 +3,17 @@ const rgbHex = require("rgb-hex");
|
|||
const Skins = require("../data/skins");
|
||||
const logger = require("../logger");
|
||||
|
||||
const filter = (reaction) => {
|
||||
return ["👍", "👎", "👏", "😔"].some((name) => reaction.emoji.name === name);
|
||||
function isEligableToApprove(user) {
|
||||
return !user.bot;
|
||||
}
|
||||
|
||||
const filter = reaction => {
|
||||
const hasNonBot = reaction.users.some(isEligableToApprove);
|
||||
|
||||
return (
|
||||
hasNonBot &&
|
||||
["👍", "👎", "👏", "😔"].some(name => reaction.emoji.name === name)
|
||||
);
|
||||
};
|
||||
|
||||
async function postSkin({ md5, title, dest }) {
|
||||
|
|
@ -26,7 +35,7 @@ async function postSkin({ md5, title, dest }) {
|
|||
tweetStatus,
|
||||
internetArchiveUrl,
|
||||
internetArchiveItemName,
|
||||
readmeText,
|
||||
readmeText
|
||||
} = skin;
|
||||
title = title ? title(canonicalFilename) : canonicalFilename;
|
||||
|
||||
|
|
@ -50,7 +59,7 @@ async function postSkin({ md5, title, dest }) {
|
|||
logger.warn("Did not get a safe color", {
|
||||
averageColor,
|
||||
color,
|
||||
warn: true,
|
||||
warn: true
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
@ -81,10 +90,12 @@ async function postSkin({ md5, title, dest }) {
|
|||
}
|
||||
|
||||
const msg = await dest.send(embed);
|
||||
await Promise.all([msg.react("👍"), msg.react("👎")]);
|
||||
|
||||
await msg.awaitReactions(filter, { max: 1 }).then(async (collected) => {
|
||||
// TODO: Timeout at some point
|
||||
await msg.awaitReactions(filter, { max: 1 }).then(async collected => {
|
||||
const vote = collected.first();
|
||||
const user = vote.users.first();
|
||||
const user = vote.users.find(isEligableToApprove);
|
||||
switch (vote.emoji.name) {
|
||||
case "👍":
|
||||
case "👏":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue