diff --git a/commands/games/rockpaperscissors.js b/commands/games/rockpaperscissors.js index 5e69a1b3..1d834847 100644 --- a/commands/games/rockpaperscissors.js +++ b/commands/games/rockpaperscissors.js @@ -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!'); } } }; diff --git a/commands/random/currency.js b/commands/random/currency.js index f03626af..0c59fe16 100644 --- a/commands/random/currency.js +++ b/commands/random/currency.js @@ -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}`); diff --git a/commands/random/temperature.js b/commands/random/temperature.js new file mode 100644 index 00000000..e4e7186d --- /dev/null +++ b/commands/random/temperature.js @@ -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.`); + } + } +}; diff --git a/html/carbonfeat.html b/html/carbonfeat.html index 9f2f6fa9..b14233ed 100644 --- a/html/carbonfeat.html +++ b/html/carbonfeat.html @@ -16,7 +16,7 @@