diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index 09d284785..6a5daaf8d 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -1142,8 +1142,13 @@ namespace Discord.API Preconditions.NotNull(command, nameof(command)); Preconditions.AtMost(command.Name.Length, 32, nameof(command.Name)); Preconditions.AtLeast(command.Name.Length, 3, nameof(command.Name)); - Preconditions.AtMost(command.Description.Length, 100, nameof(command.Description)); - Preconditions.AtLeast(command.Description.Length, 1, nameof(command.Description)); + + if (command.Type == ApplicationCommandType.Slash) + { + Preconditions.NotNullOrEmpty(command.Description, nameof(command.Description)); + Preconditions.AtMost(command.Description.Length, 100, nameof(command.Description)); + Preconditions.AtLeast(command.Description.Length, 1, nameof(command.Description)); + } options = RequestOptions.CreateOrClone(options); @@ -1180,40 +1185,6 @@ namespace Discord.API return await TrySendApplicationCommand(SendJsonAsync("PUT", () => $"applications/{this.CurrentUserId}/commands", commands, new BucketIds(), options: options)).ConfigureAwait(false); } - public async Task CreateGlobalApplicationUserCommandAsync(CreateApplicationCommandParams command, RequestOptions options = null) - { - Preconditions.NotNull(command, nameof(command)); - Preconditions.AtMost(command.Name.Length, 32, nameof(command.Name)); - Preconditions.AtLeast(command.Name.Length, 3, nameof(command.Name)); - - options = RequestOptions.CreateOrClone(options); - - return await TrySendApplicationCommand(SendJsonAsync("POST", () => $"applications/{this.CurrentUserId}/commands", command, new BucketIds(), options: options)).ConfigureAwait(false); - } - public async Task CreateGlobalApplicationMessageCommandAsync(CreateApplicationCommandParams command, RequestOptions options = null) - { - Preconditions.NotNull(command, nameof(command)); - Preconditions.AtMost(command.Name.Length, 32, nameof(command.Name)); - Preconditions.AtLeast(command.Name.Length, 3, nameof(command.Name)); - - options = RequestOptions.CreateOrClone(options); - - return await TrySendApplicationCommand(SendJsonAsync("POST", () => $"applications/{this.CurrentUserId}/commands", command, new BucketIds(), options: options)).ConfigureAwait(false); - } - - public async Task BulkOverwriteGlobalApplicationUserCommands(CreateApplicationCommandParams[] commands, RequestOptions options = null) - { - options = RequestOptions.CreateOrClone(options); - - return await TrySendApplicationCommand(SendJsonAsync("PUT", () => $"applications/{this.CurrentUserId}/commands", commands, new BucketIds(), options: options)).ConfigureAwait(false); - } - - public async Task BulkOverwriteGlobalApplicationMessageCommands(CreateApplicationCommandParams[] commands, RequestOptions options = null) - { - options = RequestOptions.CreateOrClone(options); - - return await TrySendApplicationCommand(SendJsonAsync("PUT", () => $"applications/{this.CurrentUserId}/commands", commands, new BucketIds(), options: options)).ConfigureAwait(false); - } public async Task GetGuildApplicationCommandsAsync(ulong guildId, RequestOptions options = null) { @@ -1239,6 +1210,17 @@ namespace Discord.API public async Task CreateGuildApplicationCommandAsync(CreateApplicationCommandParams command, ulong guildId, RequestOptions options = null) { + Preconditions.NotNull(command, nameof(command)); + Preconditions.AtMost(command.Name.Length, 32, nameof(command.Name)); + Preconditions.AtLeast(command.Name.Length, 3, nameof(command.Name)); + + if (command.Type == ApplicationCommandType.Slash) + { + Preconditions.NotNullOrEmpty(command.Description, nameof(command.Description)); + Preconditions.AtMost(command.Description.Length, 100, nameof(command.Description)); + Preconditions.AtLeast(command.Description.Length, 1, nameof(command.Description)); + } + options = RequestOptions.CreateOrClone(options); var bucket = new BucketIds(guildId: guildId);