mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-04 15:56:42 +02:00
38 lines
1.5 KiB
JavaScript
38 lines
1.5 KiB
JavaScript
const { EmbedBuilder } = require('discord.js');
|
|
const db = require('quick.db');
|
|
const GestionDb = new db.table("gestion");
|
|
|
|
module.exports = {
|
|
name: 'wl',
|
|
aliases: ['whitelist'],
|
|
description: 'Ajouter un utilisateur à la liste blanche ou afficher la liste blanche',
|
|
emote: '👑',
|
|
utilisation: 'wl <@user>',
|
|
category: 'gestion',
|
|
|
|
async execute(message, args, client) {
|
|
const botId = message.client.user.id;
|
|
const guildId = message.guild.id;
|
|
|
|
if (args.length > 0) {
|
|
const userId = args[0].replace(/<@!?(\d+)>/, '$1');
|
|
let whitelist = await GestionDb.get(`${botId}.${guildId}.whitelist`) || {};
|
|
|
|
if (!whitelist[userId]) {
|
|
whitelist[userId] = true;
|
|
await GestionDb.set(`${botId}.${guildId}.whitelist`, whitelist);
|
|
message.reply('Utilisateur ajouté à la liste blanche.');
|
|
} else {
|
|
message.reply('Cet utilisateur est déjà sur la liste blanche.');
|
|
}
|
|
} else {
|
|
let whitelist = await GestionDb.get(`${botId}.${guildId}.whitelist`) || {};
|
|
const embed = new EmbedBuilder()
|
|
.setTitle('Liste blanche')
|
|
.setDescription(Object.keys(whitelist).map(id => `<@${id}>`).join('\n') || 'Aucun utilisateur sur la liste blanche')
|
|
.setFooter({ text: 'design by valou336', iconURL: client.user.displayAvatarURL({dynamic: true})});
|
|
|
|
message.channel.send({ embeds: [embed] });
|
|
}
|
|
},
|
|
}; |