mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Who's That Pokemon Command, Bug Fixes
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { filterPkmn } = require('../../structures/Util');
|
||||
|
||||
module.exports = class WhosThatPokemonCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'whos-that-pokemon',
|
||||
aliases: ['who-pokmeon', '', 'whos-that-pokémon', 'who-pokémon'],
|
||||
group: 'games',
|
||||
memberName: 'whos-that-pokemon',
|
||||
description: 'Guess who that Pokémon is.',
|
||||
clientPermissions: ['EMBED_LINKS']
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg) {
|
||||
const pokemon = Math.floor(Math.random() * 721) + 1;
|
||||
const { body } = await snekfetch
|
||||
.get(`https://pokeapi.co/api/v2/pokemon-species/${pokemon}`);
|
||||
const name = filterPkmn(body.names).name.toLowerCase();
|
||||
const id = `${'000'.slice(body.id.toString().length)}${body.id}`;
|
||||
const embed = new MessageEmbed()
|
||||
.setTitle('You have 15 seconds, who\'s that Pokémon?')
|
||||
.setColor(0xED1C24)
|
||||
.setImage(`https://www.serebii.net/sunmoon/pokemon/${id}.png`);
|
||||
await msg.embed(embed);
|
||||
const msgs = await msg.channel.awaitMessages(res => res.author.id === msg.author.id, {
|
||||
max: 1,
|
||||
time: 15000
|
||||
});
|
||||
if (!msgs.size) return msg.say(`Time! It was ${name}, sorry!`);
|
||||
if (msgs.first().content.toLowerCase() !== name) return msg.say(`Nope, sorry, it's ${name}.`);
|
||||
return msg.say('Nice job! 10/10! You deserve some cake!');
|
||||
}
|
||||
};
|
||||
@@ -48,7 +48,7 @@ module.exports = class OsuCommand extends Command {
|
||||
.addField('❯ Play Count',
|
||||
body[0].playcount, true)
|
||||
.addField('❯ Country',
|
||||
body[0].country, true)
|
||||
body[0].country || 'N/A', true)
|
||||
.addField('❯ Ranked Score',
|
||||
body[0].ranked_score, true)
|
||||
.addField('❯ Total Score',
|
||||
|
||||
@@ -2,6 +2,7 @@ const Command = require('../../structures/Command');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { filterPkmn } = require('../../structures/Util');
|
||||
|
||||
module.exports = class PokedexCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -31,11 +32,11 @@ module.exports = class PokedexCommand extends Command {
|
||||
const id = `${'000'.slice(body.id.toString().length)}${body.id}`;
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xED1C24)
|
||||
.setAuthor(`#${id} - ${this.filter(body.names).name}`, `https://www.serebii.net/pokedex-sm/icon/${id}.png`)
|
||||
.setAuthor(`#${id} - ${filterPkmn(body.names).name}`, `https://www.serebii.net/pokedex-sm/icon/${id}.png`)
|
||||
.setURL(`https://www.serebii.net/pokedex-sm/${id}.shtml`)
|
||||
.setDescription(stripIndents`
|
||||
**The ${this.filter(body.genera).genus} Pokémon**
|
||||
${this.filter(body.flavor_text_entries).flavor_text.replace(/(\n|\f|\r)/g, ' ')}
|
||||
**The ${filterPkmn(body.genera).genus} Pokémon**
|
||||
${filterPkmn(body.flavor_text_entries).flavor_text.replace(/(\n|\f|\r)/g, ' ')}
|
||||
`)
|
||||
.setThumbnail(`https://www.serebii.net/sunmoon/pokemon/${id}.png`);
|
||||
return msg.embed(embed);
|
||||
@@ -44,9 +45,4 @@ module.exports = class PokedexCommand extends Command {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
filter(arr) {
|
||||
const filtered = arr.filter(entry => entry.language.name === 'en');
|
||||
return filtered[Math.floor(Math.random() * filtered.length)];
|
||||
}
|
||||
};
|
||||
|
||||
@@ -45,6 +45,7 @@ module.exports = class RedditCommand extends Command {
|
||||
post.data.score, true);
|
||||
return msg.embed(embed);
|
||||
} catch (err) {
|
||||
if (err.status === 403) return msg.say('This Subreddit is Private.');
|
||||
if (err.status === 404) return msg.say('Subreddit Not Found.');
|
||||
throw err;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "31.0.2",
|
||||
"version": "31.1.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Shard.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -79,6 +79,11 @@ class Util {
|
||||
static shorten(text, maxLen = 2000) {
|
||||
return text.length > maxLen ? `${text.substr(0, maxLen - 3)}...` : text;
|
||||
}
|
||||
|
||||
static filterPkmn(arr) {
|
||||
const filtered = arr.filter(entry => entry.language.name === 'en');
|
||||
return filtered[Math.floor(Math.random() * filtered.length)];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Util;
|
||||
|
||||
Reference in New Issue
Block a user