如何解决:使用discord.js创建语音通道的“无法读取属性”

时间:2019-08-03 16:31:15

标签: javascript discord.js voice

我搜索通过加入一个特定的其他语音通道来创建用于创建语音通道的漫游器,但是出现错误:

  

“ TypeError:无法读取未定义的属性'channel'”

bot.on('voiceStateUpdate', (oldMember, newMember, message) => {
    let newUserChannel = newMember.voiceChannel
    let oldUserChannel = oldMember.voiceChannel


    if(oldUserChannel === undefined && newUserChannel !== undefined) {
        var idVoiceChannel = newMember.voiceChannelID
        console.log('Join')
       if (idVoiceChannel === "605468426846800900") { //test
        console.log('test')
        bot.channel.createChannel('General', "voice").then(chan => {
            chan.userLimit("5");
        })
       }else if(idVoiceChannel === "607223548620755073"){
        console.log('testing 2')
       }

    } else if(newUserChannel === undefined){

      // User leaves a voice channel
      console.log('Leave');
    }
  })

0 个答案:

没有答案