fix: in/de-crement max listener for client events (#4168)

This commit is contained in:
SpaceEEC
2020-05-07 23:39:23 +02:00
committed by GitHub
parent 766b91d306
commit 407bc77d34
6 changed files with 40 additions and 9 deletions

View File

@@ -196,15 +196,18 @@ class GuildManager extends BaseManager {
const handleGuild = guild => {
if (guild.id === data.id) {
this.client.removeListener(Events.GUILD_CREATE, handleGuild);
this.client.clearTimeout(timeout);
this.client.removeListener(Events.GUILD_CREATE, handleGuild);
this.client.decrementMaxListeners();
resolve(guild);
}
};
this.client.incrementMaxListeners();
this.client.on(Events.GUILD_CREATE, handleGuild);
const timeout = this.client.setTimeout(() => {
this.client.removeListener(Events.GUILD_CREATE, handleGuild);
this.client.decrementMaxListeners();
resolve(this.client.guilds.add(data));
}, 10000);
return undefined;