Skip to content

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

http
POST /bot/commands
Authorization: Bot YOUR_TOKEN_HERE

Body:

FieldTypeRequiredDescription
namestringYesCommand name (lowercase, no spaces). Max 32 chars.
descriptionstringYesShort description shown to users. Max 100 chars.
serverIdstringYesThe server to register this command in.
minTierstringNoMinimum member tier required to invoke. One of member, moderator, admin, owner. Defaults to member.
optionsarrayNoCommand parameters (see below).

Response: 201 Created — the created command object.

Example:

json
{
  "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:

FieldTypeRequiredDescription
namestringYesParameter name
descriptionstringYesShown to users
typestringYes"string", "integer", "boolean", "user", "channel", or "label"
requiredbooleanNoDefaults to false

Example with options:

json
{
  "name": "echo",
  "description": "Repeat a message",
  "serverId": "server-uuid-here",
  "options": [
    {
      "name": "message",
      "description": "The message to echo",
      "type": "string",
      "required": true
    }
  ]
}

List Commands

http
GET /bot/commands
Authorization: Bot YOUR_TOKEN_HERE

Response: 200 OK — array of command objects.


Update a Command

http
PATCH /bot/commands/{commandId}
Authorization: Bot YOUR_TOKEN_HERE

Body: same fields as register (all optional).


Delete a Command

http
DELETE /bot/commands/{commandId}
Authorization: Bot YOUR_TOKEN_HERE

Response: 204 No Content


Handling Invocations

When a user types /ping in a channel, the gateway sends a COMMAND_INVOKE event to your bot:

json
{
  "op": 0,
  "t": "COMMAND_INVOKE",
  "d": {
    "commandId": "...",
    "commandName": "ping",
    "channelId": "...",
    "serverId": "...",
    "userId": "...",
    "options": {}
  }
}

Your bot should respond by sending a message to channelId:

typescript
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.

Licensed under CC BY-NC-SA 4.0.