Format numbers, style changes, fixes

This commit is contained in:
Daniel Odendahl Jr
2018-10-13 02:28:07 +00:00
parent 5c2c9d25a5
commit b0780575be
45 changed files with 146 additions and 159 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command');
const { formatNumber } = require('../../util/Util');
module.exports = class CharacterCountCommand extends Command {
constructor(client) {
@@ -19,6 +20,6 @@ module.exports = class CharacterCountCommand extends Command {
}
run(msg, { text }) {
return msg.reply(text.length);
return msg.reply(formatNumber(text.length));
}
};
+2 -1
View File
@@ -1,5 +1,6 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const { formatNumber } = require('../../util/Util');
module.exports = class CurrencyCommand extends Command {
constructor(client) {
@@ -41,7 +42,7 @@ module.exports = class CurrencyCommand extends Command {
if (base === target) return msg.say(`Converting ${base} to ${target} is the same value, dummy.`);
try {
const rate = await this.fetchRate(base, target);
return msg.say(`${amount} ${base} is ${(amount * rate).toFixed(2)} ${target}.`);
return msg.say(`${formatNumber(amount)} ${base} is ${formatNumber(amount * rate)} ${target}.`);
} catch (err) {
if (err.status === 400) return msg.say('Invalid base/target.');
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
+3 -2
View File
@@ -1,5 +1,5 @@
const Command = require('../../structures/Command');
const { list, firstUpperCase } = require('../../util/Util');
const { list, firstUpperCase, formatNumber } = require('../../util/Util');
const planets = require('../../assets/json/gravity');
module.exports = class GravityCommand extends Command {
@@ -28,6 +28,7 @@ module.exports = class GravityCommand extends Command {
}
run(msg, { weight, planet }) {
return msg.say(`${weight} kg on ${firstUpperCase(planet)} is ${weight * planets[planet]} kg.`);
const result = weight * planets[planet];
return msg.say(`${formatNumber(weight)} kg on ${firstUpperCase(planet)} is ${formatNumber(result)} kg.`);
}
};
+2 -1
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command');
const { formatNumber } = require('../../util/Util');
module.exports = class PrimeCommand extends Command {
constructor(client) {
@@ -20,7 +21,7 @@ module.exports = class PrimeCommand extends Command {
}
run(msg, { number }) {
return msg.reply(`${number} is${this.isPrime(number) ? '' : ' not'} a prime number.`);
return msg.reply(`${formatNumber(number)} is${this.isPrime(number) ? '' : ' not'} a prime number.`);
}
isPrime(number) {
+2 -1
View File
@@ -1,4 +1,5 @@
const Command = require('../../structures/Command');
const { formatNumber } = require('../../util/Util');
const letters = require('../../assets/json/scrabble-score');
module.exports = class ScrabbleScoreCommand extends Command {
@@ -26,6 +27,6 @@ module.exports = class ScrabbleScoreCommand extends Command {
if (!letters[letter]) continue;
score += letters[letter];
}
return msg.reply(score);
return msg.reply(formatNumber(score));
}
};
+2 -1
View File
@@ -1,5 +1,6 @@
const Command = require('../../structures/Command');
const math = require('mathjs');
const { formatNumber } = require('../../util/Util');
module.exports = class UnitsCommand extends Command {
constructor(client) {
@@ -34,7 +35,7 @@ module.exports = class UnitsCommand extends Command {
run(msg, { base, target, amount }) {
try {
const value = math.unit(amount, base).toNumber(target);
return msg.say(`${amount} ${base} is ${value} ${target}.`);
return msg.say(`${formatNumber(amount)} ${base} is ${formatNumber(value)} ${target}.`);
} catch (err) {
return msg.say('Either an invalid unit type was provided or the unit types do not match.');
}