WTTR-DISCORD/commands/main/weather.js

26 lines
874 B
JavaScript
Raw Normal View History

2022-07-23 08:04:10 -04:00
const { EmbedBuilder } = require('discord.js');
2022-07-22 18:09:13 -04:00
module.exports = {
2023-08-20 19:40:54 -04:00
name: "weather",
description: "Get the weather for a location",
private: false,
options: [{
name: "location",
2023-08-20 19:50:34 -04:00
description: "The location you would like to check",
2023-08-20 19:40:54 -04:00
required: true,
type: 3 // 6 is type USER
}],
2022-07-22 18:09:13 -04:00
run: async (client, interaction) => {
2023-08-20 19:40:54 -04:00
let encodedLocation = encodeURIComponent(interaction.options._hoistedOptions[0].value);
let location = interaction.options._hoistedOptions[0].value;
2022-07-23 08:04:10 -04:00
const embed = new EmbedBuilder()
2022-07-22 18:09:13 -04:00
.setColor("#FF0000")
2023-08-20 19:40:54 -04:00
.setTitle(`The weather for: ${location}`)
2022-07-22 18:09:13 -04:00
.setTimestamp()
2023-08-20 19:40:54 -04:00
.setImage(`https://wttr.in/${encodedLocation}.png`)
2022-07-22 18:09:13 -04:00
.setFooter({ text: `Requested by ${interaction.user.tag}`, iconURL: `${interaction.user.displayAvatarURL()}` });
2023-08-20 19:40:54 -04:00
await interaction.editReply({ embeds: [embed] });
2022-07-22 18:09:13 -04:00
},
};