2021-04-13 12:38:52 +00:00
|
|
|
import {NamedCommand, RestCommand} from "onion-lasers";
|
2021-03-31 01:40:29 +00:00
|
|
|
import {MessageEmbed} from "discord.js";
|
2021-04-08 11:37:49 +00:00
|
|
|
import {find} from "weather-js";
|
2021-03-31 01:40:29 +00:00
|
|
|
|
2021-04-05 12:21:27 +00:00
|
|
|
export default new NamedCommand({
|
2021-03-31 01:40:29 +00:00
|
|
|
description: "Shows weather info of specified location.",
|
2021-04-08 11:37:49 +00:00
|
|
|
run: "You need to provide a city.",
|
2021-04-10 17:07:55 +00:00
|
|
|
any: new RestCommand({
|
2021-04-11 09:11:21 +00:00
|
|
|
async run({send, combined}) {
|
2021-04-08 11:37:49 +00:00
|
|
|
find(
|
|
|
|
{
|
2021-04-10 17:07:55 +00:00
|
|
|
search: combined,
|
2021-04-08 11:37:49 +00:00
|
|
|
degreeType: "C"
|
|
|
|
},
|
|
|
|
function (error, result) {
|
2021-04-10 13:34:55 +00:00
|
|
|
if (error) return send(error.toString());
|
|
|
|
if (result.length === 0) return send("No city found by that name.");
|
2021-04-08 11:37:49 +00:00
|
|
|
var current = result[0].current;
|
|
|
|
var location = result[0].location;
|
|
|
|
const embed = new MessageEmbed()
|
|
|
|
.setDescription(`**${current.skytext}**`)
|
|
|
|
.setAuthor(`Weather for ${current.observationpoint}`)
|
|
|
|
.setThumbnail(current.imageUrl)
|
|
|
|
.setColor(0x00ae86)
|
|
|
|
.addField("Timezone", `UTC${location.timezone}`, true)
|
|
|
|
.addField("Degree Type", "C", true)
|
|
|
|
.addField("Temperature", `${current.temperature} Degrees`, true)
|
|
|
|
.addField("Feels like", `${current.feelslike} Degrees`, true)
|
|
|
|
.addField("Winds", current.winddisplay, true)
|
|
|
|
.addField("Humidity", `${current.humidity}%`, true);
|
2021-04-10 13:34:55 +00:00
|
|
|
return send({
|
2021-04-08 11:37:49 +00:00
|
|
|
embed
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})
|
2021-03-31 01:40:29 +00:00
|
|
|
});
|