mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-26 06:33:05 +02:00
add role vocal and mini update suggest
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user