undefined member.voiceChannel(未定义 member.voiceChannel)
问题描述
我的 discord bot 遇到问题,不知道用户在哪个频道.如果我检查 member.voiceChannel
,它总是返回 undefined
.即使我在语音频道内.
I am having trouble with my discord bot not knowing what channel a user is in. If I check member.voiceChannel
it always returns undefined
. Even if I am inside a voice 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
无论我是否在语音频道中.
console.log(voiceChannel);
prints undefined
regardless of me being in a Voice Channel or not.
推荐答案
刚刚在使用 Discord.js v12 时发生在我身上.
Happened to me just now while using Discord.js v12.
显然变量在版本之间更改了名称,现在改为:
Apparently the variable changed names between versions and now instead of:
message.member.voiceChannel
它是:
message.member.voice.channel
像这样更改变量对我有用
Changing the variable like this worked for me
这篇关于未定义 member.voiceChannel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:未定义 member.voiceChannel


基础教程推荐
- Bootstrap 模态出现在背景下 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01