DiscordLua
discorddiscord
v1.2.4
Install

Your First Bot

Guide

A complete bot script. Save as bot.lua, set DISCORD_TOKEN, then dislua run bot.lua.

lua
local discord = require("discord")
local Client, Events, GatewayIntentBits = discord.use("Client", "Events", "GatewayIntentBits")

local client = Client({
    intents = { GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent },
})

client:on(Events.ClientReady, function()
    print("Logged in as", client.user and client.user.tag)
end)

client:on(Events.MessageCreate, function(message)
    if message.author and message.author.bot then return end
    if message.content == "!ping" then
        message:reply("Pong!")
    end
end)

client:login(os.getenv("DISCORD_TOKEN"))
Search Ctrl K Navigate Open Esc