From 665caea4c568d12ed891d09e8406d9d9c628fe37 Mon Sep 17 00:00:00 2001 From: Kata Date: Sun, 2 Feb 2020 14:33:24 -0500 Subject: [PATCH] fix(DiscordService): only delay on failure not first time --- Server/services/discord.js | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/Server/services/discord.js b/Server/services/discord.js index fac3410..344a574 100644 --- a/Server/services/discord.js +++ b/Server/services/discord.js @@ -41,22 +41,20 @@ class DiscordService extends Service { } async bootstrap() { - setTimeout(() => { - try { - const ownUser = await this.rpc.ownUser(new Empty(), this.sharedHeaders) - this.ownUser = ownUser.toObject() - - const listGuilds = await this.rpc.listGuilds(new Empty(), this.sharedHeaders) - this.syncGuilds(listGuilds.toObject().guildsList) - } catch (e) { - this.bootstrapRetries++ - if (this.bootstrapRetries < this.bootstrapRetriesMax) { - return this.bootstrap() - } else { - throw e - } + try { + const ownUser = await this.rpc.ownUser(new Empty(), this.sharedHeaders) + this.ownUser = ownUser.toObject() + + const listGuilds = await this.rpc.listGuilds(new Empty(), this.sharedHeaders) + this.syncGuilds(listGuilds.toObject().guildsList) + } catch (e) { + this.bootstrapRetries++ + if (this.bootstrapRetries < this.bootstrapRetriesMax) { + return setTimeout(() => this.bootstrap(), 1000) + } else { + throw e } - }, 1000) + } } ownGm(server) {