mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 21:44:48 +02:00
padStart instead of Util.pad
This commit is contained in:
@@ -5,3 +5,6 @@ package-lock.json
|
|||||||
# Logs
|
# Logs
|
||||||
logs/
|
logs/
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
|
# Unfinished Commands
|
||||||
|
commands/games/tricks.js
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ module.exports = class CardsAgainstHumanityCommand extends Command {
|
|||||||
return msg.say('Game could not be started...');
|
return msg.say('Game could not be started...');
|
||||||
}
|
}
|
||||||
const players = await this.generatePlayers(awaitedPlayers);
|
const players = await this.generatePlayers(awaitedPlayers);
|
||||||
let czars = Array.from(players.values());
|
const czars = Array.from(players.values());
|
||||||
let winner = null;
|
let winner = null;
|
||||||
while (!winner) {
|
while (!winner) {
|
||||||
const czar = czars[0];
|
const czar = czars[0];
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
const { Command } = require('discord.js-commando');
|
||||||
const { createCanvas, loadImage } = require('canvas');
|
const { createCanvas, loadImage } = require('canvas');
|
||||||
const snekfetch = require('snekfetch');
|
const snekfetch = require('snekfetch');
|
||||||
const { filterPkmn, pad } = require('../../util/Util');
|
const { filterPkmn } = require('../../util/Util');
|
||||||
const { silhouette } = require('../../util/Canvas');
|
const { silhouette } = require('../../util/Canvas');
|
||||||
|
|
||||||
module.exports = class WhosThatPokemonCommand extends Command {
|
module.exports = class WhosThatPokemonCommand extends Command {
|
||||||
@@ -43,7 +43,7 @@ module.exports = class WhosThatPokemonCommand extends Command {
|
|||||||
}
|
}
|
||||||
const names = data.names.map(name => name.name.toLowerCase());
|
const names = data.names.map(name => name.name.toLowerCase());
|
||||||
const displayName = filterPkmn(data.names).name;
|
const displayName = filterPkmn(data.names).name;
|
||||||
const id = pad(data.id.toString(), '000');
|
const id = data.id.toString().padStart(3, '0');
|
||||||
const image = await snekfetch.get(`https://www.serebii.net/sunmoon/pokemon/${id}.png`);
|
const image = await snekfetch.get(`https://www.serebii.net/sunmoon/pokemon/${id}.png`);
|
||||||
let attachment = image.body;
|
let attachment = image.body;
|
||||||
if (hide) {
|
if (hide) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const { Command } = require('discord.js-commando');
|
|||||||
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, pad } = require('../../util/Util');
|
const { filterPkmn } = require('../../util/Util');
|
||||||
|
|
||||||
module.exports = class PokedexCommand extends Command {
|
module.exports = class PokedexCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -27,7 +27,7 @@ module.exports = class PokedexCommand extends Command {
|
|||||||
async run(msg, { pokemon }) {
|
async run(msg, { pokemon }) {
|
||||||
try {
|
try {
|
||||||
const { body } = await snekfetch.get(`https://pokeapi.co/api/v2/pokemon-species/${pokemon}/`);
|
const { body } = await snekfetch.get(`https://pokeapi.co/api/v2/pokemon-species/${pokemon}/`);
|
||||||
const id = pad(body.id.toString(), '000');
|
const id = body.id.toString().padStart(3, '0');
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setColor(0xED1C24)
|
.setColor(0xED1C24)
|
||||||
.setAuthor(`#${id} - ${filterPkmn(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`)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
const { Command } = require('discord.js-commando');
|
||||||
const { list, pad } = require('../../util/Util');
|
const { list } = require('../../util/Util');
|
||||||
const modes = ['encode', 'decode'];
|
const modes = ['encode', 'decode'];
|
||||||
|
|
||||||
module.exports = class BinaryCommand extends Command {
|
module.exports = class BinaryCommand extends Command {
|
||||||
@@ -41,7 +41,7 @@ module.exports = class BinaryCommand extends Command {
|
|||||||
binary(text) {
|
binary(text) {
|
||||||
return text.split('').map(str => {
|
return text.split('').map(str => {
|
||||||
const converted = str.charCodeAt(0).toString(2);
|
const converted = str.charCodeAt(0).toString(2);
|
||||||
return pad(converted, '00000000');
|
return converted.padStart(8, '0');
|
||||||
}).join(' ');
|
}).join(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,10 +43,6 @@ class Util {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static pad(text, prefix) {
|
|
||||||
return `${prefix.slice(text.length)}${text}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
static randomRange(min, max) {
|
static randomRange(min, max) {
|
||||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user