diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2017-05-12 19:13:34 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2017-05-12 19:13:34 +0200 |
| commit | 29f937a1d97c60334fa0e707150f73e5c3c773bb (patch) | |
| tree | 8fa07cf56f8535f08da1adda0ad0769dde6da344 | |
| parent | 3e4671a4a387045bbb608ee28dcd6f65392c2d98 (diff) | |
| download | discordbot-29f937a1d97c60334fa0e707150f73e5c3c773bb.tar.gz discordbot-29f937a1d97c60334fa0e707150f73e5c3c773bb.zip | |
use upsearch sync
| -rw-r--r-- | commands/vainsocial/guild_add.js | 12 | ||||
| -rw-r--r-- | commands/vainsocial/guild_update.js | 15 |
2 files changed, 8 insertions, 19 deletions
diff --git a/commands/vainsocial/guild_add.js b/commands/vainsocial/guild_add.js index e3a0008..bf8f8f6 100644 --- a/commands/vainsocial/guild_add.js +++ b/commands/vainsocial/guild_add.js @@ -31,18 +31,12 @@ Register IGNs to your Guild. guildAddView = new GuildAddView(msg, playersStatus); // create waiter dict & data dict await Promise.each(playersWaiters, async (waiter, idx) => { - await api.upsearchPlayer(args[idx]); let success = false; try { playersStatus[args[idx]] = "Loading…"; - do { - try { - await api.getPlayer(args[idx]); - success = true; - } catch (err) { } - await guildAddView.respond(); - } while (["stats_update", "matches_update", undefined] - .indexOf(await waiter.next())); + await guildAddView.respond(); + await api.upsearchPlayerSync(args[idx]); + success = true; } catch (err) { console.error(err); playersStatus[args[idx]] = err.error.err; diff --git a/commands/vainsocial/guild_update.js b/commands/vainsocial/guild_update.js index c3163be..a61647f 100644 --- a/commands/vainsocial/guild_update.js +++ b/commands/vainsocial/guild_update.js @@ -42,16 +42,11 @@ Update the match history for all your Guild members. const playersWaiters = names.map((name) => api.subscribeUpdates(name)); // create waiter dict & data dict await Promise.each(playersWaiters, async (waiter, idx) => { - await api.updatePlayer(names[idx]); - while (["stats_update", undefined].indexOf(await waiter.next())) { - try { - await api.getPlayer(names[idx]); - playersStatus[names[idx]] = "Loaded."; - } catch (err) { - playersStatus[names[idx]] = "Loading…"; - } - await guildUpdateView.respond(); - } + playersStatus[names[idx]] = "Loading…"; + await guildUpdateView.respond(); + await api.upsearchPlayerSync(names[idx]); + playersStatus[names[idx]] = "Loaded."; + await guildUpdateView.respond(); }); await guildUpdateView.respond("Your Guild's fame is being updated…"); try { |
