mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-10 07:03:08 -04:00
quick units, add kelvin support
This commit is contained in:
parent
f910be7ab7
commit
9eeb7f2721
3 changed files with 46 additions and 17 deletions
|
@ -11,12 +11,14 @@ const { ApplicationCommandOptionTypes } = require('detritus-client/lib/constants
|
|||
|
||||
const modifiers = {
|
||||
"°C": (i)=>i,
|
||||
"°F": (i)=>(i*(9/5))+32
|
||||
"°F": (i)=>(i*(9/5))+32,
|
||||
"K": (i)=>i+273.15
|
||||
}
|
||||
|
||||
const unitNames = {
|
||||
"°C": "Celcius",
|
||||
"°F": "Fahrenheit"
|
||||
"°F": "Fahrenheit",
|
||||
"K": "Kelvin"
|
||||
}
|
||||
|
||||
function temperature(value, units){
|
||||
|
@ -54,7 +56,7 @@ function renderWeatherCard(context, data, units){
|
|||
if(data.result.warnings.length >= 1){
|
||||
for(const w of [data.result.warnings[0]]){
|
||||
if(description.includes(stringwrap(w.label, 50))) continue;
|
||||
description += `\n\n${icon("weather_warning_" + (w.icon || "generic").toLowerCase())} **${stringwrap(w.label, 50)}**\n-# ${stringwrap(w.source, 50)} • ${link(w.url, "Learn More", "Learn more about this alert")}`
|
||||
description += `\n\n${icon("weather_warning_" + (w.icon || "generic").toLowerCase())} **${stringwrap(w.label, 50)}**\n-# ${stringwrap(w.source, 50)} • ${link(w.url, "Learn More", "Learn more about this alert")}`
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,6 +120,10 @@ module.exports = {
|
|||
{
|
||||
value: "fahrenheit",
|
||||
name: "Fahrenheit"
|
||||
},
|
||||
{
|
||||
value: "kelvin",
|
||||
name: "Kelvin"
|
||||
}
|
||||
],
|
||||
required: false
|
||||
|
@ -139,11 +145,15 @@ module.exports = {
|
|||
data = data.response.body
|
||||
|
||||
let units = ["°C", "°F"]
|
||||
if(args.units) if(["f","fahrenheit","°f"].includes(args.units.toLowerCase())) units = ["°F", "°C"]
|
||||
if(args.units){
|
||||
if(args.units == "fahrenheit") units = ["°F"]
|
||||
else if (args.units == "kelvin") units = ["K"]
|
||||
}
|
||||
|
||||
let pages = []
|
||||
pages.push(page(renderWeatherCard(context, data, units[0])))
|
||||
pages.push(page(renderWeatherCard(context, data, units[1])))
|
||||
for(const u of units) pages.push(page(renderWeatherCard(context, data, u)))
|
||||
|
||||
if(pages.length == 1) return editOrReply(context, pages[0])
|
||||
|
||||
await paginator.createPaginator({
|
||||
context,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue