summaryrefslogtreecommitdiff
path: root/views/player.js
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2017-05-09 18:02:15 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2017-05-09 18:03:06 +0200
commit0ee8e0e5239e3f76911834da54d2c72a4a149804 (patch)
treefca810d542ffad451699379a8dc61067c7ea632b /views/player.js
parent94adb2f9f182e50f6d60aadc70bb8bf8f74f2371 (diff)
downloaddiscordbot-0ee8e0e5239e3f76911834da54d2c72a4a149804.tar.gz
discordbot-0ee8e0e5239e3f76911834da54d2c72a4a149804.zip
error handling, migration to template
Diffstat (limited to 'views/player.js')
-rw-r--r--views/player.js19
1 files changed, 8 insertions, 11 deletions
diff --git a/views/player.js b/views/player.js
index ec5d38b..a481c69 100644
--- a/views/player.js
+++ b/views/player.js
@@ -72,7 +72,7 @@ ${emoji.symbols["1234"]} or ${util.usg(this.msg, "vh " + this.ign)} for more*`;
let reactions = {};
reactions[emoji.symbols.information_source] = async () => {
util.trackAction(this.msg, "reaction-match", player.name);
- await new MatchView(this.msg, matches[0].match_api_id).respond();
+ await new MatchView(this.msg).respond(matches[0].match_api_id);
};
reactions[emoji.symbols["1234"]] = async () => {
util.trackAction(this.msg, "reaction-matches", player.name);
@@ -82,16 +82,13 @@ ${emoji.symbols["1234"]} or ${util.usg(this.msg, "vh " + this.ign)} for more*`;
}
async respond() {
- const [player, matches] = await Promise.all([
- api.getPlayer(this.ign),
- api.getMatches(this.ign)
- ]);
- if (player == undefined) {
- this.response = await util.respond(this.msg,
- strings.loading(this.ign), this.response);
- return this.response;
- }
- if (matches.length == 0) {
+ let player, matches;
+ try {
+ [player, matches] = await Promise.all([
+ api.getPlayer(this.ign),
+ api.getMatches(this.ign)
+ ]);
+ } catch (err) {
this.response = await util.respond(this.msg,
strings.loading(this.ign), this.response);
return this.response;