【问题标题】:Discord.js sending message upon voice channel joining is not workingDiscord.js 在语音通道加入时发送消息不起作用
【发布时间】:2020-06-29 00:33:58
【问题描述】:

所以我的机器人要做的是,当有人加入某个频道时,它会向日志频道发送一条消息“SomeGuy123 加入了该频道!”。所以我像一个小时一样构建它,现在我解决了所有错误,但它什么也没说,也没有给出任何错误。如果你愿意,我可以发送整个代码。这里只是加入时发送消息的部分:

  client.on("voiceStateUpdate", (oldState, newState) => {
  const newUserChannel = newState.ChannelID;
  const oldUserChannel = oldState.ChannelID
  const textChannel = newState.guild.channels.cache.get('715141269395079208')

  if(newUserChannel === '715141827644358707') {
    textChannel.send(`${newState.user.username} (${newState.id}) has joined the channel`)
  } else if (oldUserChannel === '715141827644358707' && newUserChannel !== '715141827644358707') {
    textChannel.send(`${newState.user.username} (${newState.id}) has left the channel`)
  }
})

提前谢谢你。

【问题讨论】:

    标签: node.js bots discord discord.js


    【解决方案1】:

    https://discord.js.org/#/docs/main/stable/class/Client?scrollTo=e-voiceStateUpdate

    https://discord.js.org/#/docs/main/stable/class/VoiceState

    <VoiceState>.ChannelID 未定义,它的<VoiceState>.channelID,javascript 不是 pascal 大小写,除了在类中

    【讨论】:

      猜你喜欢
      • 2021-08-27
      • 2021-02-28
      • 1970-01-01
      • 2021-08-22
      • 1970-01-01
      • 1970-01-01
      • 2021-11-03
      • 1970-01-01
      • 2020-11-23
      相关资源
      最近更新 更多