From 54c351c1a38002bae5d706211aa7dcd14c2e5f79 Mon Sep 17 00:00:00 2001 From: derpystuff <3515180-derpystuff@users.noreply.gitlab.com> Date: Sun, 29 Oct 2023 15:26:23 +0100 Subject: [PATCH] weather v2, p4 --- commands/message/utils/weather.js | 12 ++++++++---- labscore/utils/statics.js | 5 +++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/commands/message/utils/weather.js b/commands/message/utils/weather.js index 7be5e81..5be03ac 100644 --- a/commands/message/utils/weather.js +++ b/commands/message/utils/weather.js @@ -5,6 +5,7 @@ const { darksky } = require('../../../labscore/api'); const { pill, iconPill, smallIconPill, smallPill, icon, weatherIcon, timestamp } = require('../../../labscore/utils/markdown'); const { Permissions } = require("detritus-client/lib/constants"); +const { STATICS } = require('../../../labscore/utils/statics'); module.exports = { name: 'weather', @@ -26,15 +27,15 @@ module.exports = { data = data.response.body - 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${iconPill("thermometer", "Feels like")} ${smallPill(Math.floor(data.result.current.temperature.feels_like) + "°C")}\n${iconPill("wind", "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\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(`${iconPill("raindrop", "Humidity")} ${smallPill(Math.floor(data.result.current.humidity * 100) + "%")}`) - if(data.result.current.uvindex > 0) secondaryPills.push(`${iconPill("sun", "UV Index")} ${smallPill(data.result.current.uvindex)}`) + if(data.result.current.humidity > 0) secondaryPills.push(`${pill("Humidity")} ${smallPill(Math.floor(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(` ​ ​ ​ ​ `) - description += `\n${iconPill("sun", "Sunrise")} ${timestamp(data.result.current.sun.sunrise, "t")} ​ ​ ${iconPill("moon", "Sunset")} ${timestamp(data.result.current.sun.sunset, "t")}` + description += `\n\n${iconPill("sun", "Sunrise")} ${timestamp(data.result.current.sun.sunrise, "t")} ​ ​ ${iconPill("moon", "Sunset")} ${timestamp(data.result.current.sun.sunset, "t")}` // Render Forecasts description += `\n` @@ -53,6 +54,9 @@ module.exports = { timestamp: new Date(data.result.current.date) }) + e.footer.iconUrl = STATICS.weather + if(data.result.location) e.footer.text = data.result.location //+ " • " + context.client.user.username + if(data.result.current.icon) e.thumbnail = { url: data.result.current.icon } if(data.result.current.image) e.image = { url: data.result.current.image } diff --git a/labscore/utils/statics.js b/labscore/utils/statics.js index 7a187ef..e0f7a0c 100644 --- a/labscore/utils/statics.js +++ b/labscore/utils/statics.js @@ -94,6 +94,10 @@ const Statics = Object.freeze({ file: "brands/urbandictionary.png", revision: 2 }, + weather: { + file: "brands/weather.png", + revision: 2 + }, wikihow: { file: "brands/wikihow.png", revision: 1 @@ -172,6 +176,7 @@ module.exports.STATICS = Object.freeze({ reddit: staticAsset(Statics.brands.reddit), tineye: staticAsset(Statics.brands.tineye), urbandictionary: staticAsset(Statics.brands.urbandictionary), + weather: staticAsset(Statics.brands.weather), wikihow: staticAsset(Statics.brands.wikihow), wikipedia: staticAsset(Statics.brands.wikipedia), wolframalpha: staticAsset(Statics.brands.wolframalpha),