mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
refactor: remove timer utilities from Client (#6113)
This commit is contained in:
@@ -217,7 +217,7 @@ class GuildManager extends CachedManager {
|
||||
|
||||
const handleGuild = guild => {
|
||||
if (guild.id === data.id) {
|
||||
this.client.clearTimeout(timeout);
|
||||
clearTimeout(timeout);
|
||||
this.client.removeListener(Events.GUILD_CREATE, handleGuild);
|
||||
this.client.decrementMaxListeners();
|
||||
resolve(guild);
|
||||
@@ -226,11 +226,11 @@ class GuildManager extends CachedManager {
|
||||
this.client.incrementMaxListeners();
|
||||
this.client.on(Events.GUILD_CREATE, handleGuild);
|
||||
|
||||
const timeout = this.client.setTimeout(() => {
|
||||
const timeout = setTimeout(() => {
|
||||
this.client.removeListener(Events.GUILD_CREATE, handleGuild);
|
||||
this.client.decrementMaxListeners();
|
||||
resolve(this.client.guilds._add(data));
|
||||
}, 10000);
|
||||
}, 10000).unref();
|
||||
return undefined;
|
||||
}, reject),
|
||||
);
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user