如果用户切换语音通道,则向通道发送消息

时间:2018-08-04 16:40:25

标签: discord discord.io

我以这种方式尝试过,但是机器人给了我一个错误:

ex2 <- ex %>% 
    group_by(group) %>% 
    nest() %>%
    mutate(h.cand = map(data,
                        ~ quantile(dist(.), seq(0.05, 0.40, by = 0.05))),
           cluster = map2(h.cand, data,
                          function(x, y) { map(x,
                                               function(x2) { msClustering(y, x2) }) } ) )
unnest(ex2, cluster)
# A tibble: 24 x 2
   group   cluster   
   <chr>   <list>    
 1 group B <list [2]>
 2 group B <list [2]>
 3 group B <list [2]>
 4 group B <list [2]>
 5 group B <list [2]>
 6 group B <list [2]>
 7 group B <list [2]>
 8 group B <list [2]>
 9 group C <list [2]>
10 group C <list [2]>
# ... with 14 more rows

它不起作用。

我的目标是将所有语音通道切换记录在我为此创建的单个文本通道中。


let newUserChannel = newMember.voiceChannel 
                               ^ 
TypeError: Cannot read property 'voiceChannel' of undefined

1 个答案:

答案 0 :(得分:0)

bot.sendMessage已过时。

尝试这个:

    bot.on('voiceStateUpdate', (oldMember, newMember) => {
  let newUserChannel = newMember.voiceChannel
  let oldUserChannel = oldMember.voiceChannel


  if(!oldUserChannel && newUserChannel) {

    bot.channels.get('475330828466126848').send("User went form Channel" + oldUserChannel.name + "to the new" 
           + newUserChannel.name + "Channel");

  }
})

请下次指定您的错误。 我使用了.send属性将您的消息发送到此频道。