@@ -1,3 +1,8 @@ | |||||
--- | |||||
uid: Guides.SlashCommands.Creating | |||||
title: Creating Slash Commands | |||||
--- | |||||
# Creating your first slash commands. | # Creating your first slash commands. | ||||
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. |
@@ -1,3 +1,8 @@ | |||||
--- | |||||
uid: Guides.SlashCommands.Receiving | |||||
title: Receiving and Responding to Slash Commands | |||||
--- | |||||
# Responding to interactions. | # Responding to interactions. | ||||
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. |
@@ -1,3 +1,8 @@ | |||||
--- | |||||
uid: Guides.SlashCommands.Parameters | |||||
title: Slash Command Parameters | |||||
--- | |||||
# Slash command parameters | # Slash command parameters | ||||
Slash commands can have a bunch of parameters, each their own type. Let's first go over the types of parameters we can have. | Slash commands can have a bunch of parameters, each their own type. Let's first go over the types of parameters we can have. | ||||
@@ -1,3 +1,8 @@ | |||||
--- | |||||
uid: Guides.SlashCommands.Ephemeral | |||||
title: Ephemeral Responses | |||||
--- | |||||
# Responding ephemerally | # Responding ephemerally | ||||
What is an ephemeral response? Basically, only the user who executed the command can see the result of it. In labs this is pretty simple to do. | What is an ephemeral response? Basically, only the user who executed the command can see the result of it. In labs this is pretty simple to do. | ||||
@@ -1,3 +1,8 @@ | |||||
--- | |||||
uid: Guides.SlashCommands.SubCommand | |||||
title: Sub Commands | |||||
--- | |||||
# Subcommands | # Subcommands | ||||
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. | ||||
@@ -1,3 +1,8 @@ | |||||
--- | |||||
uid: Guides.SlashCommands.Choices | |||||
title: Slash Command Choices | |||||
--- | |||||
# Slash Command Choices. | # Slash Command Choices. | ||||
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! | ||||
@@ -1,4 +1,10 @@ | |||||
--- | |||||
uid: Guides.SlashCommands.BulkOverwrite | |||||
title: Slash Command Bulk Overwrites | |||||
--- | |||||
If you have too many global commands then you might want to consider using the bulk overwrite function. | If you have too many global commands then you might want to consider using the bulk overwrite function. | ||||
```cs | ```cs | ||||
public async Task Client_Ready() { | public async Task Client_Ready() { | ||||
List<ApplicationCommandProperties> applicationCommandProperties = new(); | List<ApplicationCommandProperties> applicationCommandProperties = new(); | ||||
@@ -8,7 +14,7 @@ public async Task Client_Ready() { | |||||
globalCommandHelp.WithName("help"); | globalCommandHelp.WithName("help"); | ||||
globalCommandHelp.WithDescription("Shows information about the bot."); | globalCommandHelp.WithDescription("Shows information about the bot."); | ||||
applicationCommandProperties.Add(globalCommandHelp.Build()); | applicationCommandProperties.Add(globalCommandHelp.Build()); | ||||
// Slash command with name as its parameter. | // Slash command with name as its parameter. | ||||
SlashCommandOptionBuilder slashCommandOptionBuilder = new(); | SlashCommandOptionBuilder slashCommandOptionBuilder = new(); | ||||
slashCommandOptionBuilder.WithName("name"); | slashCommandOptionBuilder.WithName("name"); | ||||
@@ -16,11 +22,11 @@ public async Task Client_Ready() { | |||||
slashCommandOptionBuilder.WithDescription("Add a family"); | slashCommandOptionBuilder.WithDescription("Add a family"); | ||||
slashCommandOptionBuilder.WithRequired(true); // Only add this if you want it to be required | slashCommandOptionBuilder.WithRequired(true); // Only add this if you want it to be required | ||||
SlashCommandBuilder globalCommandAddFamily = new SlashCommandBuilder(); | |||||
SlashCommandBuilder globalCommandAddFamily = new SlashCommandBuilder(); | |||||
globalCommandAddFamily.WithName("add-family"); | globalCommandAddFamily.WithName("add-family"); | ||||
globalCommandAddFamily.WithDescription("Add a family"); | globalCommandAddFamily.WithDescription("Add a family"); | ||||
applicationCommandProperties.Add(globalCommandAddFamily.Build()); | applicationCommandProperties.Add(globalCommandAddFamily.Build()); | ||||
await _client.BulkOverwriteGlobalApplicationCommandsAsync(applicationCommandProperties.ToArray()); | await _client.BulkOverwriteGlobalApplicationCommandsAsync(applicationCommandProperties.ToArray()); | ||||
} catch (ApplicationCommandException exception) { | } catch (ApplicationCommandException exception) { | ||||
var json = JsonConvert.SerializeObject(exception.Error, Formatting.Indented); | var json = JsonConvert.SerializeObject(exception.Error, Formatting.Indented); | ||||
@@ -0,0 +1,10 @@ | |||||
--- | |||||
uid: Guides.Interactions.Intro | |||||
title: Introduction to Interactions | |||||
--- | |||||
# Interactions | |||||
Placeholder text does the brrr. | |||||
Links to different sections of guides: msg comp / slash commands. |
@@ -39,6 +39,20 @@ | |||||
items: | items: | ||||
- name: Introduction | - name: Introduction | ||||
topicUid: Guides.Interactions.Intro | topicUid: Guides.Interactions.Intro | ||||
- name: Creating slash commands | |||||
topicUid: Guides.SlashCommands.Creating | |||||
- name: Receiving and responding to slash commands | |||||
topicUid: Guides.SlashCommands.Receiving | |||||
- name: Slash command parameters | |||||
topicUid: Guides.SlashCommands.Parameters | |||||
- name: Ephemeral responses | |||||
topicUid: Guides.SlashCommands.Ephemeral | |||||
- name: Sub commands | |||||
topicUid: Guides.SlashCommands.SubCommand | |||||
- name: Slash command choices | |||||
topicUid: Guides.SlashCommands.Choices | |||||
- name: Slash ommands Bulk Overwrites | |||||
topicUid: Guides.SlashCommands.BulkOverwrite | |||||
- name: Emoji | - name: Emoji | ||||
topicUid: Guides.Emoji | topicUid: Guides.Emoji | ||||
- name: Voice | - name: Voice | ||||
@@ -3,20 +3,19 @@ uid: Root.Landing | |||||
title: Home | title: Home | ||||
--- | --- | ||||
# Discord.Net Documentation | |||||
# Discord.Net Labs Documentation | |||||
<div class="big-logo logo-switcher"></div> | <div class="big-logo logo-switcher"></div> | ||||
[](https://github.com/discord-net/Discord.Net) | |||||
[](https://www.nuget.org/packages/Discord.Net) | |||||
[](https://www.myget.org/feed/Packages/discord-net) | |||||
[](https://dev.azure.com/discord-net/Discord.Net/_build/latest?definitionId=1&branchName=dev) | |||||
[](https://discord.gg/jkrBmQR) | |||||
[](https://github.com/Discord-Net-Labs/Discord.Net-Labs) | |||||
[](https://www.nuget.org/packages/Discord.Net.Labs/) | |||||
[](https://www.myget.org/feed/Packages/discord-net-labs) | |||||
[](https://dev.azure.com/Discord-Net-Labs/Discord-Net-Labs/_build/latest?definitionId=1&branchName=release%2F3.x) | |||||
[](https://discord.gg/dvSfUTet3K) | |||||
## What is Discord.Net? | |||||
## What is Discord.Net Labs? | |||||
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 | |||||
## Where to begin? | ## Where to begin? | ||||