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 titleSetDescription(description)
: Sets the embed descriptionSetUrl(url)
: Sets the embed URLSetTimestamp(timestamp)
: Sets the embed timestampSetColor(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 texticon_url
(optional): URL for footer iconproxy_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 URLproxy_url
(optional): Proxied image URLheight
(optional): Image heightwidth
(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 nameurl
(optional): Author URLicon_url
(optional): Author icon URLproxy_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 namevalue
: Field valueinline
(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
- Set Webhook URL First: Always set the webhook URL before attempting to send embeds
- Color Values: Use decimal color values (e.g.,
0xFF0000
for red) - Field Limits: Discord has limits on embed fields (max 25 fields)
- Content Length: Keep content within Discord's limits (max 2000 characters for regular messages)
- Image URLs: Use direct image URLs that end in image extensions