Skip to content

Basic Application

This guide details the steps taken to create your first discord application!

  1. Create a new Application.luau file

  2. Using the DiscordLuau submodule, require the submodule and set up a basic client object

    local DiscordLuau = require("DiscordLuau")
    local DiscordSettings = DiscordLuau.SettingsBuilder.new("<DISCORD_TOKEN>")
    local DiscordClient = DiscordLuau.DiscordClient.new(DiscordSettings)
    DiscordClient:connectAsync():after(function()
    print("We've connected to the Discord Websocket! πŸš€")
    end)
  3. Connect to the β€˜Ready’ discord event:

    DiscordClient.eventManager.onReady:connect(function()
    print(`{DiscordClient.discordUser.username} is online! πŸŽ‰`)
    end)
  4. Run the Application

    Terminal window
    lune run application.luau
  5. if all goes well, your application should connect to the Discord API and print the above messages!

Complete Code
local DiscordLuau = require("DiscordLuau")
local DiscordSettings = DiscordLuau.SettingsBuilder.new("<DISCORD_TOKEN>")
local DiscordClient = DiscordLuau.DiscordClient.new(DiscordSettings)
DiscordClient.eventManager.onReady:connect(function()
print("We've connected to the Discord Websocket! πŸš€")
end)
DiscordClient:connectAsync():after(function()
print("We've connected to the Discord Websocket! πŸš€")
end)