Carbon

Embeds

Embeds are used to display rich content in messages.

Embeds are used to display rich content in messages. You can create them in one or two ways:

Raw Objects

If you have a one-off embed that doesn't need its own class, you can directly use the Embed class.

const testEmbed = new Embed({
    title: "Embed Test",
    description: "This is an embed test",
    url: "https://buape.com"
})
message.reply({
    embeds: [testEmbed]
})

Extended Classes

You can setup a generic Embed that you can use in multiple places by extending the Embed class, and adding properties there or in the constructor.

class TestEmbed extends Embed {
	title = "Embed Test";
	description = "This is an embed test";
	url = "https://buape.com";
}

Here we have created an embed with a title, description, and URL. You can use this embed in a message by using the Embed class.

Example Embed

Here is an example embed with all the properties you can use:

class TestEmbed extends Embed {
    title = "Embed Test"
    description = "This is an embed test"
    url = "https://carbon.buape.com"
    timestamp = new Date().toString()
    color = 16711680;
    image = "https://cdn.buape.com/CarbonWordmark.png";
    thumbnail = "https://cdn.buape.com/CarbonWordmark.png";
    author = {
        name: "Author Name",
        icon: "https://buape.com",
    };
    fields = [
        {
            name: "Field 1",
            value: "Value 1",
            inline: true,
        },
        {
            name: "Field 2",
            value: "Value 2",
            inline: true,
        },
    ];
 
    constructor(footerText: string) {
        this.footer = {
            text: footerText,
            icon: "https://cdn.buape.com/CarbonWordmark.png",
        };
    }
}
 
const embedToSend = new TestEmbed("This is the custom footer")
message.reply({
    embeds: [embedToSend]
})
Edit on GitHub

Last updated on

On this page