Conecté dos cuentas de bot de Discord a un script y quiero expulsar a un usuario cuando abandona un canal de voz, pero no funciona. código:
const { Client, Intents, ClientUser } = require('discord.js'); const cli = require('nodemon/lib/cli'); const clients = [ new Client({ intents: [Intents.FLAGS.GUILDS] }), new Client({ intents: [Intents.FLAGS.GUILDS] }) ]; const Tokens = ["token1", "token2"] clients.forEach(function(client, index) { client.login(Tokens[index]) let clientcount = index + 1 client.on("ready", () => { client.user.setUsername("PartyChat Bot") client.user.setActivity(`PartyChat Bot #${clientcount}`) console.log(`PartyBot #${clientcount} is online`) }) }); clients.forEach(function(client, index) { client.on('voiceStateUpdate', (oldState, newState) => { let newUserChannel = newState.voiceChannel let oldUserChannel = oldState.voiceChannel if(oldUserChannel === undefined && newUserChannel !== undefined) { // User Joins a voice channel } else if(newUserChannel === null){ console.log("user left") newState.member.kick() } }) });
if(oldState.channel && !newState.channel){ // code block }
esto detecta si el usuario estaba en el canal y se fue sin unirse al nuevo canal.