Slash Commands
Bots can register slash commands that users invoke by typing /commandname in a channel. When a user invokes a command, the bot receives a COMMAND_INVOKE event over the WebSocket gateway.
Registering Commands
Commands are registered via the bot self-service API. Use your bot token with the Bot prefix.
Register a Command
POST /bot/commands
Authorization: Bot YOUR_TOKEN_HEREBody:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Command name (lowercase, no spaces). Max 32 chars. |
description | string | Yes | Short description shown to users. Max 100 chars. |
serverId | string | Yes | The server to register this command in. |
minTier | string | No | Minimum member tier required to invoke. One of member, moderator, admin, owner. Defaults to member. |
options | array | No | Command parameters (see below). |
Response: 201 Created — the created command object.
Example:
{
"name": "ping",
"description": "Check if the bot is alive",
"serverId": "server-uuid-here"
}Command Options
Options are the parameters users can pass to a command. Each option:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Parameter name |
description | string | Yes | Shown to users |
type | string | Yes | "string", "integer", "boolean", "user", "channel", or "label" |
required | boolean | No | Defaults to false |
Example with options:
{
"name": "echo",
"description": "Repeat a message",
"serverId": "server-uuid-here",
"options": [
{
"name": "message",
"description": "The message to echo",
"type": "string",
"required": true
}
]
}List Commands
GET /bot/commands
Authorization: Bot YOUR_TOKEN_HEREResponse: 200 OK — array of command objects.
Update a Command
PATCH /bot/commands/{commandId}
Authorization: Bot YOUR_TOKEN_HEREBody: same fields as register (all optional).
Delete a Command
DELETE /bot/commands/{commandId}
Authorization: Bot YOUR_TOKEN_HEREResponse: 204 No Content
Handling Invocations
When a user types /ping in a channel, the gateway sends a COMMAND_INVOKE event to your bot:
{
"op": 0,
"t": "COMMAND_INVOKE",
"d": {
"commandId": "...",
"commandName": "ping",
"channelId": "...",
"serverId": "...",
"userId": "...",
"options": {}
}
}Your bot should respond by sending a message to channelId:
ws.on('message', async (raw) => {
const msg = JSON.parse(raw.toString())
if (msg.op === 0 && msg.t === 'COMMAND_INVOKE') {
const { commandName, channelId, options } = msg.d
if (commandName === 'ping') {
await sendMessage(channelId, 'Pong! 🏓')
}
if (commandName === 'echo') {
await sendMessage(channelId, options.message)
}
}
})
async function sendMessage(channelId: string, content: string) {
await fetch(`https://app.fluffwire.com/api/channels/${channelId}/messages`, {
method: 'POST',
headers: {
'Authorization': `Bot ${process.env.FLUFFWIRE_BOT_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ content }),
})
}Enabling Commands in a Server
After registering a command, server admins can enable or disable individual bot commands in Server Settings → Commands. Commands are disabled by default until an admin enables them.