fix(Collector): support async (#4123)

This commit is contained in:
Nathan Franke
2020-08-11 16:34:47 -05:00
committed by GitHub
parent 05cbf70486
commit 124afeb843
2 changed files with 4 additions and 4 deletions

View File

@@ -9,7 +9,7 @@ const Util = require('../../util/Util');
* @typedef {Function} CollectorFilter
* @param {...*} args Any arguments received by the listener
* @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
* @emits Collector#collect
*/
handleCollect(...args) {
async handleCollect(...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]);
/**

2
typings/index.d.ts vendored
View File

@@ -2295,7 +2295,7 @@ declare module 'discord.js' {
target: WebSocket;
}
type CollectorFilter = (...args: any[]) => boolean;
type CollectorFilter = (...args: any[]) => boolean | Promise<boolean>;
interface CollectorOptions {
time?: number;