【问题标题】:How to make a discord bot read embed如何使不和谐的机器人读取嵌入
【发布时间】:2021-01-21 19:31:11
【问题描述】:

我有一个最喜欢的名为“EPIC RPG”的不和谐机器人游戏,有一个面向玩家的事件,所以我想制作一个可以宣布事件并提及特定角色并添加一些消息的机器人,如何解决这个问题?

TypeError: Cannot read property 'includes' of undefined

这是我的代码

client.on('message', message => { 
  let embed = message.embeds[0];
  if (embed && embed.title.includes('Type ``join`` to join the arena!')) {  
   message.channel.send( "<@&757597420275368076>" +"\:moneybag:" + "**CATCH**" + "\:moneybag:" );
  }
})

https://prnt.sc/uuci4z

【问题讨论】:

  • if (embed &amp;&amp; embed.title.includes()) 更改为 if (embed &amp;&amp; embed.title &amp;&amp; embed.title.includes())

标签: discord.js


【解决方案1】:

您可以使用以下代码(适用于 Discord.js V 13):

client.on('messageCreate', message => { 
  let embed = message.embeds[0];

  if (embed && embed.title?.includes('Type ``join`` to join the arena!')) {  
   message.channel.send( "<@&757597420275368076>" +"\:moneybag:" + "**CATCH**" + "\:moneybag:" );
  }
})

【讨论】:

    猜你喜欢
    • 2019-04-11
    • 1970-01-01
    • 2020-12-06
    • 1970-01-01
    • 2020-12-25
    • 1970-01-01
    • 2017-10-08
    • 2021-03-28
    • 2021-12-21
    相关资源
    最近更新 更多