Bafflux Docs Developer Portal

Building bots

Commands

Register slash commands with typed options, and prefix commands for the command list.

Commands are what people see when they type / in a channel your bot is in. There are two kinds:

  • Slash commands run on your bot: Bafflux checks the options, then sends your bot an interaction to answer.
  • Prefix commands (like !help) are only listed in the picker so people can find them. They arrive as normal messages; your bot reads them from MESSAGE_CREATE.

Registering

Send the full list with PUT. It replaces every command in that scope, so bots usually do this each time they start.

bash
curl -X PUT https://bafflux.com/api/applications/$APP_ID/commands \
  -H "Authorization: Bot $BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '[
    { "name": "ping", "description": "Checks the bot is awake" },
    { "name": "say", "description": "Repeats what you type",
      "options": [
        { "name": "text", "description": "What to say", "type": "string", "required": true },
        { "name": "times", "description": "How many times", "type": "integer" }
      ] },
    { "kind": "prefix", "prefix": "!", "name": "help", "description": "Lists commands" }
  ]'

The answer is the saved list, each command with its id.

EndpointWhat
GET /api/applications/{appId}/commandsCommands available everywhere your bot is
PUT /api/applications/{appId}/commandsReplace them
GET /api/applications/{appId}/servers/{serverId}/commandsCommands only for one server (the bot must be in it)
PUT /api/applications/{appId}/servers/{serverId}/commandsReplace them
DELETE /api/applications/{appId}/commands/{commandId}Remove one command

These work with the bot's token or while logged in to the portal as the app's owner. Changes show up in the picker within a minute.

The command object

FieldTypeNotes
namestringSlash: 1-32 lowercase letters, numbers, - or _. Prefix: 1-32 characters, no spaces
descriptionstringSlash: 1-100 characters, required. Prefix: up to 100
kind"slash" or "prefix"Defaults to "slash"
prefixstringPrefix commands only: 1-5 characters, no spaces, like ! or .
optionsarraySlash commands only, up to 25

Names must be unique within a list (per kind). You can have up to 100 commands everywhere, plus up to 100 in each server.

Options

FieldTypeNotes
namestring1-32 lowercase letters, numbers, - or _
descriptionstring1-100 characters
typestringOne of the types below. Defaults to string
requiredbooleanDefaults to false. Required options must come before optional ones
TypeWhat people typeWhat your bot gets
stringAny text, 1-2000 charactersThe text
integer42A number
number4.5A number
booleantrue, false, yes, no, on, offtrue or false
user@someoneTheir user ID, as a string
role@RoleThe role ID, as a string
channelA channel IDThe channel ID, as a string

Bafflux checks types and required options before your bot hears about the command, so you can trust what arrives.

How people fill in options

After picking a command, people type each option as name: value, in any order:

/say text: hello there times: 3

A command with a single option also takes everything after the name as that option: /say hello there. The picker shows the option names next to each command, and fills in the first one for commands that have several.