mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-03 23:36:35 +02:00
9bd39c69ca
sinon il y a pleins de truc comme les anti raid , des coorectif ect
56 lines
1.8 KiB
JavaScript
56 lines
1.8 KiB
JavaScript
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);
|
|
},
|
|
}; |