> ## Documentation Index
> Fetch the complete documentation index at: https://www.chapterjs.org/llms.txt
> Use this file to discover all available pages before exploring further.

# embed()

> The function that declares an embed used in several messages, and what it returns

`embed()` declares an embed, from any file of `src/`. It takes the embed itself, or a function that returns one.

```ts src/components/welcome.ts theme={"theme":{"light":"github-light","dark":"vesper"}}
import { embed, type GuildMember } from 'chapterjs';

export default embed((member: GuildMember) => ({
  title: `Welcome ${member.displayName}!`,
  color: 0x57f287,
}));
```

> [!NOTE]
>
> How to write and use an embed file is in the [guide](https://www.chapterjs.org/components/embeds.md). What an embed can hold is [Embed](https://www.chapterjs.org/reference/message-options.md#embed).

## embed()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
embed(definition: Embed): EmbedDeclaration<[]>
embed<Args extends readonly unknown[]>(definition: (...args: Args) => Embed): EmbedDeclaration<Args>
```

Declares an embed. Export the result from any file of `src/`. Give it the embed itself when it always looks the same, or a function of what it shows.

A static embed is checked against the limits of Discord when the file loads; the embed a function returns is checked when the message is sent.

### EmbedDeclaration

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
type EmbedDeclaration<Args extends readonly unknown[] = []> = { readonly config: unknown } & ((...args: Args) => Embed)
```

What `embed()` returns: a declaration the framework finds in the exports of a file. Import it where you send a message: `embeds: [welcome({ member })]`, or `embeds: [rules]` for an embed that always looks the same.

**config** `unknown`

What the file gave to `embed()`, not checked yet.

The `embeds` of a message take an `Embed` or an `EmbedDeclaration<[]>`: an embed that needs arguments must be called.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.