Skip to content
Snippets Groups Projects
Unverified Commit 3c3e89a1 authored by mara's avatar mara Committed by GitHub
Browse files

Merge pull request #28 from tatsumara/weather-fix

fix: /weather erroring out
parents bfeeb988 5a1e3d2b
No related branches found
No related tags found
No related merge requests found
......@@ -51,6 +51,12 @@ module.exports = {
async execute(client, interaction) {
const location = interaction.options.getString('location');
const result = await got(`https://wttr.in/${location}?format=j1`);
if (result.body.startsWith('Unknown location')) {
await interaction.editReply({ content: 'Sorry, I don\'t know this place' });
return;
}
// get weather
// i love pattern matching
const {
......@@ -70,7 +76,7 @@ module.exports = {
region: [{ value: region }],
latitude, longitude,
}],
} = JSON.parse((await got(`https://wttr.in/${location}?format=j1`)).body);
} = JSON.parse(result.body);
// get UTC offset
const {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment