finished update all comment with sqlite3

This commit is contained in:
VALOU3336
2024-03-01 21:06:34 +01:00
parent 4cf07f2d2c
commit 9fd591093d
11 changed files with 270 additions and 168 deletions
+20 -10
View File
@@ -1,6 +1,7 @@
const { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } = require('discord.js');
const db = require('quick.db');
const PrevnameDb = new db.table("prevname");
const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('myDatabase.db');
module.exports = {
name: 'prevname',
description: 'Affiche tous les pseudos précédents et permet de les supprimer',
@@ -9,25 +10,34 @@ module.exports = {
utilisation: 'prevname',
async execute(message, args) {
const userId = message.author.id;
const nameChanges = PrevnameDb.get(`${userId}.nameChanges`) || [];
let nameChanges = await new Promise((resolve, reject) => {
db.get('SELECT value FROM prevname WHERE id = ?', [userId], (err, row) => {
if (err) {
console.error(err.message);
reject(err);
}
resolve(row ? JSON.parse(row.value) : []);
});
});
let description = 'Vous n\'avez pas de pseudos précédents enregistrés.';
if (nameChanges.length > 0) {
description = nameChanges.map((change, index) => `${index + 1}. ${change.newName} - <t:${change.changeDate}:F>`).join('\n');
if (nameChanges.length > 0) {
description = nameChanges.map((change, index) => `${index + 1}. ${change.newName} - <t:${change.changeDate}:F>`).join('\n');
}
const embed = new EmbedBuilder()
.setTitle('Pseudos précédents')
.setDescription(description)
.setColor('#0099ff');
.setTitle('Pseudos précédents')
.setDescription(description)
.setColor('#0099ff');
const deleteButton = new ButtonBuilder()
.setCustomId(`deleteprevnames_${message.author.id}`)
.setEmoji('🗑️')
.setStyle(ButtonStyle.Secondary)
.setStyle(ButtonStyle.Secondary);
const row = new ActionRowBuilder()
.addComponents(deleteButton);
await message.reply({ embeds: [embed], components: [row] });
},
};
};
+28 -29
View File
@@ -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] });
},
};