Discord.lua is a modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Lua for the Luvit runtime.
- Asynchronous
- Proper rate limit handling.
- Optimised for both speed and memory usage.
- Full application API support.
lit install filispeen/discord.luaOn the first require("discord.lua"), Linux x64 and Windows x64 installations download the native voice bundle automatically. See the installation guide for platform requirements.
Traditional bot
local discord = require("discord.lua")
local bot = discord.Bot()
bot:on("ready", function()
print("Bot is ready!")
end)
bot:command("ping", function(ctx)
ctx:reply("Pong!")
end)
bot:run("YOUR_TOKEN")Interactions bot
local discord = require("discord.lua")
local bot = discord.Bot()
bot:on("ready", function()
print("Bot is ready!")
end)
bot:slash_command("ping", {
description = "Repeats back pong",
callback = function(ctx)
ctx:respond("Pong!")
end,
})
bot:slash_command("roll", {
description = "Rolls a die",
options = {
{
name = "sides",
type = discord.enums.OPTION_TYPE.INTEGER,
description = "Number of sides, defaults to 6",
required = false,
},
},
callback = function(ctx)
local sides = ctx:get_arg("sides", 6)
ctx:respond("Rolled: " .. math.random(1, sides))
end,
})
bot:run("YOUR_TOKEN")See more examples in examples/ directory:
basic_bot.lua- Basic bot with some functionson_message.lua- Bot with on_message eventinteraction_bot.lua- Bot with interactionsview_button.lua- Button with View timeouthybrid_command.lua- Hybrid command (prefix + slash)voice_play.lua- Voice client usagesharded_bot.lua- Sharded bot with auto-sharding
For context: ✅ Built in ·
| Feature | discord.lua | Discordia |
|---|---|---|
| Gateway events | ✅ | ✅ |
| REST API and Discord models | ✅ | ✅ |
| Cache-backed models | ✅ | ✅ |
| Rate-limit handling | ✅ | ✅ |
| Prefix command framework | ✅ | |
| Slash commands | ✅ | ❌ |
| User and message context commands | ✅ | ❌ |
| Command groups and subcommands | ✅ | ❌ |
| Autocomplete | ✅ | ❌ |
| Application command sync | ✅ | ❌ |
| Hybrid prefix + slash commands | ✅ | ❌ |
| Interaction responses and follow-ups | ✅ | ❌ |
| Buttons and select menus | ✅ | ❌ |
| Views and timeouts | ✅ | ❌ |
| Modals | ✅ | ❌ |
| Discord Components V2 | ✅ | ❌ |
| Scheduled events | ✅ | ❌ |
| AutoMod | ✅ | ❌ |
| Polls | ✅ | ❌ |
| Monetization | ✅ | ❌ |
| Application emojis | ✅ | ❌ |
| Checks, cooldowns and error handlers | ✅ | ❌ |
| Extensions, cogs and task helpers | ✅ | ❌ |
| Voice | ✅ | ✅ |
| Automatic gateway sharding | ✅ | ✅ |