Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

321
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda