Skip to content

Installation

discord-luau is distributed via pesde, the Luau package manager. The quickest way to get started is with the create_app scaffolder, which sets up a complete project for you.

Before running the scaffolder, make sure the following tools are installed:

ToolInstall
pesdeLuau package manager - used to run create_app and install dependencies
rokitToolchain manager - used during project setup to install your chosen runtime
luneLuau runtime - used by pesde to execute the create_app script
zuneLuau runtime - invoked by create_app to run the interactive wizard

Run the following command to launch the interactive project wizard:

Terminal window
pesde x discord_luau/create_app create

To scaffold into a specific directory, pass it as an argument:

Terminal window
pesde x discord_luau/create_app create ./my-bot

The wizard will check that your prerequisites are installed, then walk you through the following steps:

PromptOptionsDefault
Project Namescope/project_name (lowercase, underscores)-
IDEvscode, nvim, zedvscode
Runtimezune, lunezune
Use GitYes, NoYes
LicenseAny SPDX identifierMIT
Discord TokenYour bot token-

Once confirmed, the wizard will automatically run:

  1. rokit install - installs your chosen runtime via rokit
  2. {runtime} setup - sets up the runtime environment
  3. git init - initialises a git repository (if selected)
  4. pesde install - installs discord-luau and its dependencies

After scaffolding, your project will look like this:

my_project/
├── src/
│ └── init.luau # Your bot's entry point
├── patches/ # Dependency patches applied by pesde
├── .env.luau # Your bot token - do not commit this
├── .gitignore # Excludes .env.luau and luau_packages/
├── .luaurc # Luau type aliases
├── pesde.toml # Package manifest
├── rokit.toml # Toolchain manifest
└── selene.toml # Linter config

src/init.luau contains a working bot that logs messages and prints when it comes online:

local discord = require("@self/../luau_packages/discord")
local classes = require("@self/../luau_packages/classes")
local builders = require("@self/../luau_packages/builders")
local env = require("@self/../.env")
local DISCORD_BOT_INTENTS = builders.intents
.new({
"Guilds",
"GuildMessages",
"MessageContent",
})
:build()
local bot = discord.bot.new({
token = env.DISCORD_BOT_TOKEN,
intents = DISCORD_BOT_INTENTS,
reconnect = true,
})
bot.onMessage:listen(function(message: classes.Message)
print(`Message sent by '{message.author.globalName}' said: '{message.content}'`)
end)
bot.onAllShardsReady:listenOnce(function()
print(`Bot '{bot.user.username}' is online!`)
end)
bot:connectAsync():await()

Once setup is complete, run your bot with your chosen runtime. For example, with zune:

Terminal window
zune run src/init.luau

Or with lune:

Terminal window
lune run src/init.luau