mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Gravity Command
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "90.2.1",
|
||||
"version": "90.3.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user