Results

Namespace

Type

Discord allows us to send Rich Embed objects attached to messages that render as nice info boxes in chat.

Example: Send an embed with some customization in response to an !info command.

const commands = new discord.command.CommandGroup({
 defaultPrefix: '!'
});

commands.registerCommand(
 "info",
 args => ({
   user: args.user()
 }),
 async ({ message }, { user }) => {
   // build the rich embed
   const richEmbed = new discord.Embed();
   richEmbed.setTitle(user.getTag()).setColor(0x00ff00);
   richEmbed.setDescription("User Information Example");
   richEmbed.setThumbnail({ url: user.getAvatarUrl() });
   richEmbed.addField({
     name: "User ID",
     value: user.id,
     inline: false
   });
   richEmbed.setTimestamp(new Date().toISOString());
   // reply to the command with our embed
   await message.reply({ content: "", embed: richEmbed });
 }
);

Hierarchy

  • Embed <-- You are here!

Index

Constructors

constructor

  • new Embed(init?: IEmbed): Embed
  • Constructs an Embed instance with the data provided.

    Parameters

    • Optional init: IEmbed

      The options for this embed.

    Returns Embed

Properties

Readonly author

author: IEmbedAuthor | null

The author data for this embed. The name field may be up to 256 characters.

Readonly color

color: number | null

The numerically encoded RGB color code for this embed.

Readonly description

description: string | null

The description text for the embed. Up to 2048 characters.

Readonly fields

An array of fields to be rendered on this embed.

Field names may be up to 256 characters. Field values may be up to 1024 characters, and support markdown.

Readonly footer

footer: IEmbedFooter | null

The footer for this embed. The text may be up to 2048 characters.

Readonly image

image: IEmbedImage | null

The image data for this embed.

Readonly provider

provider: IEmbedProvider | null

The provider data for this embed.

Readonly thumbnail

thumbnail: IEmbedThumbnail | null

The thumbnail data for this embed.

Readonly timestamp

timestamp: string | null

The ISO-8601 UTC timestamp for this embed.

Readonly title

title: string | null

The title of the embed.

Readonly type

type: string | null

The type of the embed.

Readonly url

url: string | null

The url of the embed. It renders as a link on the name, if provided.

Readonly video

video: IEmbedVideo | null

The video data for this embed.

Methods

addField

  • addField(field: IEmbedField): Embed
  • Adds a field to the embed.

    Fields appear under the description. Inline fields may be rendered side-by-side depending on the screen width.

    Parameters

    Returns Embed

setAuthor

  • setAuthor(author: IEmbedAuthor | null): Embed
  • Sets the author options for this embed.

    You may set an author name, url and icon image url.

    Parameters

    Returns Embed

setColor

  • setColor(color: number | null): Embed
  • Sets the color for this embed. An integer representation of a hexadecimal color code.

    The default color for roles (no color) is 0.

    Note: You can set this to a hex color code using an integer represented in hex format.

    Example: 0xFF0000 (or 16711680) is red.

    Parameters

    • color: number | null

      The integer representation of a color.

    Returns Embed

setDescription

  • setDescription(description: string | null): Embed
  • Sets the description for this embed.

    May contain markdown-formatted text, including links.

    Parameters

    • description: string | null

      The description for this embed. Up to 2048 characters.

    Returns Embed

setFields

setFooter

  • setFooter(footer: IEmbedFooter | null): Embed
  • Sets the footer for this embed. Rendered at the bottom of an embed.

    Parameters

    • footer: IEmbedFooter | null

      The footer for this embed. The text property may be up to 2048 characters.

    Returns Embed

setImage

  • setImage(image: IEmbedImage | null): Embed
  • Sets an image for this embed. If set, the image is typically rendered below the description and fields.

    You must only set the url property of the options sent to this function.

    Parameters

    Returns Embed

setProvider

  • setProvider(provider: IEmbedProvider | null): Embed
  • Sets a provider for this embed. Contains a name and url.

    Parameters

    Returns Embed

setThumbnail

  • setThumbnail(thumbnail: IEmbedThumbnail | null): Embed
  • Sets a thumbnail for this embed. If set, the thumbnail is typically rendered to the right of the description and fields.

    You must only set the url property of the options sent to this function.

    Parameters

    Returns Embed

setTimestamp

  • setTimestamp(timestamp: string | null): Embed
  • A localized timestamp to render at the bottom of the embed.

    Should be set to a UTC time string in ISO 8601 format (YYYY-MM-DDTHH:mm:ss)

    For example, new Date().toISOString() returns the current date and time in this format.

    Parameters

    • timestamp: string | null

      The ISO-8601 formatted timestamp string to set the embed timestamp to.

    Returns Embed

setTitle

  • setTitle(title: string | null): Embed
  • Sets the title of this embed.

    Parameters

    • title: string | null

      A new title for the embed. Must be no more than 256 characters.

    Returns Embed

setType

  • setType(type: string | null): Embed
  • Sets the type of this embed. Always rich for webhook embeds.

    Parameters

    • type: string | null

      The type of this embed.

    Returns Embed

setUrl

  • setUrl(url: string | null): Embed
  • Adds a link to the specified URL to the title of this embed.

    Note: Requires a title to be set.

    Parameters

    • url: string | null

      The url of this embed.

    Returns Embed

setVideo

  • setVideo(video: IEmbedVideo | null): Embed
  • Sets an video for this embed. If set, the video is typically rendered below the description and fields.

    You must only set the url property of the options sent to this function.

    Parameters

    Returns Embed

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc