From f4a003cc55276f528816daa671d64d8eedcdda3f Mon Sep 17 00:00:00 2001 From: bignutty <3515180-bignutty@users.noreply.gitlab.com> Date: Mon, 15 Jul 2024 20:58:39 +0200 Subject: [PATCH] fix duplicate weather warnings --- commands/interaction/slash/utils/weather.js | 6 +++--- commands/message/utils/weather.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/commands/interaction/slash/utils/weather.js b/commands/interaction/slash/utils/weather.js index 5835d1b..6e5784d 100644 --- a/commands/interaction/slash/utils/weather.js +++ b/commands/interaction/slash/utils/weather.js @@ -54,9 +54,9 @@ module.exports = { // Render weather alerts if(data.result.warnings.length >= 1){ - description += `\n` - for(const w of data.result.warnings){ - description += `\n${icon("warning")} **${w.label}**\n-# ${w.source} • ${link(w.url, "Learn More", "Learn more about this alert")}` + for(const w of data.result.warnings.splice(0, 2)){ + if(description.includes(w.label)) continue; + description += `\n\n${icon("warning")} **${w.label}**\n-# ${w.source} • ${link(w.url, "Learn More", "Learn more about this alert")}` } } diff --git a/commands/message/utils/weather.js b/commands/message/utils/weather.js index b27e159..fc5e116 100644 --- a/commands/message/utils/weather.js +++ b/commands/message/utils/weather.js @@ -41,9 +41,9 @@ module.exports = { // Render weather alerts if(data.result.warnings.length >= 1){ - description += `\n` - for(const w of data.result.warnings){ - description += `\n${icon("warning")} **${w.label}**\n-# ${w.source} • ${link(w.url, "Learn More", "Learn more about this alert")}` + for(const w of data.result.warnings.splice(0, 2)){ + if(description.includes(w.label)) continue; + description += `\n\n${icon("warning")} **${w.label}**\n-# ${w.source} • ${link(w.url, "Learn More", "Learn more about this alert")}` } }