mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 06:45:31 +02:00
Cool pad thing
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { filterPkmn } = require('../../structures/Util');
|
||||
const { filterPkmn, pad } = require('../../structures/Util');
|
||||
|
||||
module.exports = class WhosThatPokemonCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -11,7 +10,7 @@ module.exports = class WhosThatPokemonCommand extends Command {
|
||||
group: 'games',
|
||||
memberName: 'whos-that-pokemon',
|
||||
description: 'Guess who that Pokémon is.',
|
||||
clientPermissions: ['EMBED_LINKS']
|
||||
clientPermissions: ['ATTACH_FILES']
|
||||
});
|
||||
}
|
||||
|
||||
@@ -21,12 +20,8 @@ module.exports = class WhosThatPokemonCommand extends Command {
|
||||
const { body } = await snekfetch.get(`https://pokeapi.co/api/v2/pokemon-species/${pokemon}/`);
|
||||
const names = body.names.map(name => name.name.toLowerCase());
|
||||
const displayName = filterPkmn(body.names).name;
|
||||
const id = `${'000'.slice(body.id.toString().length)}${body.id}`;
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xED1C24)
|
||||
.setTitle('You have 15 seconds, who\'s that Pokémon?')
|
||||
.setImage(`https://www.serebii.net/sunmoon/pokemon/${id}.png`);
|
||||
await msg.embed(embed);
|
||||
const image = `https://www.serebii.net/sunmoon/pokemon/${pad(body.id.toString(), '000')}.png`;
|
||||
await msg.say('**You have 15 seconds, who\'s that Pokémon?**', { files: [image] });
|
||||
const msgs = await msg.channel.awaitMessages(res => res.author.id === msg.author.id, {
|
||||
max: 1,
|
||||
time: 15000
|
||||
|
||||
@@ -36,6 +36,6 @@ module.exports = class PokemonFusionCommand extends Command {
|
||||
}
|
||||
|
||||
run(msg, { body, palette }) {
|
||||
return msg.say(`http://images.alexonsager.net/pokemon/fused/${body}/${body}.${palette}.png`);
|
||||
return msg.say({ files: [`http://images.alexonsager.net/pokemon/fused/${body}/${body}.${palette}.png`] });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ const { Command } = require('discord.js-commando');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { filterPkmn } = require('../../structures/Util');
|
||||
const { filterPkmn, pad } = require('../../structures/Util');
|
||||
|
||||
module.exports = class PokedexCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -27,7 +27,7 @@ module.exports = class PokedexCommand extends Command {
|
||||
async run(msg, { pokemon }) {
|
||||
try {
|
||||
const { body } = await snekfetch.get(`https://pokeapi.co/api/v2/pokemon-species/${pokemon}/`);
|
||||
const id = `${'000'.slice(body.id.toString().length)}${body.id}`;
|
||||
const id = pad(body.id.toString(), '000');
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xED1C24)
|
||||
.setAuthor(`#${id} - ${filterPkmn(body.names).name}`, `https://www.serebii.net/pokedex-sm/icon/${id}.png`)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { pad } = require('../../structures/Util');
|
||||
|
||||
module.exports = class BinaryCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -28,7 +29,7 @@ module.exports = class BinaryCommand extends Command {
|
||||
binary(text) {
|
||||
return text.split('').map(str => {
|
||||
const converted = str.charCodeAt(0).toString(2);
|
||||
return `${'00000000'.slice(converted.length)}${converted}`;
|
||||
return pad(converted, '00000000');
|
||||
}).join('');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -56,6 +56,10 @@ class Util {
|
||||
format: () => `${hrs < 10 ? `0${hrs}` : hrs}:${min < 10 ? `0${min}` : min}:${sec < 10 ? `0${sec}` : sec}`
|
||||
};
|
||||
}
|
||||
|
||||
static pad(text, prefix) {
|
||||
return `${prefix.slice(text.length)}${text}`;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Util;
|
||||
|
||||
Reference in New Issue
Block a user