error handling

This commit is contained in:
Emily 2020-11-04 17:07:49 +11:00
parent 4e4ab100ec
commit afd3b7197e

View file

@ -64,17 +64,16 @@ module.exports = class {
.then((res) => res.json()) .then((res) => res.json())
.then((json) => { .then((json) => {
if (json.errors) { if (json.errors) {
console.log(json.errors) json.errors.forEach(error => {
for (const error in json.errors) {
console.log(error);
if (error.message.startsWith('No Pokémon found')) { if (error.message.startsWith('No Pokémon found')) {
message.channel.createMessage( 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 { } else {
client.logger.error('POKEMON_FETCH_ERROR', error.message); client.logger.error('POKEMON_FETCH_ERROR', error.message);
} }
} });
return; return;
} }