mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
padStart instead of Util.pad
This commit is contained in:
@@ -5,3 +5,6 @@ package-lock.json
|
||||
# Logs
|
||||
logs/
|
||||
*.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...');
|
||||
}
|
||||
const players = await this.generatePlayers(awaitedPlayers);
|
||||
let czars = Array.from(players.values());
|
||||
const czars = Array.from(players.values());
|
||||
let winner = null;
|
||||
while (!winner) {
|
||||
const czar = czars[0];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { filterPkmn, pad } = require('../../util/Util');
|
||||
const { filterPkmn } = require('../../util/Util');
|
||||
const { silhouette } = require('../../util/Canvas');
|
||||
|
||||
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 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`);
|
||||
let attachment = image.body;
|
||||
if (hide) {
|
||||
|
||||
@@ -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, pad } = require('../../util/Util');
|
||||
const { filterPkmn } = require('../../util/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 = pad(body.id.toString(), '000');
|
||||
const id = body.id.toString().padStart(3, '0');
|
||||
const embed = new MessageEmbed()
|
||||
.setColor(0xED1C24)
|
||||
.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 { list, pad } = require('../../util/Util');
|
||||
const { list } = require('../../util/Util');
|
||||
const modes = ['encode', 'decode'];
|
||||
|
||||
module.exports = class BinaryCommand extends Command {
|
||||
@@ -41,7 +41,7 @@ module.exports = class BinaryCommand extends Command {
|
||||
binary(text) {
|
||||
return text.split('').map(str => {
|
||||
const converted = str.charCodeAt(0).toString(2);
|
||||
return pad(converted, '00000000');
|
||||
return converted.padStart(8, '0');
|
||||
}).join(' ');
|
||||
}
|
||||
|
||||
|
||||
@@ -43,10 +43,6 @@ class Util {
|
||||
};
|
||||
}
|
||||
|
||||
static pad(text, prefix) {
|
||||
return `${prefix.slice(text.length)}${text}`;
|
||||
}
|
||||
|
||||
static randomRange(min, max) {
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user