我的 discord 机器人有问题,不知道用户在哪个 channel 。如果我检查 member.voiceChannel
,它总是返回 undefined
。即使我在语音 channel 内。
代码:
let voiceChannel;
voiceChannel = msg.member.voiceChannel;
if (!voiceChannel) {
return msg.reply('Please join a voice channel before using this command.');
}
console.log(voiceChannel);
打印 undefined
无论我是否在语音 channel 中。
最佳答案
刚才在使用 Discord.js v12 时发生在我身上。
显然变量在版本之间更改了名称,现在代替了:
message.member.voiceChannel
它是:
message.member.voice.channel
像这样改变变量对我有用
关于javascript - 未定义的成员.voiceChannel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51922097/