mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13: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
|
||||
* @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
2
typings/index.d.ts
vendored
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user