fix(DiscordService): only delay on failure not first time

This commit is contained in:
41666 2020-02-02 14:33:24 -05:00
parent fb122015cb
commit 665caea4c5
No known key found for this signature in database
GPG key ID: BC51D07640DC10AF

View file

@ -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) {