Cannot read property 'includes' of undefined

前端 未结 6 1382
抹茶落季
抹茶落季 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:33

    Probably some of the embed object is coming without the title property.

    You can safely use your logic changing your if condition to:

    if ('title' in message.embeds[i] && message.embeds[i].title.includes("text!")) {
       /* ... */
    }
    

提交回复
热议问题