mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-03 23:36:35 +02:00
38 lines
1.6 KiB
JavaScript
38 lines
1.6 KiB
JavaScript
const { EmbedBuilder } = require('discord.js');
|
|
const sqlite3 = require('sqlite3').verbose();
|
|
const db = new sqlite3.Database('myDatabase.db');
|
|
|
|
module.exports = {
|
|
name: 'sanction',
|
|
description: 'Afficher tous les avertissements d\'un utilisateur',
|
|
aliases: ['sanction'],
|
|
category: 'moderation',
|
|
utilisation: '+sanction @user/id',
|
|
|
|
async execute(message, args, client) {
|
|
const user = message.mentions.users.first() || client.users.cache.get(args[0]);
|
|
if (!user) {
|
|
return message.reply('Utilisateur non trouvé.');
|
|
}
|
|
|
|
let warnings = await new Promise((resolve, reject) => {
|
|
db.all('SELECT warningId, reason, timestamp FROM warnings WHERE guildId = ? AND userId = ? ORDER BY warningId', [message.guild.id, user.id], (err, rows) => {
|
|
if (err) {
|
|
console.error(err.message);
|
|
reject(err);
|
|
}
|
|
resolve(rows);
|
|
});
|
|
});
|
|
|
|
const embed = new EmbedBuilder()
|
|
.setTitle(`Sanctions de ${user.tag}`)
|
|
.setDescription(warnings.map(warning => `**${warning.warningId}:** ${warning.reason} (Mis le <t:${Math.floor(warning.timestamp / 1000)}:R>)`).join('\n') || "Cette personne n'a pas de sanction")
|
|
.setFooter({ text: 'Gestion des sanctions', iconURL: client.user.displayAvatarURL({dynamic: true})});
|
|
try {
|
|
message.channel.send({ embeds: [embed] });
|
|
}catch(err) {
|
|
message.reply("Une erreur est survenu dans l'embed du message")
|
|
}
|
|
},
|
|
}; |