mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
Fix ReactionCollector#remove and make Collector interface more consistent (#2221)
* Fix ReactionCollector#remove and make Collector interface more consistent * Move those below the doc * Remove object spread * Only emit event arguments * Forgot to delete this line * Update docs * Also fix this * More edits to docs * Snowflake|string
This commit is contained in:
@@ -78,15 +78,14 @@ class Collector extends EventEmitter {
|
||||
const collect = this.collect(...args);
|
||||
|
||||
if (collect && this.filter(...args, this.collected)) {
|
||||
this.collected.set(collect.key, collect.value);
|
||||
this.collected.set(collect, args[0]);
|
||||
|
||||
/**
|
||||
* Emitted whenever an element is collected.
|
||||
* @event Collector#collect
|
||||
* @param {*} element The element that got collected
|
||||
* @param {...*} args The arguments emitted by the listener
|
||||
*/
|
||||
this.emit('collect', collect.value, ...args);
|
||||
this.emit('collect', ...args);
|
||||
}
|
||||
this.checkEnd();
|
||||
}
|
||||
@@ -101,17 +100,14 @@ class Collector extends EventEmitter {
|
||||
|
||||
const dispose = this.dispose(...args);
|
||||
if (!dispose || !this.filter(...args) || !this.collected.has(dispose)) return;
|
||||
|
||||
const value = this.collected.get(dispose);
|
||||
this.collected.delete(dispose);
|
||||
|
||||
/**
|
||||
* Emitted whenever an element has been disposed.
|
||||
* Emitted whenever an element is disposed of.
|
||||
* @event Collector#dispose
|
||||
* @param {*} element The element that was disposed
|
||||
* @param {...*} args The arguments emitted by the listener
|
||||
*/
|
||||
this.emit('dispose', value, ...args);
|
||||
this.emit('dispose', ...args);
|
||||
this.checkEnd();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user