For the complete documentation index, see llms.txt. This page is also available as Markdown.

Embeds

This page explains how to work with the internal Embed API.

Embed API

Embeds are a beautiful way to enhance your plugin with clean, professional-looking message designs. Athena’s API provides three custom pre-built embed types.


Error embeds

Error embeds are primarily used inside try-catch blocks. To generate an error embed, use the following snippet:

const errorEmbed = this.heart.core.util.discord.generateErrorEmbed(`${userMention(interaction.user.id)}, something went wrong!`);
interaction.reply({ embeds: [errorEmbed] });

The .generateErrorEmbed() function returns an EmbedBuilder instance. The text you pass in becomes the description of the error embed preset.


Warning embeds

Warning embeds are the correct way to inform the command or interaction executor that they cannot proceed. Typical use cases include:

  • The user does not have permission to use a panel.

  • The command can only be executed in ticket channels.

  • Any other situation where the command cannot be executed.

const warnEmbed = this.heart.core.util.discord.generateWarnEmbed(`${userMention(interaction.user.id)}, this command can only be run in tickets!`);
interaction.reply({ embeds: [warnEmbed] });

The .generateWarnEmbed() function returns an EmbedBuilder instance. The text you pass in becomes the description of the warning embed preset.


Other embeds

Not every message should be an error or warning. This embed type is used for general information, notifications, and other messages that do not fall under those categories.

The embed configuration follows the official Embed JSON representation. Athena provides four additional custom fields to extend the embed functionality:

  • defaultFooter: If set to true, the time when the embed is generated is used as the timestamp.

  • defaultFooter: If set to true, the default footer text from your common.json config is used.

  • guildIcon: If set to true and a guild instance is provided, the guild icon is displayed in the embed thumbnail.

  • userIcon: If set to true and a user instance is provided, the user avatar is displayed in the embed thumbnail.

Placeholders can be used by writing %placeholder_name% in any field such as the title or description. This is extremely useful if you want to make your messages configurable through your configuration file.

Athena also provides additional default placeholders that work in every embed rendered by .resolveEmbed():

  • %custom_emoji_<number>%

  • %user%

  • %user_display%

  • %user_id%

  • %user_mention%

  • %user_icon%

  • %user_created%

  • %user_created_formatted%

  • %user_joined%

  • %user_joined_formatted%

  • %guild%

  • %guild_id%

  • %guild_icon%

  • %random_int_<max_number>%

  • %random_string_<length>%

  • %current_date%

  • %current_time%

  • %current_time_seconds%

  • %current_datetime%

  • %current_iso%

All %user_...% placeholders only work if a user instance is provided to .resolveEmbed(). The same applies to %guild_...% placeholders and a guild instance.

Last updated