mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-09 06:33:05 -04:00
weather v2, p2
This commit is contained in:
parent
911d28c46b
commit
f0478902c5
3 changed files with 31 additions and 8 deletions
|
@ -2,7 +2,7 @@ const { createEmbed } = require('../../../labscore/utils/embed')
|
|||
const { editOrReply } = require('../../../labscore/utils/message')
|
||||
|
||||
const { darksky } = require('../../../labscore/api');
|
||||
const { pill, iconPill, smallIconPill, smallPill, icon } = require('../../../labscore/utils/markdown');
|
||||
const { pill, iconPill, smallIconPill, smallPill, icon, weatherIcon } = require('../../../labscore/utils/markdown');
|
||||
|
||||
const { Permissions } = require("detritus-client/lib/constants");
|
||||
|
||||
|
@ -26,10 +26,10 @@ module.exports = {
|
|||
|
||||
data = data.response.body
|
||||
|
||||
let description = `### ${data.result.location} • ${data.result.current.condition}\n${iconPill("thermometer", data.result.current.temperature.current + "°C")} ${pill("Wind")} ${smallPill(data.result.current.wind.speed + " km/h")}`
|
||||
let description = `### ${weatherIcon(data.result.current.condition.id.toLowerCase())} ${Math.floor(data.result.current.temperature.current)}°C • ${data.result.current.condition.label}\n${data.result.location}\n\n${pill("Feels like")} ${smallPill(Math.floor(data.result.current.temperature.feels_like) + "°C")} ${pill("Wind")} ${smallPill(data.result.current.wind.speed + " km/h")}`
|
||||
|
||||
let secondaryPills = [];
|
||||
if(data.result.current.humidity > 0) secondaryPills.push(`${pill("Humidity")} ${smallPill(data.result.current.humidity)}`)
|
||||
if(data.result.current.humidity > 0) secondaryPills.push(`${pill("Humidity")} ${smallPill((data.result.current.humidity * 100) + "%")}`)
|
||||
if(data.result.current.uvindex > 0) secondaryPills.push(`${pill("UV Index")} ${smallPill(data.result.current.uvindex)}`)
|
||||
|
||||
if(secondaryPills.length >= 1) description += '\n' + secondaryPills.join(` `)
|
||||
|
@ -37,18 +37,23 @@ module.exports = {
|
|||
// Render Forecasts
|
||||
description += `\n`
|
||||
for(const i of data.result.forecast){
|
||||
description += `\n${pill(i.day)} ${smallPill(i.condition)} ${icon("thermometer")} Between ${smallPill(i.temperature.min + "°C")} and ${smallPill(i.temperature.max + "°C")} `
|
||||
description += `\n${pill(i.day)} ${weatherIcon(i.condition.toLowerCase().replace(' ', '_'))}`
|
||||
if(Math.floor(i.temperature.max).toString().length == 1) description += `${pill(Math.floor(i.temperature.max) + "°C ")}`
|
||||
else description += `${pill(Math.floor(i.temperature.max) + "°C")}`
|
||||
description += `**/**`
|
||||
if(Math.floor(i.temperature.min).toString().length == 1) description += `${smallPill(Math.floor(i.temperature.min) + "°C ")}`
|
||||
else description += `${smallPill(Math.floor(i.temperature.min) + "°C")}`
|
||||
}
|
||||
|
||||
|
||||
let e = createEmbed("default", context, {
|
||||
description,
|
||||
thumbnail: {
|
||||
url: data.result.current.icon
|
||||
},
|
||||
timestamp: new Date(data.result.current.date)
|
||||
})
|
||||
|
||||
if(data.result.current.icon) e.thumbnail = { url: data.result.current.icon }
|
||||
if(data.result.current.image) e.image = { url: data.result.current.image }
|
||||
|
||||
return editOrReply(context, {embeds: [e]})
|
||||
}catch(e){
|
||||
console.log(e)
|
||||
|
|
|
@ -200,6 +200,19 @@ module.exports.REDESIGN_ICONS = Object.freeze({
|
|||
"exclaim_4": "<:ico_exclaim_4:1165263551586369609>",
|
||||
"question_large": "<:ico_question_large:1165263553050185950>",
|
||||
|
||||
"weather_clear": "<:ico_weather_clear_day:1167770009557286913>",
|
||||
"weather_cloudy": "<:ico_weather_cloudy:1167770011776073819>",
|
||||
"weather_drizzle": "<:ico_weather_drizzle:1167770013747388437>",
|
||||
"weather_flurries": "<:ico_weather_flurries:1167788306059247616>",
|
||||
"weather_haze": "<:haze:1167770015957782548>",
|
||||
"weather_mostlyclear": "<:ico_weather_mostly_clear_day:1167770017719398411>",
|
||||
"weather_mostlycloudy": "<:ico_weather_mostly_cloudy_day:1167770019766214686>",
|
||||
"weather_partlycloudy": "<:ico_weather_partly_cloudy_day:1167770022073094234>",
|
||||
"weather_rain": "<:ico_weather_rain:1167770024761630741>",
|
||||
"weather_snow": "<:ico_weather_snow:1167770027135606806>",
|
||||
"weather_thunderstorms": "<:ico_weather_thunderstorms:1167770030063231117>",
|
||||
"weather_windy": "<:ico_weather_windy:1167770031682232420>",
|
||||
|
||||
"information": "<:ico_information:1139704769179562064>",
|
||||
"question": "<:ico_question:1139704770760806502>",
|
||||
"warning": "<:ico_warning:1151286226117201970>",
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
const { ICONS, REDESIGN_ICONS } = require('../constants')
|
||||
|
||||
module.exports.icon = function(icon){
|
||||
if(!REDESIGN_ICONS[icon]) return ICONS.question
|
||||
if(!REDESIGN_ICONS[icon]) return ICONS.question.replace(/:[a-z1-9_]*:/, ':i:')
|
||||
return REDESIGN_ICONS[icon].replace(/:[a-z1-9_]*:/, ':i:')
|
||||
}
|
||||
|
||||
module.exports.weatherIcon = function(icon){
|
||||
if(!REDESIGN_ICONS["weather_" + icon]) return REDESIGN_ICONS["calendar"].replace(/:[a-z1-9_]*:/, ':i:')
|
||||
return REDESIGN_ICONS["weather_" + icon].replace(/:[a-z1-9_]*:/, ':i:')
|
||||
}
|
||||
|
||||
module.exports.highlight = function(content = ""){
|
||||
return "`" + content.toString().replace(/\`/g, 'ˋ') + "`"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue