diff --git a/README.md b/README.md index 581c9eecd..dceb2a7a8 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ 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 +If this projects benefits you (*and your financially stable*) consider donating or becoming a sponsor as it really helps out! + ## Known issues 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. diff --git a/docs/guides/interactions/application-commands/slash-commands/02-creating-slash-commands.md b/docs/guides/interactions/application-commands/slash-commands/02-creating-slash-commands.md index 6e4892122..830c52aa5 100644 --- a/docs/guides/interactions/application-commands/slash-commands/02-creating-slash-commands.md +++ b/docs/guides/interactions/application-commands/slash-commands/02-creating-slash-commands.md @@ -12,6 +12,8 @@ Guild commands are specific to the guild you specify when making them. Guild com **Note**: Apps can have a maximum of 100 global commands, and an additional 100 guild-specific commands per guild. +**Note**: Global commands will take up to 1 hour to create, delete or modify on guilds. If you need to update a command quickly for testing you can create it as a guild command. + If you don't have the code for a bot ready yet please follow [this guide](https://docs.stillu.cc/guides/getting_started/first-bot.html). ## SlashCommandBuilder diff --git a/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandProperties.cs b/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandProperties.cs index 2ccb0148b..55c91bc64 100644 --- a/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandProperties.cs +++ b/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandProperties.cs @@ -18,6 +18,11 @@ namespace Discord /// public Optional Name { get; set; } + /// + /// Whether the command is enabled by default when the app is added to a guild. Default is + /// + public Optional DefaultPermission { get; set; } + internal ApplicationCommandProperties() { } } } diff --git a/src/Discord.Net.Core/Entities/Interactions/Context Menus/MessageCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/Context Menus/MessageCommandBuilder.cs index 801aca302..ce9c75452 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Context Menus/MessageCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Context Menus/MessageCommandBuilder.cs @@ -36,6 +36,11 @@ namespace Discord } } + /// + /// Whether the command is enabled by default when the app is added to a guild + /// + public bool DefaultPermission { get; set; } = true; + private string _name { get; set; } /// @@ -49,6 +54,7 @@ namespace Discord MessageCommandProperties props = new MessageCommandProperties() { Name = this.Name, + DefaultPermission = this.DefaultPermission }; return props; @@ -66,6 +72,17 @@ namespace Discord { this.Name = name; return this; - } + } + + /// + /// Sets the default permission of the current command. + /// + /// The default permission value to set. + /// The current builder. + public MessageCommandBuilder WithDefaultPermission (bool value) + { + this.DefaultPermission = value; + return this; + } } } diff --git a/src/Discord.Net.Core/Entities/Interactions/Context Menus/UserCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/Context Menus/UserCommandBuilder.cs index 5629a7014..a49250d08 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Context Menus/UserCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Context Menus/UserCommandBuilder.cs @@ -36,6 +36,11 @@ namespace Discord } } + /// + /// Whether the command is enabled by default when the app is added to a guild + /// + public bool DefaultPermission { get; set; } = true; + private string _name { get; set; } /// @@ -47,6 +52,7 @@ namespace Discord UserCommandProperties props = new UserCommandProperties() { Name = this.Name, + DefaultPermission = this.DefaultPermission }; return props; @@ -64,6 +70,17 @@ namespace Discord { this.Name = name; return this; - } + } + + /// + /// Sets the default permission of the current command. + /// + /// The default permission value to set. + /// The current builder. + public UserCommandBuilder WithDefaultPermission (bool value) + { + this.DefaultPermission = value; + return this; + } } } diff --git a/src/Discord.Net.Core/Entities/Interactions/SlashCommandProperties.cs b/src/Discord.Net.Core/Entities/Interactions/SlashCommandProperties.cs index 72c7c322b..e9b7222d4 100644 --- a/src/Discord.Net.Core/Entities/Interactions/SlashCommandProperties.cs +++ b/src/Discord.Net.Core/Entities/Interactions/SlashCommandProperties.cs @@ -22,11 +22,6 @@ namespace Discord /// public Optional> Options { get; set; } - /// - /// Whether the command is enabled by default when the app is added to a guild. Default is - /// - public Optional DefaultPermission { get; set; } - internal SlashCommandProperties() { } } } diff --git a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs index a6d8c524b..8bc87339e 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs @@ -68,6 +68,9 @@ namespace Discord.Rest { Name = arg.Name.Value, Type = arg.Type, + DefaultPermission = arg.DefaultPermission.IsSpecified + ? arg.DefaultPermission.Value + : Optional.Unspecified }; if (arg is SlashCommandProperties slashProps) @@ -79,10 +82,6 @@ namespace Discord.Rest model.Options = slashProps.Options.IsSpecified ? slashProps.Options.Value.Select(x => new Discord.API.ApplicationCommandOption(x)).ToArray() : Optional.Unspecified; - - model.DefaultPermission = slashProps.DefaultPermission.IsSpecified - ? slashProps.DefaultPermission.Value - : Optional.Unspecified; } return await client.ApiClient.CreateGlobalApplicationCommandAsync(model, options).ConfigureAwait(false); @@ -103,6 +102,9 @@ namespace Discord.Rest { Name = arg.Name.Value, Type = arg.Type, + DefaultPermission = arg.DefaultPermission.IsSpecified + ? arg.DefaultPermission.Value + : Optional.Unspecified }; if (arg is SlashCommandProperties slashProps) @@ -114,10 +116,6 @@ namespace Discord.Rest model.Options = slashProps.Options.IsSpecified ? slashProps.Options.Value.Select(x => new Discord.API.ApplicationCommandOption(x)).ToArray() : Optional.Unspecified; - - model.DefaultPermission = slashProps.DefaultPermission.IsSpecified - ? slashProps.DefaultPermission.Value - : Optional.Unspecified; } models.Add(model); @@ -141,6 +139,9 @@ namespace Discord.Rest { Name = arg.Name.Value, Type = arg.Type, + DefaultPermission = arg.DefaultPermission.IsSpecified + ? arg.DefaultPermission.Value + : Optional.Unspecified }; if (arg is SlashCommandProperties slashProps) @@ -152,10 +153,6 @@ namespace Discord.Rest model.Options = slashProps.Options.IsSpecified ? slashProps.Options.Value.Select(x => new Discord.API.ApplicationCommandOption(x)).ToArray() : Optional.Unspecified; - - model.DefaultPermission = slashProps.DefaultPermission.IsSpecified - ? slashProps.DefaultPermission.Value - : Optional.Unspecified; } models.Add(model); @@ -202,6 +199,9 @@ namespace Discord.Rest var model = new Discord.API.Rest.ModifyApplicationCommandParams() { Name = args.Name, + DefaultPermission = args.DefaultPermission.IsSpecified + ? args.DefaultPermission.Value + : Optional.Unspecified }; if(args is SlashCommandProperties slashProps) @@ -223,10 +223,6 @@ namespace Discord.Rest model.Options = slashProps.Options.IsSpecified ? slashProps.Options.Value.Select(x => new Discord.API.ApplicationCommandOption(x)).ToArray() : Optional.Unspecified; - - model.DefaultPermission = slashProps.DefaultPermission.IsSpecified - ? slashProps.DefaultPermission.Value - : Optional.Unspecified; } return await client.ApiClient.ModifyGlobalApplicationCommandAsync(model, command.Id, options).ConfigureAwait(false); @@ -257,6 +253,9 @@ namespace Discord.Rest { Name = arg.Name.Value, Type = arg.Type, + DefaultPermission = arg.DefaultPermission.IsSpecified + ? arg.DefaultPermission.Value + : Optional.Unspecified }; if (arg is SlashCommandProperties slashProps) @@ -268,10 +267,6 @@ namespace Discord.Rest model.Options = slashProps.Options.IsSpecified ? slashProps.Options.Value.Select(x => new Discord.API.ApplicationCommandOption(x)).ToArray() : Optional.Unspecified; - - model.DefaultPermission = slashProps.DefaultPermission.IsSpecified - ? slashProps.DefaultPermission.Value - : Optional.Unspecified; } return await client.ApiClient.CreateGuildApplicationCommandAsync(model, guildId, options).ConfigureAwait(false); @@ -291,6 +286,9 @@ namespace Discord.Rest var model = new ModifyApplicationCommandParams() { Name = arg.Name, + DefaultPermission = arg.DefaultPermission.IsSpecified + ? arg.DefaultPermission.Value + : Optional.Unspecified }; if (arg is SlashCommandProperties slashProps) @@ -302,10 +300,6 @@ namespace Discord.Rest model.Options = slashProps.Options.IsSpecified ? slashProps.Options.Value.Select(x => new Discord.API.ApplicationCommandOption(x)).ToArray() : Optional.Unspecified; - - model.DefaultPermission = slashProps.DefaultPermission.IsSpecified - ? slashProps.DefaultPermission.Value - : Optional.Unspecified; } return await client.ApiClient.ModifyGuildApplicationCommandAsync(model, guildId, command.Id, options).ConfigureAwait(false);