Fix Everything

This commit is contained in:
Daniel Odendahl Jr
2017-06-01 18:31:20 +00:00
parent 66706d9c7b
commit 4e1f83a30f
85 changed files with 721 additions and 851 deletions
+12 -29
View File
@@ -13,11 +13,8 @@ module.exports = class TemperatureCommand extends Command {
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;
} else {
return 'Please enter either `celsius`, `fahrenheit`, or `kelvin`.';
}
if (['celsius', 'fahrenheit', 'kelvin'].includes(base.toLowerCase())) return true;
else return 'Please enter either `celsius`, `fahrenheit`, or `kelvin`.';
},
parse: (base) => base.toLowerCase()
},
@@ -26,11 +23,8 @@ module.exports = class TemperatureCommand extends Command {
prompt: 'What temperature unit do you want to convert to?',
type: 'string',
validate: (to) => {
if (['celsius', 'fahrenheit', 'kelvin'].includes(to.toLowerCase())) {
return true;
} else {
return 'Please enter either `celsius`, `fahrenheit`, or `kelvin`.';
}
if (['celsius', 'fahrenheit', 'kelvin'].includes(to.toLowerCase())) return true;
else return 'Please enter either `celsius`, `fahrenheit`, or `kelvin`.';
},
parse: (to) => to.toLowerCase()
},
@@ -45,27 +39,16 @@ module.exports = class TemperatureCommand extends Command {
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 === 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.`);
} else if (to === 'kelvin') {
return msg.say(`${amount}°C is ${amount + 273.15}°K.`);
}
if (to === 'fahrenheit') return msg.say(`${amount}°C is ${(amount * 1.8) + 32}°F.`);
else 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.`);
} else 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.`);
} else if (to === 'fahrenheit') {
return msg.say(`${amount}°K is ${(amount * 1.8) - 459.67}°F.`);
}
if (to === 'celsius') return msg.say(`${amount}°F is ${(amount - 32) / 1.8}°C.`);
else return msg.say(`${amount}°F is ${(amount + 459.67) * (5 / 9)}°K.`);
} else {
if (to === 'celsius') return msg.say(`${amount}°K is ${amount - 273.15}°C.`);
else return msg.say(`${amount}°K is ${(amount * 1.8) - 459.67}°F.`);
}
}
};