Skip to content

Instantly share code, notes, and snippets.

@MinnDevelopment
Last active December 11, 2024 00:47
Show Gist options
  • Save MinnDevelopment/b883b078fdb69d0e568249cc8bf37fe9 to your computer and use it in GitHub Desktop.
Save MinnDevelopment/b883b078fdb69d0e568249cc8bf37fe9 to your computer and use it in GitHub Desktop.

What is possible?

Slash commands offer a way to integrate your bot commands directly into the Discord UI. However, these commands are still very limited and cannot replace every use-case for now. I'll explain the limitations and possibilities of this new feature a bit here.

Slash Commands work entirely through the Webhook API. Which introduces a number of moderation issues. See the Moderation section below. It also causes some Rate Limit Problems.

Things you can do with slash commands

  • Simple Q/A type commands that just take an input and return an answer
  • Simple commands that have side-effects such as kick/ban/music
  • You can add commands to guilds, instead of having them available globally
  • Restrict commands by a User/Role whitelist or blacklist. This is per-guild and limited to 10 entries. In JDA these are called ComandPrivileges Bots can no longer manage these without an OAuth2 access token. You can instead set which permissions a command requires, and moderators can further overwrite it with whitelist/blacklist settings.

Things you cannot do

  • You MUST reply to every command. You cannot simply accept it and do something without responding.
  • Commands that require multiline inputs (such as eval).
  • Commands that require additional inputs (like a menu or similar) [Kind of solved by modals, but not that useful so far]
  • Restricting commands to members through permissions (such as /ban only for members that can actually ban) [Kind of solved by permissions v2]
  • Slash commands cannot accept attachments, no file uploads [Solved by attachment options]

Ephemeral Messages are limited

  • You cannot add attachments [Solved ephemeral attachments]
  • You cannot add reactions
  • You cannot delete them (only the user can) [Can be deleted using the interaction hook, but not the channel endpoint]
  • You can edit them (only your original reply)

Limitation of arguments (options)

  • There are currently only 9 different argument types (excluding subcommands) (OptionTypes)
  • You cannot make repeatable (aka variadic) arguments
  • The USER option type is unrestricted by the guild. You can pass users from anywhere, by inserting an ID.
  • The CHANNEL type cannot be restricted to a specific channel type. If you want a music bot join command you will have to deal with users trying to make you join text channels. [Solved channel_types in ApplicationCommandOption]
  • The MENTIONABLE type can only handle role and user, so you can't use it as a placeholder for IDs
  • The INTEGER type is restricted to 53 bit precision (which would be a long in java)
  • The NUMBER type is restricted to 2^53 due to Flask limitations on Discord's end
  • The STRING type can take any input below a certain character limit. It cannot be restricted in any way. Can be restricted to a specific min_length and max_length (Whether thats codepoints or bytes is not documented)
  • You can now specify a valid range for INTEGER and NUMBER options: Add min_value and max_value on slash command options

Managing Commands

  • Global commands take up to 1 hour to propagate through the API backend
  • You can't have 2 global commands with the same name, or 2 guild commands with the same name See docs
  • There is no way to identify if a global command has been updated reliably
  • There are limits to how many commands you can have see here
  • There are also limits to how many commands can be present in one server. This limit is shared by all integrations (bots) in the server.
  • The client will only load commands for the first 50 integrations in your server. (This means the first bots that were added)
  • You cannot force the applications.commands scope without oauth2 code flow (This means you have to do a full oauth2 token exchange just to verify the scope is present!)

Moderation Problems

  • Moderators have only the Use Slash Commands permission at their disposal to limit who can use commands
  • There is no way to limit which bots can use commands in which channels
  • The only way to disable slash commands for a bot is to kick it from the server, removing the scope from the invite, and adding it back
  • There is no way to limit which commands are enabled or hiding commands in general. Either you enable all commands or disable all commands. The bot can make a whitelist/blacklist per command but moderators have no control over it.
  • Discord only shows commands for the first 50 integrations (bots) in a server, there is no way to re-order them. You just have to kick all bots and then add the 50 bots that you need to have slash commands for.
  • You cannot disable commands for admins. This is a downgrade from legacy command dashboards. (discord/discord-api-docs#4914)

Update 2022/04/27: You can now edit each integration one by one (roles still don't matter). This system is extremely overengineered and hard to understand. Discord ignored all feedback given for this system, including initial design decisions such as the confusing nature of "synced" or that there is no way to manage a group of integrations.

@Lel020
Copy link

Lel020 commented Sep 5, 2023

can I trigger a bot to send a command to another bot?

https://stackoverflow.com/questions/72280576/jda-slash-command-event

@DragonCoding-Reiko
Copy link

As of now you CAN delete the ephemeral message while using event.getHook().deleteOriginal.queue()

@DVyadav2307
Copy link

Where can I learn about attachments with commands??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment