diff --git a/README.md b/README.md
index f99f3ec4a..fb44c42e3 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@
This repo is a custom fork of Discord.Net that introduces the newest features of discord for testing and experimenting. Nothing here is guaranteed to work but you are more than welcome to submit bugs in the issues tabs
## Known issues
-Labs will not work with Playwo's [InteractivityAddon](https://github.com/Playwo/Discord.InteractivityAddon). The reason is that his package depends on the base discord.net lib, you can get around this by cloning his repo and building it with discord.net labs instead of discord.net.
+Labs will not work with normal package of Playwo's [InteractivityAddon](https://www.nuget.org/packages/Discord.InteractivityAddon). The reason is that his package depends on the base discord.net lib. You can instead use the [InteractivityAddon.Labs](https://www.nuget.org/packages/Discord.InteractivityAddon.Labs) package which implements some of the features added in Discord.Net-Labs.
## How to use
Setting up labs in your project is really simple, here's how to do it:
diff --git a/docs/guides/slash-commands/03-responding-to-slash-commands.md b/docs/guides/slash-commands/03-responding-to-slash-commands.md
index ae836768d..8ab7307d4 100644
--- a/docs/guides/slash-commands/03-responding-to-slash-commands.md
+++ b/docs/guides/slash-commands/03-responding-to-slash-commands.md
@@ -1,6 +1,6 @@
# 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.
```cs
client.InteractionCreated += Client_InteractionCreated;
@@ -13,7 +13,7 @@ private async Task Client_InteractionCreated(SocketInteraction arg)
}
```
-Now that we have the interaction event, Let's talk about the `SocketInteraction` argument. The interaction can be cast to either a `SocketSlashCommand` or a `SocketMessageComponent`. In our case we're trying to use slash commands so Let's cast it to a `SocketSlashCommand`.
+Now that we have the interaction event, let's talk about the `SocketInteraction` argument. The interaction can be cast to either a `SocketSlashCommand` or a `SocketMessageComponent`. In our case, we're trying to use slash commands so let's cast it to a `SocketSlashCommand`.
```cs
private async Task Client_InteractionCreated(SocketInteraction arg)
@@ -25,7 +25,7 @@ private async Task Client_InteractionCreated(SocketInteraction arg)
}
```
-With every type of interaction there is a `Data` field. this is where the relevant information lives about our command that was executed. In our case, `Data` is a `SocketSlashCommandData` class. In the data class, we can access the name of the command triggered as well as the options if there were any. For this example, we're just going to respond with the name of the command executed.
+With every type of interaction there is a `Data` field. This is where the relevant information lives about our command that was executed. In our case, `Data` is a `SocketSlashCommandData` instance. In the data class, we can access the name of the command triggered as well as the options if there were any. For this example, we're just going to respond with the name of the command executed.
```cs
private async Task Client_InteractionCreated(SocketInteraction arg)
@@ -45,6 +45,6 @@ Let's try this out!
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 `ChannelMessageWithSource` or you can choose to send a deferred response with `DeferredChannelMessageWithSource`. 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 Edit Original Interaction Response. You can read more about Response types [here](https://discord.com/developers/docs/interactions/slash-commands#interaction-response)
+> After receiving an interaction, you must respond to acknowledge it. You can choose to respond with a message immediately using `ChannelMessageWithSource` or you can choose to send a deferred response with `DeferredChannelMessageWithSource`. 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 Edit Original Interaction Response. 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.
diff --git a/docs/guides/slash-commands/06-subcommands.md b/docs/guides/slash-commands/06-subcommands.md
index c4481bfd8..54ff03cdc 100644
--- a/docs/guides/slash-commands/06-subcommands.md
+++ b/docs/guides/slash-commands/06-subcommands.md
@@ -1,6 +1,6 @@
# Subcommands
-Sub commands 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 sub commands 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.
- An app can have up to 25 subcommand groups on a top-level command
- An app can have up to 25 subcommands within a subcommand group
@@ -59,7 +59,7 @@ command
|__ subcommand-group
```
-Let's write a settings command that can change 2 fields in our bot.
+Let's write a settings command that can change 3 fields in our bot.
```cs
public string FieldA { get; set; } = "test";
@@ -132,7 +132,7 @@ public async Task Client_Ready()
All that code generates a command that looks like this:

-Now that we have our command made, we need to handle the multiple options with this command. so lets add this into our handler
+Now that we have our command made, we need to handle the multiple options with this command. So lets add this into our handler:
```cs
private async Task Client_InteractionCreated(SocketInteraction arg)
@@ -157,7 +157,7 @@ private async Task HandleSettingsCommand(SocketSlashCommand command)
// First lets extract our variables
var fieldName = command.Data.Options.First().Name;
var getOrSet = command.Data.Options.First().Options.First().Name;
- // since there is no value on a get command, we use the ? operator because "Options" can be null.
+ // Since there is no value on a get command, we use the ? operator because "Options" can be null.
var value = command.Data.Options.First().Options.First().Options?.FirstOrDefault().Value;
switch (fieldName)
@@ -206,11 +206,11 @@ private async Task HandleSettingsCommand(SocketSlashCommand command)
```
-Now, let't try this out! Running the 3 get commands seems to get the default values we set.
+Now, let's try this out! Running the 3 get commands seems to get the default values we set.

-Now lets try changing each to a different value.
+Now let's try changing each to a different value.

diff --git a/docs/guides/slash-commands/07-choice-slash-command.md b/docs/guides/slash-commands/07-choice-slash-command.md
index 4dbb7b7d3..53cccb39e 100644
--- a/docs/guides/slash-commands/07-choice-slash-command.md
+++ b/docs/guides/slash-commands/07-choice-slash-command.md
@@ -1,8 +1,8 @@
# Slash Command Choices.
-With slash command options you can add choices, making the user select between some set values. Lets create a command that ask 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!
-Lets set up our slash command:
+Let's set up our slash command:
```cs
private async Task Client_Ready()
@@ -78,6 +78,6 @@ private async Task HandleFeedbackCommand(SocketSlashCommand command)
}
```
-And this is the result!
+And this is the result:

diff --git a/docs/guides/slash-commands/README.md b/docs/guides/slash-commands/README.md
index e69de29bb..702aec6de 100644
--- a/docs/guides/slash-commands/README.md
+++ b/docs/guides/slash-commands/README.md
@@ -0,0 +1,11 @@
+## Slash command guides
+
+Here you can find some guides on how to use slash commands.
+
+1. [Getting started](https://github.com/Discord-Net-Labs/Discord.Net-Labs/blob/Interactions/docs/guides/slash-commands/01-getting-started.md)
+2. [Creating a slash command](https://github.com/Discord-Net-Labs/Discord.Net-Labs/blob/Interactions/docs/guides/slash-commands/02-creating-slash-commands.md)
+3. [Responding to slash commands](https://github.com/Discord-Net-Labs/Discord.Net-Labs/blob/Interactions/docs/guides/slash-commands/03-responding-to-slash-commands.md)
+4. [Parameters in slash commands](https://github.com/Discord-Net-Labs/Discord.Net-Labs/blob/Interactions/docs/guides/slash-commands/04-parameters.md)
+5. [Responding ephemerally](https://github.com/Discord-Net-Labs/Discord.Net-Labs/blob/Interactions/docs/guides/slash-commands/05-responding-ephemerally.md)
+6. [Subcommands](https://github.com/Discord-Net-Labs/Discord.Net-Labs/blob/Interactions/docs/guides/slash-commands/06-subcommands.md)
+7. [Choices](https://github.com/Discord-Net-Labs/Discord.Net-Labs/blob/Interactions/docs/guides/slash-commands/07-choice-slash-command.md)
diff --git a/src/Discord.Net.Rest/Discord.Net.Rest.xml b/src/Discord.Net.Rest/Discord.Net.Rest.xml
index 5a70ac05f..da7b42842 100644
--- a/src/Discord.Net.Rest/Discord.Net.Rest.xml
+++ b/src/Discord.Net.Rest/Discord.Net.Rest.xml
@@ -2740,6 +2740,15 @@
+
+
+ Deletes all slash commands in the current guild.
+
+ The options to be used when sending the request.
+
+ A task that represents the asynchronous delete operation.
+
+
Gets a collection of slash commands created by the current user in this guild.
diff --git a/src/Discord.Net.Rest/DiscordRestClient.cs b/src/Discord.Net.Rest/DiscordRestClient.cs
index 0f93c3f65..a8849525e 100644
--- a/src/Discord.Net.Rest/DiscordRestClient.cs
+++ b/src/Discord.Net.Rest/DiscordRestClient.cs
@@ -125,7 +125,8 @@ namespace Discord.Rest
=> InteractionHelper.BulkOverwriteGuildCommands(this, guildId, commandProperties, options);
public Task> BatchEditGuildCommandPermissions(ulong guildId, IDictionary permissions, RequestOptions options = null)
=> InteractionHelper.BatchEditGuildCommandPermissionsAsync(this, guildId, permissions, options);
-
+ public Task DeleteAllGlobalCommandsAsync(RequestOptions options = null)
+ => InteractionHelper.DeleteAllGlobalCommandsAsync(this, options);
public Task AddRoleAsync(ulong guildId, ulong userId, ulong roleId)
=> ClientHelper.AddRoleAsync(this, guildId, userId, roleId);
diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
index 6c561002e..37491909c 100644
--- a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
+++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
@@ -256,6 +256,16 @@ namespace Discord.Rest
=> GuildHelper.LeaveAsync(this, Discord, options);
//Interactions
+ ///
+ /// Deletes all slash commands in the current guild.
+ ///
+ /// The options to be used when sending the request.
+ ///
+ /// A task that represents the asynchronous delete operation.
+ ///
+ public Task DeleteSlashCommandsAsync(RequestOptions options = null)
+ => InteractionHelper.DeleteAllGuildCommandsAsync(Discord, this.Id, options);
+
///
/// Gets a collection of slash commands created by the current user in this guild.
///
diff --git a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs
index 38ba94275..22f12ff48 100644
--- a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs
+++ b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs
@@ -11,6 +11,16 @@ namespace Discord.Rest
{
internal static class InteractionHelper
{
+ public static Task DeleteAllGuildCommandsAsync(BaseDiscordClient client, ulong guildId, RequestOptions options = null)
+ {
+ return client.ApiClient.BulkOverwriteGuildApplicationCommands(guildId, new CreateApplicationCommandParams[0], options);
+ }
+
+ public static Task DeleteAllGlobalCommandsAsync(BaseDiscordClient client, RequestOptions options = null)
+ {
+ return client.ApiClient.BulkOverwriteGlobalApplicationCommands(new CreateApplicationCommandParams[0], options);
+ }
+
public static Task SendInteractionResponse(BaseDiscordClient client, IMessageChannel channel, InteractionResponse response,
ulong interactionId, string interactionToken, RequestOptions options = null)
{
@@ -348,7 +358,7 @@ namespace Discord.Rest
return new GuildApplicationCommandPermission(model.Id, model.ApplicationId, guildId, model.Permissions.Select(
y => new ApplicationCommandPermission(y.Id, y.Type, y.Permission)).ToArray());
}
- catch(HttpException x)
+ catch (HttpException x)
{
if (x.HttpCode == System.Net.HttpStatusCode.NotFound)
return null;
@@ -365,7 +375,7 @@ namespace Discord.Rest
List models = new List();
- foreach(var arg in args)
+ foreach (var arg in args)
{
var model = new ApplicationCommandPermissions()
{
@@ -391,7 +401,7 @@ namespace Discord.Rest
List models = new List();
- foreach(var arg in args)
+ foreach (var arg in args)
{
Preconditions.AtMost(arg.Value.Length, 10, nameof(args));
diff --git a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml
index 344d7ab20..9df04c8a5 100644
--- a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml
+++ b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml
@@ -2843,6 +2843,15 @@
voice regions the guild can access.
+
+
+ Deletes all slash commands in the current guild.
+
+ The options to be used when sending the request.
+
+ A task that represents the asynchronous delete operation.
+
+
Gets a collection of slash commands created by the current user in this guild.
diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
index ef4e87305..e8748dda9 100644
--- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
+++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
@@ -724,6 +724,16 @@ namespace Discord.WebSocket
=> GuildHelper.CreateIntegrationAsync(this, Discord, id, type, options);
//Interactions
+ ///
+ /// Deletes all slash commands in the current guild.
+ ///
+ /// The options to be used when sending the request.
+ ///
+ /// A task that represents the asynchronous delete operation.
+ ///
+ public Task DeleteSlashCommandsAsync(RequestOptions options = null)
+ => InteractionHelper.DeleteAllGuildCommandsAsync(Discord, this.Id, options);
+
///
/// Gets a collection of slash commands created by the current user in this guild.
///
@@ -823,7 +833,7 @@ namespace Discord.WebSocket
if (_roles.TryGetValue(model.Id, out SocketRole role))
_roles[model.Id].Update(this.Discord.State, model);
else
- role = AddRole(model);
+ role = AddRole(model);
return role;
}
@@ -1289,7 +1299,7 @@ namespace Discord.WebSocket
Task> IGuild.GetVoiceChannelsAsync(CacheMode mode, RequestOptions options)
=> Task.FromResult>(VoiceChannels);
///
- Task> IGuild.GetCategoriesAsync(CacheMode mode , RequestOptions options)
+ Task> IGuild.GetCategoriesAsync(CacheMode mode, RequestOptions options)
=> Task.FromResult>(CategoryChannels);
///
Task IGuild.GetVoiceChannelAsync(ulong id, CacheMode mode, RequestOptions options)