mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-06 06:10:49 +02:00
Temperature Command
This commit is contained in:
@@ -30,26 +30,17 @@ module.exports = class RockPaperScissorsCommand extends Command {
|
||||
const { choice } = args;
|
||||
const response = responses[Math.floor(Math.random() * responses.length)];
|
||||
if(choice === 'rock') {
|
||||
if(response === 'Rock')
|
||||
return msg.say('Rock! Aw, it\'s a tie!');
|
||||
if(response === 'Paper')
|
||||
return msg.say('Paper! Yes! I win!');
|
||||
if(response === 'Scissors')
|
||||
return msg.say('Scissors! Aw... I lose...');
|
||||
if(response === 'Rock') return msg.say('Rock! Aw, it\'s a tie!');
|
||||
if(response === 'Paper') return msg.say('Paper! Yes! I win!');
|
||||
if(response === 'Scissors') return msg.say('Scissors! Aw... I lose...');
|
||||
} else if(choice === 'paper') {
|
||||
if(response === 'Rock')
|
||||
return msg.say('Rock! Aw... I lose...');
|
||||
if(response === 'Paper')
|
||||
return msg.say('Paper! Aw, it\'s a tie!');
|
||||
if(response === 'Scissors')
|
||||
return msg.say('Scissors! Yes! I win!');
|
||||
if(response === 'Rock') return msg.say('Rock! Aw... I lose...');
|
||||
if(response === 'Paper') return msg.say('Paper! Aw, it\'s a tie!');
|
||||
if(response === 'Scissors') return msg.say('Scissors! Yes! I win!');
|
||||
} else if(choice === 'scissors') {
|
||||
if(response === 'Rock')
|
||||
return msg.say('Rock! Yes! I win!');
|
||||
if(response === 'Paper')
|
||||
return msg.say('Paper! Aw... I lose...');
|
||||
if(response === 'Scissors')
|
||||
return msg.say('Scissors! Aw, it\'s a tie!');
|
||||
if(response === 'Rock') return msg.say('Rock! Yes! I win!');
|
||||
if(response === 'Paper') return msg.say('Paper! Aw... I lose...');
|
||||
if(response === 'Scissors') return msg.say('Scissors! Aw, it\'s a tie!');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -42,7 +42,7 @@ module.exports = class CurrencyCommand extends Command {
|
||||
|
||||
async run(msg, args) {
|
||||
const { base, to, amount } = args;
|
||||
if(base === to) return msg.say(`${amount} ${base} is ${amount} ${to}.`);
|
||||
if(base === to) return msg.say(`Converting ${base} to ${to} is the same value, dummy.`);
|
||||
try {
|
||||
const { body } = await request
|
||||
.get(`http://api.fixer.io/latest?base=${base}&symbols=${to}`);
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
|
||||
module.exports = class TemperatureCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'temperature',
|
||||
group: 'random',
|
||||
memberName: 'temperature',
|
||||
description: 'Converts temperatures to/from Celsius, Fahrenheit, or Kelvin.',
|
||||
args: [
|
||||
{
|
||||
key: 'base',
|
||||
prompt: 'What temperature unit do you want to use as the base?',
|
||||
type: 'string',
|
||||
validate: base => {
|
||||
if(['celsius', 'fahrenheit', 'kelvin'].includes(base.toLowerCase())) return true;
|
||||
return 'Please enter either `celsius`, `fahrenheit`, or `kelvin`.';
|
||||
},
|
||||
parse: base => base.toLowerCase()
|
||||
},
|
||||
{
|
||||
key: 'to',
|
||||
prompt: 'What temperature unit do you want to convert to?',
|
||||
type: 'string',
|
||||
validate: to => {
|
||||
if(['celsius', 'fahrenheit', 'kelvin'].includes(to.toLowerCase())) return true;
|
||||
return 'Please enter either `celsius`, `fahrenheit`, or `kelvin`.';
|
||||
},
|
||||
parse: to => to.toLowerCase()
|
||||
},
|
||||
{
|
||||
key: 'amount',
|
||||
prompt: 'What temperature should be converted?',
|
||||
type: 'integer'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, args) {
|
||||
const { base, to, amount } = args;
|
||||
if(base === to) return msg.say(`Converting ${base} to ${to} is the same value, dummy.`);
|
||||
if(base === 'celsius') {
|
||||
if(to === 'fahrenheit') return msg.say(`${amount}°C is ${(amount * 1.8) + 32}°F.`);
|
||||
if(to === 'kelvin') return msg.say(`${amount}°C is ${amount + 273.15}°K.`);
|
||||
} else if(base === 'fahrenheit') {
|
||||
if(to === 'celsius') return msg.say(`${amount}°F is ${(amount - 32) / 1.8}°C.`);
|
||||
if(to === 'kelvin') return msg.say(`${amount}°F is ${(amount + 459.67) * (5 / 9)}°K.`);
|
||||
} else if(base === 'kelvin') {
|
||||
if(to === 'celsius') return msg.say(`${amount}°K is ${amount - 273.15}°C.`);
|
||||
if(to === 'fahrenheit') return msg.say(`${amount}°K is ${(amount * 1.8) - 459.67}°F.`);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -16,7 +16,7 @@
|
||||
<li>Server and User Information!</li>
|
||||
<li>Meme Generation!</li>
|
||||
<li>Moderation Commands including Ban/Softban/Kick/Warn/Unban, Lockdown, and Prune, with Customizable Logging!</li>
|
||||
<li>Currency Conversion!</li>
|
||||
<li>Currency and Temperature Conversion!</li>
|
||||
<li>Tons of Secret Easter Eggs to discover!</li>
|
||||
<li>Calculator!</li>
|
||||
<li>Strawpoll Generation!</li>
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<li>Server and User Information!</li>
|
||||
<li>Meme Generation!</li>
|
||||
<li>Moderation Commands including Ban/Softban/Kick/Warn/Unban, Lockdown, and Prune, with Customizable Logging!</li>
|
||||
<li>Currency Conversion!</li>
|
||||
<li>Currency and Temperature Conversion!</li>
|
||||
<li>Tons of Secret Easter Eggs to discover!</li>
|
||||
<li>Calculator!</li>
|
||||
<li>Strawpoll Generation!</li>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "18.2.5",
|
||||
"version": "18.3.0",
|
||||
"description": "A Discord Bot",
|
||||
"main": "shardingmanager.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user