This section answers basic questions and common mistakes in handling application commands, and responding to them.
The difference between these 3 functions is in how you handle the command response.
RespondAsync and
DeferAsync let the API know you have succesfully received the command. This is also called 'acknowledging' a command.
DeferAsync will not send out a response, RespondAsync will.
FollowupAsync follows up on succesful acknowledgement.
[!WARNING]
If you have not acknowledged the command FollowupAsync will not work! the interaction has not been resonded to, so you cannot follow it up!
Bad form exceptions are thrown if the slash, user or message command builder has invalid values.
The following options could resolve your error.
If your command name is not lowercase, it is not seen as a valid command entry.
Avatar
is invalid; avatar
is valid.
Discord expects all values to be below maximum allowed.
Going over this maximum amount of characters causes an exception.
[!NOTE]
All maximum and minimum value requirements can be found in the Discord Developer Docs.
For components, structure documentation is found here.
Branching structure is covered properly here: xref:Guides.SlashCommands.SubCommand
If you registered your commands globally, it can take up to 1 hour for them to register.
Did you register a guild command (should be instant), or waited more than an hour and still don't have them show up?
Try to check for any errors in the console, there is a good chance something might have been thrown.
Register your commands after the Ready event in the client. The client is not configured to register commands before this moment.
Check if no bad form exception is thrown; If so, refer to the above question.
Do you have the application commands scope checked when adding your bot to guilds?
[!code-csharpRegister examples]
[!NOTE]
You can use bulkoverwrite even if there are no commands in guild, nor globally.
The bulkoverwrite method disposes the old set of commands and replaces it with the new.
If you are registering your commands for the first time, it is required to create them once.
After this, commands will exist indefinitely until you overwrite them.
Overwriting is only required if you make changes to existing commands, or add new ones.
Message and user commands have a limit of 5 per guild, and another 5 globally.
If you have more than 5 guild-only message commands being registered, no more than 5 will actually show up.
You can get up to 10 entries to show if you register 5 per guild, and another 5 globally.