| @@ -1147,7 +1147,7 @@ namespace Discord | |||||
| /// A task that represents the asynchronous get operation. The task result contains a read-only collection | /// A task that represents the asynchronous get operation. The task result contains a read-only collection | ||||
| /// of application commands found within the guild. | /// of application commands found within the guild. | ||||
| /// </returns> | /// </returns> | ||||
| Task<IReadOnlyCollection<IApplicationCommand>> GetApplicationCommandsAsync(RequestOptions options = null); | |||||
| Task<IReadOnlyCollection<IApplicationCommand>> GetApplicationCommandsAsync(bool withLocalizations = false, RequestOptions options = null); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets an application command within this guild with the specified id. | /// Gets an application command within this guild with the specified id. | ||||
| @@ -34,18 +34,7 @@ namespace Discord | |||||
| get => _name; | get => _name; | ||||
| set | set | ||||
| { | { | ||||
| Preconditions.NotNullOrEmpty(value, nameof(value)); | |||||
| Preconditions.AtLeast(value.Length, 1, nameof(value)); | |||||
| Preconditions.AtMost(value.Length, MaxNameLength, nameof(value)); | |||||
| // Discord updated the docs, this regex prevents special characters like @!$%(... etc, | |||||
| // https://discord.com/developers/docs/interactions/slash-commands#applicationcommand | |||||
| if (!Regex.IsMatch(value, @"^[\w-]{1,32}$")) | |||||
| throw new ArgumentException("Command name cannot contain any special characters or whitespaces!", nameof(value)); | |||||
| if (value.Any(x => char.IsUpper(x))) | |||||
| throw new FormatException("Name cannot contain any uppercase characters."); | |||||
| EnsureValidCommandName(value); | |||||
| _name = value; | _name = value; | ||||
| } | } | ||||
| } | } | ||||
| @@ -58,10 +47,7 @@ namespace Discord | |||||
| get => _description; | get => _description; | ||||
| set | set | ||||
| { | { | ||||
| Preconditions.NotNullOrEmpty(value, nameof(Description)); | |||||
| Preconditions.AtLeast(value.Length, 1, nameof(Description)); | |||||
| Preconditions.AtMost(value.Length, MaxDescriptionLength, nameof(Description)); | |||||
| EnsureValidCommandDescription(value); | |||||
| _description = value; | _description = value; | ||||
| } | } | ||||
| } | } | ||||
| @@ -268,10 +254,7 @@ namespace Discord | |||||
| if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) | if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) | ||||
| throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); | throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); | ||||
| Preconditions.AtLeast(name.Length, 1, nameof(name)); | |||||
| Preconditions.AtMost(name.Length, SlashCommandBuilder.MaxNameLength, nameof(name)); | |||||
| if (!Regex.IsMatch(name, @"^[\w-]{1,32}$")) | |||||
| throw new ArgumentException("Option name cannot contain any special characters or whitespaces!", nameof(name)); | |||||
| EnsureValidCommandName(name); | |||||
| } | } | ||||
| _nameLocalizations = new Dictionary<string, string>(nameLocalizations); | _nameLocalizations = new Dictionary<string, string>(nameLocalizations); | ||||
| @@ -288,8 +271,7 @@ namespace Discord | |||||
| if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) | if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) | ||||
| throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); | throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); | ||||
| Preconditions.AtLeast(description.Length, 1, nameof(description)); | |||||
| Preconditions.AtMost(description.Length, SlashCommandBuilder.MaxDescriptionLength, nameof(description)); | |||||
| EnsureValidCommandDescription(description); | |||||
| } | } | ||||
| _descriptionLocalizations = new Dictionary<string, string>(descriptionLocalizations); | _descriptionLocalizations = new Dictionary<string, string>(descriptionLocalizations); | ||||
| @@ -301,12 +283,9 @@ namespace Discord | |||||
| if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) | if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) | ||||
| throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); | throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); | ||||
| Preconditions.AtLeast(name.Length, 1, nameof(name)); | |||||
| Preconditions.AtMost(name.Length, SlashCommandBuilder.MaxNameLength, nameof(name)); | |||||
| if (!Regex.IsMatch(name, @"^[\w-]{1,32}$")) | |||||
| throw new ArgumentException("Option name cannot contain any special characters or whitespaces!", nameof(name)); | |||||
| EnsureValidCommandName(name); | |||||
| _descriptionLocalizations ??= new(); | |||||
| _nameLocalizations ??= new(); | |||||
| _nameLocalizations.Add(locale, name); | _nameLocalizations.Add(locale, name); | ||||
| return this; | return this; | ||||
| @@ -317,14 +296,35 @@ namespace Discord | |||||
| if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) | if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) | ||||
| throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); | throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); | ||||
| Preconditions.AtLeast(description.Length, 1, nameof(description)); | |||||
| Preconditions.AtMost(description.Length, SlashCommandBuilder.MaxDescriptionLength, nameof(description)); | |||||
| EnsureValidCommandDescription(description); | |||||
| _descriptionLocalizations ??= new(); | _descriptionLocalizations ??= new(); | ||||
| _descriptionLocalizations.Add(locale, description); | _descriptionLocalizations.Add(locale, description); | ||||
| return this; | return this; | ||||
| } | } | ||||
| internal static void EnsureValidCommandName(string name) | |||||
| { | |||||
| Preconditions.NotNullOrEmpty(name, nameof(name)); | |||||
| Preconditions.AtLeast(name.Length, 1, nameof(name)); | |||||
| Preconditions.AtMost(name.Length, MaxNameLength, nameof(name)); | |||||
| // Discord updated the docs, this regex prevents special characters like @!$%(... etc, | |||||
| // https://discord.com/developers/docs/interactions/slash-commands#applicationcommand | |||||
| if (!Regex.IsMatch(name, @"^[\w-]{1,32}$")) | |||||
| throw new ArgumentException("Command name cannot contain any special characters or whitespaces!", nameof(name)); | |||||
| if (name.Any(x => char.IsUpper(x))) | |||||
| throw new FormatException("Name cannot contain any uppercase characters."); | |||||
| } | |||||
| internal static void EnsureValidCommandDescription(string description) | |||||
| { | |||||
| Preconditions.NotNullOrEmpty(description, nameof(description)); | |||||
| Preconditions.AtLeast(description.Length, 1, nameof(description)); | |||||
| Preconditions.AtMost(description.Length, MaxDescriptionLength, nameof(description)); | |||||
| } | |||||
| } | } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -357,10 +357,7 @@ namespace Discord | |||||
| { | { | ||||
| if (value != null) | if (value != null) | ||||
| { | { | ||||
| Preconditions.AtLeast(value.Length, 1, nameof(value)); | |||||
| Preconditions.AtMost(value.Length, SlashCommandBuilder.MaxNameLength, nameof(value)); | |||||
| if (!Regex.IsMatch(value, @"^[\w-]{1,32}$")) | |||||
| throw new ArgumentException("Option name cannot contain any special characters or whitespaces!", nameof(value)); | |||||
| EnsureValidCommandOptionName(value); | |||||
| } | } | ||||
| _name = value; | _name = value; | ||||
| @@ -377,8 +374,7 @@ namespace Discord | |||||
| { | { | ||||
| if (value != null) | if (value != null) | ||||
| { | { | ||||
| Preconditions.AtLeast(value.Length, 1, nameof(value)); | |||||
| Preconditions.AtMost(value.Length, SlashCommandBuilder.MaxDescriptionLength, nameof(value)); | |||||
| EnsureValidCommandOptionDescription(value); | |||||
| } | } | ||||
| _description = value; | _description = value; | ||||
| @@ -752,10 +748,7 @@ namespace Discord | |||||
| if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) | if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) | ||||
| throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); | throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); | ||||
| Preconditions.AtLeast(name.Length, 1, nameof(name)); | |||||
| Preconditions.AtMost(name.Length, SlashCommandBuilder.MaxNameLength, nameof(name)); | |||||
| if (!Regex.IsMatch(name, @"^[\w-]{1,32}$")) | |||||
| throw new ArgumentException("Option name cannot contain any special characters or whitespaces!", nameof(name)); | |||||
| EnsureValidCommandOptionName(name); | |||||
| } | } | ||||
| _nameLocalizations = new Dictionary<string, string>(nameLocalizations); | _nameLocalizations = new Dictionary<string, string>(nameLocalizations); | ||||
| @@ -772,8 +765,7 @@ namespace Discord | |||||
| if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) | if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) | ||||
| throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); | throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); | ||||
| Preconditions.AtLeast(description.Length, 1, nameof(description)); | |||||
| Preconditions.AtMost(description.Length, SlashCommandBuilder.MaxDescriptionLength, nameof(description)); | |||||
| EnsureValidCommandOptionDescription(description); | |||||
| } | } | ||||
| _descriptionLocalizations = new Dictionary<string, string>(descriptionLocalizations); | _descriptionLocalizations = new Dictionary<string, string>(descriptionLocalizations); | ||||
| @@ -785,10 +777,7 @@ namespace Discord | |||||
| if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) | if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) | ||||
| throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); | throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); | ||||
| Preconditions.AtLeast(name.Length, 1, nameof(name)); | |||||
| Preconditions.AtMost(name.Length, SlashCommandBuilder.MaxNameLength, nameof(name)); | |||||
| if (!Regex.IsMatch(name, @"^[\w-]{1,32}$")) | |||||
| throw new ArgumentException("Option name cannot contain any special characters or whitespaces!", nameof(name)); | |||||
| EnsureValidCommandOptionName(name); | |||||
| _descriptionLocalizations ??= new(); | _descriptionLocalizations ??= new(); | ||||
| _nameLocalizations.Add(locale, name); | _nameLocalizations.Add(locale, name); | ||||
| @@ -801,13 +790,26 @@ namespace Discord | |||||
| if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) | if(!Regex.IsMatch(locale, @"^\w{2}(?:-\w{2})?$")) | ||||
| throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); | throw new ArgumentException($"Invalid locale: {locale}", nameof(locale)); | ||||
| Preconditions.AtLeast(description.Length, 1, nameof(description)); | |||||
| Preconditions.AtMost(description.Length, SlashCommandBuilder.MaxDescriptionLength, nameof(description)); | |||||
| EnsureValidCommandOptionDescription(description); | |||||
| _descriptionLocalizations ??= new(); | _descriptionLocalizations ??= new(); | ||||
| _descriptionLocalizations.Add(locale, description); | _descriptionLocalizations.Add(locale, description); | ||||
| return this; | return this; | ||||
| } | } | ||||
| private static void EnsureValidCommandOptionName(string name) | |||||
| { | |||||
| Preconditions.AtLeast(name.Length, 1, nameof(name)); | |||||
| Preconditions.AtMost(name.Length, SlashCommandBuilder.MaxNameLength, nameof(name)); | |||||
| if (!Regex.IsMatch(name, @"^[\w-]{1,32}$")) | |||||
| throw new ArgumentException("Option name cannot contain any special characters or whitespaces!", nameof(name)); | |||||
| } | |||||
| private static void EnsureValidCommandOptionDescription(string description) | |||||
| { | |||||
| Preconditions.AtLeast(description.Length, 1, nameof(description)); | |||||
| Preconditions.AtMost(description.Length, SlashCommandBuilder.MaxDescriptionLength, nameof(description)); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -160,7 +160,7 @@ namespace Discord | |||||
| /// A task that represents the asynchronous get operation. The task result contains a read-only collection of global | /// A task that represents the asynchronous get operation. The task result contains a read-only collection of global | ||||
| /// application commands. | /// application commands. | ||||
| /// </returns> | /// </returns> | ||||
| Task<IReadOnlyCollection<IApplicationCommand>> GetGlobalApplicationCommandsAsync(RequestOptions options = null); | |||||
| Task<IReadOnlyCollection<IApplicationCommand>> GetGlobalApplicationCommandsAsync(bool withLocalizations = false, RequestOptions options = null); | |||||
| /// <summary> | /// <summary> | ||||
| /// Creates a global application command. | /// Creates a global application command. | ||||
| @@ -241,7 +241,7 @@ namespace Discord.Rest | |||||
| => Task.FromResult<IApplicationCommand>(null); | => Task.FromResult<IApplicationCommand>(null); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| Task<IReadOnlyCollection<IApplicationCommand>> IDiscordClient.GetGlobalApplicationCommandsAsync(RequestOptions options) | |||||
| Task<IReadOnlyCollection<IApplicationCommand>> IDiscordClient.GetGlobalApplicationCommandsAsync(bool withLocalizations, RequestOptions options) | |||||
| => Task.FromResult<IReadOnlyCollection<IApplicationCommand>>(ImmutableArray.Create<IApplicationCommand>()); | => Task.FromResult<IReadOnlyCollection<IApplicationCommand>>(ImmutableArray.Create<IApplicationCommand>()); | ||||
| Task<IApplicationCommand> IDiscordClient.CreateGlobalApplicationCommand(ApplicationCommandProperties properties, RequestOptions options) | Task<IApplicationCommand> IDiscordClient.CreateGlobalApplicationCommand(ApplicationCommandProperties properties, RequestOptions options) | ||||
| => Task.FromResult<IApplicationCommand>(null); | => Task.FromResult<IApplicationCommand>(null); | ||||
| @@ -255,6 +255,6 @@ namespace Discord.Rest | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| Task IDiscordClient.StopAsync() | Task IDiscordClient.StopAsync() | ||||
| => Task.Delay(0); | => Task.Delay(0); | ||||
| #endregion | |||||
| #endregion | |||||
| } | } | ||||
| } | } | ||||
| @@ -194,10 +194,10 @@ namespace Discord.Rest | |||||
| }; | }; | ||||
| } | } | ||||
| public static async Task<IReadOnlyCollection<RestGlobalCommand>> GetGlobalApplicationCommandsAsync(BaseDiscordClient client, | |||||
| public static async Task<IReadOnlyCollection<RestGlobalCommand>> GetGlobalApplicationCommandsAsync(BaseDiscordClient client, bool withLocalizations = false, | |||||
| RequestOptions options = null) | RequestOptions options = null) | ||||
| { | { | ||||
| var response = await client.ApiClient.GetGlobalApplicationCommandsAsync(options).ConfigureAwait(false); | |||||
| var response = await client.ApiClient.GetGlobalApplicationCommandsAsync(withLocalizations, options).ConfigureAwait(false); | |||||
| if (!response.Any()) | if (!response.Any()) | ||||
| return Array.Empty<RestGlobalCommand>(); | return Array.Empty<RestGlobalCommand>(); | ||||
| @@ -212,10 +212,10 @@ namespace Discord.Rest | |||||
| return model != null ? RestGlobalCommand.Create(client, model) : null; | return model != null ? RestGlobalCommand.Create(client, model) : null; | ||||
| } | } | ||||
| public static async Task<IReadOnlyCollection<RestGuildCommand>> GetGuildApplicationCommandsAsync(BaseDiscordClient client, ulong guildId, | |||||
| public static async Task<IReadOnlyCollection<RestGuildCommand>> GetGuildApplicationCommandsAsync(BaseDiscordClient client, ulong guildId, bool withLocalizations = false, | |||||
| RequestOptions options = null) | RequestOptions options = null) | ||||
| { | { | ||||
| var response = await client.ApiClient.GetGuildApplicationCommandsAsync(guildId, options).ConfigureAwait(false); | |||||
| var response = await client.ApiClient.GetGuildApplicationCommandsAsync(guildId, withLocalizations, options).ConfigureAwait(false); | |||||
| if (!response.Any()) | if (!response.Any()) | ||||
| return ImmutableArray.Create<RestGuildCommand>(); | return ImmutableArray.Create<RestGuildCommand>(); | ||||
| @@ -1188,11 +1188,12 @@ namespace Discord.API | |||||
| #endregion | #endregion | ||||
| #region Interactions | #region Interactions | ||||
| public async Task<ApplicationCommand[]> GetGlobalApplicationCommandsAsync(RequestOptions options = null) | |||||
| public async Task<ApplicationCommand[]> GetGlobalApplicationCommandsAsync(bool withLocalizations = false, RequestOptions options = null) | |||||
| { | { | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await SendAsync<ApplicationCommand[]>("GET", () => $"applications/{CurrentApplicationId}/commands", new BucketIds(), options: options).ConfigureAwait(false); | |||||
| return await SendAsync<ApplicationCommand[]>("GET", () => $"applications/{CurrentApplicationId}/commands?with_localizations={withLocalizations}", | |||||
| new BucketIds(), options: options).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<ApplicationCommand> GetGlobalApplicationCommandAsync(ulong id, RequestOptions options = null) | public async Task<ApplicationCommand> GetGlobalApplicationCommandAsync(ulong id, RequestOptions options = null) | ||||
| @@ -1257,13 +1258,14 @@ namespace Discord.API | |||||
| return await SendJsonAsync<ApplicationCommand[]>("PUT", () => $"applications/{CurrentApplicationId}/commands", commands, new BucketIds(), options: options).ConfigureAwait(false); | return await SendJsonAsync<ApplicationCommand[]>("PUT", () => $"applications/{CurrentApplicationId}/commands", commands, new BucketIds(), options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<ApplicationCommand[]> GetGuildApplicationCommandsAsync(ulong guildId, RequestOptions options = null) | |||||
| public async Task<ApplicationCommand[]> GetGuildApplicationCommandsAsync(ulong guildId, bool withLocalizations = false, RequestOptions options = null) | |||||
| { | { | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| var bucket = new BucketIds(guildId: guildId); | var bucket = new BucketIds(guildId: guildId); | ||||
| return await SendAsync<ApplicationCommand[]>("GET", () => $"applications/{CurrentApplicationId}/guilds/{guildId}/commands", bucket, options: options).ConfigureAwait(false); | |||||
| return await SendAsync<ApplicationCommand[]>("GET", () => $"applications/{CurrentApplicationId}/guilds/{guildId}/commands?with_localizations={withLocalizations}", | |||||
| bucket, options: options).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<ApplicationCommand> GetGuildApplicationCommandAsync(ulong guildId, ulong commandId, RequestOptions options = null) | public async Task<ApplicationCommand> GetGuildApplicationCommandAsync(ulong guildId, ulong commandId, RequestOptions options = null) | ||||
| @@ -1400,7 +1402,7 @@ namespace Discord.API | |||||
| throw new ArgumentException(message: $"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", paramName: nameof(args.Content)); | throw new ArgumentException(message: $"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", paramName: nameof(args.Content)); | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| var ids = new BucketIds(); | var ids = new BucketIds(); | ||||
| return await SendMultipartAsync<Message>("POST", () => $"webhooks/{CurrentApplicationId}/{token}?wait=true", args.ToDictionary(), ids, clientBucket: ClientBucketType.SendEdit, options: options).ConfigureAwait(false); | return await SendMultipartAsync<Message>("POST", () => $"webhooks/{CurrentApplicationId}/{token}?wait=true", args.ToDictionary(), ids, clientBucket: ClientBucketType.SendEdit, options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| @@ -25,7 +25,7 @@ namespace Discord.Rest | |||||
| /// Gets the logged-in user. | /// Gets the logged-in user. | ||||
| /// </summary> | /// </summary> | ||||
| public new RestSelfUser CurrentUser { get => base.CurrentUser as RestSelfUser; internal set => base.CurrentUser = value; } | public new RestSelfUser CurrentUser { get => base.CurrentUser as RestSelfUser; internal set => base.CurrentUser = value; } | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public DiscordRestClient() : this(new DiscordRestConfig()) { } | public DiscordRestClient() : this(new DiscordRestConfig()) { } | ||||
| /// <summary> | /// <summary> | ||||
| @@ -197,10 +197,10 @@ namespace Discord.Rest | |||||
| => ClientHelper.CreateGlobalApplicationCommandAsync(this, properties, options); | => ClientHelper.CreateGlobalApplicationCommandAsync(this, properties, options); | ||||
| public Task<RestGuildCommand> CreateGuildCommand(ApplicationCommandProperties properties, ulong guildId, RequestOptions options = null) | public Task<RestGuildCommand> CreateGuildCommand(ApplicationCommandProperties properties, ulong guildId, RequestOptions options = null) | ||||
| => ClientHelper.CreateGuildApplicationCommandAsync(this, guildId, properties, options); | => ClientHelper.CreateGuildApplicationCommandAsync(this, guildId, properties, options); | ||||
| public Task<IReadOnlyCollection<RestGlobalCommand>> GetGlobalApplicationCommands(RequestOptions options = null) | |||||
| => ClientHelper.GetGlobalApplicationCommandsAsync(this, options); | |||||
| public Task<IReadOnlyCollection<RestGuildCommand>> GetGuildApplicationCommands(ulong guildId, RequestOptions options = null) | |||||
| => ClientHelper.GetGuildApplicationCommandsAsync(this, guildId, options); | |||||
| public Task<IReadOnlyCollection<RestGlobalCommand>> GetGlobalApplicationCommands(bool withLocalizations = false, RequestOptions options = null) | |||||
| => ClientHelper.GetGlobalApplicationCommandsAsync(this, withLocalizations, options); | |||||
| public Task<IReadOnlyCollection<RestGuildCommand>> GetGuildApplicationCommands(ulong guildId, bool withLocalizations = false, RequestOptions options = null) | |||||
| => ClientHelper.GetGuildApplicationCommandsAsync(this, guildId, withLocalizations, options); | |||||
| public Task<IReadOnlyCollection<RestGlobalCommand>> BulkOverwriteGlobalCommands(ApplicationCommandProperties[] commandProperties, RequestOptions options = null) | public Task<IReadOnlyCollection<RestGlobalCommand>> BulkOverwriteGlobalCommands(ApplicationCommandProperties[] commandProperties, RequestOptions options = null) | ||||
| => ClientHelper.BulkOverwriteGlobalApplicationCommandAsync(this, commandProperties, options); | => ClientHelper.BulkOverwriteGlobalApplicationCommandAsync(this, commandProperties, options); | ||||
| public Task<IReadOnlyCollection<RestGuildCommand>> BulkOverwriteGuildCommands(ApplicationCommandProperties[] commandProperties, ulong guildId, RequestOptions options = null) | public Task<IReadOnlyCollection<RestGuildCommand>> BulkOverwriteGuildCommands(ApplicationCommandProperties[] commandProperties, ulong guildId, RequestOptions options = null) | ||||
| @@ -311,8 +311,8 @@ namespace Discord.Rest | |||||
| => await GetWebhookAsync(id, options).ConfigureAwait(false); | => await GetWebhookAsync(id, options).ConfigureAwait(false); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<IReadOnlyCollection<IApplicationCommand>> IDiscordClient.GetGlobalApplicationCommandsAsync(RequestOptions options) | |||||
| => await GetGlobalApplicationCommands(options).ConfigureAwait(false); | |||||
| async Task<IReadOnlyCollection<IApplicationCommand>> IDiscordClient.GetGlobalApplicationCommandsAsync(bool withLocalizations, RequestOptions options) | |||||
| => await GetGlobalApplicationCommands(withLocalizations, options).ConfigureAwait(false); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<IApplicationCommand> IDiscordClient.GetGlobalApplicationCommandAsync(ulong id, RequestOptions options) | async Task<IApplicationCommand> IDiscordClient.GetGlobalApplicationCommandAsync(ulong id, RequestOptions options) | ||||
| => await ClientHelper.GetGlobalApplicationCommandAsync(this, id, options).ConfigureAwait(false); | => await ClientHelper.GetGlobalApplicationCommandAsync(this, id, options).ConfigureAwait(false); | ||||
| @@ -317,10 +317,10 @@ namespace Discord.Rest | |||||
| #endregion | #endregion | ||||
| #region Interactions | #region Interactions | ||||
| public static async Task<IReadOnlyCollection<RestGuildCommand>> GetSlashCommandsAsync(IGuild guild, BaseDiscordClient client, | |||||
| public static async Task<IReadOnlyCollection<RestGuildCommand>> GetSlashCommandsAsync(IGuild guild, BaseDiscordClient client, bool withLocalizations, | |||||
| RequestOptions options) | RequestOptions options) | ||||
| { | { | ||||
| var models = await client.ApiClient.GetGuildApplicationCommandsAsync(guild.Id, options); | |||||
| var models = await client.ApiClient.GetGuildApplicationCommandsAsync(guild.Id, withLocalizations, options); | |||||
| return models.Select(x => RestGuildCommand.Create(client, x, guild.Id)).ToImmutableArray(); | return models.Select(x => RestGuildCommand.Create(client, x, guild.Id)).ToImmutableArray(); | ||||
| } | } | ||||
| public static async Task<RestGuildCommand> GetSlashCommandAsync(IGuild guild, ulong id, BaseDiscordClient client, | public static async Task<RestGuildCommand> GetSlashCommandAsync(IGuild guild, ulong id, BaseDiscordClient client, | ||||
| @@ -866,7 +866,7 @@ namespace Discord.Rest | |||||
| if (endTime != null && endTime <= startTime) | if (endTime != null && endTime <= startTime) | ||||
| throw new ArgumentOutOfRangeException(nameof(endTime), $"{nameof(endTime)} cannot be before the start time"); | throw new ArgumentOutOfRangeException(nameof(endTime), $"{nameof(endTime)} cannot be before the start time"); | ||||
| var apiArgs = new CreateGuildScheduledEventParams() | var apiArgs = new CreateGuildScheduledEventParams() | ||||
| { | { | ||||
| ChannelId = channelId ?? Optional<ulong>.Unspecified, | ChannelId = channelId ?? Optional<ulong>.Unspecified, | ||||
| @@ -316,8 +316,8 @@ namespace Discord.Rest | |||||
| /// A task that represents the asynchronous get operation. The task result contains a read-only collection of | /// A task that represents the asynchronous get operation. The task result contains a read-only collection of | ||||
| /// slash commands created by the current user. | /// slash commands created by the current user. | ||||
| /// </returns> | /// </returns> | ||||
| public Task<IReadOnlyCollection<RestGuildCommand>> GetSlashCommandsAsync(RequestOptions options = null) | |||||
| => GuildHelper.GetSlashCommandsAsync(this, Discord, options); | |||||
| public Task<IReadOnlyCollection<RestGuildCommand>> GetSlashCommandsAsync(bool withLocalizations = false, RequestOptions options = null) | |||||
| => GuildHelper.GetSlashCommandsAsync(this, Discord, withLocalizations, options); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets a slash command in the current guild. | /// Gets a slash command in the current guild. | ||||
| @@ -932,8 +932,8 @@ namespace Discord.Rest | |||||
| /// A task that represents the asynchronous get operation. The task result contains a read-only collection | /// A task that represents the asynchronous get operation. The task result contains a read-only collection | ||||
| /// of application commands found within the guild. | /// of application commands found within the guild. | ||||
| /// </returns> | /// </returns> | ||||
| public async Task<IReadOnlyCollection<RestGuildCommand>> GetApplicationCommandsAsync (RequestOptions options = null) | |||||
| => await ClientHelper.GetGuildApplicationCommandsAsync(Discord, Id, options).ConfigureAwait(false); | |||||
| public async Task<IReadOnlyCollection<RestGuildCommand>> GetApplicationCommandsAsync (bool withLocalizations = false, RequestOptions options = null) | |||||
| => await ClientHelper.GetGuildApplicationCommandsAsync(Discord, Id, withLocalizations, options).ConfigureAwait(false); | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets an application command within this guild with the specified id. | /// Gets an application command within this guild with the specified id. | ||||
| /// </summary> | /// </summary> | ||||
| @@ -1465,8 +1465,8 @@ namespace Discord.Rest | |||||
| async Task<IReadOnlyCollection<IWebhook>> IGuild.GetWebhooksAsync(RequestOptions options) | async Task<IReadOnlyCollection<IWebhook>> IGuild.GetWebhooksAsync(RequestOptions options) | ||||
| => await GetWebhooksAsync(options).ConfigureAwait(false); | => await GetWebhooksAsync(options).ConfigureAwait(false); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<IReadOnlyCollection<IApplicationCommand>> IGuild.GetApplicationCommandsAsync (RequestOptions options) | |||||
| => await GetApplicationCommandsAsync(options).ConfigureAwait(false); | |||||
| async Task<IReadOnlyCollection<IApplicationCommand>> IGuild.GetApplicationCommandsAsync (bool withLocalizations, RequestOptions options) | |||||
| => await GetApplicationCommandsAsync(withLocalizations, options).ConfigureAwait(false); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<ICustomSticker> IGuild.CreateStickerAsync(string name, string description, IEnumerable<string> tags, Image image, RequestOptions options) | async Task<ICustomSticker> IGuild.CreateStickerAsync(string name, string description, IEnumerable<string> tags, Image image, RequestOptions options) | ||||
| => await CreateStickerAsync(name, description, tags, image, options); | => await CreateStickerAsync(name, description, tags, image, options); | ||||
| @@ -872,9 +872,10 @@ namespace Discord.WebSocket | |||||
| /// A task that represents the asynchronous get operation. The task result contains a read-only collection of | /// A task that represents the asynchronous get operation. The task result contains a read-only collection of | ||||
| /// slash commands created by the current user. | /// slash commands created by the current user. | ||||
| /// </returns> | /// </returns> | ||||
| public async Task<IReadOnlyCollection<SocketApplicationCommand>> GetApplicationCommandsAsync(RequestOptions options = null) | |||||
| public async Task<IReadOnlyCollection<SocketApplicationCommand>> GetApplicationCommandsAsync(bool withLocalizations = false, RequestOptions options = null) | |||||
| { | { | ||||
| var commands = (await Discord.ApiClient.GetGuildApplicationCommandsAsync(Id, options)).Select(x => SocketApplicationCommand.Create(Discord, x, Id)); | |||||
| var commands = (await Discord.ApiClient.GetGuildApplicationCommandsAsync(Id, withLocalizations, options)) | |||||
| .Select(x => SocketApplicationCommand.Create(Discord, x, Id)); | |||||
| foreach (var command in commands) | foreach (var command in commands) | ||||
| { | { | ||||
| @@ -1965,8 +1966,8 @@ namespace Discord.WebSocket | |||||
| async Task<IReadOnlyCollection<IWebhook>> IGuild.GetWebhooksAsync(RequestOptions options) | async Task<IReadOnlyCollection<IWebhook>> IGuild.GetWebhooksAsync(RequestOptions options) | ||||
| => await GetWebhooksAsync(options).ConfigureAwait(false); | => await GetWebhooksAsync(options).ConfigureAwait(false); | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<IReadOnlyCollection<IApplicationCommand>> IGuild.GetApplicationCommandsAsync (RequestOptions options) | |||||
| => await GetApplicationCommandsAsync(options).ConfigureAwait(false); | |||||
| async Task<IReadOnlyCollection<IApplicationCommand>> IGuild.GetApplicationCommandsAsync (bool withLocalizations, RequestOptions options) | |||||
| => await GetApplicationCommandsAsync(withLocalizations, options).ConfigureAwait(false); | |||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| async Task<ICustomSticker> IGuild.CreateStickerAsync(string name, string description, IEnumerable<string> tags, Image image, RequestOptions options) | async Task<ICustomSticker> IGuild.CreateStickerAsync(string name, string description, IEnumerable<string> tags, Image image, RequestOptions options) | ||||
| => await CreateStickerAsync(name, description, tags, image, options); | => await CreateStickerAsync(name, description, tags, image, options); | ||||