add role vocal and mini update suggest

This commit is contained in:
VALOU3336
2024-02-24 21:15:00 +01:00
parent b070fe6edf
commit 58ac0125b9
3 changed files with 107 additions and 1 deletions
+28
View File
@@ -0,0 +1,28 @@
const db = require('quick.db');
const GestionDb = new db.table('gestion');
const {Events} = require("discord.js")
module.exports = {
name: Events.VoiceStateUpdate,
async execute(oldState, newState) {
if (!oldState.channelId && newState.channelId) {
const guildId = newState.guild.id;
const botId = newState.client.user.id;
const channelId = newState.channelId;
const roles = GestionDb.get(`${botId}.${guildId}.rolevocal.${channelId}`) || [];
if (roles.length > 0) {
const member = newState.member;
for (const roleId of roles) {
const role = newState.guild.roles.cache.get(roleId);
if (role) {
try {
await member.roles.add(role);
} catch (error) {
console.error(`Erreur lors de l'ajout du rôle ${roleId} à l'utilisateur ${member.id}:`, error);
}
}
}
}
}
},
};