Skip to content

Responding with Embeds

Embeds are a way to display rich content in Discord messages. They allow you to include images, formatted text, fields, and other interactive elements within a message.

  1. Create a discord-luau bot implementation:

    local DiscordLuau = require("DiscordLuau")
    local DiscordSettings = DiscordLuau.SettingsBuilder.new("<DISCORD_TOKEN>")
    local DiscordClient = DiscordLuau.DiscordClient.new(DiscordSettings)
    DiscordClient.eventManager.onMessage:connect(function(message)
    if message.content == "!embed" then
    ...
    end
    end)
    DiscordClient.eventManager.onReady:connect(function()
    print(`πŸŽ‰πŸŽ‰ {DiscordClient.discordUser.username} is online! πŸŽ‰πŸŽ‰`)
    end)
    DiscordClient:connectAsync()
  2. Allow the bot to check messages:

    • Go to the Discord Developer Portal
    • Choose your bot application in the Applications tab
    • Go to the Bot tab and enable MESSAGE CONTENT INTENT
  3. Create a Discord embed that we can respond with:

    local responseEmbed = DiscordLuau.EmbedBuilder.new()
    :setTitle("Example Embed")
    :setDescription("This is an example of an embed created using DiscordLuau!")
    :setColor(0xFF0000)
    :addField("Field 1", "Value 1", true)
    :addField("Field 2", "Value 2", true)
    :setFooter("This is a footer")
  4. Reply to the message with the newly created embed:

    local responseMessage = DiscordLuau.MessageBuilder.new()
    local responseEmbed = DiscordLuau.EmbedBuilder.new()
    :setTitle("Example Embed")
    :setDescription("This is an example of an embed created using DiscordLuau!")
    :setColor(0xFF0000)
    :addField("Field 1", "Value 1", true)
    :addField("Field 2", "Value 2", true)
    :setFooter("This is a footer")
    message:replyAsync(responseMessage:addEmbed(responseEmbed))
See The Entire Code
local DiscordLuau = require("DiscordLuau")
local DiscordSettings = DiscordLuau.SettingsBuilder.new("<DISCORD_TOKEN>")
local DiscordClient = DiscordLuau.DiscordClient.new(DiscordSettings)
DiscordClient.eventManager.onMessage:connect(function(message)
if message.Content == "!embed" then
local responseMessage = DiscordLuau.MessageBuilder.new()
local responseEmbed = DiscordLuau.EmbedBuilder.new()
:setTitle("Example Embed")
:setDescription("This is an example of an embed created using DiscordLuau!")
:setColor(0xFF0000)
:addField("Field 1", "Value 1", true)
:addField("Field 2", "Value 2", true)
:setFooter("This is a footer")
message:replyAsync(responseMessage:addEmbed(responseEmbed))
end
end)
DiscordClient.eventManager.onReady:connect(function()
print(`πŸŽ‰πŸŽ‰ {DiscordClient.discordUser.username} is online! πŸŽ‰πŸŽ‰`)
end)
DiscordClient:connectAsync()

That’s all! For more details, refer to the relevant docs;