如何使名称像用户一样具有该角色

时间:2020-06-23 14:58:29

标签: javascript node.js discord.js

当有人加入语音通道时,漫游器将创建名称通道,就像用户具有该角色一样,而漫游器将在用户具有该角色的情况下创建,例如:* UserJoin-> Bot Create Channel-> IRON |用户名

对不起,我的英语不好

music.on('voiceStateUpdate',(lama, baru) => {
  var state = null;  
  const kategorikanal = '700743802574602260'
  const channelid = '700743824346972231'
  if(!lama.voiceChannel && !baru.voiceChannel) return;
  if(!lama.voiceChannel && baru.voiceChannel) {state = "join"}
  else if(lama.voiceChannel && !baru.voiceChannel) {state = "leave"}
  else if(lama.voiceChannel.id !== baru.voiceChannel.id) {state = "move"}
  else if(lama.voiceChannel.id == baru.voiceChannel.id) return;
  console.log(state);
   let allowedRole = baru.guild.roles.find("name", "IRON");
  if(baru.voiceChannelID === channelid || baru.member.roles.has(allowedRole.id) ){
    baru.guild.createChannel(`${allowedRole.name} | ${baru.user.username}`,'voice')
    .then(tempChannel => {
      tempChannel.setParent(kategorikanal);
      baru.setVoiceChannel(tempChannel.id);
      tempChannel.setUserLimit('5');
      })
      
  .catch(console.error)
}
  if(lama.voiceChannelID) {
         
     const voicelama = lama.guild.channels.get(lama.voiceChannelID);
    
  if(voicelama.name.startsWith(`${allowedRole.name} | ${baru.user.username}`)){
      let sawadikap = `**${baru.user.username}'s**` + " **Team**"
      var koko = new Discord.RichEmbed()
      .setColor("#FF4654")
      .setThumbnail(`${baru.user.avatarURL}`)
      .addField('**Good Game Well Played**',`${sawadikap}`)
      .setFooter("@Valorant Indonesia Community." , 'https://i.imgur.com/yPWqxxu.png') 
      voicelama.delete()
      .then(function() {
        music.channels.get('717475755512299560').send(koko)
  })
      .catch(console.error);
  }
    }
  })

请帮助我

0 个答案:

没有答案