MeshCord
Host a node Downloads Features Node Setup Bot Dev

Bot Development

MeshCord bots are written in Lua — not Python, not JavaScript. Every bot is a real node user account flagged isBot, registered by a node admin, and authenticated with its own bot token over the same WebSocket API the desktop client uses. Setting up a node? See Node Setup.

⚠ MeshCord Bot Lua Development is in very early stages. Please allow us some time to update and finish the documentation, which may not contain the full, proper, or fully finished documentation for developing your own MeshCord bot.

Any MeshCord bot must use the MeshCord Bot Core Lua development package for all bots to work and function correctly. Bots that do not use the Core package are not supported and will not authenticate.

The MeshCord Bot Contract

Every bot on every node is bound by these rules. They are mandatory and cannot be changed — the SDK simply has no API for forbidden behavior, and the node rejects it anyway even from hand-rolled clients.

Bots may not

  • Spam users, servers, or nodes. Every bot account is held to a fixed send budget — a hard 0.5-second gap and 30 messages per minute — enforced by the node itself.
  • Be added by anyone but a Main Admin. Only node admin accounts can register a bot or add it to a server.
  • Request user information such as IP addresses or personally identifiable data. No bot API exposes it.
  • Gather, scrape, or impersonate other bots, servers, or nodes.
  • Read, scan, check, or send direct messages. Bots have no DM surface at all — the node refuses every DM request from a bot token.
  • Be used for illicit purposes — scamming, doxing, or any otherwise harmful purpose or reason.

Bots may

  • Read public server statistics — total members, channel counts, server and channel names.
  • Post announcements — game updates, going-live notifications (Twitch, YouTube, Kick, TikTok, …).
  • Moderate — timeout, kick, and ban members who break server rules, with every action written to the audit log.
  • Auto-generate channels at an admin's request — coordinated through a private, admin-only text channel on the server, the bot can build or restructure text and voice channels.

1. Register the bot

A Main Admin registers the bot on the node — via the desktop app's Bot Discovery panel, the admin dashboard, or the API. Registration is admin-only; regular users and other bots get 403.

POST /api/v1/bots { "name": "mybot", "description": "Does a thing" } → { "bot": {…}, "token": "<bot-token>" }

The returned token is the bot's credential — store it like a password. The admin then adds the bot to a server (POST /api/v1/bots/:id/servers/:serverId); the bot sees events only for servers it belongs to.

2. Get MeshCord Bot Core

luarocks install meshcord-bot-core
local meshcord = require("meshcord.core") local bot = meshcord.Bot { domain = "https://node.example.com", token = os.getenv("MESHCORD_BOT_TOKEN"), } bot:on("ready", function() bot:subscribeAll() -- join every server the bot belongs to end) bot:on("message", function(msg) if msg.content == "!ping" then bot:reply(msg, "pong") end end) bot:run()

3. Events

EventFires when
readyThe WebSocket session is authenticated — subscribe to your servers here (bot:subscribeAll()).
messageA message is posted in a channel of a subscribed server.
edit / deleteA message is edited or deleted.
pin / reactionPins or reactions change.
statusA member's presence changes.
voice_join / voice_leftVoice channel joins and leaves.
error / disconnectServer errors and socket drops (Core reconnects automatically).

There is no dm event. Bots cannot read, scan, check, or send direct messages — ever.

4. API reference

Messaging

MethodWhat it does
bot:send(channelId, text)Post a message to a channel.
bot:reply(msg, text)Reply in the channel a message came from.

Statistics

MethodReturns
bot:serverStats(serverId){ name, members, channels } — counts and the server name.
bot:members(serverId)Sanitized member list — { id, username, avatarColor, status, role, isBot }. Nothing else exists.
bot:channels(serverId)Channel list — { id, name, type, topic, category }.

Moderation

MethodWhat it does
bot:timeout(serverId, userId, seconds)Silence a member (server caps at 28 days). Audited.
bot:kick(serverId, userId)Remove a member from the server. Audited.
bot:ban(serverId, userId, reason)Permanently ban a member. Audited.

Server building

MethodWhat it does
bot:createChannel(serverId, name, type, opts)Create a text or voice channel; opts takes topic, category, limit.
bot:patchChannel(serverId, channelId, patch)Rename, retopic, or move a channel — { name?, topic?, category?, limit? }.
bot:deleteChannel(serverId, channelId)Delete a channel.

The intended pattern: create a private text channel visible only to admins, have the bot watch it for build/restructure commands, and let it translate those into channel operations.

Connection

MethodWhat it does
bot:subscribe(serverId)Stream events for one server.
bot:subscribeAll()Subscribe to every server the bot belongs to. Returns the count.
bot:run()Connect and process events. Blocks; auto-reconnects with backoff.
bot:stop()Disconnect and return from run().

5. Housekeeping rules

  • Bot names follow the username rules: 2–32 chars, letters, numbers, _ . -.
  • Bots must use the MeshCord Bot Core package — direct token juggling is unsupported.
  • Bots must obey the Terms and the Bot Contract — the node enforces both.
MeshCord — self-hosted communities. Terms · Privacy