Read contents of an embed message from a discord server

前端 未结 1 1754
猫巷女王i
猫巷女王i 2020-12-19 11:39

Scenario: I am trying to read various fields in an embed message posted to a sever, do some processing, and log results in a DB.

相关标签:
1条回答
  • 2020-12-19 12:00

    Once you have your Message object, check the embeds property to obtain an array of all MessageEmbeds contained inside it. You can then read any of the properties, such as description, fields, etc.

    Here's some example code:

    const client = new Discord.Client();
    /* client.login, etc. etc. */
    
    client.on('message', (msg) => {
        msg.embeds.forEach((embed) => {
           // add this embed to the database, using embed.description, embed.fields, etc.
            // if there are no embeds, this code won't run.
        });
        msg.reply("Embed sent!");
    });
    
    0 讨论(0)
提交回复
热议问题