WTTR-DISCORD/commands/main/weather.js

26 lines
874 B
JavaScript

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