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
53 lines
2.0 KiB
JavaScript
53 lines
2.0 KiB
JavaScript
const { Events, EmbedBuilder } = require("discord.js");
|
|
const sqlite3 = require('sqlite3').verbose();
|
|
const db = new sqlite3.Database('myDatabase.db');
|
|
module.exports = {
|
|
name: Events.VoiceStateUpdate,
|
|
once: false,
|
|
async execute(oldState, newState, client) {
|
|
// Ignorer les changements de salon vocal pour les bots
|
|
if (oldState.member.user.bot || newState.member.user.bot) return;
|
|
|
|
// Récupérer les données de configuration des logs pour le serveur
|
|
let data = await new Promise((resolve, reject) => {
|
|
db.get('SELECT value FROM gestion WHERE id = ?', [client.user.id], (err, row) => {
|
|
if (err) {
|
|
console.error(err.message);
|
|
reject(err);
|
|
}
|
|
resolve(row ? JSON.parse(row.value) : {});
|
|
});
|
|
});
|
|
|
|
// Vérifier si le serveur a un canal de logs configuré pour les salons vocaux
|
|
if (!data[oldState.guild.id] || !data[oldState.guild.id].vocallog) return;
|
|
|
|
const logChannelId = data[oldState.guild.id].vocallog;
|
|
const logChannel = client.channels.cache.get(logChannelId);
|
|
|
|
if (!logChannel) return;
|
|
|
|
const joinedVoiceChannel = newState.channel;
|
|
const leftVoiceChannel = oldState.channel;
|
|
|
|
if (joinedVoiceChannel) {
|
|
const embed = new EmbedBuilder()
|
|
.setDescription(`${newState.member.user.tag} a rejoint le salon vocal <#${joinedVoiceChannel.id}>`)
|
|
.setTimestamp();
|
|
|
|
try {
|
|
await logChannel.send({ embeds: [embed] });
|
|
} catch (error) {
|
|
}
|
|
} else if (leftVoiceChannel) {
|
|
const embed = new EmbedBuilder()
|
|
.setDescription(`${oldState.member.user.tag} a quitté le salon vocal <#${leftVoiceChannel.id}>`)
|
|
.setTimestamp();
|
|
|
|
try {
|
|
await logChannel.send({ embeds: [embed] });
|
|
} catch (error) {
|
|
}
|
|
}
|
|
},
|
|
}; |