Time to Code

Quickstart

Get up and start coding your first bot with silicord.

Requirements

These are installed automatically when you install silicord via LuaRocks.

Lua 5.1+
luasocket auto
luasec auto
copas auto
dkjson auto

Installation & Setup

01

Install via LuaRocks

Run this in your terminal first to get silicord installed.

bash
luarocks install silicord
02

Create your bot file

Make a new file called bot.lua or whatever you like and paste this. This is a simple bot and you can expand it later.

lua
local silicord = require("silicord")

local client = silicord.Connect({
    token  = "your bot token here",
    prefix = "!"
})

client:CreateCommand("ping", function(message, args)
    message:Reply("Pong")
end)

silicord.Run()
03

Get your bot token

Head to the Discord Developer Portal, create an application, add a Bot, and copy the token. Paste it into your bot.lua.

Never share your bot token. Store it in an environment variable or a config file that's excluded from version control.
04

Run it

Start your bot with a single command.

bash
lua <filename>.lua

Your bot is now online. Type !ping in any channel it has access to and it will reply "Pong"!

silicord.Connect( config )

The entry point for every silicord bot. Pass a config table with these fields:

FieldTypeRequiredDescription
tokenstring✅ yesYour Discord bot token
prefixstringnoCommand prefix (default: "!")
app_idstringnoApplication ID — only needed for slash commands
lua
local client = silicord.Connect({
    token  = "your token",
    prefix = "!",
    app_id = "your application id"  -- only needed for slash commands and presence updates
})

Full example

Here's a more complete bot showing prefix commands, slash commands, embeds, buttons, middleware, and events all together.

lua
local silicord = require("silicord")

local client = silicord.Connect({
    token  = "your token here",
    prefix = "!",
    app_id = "your app id here"
})

-- Cooldown middleware
local cooldowns = {}
client:AddMiddleware(function(ctx, cmd, args)
    local key = ctx.author.id .. ":" .. cmd
    if os.time() - (cooldowns[key] or 0) < 3 then
        ctx:Reply("Wait 3 seconds between commands.")
        return false
    end
    cooldowns[key] = os.time()
end)

-- !ping
client:CreateCommand("ping", function(message, args)
    message:Reply("Pong!")
end)

-- !vote (buttons)
client:CreateCommand("vote", function(message, args)
    local row = silicord.ActionRow(
        silicord.Button({ label = "Yes", style = "success", custom_id = "vote_yes" }),
        silicord.Button({ label = "No",  style = "danger",  custom_id = "vote_no"  })
    )
    message:Reply("Cast your vote!", nil, { row })
end)

client:CreateComponent("vote_yes", function(interaction)
    interaction:Update("You voted Yes! ✅")
end)

-- /ping (slash)
client:CreateSlashCommand("ping", {
    description = "Replies with pong"
}, function(interaction, args)
    interaction:Reply("Pong!")
end)

silicord.Run()

Next steps

📦

Embeds

If you want your bot to be more professional and visually appealing.

🎛️

Buttons & Select Menus

Allow users to interact with your bot.

🏰

Guild & Member management

Recommended if you're creating a moderation bot.