mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-03 15:07:26 +02:00
40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
const Weather = require('weather');
|
|
const { EmbedBuilder } = require('discord.js');
|
|
const appID = '';
|
|
const appCode = '';
|
|
|
|
const weather = new Weather({
|
|
appID,
|
|
appCode
|
|
});
|
|
module.exports = {
|
|
name: 'weather',
|
|
description: 'Affiche les informations météorologiques d\'une ville',
|
|
category: 'utils',
|
|
emote: '☀️',
|
|
utilisation: 'weather [ville]',
|
|
async execute(message, args) {
|
|
if (args.length < 2) {
|
|
return message.channel.send('Veuillez fournir une ville et un pays.');
|
|
}
|
|
|
|
const city = args[0];
|
|
const country = args[1];
|
|
|
|
const weatherData = await weather.now(`${city}, ${country}`).then((results) => {
|
|
console.log(results);
|
|
});
|
|
const embed = new EmbedBuilder()
|
|
.setTitle(`🌤️ Météo pour ${weatherData.location.name}`)
|
|
.setDescription(`Température: ${weatherData.current.temperature}°C`)
|
|
.addFields(
|
|
{ name: '🌦️ Conditions', value: weatherData.current.skytext, inline: true },
|
|
{ name: '💨 Vent', value: weatherData.current.winddisplay, inline: true },
|
|
{ name: '💧 Humidité', value: weatherData.current.humidity, inline: true }
|
|
)
|
|
.setFooter('Informations météorologiques fournies par Weather.com');
|
|
|
|
|
|
message.channel.send({ embeds: [embed] });
|
|
},
|
|
}; |