Developers
Build a Voltex bot
Start with a ready-made welcome, auto-reply or auto-role bot. Use the developer API for custom modules, slash commands and integrations.
What you can build
A Voltex bot is an account with a BOT tag. Ready-made bots run inside Voltex and are configured in Server Settings → Bots. For a custom bot, your code connects through the developer API. Both use normal server permissions. Webhooks need no bot account: a script can post into a channel with one HTTP request.
Moderation
Read every message in the channels it can see, delete spam or banned links, log actions to a mod channel and add commands like /warn.
messageCreateDELETE message/warn
Welcome & auto-role
Greet new members in a welcome channel and give them a starter role the moment they join; post when someone leaves.
memberJoinmemberLeavePUT role
Tickets & support
/ticket sends the request to a private staff channel and answers the member privately (ephemeral). Staff track tickets with reactions.
interactionCreateephemeralreactionAdd
Notifications & feeds
CI builds, new releases, uptime alerts, store orders, game-server events — post them with a webhook URL, no bot or library needed.
webhook?wait=true
Relays & bridges
Webhooks accept Discord-style bodies, so tools that already post to Discord work by swapping the URL. A bot can also forward messages between channels.
webhookmessageCreatePOST message
Slash-command utilities
Dice, polls with reactions, lookups against your own API, server stats — typed options, choices and private answers built in.
PUT /commandsreplydefer
Reaction roles
Post a message, react with the options, and give the matching role when a member reacts.
reactionAddPUT role
Logs & stats
Count messages, track joins/leaves, archive history page by page, or mirror edits and deletions to a log channel.
messageUpdatemessageDeleteGET messages
Not available through the developer bot API: joining voice channels (so no music playback), bot DMs, buttons/embeds/modals, general file uploads, channel creation or kicking/banning. Ready-made welcome bots can generate image cards; this does not add a general upload endpoint to the bot API. There is no reaction-removed event.
Ready-made bots: no coding needed
- 1Open Server Settings → Bots. You need Manage Server; installing or editing an auto-role bot also needs Manage Roles.
- 2Choose Welcome, Auto-reply or Auto-role and give the bot a name. You can install up to 10 ready-made bots in each server.
- 3Choose the channel, response or role. For a welcome card, upload a background and customize the text, font weight and colors.
- 4Use Preview to inspect a draft welcome card. Save, then use Test on an installed welcome bot to send a real sample to its configured channel.
- 5Enable the bot. It runs inside Voltex without a token, hosting or a separately running script. Turn it off to stop its automation while keeping the settings.
👋 Customize a welcome card
- The card is 960 × 360 pixels. Upload a PNG, JPEG or WebP background up to 3 MB; the background is stored by Voltex.
- Choose Vazirmatn Regular, Bold or Light. These are bundled Persian font weights, not arbitrary uploaded fonts. Choose a font size from 24 to 64, text/background/accent colors, a title up to 120 characters and a subtitle up to 160 characters.
- Show or hide the joining member's avatar. A separate message can accompany the card.
- Preview makes no persistent file and sends no message. Test posts in the real channel, using a sample member; it is not a simulation of a new membership.
| Variable | Value |
|---|---|
{user} | The joining or triggering member's mention |
{username} | The member's display name |
{server} | The server name |
{memberCount} | The current server member count |
Message: {user}, welcome to {server}! 👋
Card title: Welcome, {username}
Card subtitle: Member #{memberCount} · {server}💬 Auto-replies and 🏷️ auto-roles
- Auto-reply: choose an exact match, contains or starts-with trigger. Triggers are literal text, not regular expressions; maximum 100 characters. Replies can use the variables above and be up to 2,000 characters.
- Restrict an auto-reply to one channel or all channels visible to the bot. Set a cooldown from 5 to 3,600 seconds for each bot/channel. Bot and webhook messages are ignored to prevent loops.
- Auto-role: choose one role to give new members. The bot needs Manage Roles and its role must be above the target role; neither the owner nor an administrator bypasses the bot's role hierarchy.
If a bot stops working, check its latest run/error, the platform bot feature flag, its membership, channel permissions and role hierarchy. Disabling the platform's bot feature stops ready-made automation too. A welcome bot needs View Channel, Send Messages and permission to attach files in its destination channel.
Quick start
- 1In the Voltex app open Settings → My Bots → New bot. Give it a name. Copy the token right away — it is shown only once.
- 2On the bot's card open Invite link, tick View Channel and Send Messages, and open the link. Pick a server where you have Manage Server and click Authorize.
- 3Save the token in an environment variable:
export VOLTEX_BOT_TOKEN=...(never put it in code or git). - 4Copy one of the programs below and run it. Type
/pingin a channel the bot can see — it answers “Pong!”. Type!helloand it replies to you.
// npm i socket.io-client (Node 18+ — fetch is built in)
// VOLTEX_BOT_TOKEN=... node bot.js
const { io } = require('socket.io-client');
const API = 'https://backend.voltex.social';
const TOKEN = process.env.VOLTEX_BOT_TOKEN;
// Call the bot REST API: https://backend.voltex.social/api/bot/...
async function api(method, path, body) {
const res = await fetch(API + '/api/bot' + path, {
method,
headers: { Authorization: 'Bot ' + TOKEN, 'Content-Type': 'application/json' },
body: body === undefined ? undefined : JSON.stringify(body),
});
const text = await res.text();
const data = text ? JSON.parse(text) : null;
if (!res.ok) throw new Error(res.status + ' ' + (data?.message ?? text));
return data;
}
async function main() {
// 1. Register slash commands. PUT replaces the whole set — safe on every start.
await api('PUT', '/commands', {
commands: [
{ name: 'ping', description: 'Check that the bot is alive' },
{
name: 'say',
description: 'Make the bot say something',
options: [{ name: 'text', description: 'What to say', type: 'string', required: true }],
},
],
});
// 2. Connect to the realtime gateway (socket.io namespace /bots).
const socket = io(API + '/bots', { auth: { token: TOKEN }, transports: ['websocket'] });
socket.on('ready', ({ user, servers }) => {
console.log('Logged in as ' + user.name + ' — in ' + servers.length + ' server(s)');
});
// 3. Answer slash commands (within 3 seconds, or defer first).
socket.on('interactionCreate', async (i) => {
if (i.commandName === 'ping') {
await api('POST', '/interactions/' + i.id + '/reply', { content: 'Pong! 🏓' });
} else if (i.commandName === 'say') {
await api('POST', '/interactions/' + i.id + '/reply', { content: String(i.options.text) });
}
});
// 4. React to normal messages.
socket.on('messageCreate', async (msg) => {
if (msg.author?.isBot) return; // ignore bots — including yourself
if (msg.content === '!hello') {
await api('POST', '/channels/' + msg.channelId + '/messages', {
content: 'Hi ' + msg.author.name + '!',
replyToId: msg.id,
});
}
});
socket.on('connect_error', (err) => console.error('gateway error:', err.message));
}
main().catch((err) => { console.error(err); process.exit(1); });A bigger runnable example (/ping, /say, /secret with an ephemeral answer, a welcome message and retry on 429) lives in examples/voltex-bot in the repository.
Authentication
Every bot API call goes to https://backend.voltex.social/api/bot/… with the header Authorization: Bot <token>. The gateway takes the same token in the socket.io auth object. A bot token works only there — it is never accepted by the normal user API, and a user login is never accepted by the bot API.
- The token is shown once when the bot is created. Voltex keeps only a hash of it.
- Reset token (Settings → My Bots) issues a new one; the old token stops working immediately and the bot's gateway connections are dropped.
- A missing or wrong token returns
401(Bot token required/Invalid bot token). - Each developer can own up to 10 bots. Turn Public bot off so only you can add it to servers.
curl -H "Authorization: Bot $VOLTEX_BOT_TOKEN" \
https://backend.voltex.social/api/bot/users/@me
# → {"id":"<bot user id>","botId":"<bot id>","username":"mybot","name":"My Bot","isBot":true}The token is a password: anyone who has it controls your bot. Never commit it, paste it in chat or print it in logs. If it leaks, reset it.
Adding to a server & permissions
Share the bot's invite link. Whoever opens it picks a server where they have Manage Server, sees the requested permissions and clicks Authorize:
https://app.voltex.social/oauth2/authorize?client_id=<BOT_ID>&permissions=<BITMASK>permissions is a decimal bitmask: add up the values of the permissions you need. The ones bots use most:
| Permission | Bit | Value | What the bot can do |
|---|---|---|---|
MANAGE_ROLES | 10 | 1024 | Give/take roles below its own role |
VIEW_CHANNEL | 16 | 65536 | See a channel and get its events |
SEND_MESSAGES | 17 | 131072 | Post messages and public slash-command replies |
MANAGE_MESSAGES | 19 | 524288 | Delete other people's messages |
READ_MESSAGE_HISTORY | 22 | 4194304 | Read older messages |
MENTION_EVERYONE | 23 | 8388608 | Use @everyone |
ADD_REACTIONS | 25 | 33554432 | Add reactions |
- Basic chat bot:
VIEW_CHANNEL + SEND_MESSAGES + READ_MESSAGE_HISTORY + ADD_REACTIONS=37945344. - Moderation:
VIEW_CHANNEL + SEND_MESSAGES + READ_MESSAGE_HISTORY + MANAGE_MESSAGES=4915200. - Welcome + auto-role:
VIEW_CHANNEL + SEND_MESSAGES + MANAGE_ROLES=197632.
// Permission bits (block 0). Use BigInt — some bits are above 2^31.
const P = {
MANAGE_ROLES: 10n, VIEW_CHANNEL: 16n, SEND_MESSAGES: 17n, MANAGE_MESSAGES: 19n,
READ_MESSAGE_HISTORY: 22n, MENTION_EVERYONE: 23n, ADD_REACTIONS: 25n,
};
const mask = [P.VIEW_CHANNEL, P.SEND_MESSAGES, P.READ_MESSAGE_HISTORY, P.ADD_REACTIONS]
.reduce((m, bit) => m | (1n << bit), 0n);
const link = 'https://app.voltex.social/oauth2/authorize?client_id=' + BOT_ID + '&permissions=' + mask;
// mask = 37945344The managed role
- The bot gets its own role holding the granted permissions — never more than the person adding it has (the owner and administrators can grant anything).
- The role sits just above
@everyone. To let the bot give out a role, drag the bot's role above it in Server settings → Roles. - Nobody can give this role to someone else or delete it by hand. It disappears when the bot leaves (kick, ban or bot deleted).
- Channel permission overrides apply to the bot like to any member: a bot that can't see a channel gets no events from it and can't post there.
REST API
Base URL https://backend.voltex.social/api/bot · JSON bodies · header Authorization: Bot <token>. Every call runs as the bot's own account through the same code people use, so channel permissions, role hierarchy, timeouts, AutoMod, message limits and live updates all apply.
| Method | Path | What it does |
|---|---|---|
GET | /users/@me | The bot itself: { id, botId, username, name, isBot } |
GET | /servers | Servers the bot is in: [{ id, name, iconUrl }] |
GET | /servers/:serverId/channels | Channels the bot can see: { id, serverId, name, type, categoryId, position } |
GET | /servers/:serverId/members?limit=&after= | Members, up to 100 per page; after = the last member id you got |
GET | /servers/:serverId/roles | All roles of the server |
PUT · DELETE | /servers/:serverId/members/:userId/roles/:roleId | Give / take a role (needs MANAGE_ROLES and a higher role) |
GET | /channels/:channelId/messages?limit=&before= | Message history (limit ≤ 100, before = a message id) → { messages, hasMore } |
POST | /channels/:channelId/messages | Send { content, replyToId? } (1–2000 characters) |
PATCH | /channels/:channelId/messages/:messageId | Edit the bot's own message { content } |
DELETE | /channels/:channelId/messages/:messageId | Delete — its own, or anyone's with MANAGE_MESSAGES |
PUT · DELETE | /channels/:channelId/messages/:messageId/reactions/:emoji | React / remove its reaction (URL-encode the emoji) |
GET · PUT | /commands | List / replace all slash commands |
POST | /interactions/:interactionId/defer | Show “thinking…” now and answer later { ephemeral? } |
POST | /interactions/:interactionId/reply | Answer a slash command { content, ephemeral? } |
Send, edit and delete messages
# Send (optionally as a reply)
curl -X POST -H "Authorization: Bot $VOLTEX_BOT_TOKEN" -H "Content-Type: application/json" \
-d '{"content":"Hello from my bot 👋","replyToId":"<messageId>"}' \
https://backend.voltex.social/api/bot/channels/<channelId>/messages
# Edit your own message
curl -X PATCH -H "Authorization: Bot $VOLTEX_BOT_TOKEN" -H "Content-Type: application/json" \
-d '{"content":"Edited text"}' \
https://backend.voltex.social/api/bot/channels/<channelId>/messages/<messageId>
# Delete (yours, or anyone's with MANAGE_MESSAGES)
curl -X DELETE -H "Authorization: Bot $VOLTEX_BOT_TOKEN" \
https://backend.voltex.social/api/bot/channels/<channelId>/messages/<messageId>Reactions, members and roles
# React (URL-encode the emoji: 👍 = %F0%9F%91%8D)
curl -X PUT -H "Authorization: Bot $VOLTEX_BOT_TOKEN" \
https://backend.voltex.social/api/bot/channels/<channelId>/messages/<messageId>/reactions/%F0%9F%91%8D
# Members, 100 per page — pass the last member "id" as ?after=
curl -H "Authorization: Bot $VOLTEX_BOT_TOKEN" \
"https://backend.voltex.social/api/bot/servers/<serverId>/members?limit=100"
# Give a role (needs MANAGE_ROLES, and the bot's role must sit above it)
curl -X PUT -H "Authorization: Bot $VOLTEX_BOT_TOKEN" \
https://backend.voltex.social/api/bot/servers/<serverId>/members/<userId>/roles/<roleId>- Bots work in server channels only — no DMs in this version.
- A server or channel the bot is not in returns
404, the same as one that doesn't exist. - Mentions use the same tokens as the app:
<@userId>,<@&roleId>,<#channelId>.
Gateway (realtime events)
Connect a socket.io v4 client to the /bots namespace at https://backend.voltex.social with auth: { token }. The gateway only sends events — everything the bot does goes through the REST API. While connected the bot shows as online.
| Event | Payload | When |
|---|---|---|
ready | { user, botId, servers: [{ id, name }] } | Right after connecting (and after every reconnect) |
serverCreate | { id, name } | The bot was added to a server |
serverDelete | { id } | The bot was removed from a server (kick, ban, leave) |
messageCreate | message | A message was sent in a channel the bot can see |
messageUpdate | message | A message was edited |
messageDelete | { id, channelId, serverId } | A message was deleted |
reactionAdd | { messageId, channelId, serverId, userId, emoji } | Someone reacted to a message |
memberJoin | { serverId, user } | A member (person or bot) joined a server |
memberLeave | { serverId, userId, reason } | A member left, was kicked or banned |
interactionCreate | interaction | Someone used one of the bot's slash commands |
const { io } = require('socket.io-client');
const socket = io('https://backend.voltex.social/bots', {
auth: { token: process.env.VOLTEX_BOT_TOKEN },
transports: ['websocket'],
});
socket.on('ready', ({ user, botId, servers }) => console.log('ready', user.name, servers));
socket.on('serverCreate', (server) => console.log('added to', server.name));
socket.on('serverDelete', ({ id }) => console.log('removed from', id));
socket.on('messageCreate', (msg) => { /* full message */ });
socket.on('messageUpdate', (msg) => { /* edited message */ });
socket.on('messageDelete', ({ id, channelId, serverId }) => {});
socket.on('reactionAdd', ({ messageId, channelId, serverId, userId, emoji }) => {});
socket.on('memberJoin', ({ serverId, user }) => {});
socket.on('memberLeave', ({ serverId, userId, reason }) => {});
socket.on('interactionCreate', (interaction) => {});
// socket.io reconnects by itself; 'ready' fires again after each reconnect.
socket.on('disconnect', (reason) => console.warn('disconnected:', reason));The message object
{
"id": "6f1c…", // message id
"channelId": "0b9e…",
"serverId": "a41d…",
"content": "hello <@7c2f…>",
"authorId": "7c2f…",
"author": { "id": "7c2f…", "username": "sara", "name": "Sara", "isBot": false, "profileUrl": "…" },
"webhookId": null, // set when a webhook posted it
"replyToId": null,
"files": [],
"mentionUserIds": ["7c2f…"],
"mentionRoleIds": [],
"mentionEveryone": false,
"interaction": null, // { id, name, userId } on slash-command replies
"isEdited": false,
"createdAt": "2026-11-04T10:00:00.000Z",
"updatedAt": "2026-11-04T10:00:00.000Z"
}- Channel events only arrive for channels the bot can see (VIEW_CHANNEL).
- The bot's own messages arrive too — skip
author.isBotto avoid answering yourself in a loop. webhookIdis set on webhook posts;interactionis set on slash-command replies.
Slash commands & interactions
Register commands with PUT /commands. It replaces the bot's whole set (commands left out are removed), so it is safe to call on every start. Members type / in a channel and see the commands of every bot there that can see that channel (they need Use Application Commands).
name: 1–32 lowercase letters, digits,-or_.description: 1–100 characters.- Up to 50 commands per bot and 25 options per command. Required options must come before optional ones.
choices(up to 25) only forstring,integerandnumberoptions.
| Option type | Your bot receives |
|---|---|
string | Text (up to 1000 characters) |
integer · number | A number (whole number for integer) |
boolean | true / false (users may type yes/no/1/0) |
user | A user id (<@id> mentions are accepted) |
channel | A channel id (<#id> accepted) |
role | A role id (<@&id> accepted) |
curl -X PUT -H "Authorization: Bot $VOLTEX_BOT_TOKEN" -H "Content-Type: application/json" \
https://backend.voltex.social/api/bot/commands -d @- <<'JSON'
{
"commands": [
{ "name": "ping", "description": "Check that the bot is alive" },
{
"name": "roll",
"description": "Roll a die",
"options": [
{ "name": "sides", "description": "How many sides", "type": "integer",
"required": true, "choices": [{ "name": "d6", "value": 6 }, { "name": "d20", "value": 20 }] },
{ "name": "secret", "description": "Only you see it", "type": "boolean" }
]
},
{
"name": "warn",
"description": "Warn a member",
"options": [
{ "name": "member", "description": "Who", "type": "user", "required": true },
{ "name": "reason", "description": "Why", "type": "string" }
]
}
]
}
JSON
# List what is registered
curl -H "Authorization: Bot $VOLTEX_BOT_TOKEN" https://backend.voltex.social/api/bot/commandsinteractionCreate
When a member runs a command, the options are validated and typed before your bot hears about it:
// interactionCreate
{
"id": "e3b0…", // use it in /interactions/:id/…
"type": "command",
"commandId": "51aa…",
"commandName": "roll",
"options": { "sides": 20, "secret": true }, // already validated and typed
"serverId": "a41d…",
"channelId": "0b9e…",
"user": { "id": "7c2f…", "username": "sara", "name": "Sara", "isBot": false },
"createdAt": "2026-11-04T10:00:00.000Z"
}Answering
- 1
POST /interactions/:id/reply { content }posts a normal message shown as “user used /name”. The bot needs Send Messages in that channel. - 2Add
ephemeral: trueand only the person who ran the command sees the answer. Ephemeral answers are never stored. - 3No answer within 3 seconds → the member sees “bot is thinking…”. For slow work call
POST /interactions/:id/deferfirst; you then have 15 minutes to reply. A deferred ephemeral “thinking” resolves to an ephemeral answer. - 4A bot that never acknowledges fails after 30 seconds (“did not respond”). Each interaction can be answered once; a second reply returns
400, an expired one410. - 5If the bot is offline when someone runs a command, the member is told right away.
socket.on('interactionCreate', async (i) => {
const reply = (content, ephemeral = false) =>
api('POST', '/interactions/' + i.id + '/reply', { content, ephemeral });
if (i.commandName === 'roll') {
const n = 1 + Math.floor(Math.random() * i.options.sides);
return reply('🎲 ' + n, i.options.secret === true); // ephemeral: only the user sees it
}
if (i.commandName === 'report') {
// Slow work? Defer first — the user sees "thinking…", you get 15 minutes.
await api('POST', '/interactions/' + i.id + '/defer', { ephemeral: true });
const text = await buildSlowReport();
return reply(text); // stays ephemeral because the defer was
}
});Webhooks
A webhook is a secret URL that posts into one channel. No account, no token header, no library — the URL is the credential.
- 1Channel settings → Webhooks → New webhook (needs Manage Webhooks). Give it a name and, if you like, an avatar.
- 2Copy the URL — like a bot token, it is shown once. New URL replaces it and the old one stops working.
- 3POST JSON to it from anywhere.
curl -X POST -H "Content-Type: application/json" \
-d '{"content":"✅ Build #42 passed","username":"CI","avatar_url":"https://example.com/ci.png"}' \
"https://backend.voltex.social/api/webhooks/<id>/<token>"
# ?wait=true returns the created message instead of {"ok":true}
curl -X POST -H "Content-Type: application/json" -d '{"content":"hi"}' \
"https://backend.voltex.social/api/webhooks/<id>/<token>?wait=true"| Field | Notes |
|---|---|
content | Required, up to 2000 characters |
username | Optional display name for this post (up to 80 characters) |
avatar_url · avatarUrl | Optional image URL. Voltex downloads and re-hosts it (images only, ≤ 1 MB, private addresses refused) |
?wait=true | Query flag: return the created message instead of { "ok": true } |
- Discord field names work, so most Discord webhook senders only need the URL swapped.
- Posts show the chosen name with a WEBHOOK tag. Up to 10 webhooks per channel.
- A wrong id or token returns
404 Unknown webhook.
Rate limits & errors
| Limit | Value |
|---|---|
| Bot API requests | 50 per second per bot (headers X-RateLimit-Limit, X-RateLimit-Remaining) |
| Messages | The normal per-sender message limit applies to bots too (8 per 5 seconds) |
| Webhook posts | 5 per 2 seconds per webhook, and 30 per minute per channel |
| Running slash commands | 5 per 5 seconds per member |
| Message length | 2000 characters |
| Slash commands | 50 per bot, 25 options each, 25 choices per option |
| Bots / webhooks | 10 bots per developer, 10 webhooks per channel |
| Status | Meaning |
|---|---|
400 | Invalid body (the message field says which), or the interaction was already answered |
401 | Missing or invalid bot token |
403 | The bot lacks a permission, e.g. Missing permission: MANAGE_ROLES, or the role is above the bot's |
404 | Unknown server, channel, message, interaction or webhook — or one the bot can't access |
410 | The interaction expired |
429 | RATE_LIMITED — wait retryAfter seconds (in the body) and retry |
503 | BOTS_DISABLED / WEBHOOKS_DISABLED — turned off by the Voltex team or for this server |
async function api(method, path, body, attempt = 0) {
const res = await fetch(API + '/api/bot' + path, {
method,
headers: { Authorization: 'Bot ' + TOKEN, 'Content-Type': 'application/json' },
body: body === undefined ? undefined : JSON.stringify(body),
});
if (res.status === 429 && attempt < 3) {
const info = await res.json().catch(() => ({}));
const wait = Number(info.retryAfter ?? 1); // seconds
await new Promise((r) => setTimeout(r, wait * 1000));
return api(method, path, body, attempt + 1);
}
// res.headers.get('X-RateLimit-Remaining') tells you how much room is left
const text = await res.text();
const data = text ? JSON.parse(text) : null;
if (!res.ok) throw new Error(res.status + ' ' + (data?.code ?? '') + ' ' + (data?.message ?? text));
return data;
}Recipes
Short, complete handlers for common bots. They reuse api() and socket / sio from the quick start.
👋 Welcome message + auto-role
// Welcome + auto-role. Invite permissions: VIEW_CHANNEL, SEND_MESSAGES, MANAGE_ROLES (197632)
// Then drag the bot's role above the role it hands out (Server settings → Roles).
const WELCOME_CHANNEL_ID = process.env.WELCOME_CHANNEL_ID;
const MEMBER_ROLE_ID = process.env.MEMBER_ROLE_ID;
const SERVER_ID = process.env.SERVER_ID;
socket.on('memberJoin', async ({ serverId, user }) => {
if (serverId !== SERVER_ID || user.isBot) return;
await api('POST', '/channels/' + WELCOME_CHANNEL_ID + '/messages', {
content: 'Welcome <@' + user.id + '>! Read the rules and say hi 👋',
});
await api('PUT', '/servers/' + serverId + '/members/' + user.id + '/roles/' + MEMBER_ROLE_ID);
});
socket.on('memberLeave', async ({ serverId, reason }) => {
if (serverId !== SERVER_ID) return;
await api('POST', '/channels/' + WELCOME_CHANNEL_ID + '/messages', {
content: 'A member left (' + (reason ?? 'left') + ').',
});
});💬 FAQ auto-replies with a cooldown
// Exact-match FAQ. Invite permissions: VIEW_CHANNEL + SEND_MESSAGES (196608).
// Only the configured server/channel is watched; bots and webhooks are ignored.
const FAQ_CHANNEL_ID = process.env.FAQ_CHANNEL_ID;
const answers = new Map([
['!rules', 'Read the pinned rules before posting.'],
['!help', 'Ask a moderator or use /help.'],
]);
let nextReplyAt = 0;
socket.on('messageCreate', async (msg) => {
if (msg.channelId !== FAQ_CHANNEL_ID || msg.author?.isBot || msg.webhookId) return;
const content = answers.get(msg.content.trim().toLowerCase());
if (!content || Date.now() < nextReplyAt) return;
nextReplyAt = Date.now() + 10_000;
try {
await api('POST', '/channels/' + msg.channelId + '/messages', {
content, replyToId: msg.id,
});
} catch (error) {
console.error('FAQ reply failed:', error.message);
}
});⚡ A custom /help command
// Add this definition to the full command list you register with PUT /commands.
// PUT replaces ALL existing commands, so keep the complete list in your code.
const helpCommand = {
name: 'help', description: 'Find a server resource',
options: [{
name: 'topic', description: 'What do you need?', type: 'string', required: true,
choices: [{ name: 'Rules', value: 'rules' }, { name: 'Support', value: 'support' }],
}],
};
socket.on('interactionCreate', async (i) => {
if (i.commandName !== 'help') return;
const answers = { rules: 'Read the pinned rules.', support: 'Contact the server moderators.' };
await api('POST', '/interactions/' + i.id + '/reply', {
content: answers[i.options.topic], ephemeral: true,
});
});
// For a slow API lookup: POST /interactions/:id/defer { ephemeral: true }
// before starting the lookup, then POST /interactions/:id/reply with its result.🛡️ Moderation: word filter + /warn
// Word filter + /warn. Invite permissions: VIEW_CHANNEL, SEND_MESSAGES,
// READ_MESSAGE_HISTORY, MANAGE_MESSAGES (4915200)
const BANNED = [/free\s*nitro/i, /bit\.ly\//i];
const LOG_CHANNEL_ID = process.env.LOG_CHANNEL_ID;
socket.on('messageCreate', async (msg) => {
if (msg.author?.isBot || msg.webhookId) return;
if (!BANNED.some((re) => re.test(msg.content))) return;
await api('DELETE', '/channels/' + msg.channelId + '/messages/' + msg.id);
await api('POST', '/channels/' + LOG_CHANNEL_ID + '/messages', {
content: '🛡️ Removed a message from <@' + msg.authorId + '> in <#' + msg.channelId + '>',
});
});
socket.on('interactionCreate', async (i) => {
if (i.commandName !== 'warn') return;
await api('POST', '/channels/' + LOG_CHANNEL_ID + '/messages', {
content: '⚠️ <@' + i.options.member + '> warned by <@' + i.user.id + '>: ' + (i.options.reason ?? '—'),
});
await api('POST', '/interactions/' + i.id + '/reply', { content: 'Warning logged.', ephemeral: true });
});🎫 Support tickets
// /ticket topic:<text> → posts to a private staff channel, answers privately.
// Register: { name: 'ticket', description: 'Ask the staff for help',
// options: [{ name: 'topic', description: 'What do you need?', type: 'string', required: true }] }
const STAFF_CHANNEL_ID = process.env.STAFF_CHANNEL_ID; // the bot must be able to see it
socket.on('interactionCreate', async (i) => {
if (i.commandName !== 'ticket') return;
const posted = await api('POST', '/channels/' + STAFF_CHANNEL_ID + '/messages', {
content: '🎫 New ticket from <@' + i.user.id + '> (in <#' + i.channelId + '>):\n' + i.options.topic,
});
await api('PUT', '/channels/' + STAFF_CHANNEL_ID + '/messages/' + posted.id + '/reactions/' + encodeURIComponent('👀'));
await api('POST', '/interactions/' + i.id + '/reply', {
content: 'Thanks! The staff got your ticket and will reach out.',
ephemeral: true,
});
});
// Staff react ✅ on the ticket → the bot closes it
socket.on('reactionAdd', async ({ channelId, messageId, emoji }) => {
if (channelId !== STAFF_CHANNEL_ID || emoji !== '✅') return;
await api('POST', '/channels/' + channelId + '/messages', { content: 'Ticket closed ✅', replyToId: messageId });
});🔔 Notifications with a webhook (no bot)
// No bot needed — a webhook + a cron job / CI step / server hook.
// e.g. post new releases of a GitHub repo every 10 minutes:
let last;
setInterval(async () => {
const r = await fetch('https://api.github.com/repos/OWNER/REPO/releases/latest').then((x) => x.json());
if (!r.tag_name || r.tag_name === last) return;
last = r.tag_name;
await fetch(process.env.VOLTEX_WEBHOOK_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username: 'Releases', content: '🚀 ' + r.name + '\n' + r.html_url }),
});
}, 10 * 60 * 1000);These external-bot recipes need your own running process. Scope handlers to the intended server/channel, ignore bots and webhooks, catch handler errors, and keep state in a database when it must survive restarts. Command names such as /warn do not grant moderator authority: check the invoking user's permissions in your own trusted service before taking a privileged action.
Build a more capable bot
A single bot can combine several modules. Keep each module's configuration separate for each server; changing one server's welcome channel or role must not affect another server.
| Pattern | Available building blocks | What your bot must provide |
|---|---|---|
| FAQ and custom commands | messageCreate, typed slash options, ephemeral replies | Reply templates, channel scope and cooldowns |
| Welcome and starter roles | memberJoin, memberLeave, send message, give role | Per-server settings; the bot's role must be above the assigned role |
| Polls and starboards | Send messages, add reactions, reactionAdd | A database for votes/stars; no reaction-removed event, so removing a vote cannot be tracked reliably |
| Levels and rewards | messageCreate, member lists, give role | Persistent XP, per-user cooldowns and reward rules |
| Scheduled announcements | Send message or execute webhook | An external scheduler and stored job state |
| Support requests | Slash commands, a private staff channel, ephemeral replies | Ticket state and staff authorization; channel creation is not exposed by the bot API |
These are implementation patterns, not additional built-in platform features. Voice/music bots, buttons, modals, embeds and bot DMs still need platform APIs that are not available yet.