mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Gravity Command
This commit is contained in:
@@ -8,14 +8,14 @@
|
|||||||
|
|
||||||
Xiao is a Discord bot coded in JavaScript with
|
Xiao is a Discord bot coded in JavaScript with
|
||||||
[discord.js](https://discord.js.org/) using the
|
[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.
|
300 commands, she is one of the most feature-filled bots out there.
|
||||||
|
|
||||||
## Invite
|
## Invite
|
||||||
The bot is no longer available for invite. You can self-host the bot, or use her
|
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).
|
on the [home server](https://discord.gg/sbMe32W).
|
||||||
|
|
||||||
## Commands (300)
|
## Commands (301)
|
||||||
### Utility:
|
### Utility:
|
||||||
|
|
||||||
* **eval**: Executes JavaScript code.
|
* **eval**: Executes JavaScript code.
|
||||||
@@ -331,6 +331,7 @@ on the [home server](https://discord.gg/sbMe32W).
|
|||||||
|
|
||||||
* **currency**: Converts money from one currency to another.
|
* **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.
|
* **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.
|
* **math**: Evaluates a math expression.
|
||||||
* **roman-numeral**: Converts a number to roman numerals.
|
* **roman-numeral**: Converts a number to roman numerals.
|
||||||
* **scrabble-score**: Responds with the scrabble score of a word.
|
* **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 }) {
|
run(msg, { number }) {
|
||||||
if (number === 0) return msg.say('_nulla_');
|
if (number === 0) return msg.reply('_nulla_');
|
||||||
let result = '';
|
let result = '';
|
||||||
for (const [numeral, value] of Object.entries(numerals)) {
|
for (const [numeral, value] of Object.entries(numerals)) {
|
||||||
while (number >= value) {
|
while (number >= value) {
|
||||||
@@ -30,6 +30,6 @@ module.exports = class RomanNumeralCommand extends Command {
|
|||||||
number -= value;
|
number -= value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return msg.say(result);
|
return msg.reply(result);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "90.2.1",
|
"version": "90.3.0",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ module.exports = class Util {
|
|||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static firstUpperCase(text) {
|
||||||
|
return `${text.charAt(0).toUpperCase()}${text.slice(1)}`;
|
||||||
|
}
|
||||||
|
|
||||||
static base64(text, mode = 'encode') {
|
static base64(text, mode = 'encode') {
|
||||||
if (mode === 'encode') return Buffer.from(text).toString('base64');
|
if (mode === 'encode') return Buffer.from(text).toString('base64');
|
||||||
if (mode === 'decode') return Buffer.from(text, 'base64').toString('utf8') || null;
|
if (mode === 'decode') return Buffer.from(text, 'base64').toString('utf8') || null;
|
||||||
|
|||||||
Reference in New Issue
Block a user