refactor: remove timer utilities from Client (#6113)

This commit is contained in:
Antonio Román
2021-07-16 14:31:25 +02:00
committed by GitHub
parent f200f14a40
commit 5ca97c9351
13 changed files with 47 additions and 145 deletions

View File

@@ -372,7 +372,7 @@ class GuildMemberManager extends CachedManager {
(limit && fetchedMembers.size >= limit) ||
i === chunk.count
) {
this.client.clearTimeout(timeout);
clearTimeout(timeout);
this.client.removeListener(Events.GUILD_MEMBERS_CHUNK, handler);
this.client.decrementMaxListeners();
let fetched = option ? fetchedMembers : this.cache;
@@ -380,11 +380,11 @@ class GuildMemberManager extends CachedManager {
resolve(fetched);
}
};
const timeout = this.client.setTimeout(() => {
const timeout = setTimeout(() => {
this.client.removeListener(Events.GUILD_MEMBERS_CHUNK, handler);
this.client.decrementMaxListeners();
reject(new Error('GUILD_MEMBERS_TIMEOUT'));
}, time);
}, time).unref();
this.client.incrementMaxListeners();
this.client.on(Events.GUILD_MEMBERS_CHUNK, handler);
});