Files
xiao/commands/edit-number/gravity.js
T
Dragon Fire c61ae11679 Fix
2021-06-05 12:50:41 -04:00

44 lines
1.3 KiB
JavaScript

const Command = require('../../framework/Command');
const { list, firstUpperCase, formatNumber } = require('../../util/Util');
const planets = require('../../assets/json/gravity');
module.exports = class GravityCommand extends Command {
constructor(client) {
super(client, {
name: 'gravity',
group: 'edit-number',
memberName: 'gravity',
description: 'Determines weight on another celestial object.',
details: `**Celestial Objects:** ${Object.keys(planets).join(', ')}`,
credit: [
{
name: 'NASA',
url: 'https://www.nasa.gov/',
reason: 'Planet Gravity Data',
reasonURL: 'https://nssdc.gsfc.nasa.gov/planetary/factsheet/planet_table_ratio.html'
}
],
args: [
{
key: 'weight',
prompt: 'What should the starting weight be (in KG)?',
type: 'float'
},
{
key: 'planet',
label: 'celestial object',
prompt: `What celestial object do you want to use? Either ${list(Object.keys(planets), 'or')}.`,
type: 'string',
oneOf: Object.keys(planets),
parse: planet => planet.toLowerCase()
}
]
});
}
run(msg, { weight, planet }) {
const result = weight * planets[planet];
return msg.say(`${formatNumber(weight)} kg on ${firstUpperCase(planet)} is ${formatNumber(result)} kg.`);
}
};