Advertisement
Lockyz

poke.js

May 20th, 2020
1,386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { RichEmbed } = require('discord.js');
  2. const { noBotPerms } = require('../utils/errors');
  3. const pokemon = require('../db/pokemon.js');
  4.  
  5. exports.run = async (client, message, args) => {
  6.  
  7.     let perms = message.guild.me.permissions;
  8.     if (!perms.has('EMBED_LINKS')) return noBotPerms(message, 'EMBED_LINKS');
  9.     var msg = message;
  10.  
  11.     if(!args) {
  12.         const embed = new RichEmbed()
  13.             .setTitle("Error")
  14.             .setDescription("A pokemon needs to be entered.")
  15.         message.channel.send(embed)
  16.         return;
  17.     }
  18.  
  19.     let pkmon = args.toString().toLowerCase();
  20.  
  21.     for(var i=0;i<pokemon.length;i++){
  22.         if(pkmon == pokemon[i].species.toLowerCase()){
  23.             let description = pokemon[i].description;
  24.             let otherFormes = pokemon[i].otherFormes;
  25.             const db = "https://db.lockyzgroup.net/dismon/sprites/"+pokemon[i].species.toLowerCase()+".gif"
  26.             const embed = new RichEmbed()
  27.                 .setTitle("NĀ° "+pokemon[i].num+ " " +pokemon[i].species)
  28.                 .setThumbnail(db)
  29.                 .setAuthor("Pokedex")
  30.                 .addField(`Type`, pokemon[i].types, true)
  31.  
  32.                 if(pokemon[i].num >= 0 && pokemon[i].num <= 151) {
  33.                     embed.addField('Gen', '1', true)
  34.                 }
  35.                 if(pokemon[i].num >= 152 && pokemon[i].num <= 251) {
  36.                     embed.addField('Gen', '2', true)
  37.                 }
  38.                 if(pokemon[i].num >= 252 && pokemon[i].num <= 386) {
  39.                     embed.addField('Gen', '3', true)
  40.                 }
  41.                 if(pokemon[i].num >= 387 && pokemon[i].num <= 493) {
  42.                     embed.addField('Gen', '4', true)
  43.                 }
  44.                 if(pokemon[i].num >= 494 && pokemon[i].num <= 649) {
  45.                     embed.addField('Gen', '5', true)
  46.                 }
  47.                 if(pokemon[i].num >= 650 && pokemon[i].num <= 721) {
  48.                     embed.addField('Gen', '6', true)
  49.                 }
  50.                 if(pokemon[i].num >= 722 && pokemon[i].num <= 809) {
  51.                     embed.addField('Gen', '7', true)
  52.                 }
  53.                 if(pokemon[i].num >= 810 && pokemon[i].num <= 894) {
  54.                     embed.addField('Gen', '8', true)
  55.                 }
  56.  
  57.                 if(otherFormes === undefined) {
  58.                     embed.addField(`Formes`, "No formes found", true)
  59.                 } else {
  60.                     embed.addField(`Formes`, otherFormes, true)
  61.                 }
  62.  
  63.                 embed.addBlankField()
  64.                 //embed.addField('Base Stats')
  65.                 embed.addField('HP', pokemon[i].baseStats.hp, true)
  66.                 embed.addField('ATK', pokemon[i].baseStats.atk, true)
  67.                 embed.addField('DEF', pokemon[i].baseStats.def, true)
  68.                 embed.addField('S. ATK', pokemon[i].baseStats.spa, true)
  69.                 embed.addField('S. DEF', pokemon[i].baseStats.spd, true)
  70.                 embed.addBlankField(true)
  71.  
  72.                 if(description === undefined) {
  73.                     embed.setDescription("A description could not be found. Please help us update our database [here](https://github.com/lockyz/dismon-database)")
  74.                 } else {
  75.                     embed.setDescription(description)
  76.                 }
  77.                 embed.addBlankField()
  78.                 embed.addField(`Ability 1`, pokemon[i].abilities[0], true)
  79.                 if(pokemon[i].abilities[1] === undefined) {
  80.                 } else {
  81.                     embed.addField(`Ability 2`, pokemon[i].abilities[1], true)
  82.                 }
  83.                 if(pokemon[i].abilities.H === undefined) {
  84.                 } else {
  85.                     embed.addField(`Hidden Ability`, pokemon[i].abilities.H, true)
  86.                 }
  87.                 embed.addField(`Innacurate Information?`, `Help us update it [here](https://github.com/lockyz/dismon-database)`)
  88.             return message.channel.send({embed});
  89.         }
  90.     }
  91.     for(var i=0;!i<pokemon.length;i++){
  92.         const embed = new RichEmbed()
  93.                 .setTitle(`Typedex`)
  94.                 .setThumbnail("https://db.lockyzgroup.net/dismon/unknown.png")  
  95.                 .setDescription("Your Type could not be found.\nIf you believe this was done in error help us update our database [here](https://github.com/lockyz/dismon-database)")
  96.             message.channel.send(embed)
  97.             return;
  98.     }
  99.     return;
  100. };
  101.  
  102. exports.help = {
  103.     name: 'pokedex',
  104.     aliases: ['poke', 'pdex'],
  105.     description: 'Get Poke Information.',
  106.     usage: 'pokedex {Pokemon}'
  107. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement