From afd3b7197e88df68e8d41065641a744510c2b511 Mon Sep 17 00:00:00 2001 From: Emily J Date: Wed, 4 Nov 2020 17:07:49 +1100 Subject: [PATCH] error handling --- bot/commands/Fun/pokemon.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bot/commands/Fun/pokemon.js b/bot/commands/Fun/pokemon.js index 9fb0232..6642ef5 100644 --- a/bot/commands/Fun/pokemon.js +++ b/bot/commands/Fun/pokemon.js @@ -64,17 +64,16 @@ module.exports = class { .then((res) => res.json()) .then((json) => { if (json.errors) { - console.log(json.errors) - for (const error in json.errors) { - console.log(error); + json.errors.forEach(error => { if (error.message.startsWith('No Pokémon found')) { message.channel.createMessage( - `${client.constants.emojis.userError} I tried really hard, but I couldn't find any Pokemon called \`${query}\`` + `${client.constants.emojis.userError} I couldn't find any Pokemon called ${query}c` ); } else { client.logger.error('POKEMON_FETCH_ERROR', error.message); } - } + }); + return; }