mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 14:19:11 +02:00
Format numbers, style changes, fixes
This commit is contained in:
@@ -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));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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!`);
|
||||
|
||||
@@ -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.`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user