Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

315
Vistas
Enviar un mensaje a un canal de texto cuando una persona se una a un canal de voz específico

Estoy tratando de hacer que mi bot notifique al personal de mi servidor en un canal de texto específico cuando alguien ingresa a la sala de espera de soporte de voz.

Desafortunadamente, solo encontré algunos ejemplos para la versión 12 de Discord, y no me funciona en la versión 13. No sé qué cambiar en ese código.

No hay mensaje de error ni nada, simplemente no envía un mensaje cuando alguien se une al canal de voz.

 client.on('voiceStateUpdate', (oldState, newState) => { const newUserChannel = newState.channelID; const textChannel = client.channels.cache.get('931223643362703521'); if (newUserChannel === '931156705303317013') { textChannel.send('Somebody joined'); } console.error(); });
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Primero, asegúrese de agregar las intenciones de GUILD_VOICE_STATES .

Probablemente sea mejor fetch el canal, en lugar de confiar en el caché. Si el canal ya está almacenado en caché, fetch lo usará y no realizará una solicitud a la API de discord, pero si no está almacenado en caché, channels.cache.get no lo encontrará.

Hice un par de cambios y agregué algunos comentarios en el siguiente código:

 const { Client, Intents } = require('discord.js'); const client = new Client({ intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_VOICE_STATES, ], }); client.on('voiceStateUpdate', async (oldState, newState) => { const VOICE_SUPPORT_ID = '931156705303317013'; const LOG_CHANNEL_ID = '931223643362703521'; // if there is no newState channel, the user has just left a channel const USER_LEFT = !newState.channel; // if there is no oldState channel, the user has just joined a channel const USER_JOINED = !oldState.channel; // if there are oldState and newState channels, but the IDs are different, // user has just switched voice channels const USER_SWITCHED = newState.channel?.id !== oldState.channel?.id; // if a user has just left a channel, stop executing the code if (USER_LEFT) return; if ( // if a user has just joined or switched to a voice channel (USER_JOINED || USER_SWITCHED) && // and the new voice channel is the same as the support channel newState.channel.id === VOICE_SUPPORT_ID ) { try { let logChannel = await client.channels.fetch(LOG_CHANNEL_ID); logChannel.send( `${newState.member.displayName} joined the support channel`, ); } catch (err) { console.error('❌ Error finding the log channel, check the error below'); console.error(err); return; } } });
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda