collector.on("collect", async (i) => { i.deferReply({ ephemeral: true }).catch(() => {}); if (!interaction.member.voice.channel) return i.followUp({ content: emojis.error + ` | **You Must Join A Voice Channel**`, ephemeral: true, }); if (interaction.guild.me.voice.channel) { if ( interaction.member.voice.channel?.id !== interaction.guild.me.voice.channel?.id ) return i.followUp({ content: emojis.error + ` | **You Must Join <#${interaction.guild.me.voice.channel.id}> To Contolr The Panel**`, ephemeral: true, }); } ----------------------------------------------------------------------------- else if (panelType == "reactions") { if (!interaction.member.voice.channel) return interaction.channel .send(emojis.error + ` | **You Must Join A Voice Channel**`) .then((m) => { setTimeout(() => { m.delete(); }, 1500); }); if (interaction.guild.me.voice.channel) { if ( interaction.member.voice.channel?.id !== interaction.guild.me.voice.channel?.id ) return interaction.channel .send( emojis.error + ` | **You Must Join <#${interaction.guild.me.voice.channel.id}> To Contolr The Panel**` ) .then((m) => { setTimeout(() => { m.delete(); }, 1500); }); }Cualquiera puede ayudar, por favor. Quiero que el usuario escriba el prefijo mientras toca. Quiero que el usuario reciba un mensaje de error que indique que no puede reproducir esa canción si no está en algún canal. Este código sí. no ejecutarlo alguien me lo puede arreglar
Puede usar una declaración if () :
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.reply({content: 'you must be in the same voice channel as me'}) O puede usar el método .some() para devolver un valor booleano, como:
const sameChan = client.voice.connections.some((c) => c.channel.id === msg.member.voice.channelID) if (!sameChan) return message.reply({content: 'you must be in the same voice channel as me'})Sin embargo, recomiendo usar la primera opción.
collector.on("collect", async (i) => { i.deferReply({ ephemeral: true }).catch(() => {}); if (!interaction.member.voice.channel) return i.followUp({ content: emojis.error + ` | **You Must Join A Voice Channel**`, ephemeral: true, }); if (interaction.guild.me.voice.channel) { if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.reply({content: 'you must be in the same voice channel as me'}) }}); ---------------------------------------------------------------------------- else if (panelType == "reactions") { if (!interaction.member.voice.channel) return interaction.channel .send(emojis.error + ` | **You Must Join A Voice Channel**`) .then((m) => { setTimeout(() => { m.delete(); }, 1500); }); if (interaction.guild.me.voice.channel) { if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.reply({content: 'you must be in the same voice channel as me'}) }; .then((m) => { setTimeout(() => { m.delete(); }, 1500); }); }