Brian Chambers
Brian Chambers

Reputation: 25

Cannot get Discord.js to embed THEN delete

EDIT: Trying to make it more clear. I want the embed listed below in the part where it says EMBED GOES HERE.

Unsure if i can even do that. My structure is calling externally for files named in example: test.js through swap args. Creating a very rough command handler.

module.exports = {
    name: 'test',
    description: "Embed",
    execute(message, args){
        message.delete();
message.channel.send(`**EMBED GOES HERE**`).then(async sentMessage => {
    await sentMessage.delete({ timeout: 10000 });
});
    }
}

Where this is the embed.

 "embed": {
              "title": "Test",
              "thumbnail": 'google.com',
              "url": "google.com",
              "description": 'test',
              "color": 16763981,
              "footer": {
              }

Upvotes: 1

Views: 62

Answers (1)

Tarazed
Tarazed

Reputation: 2675

An embed is a specially formatted JSON object, which can be easily assigned to any variable. However, the data portion of channel.send is also an object, so in the end it will be an object nested in an object. (The second one, I will create inline) This may be a bit confusing, because an embed is an option, not part of the content.

let myEmbed = {
    title: "Test",
    thumbnail: { url: 'google.com'},
    url: "google.com",
    description: 'test',
    color: 16763981,
    footer: { }
};

message.channel.send({embed: myEmbed }).then(async sentMessage => {
    await sentMessage.delete({ timeout: 10000 });
    message.delete();
});

Upvotes: 1

Related Questions