Compare commits

...

4 Commits

Author SHA1 Message Date
iCrawl
de0cacdf32 chore(release): version 2020-03-20 09:06:58 +01:00
izexi
bb4cb3e7fe fix: messageReactionRemove emission (#3966)
* fix: handler event name for MessageReactionRemoveEmoji

* fix: typo in WSEvents key
2020-03-20 08:53:47 +01:00
SpaceEEC
08865a98cd chore(release): publish 2020-03-08 19:38:05 +01:00
SpaceEEC
20075e306b fix(ReactionCollector): only modify users and total on collect (#3905) 2020-03-08 19:33:18 +01:00
7 changed files with 20 additions and 8 deletions

View File

@@ -23,7 +23,7 @@ The usage of the API isn't any different from using it in Node.js.
## Example
```html
<script type="text/javascript" src="discord.11.5.0.min.js"></script>
<script type="text/javascript" src="discord.11.6.2.min.js"></script>
<script type="text/javascript">
const client = new Discord.Client();

View File

@@ -1,6 +1,6 @@
{
"name": "discord.js",
"version": "11.6.1",
"version": "11.6.3",
"description": "A powerful library for interacting with the Discord API",
"main": "./src/index",
"types": "./typings/index.d.ts",

View File

@@ -55,7 +55,7 @@ class WebSocketPacketManager {
this.register(Constants.WSEvents.RELATIONSHIP_REMOVE, require('./handlers/RelationshipRemove'));
this.register(Constants.WSEvents.MESSAGE_REACTION_ADD, require('./handlers/MessageReactionAdd'));
this.register(Constants.WSEvents.MESSAGE_REACTION_REMOVE, require('./handlers/MessageReactionRemove'));
this.register(Constants.WSEvents.MESSAGE_REACTION_REMOVE, require('./handlers/MessageReactionRemoveEmoji'));
this.register(Constants.WSEvents.MESSAGE_REACTION_REMOVE_EMOJI, require('./handlers/MessageReactionRemoveEmoji'));
this.register(Constants.WSEvents.MESSAGE_REACTION_REMOVE_ALL, require('./handlers/MessageReactionRemoveAll'));
this.register(Constants.WSEvents.WEBHOOKS_UPDATE, require('./handlers/WebhooksUpdate'));
}

View File

@@ -41,6 +41,11 @@ class ReactionCollector extends Collector {
if (this.client.getMaxListeners() !== 0) this.client.setMaxListeners(this.client.getMaxListeners() + 1);
this.client.on('messageReactionAdd', this.listener);
this.on('fullCollect', (reaction, user) => {
this.users.set(user.id, user);
this.total++;
});
}
/**
@@ -64,9 +69,8 @@ class ReactionCollector extends Collector {
* @returns {?string} Reason to end the collector, if any
* @private
*/
postCheck(reaction, user) {
this.users.set(user.id, user);
if (this.options.max && ++this.total >= this.options.max) return 'limit';
postCheck() {
if (this.options.max && this.total >= this.options.max) return 'limit';
if (this.options.maxEmojis && this.collected.size >= this.options.maxEmojis) return 'emojiLimit';
if (this.options.maxUsers && this.users.size >= this.options.maxUsers) return 'userLimit';
return null;

View File

@@ -99,6 +99,14 @@ class Collector extends EventEmitter {
*/
this.emit('collect', collect.value, this);
/**
* Emitted whenever an element is collected.
* @event Collector#fullCollect
* @param {...*} args The arguments emitted by the listener
* @private
*/
this.emit('fullCollect', ...args, this);
if (this._idletimeout) {
this.client.clearTimeout(this._idletimeout);
this._idletimeout = this.client.setTimeout(() => this.stop('idle'), this.options.idle);

View File

@@ -478,7 +478,7 @@ exports.WSEvents = {
MESSAGE_DELETE_BULK: 'MESSAGE_DELETE_BULK',
MESSAGE_REACTION_ADD: 'MESSAGE_REACTION_ADD',
MESSAGE_REACTION_REMOVE: 'MESSAGE_REACTION_REMOVE',
MESSAGE_REACTION_RMEOVE_EMOJI: 'MESSAGE_REACTION_REMOVE_EMOJI',
MESSAGE_REACTION_REMOVE_EMOJI: 'MESSAGE_REACTION_REMOVE_EMOJI',
MESSAGE_REACTION_REMOVE_ALL: 'MESSAGE_REACTION_REMOVE_ALL',
USER_UPDATE: 'USER_UPDATE',
USER_NOTE_UPDATE: 'USER_NOTE_UPDATE',

2
typings/index.d.ts vendored
View File

@@ -1,4 +1,4 @@
// Type definitions for discord.js 11.6.1
// Type definitions for discord.js 11.6.2
// Project: https://github.com/discordjs/discord.js
// Definitions by:
// acdenisSK <acdenissk69@gmail.com> (https://github.com/acdenisSK)