Riscord Back to chat

Developer docs

Build a bot that belongs in your community.

API v1 SDK 0.5.0

Commands

Register slash commands, typed options and optional text aliases.

Examples use the bot client from Your first bot.

Define your commands

Command names use lowercase letters, digits, underscores and hyphens, up to 32 characters. A bot can register up to 50 commands, each with up to 25 options. Replacing definitions keeps IDs for unchanged application, server and name combinations.

JavaScript
await bot.registerCommands([{
  name: 'greet',
  description: 'Say hello to someone',
  contexts: ['server'],
  options: [{ name: 'person', description: 'Who to greet', type: 'user', required: true }],
}]);
bot.command('greet', interaction => {
  const personId = interaction.data.values.person;
  return interaction.reply(`Hello <@${personId}>!`);
});

Option types

All IDs stay strings. Roles require a server context and must belong to that server. User and mentionable values in DMs can refer only to conversation participants. Do not convert IDs to JavaScript numbers.

TypeValue
stringText
integerA whole number
numberA number, including decimals
booleanTrue or false
userA user ID string
channelA channel ID string
roleA role ID string in this server
mentionableA user or role ID string

Choices and bounds

String, integer and number options can offer up to 25 static choices. Each choice has a name and a value matching its option type. Numeric options support minValue and maxValue; strings support minLength and maxLength. The API checks both the definition and the submitted value.

Autocomplete and nested subcommands are not available yet. Use static choices and separate command names.

JavaScript
await bot.registerCommands([{
  name: 'volume', description: 'Choose a volume', contexts: ['server'],
  options: [{
    name: 'level', description: 'How loud?', type: 'number', required: true,
    minValue: 0, maxValue: 2,
    choices: [{ name: 'Quiet', value: 0.5 }, { name: 'Normal', value: 1 }],
  }],
}]);

Contexts and permissions

Use contexts to choose server, dm or both. A serverId limits a definition to an installed development server. The permissions list describes what the invoking member must have; it does not grant the bot new capabilities.

Command handlers share ordered event processing. Acknowledge or defer promptly, then move long jobs into a background promise or task.

Text commands

A command can have up to five aliases. Registered text commands and mentions can be delivered without Message Content. Match the application’s configured prefix in your message handler; aliases alone do not make the SDK run a handler. Broader message listeners need Message Content permission.