Introduction
GuideOn this page
DiscordLua documentation
Build Discord bots with Lua.
DiscordLua is a standalone Lua 5.4 runtime, Discord module, CLI, and Windows installer. One download is enough to write, run, and update a bot.
Runtime 1.0.0Module 1.2.4Discord API v10
What is DiscordLua?
A native runtime that embeds official Lua 5.4 and talks to Discord over REST and Gateway. Bot scripts use require("discord"). HTTP, TLS, WebSocket, JSON, timers, and voice I/O are implemented in C++ — not a third-party Lua event loop.
What you can build
- Prefix and slash-command bots
- Moderation, logging, and role tools using guild, channel, and overwrite helpers
- Component UIs: buttons, select menus, modals
- Voice connections that play Opus packets
- Sharded processes with
ShardingManager
How do I install it?
Download DiscordLua-Setup.exe or run dislua update if a previous version is already on PATH. After setup, dislua and discordlua are available in a new terminal.
How do I create my first bot?
Create an application in the Discord developer portal, copy the bot token into DISCORD_TOKEN, then run dislua init and dislua run bot.lua. The walkthrough is on Your First Bot.
local discord = require("discord")
local client = discord.Client({
intents = { "Guilds", "GuildMessages", "MessageContent" }
})
client:on("ready", function()
print("Bot is ready!")
end)
client:login(os.getenv("DISCORD_TOKEN"))How do I access the API?
Open the API reference. Start with Client, then managers such as GuildManager and builders such as EmbedBuilder. Search with Ctrl K.
What you do not install
Python, Node.js, Luvit, LuaJIT, and LuaSocket are not required. DiscordLua ships its own runtime.