mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-03 15:07:26 +02:00
9bd39c69ca
sinon il y a pleins de truc comme les anti raid , des coorectif ect
65 lines
2.5 KiB
JavaScript
65 lines
2.5 KiB
JavaScript
const { EmbedBuilder, ChannelType } = require('discord.js');
|
|
const sqlite3 = require('sqlite3').verbose();
|
|
const db = new sqlite3.Database('myDatabase.db');
|
|
|
|
module.exports = {
|
|
name: 'modlog',
|
|
description: 'Enregistre l\'ID d\'un salon pour les logs de modération.',
|
|
category: 'gestion',
|
|
emote: '📝',
|
|
utilisation: 'modlog [#salon/id]',
|
|
async execute(message, args) {
|
|
let channelId;
|
|
const mentionedChannel = message.mentions.channels.first();
|
|
|
|
if (mentionedChannel) {
|
|
channelId = mentionedChannel.id;
|
|
} else if (args[0]) {
|
|
const channel = message.guild.channels.cache.get(args[0]);
|
|
if (channel && channel.type === ChannelType.GuildText) {
|
|
channelId = args[0];
|
|
} else {
|
|
return message.reply('Le salon spécifié est invalide ou n\'existe pas dans ce serveur.');
|
|
}
|
|
} else {
|
|
channelId = message.channel.id;
|
|
}
|
|
|
|
let data = await new Promise((resolve, reject) => {
|
|
db.get('SELECT value FROM gestion WHERE id = ?', [message.client.user.id], (err, row) => {
|
|
if (err) {
|
|
console.error(err.message);
|
|
reject(err);
|
|
}
|
|
resolve(row ? JSON.parse(row.value) : {});
|
|
});
|
|
});
|
|
|
|
if (!data[message.guild.id]) {
|
|
data[message.guild.id] = {};
|
|
}
|
|
|
|
if (data[message.guild.id].modlog && data[message.guild.id].modlog === channelId) {
|
|
delete data[message.guild.id].modlog;
|
|
db.run('INSERT OR REPLACE INTO gestion (id, value) VALUES (?, ?)', [message.client.user.id, JSON.stringify(data)], function(err) {
|
|
if (err) {
|
|
return console.error(err.message);
|
|
}
|
|
});
|
|
return message.reply("Le salon de modlog a bien etait supprimé")
|
|
} else {
|
|
data[message.guild.id].modlog = channelId;
|
|
}
|
|
|
|
db.run('INSERT OR REPLACE INTO gestion (id, value) VALUES (?, ?)', [message.client.user.id, JSON.stringify(data)], function(err) {
|
|
if (err) {
|
|
return console.error(err.message);
|
|
}
|
|
});
|
|
|
|
const embed = new EmbedBuilder()
|
|
.setColor('#0099ff')
|
|
.setDescription(`Le salon de log de modération a été mis à jour dans le salon <#${channelId}>`);
|
|
message.channel.send({ embeds: [embed] });
|
|
},
|
|
}; |