From 7d1a3793ce96868aae2a6ced6af4c7583be03b66 Mon Sep 17 00:00:00 2001 From: Emily J Date: Thu, 22 Oct 2020 18:35:33 +1100 Subject: [PATCH] eris-collector --- bot/event_modules/messageCreate/collector.js | 33 ++++++++++++++++++++ package-lock.json | 27 ++++++---------- package.json | 2 +- 3 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 bot/event_modules/messageCreate/collector.js diff --git a/bot/event_modules/messageCreate/collector.js b/bot/event_modules/messageCreate/collector.js new file mode 100644 index 0000000..e221082 --- /dev/null +++ b/bot/event_modules/messageCreate/collector.js @@ -0,0 +1,33 @@ +const { ReactionCollector } = require('eris-collector'); + +module.exports = class { + constructor (wsEvent) { + this.wsEvent = wsEvent; + } + + async run (client, message) { + /* Creating reaction collector */ + if (message.content === 'createReactionCollector') { + + /* Send informative message */ + const msg = await client.createMessage(message.channel.id, 'This is a reaction collector example!'); + await msg.addReaction('🐝'); + + /* Create reaction filter */ + const filter = (m, emoji, userID) => emoji.name === '🐝' && userID === message.author.id; + + /* Create collector */ + const collector = new ReactionCollector(client, msg, filter, { + time: 1000 * 20 + }); + + /* + * Emitted when collector collects something suitable for filter + * For more information, please see discord.js docs: https://discord.js.org/#/docs/main/stable/class/ReactionCollector + */ + collector.on('collect', (m, emoji, userID) => { + console.log(client.createMessage(m.channel.id, `Reaction added by \`${userID}\``)); + }); + } + } +}; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1adef4d..07585b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -334,24 +334,12 @@ "ws": "^7.2.1" } }, - "eris-additions": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/eris-additions/-/eris-additions-1.4.1.tgz", - "integrity": "sha512-ZaAvQKZjXWOJB653RCKsdYMgJH+vXqdjjv/wTVtmFTUvaRdehON3x/yU/YseQwpoTwQVhOBLofTu6fdz0KzZmQ==", + "eris-collector": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/eris-collector/-/eris-collector-1.0.1.tgz", + "integrity": "sha512-qAuIP8//rMaTFs/3J7Ggk2tzWuNbFqJsAP8DuT9MLpNYc6f0u+Cifpa06//oxGQOWl4sWY1+0ncJDfRvlz2PMg==", "requires": { - "eris": "^0.12.0" - }, - "dependencies": { - "eris": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/eris/-/eris-0.12.0.tgz", - "integrity": "sha512-LIw+uEOfHFCdE9BXL3wqxwml+74TJ7eMiMcyeW/jsmiWndDzybA/WlakiXAAnyg9a5OULOkHlKLOFsl+EgoZag==", - "requires": { - "opusscript": "^0.0.7", - "tweetnacl": "^1.0.1", - "ws": "^7.2.1" - } - } + "events": "^3.1.0" } }, "escape-string-regexp": { @@ -494,6 +482,11 @@ "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==" }, + "events": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.2.0.tgz", + "integrity": "sha512-/46HWwbfCX2xTawVfkKLGxMifJYQBWMwY1mjywRtb4c9x8l5NP3KoJtnIOiL1hfdRkIuYhETxQlo62IF8tcnlg==" + }, "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", diff --git a/package.json b/package.json index fa52faa..f80197c 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "@sentry/node": "^5.26.0", "chalk": "^4.1.0", "eris": "^0.13.3", - "eris-additions": "^1.4.1", + "eris-collector": "^1.0.1", "eslint": "^7.11.0", "fs-readdir-recursive": "^1.1.0", "js-yaml": "^3.14.0",