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.
Testing: Using a testBot for sending relevant messages everything works when using a normal text message, but when an "embed message" is used (theoretically making it much easier to identify fields for processing etc), I can't retrieve the data. I'm at an total loss how to access the "embed" from the message object.
I realize that it is about now I should pop in some code for you to examine, but I'm not even that far along ! Reading the documentation (linked to at the end) I am pretty sure is will be something to do with one of these classes:- message.embeds.x.y.z or MessageEmbed.x.y.x
Google has not been my friend, I can not find one example of code that reads an "Embed message" which is odd.
Anyway, to ensure I don't look like a complete sponge I'll include the working code for the "embed sender bot". A few people seem to have problems cracking the syntax, so it maybe of use to someone else searching on here...
Thanks in advance for any help you can give.
Documentation Found: Docs for MessageEmbed And;
Embed used within message class
Code for test Embed sender bot:
const Discord = require("discord.js");
const client = new Discord.Client();
const config = require("./config.json");
/* A simple bot to throw out a test "Embed message" when asked to. */
client.on("message", (message) => {
if (!message.content.startsWith(config.prefix) || message.author.bot)
return;
if (message.content.startsWith(config.prefix + "emb")) {
console.log("Sending an embedd message");
message.channel.send({embed: {
color: 3447003,
title: "This is an embed (Title)",
description: "Embed! (first line)\nsecond line of Desc\nthird line of
Desc",
footer:
{
text: "Footnote ©"
}
}});
} else if (message.content.startsWith(config.prefix + "test"))
{
message.reply("Bot active");
};
});
client.login(config.token);