Doing stuff to /forecast

This commit is contained in:
Christopher Cookman 2024-06-20 17:55:56 -06:00
parent 70cce9e2ba
commit d8b6d04edf
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42
2 changed files with 4 additions and 4 deletions

View file

@ -91,10 +91,9 @@ const generateDiscordEmbeds = (forecastData, numOfDays) => {
if (period.icon?.startsWith("/")) { if (period.icon?.startsWith("/")) {
period.icon = `https://api.weather.gov${period.icon}` period.icon = `https://api.weather.gov${period.icon}`
} }
console.log(period.icon)
const embed = { const embed = {
title: `${period.name} in ${forecastData.properties.relativeLocation.properties.city} ${forecastData.properties.relativeLocation.properties.state}`, title: `${period.name} in ${forecastData.properties.relativeLocation.properties.city} ${forecastData.properties.relativeLocation.properties.state}`,
description: period.detailedForecast, description: `Valid <t:${new Date(period.startTime)/1000}:f> - <t:${new Date(period.endTime)/1000}:f>\n${period.detailedForecast}`,
timestamp: new Date(period.startTime), timestamp: new Date(period.startTime),
thumbnail: { thumbnail: {
url: period.icon, url: period.icon,
@ -107,7 +106,7 @@ const generateDiscordEmbeds = (forecastData, numOfDays) => {
}, },
{ {
name: 'Wind', name: 'Wind',
value: `${period.windDirection} ${period.windSpeed}`, value: `${period.windDirection}@${period.windSpeed}`,
inline: true inline: true
}, },
{ {
@ -122,7 +121,7 @@ const generateDiscordEmbeds = (forecastData, numOfDays) => {
], ],
footer: { footer: {
text: 'Data provided by the National Weather Service' text: `Data provided by the National Weather Service | Elevation ${forecastData.properties.elevation.value}m`
} }
}; };
embeds.push(embed); embeds.push(embed);

View file

@ -1285,6 +1285,7 @@ discord.on("interactionCreate", async (interaction) => {
await interaction.deferReply(); await interaction.deferReply();
periods = interaction.options.getInteger("periods") || 1; periods = interaction.options.getInteger("periods") || 1;
funcs.getWeatherBySearch(interaction.options.getString("location")).then((weather) => { funcs.getWeatherBySearch(interaction.options.getString("location")).then((weather) => {
if (config.debug >= 1) console.log(JSON.stringify(weather, null, 2))
embeds = funcs.generateDiscordEmbeds(weather, periods); embeds = funcs.generateDiscordEmbeds(weather, periods);
interaction.editReply({ embeds }); interaction.editReply({ embeds });
}).catch((err) => { }).catch((err) => {