Basic Application
This guide details the steps taken to create your first discord application!
-
Create a new
Application.luau
file -
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) -
Connect to the βReadyβ discord event:
DiscordClient.eventManager.onReady:connect(function()print(`{DiscordClient.discordUser.username} is online! π`)end) -
Run the Application
Terminal window lune run application.luau -
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)