Overview
The embed() function creates a rich embed builder for Discord messages. Embeds allow you to display formatted content with titles, descriptions, images, fields, and more.
Signature
function embed(initial?: Embed): EmbedBuilder
Parameters
Optional initial embed object to populate the builder
Return Value
Returns an EmbedBuilder instance with chainable methods.
EmbedBuilder Methods
setTitle()
Set the embed title.
setTitle(title: string): this
setDescription()
Set the embed description (main text content).
setDescription(description: string): this
setUrl()
Set a URL that the title links to.
setUrl(url: string): this
setColor()
Set the color bar on the left side of the embed.
setColor(color: number): this
Parameter:
color - Decimal color value (e.g., 0xFF5733 for orange)
setTimestamp()
Set the timestamp shown in the footer.
setTimestamp(timestamp: string): this
Parameter:
timestamp - ISO8601 timestamp string
Set footer text and optional icon.
setFooter(text: string, iconUrl?: string): this
setImage()
Set a large image displayed at the bottom of the embed.
setImage(url: string): this
setThumbnail()
Set a small thumbnail image in the top-right corner.
setThumbnail(url: string): this
setAuthor()
Set author information displayed at the top.
setAuthor(name?: string, options?: { url?: string; iconUrl?: string }): this
addField()
Add a single field to the embed.
addField(name: string, value: string, inline?: boolean): this
Parameters:
name - Field title
value - Field content
inline - Whether to display inline with other fields (default: false)
addFields()
Add multiple fields at once.
addFields(fields: EmbedField[]): this
setFields()
Replace all fields with a new array.
setFields(fields: EmbedField[]): this
toJSON()
Convert the builder to a plain object.
Example Usage
Basic Embed
const infoEmbed = embed()
.setTitle('Welcome!')
.setDescription('Thanks for joining our server')
.setColor(0x00FF00)
.toJSON()
await ctx.reply({ embeds: [infoEmbed] })
Rich Embed with Fields
const statsEmbed = embed()
.setTitle('Server Stats')
.setDescription('Current server statistics')
.setColor(0x3498DB)
.setThumbnail('https://example.com/icon.png')
.addField('Members', '1,234', true)
.addField('Online', '567', true)
.addField('Channels', '42', true)
.setFooter('Updated at', 'https://example.com/footer.png')
.setTimestamp(new Date().toISOString())
.toJSON()
await ctx.reply({ embeds: [statsEmbed] })
Multiple Fields
const helpEmbed = embed()
.setTitle('Bot Commands')
.setColor(0x9B59B6)
.addFields([
{ name: '/help', value: 'Show this message', inline: false },
{ name: '/ping', value: 'Check bot latency', inline: false },
{ name: '/stats', value: 'View server stats', inline: false }
])
.toJSON()
await ctx.reply({ embeds: [helpEmbed] })
Embed with Image and Author
const newsEmbed = embed()
.setAuthor('Bot News', {
url: 'https://example.com',
iconUrl: 'https://example.com/avatar.png'
})
.setTitle('New Feature Released!')
.setDescription('Check out our latest update')
.setImage('https://example.com/banner.png')
.setColor(0xE74C3C)
.toJSON()
await ctx.reply({ embeds: [newsEmbed] })
Cloning an Embed
const original = embed()
.setTitle('Original')
.setColor(0xFF0000)
.toJSON()
// Create a new embed based on the original
const modified = embed(original)
.setTitle('Modified Copy')
.setColor(0x00FF00)
.toJSON()
Embed Limits
- Title: 256 characters
- Description: 4096 characters
- Fields: Maximum 25 fields
- Field name: 256 characters
- Field value: 1024 characters
- Footer text: 2048 characters
- Author name: 256 characters
- Total: 6000 characters across all fields
Color Values
Colors are specified as decimal integers. Common colors:
const Colors = {
Red: 0xFF0000,
Green: 0x00FF00,
Blue: 0x0000FF,
Yellow: 0xFFFF00,
Purple: 0x9B59B6,
Orange: 0xFF5733,
Discord: 0x5865F2
}
embed().setColor(Colors.Discord)
Notes
- Methods are chainable for fluent API usage
- Always call
.toJSON() before passing to reply() or message options
- Multiple embeds can be sent in one message (up to 10)
- Images must be publicly accessible URLs
- Inline fields display side-by-side (up to 3 per row)