他のボット埋め込みメッセージを読むように不和ボットを作成する方法

Aug 17 2020

好きな不和ボットゲーム「EPICRPG」があり、プレイヤー向けのイベントがあるので、特定の役割を挙げてメッセージを追加してイベントをアナウンスできるボットを作りたかったのですが、アイデアが必要です。

これが私のコードです

client.on('message', (message) => {
  if (message.author.id === '555955826880413696') {
    if (message.embeds) {
      const embed = message.embeds[0]
      if (embed.title === "**IT'S RAINING COINS**") {
        return  message.channel.send('the COIN RAIN event is started')
      }
    }
  }
})

そのコードはこの写真によるものです。IT'SRAININGCOINSステートメントでコマンドをトリガーし、「コインレインイベントが開始されました」と返信したいのですがhttps://i.stack.imgur.com/H5mjN.png、問題はボットが埋め込みメッセージを読み取れないことです、何かアイデアはありますか?

PS:私がそれを始めたとき、それはtitle上の単語if (embed.title === "Theblablablaが未定義であることを示しています

回答

Dorian349 Aug 17 2020 at 12:39

写真でわかるように、埋め込みのタイトルは単なるテキストではなく、絵文字もあります。

変更する必要があります embed.title === "**IT'S RAINING COINS**"

embed.title.includes("IT'S RAINING COINS")

最終結果:

client.on('message', (message) => {
  if (message.author.id === '555955826880413696') {
    if (message.embeds.length == 1) {
      const embed = message.embeds[0]
      if (embed.title.includes("IT'S RAINING COINS")) {
        return  message.channel.send('the COIN RAIN event is started')
      }
    }
  }
})