Skip to main content

Discord Webhook

The Discord webhook hook provides functionality to send rich embeds and messages to Discord channels through webhooks.

Basic Usage

local Discord = Aurora.Discord

-- Set your webhook URL
Discord:SetWebhookUrl("your-webhook-url")

-- Create a basic embed
local embed = Discord.DiscordEmbed.new()
:SetTitle("Hello World")
:SetDescription("This is a test embed")
:SetColor(0xFF0000) -- Red color

-- Send the embed
Discord:SendEmbed(embed)

Available Classes

DiscordEmbed

The main class for creating Discord embeds. Supports method chaining for easy configuration.

local embed = Discord.DiscordEmbed.new()

Methods

  • SetTitle(title): Sets the embed title
  • SetDescription(description): Sets the embed description
  • SetUrl(url): Sets the embed URL
  • SetTimestamp(timestamp): Sets the embed timestamp
  • SetColor(color): Sets the embed color (in decimal format)
  • SetFooter(footer): Sets the embed footer (requires EmbedFooter object)
  • SetImage(image): Sets the embed image (requires EmbedImage object)
  • SetThumbnail(thumbnail): Sets the embed thumbnail (requires EmbedImage object)
  • SetAuthor(author): Sets the embed author (requires EmbedAuthor object)
  • AddField(field): Adds a field to the embed (requires EmbedField object)

EmbedFooter

Creates a footer for the embed.

local footer = Discord.EmbedFooter.new(text, icon_url, proxy_icon_url)

Parameters

  • text: Footer text
  • icon_url (optional): URL for footer icon
  • proxy_icon_url (optional): Proxied URL for footer icon

EmbedImage

Creates an image or thumbnail for the embed.

local image = Discord.EmbedImage.new(url, proxy_url, height, width)

Parameters

  • url: Image URL
  • proxy_url (optional): Proxied image URL
  • height (optional): Image height
  • width (optional): Image width

EmbedAuthor

Creates an author section for the embed.

local author = Discord.EmbedAuthor.new(name, url, icon_url, proxy_icon_url)

Parameters

  • name: Author name
  • url (optional): Author URL
  • icon_url (optional): Author icon URL
  • proxy_icon_url (optional): Proxied author icon URL

EmbedField

Creates a field for the embed.

local field = Discord.EmbedField.new(name, value, inline)

Parameters

  • name: Field name
  • value: Field value
  • inline (optional): Whether the field should be inline (default: false)

Complete Example

Here's a comprehensive example showing all features:

local Discord = Aurora.Discord

-- Set webhook URL
Discord:SetWebhookUrl("your-webhook-url")

-- Create a full embed
local embed = Discord.DiscordEmbed.new()
:SetTitle("Hello World")
:SetDescription("This is a complete embed example")
:SetUrl("https://aurora-wow.wtf")
:SetColor(0xFF0000)
:SetFooter(
Discord.EmbedFooter.new(
"Footer Text",
"https://example.com/footer-icon.png"
)
)
:SetImage(
Discord.EmbedImage.new(
"https://example.com/image.png"
)
)
:SetThumbnail(
Discord.EmbedImage.new(
"https://example.com/thumbnail.png"
)
)
:SetAuthor(
Discord.EmbedAuthor.new(
"Author Name",
"https://example.com",
"https://example.com/author-icon.png"
)
)
:AddField(
Discord.EmbedField.new("Field 1", "Value 1", true)
)
:AddField(
Discord.EmbedField.new("Field 2", "Value 2", true)
)

-- Send the embed
Discord:SendEmbed(embed)

Error Handling

The Discord webhook implementation includes basic error handling:

  • If webhook URL is not set, it will throw an error
  • Failed JSON encoding will be logged
  • Failed HTTP requests will be logged with status code and response
  • Successful webhook sends will be confirmed in the log

Best Practices

  1. Set Webhook URL First: Always set the webhook URL before attempting to send embeds
  2. Color Values: Use decimal color values (e.g., 0xFF0000 for red)
  3. Field Limits: Discord has limits on embed fields (max 25 fields)
  4. Content Length: Keep content within Discord's limits (max 2000 characters for regular messages)
  5. Image URLs: Use direct image URLs that end in image extensions