diff --git a/README.md b/README.md index 10f2319c..b68ae81a 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,14 @@ Xiao is a Discord bot coded in JavaScript with [discord.js](https://discord.js.org/) using the -[Commando](https://github.com/discordjs/Commando) command framework. With nearly +[Commando](https://github.com/discordjs/Commando) command framework. With over 300 commands, she is one of the most feature-filled bots out there. ## Invite The bot is no longer available for invite. You can self-host the bot, or use her on the [home server](https://discord.gg/sbMe32W). -## Commands (300) +## Commands (301) ### Utility: * **eval**: Executes JavaScript code. @@ -331,6 +331,7 @@ on the [home server](https://discord.gg/sbMe32W). * **currency**: Converts money from one currency to another. * **final-grade-calculator**: Determines the grade you need to make on your final to get your desired course grade. +* **gravity**: Determines weight on another planet. * **math**: Evaluates a math expression. * **roman-numeral**: Converts a number to roman numerals. * **scrabble-score**: Responds with the scrabble score of a word. diff --git a/assets/json/gravity.json b/assets/json/gravity.json new file mode 100644 index 00000000..518f9a97 --- /dev/null +++ b/assets/json/gravity.json @@ -0,0 +1,12 @@ +{ + "mercury": 0.378, + "venus": 0.907, + "earth": 1, + "moon": 0.166, + "mars": 0.377, + "jupiter": 2.36, + "saturn": 0.916, + "uranus": 0.889, + "neptune": 1.12, + "pluto": 0.071 +} diff --git a/commands/number-edit/gravity.js b/commands/number-edit/gravity.js new file mode 100644 index 00000000..80970717 --- /dev/null +++ b/commands/number-edit/gravity.js @@ -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.`); + } +}; diff --git a/commands/number-edit/roman-numeral.js b/commands/number-edit/roman-numeral.js index c8ad007b..4a0749cb 100644 --- a/commands/number-edit/roman-numeral.js +++ b/commands/number-edit/roman-numeral.js @@ -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); } }; diff --git a/package.json b/package.json index 39aebd76..3d744727 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "90.2.1", + "version": "90.3.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { diff --git a/util/Util.js b/util/Util.js index c96446b7..3ea53c4d 100644 --- a/util/Util.js +++ b/util/Util.js @@ -48,6 +48,10 @@ module.exports = class Util { return arr; } + static firstUpperCase(text) { + return `${text.charAt(0).toUpperCase()}${text.slice(1)}`; + } + static base64(text, mode = 'encode') { if (mode === 'encode') return Buffer.from(text).toString('base64'); if (mode === 'decode') return Buffer.from(text, 'base64').toString('utf8') || null;