Discord · Platform not recorded

Create Custom Discord Slash Commands With an App

Source-checked About 10 minutes

Answer

Create a slash command through a Discord application, test it in a development guild, and verify each interaction on the server before responding. Keep the application token and interaction verification material secret and grant only the permissions the command needs.

Create or select the application

Open the Discord Developer Portal, create an application or select the one that will own the command, and record its application ID. Do not paste a bot token or public key into a client-side page or a public repository.

Define a development command

Create an application command with a clear name, description, and typed options. Register it for a development guild while iterating so you can test the intended server scope before using a global command.

Install with narrow permissions

Use the application’s OAuth2 installation flow and select only the scopes and permissions the command needs. Confirm you are authorizing the intended test server and account.

Receive interactions on a server

Configure the interaction endpoint or gateway handling in the server environment. Verify Discord’s interaction signature before processing data, then acknowledge and respond within Discord’s required interaction timing.

Test an authorized account

Open the test server, type the slash command, provide valid input, and confirm the expected response appears. Test an account or role that should be denied separately.

Handle failures safely

Log the command name, interaction ID, and safe error context, but never log tokens, secrets, or private command content unnecessarily. Make validation failures explain what the user can correct.

Move beyond test scope deliberately

Only register globally after the command works in the development guild and you understand the distribution and update behavior documented by Discord.

Video walkthrough

If it does not work

  • If the command is missing, verify the application ID, install scope, target guild, and registration environment before creating duplicate applications.
  • If interactions time out, verify the endpoint and signature handling on the server. Do not expose a token or disable verification to make a test appear to work.
Sources and verification

Checked against official documentation on . Scope: Platform not recorded.

Follow the linked first-party guidance if labels differ after a platform or app update.

Continue with

Browse more Discord tutorials