mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-16 23:57:48 +02:00
finished update all comment with sqlite3
This commit is contained in:
+28
-29
@@ -1,12 +1,6 @@
|
||||
const Weather = require('weather');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const appID = '';
|
||||
const appCode = '';
|
||||
const Discord = require('discord.js');
|
||||
const axios = require('axios');
|
||||
|
||||
const weather = new Weather({
|
||||
appID,
|
||||
appCode
|
||||
});
|
||||
module.exports = {
|
||||
name: 'weather',
|
||||
description: 'Affiche les informations météorologiques d\'une ville',
|
||||
@@ -14,27 +8,32 @@ module.exports = {
|
||||
emote: '☀️',
|
||||
utilisation: 'weather [ville]',
|
||||
async execute(message, args) {
|
||||
if (args.length < 2) {
|
||||
return message.channel.send('Veuillez fournir une ville et un pays.');
|
||||
try {
|
||||
const APIKEY = '1e59407044fd6d842180610a8c423aa4';
|
||||
const city = args[0];
|
||||
|
||||
if (!city) {
|
||||
return message.channel.send('Veuillez fournir une ville.');
|
||||
}
|
||||
|
||||
const response = await axios.get(`https://api.openweathermap.org/data/2.5/weather?q=${encodeURIComponent(city)}&appid=${APIKEY}&units=metric`);
|
||||
const weatherData = response.data;
|
||||
|
||||
const cityName = weatherData.name;
|
||||
const temperature = weatherData.main.temp;
|
||||
const weatherDescription = weatherData.weather[0].description;
|
||||
|
||||
const Embed = new Discord.MessageEmbed()
|
||||
.setTitle(`Meteo à ${cityName}`)
|
||||
.setDescription(`🌡・Temperature: ${temperature}°C\n⛅・Temps: ${weatherDescription}`)
|
||||
.setTimestamp()
|
||||
.setColor('RANDOM') // Discord.js uses 'RANDOM' for random colors
|
||||
.setFooter({text: message.client.user.username, iconURL: message.client.user.displayAvatarURL({dynamic: true})});
|
||||
|
||||
await message.channel.send({ embeds: [Embed] });
|
||||
} catch(e) {
|
||||
console.error(e);
|
||||
await message.channel.send(`Je n'ai pas trouvé la ville ${city}!`);
|
||||
}
|
||||
|
||||
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] });
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user