Encontré algunos artículos sobre esta pregunta. comoeste
Pero estaba en discord v12. Quiero discord.js v13
Mi código:
client.on("ready", async() => { const { joinVoiceChannel } = require('@discordjs/voice'); joinVoiceChannel({ channelId: "863783336860975114", guildId: "847071265100791849", adapterCreator: channelId.guild.voiceAdapterCreator }) // It does not work }¿Cómo puedo hacer que mi bot se una a un canal específico cuando esté listo?
Estoy usando discord.js v13 y node.js v16.15
En la documentación de @discordjs/voice y en la guía discord.js vemos:
const { joinVoiceChannel } = require('@discordjs/voice'); const connection = joinVoiceChannel({ channelId: channel.id, guildId: channel.guild.id, adapterCreator: channel.guild.voiceAdapterCreator, });Primero debe buscar el gremio o el canal, ya que necesita usar un voiceAdapterCreator .
Puedes usar algo como client . canales fetch para obtener el objeto del canal.
Código de ejemplo para poner dentro del evento ready:
client.channels.fetch(id) // voice channel's id .then((channel) => { // channel object const VoiceConnection = joinVoiceChannel({ channelId: channel.id, // the voice channel's id guildId: channel.guild.id, // the guild that the channel is in adapterCreator: channel.guild.voiceAdapterCreator // and setting the voice adapter creator }); });