use fuzzy search

This commit is contained in:
Emily 2020-11-03 21:47:43 +11:00
parent ac60e717f6
commit 79a2c9a89b

View file

@ -22,9 +22,7 @@ module.exports = class {
async run (client, message, args, data) { //eslint-disable-line no-unused-vars async run (client, message, args, data) { //eslint-disable-line no-unused-vars
const query = args.join(' ');
let query = args.join(' ');
query = query.trim();
fetch('https://graphqlpokemon.favware.tech/', { fetch('https://graphqlpokemon.favware.tech/', {
method: 'POST', method: 'POST',
@ -33,7 +31,7 @@ module.exports = class {
}, },
body: JSON.stringify({ query: ` body: JSON.stringify({ query: `
{ {
getPokemonDetails(pokemon: ${query}) { getPokemonDetailsByFuzzy(pokemon: "${query}") {
num num
species species
types types
@ -62,7 +60,7 @@ module.exports = class {
}) })
.then((res) => res.json()) .then((res) => res.json())
.then((json) => { .then((json) => {
const pokemon = json.data.getPokemonDetails; const pokemon = json.data.getPokemonDetailsByFuzzy;
const evoChain = this.parseEvoChain(pokemon); const evoChain = this.parseEvoChain(pokemon);
const genderRatio = this.parseGenderRatio(pokemon.gender); const genderRatio = this.parseGenderRatio(pokemon.gender);
const abilities = this.parseAbilities(pokemon.abilities); const abilities = this.parseAbilities(pokemon.abilities);