【问题标题】:discord.js. Cant get channel id from user texting不和谐.js。无法从用户短信中获取频道 ID
【发布时间】:2020-07-05 05:23:00
【问题描述】:

所以我尝试让一个机器人加入我所在的语音频道,然后让它发送一条消息。问题是我不完全确定我是否以正确的方式使用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)

机器人读取了消息,然后我不完全确定尝试加入时出了什么问题...

【问题讨论】:

    标签: javascript discord.js


    【解决方案1】:

    这是 Discord.js v12 中的更改。 将msg.member.voiceChannel 替换为msg.member.voice.channel

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-04
      • 1970-01-01
      • 2020-10-09
      • 1970-01-01
      • 1970-01-01
      • 2022-10-05
      • 2023-04-07
      • 2019-05-09
      相关资源
      最近更新 更多