Rule of the internet, better units

This commit is contained in:
Daniel Odendahl Jr
2018-03-23 21:00:32 +00:00
parent dd7ece36a2
commit c52d833b9d
5 changed files with 83 additions and 4 deletions
+2 -2
View File
@@ -33,8 +33,8 @@ module.exports = class UnitsCommand extends Command {
run(msg, { base, target, amount }) {
try {
const value = math.unit(amount, base).to(target).toString();
return msg.say(value);
const value = math.unit(amount, base).toNumber(target);
return msg.say(`${amount} ${base} is ${value} ${target}.`);
} catch (err) {
return msg.say('Either an invalid unit type was provided or the unit types do not match.');
}
+29
View File
@@ -0,0 +1,29 @@
const { Command } = require('discord.js-commando');
const rules = require('../../assets/json/rule-of-the-internet');
module.exports = class RuleOfTheInternetCommand extends Command {
constructor(client) {
super(client, {
name: 'rule-of-the-internet',
aliases: ['rules-of-the-internet', 'internet-rule', 'rule'],
group: 'search',
memberName: 'rule-of-the-internet',
description: 'Responds with a rule of the internet.',
args: [
{
key: 'rule',
prompt: 'Which rule would you like to view?',
type: 'integer',
default: '',
min: 1,
max: rules.length
}
]
});
}
run(msg, { rule }) {
if (!rule) return msg.say({ files: ['https://i.imgur.com/vGw29EQ.jpg'] });
return msg.say(`**Rule #${rule}**: ${rules[rule - 1]}`);
}
};