Discord.js此临时频道代码不起作用

时间:2020-09-04 16:31:28

标签: javascript node.js discord discord.js

我在解决方案中使用了Discord.js doesn't create temporary channels的代码,但是它也不起作用

bot.on('voiceStateUpdate', async (oldMember, newMember) => {
 const mainCatagory = '670970042074267700';
 const mainChannel = '715732769476444161';
 if (newMember.voiceChannelID == mainChannel) {
  let channel = await newMember.guild.channels.create(
   `${newMember.user.username} 5vs5`,
   { type: 'voice', parent: mainCatagory }
  );

  temporary.push({ newID: channel.id, guild: channel.guild });
  // A new element has been added to temporary array!
  await newMember.setVoiceChannel(channel.id);
 }
 // The rest of your code.

 if (temporary.length >= 0)
  for (let i = 0; i < temporary.length; i++) {
   // Finding...
   let ch = temporary[i].guild.channels.cache.find(
    (x) => x.id == temporary[i].newID
   );
   // Channel Found!
   ch.setUserLimit(5);
   if (ch.members.size <= 0) {
    ch.delete(1000);
    // Channel has been deleted!
    return temporary.splice(i, 1);
   }
  }
});

0 个答案:

没有答案