Cannot read property 'includes' of undefined

前端 未结 6 1315
抹茶落季
抹茶落季 2021-01-21 16:09

I am new to JavaScript, am I was trying to dissect an embedded message. Here\'s my code, it runs fine for a few mins, works accordingly but idk what goes wrong.



        
6条回答
  •  悲&欢浪女
    2021-01-21 16:37

    I think this code can fix this problem.

    
    bot.on('message', (message) => {
      for (var i = 0; i < message.embeds.length; i++) {
        if (message.embeds[i] && message.embeds[i].title.includes("text!")) {
          message.channel.send('reply')
        }
      }
    })
    
    

提交回复
热议问题