const sqlite3 = require('sqlite3').verbose(); const db = new sqlite3.Database('myDatabase.db'); const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); const paginationEmbed = require('discordjs-button-pagination'); module.exports = { name: 'news', aliases: ['changelog'], description: 'Affiche tous les changements rĂ©cents sur le bot', category: "utils" , emote:"📌", utilisation: "changelog", async execute(message, args, client) { let changelogs = await new Promise((resolve, reject) => { db.get('SELECT value FROM master WHERE id = ?', ["changelogGestion"], (err, row) => { if (err) { console.error(err.message); reject(err); } resolve(row ? JSON.parse(row.value) : []); }); }); if (changelogs.length === 0) { const noChangeLogEmbed = new EmbedBuilder() .setTitle('Aucun changement rĂ©cent') .setDescription('Il n\'y a aucun changement rĂ©cent Ă  afficher.') .setColor('#0099ff'); return message.channel.send({ embeds: [noChangeLogEmbed] }); } const embeds = changelogs.map((log, index) => { const embed = new EmbedBuilder() .setTitle(new Date(log.timestamp).toLocaleDateString()) .setDescription(log.text) .setColor('#0099ff'); return embed; }); const backButton = new ButtonBuilder() .setCustomId('previousbtn') .setLabel('PrĂ©cĂ©dent') .setStyle(ButtonStyle.Danger); const nextButton = new ButtonBuilder() .setCustomId('nextbtn') .setLabel('Suivant') .setStyle(ButtonStyle.Success); const buttonList = [backButton, nextButton]; const timeout = 15000; paginationEmbed(message, embeds, buttonList, timeout); }, };