Skip to content

Repository files navigation

Logo

Discord.lua is a modern, easy to use, feature-rich, and async ready API wrapper for Discord written in Lua for the Luvit runtime.

Lit Lua

Lint Tests


Key Features

  • Asynchronous
  • Proper rate limit handling.
  • Optimised for both speed and memory usage.
  • Full application API support.

Installation

luvit

lit install filispeen/discord.lua

On the first require("discord.lua"), Linux x64 and Windows x64 installations download the native voice bundle automatically. See the installation guide for platform requirements.

Quick example

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")

Full Examples

See more examples in examples/ directory:

Feature Comparison

For context: ✅ Built in · ⚠️ Manual or limited support · ❌ No built-in high-level API

Feature discord.lua Discordia
Gateway events ✅ ✅
REST API and Discord models ✅ ✅
Cache-backed models ✅ ✅
Rate-limit handling ✅ ✅
Prefix command framework ✅ ⚠️ Manual
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 ✅ ✅

Reference

About

A lightweight and efficient Discord API wrapper for Lua in the Luvit runtime.

Topics

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages