From c09e757bd7cb03c0f00e0ee5e294e3b642999e1c Mon Sep 17 00:00:00 2001 From: schneefux Date: Fri, 21 Apr 2017 11:28:15 +0200 Subject: remove reaction buttons after timeout --- responses.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'responses.js') 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); -- cgit v1.3.1