javascript - 不和谐.js。无法从用户短信中获取频道 ID
问题描述
所以我试图让一个机器人加入我的语音频道,然后让它发送一条消息。问题是我不完全确定我使用voiceChannel.join()
的是正确的方法,因为我收到以下错误"Cannot ready property "join" of undefined"
:
client.on('message', msg=>{
if(msg.content === "testing"){
const channel = msg.member.voiceChannel;
channel.join() //voiceChannel.join()
.then(msg.channel.send("!p https://www.youtube.com/watch?v=e-IWRmpefzE"));
}
})
我得到了这个错误:
C:\Users\Jakob\Desktop\DiscordBot\index.js:13
channel.join();
^
TypeError: Cannot read property 'join' of undefined
at Client.<anonymous> (C:\Users\Jakob\Desktop\DiscordBot\index.js:13:17)
机器人读取了消息,然后我不完全确定尝试加入时出了什么问题......
解决方案
这是 Discord.js v12 中的一个变化。替换msg.member.voiceChannel
为msg.member.voice.channel
推荐阅读
- java - SearchView.setQuery() 在用户点击放大镜菜单项之前
- java - 从 Excel 数据源 JasperReport 导出 Excel 报告
- azure - 我们可以将发布到 Azure Web App 的 .net 核心 API 导入 APIM
- javascript - 将 JavaScript 数组转换为 JSON 格式:JavaScript
- react-native - aws-amplify AWSIoTProvider 套接字错误:未定义
- list - Flutter - DrowpdownMunu 项目未从列表中填充
- r - 如何计算r中数据帧中每一行的非零元素的平均值
- android - Android TV:焦点移至 ScrollView 中的视图,该视图位于 ScrollView 的可见部分之外
- neural-network - 了解卷积层中的特征图 (PyTorch)
- python - Pymodm:ImportError(两个模型相互引用)