STUFF
This commit is contained in:
		
							parent
							
								
									ce709f0576
								
							
						
					
					
						commit
						5e98cb6c12
					
				
					 4 changed files with 137 additions and 3 deletions
				
			
		| 
						 | 
					@ -12,10 +12,10 @@ module.exports = class {
 | 
				
			||||||
        this.botPerms = [],
 | 
					        this.botPerms = [],
 | 
				
			||||||
        this.cooldown = 2000,
 | 
					        this.cooldown = 2000,
 | 
				
			||||||
        this.help = {
 | 
					        this.help = {
 | 
				
			||||||
            description: '',
 | 
					            description: 'Get data on a Pokemon ability.',
 | 
				
			||||||
            arguments: '',
 | 
					            arguments: '<ability>',
 | 
				
			||||||
            details: '',
 | 
					            details: '',
 | 
				
			||||||
            examples: ''
 | 
					            examples: '`ability intimidate`\n`ability moxie`'
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -62,6 +62,9 @@ module.exports = class {
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                const ability = json.data.getAbilityDetailsByFuzzy;
 | 
					                const ability = json.data.getAbilityDetailsByFuzzy;
 | 
				
			||||||
 | 
					                if (!ability.desc) return message.channel.createMessage(
 | 
				
			||||||
 | 
					                    `${client.constants.emojis.botError} I'm missing data for this ability so I can't show it to you, sorry! ;w;`
 | 
				
			||||||
 | 
					                )
 | 
				
			||||||
                const embed = new Embed()
 | 
					                const embed = new Embed()
 | 
				
			||||||
                    .setColour(client.functions.displayHexColour(message.channel.guild, client.user.id))
 | 
					                    .setColour(client.functions.displayHexColour(message.channel.guild, client.user.id))
 | 
				
			||||||
                    .setTitle(ability.name.toProperCase())
 | 
					                    .setTitle(ability.name.toProperCase())
 | 
				
			||||||
							
								
								
									
										0
									
								
								bot/commands/Fun/pokeitem.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								bot/commands/Fun/pokeitem.js
									
										
									
									
									
										Normal file
									
								
							
							
								
								
									
										0
									
								
								bot/commands/Fun/pokemove.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								bot/commands/Fun/pokemove.js
									
										
									
									
									
										Normal file
									
								
							
							
								
								
									
										131
									
								
								bot/commands/Fun/typematchup.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										131
									
								
								bot/commands/Fun/typematchup.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,131 @@
 | 
				
			||||||
 | 
					const Embed = require('../../util/embed');
 | 
				
			||||||
 | 
					const colours = require('../../assets/constants/typeColours.json');
 | 
				
			||||||
 | 
					const fetch = require('node-fetch');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					module.exports = class {
 | 
				
			||||||
 | 
					    constructor (name, category) {
 | 
				
			||||||
 | 
					        this.name = name,
 | 
				
			||||||
 | 
					        this.category = category,
 | 
				
			||||||
 | 
					        this.enabled = true,
 | 
				
			||||||
 | 
					        this.devOnly = false,
 | 
				
			||||||
 | 
					        this.aliases = ['pokedex', 'dex'],
 | 
				
			||||||
 | 
					        this.userPerms = [],
 | 
				
			||||||
 | 
					        this.botPerms = [],
 | 
				
			||||||
 | 
					        this.cooldown = 5000,
 | 
				
			||||||
 | 
					        this.help = {
 | 
				
			||||||
 | 
					            description: 'Get useful data on any pokemon you ask me to!',
 | 
				
			||||||
 | 
					            arguments: '<pokemon>',
 | 
				
			||||||
 | 
					            details: '',
 | 
				
			||||||
 | 
					            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!`
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        message.channel.sendTyping();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        const query = args.join(' ').toLowerCase();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        fetch('https://graphqlpokemon.favware.tech/', {
 | 
				
			||||||
 | 
					            method: 'POST',
 | 
				
			||||||
 | 
					            headers: {
 | 
				
			||||||
 | 
					                'Content-Type': 'application/json'
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            body: JSON.stringify({ query: `
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    getPokemonDetailsByFuzzy(pokemon: "${query}") {
 | 
				
			||||||
 | 
					                        num
 | 
				
			||||||
 | 
					                        species
 | 
				
			||||||
 | 
					                        types
 | 
				
			||||||
 | 
					                        sprite
 | 
				
			||||||
 | 
					                        shinySprite
 | 
				
			||||||
 | 
					                        bulbapediaPage
 | 
				
			||||||
 | 
					                        serebiiPage
 | 
				
			||||||
 | 
					                        smogonPage
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            `})
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
 | 
					            .then(res => res.json())
 | 
				
			||||||
 | 
					            .then(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;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                const pokemon = json.data.getPokemonDetailsByFuzzy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                fetch('https://graphqlpokemon.favware.tech/', {
 | 
				
			||||||
 | 
					                    method: 'POST',
 | 
				
			||||||
 | 
					                    headers: {
 | 
				
			||||||
 | 
					                        'Content-Type': 'application/json'
 | 
				
			||||||
 | 
					                    },
 | 
				
			||||||
 | 
					                    body: JSON.stringify({ query: `
 | 
				
			||||||
 | 
					                        {
 | 
				
			||||||
 | 
					                            getPokemonDetailsByFuzzy(pokemon: "${query}") {
 | 
				
			||||||
 | 
					                                num
 | 
				
			||||||
 | 
					                                species
 | 
				
			||||||
 | 
					                                types
 | 
				
			||||||
 | 
					                                sprite
 | 
				
			||||||
 | 
					                                shinySprite
 | 
				
			||||||
 | 
					                                bulbapediaPage
 | 
				
			||||||
 | 
					                                serebiiPage
 | 
				
			||||||
 | 
					                                smogonPage
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    `})
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					                    .then(res => res.json())
 | 
				
			||||||
 | 
					                    .then(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.attacking;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        let doubleEffective = '';
 | 
				
			||||||
 | 
					                        if (typeMatchup.doubleEffectiveTypes.length > 0) {
 | 
				
			||||||
 | 
					                            doubleEffective = '**' + typeMatchup.doubleEffectiveTypes.join('** **') + '**';
 | 
				
			||||||
 | 
					                            doubleEffective = doubleEffective.split(' ');
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        let doubleResists = '';
 | 
				
			||||||
 | 
					                        if (typeMatchup.doubleResistedTypes.length > 0) {
 | 
				
			||||||
 | 
					                            doubleResists = '**' + typeMatchup.doubleResistedTypes.join('** **') + '**';
 | 
				
			||||||
 | 
					                            doubleResists = doubleResists.split(' ');
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                        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.concat(typeMatchup.effectiveTypes).join(', '))
 | 
				
			||||||
 | 
					                            .addField('**Strong against:**', doubleResists.concat(typeMatchup.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));
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue