加入语音通道时Discord.js发送消息不起作用

时间:2020-06-28 10:01:47

标签: node.js bots discord discord.js

所以我的机器人的意思是,当某人加入某个频道时,它将向日志频道“ 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`)
  }
})

谢谢。

1 个答案:

答案 0 :(得分:0)

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大小写