mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-12 08:14:47 +02:00
Gravity Command
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { list, firstUpperCase } = require('../../util/Util');
|
||||
const planets = require('../../assets/json/gravity');
|
||||
|
||||
module.exports = class GravityCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'gravity',
|
||||
group: 'number-edit',
|
||||
memberName: 'gravity',
|
||||
description: 'Determines weight on another planet.',
|
||||
details: `**Planets**: ${Object.keys(planets).join(', ')}`,
|
||||
args: [
|
||||
{
|
||||
key: 'weight',
|
||||
prompt: 'What should the starting weight be (in KG)?',
|
||||
type: 'float'
|
||||
},
|
||||
{
|
||||
key: 'planet',
|
||||
prompt: `What planet do you want to use as the base? Either ${list(Object.keys(planets), 'or')}.`,
|
||||
type: 'string',
|
||||
oneOf: planets,
|
||||
parse: planet => planet.toUpperCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, { weight, planet }) {
|
||||
return msg.say(`${weight} kg on ${firstUpperCase(planet)} is ${weight * planets[planet]} kg.`);
|
||||
}
|
||||
};
|
||||
@@ -22,7 +22,7 @@ module.exports = class RomanNumeralCommand extends Command {
|
||||
}
|
||||
|
||||
run(msg, { number }) {
|
||||
if (number === 0) return msg.say('_nulla_');
|
||||
if (number === 0) return msg.reply('_nulla_');
|
||||
let result = '';
|
||||
for (const [numeral, value] of Object.entries(numerals)) {
|
||||
while (number >= value) {
|
||||
@@ -30,6 +30,6 @@ module.exports = class RomanNumeralCommand extends Command {
|
||||
number -= value;
|
||||
}
|
||||
}
|
||||
return msg.say(result);
|
||||
return msg.reply(result);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user