gpt4 book ai didi

javascript - 未定义的成员.voiceChannel

转载 作者:行者123 更新时间:2023-11-30 11:15:07 25 4
gpt4 key购买 nike

我的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com