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 Rockspec

Rockspec


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

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:

Reference

About

Discord API wrapper written in Lua for the Luvit runtime

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages