From d58364a3d13eca3b5bd7f8d991d225cd6d5f2d54 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Sun, 28 Jan 2018 02:04:04 +0000 Subject: [PATCH] padStart instead of Util.pad --- .gitignore | 3 +++ commands/games/cards-against-humanity.js | 2 +- commands/games/whos-that-pokemon.js | 4 ++-- commands/search/pokedex.js | 4 ++-- commands/text-edit/binary.js | 4 ++-- util/Util.js | 4 ---- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 0c65b2e3..984cc017 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ package-lock.json # Logs logs/ *.log + +# Unfinished Commands +commands/games/tricks.js diff --git a/commands/games/cards-against-humanity.js b/commands/games/cards-against-humanity.js index 72bc80d8..087dbaa3 100644 --- a/commands/games/cards-against-humanity.js +++ b/commands/games/cards-against-humanity.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]; diff --git a/commands/games/whos-that-pokemon.js b/commands/games/whos-that-pokemon.js index 485f83fd..49359de2 100644 --- a/commands/games/whos-that-pokemon.js +++ b/commands/games/whos-that-pokemon.js @@ -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) { diff --git a/commands/search/pokedex.js b/commands/search/pokedex.js index 06fe8f67..52508481 100644 --- a/commands/search/pokedex.js +++ b/commands/search/pokedex.js @@ -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`) diff --git a/commands/text-edit/binary.js b/commands/text-edit/binary.js index a67f86c0..9d0ec314 100644 --- a/commands/text-edit/binary.js +++ b/commands/text-edit/binary.js @@ -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(' '); } diff --git a/util/Util.js b/util/Util.js index d1d812dc..19dc878d 100644 --- a/util/Util.js +++ b/util/Util.js @@ -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; }