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.luaTraditional 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