forked from ChrisChrome/weather-bot
Doing stuff to /forecast
This commit is contained in:
parent
70cce9e2ba
commit
d8b6d04edf
7
funcs.js
7
funcs.js
|
@ -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);
|
||||||
|
|
1
index.js
1
index.js
|
@ -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) => {
|
||||||
|
|
Loading…
Reference in a new issue