summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2017-04-21 11:28:15 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2017-04-21 11:28:15 +0200
commitc09e757bd7cb03c0f00e0ee5e294e3b642999e1c (patch)
treebf8e2a13f6bb7258535c9f97d38502a0ba3a892f
parenta9683a5123206ab483fd638555dd6a59bc866d53 (diff)
downloaddiscordbot-c09e757bd7cb03c0f00e0ee5e294e3b642999e1c.tar.gz
discordbot-c09e757bd7cb03c0f00e0ee5e294e3b642999e1c.zip
remove reaction buttons after timeout
-rw-r--r--responses.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/responses.js b/responses.js
index ea7c01b..18b42a4 100644
--- a/responses.js
+++ b/responses.js
@@ -150,11 +150,16 @@ module.exports.onNewReaction = (reaction) => {
// the Promise result is the reaction name
function awaitReactions(message, emoji, timeout=REACTION_TIMEOUT) {
const pipeOut = new Channel();
+ let reactions = [];
// stop listening after timeout
- setTimeout(() => pipeOut.close(), timeout*1000);
+ setTimeout(() => {
+ pipeOut.close();
+ Promise.map(reactions, async (r) => r.remove());
+ }, timeout*1000);
+ // async in background
Promise.each(emoji, async (em) =>
- message.react(em)); // async in background
+ reactions.push(await message.react(em)));
let reaction;
reactionsPipe.pipe(pipeOut);