There are two kinds of Slash Commands: global commands and guild commands.
There are two kinds of Slash Commands: global commands and guild commands.
@@ -35,7 +40,10 @@ The slash command builder will help you create slash commands. The builder has t
| AddOption | Function | Adds an option to the current slash command. |
| AddOption | Function | Adds an option to the current slash command. |
| Build | Function | Builds the builder into a `SlashCommandCreationProperties` class used to make slash commands |
| Build | Function | Builds the builder into a `SlashCommandCreationProperties` class used to make slash commands |
**Note**: Slash command names must be all lowercase!
> [!NOTE]
> Slash command names must be all lowercase!
## Creating a Slash Command
Let's use the slash command builder to make a global and guild command.
Let's use the slash command builder to make a global and guild command.
@@ -84,4 +92,5 @@ public async Task Client_Ready()
```
```
**Note**: Slash commands only need to be created once. They do _not_ have to be 'created' on every startup or connection. The example simple shows creating them in the ready event as it's simpler than creating normal bot commands to register slash commands.
> [!NOTE]
> Slash commands only need to be created once. They do _not_ have to be 'created' on every startup or connection. The example simple shows creating them in the ready event as it's simpler than creating normal bot commands to register slash commands.
Interactions are the base thing sent over by Discord. Slash commands are one of the interaction types. In order to receive a slash command we have to listen to the `InteractionCreated` event. Let's add this to our code.
Interactions are the base thing sent over by Discord. Slash commands are one of the interaction types. In order to receive a slash command we have to listen to the `InteractionCreated` event. Let's add this to our code.
@@ -45,6 +50,8 @@ Let's try this out!
Let's go over the response types quickly, as you would only change them for style points :P
Let's go over the response types quickly, as you would only change them for style points :P
> After receiving an interaction, you must respond to acknowledge it. You can choose to respond with a message immediately using `RespondAsync()` or you can choose to send a deferred response with `DeferAsync()`. If choosing a deferred response, the user will see a loading state for the interaction, and you'll have up to 15 minutes to edit the original deferred response using `ModifyOriginalResponseAsync()`. You can read more about response types [here](https://discord.com/developers/docs/interactions/slash-commands#interaction-response)
> [!NOTE]
> After receiving an interaction, you must respond to acknowledge it. You can choose to respond with a message immediately using `RespondAsync()` or you can choose to send a deferred response with `DeferAsync()`.
> If choosing a deferred response, the user will see a loading state for the interaction, and you'll have up to 15 minutes to edit the original deferred response using `ModifyOriginalResponseAsync()`. You can read more about response types [here](https://discord.com/developers/docs/interactions/slash-commands#interaction-response)
This seems to be working! Next, we will look at parameters for slash commands.
This seems to be working! Next, we will look at parameters for slash commands.
Subcommands allow you to have multiple commands available in a single command. They can be useful for representing sub options for a command. For example: A settings command. Let's first look at some limitations with subcommands set by discord.
Subcommands allow you to have multiple commands available in a single command. They can be useful for representing sub options for a command. For example: A settings command. Let's first look at some limitations with subcommands set by discord.
With slash command options you can add choices, making the user select between some set values. Lets create a command that asks how much they like our bot!
With slash command options you can add choices, making the user select between some set values. Lets create a command that asks how much they like our bot!
Discord.Net is an asynchronous, multi-platform .NET Library used to
interface with the [Discord API](https://discord.com/).
Discord.Net Labs is an experimental fork of Discord.Net that implements the newest discord features for testing and development to eventually get merged into Discord.Net
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.