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

281
Views
cómo verificar si el miembro está unido a un canal de voz específico DiscordJS

Quiero comprobar si el miembro está unido al canal de voz al que está unido el bot. Todo el código está funcionando, solo quiero agregar esa línea que puse en los comentarios del código. Mi código:

 const { QueryType } = require('discord-player'); const { MessageEmbed } = require('discord.js'); module.exports = { name: 'play', aliases: ['p'], permissions: ['CONNECT'], description: 'Plays a music', voiceChannel: true, async execute(message, args, cmd, client, Discord, profileData) { // if the member that used the comamnd is not joined to the voicechannel that the bot is playing music on it, return; const player = client.player if (!args[0]) return message.channel.send({ content: `${message.author}, Write the name of the music you want to search. <:Cross:961558777667149874>` }); const res = await client.player.search(args.join(' '), { requestedBy: message.member, searchEngine: QueryType.AUTO }); if (!res || !res.tracks.length) return message.channel.send({ content: `${message.author}, No results found! <:Cross:961558777667149874>` }); const queue = await client.player.createQueue(message.guild, { metadata: message.channel }); try { if (!queue.connection) await queue.connect(message.member.voice.channel) } catch { await client.player.deleteQueue(message.guild.id); return message.channel.send({ content: `<:Cross:961558777667149874> ${message.author}, I can't join audio channel ` }); } if(client.config.opt.selfDeaf === false) { let channel = message.member.voice.channel; const { joinVoiceChannel } = require('@discordjs/voice'); const connection = joinVoiceChannel({ channelId: channel.id, guildId: channel.guild.id, adapterCreator: channel.guild.voiceAdapterCreator, selfDeaf: false }); } res.playlist ? queue.addTracks(res.tracks) : queue.addTrack(res.tracks[0]); if (!queue.playing) await queue.play(); }, };

No estoy recibiendo ningún error. Estoy usando node.js v16 y discord.js v13

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede usar este código para regresar si el miembro no está en el mismo canal de voz que usted.

 if(message.member.voice.channelId !== message.guild.me.voice.channelId) return;

Luego regresará si no están en el mismo canal.

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!