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

221
Views
¿Cómo eliminar un canal de voz cuando todos se desconectan?

Creé un sistema de unión para crear que crea un canal cuando un usuario se une y lo elimina cuando se va. Sin embargo, solo se elimina si la última persona que se va es el usuario que creó la sala. ¿Algunas ideas?

 const { Collection } = require("discord.js"); const voiceCollection = new Collection(); module.exports = async (Discord, client, oldState, newState) => { const user = await client.users.fetch(newState.id); const member = newState.guild.member(user); // JOIN if (!voiceName || voiceName === "") { if (!oldState.channel && newState.channelID === "898245212541976667") { const channel = await newState.guild.channels.create(user.tag, { type: "voice", parent: newState.channel.parent, }); member.voice.setChannel(channel); voiceCollection.set(user.id, channel.id); await channel.overwritePermissions([ { id: user.id, allow: ["MANAGE_CHANNELS", "CONNECT"], }, { id: member.guild.id, deny: ["CONNECT"], }, ]); } else if (!newState.channel) { if (oldState.channelID === voiceCollection.get(newState.id)) { if (oldState.channel.members.size < 1) { return oldState.channel.delete(); } } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

var newchannel_id = config.Channel_id; var categoría_id = config.categoría;

var lista de canales de usuario = []

cliente.login(token); cliente.on('voiceStateUpdate', asíncrono (antiguoMiembro, nuevoMiembro) => {

 if (newMember.channel !== null && oldMember.channel === null && newMember.channel.id === newchannel_id || newMember.channel !== null && oldMember.channel !== null && newMember.channel.id === newchannel_id) { var current_user = newMember.member.user; console.log(current_user.username + 'creating the channel'); // Start the creation of the new channel var server = newMember.guild; let USERA = newMember.member.nickname || newMember.member.user.username; var channel = { type: 'voice', bitrate: 384000, parent: category_id, permissionOverwrites: [{ // permissions id: server.id, allow: ['VIEW_CHANNEL'], }, { id: current_user.id, allow: ['MOVE_MEMBERS', 'MANAGE_CHANNELS'] } ] }; server.channels.create('🔊' + USERA, channel).then(channel => { newMember.setChannel(channel).catch(console.error) userchannellist.push(channel) //channel region client.api.channels(channel.id).patch({ data: { rtc_region: "rotterdam" } }) }).catch(console.error); } // delete Chaneel if (oldMember.channel) { let filter = (ch) => (ch.parentID == category_id) && (ch.id !== newchannel_id) && (oldMember.channel == ch.id) && (oldMember.channel.members.size == 0); return oldMember.guild.channels.cache .filter(filter) .forEach((ch) => ch.delete() .catch(console.error)); } });
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!