mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 04:23:31 +01:00
fix(Collector): support async (#4123)
This commit is contained in:
@@ -9,7 +9,7 @@ const Util = require('../../util/Util');
|
|||||||
* @typedef {Function} CollectorFilter
|
* @typedef {Function} CollectorFilter
|
||||||
* @param {...*} args Any arguments received by the listener
|
* @param {...*} args Any arguments received by the listener
|
||||||
* @param {Collection} collection The items collected by this collector
|
* @param {Collection} collection The items collected by this collector
|
||||||
* @returns {boolean}
|
* @returns {boolean|Promise<boolean>}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,10 +86,10 @@ class Collector extends EventEmitter {
|
|||||||
* @param {...*} args The arguments emitted by the listener
|
* @param {...*} args The arguments emitted by the listener
|
||||||
* @emits Collector#collect
|
* @emits Collector#collect
|
||||||
*/
|
*/
|
||||||
handleCollect(...args) {
|
async handleCollect(...args) {
|
||||||
const collect = this.collect(...args);
|
const collect = this.collect(...args);
|
||||||
|
|
||||||
if (collect && this.filter(...args, this.collected)) {
|
if (collect && (await this.filter(...args, this.collected))) {
|
||||||
this.collected.set(collect, args[0]);
|
this.collected.set(collect, args[0]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
2
typings/index.d.ts
vendored
2
typings/index.d.ts
vendored
@@ -2295,7 +2295,7 @@ declare module 'discord.js' {
|
|||||||
target: WebSocket;
|
target: WebSocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
type CollectorFilter = (...args: any[]) => boolean;
|
type CollectorFilter = (...args: any[]) => boolean | Promise<boolean>;
|
||||||
|
|
||||||
interface CollectorOptions {
|
interface CollectorOptions {
|
||||||
time?: number;
|
time?: number;
|
||||||
|
|||||||
Reference in New Issue
Block a user