Discord Bot icon

Discord Bot

Send messages and manage slash commands for Discord bots

Register Slash Command

AI-generated

Summary

Register a slash command with Discord, optionally scoped to a specific guild or globally, by specifying the command name, description, and configurable options or by providing raw JSON for the command options.

Inputs

  • Guild ID — The ID of the guild to register the slash command for; leave empty to register the command globally.
  • Command Name (required) — The name of the slash command to register.
  • Command Description (required) — A description of what the command does.
  • Command Options — Structured options for the slash command, including each option's name, description, type, predefined choices (for string and integer types), and whether the option is required.
  • Or Provide Raw JSON Instead — A JSON array representing the slash command options for advanced configuration beyond the UI builder.

Output shape

a single record containing the Discord API response for the registered slash command, including its ID and definition details

The registered command can be scoped to a specific guild if Guild ID is set, otherwise it is registered globally. The output reflects the Discord API's created command object.

Examples

Example 1: Register a global slash command named 'weather' with a description 'Get the weather forecast' and no options.

Set Command Name to 'weather', Command Description to 'Get the weather forecast', leave Guild ID empty, and leave Command Options empty.

Example 2: Register a guild-specific slash command named 'poll' with options for question (string, required) and anonymous (boolean, optional).

Set Guild ID to the target guild's ID, Command Name to 'poll', Command Description to 'Create a poll in this guild', add two Command Options: one string option named 'question' marked as required, and one boolean option named 'anonymous' marked as optional.

Links

Discussion