Skip to content

Commit

Permalink
fix wheather?
Browse files Browse the repository at this point in the history
  • Loading branch information
iernie committed Jul 1, 2024
1 parent 3b08110 commit d076c8d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion commands/weather.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ const command: SlashCommand = {
option.setName("location").setDescription("location for temperature").setRequired(true),
),
async execute(interaction) {
const location = await geocoder.geocode(interaction.options.getString("location")!.trim());
const response = await fetch(
`https://nominatim.openstreetmap.org/search?addressdetails=1&q=${interaction.options.getString("location")!.trim().replace(" ", "+")}&format=json`,
);
const location = (await response.json()) as [
{
latitude: string;
longitude: string;
city: string;
},
];

const data = (await fetch(
`https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=${location[0].latitude}&lon=${location[0].longitude}`,
{
Expand Down

0 comments on commit d076c8d

Please sign in to comment.