unbold titles

This commit is contained in:
Emily 2020-11-06 14:42:52 +11:00
parent bd0f53c1ed
commit 88b17808d1
4 changed files with 77 additions and 87 deletions

View file

@ -69,7 +69,7 @@ module.exports = class {
.setColour(client.functions.displayHexColour(message.channel.guild, client.user.id))
.setTitle(ability.name.toProperCase())
.setDescription(ability.desc)
.addField('**External Resources:**', `[Bulbapedia](${ability.bulbapediaPage}) | [Serebii](${ability.serebiiPage}) | [Smogon](${ability.smogonPage})`);
.addField('External Resources:', `[Bulbapedia](${ability.bulbapediaPage}) | [Serebii](${ability.serebiiPage}) | [Smogon](${ability.smogonPage})`);
message.channel.createMessage({ embed: embed });
})
.catch(err => console.log(err));

View file

@ -1,5 +1,5 @@
const Embed = require('../../util/embed');
const colours = require('../../assets/constants/typeColours.json');
const { typeArray, colours } = require('../../assets/constants/pokemon.json');
const fetch = require('node-fetch');
module.exports = class {
@ -16,18 +16,52 @@ module.exports = class {
description: 'Get useful data on any pokemon you ask me to!',
arguments: '<pokemon>',
details: '',
examples: '`pokemon mudkip`\n`pokemon giratina-origin`'
examples: '`pokemon mudkip`\n`pokemon giratina origin`'
};
}
async run (client, message, args, data) { //eslint-disable-line no-unused-vars
if (!args[0]) return message.channel.createMessage(
`${client.constants.emojis.userError} You didn't give me a pokemon to look up!`
`${client.constants.emojis.userError} You didn't give me a pokemon or type combination to look up! Usage: \`${message.prefix + this.name + ' ' + this.help.arguments}\``
);
message.channel.sendTyping();
const query = args.join(' ').toLowerCase();
let types;
if (!typeArray.includes(args[0].toProperCase())) {
const res = await fetch('https://graphqlpokemon.favware.tech/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ query: `
{
getPokemonDetailsByFuzzy(pokemon: "${args.join(' ').toLowerCase()}") {
types
}
}
`})
});
const json = await res.json();
if (json.errors) {
json.errors.forEach(error => {
if (error.message.startsWith('No Pokémon found')) {
message.channel.createMessage(
`${client.constants.emojis.userError} I couldn't find any Pokemon with names similar to ${query}. Check your spelling, maybe?`
);
} else {
client.logger.error('POKEMON_FETCH_ERROR', error.message);
}
});
return;
}
console.log(json)
types = json.data.getPokemonDetailsByFuzzy.types.join(', ').toLowerCase();
} else {
types = args.join(', ').toLowerCase();
}
fetch('https://graphqlpokemon.favware.tech/', {
method: 'POST',
@ -36,21 +70,16 @@ module.exports = class {
},
body: JSON.stringify({ query: `
{
getPokemonDetailsByFuzzy(pokemon: "${query}") {
num
species
types
sprite
shinySprite
bulbapediaPage
serebiiPage
smogonPage
getTypeMatchup(types: [${types}]) {
attacking { doubleEffectiveTypes effectiveTypes normalTypes resistedTypes doubleResistedTypes effectlessTypes }
defending { doubleEffectiveTypes effectiveTypes normalTypes resistedTypes doubleResistedTypes effectlessTypes }
}
}
`})
})
.then(res => res.json())
.then(json => {
console.log(json.data)
if (json.errors) {
json.errors.forEach(error => {
if (error.message.startsWith('No Pokémon found')) {
@ -61,68 +90,29 @@ module.exports = class {
client.logger.error('POKEMON_FETCH_ERROR', error.message);
}
});
return;
}
const pokemon = json.data.getPokemonDetailsByFuzzy;
console.log(pokemon.types)
fetch('https://graphqlpokemon.favware.tech/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ query: `
{
getTypeMatchup(types: [water]) {
attacking { doubleEffectiveTypes effectiveTypes resistedTypes doubleResistedTypes effectlessTypes }
}
}
`})
})
.then(res => res.json())
.then(json => {
console.log(json)
if (json.errors) {
json.errors.forEach(error => {
client.logger.error('POKEMON_FETCH_ERROR', error.message);
});
return;
}
console.log(json.data)
const typeMatchup = json.data.getTypeMatchup;
let doubleEffective = '';
if (typeMatchup.doubleEffectiveTypes && typeMatchup.doubleEffectiveTypes.length > 0) {
doubleEffective = '**' + typeMatchup.doubleEffectiveTypes.join('**, **') + '**';
doubleEffective = doubleEffective.concat(typeMatchup.effectiveTypes).join(', ');
}
let doubleResists = '';
if (typeMatchup.doubleResistedTypes && typeMatchup.doubleResistedTypes.length > 0) {
doubleResists = '**' + typeMatchup.doubleResistedTypes.join('** **') + '**';
doubleResists = doubleResists.split(' ');
doubleResists = doubleResists.concat(typeMatchup.resistedTypes).join(', ');
}
const embed = new Embed()
.setColour(colours[pokemon.types[0]])
.setTitle(`${pokemon.species.toProperCase()} (No. ${pokemon.num})`)
.setThumbnail(pokemon.sprite)
.addField('**Types:**', pokemon.types.join(', '), true)
.addField('**Weak to:**', doubleEffective)
.addField('**Strong against:**', doubleResists)
.addField('**Immune to:**', typeMatchup.effectlessTypes.join(' '))
.addField('**External Resources:**', `[Bulbapedia](${pokemon.bulbapediaPage}) | [Serebii](${pokemon.serebiiPage}) | [Smogon](${pokemon.smogonPage})`);
message.channel.createMessage({ embed: embed });
})
.catch(err => client.logger.error('TYPEMATCHUP_CMD_ERROR', err));
const typeMatchup = json.data.getTypeMatchup;
const embed = new Embed()
.setTitle('Offensive')
.addField('Weak to:', typeMatchup.attacking.effectiveTypes.join(', '))
.addField('Strong against:', typeMatchup.attacking.resistedTypes.join(', '));
//.addField('Immune to:', typeMatchup.effectlessTypes.join(' '));
//.addField('External Resources:', `[Bulbapedia](${pokemon.bulbapediaPage}) | [Serebii](${pokemon.serebiiPage}) | [Smogon](${pokemon.smogonPage})`);
message.channel.createMessage({ embed: embed });
})
.catch(err => client.logger.error('TYPEMATCHUP_CMD_ERROR', err));
.catch(err => client.logger.error('TYPEMATCHUP_CMD_ERROR', err.stack));
}
parseEffectiveTypes (effective, doubleEffective) {
}
parseResistedTtypes (resisted, doubleResisted) {
}
};