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

@ -45,7 +45,7 @@ module.exports = class {
`
);
categories.forEach(category => {
embed.addField(`${prettified[category].emoji} **${category}**`, `*${prettified[category].description}*\n${client.commands.filter(cmd => cmd.category === category).length} commands`, true);
embed.addField(`${prettified[category].emoji} ${category}`, `*${prettified[category].description}*\n${client.commands.filter(cmd => cmd.category === category).length} commands`, true);
});
embed.setFooter('<> = required, / = either/or, [] = optional');
@ -80,13 +80,13 @@ module.exports = class {
.setTitle(prettified[command.category].emoji + ' ' + command.category + ' -> ' + command.name.toProperCase())
.setColour(client.functions.displayHexColour(message.channel.guild, client.user.id))
.setDescription(command.help.description)
.addField('**Format:**', `\`${message.prefix + command.name} ${command.help.arguments}`.trim() + '`');
if (command.help.details.length > 0) embed.addField('**Parameters:**', command.help.details);
if (command.help.examples.length > 0) embed.addField('**Examples**', command.help.examples);
if (command.aliases.length > 0) embed.addField('**Aliases:**', '`' + command.aliases.join('`, `') + '`');
if (command.userPerms.length > 0) embed.addField('**User permissions:**', command.userPerms.join(', '), true);
if (command.botPerms.length > 0) embed.addField('**Bot permissions:', command.botPerms.join(', '), true);
embed.addField('**Cooldown:**', `${command.cooldown / 1000} seconds`, true);
.addField('Format:', `\`${message.prefix + command.name} ${command.help.arguments}`.trim() + '`');
if (command.help.details.length > 0) embed.addField('Parameters:', command.help.details);
if (command.help.examples.length > 0) embed.addField('Examples', command.help.examples);
if (command.aliases.length > 0) embed.addField('Aliases:', '`' + command.aliases.join('`, `') + '`');
if (command.userPerms.length > 0) embed.addField('User permissions:', command.userPerms.join(', '), true);
if (command.botPerms.length > 0) embed.addField('Bot permissions:', command.botPerms.join(', '), true);
embed.addField('Cooldown:', `${command.cooldown / 1000} seconds`, true);
embed.setFooter('<> = required, / = either/or, [] = optional');
return message.channel.createMessage({ embed: embed });
}

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,41 +16,34 @@ 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;
fetch('https://graphqlpokemon.favware.tech/', {
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: "${query}") {
num
species
getPokemonDetailsByFuzzy(pokemon: "${args.join(' ').toLowerCase()}") {
types
sprite
shinySprite
bulbapediaPage
serebiiPage
smogonPage
}
}
`})
})
.then(res => res.json())
.then(json => {
});
const json = await res.json();
if (json.errors) {
json.errors.forEach(error => {
if (error.message.startsWith('No Pokémon found')) {
@ -64,10 +57,11 @@ module.exports = class {
return;
}
const pokemon = json.data.getPokemonDetailsByFuzzy;
console.log(pokemon.types)
console.log(json)
types = json.data.getPokemonDetailsByFuzzy.types.join(', ').toLowerCase();
} else {
types = args.join(', ').toLowerCase();
}
fetch('https://graphqlpokemon.favware.tech/', {
method: 'POST',
@ -76,53 +70,49 @@ module.exports = class {
},
body: JSON.stringify({ query: `
{
getTypeMatchup(types: [water]) {
attacking { doubleEffectiveTypes effectiveTypes resistedTypes doubleResistedTypes effectlessTypes }
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)
console.log(json.data)
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.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})`);
.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));
.catch(err => client.logger.error('TYPEMATCHUP_CMD_ERROR', err.stack));
}
parseEffectiveTypes (effective, doubleEffective) {
}
parseResistedTtypes (resisted, doubleResisted) {
}
};

View file

@ -61,15 +61,15 @@ module.exports = class {
.setTitle(`Weather for ${city + ', ' + ISO2.code[json.sys.country]}`)
.setThumbnail(`https://openweathermap.org/img/wn/${json.weather[0].icon}@4x.png`)
.setColour(embedColour)
.addField('**Condition:**', json.weather[0].main, true)
.addField('**Temperature:**', `${tempCelcius}°C | ${Math.round(json.main.temp * 9/5 - 459.67)}°F`, true)
.addField('**Min/Max**:', `
.addField('Condition:', json.weather[0].main, true)
.addField('Temperature:', `${tempCelcius}°C | ${Math.round(json.main.temp * 9/5 - 459.67)}°F`, true)
.addField('Min/Max:', `
${Math.round(json.main.temp_min - 273.15)}°C - ${Math.round(json.main.temp_max - 273.15)}°C
${Math.round(json.main.temp_min * 9/5 - 459.67)}°F - ${Math.round(json.main.temp_max * 9/5 - 459.67)}°F
`, true)
.addField('**Humidity:**', `${json.main.humidity}%`, true)
.addField('**Wind Speed:**', `${Math.round(json.wind.speed * 10) / 10}km/h | ${Math.round(json.wind.speed * 10 / 1.609344)}mi/h`, true)
.addField('**Wind Direction:**', windrose.getPoint(json.wind.deg).name, true)
.addField('Humidity:', `${json.main.humidity}%`, true)
.addField('Wind Speed:', `${Math.round(json.wind.speed * 10) / 10}km/h | ${Math.round(json.wind.speed * 10 / 1.609344)}mi/h`, true)
.addField('Wind Direction:', windrose.getPoint(json.wind.deg).name, true)
.setFooter('Powered by openweathermap.org');
return message.channel.createMessage({ embed:embed });
} else {