padStart instead of Util.pad

This commit is contained in:
Daniel Odendahl Jr
2018-01-28 02:04:04 +00:00
parent d63cfef8a0
commit d58364a3d1
6 changed files with 10 additions and 11 deletions
+3
View File
@@ -5,3 +5,6 @@ package-lock.json
# Logs
logs/
*.log
# Unfinished Commands
commands/games/tricks.js
+1 -1
View File
@@ -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];
+2 -2
View File
@@ -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 -2
View File
@@ -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`)
+2 -2
View File
@@ -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(' ');
}
-4
View File
@@ -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;
}