diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-04-21 11:28:15 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-04-21 11:28:15 +0200 |
| commit | c09e757bd7cb03c0f00e0ee5e294e3b642999e1c (patch) | |
| tree | bf8e2a13f6bb7258535c9f97d38502a0ba3a892f | |
| parent | a9683a5123206ab483fd638555dd6a59bc866d53 (diff) | |
| download | discordbot-c09e757bd7cb03c0f00e0ee5e294e3b642999e1c.tar.gz discordbot-c09e757bd7cb03c0f00e0ee5e294e3b642999e1c.zip | |
remove reaction buttons after timeout
| -rw-r--r-- | responses.js | 9 |
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); |
