Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

264
Views
Connection.Destroy () Deja el canal de voz discordjs v13

Este es mi codigo para "salir de un canal de voz, pero como ven no esta funcional, cuando uso el comando, si no esta en un canal de voz me manda el mensaje" no estoy en un canal de voz.

Quiero hacer que salga del canal de voz sin usar la conexión const = ya que esta es la razón por la que se produce un error en la conexión y desconexión.

soy nuevo y estoy experimentando con esto, entiendo la logica de la programacion pero en este caso no se que hacer

 if(message.member.voice.channel) { const connection = joinVoiceChannel({ channelId: message.member.voice.channel.id, guildId: message.guild.id, adapterCreator: message.guild.voiceAdapterCreator, }); message.channel.send("Disconected!"); } message.channel.send("i am not in a channel voice");
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Así es como funciona

 client.on('messageCreate', async (message) => { if (message.content.toLocaleLowerCase() === prefix + 'join') { //Here's how to join a voice channel if (!message.member.voice.channel) return message.channel.send('You need to be a voice channel to execute this command!') if(!message.member.voice.channel.joinable) return message.channel.send('I need permission to join your voice channel!') const connection = joinVoiceChannel({ channelId: message.member.voice.channel.id, guildId: message.member.guild.id, adapterCreator: message.channel.guild.voiceAdapterCreator }) console.log('Connected to voice!'); } if (message.content.toLocaleLowerCase() === prefix + 'leave') { //Here's how to leave from voice channel const connection = getVoiceConnection(message.guild.id) if(!connection) return message.channel.send("I'm not in a voice channel!") connection.destroy() console.log('Disconnected from voice!'); } });

Aquí está el código completo

 const { Client, Intents } = require('discord.js') const { joinVoiceChannel, getVoiceConnection } = require('@discordjs/voice') const client = new Client({ intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_VOICE_STATES /// <= Don't miss this :) ] }); var prefix = '!' client.on('ready', async () => { console.log('Client is Ready...'); }); client.on('messageCreate', async (message) => { if (message.content.toLocaleLowerCase() === prefix + 'join') { //Here's how to join a voice channel if (!message.member.voice.channel) return message.channel.send('You need to be a voice channel to execute this command!') if(!message.member.voice.channel.joinable) return message.channel.send('I need permission to join your voice channel!') const connection = joinVoiceChannel({ channelId: message.member.voice.channel.id, guildId: message.member.guild.id, adapterCreator: message.channel.guild.voiceAdapterCreator }) console.log('Connected to voice!'); } if (message.content.toLocaleLowerCase() === prefix + 'leave') { //Here's how to leave from voice channel const connection = getVoiceConnection(message.guild.id) if(!connection) return message.channel.send("I'm not in a voice channel!") connection.destroy() console.log('Disconnected from voice!'); } }); client.login('BOT TOKEN HERE!');
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!