mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-23 18:05:01 +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',
|
.addField('❯ Play Count',
|
||||||
body[0].playcount, true)
|
body[0].playcount, true)
|
||||||
.addField('❯ Country',
|
.addField('❯ Country',
|
||||||
body[0].country, true)
|
body[0].country || 'N/A', true)
|
||||||
.addField('❯ Ranked Score',
|
.addField('❯ Ranked Score',
|
||||||
body[0].ranked_score, true)
|
body[0].ranked_score, true)
|
||||||
.addField('❯ Total Score',
|
.addField('❯ Total Score',
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const Command = require('../../structures/Command');
|
|||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const snekfetch = require('snekfetch');
|
const snekfetch = require('snekfetch');
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
|
const { filterPkmn } = require('../../structures/Util');
|
||||||
|
|
||||||
module.exports = class PokedexCommand extends Command {
|
module.exports = class PokedexCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -31,11 +32,11 @@ module.exports = class PokedexCommand extends Command {
|
|||||||
const id = `${'000'.slice(body.id.toString().length)}${body.id}`;
|
const id = `${'000'.slice(body.id.toString().length)}${body.id}`;
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setColor(0xED1C24)
|
.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`)
|
.setURL(`https://www.serebii.net/pokedex-sm/${id}.shtml`)
|
||||||
.setDescription(stripIndents`
|
.setDescription(stripIndents`
|
||||||
**The ${this.filter(body.genera).genus} Pokémon**
|
**The ${filterPkmn(body.genera).genus} Pokémon**
|
||||||
${this.filter(body.flavor_text_entries).flavor_text.replace(/(\n|\f|\r)/g, ' ')}
|
${filterPkmn(body.flavor_text_entries).flavor_text.replace(/(\n|\f|\r)/g, ' ')}
|
||||||
`)
|
`)
|
||||||
.setThumbnail(`https://www.serebii.net/sunmoon/pokemon/${id}.png`);
|
.setThumbnail(`https://www.serebii.net/sunmoon/pokemon/${id}.png`);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
@@ -44,9 +45,4 @@ module.exports = class PokedexCommand extends Command {
|
|||||||
throw err;
|
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);
|
post.data.score, true);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
if (err.status === 403) return msg.say('This Subreddit is Private.');
|
||||||
if (err.status === 404) return msg.say('Subreddit Not Found.');
|
if (err.status === 404) return msg.say('Subreddit Not Found.');
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiaobot",
|
"name": "xiaobot",
|
||||||
"version": "31.0.2",
|
"version": "31.1.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Shard.js",
|
"main": "Shard.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -79,6 +79,11 @@ class Util {
|
|||||||
static shorten(text, maxLen = 2000) {
|
static shorten(text, maxLen = 2000) {
|
||||||
return text.length > maxLen ? `${text.substr(0, maxLen - 3)}...` : text;
|
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;
|
module.exports = Util;
|
||||||
|
|||||||
Reference in New Issue
Block a user