【问题标题】:Cannot leave voice channel无法离开语音频道
【发布时间】:2019-07-08 18:49:29
【问题描述】:

我的机器人不能离开语音频道,但它可以加入任何人。我有两个代码,一个是“离开”,另一个是“stopstream”,它说“无法读取未定义的属性'channelID'”和“(节点:11416)UnhandledPromiseRejectionWarning:TypeError:无法读取未定义的属性'voiceChannel' " 一个复杂的代码

我尝试使用不同的代码,其中一个比另一个复杂。并输入“const ytdl = require('ytdl-core'); const streamOptions = { seek: 0, volume: 1 };" 在复数中。

//leave

const ytdl = require('ytdl-core');
const streamOptions = { seek: 0, volume: 1 };

exports.run = async (client, message, args, ops) => {

   if (!message.member.voiceChannel) return message.channel.send('Please connect to a voice chanel, don\'t be afraid my child. Share you beautiful voice.');

   if (!message.guild.mne.voiceChannel) return message.channel.send('Sorry, I\'m not connected to the guild.');

   if (message.guild.me.voiceChannelID !== message.member.voiceChannelID) return message.chanel.send('Sorry, you aren\t connected to the same channel, I\'ll give you some PeterFriffinCoins, for free.');

   message.guild.me.voiceChannel.leave();

   message.channel.send('Leaving Channel... I\'m a free elf...')
}


//stopstream

exports.run = (client, message, args) => {

    client.leaveVoiceChannel(message.member.voiceState.channelID);
    message.channel.send('Thanks for tuning in!');
}

【问题讨论】:

    标签: javascript discord


    【解决方案1】:

    在离开频道命令中试试这个

    let authorVoiceChannel = message.member.voiceChannel;
    if(!authorVoiceChannel) return message.channel.send("You are not in a voice channel")
    if(authorVoiceChannel.id !== client.voiceChannel.id) return message.channel.send("We're not in the same voice channel")
    
    authorVoiceChannel.leave()
    
    message.channel.send("I left voice channel")
    
    

    【讨论】:

      猜你喜欢
      • 2020-07-17
      • 1970-01-01
      • 2018-06-16
      • 2020-08-30
      • 2021-04-24
      • 2019-04-08
      • 1970-01-01
      • 2020-10-24
      • 2020-09-07
      相关资源
      最近更新 更多