Fix some things

This commit is contained in:
Daniel Odendahl Jr
2019-05-16 14:29:39 +00:00
parent 7a86c80c23
commit e6e38fb4e4
7 changed files with 16 additions and 71 deletions
+1 -8
View File
@@ -106,18 +106,11 @@ module.exports = class AnimeCommand extends Command {
.send({
variables: {
search: query,
type: 'ANIME',
isAdult: Boolean(nsfw)
type: 'ANIME'
},
query: searchGraphQL
});
if (!body.data.anime.results.length) return null;
const found = body.data.anime.results.find(anime => {
if (anime.title.english && anime.title.english.toLowerCase() === query) return true;
if (anime.title.romaji && anime.title.romaji.toLowerCase() === query) return true;
return false;
});
if (found) return found.id;
return body.data.anime.results[0].id;
}