| @@ -897,7 +897,7 @@ namespace Discord.API | |||||
| } | } | ||||
| #endregion | #endregion | ||||
| #region Stickers | |||||
| #region Stickers, Reactions, Crosspost, and Acks | |||||
| public async Task<Sticker> GetStickerAsync(ulong id, RequestOptions options = null) | public async Task<Sticker> GetStickerAsync(ulong id, RequestOptions options = null) | ||||
| { | { | ||||
| Preconditions.NotEqual(id, 0, nameof(id)); | Preconditions.NotEqual(id, 0, nameof(id)); | ||||
| @@ -1166,25 +1166,25 @@ namespace Discord.API | |||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await TrySendApplicationCommand(SendJsonAsync<ApplicationCommand>("POST", () => $"applications/{this.CurrentUserId}/commands", command, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand>("POST", () => $"applications/{this.CurrentUserId}/commands", command, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<ApplicationCommand> ModifyGlobalApplicationCommandAsync(ModifyApplicationCommandParams command, ulong commandId, RequestOptions options = null) | public async Task<ApplicationCommand> ModifyGlobalApplicationCommandAsync(ModifyApplicationCommandParams command, ulong commandId, RequestOptions options = null) | ||||
| { | { | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await TrySendApplicationCommand(SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{this.CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{this.CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<ApplicationCommand> ModifyGlobalApplicationUserCommandAsync(ModifyApplicationCommandParams command, ulong commandId, RequestOptions options = null) | public async Task<ApplicationCommand> ModifyGlobalApplicationUserCommandAsync(ModifyApplicationCommandParams command, ulong commandId, RequestOptions options = null) | ||||
| { | { | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await TrySendApplicationCommand(SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{this.CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{this.CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<ApplicationCommand> ModifyGlobalApplicationMessageCommandAsync(ModifyApplicationCommandParams command, ulong commandId, RequestOptions options = null) | public async Task<ApplicationCommand> ModifyGlobalApplicationMessageCommandAsync(ModifyApplicationCommandParams command, ulong commandId, RequestOptions options = null) | ||||
| { | { | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await TrySendApplicationCommand(SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{this.CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{this.CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task DeleteGlobalApplicationCommandAsync(ulong commandId, RequestOptions options = null) | public async Task DeleteGlobalApplicationCommandAsync(ulong commandId, RequestOptions options = null) | ||||
| { | { | ||||
| @@ -1193,11 +1193,11 @@ namespace Discord.API | |||||
| await SendAsync("DELETE", () => $"applications/{this.CurrentUserId}/commands/{commandId}", new BucketIds(), options: options).ConfigureAwait(false); | await SendAsync("DELETE", () => $"applications/{this.CurrentUserId}/commands/{commandId}", new BucketIds(), options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<ApplicationCommand[]> BulkOverwriteGlobalApplicationCommands(CreateApplicationCommandParams[] commands, RequestOptions options = null) | |||||
| public async Task<ApplicationCommand[]> BulkOverwriteGlobalApplicationCommandsAsync(CreateApplicationCommandParams[] commands, RequestOptions options = null) | |||||
| { | { | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await TrySendApplicationCommand(SendJsonAsync<ApplicationCommand[]>("PUT", () => $"applications/{this.CurrentUserId}/commands", commands, new BucketIds(), options: options)).ConfigureAwait(false); | |||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand[]>("PUT", () => $"applications/{this.CurrentUserId}/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, RequestOptions options = null) | ||||
| @@ -1239,7 +1239,7 @@ namespace Discord.API | |||||
| var bucket = new BucketIds(guildId: guildId); | var bucket = new BucketIds(guildId: guildId); | ||||
| return await TrySendApplicationCommand(SendJsonAsync<ApplicationCommand>("POST", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands", command, bucket, options: options)).ConfigureAwait(false); | |||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand>("POST", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands", command, bucket, options: options)).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task<ApplicationCommand> ModifyGuildApplicationCommandAsync(ModifyApplicationCommandParams command, ulong guildId, ulong commandId, RequestOptions options = null) | public async Task<ApplicationCommand> ModifyGuildApplicationCommandAsync(ModifyApplicationCommandParams command, ulong guildId, ulong commandId, RequestOptions options = null) | ||||
| { | { | ||||
| @@ -1247,7 +1247,7 @@ namespace Discord.API | |||||
| var bucket = new BucketIds(guildId: guildId); | var bucket = new BucketIds(guildId: guildId); | ||||
| return await TrySendApplicationCommand(SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}", command, bucket, options: options)).ConfigureAwait(false); | |||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand>("PATCH", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}", command, bucket, options: options)).ConfigureAwait(false); | |||||
| } | } | ||||
| public async Task DeleteGuildApplicationCommandAsync(ulong guildId, ulong commandId, RequestOptions options = null) | public async Task DeleteGuildApplicationCommandAsync(ulong guildId, ulong commandId, RequestOptions options = null) | ||||
| { | { | ||||
| @@ -1258,18 +1258,18 @@ namespace Discord.API | |||||
| await SendAsync<ApplicationCommand>("DELETE", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}", bucket, options: options).ConfigureAwait(false); | await SendAsync<ApplicationCommand>("DELETE", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}", bucket, options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<ApplicationCommand[]> BulkOverwriteGuildApplicationCommands(ulong guildId, CreateApplicationCommandParams[] commands, RequestOptions options = null) | |||||
| public async Task<ApplicationCommand[]> BulkOverwriteGuildApplicationCommandsAsync(ulong guildId, CreateApplicationCommandParams[] commands, 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 TrySendApplicationCommand(SendJsonAsync<ApplicationCommand[]>("PUT", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands", commands, bucket, options: options)).ConfigureAwait(false); | |||||
| return await TrySendApplicationCommandAsync(SendJsonAsync<ApplicationCommand[]>("PUT", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands", commands, bucket, options: options)).ConfigureAwait(false); | |||||
| } | } | ||||
| #endregion | #endregion | ||||
| #region Interaction Responses | #region Interaction Responses | ||||
| public async Task CreateInteractionResponse(InteractionResponse response, ulong interactionId, string interactionToken, RequestOptions options = null) | |||||
| public async Task CreateInteractionResponseAsync(InteractionResponse response, ulong interactionId, string interactionToken, RequestOptions options = null) | |||||
| { | { | ||||
| if(response.Data.IsSpecified && response.Data.Value.Content.IsSpecified) | if(response.Data.IsSpecified && response.Data.Value.Content.IsSpecified) | ||||
| Preconditions.AtMost(response.Data.Value.Content.Value?.Length ?? 0, 2000, nameof(response.Data.Value.Content)); | Preconditions.AtMost(response.Data.Value.Content.Value?.Length ?? 0, 2000, nameof(response.Data.Value.Content)); | ||||
| @@ -1278,7 +1278,7 @@ namespace Discord.API | |||||
| await SendJsonAsync<Message>("POST", () => $"interactions/{interactionId}/{interactionToken}/callback", response, new BucketIds(), options: options); | await SendJsonAsync<Message>("POST", () => $"interactions/{interactionId}/{interactionToken}/callback", response, new BucketIds(), options: options); | ||||
| } | } | ||||
| public async Task<Message> GetInteractionResponse(string interactionToken, RequestOptions options = null) | |||||
| public async Task<Message> GetInteractionResponseAsync(string interactionToken, RequestOptions options = null) | |||||
| { | { | ||||
| Preconditions.NotNullOrEmpty(interactionToken, nameof(interactionToken)); | Preconditions.NotNullOrEmpty(interactionToken, nameof(interactionToken)); | ||||
| @@ -1286,20 +1286,20 @@ namespace Discord.API | |||||
| return await SendAsync<Message>("GET", () => $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original", new BucketIds(), options: options).ConfigureAwait(false); | return await SendAsync<Message>("GET", () => $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original", new BucketIds(), options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<Message> ModifyInteractionResponse(ModifyInteractionResponseParams args, string interactionToken, RequestOptions options = null) | |||||
| public async Task<Message> ModifyInteractionResponseAsync(ModifyInteractionResponseParams args, string interactionToken, RequestOptions options = null) | |||||
| { | { | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| return await SendJsonAsync<Message>("PATCH", () => $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original", args, new BucketIds(), options: options); | return await SendJsonAsync<Message>("PATCH", () => $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original", args, new BucketIds(), options: options); | ||||
| } | } | ||||
| public async Task DeleteInteractionResponse(string interactionToken, RequestOptions options = null) | |||||
| public async Task DeleteInteractionResponseAsync(string interactionToken, RequestOptions options = null) | |||||
| { | { | ||||
| options = RequestOptions.CreateOrClone(options); | options = RequestOptions.CreateOrClone(options); | ||||
| await SendAsync("DELETE", () => $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original", new BucketIds(), options: options); | await SendAsync("DELETE", () => $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original", new BucketIds(), options: options); | ||||
| } | } | ||||
| public async Task<Message> CreateInteractionFollowupMessage(CreateWebhookMessageParams args, string token, RequestOptions options = null) | |||||
| public async Task<Message> CreateInteractionFollowupMessageAsync(CreateWebhookMessageParams args, string token, RequestOptions options = null) | |||||
| { | { | ||||
| if ((!args.Embeds.IsSpecified || args.Embeds.Value == null || args.Embeds.Value.Length == 0) && !args.File.IsSpecified) | if ((!args.Embeds.IsSpecified || args.Embeds.Value == null || args.Embeds.Value.Length == 0) && !args.File.IsSpecified) | ||||
| Preconditions.NotNullOrEmpty(args.Content, nameof(args.Content)); | Preconditions.NotNullOrEmpty(args.Content, nameof(args.Content)); | ||||
| @@ -1315,7 +1315,7 @@ namespace Discord.API | |||||
| return await SendMultipartAsync<Message>("POST", () => $"webhooks/{CurrentUserId}/{token}?wait=true", args.ToDictionary(), new BucketIds(), options: options).ConfigureAwait(false); | return await SendMultipartAsync<Message>("POST", () => $"webhooks/{CurrentUserId}/{token}?wait=true", args.ToDictionary(), new BucketIds(), options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<Message> ModifyInteractionFollowupMessage(ModifyInteractionResponseParams args, ulong id, string token, RequestOptions options = null) | |||||
| public async Task<Message> ModifyInteractionFollowupMessageAsync(ModifyInteractionResponseParams args, ulong id, string token, RequestOptions options = null) | |||||
| { | { | ||||
| Preconditions.NotNull(args, nameof(args)); | Preconditions.NotNull(args, nameof(args)); | ||||
| Preconditions.NotEqual(id, 0, nameof(id)); | Preconditions.NotEqual(id, 0, nameof(id)); | ||||
| @@ -1329,7 +1329,7 @@ namespace Discord.API | |||||
| return await SendJsonAsync<Message>("PATCH", () => $"webhooks/{CurrentUserId}/{token}/messages/{id}", args, new BucketIds(), options: options).ConfigureAwait(false); | return await SendJsonAsync<Message>("PATCH", () => $"webhooks/{CurrentUserId}/{token}/messages/{id}", args, new BucketIds(), options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task DeleteInteractionFollowupMessage(ulong id, string token, RequestOptions options = null) | |||||
| public async Task DeleteInteractionFollowupMessageAsync(ulong id, string token, RequestOptions options = null) | |||||
| { | { | ||||
| Preconditions.NotEqual(id, 0, nameof(id)); | Preconditions.NotEqual(id, 0, nameof(id)); | ||||
| @@ -1340,7 +1340,7 @@ namespace Discord.API | |||||
| #endregion | #endregion | ||||
| #region Application Command permissions | #region Application Command permissions | ||||
| public async Task<GuildApplicationCommandPermission[]> GetGuildApplicationCommandPermissions(ulong guildId, RequestOptions options = null) | |||||
| public async Task<GuildApplicationCommandPermission[]> GetGuildApplicationCommandPermissionsAsync(ulong guildId, RequestOptions options = null) | |||||
| { | { | ||||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | Preconditions.NotEqual(guildId, 0, nameof(guildId)); | ||||
| @@ -1349,7 +1349,7 @@ namespace Discord.API | |||||
| return await SendAsync<GuildApplicationCommandPermission[]>("GET", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/permissions", new BucketIds(), options: options).ConfigureAwait(false); | return await SendAsync<GuildApplicationCommandPermission[]>("GET", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/permissions", new BucketIds(), options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<GuildApplicationCommandPermission> GetGuildApplicationCommandPermission(ulong guildId, ulong commandId, RequestOptions options = null) | |||||
| public async Task<GuildApplicationCommandPermission> GetGuildApplicationCommandPermissionAsync(ulong guildId, ulong commandId, RequestOptions options = null) | |||||
| { | { | ||||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | Preconditions.NotEqual(guildId, 0, nameof(guildId)); | ||||
| Preconditions.NotEqual(commandId, 0, nameof(commandId)); | Preconditions.NotEqual(commandId, 0, nameof(commandId)); | ||||
| @@ -1359,7 +1359,7 @@ namespace Discord.API | |||||
| return await SendAsync<GuildApplicationCommandPermission>("GET", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}/permissions", new BucketIds(), options: options).ConfigureAwait(false); | return await SendAsync<GuildApplicationCommandPermission>("GET", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}/permissions", new BucketIds(), options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<GuildApplicationCommandPermission> ModifyApplicationCommandPermissions(ModifyGuildApplicationCommandPermissionsParams permissions, ulong guildId, ulong commandId, RequestOptions options = null) | |||||
| public async Task<GuildApplicationCommandPermission> ModifyApplicationCommandPermissionsAsync(ModifyGuildApplicationCommandPermissionsParams permissions, ulong guildId, ulong commandId, RequestOptions options = null) | |||||
| { | { | ||||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | Preconditions.NotEqual(guildId, 0, nameof(guildId)); | ||||
| Preconditions.NotEqual(commandId, 0, nameof(commandId)); | Preconditions.NotEqual(commandId, 0, nameof(commandId)); | ||||
| @@ -1369,7 +1369,7 @@ namespace Discord.API | |||||
| return await SendJsonAsync<GuildApplicationCommandPermission>("PUT", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false); | return await SendJsonAsync<GuildApplicationCommandPermission>("PUT", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<IReadOnlyCollection<GuildApplicationCommandPermission>> BatchModifyApplicationCommandPermissions(ModifyGuildApplicationCommandPermissions[] permissions, ulong guildId, RequestOptions options = null) | |||||
| public async Task<IReadOnlyCollection<GuildApplicationCommandPermission>> BatchModifyApplicationCommandPermissionsAsync(ModifyGuildApplicationCommandPermissions[] permissions, ulong guildId, RequestOptions options = null) | |||||
| { | { | ||||
| Preconditions.NotEqual(guildId, 0, nameof(guildId)); | Preconditions.NotEqual(guildId, 0, nameof(guildId)); | ||||
| Preconditions.NotNull(permissions, nameof(permissions)); | Preconditions.NotNull(permissions, nameof(permissions)); | ||||
| @@ -2091,7 +2091,7 @@ namespace Discord.API | |||||
| return _serializer.Deserialize<T>(reader); | return _serializer.Deserialize<T>(reader); | ||||
| } | } | ||||
| protected async Task<T> TrySendApplicationCommand<T>(Task<T> sendTask) | |||||
| protected async Task<T> TrySendApplicationCommandAsync<T>(Task<T> sendTask) | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| @@ -14,31 +14,31 @@ namespace Discord.Rest | |||||
| #region InteractionHelper | #region InteractionHelper | ||||
| public static Task DeleteAllGuildCommandsAsync(BaseDiscordClient client, ulong guildId, RequestOptions options = null) | public static Task DeleteAllGuildCommandsAsync(BaseDiscordClient client, ulong guildId, RequestOptions options = null) | ||||
| { | { | ||||
| return client.ApiClient.BulkOverwriteGuildApplicationCommands(guildId, new CreateApplicationCommandParams[0], options); | |||||
| return client.ApiClient.BulkOverwriteGuildApplicationCommandsAsync(guildId, new CreateApplicationCommandParams[0], options); | |||||
| } | } | ||||
| public static Task DeleteAllGlobalCommandsAsync(BaseDiscordClient client, RequestOptions options = null) | public static Task DeleteAllGlobalCommandsAsync(BaseDiscordClient client, RequestOptions options = null) | ||||
| { | { | ||||
| return client.ApiClient.BulkOverwriteGlobalApplicationCommands(new CreateApplicationCommandParams[0], options); | |||||
| return client.ApiClient.BulkOverwriteGlobalApplicationCommandsAsync(new CreateApplicationCommandParams[0], options); | |||||
| } | } | ||||
| public static Task SendInteractionResponse(BaseDiscordClient client, InteractionResponse response, | public static Task SendInteractionResponse(BaseDiscordClient client, InteractionResponse response, | ||||
| ulong interactionId, string interactionToken, RequestOptions options = null) | ulong interactionId, string interactionToken, RequestOptions options = null) | ||||
| { | { | ||||
| return client.ApiClient.CreateInteractionResponse(response, interactionId, interactionToken, options); | |||||
| return client.ApiClient.CreateInteractionResponseAsync(response, interactionId, interactionToken, options); | |||||
| } | } | ||||
| public static async Task<RestInteractionMessage> GetOriginalResponseAsync(BaseDiscordClient client, IMessageChannel channel, | public static async Task<RestInteractionMessage> GetOriginalResponseAsync(BaseDiscordClient client, IMessageChannel channel, | ||||
| IDiscordInteraction interaction, RequestOptions options = null) | IDiscordInteraction interaction, RequestOptions options = null) | ||||
| { | { | ||||
| var model = await client.ApiClient.GetInteractionResponse(interaction.Token, options).ConfigureAwait(false); | |||||
| var model = await client.ApiClient.GetInteractionResponseAsync(interaction.Token, options).ConfigureAwait(false); | |||||
| return RestInteractionMessage.Create(client, model, interaction.Token, channel); | return RestInteractionMessage.Create(client, model, interaction.Token, channel); | ||||
| } | } | ||||
| public static async Task<RestFollowupMessage> SendFollowupAsync(BaseDiscordClient client, CreateWebhookMessageParams args, | public static async Task<RestFollowupMessage> SendFollowupAsync(BaseDiscordClient client, CreateWebhookMessageParams args, | ||||
| string token, IMessageChannel channel, RequestOptions options = null) | string token, IMessageChannel channel, RequestOptions options = null) | ||||
| { | { | ||||
| var model = await client.ApiClient.CreateInteractionFollowupMessage(args, token, options).ConfigureAwait(false); | |||||
| var model = await client.ApiClient.CreateInteractionFollowupMessageAsync(args, token, options).ConfigureAwait(false); | |||||
| RestFollowupMessage entity = RestFollowupMessage.Create(client, model, token, channel); | RestFollowupMessage entity = RestFollowupMessage.Create(client, model, token, channel); | ||||
| return entity; | return entity; | ||||
| @@ -123,7 +123,7 @@ namespace Discord.Rest | |||||
| models.Add(model); | models.Add(model); | ||||
| } | } | ||||
| return await client.ApiClient.BulkOverwriteGlobalApplicationCommands(models.ToArray(), options).ConfigureAwait(false); | |||||
| return await client.ApiClient.BulkOverwriteGlobalApplicationCommandsAsync(models.ToArray(), options).ConfigureAwait(false); | |||||
| } | } | ||||
| public static async Task<IReadOnlyCollection<ApplicationCommand>> BulkOverwriteGuildCommands(BaseDiscordClient client, ulong guildId, | public static async Task<IReadOnlyCollection<ApplicationCommand>> BulkOverwriteGuildCommands(BaseDiscordClient client, ulong guildId, | ||||
| @@ -160,7 +160,7 @@ namespace Discord.Rest | |||||
| models.Add(model); | models.Add(model); | ||||
| } | } | ||||
| return await client.ApiClient.BulkOverwriteGuildApplicationCommands(guildId, models.ToArray(), options).ConfigureAwait(false); | |||||
| return await client.ApiClient.BulkOverwriteGuildApplicationCommandsAsync(guildId, models.ToArray(), options).ConfigureAwait(false); | |||||
| } | } | ||||
| private static TArg GetApplicationCommandProperties<TArg>(IApplicationCommand command) | private static TArg GetApplicationCommandProperties<TArg>(IApplicationCommand command) | ||||
| @@ -367,11 +367,11 @@ namespace Discord.Rest | |||||
| Components = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() : Optional<API.ActionRowComponent[]>.Unspecified, | Components = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() : Optional<API.ActionRowComponent[]>.Unspecified, | ||||
| }; | }; | ||||
| return await client.ApiClient.ModifyInteractionFollowupMessage(apiArgs, message.Id, message.Token, options).ConfigureAwait(false); | |||||
| return await client.ApiClient.ModifyInteractionFollowupMessageAsync(apiArgs, message.Id, message.Token, options).ConfigureAwait(false); | |||||
| } | } | ||||
| public static async Task DeleteFollowupMessage(BaseDiscordClient client, RestFollowupMessage message, RequestOptions options = null) | public static async Task DeleteFollowupMessage(BaseDiscordClient client, RestFollowupMessage message, RequestOptions options = null) | ||||
| => await client.ApiClient.DeleteInteractionFollowupMessage(message.Id, message.Token, options); | |||||
| => await client.ApiClient.DeleteInteractionFollowupMessageAsync(message.Id, message.Token, options); | |||||
| public static async Task<Message> ModifyInteractionResponse(BaseDiscordClient client, string token, Action<MessageProperties> func, | public static async Task<Message> ModifyInteractionResponse(BaseDiscordClient client, string token, Action<MessageProperties> func, | ||||
| RequestOptions options = null) | RequestOptions options = null) | ||||
| @@ -411,18 +411,18 @@ namespace Discord.Rest | |||||
| Flags = args.Flags | Flags = args.Flags | ||||
| }; | }; | ||||
| return await client.ApiClient.ModifyInteractionResponse(apiArgs, token, options).ConfigureAwait(false); | |||||
| return await client.ApiClient.ModifyInteractionResponseAsync(apiArgs, token, options).ConfigureAwait(false); | |||||
| } | } | ||||
| public static async Task DeletedInteractionResponse(BaseDiscordClient client, RestInteractionMessage message, RequestOptions options = null) | public static async Task DeletedInteractionResponse(BaseDiscordClient client, RestInteractionMessage message, RequestOptions options = null) | ||||
| => await client.ApiClient.DeleteInteractionFollowupMessage(message.Id, message.Token, options); | |||||
| => await client.ApiClient.DeleteInteractionFollowupMessageAsync(message.Id, message.Token, options); | |||||
| #endregion | #endregion | ||||
| #region Guild permissions | #region Guild permissions | ||||
| public static async Task<IReadOnlyCollection<GuildApplicationCommandPermission>> GetGuildCommandPermissionsAsync(BaseDiscordClient client, | public static async Task<IReadOnlyCollection<GuildApplicationCommandPermission>> GetGuildCommandPermissionsAsync(BaseDiscordClient client, | ||||
| ulong guildId, RequestOptions options) | ulong guildId, RequestOptions options) | ||||
| { | { | ||||
| var models = await client.ApiClient.GetGuildApplicationCommandPermissions(guildId, options); | |||||
| var models = await client.ApiClient.GetGuildApplicationCommandPermissionsAsync(guildId, options); | |||||
| return models.Select(x => | return models.Select(x => | ||||
| new GuildApplicationCommandPermission(x.Id, x.ApplicationId, guildId, x.Permissions.Select( | new GuildApplicationCommandPermission(x.Id, x.ApplicationId, guildId, x.Permissions.Select( | ||||
| y => new Discord.ApplicationCommandPermission(y.Id, y.Type, y.Permission)) | y => new Discord.ApplicationCommandPermission(y.Id, y.Type, y.Permission)) | ||||
| @@ -435,7 +435,7 @@ namespace Discord.Rest | |||||
| { | { | ||||
| try | try | ||||
| { | { | ||||
| var model = await client.ApiClient.GetGuildApplicationCommandPermission(guildId, commandId, options); | |||||
| var model = await client.ApiClient.GetGuildApplicationCommandPermissionAsync(guildId, commandId, options); | |||||
| return new GuildApplicationCommandPermission(model.Id, model.ApplicationId, guildId, model.Permissions.Select( | return new GuildApplicationCommandPermission(model.Id, model.ApplicationId, guildId, model.Permissions.Select( | ||||
| y => new ApplicationCommandPermission(y.Id, y.Type, y.Permission)).ToArray()); | y => new ApplicationCommandPermission(y.Id, y.Type, y.Permission)).ToArray()); | ||||
| } | } | ||||
| @@ -473,7 +473,7 @@ namespace Discord.Rest | |||||
| Permissions = permissionsList.ToArray() | Permissions = permissionsList.ToArray() | ||||
| }; | }; | ||||
| var apiModel = await client.ApiClient.ModifyApplicationCommandPermissions(model, guildId, commandId, options); | |||||
| var apiModel = await client.ApiClient.ModifyApplicationCommandPermissionsAsync(model, guildId, commandId, options); | |||||
| return new GuildApplicationCommandPermission(apiModel.Id, apiModel.ApplicationId, guildId, apiModel.Permissions.Select( | return new GuildApplicationCommandPermission(apiModel.Id, apiModel.ApplicationId, guildId, apiModel.Permissions.Select( | ||||
| x => new ApplicationCommandPermission(x.Id, x.Type, x.Permission)).ToArray()); | x => new ApplicationCommandPermission(x.Id, x.Type, x.Permission)).ToArray()); | ||||
| @@ -505,7 +505,7 @@ namespace Discord.Rest | |||||
| models.Add(model); | models.Add(model); | ||||
| } | } | ||||
| var apiModels = await client.ApiClient.BatchModifyApplicationCommandPermissions(models.ToArray(), guildId, options); | |||||
| var apiModels = await client.ApiClient.BatchModifyApplicationCommandPermissionsAsync(models.ToArray(), guildId, options); | |||||
| return apiModels.Select( | return apiModels.Select( | ||||
| x => new GuildApplicationCommandPermission(x.Id, x.ApplicationId, x.GuildId, x.Permissions.Select( | x => new GuildApplicationCommandPermission(x.Id, x.ApplicationId, x.GuildId, x.Permissions.Select( | ||||
| @@ -1393,29 +1393,6 @@ | |||||
| </note> | </note> | ||||
| </remarks> | </remarks> | ||||
| </member> | </member> | ||||
| <member name="P:Discord.WebSocket.DiscordSocketConfig.AlwaysAcknowledgeInteractions"> | |||||
| <summary> | |||||
| Gets or sets whether or not interactions are acknowledge with source. | |||||
| </summary> | |||||
| <remarks> | |||||
| <para> | |||||
| Discord interactions will not appear in chat until the client responds to them. With this option set to | |||||
| <see langword="true"/>, the client will automatically acknowledge the interaction with <see cref="F:Discord.InteractionResponseType.DeferredChannelMessageWithSource"/>. | |||||
| See <see href="https://discord.com/developers/docs/interactions/slash-commands#interaction-interactionresponsetype">the docs</see> on | |||||
| responding to interactions for more info. | |||||
| </para> | |||||
| <para> | |||||
| With this option set to <see langword="false"/>, you will have to acknowledge the interaction with | |||||
| <see cref="!:SocketInteraction.RespondAsync(string, bool, Embed, InteractionResponseType, AllowedMentions, RequestOptions)"/>. | |||||
| Only after the interaction is acknowledged, the original slash command message will be visible. | |||||
| </para> | |||||
| <note> | |||||
| Please note that manually acknowledging the interaction with a message reply will not provide any return data. | |||||
| Automatically acknowledging the interaction without sending the message will allow for follow up responses to | |||||
| be used; follow up responses return the message data sent. | |||||
| </note> | |||||
| </remarks> | |||||
| </member> | |||||
| <member name="P:Discord.WebSocket.DiscordSocketConfig.HandlerTimeout"> | <member name="P:Discord.WebSocket.DiscordSocketConfig.HandlerTimeout"> | ||||
| <summary> | <summary> | ||||
| Gets or sets the timeout for event handlers, in milliseconds, after which a warning will be logged. | Gets or sets the timeout for event handlers, in milliseconds, after which a warning will be logged. | ||||
| @@ -4207,7 +4184,7 @@ | |||||
| <summary> | <summary> | ||||
| Responds to an Interaction with type <see cref="F:Discord.InteractionResponseType.ChannelMessageWithSource"/>. | Responds to an Interaction with type <see cref="F:Discord.InteractionResponseType.ChannelMessageWithSource"/>. | ||||
| <para> | <para> | ||||
| If you have <see cref="P:Discord.WebSocket.DiscordSocketConfig.AlwaysAcknowledgeInteractions"/> set to <see langword="true"/>, You should use | |||||
| If you have <see cref="!:DiscordSocketConfig.AlwaysAcknowledgeInteractions"/> set to <see langword="true"/>, You should use | |||||
| <see cref="M:Discord.WebSocket.SocketInteraction.FollowupAsync(System.String,Discord.Embed[],System.Boolean,System.Boolean,Discord.AllowedMentions,Discord.RequestOptions,Discord.MessageComponent,Discord.Embed)"/> instead. | <see cref="M:Discord.WebSocket.SocketInteraction.FollowupAsync(System.String,Discord.Embed[],System.Boolean,System.Boolean,Discord.AllowedMentions,Discord.RequestOptions,Discord.MessageComponent,Discord.Embed)"/> instead. | ||||
| </para> | </para> | ||||
| </summary> | </summary> | ||||
| @@ -72,8 +72,6 @@ namespace Discord.WebSocket | |||||
| internal WebSocketProvider WebSocketProvider { get; private set; } | internal WebSocketProvider WebSocketProvider { get; private set; } | ||||
| internal bool AlwaysDownloadUsers { get; private set; } | internal bool AlwaysDownloadUsers { get; private set; } | ||||
| internal int? HandlerTimeout { get; private set; } | internal int? HandlerTimeout { get; private set; } | ||||
| internal bool AlwaysAcknowledgeInteractions { get; private set; } | |||||
| internal new DiscordSocketApiClient ApiClient => base.ApiClient as DiscordSocketApiClient; | internal new DiscordSocketApiClient ApiClient => base.ApiClient as DiscordSocketApiClient; | ||||
| /// <inheritdoc /> | /// <inheritdoc /> | ||||
| public override IReadOnlyCollection<SocketGuild> Guilds => State.Guilds; | public override IReadOnlyCollection<SocketGuild> Guilds => State.Guilds; | ||||
| @@ -143,7 +141,6 @@ namespace Discord.WebSocket | |||||
| UdpSocketProvider = config.UdpSocketProvider; | UdpSocketProvider = config.UdpSocketProvider; | ||||
| WebSocketProvider = config.WebSocketProvider; | WebSocketProvider = config.WebSocketProvider; | ||||
| AlwaysDownloadUsers = config.AlwaysDownloadUsers; | AlwaysDownloadUsers = config.AlwaysDownloadUsers; | ||||
| AlwaysAcknowledgeInteractions = config.AlwaysAcknowledgeInteractions; | |||||
| HandlerTimeout = config.HandlerTimeout; | HandlerTimeout = config.HandlerTimeout; | ||||
| State = new ClientState(0, 0); | State = new ClientState(0, 0); | ||||
| Rest = new DiscordSocketRestClient(config, ApiClient); | Rest = new DiscordSocketRestClient(config, ApiClient); | ||||
| @@ -2095,9 +2092,6 @@ namespace Discord.WebSocket | |||||
| var interaction = SocketInteraction.Create(this, data, channel as ISocketMessageChannel); | var interaction = SocketInteraction.Create(this, data, channel as ISocketMessageChannel); | ||||
| if (this.AlwaysAcknowledgeInteractions) | |||||
| await interaction.DeferAsync().ConfigureAwait(false); | |||||
| await TimedInvokeAsync(_interactionCreatedEvent, nameof(InteractionCreated), interaction).ConfigureAwait(false); | await TimedInvokeAsync(_interactionCreatedEvent, nameof(InteractionCreated), interaction).ConfigureAwait(false); | ||||
| switch (interaction) | switch (interaction) | ||||
| @@ -105,29 +105,6 @@ namespace Discord.WebSocket | |||||
| /// </remarks> | /// </remarks> | ||||
| public bool AlwaysDownloadUsers { get; set; } = false; | public bool AlwaysDownloadUsers { get; set; } = false; | ||||
| /// <summary> | |||||
| /// Gets or sets whether or not interactions are acknowledge with source. | |||||
| /// </summary> | |||||
| /// <remarks> | |||||
| /// <para> | |||||
| /// Discord interactions will not appear in chat until the client responds to them. With this option set to | |||||
| /// <see langword="true"/>, the client will automatically acknowledge the interaction with <see cref="InteractionResponseType.DeferredChannelMessageWithSource"/>. | |||||
| /// See <see href="https://discord.com/developers/docs/interactions/slash-commands#interaction-interactionresponsetype">the docs</see> on | |||||
| /// responding to interactions for more info. | |||||
| /// </para> | |||||
| /// <para> | |||||
| /// With this option set to <see langword="false"/>, you will have to acknowledge the interaction with | |||||
| /// <see cref="SocketInteraction.RespondAsync(string, bool, Embed, InteractionResponseType, AllowedMentions, RequestOptions)"/>. | |||||
| /// Only after the interaction is acknowledged, the original slash command message will be visible. | |||||
| /// </para> | |||||
| /// <note> | |||||
| /// Please note that manually acknowledging the interaction with a message reply will not provide any return data. | |||||
| /// Automatically acknowledging the interaction without sending the message will allow for follow up responses to | |||||
| /// be used; follow up responses return the message data sent. | |||||
| /// </note> | |||||
| /// </remarks> | |||||
| public bool AlwaysAcknowledgeInteractions { get; set; } = true; | |||||
| /// <summary> | /// <summary> | ||||
| /// Gets or sets the timeout for event handlers, in milliseconds, after which a warning will be logged. | /// Gets or sets the timeout for event handlers, in milliseconds, after which a warning will be logged. | ||||
| /// Setting this property to <c>null</c>disables this check. | /// Setting this property to <c>null</c>disables this check. | ||||
| @@ -86,12 +86,6 @@ namespace Discord.WebSocket | |||||
| if (embeds == null && embed != null) | if (embeds == null && embed != null) | ||||
| embeds = new[] { embed }; | embeds = new[] { embed }; | ||||
| if (Discord.AlwaysAcknowledgeInteractions) | |||||
| { | |||||
| await FollowupAsync(text, embeds, isTTS, ephemeral, allowedMentions, options); | |||||
| return; | |||||
| } | |||||
| Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); | Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); | ||||
| Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); | Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); | ||||
| Preconditions.AtMost(embeds?.Length ?? 0, 10, nameof(embeds), "A max of 10 embeds are allowed."); | Preconditions.AtMost(embeds?.Length ?? 0, 10, nameof(embeds), "A max of 10 embeds are allowed."); | ||||
| @@ -341,7 +335,7 @@ namespace Discord.WebSocket | |||||
| }; | }; | ||||
| return Discord.Rest.ApiClient.CreateInteractionResponse(response, this.Id, this.Token, options); | |||||
| return Discord.Rest.ApiClient.CreateInteractionResponseAsync(response, this.Id, this.Token, options); | |||||
| } | } | ||||
| /// <inheritdoc/> | /// <inheritdoc/> | ||||
| @@ -354,7 +348,7 @@ namespace Discord.WebSocket | |||||
| }; | }; | ||||
| return Discord.Rest.ApiClient.CreateInteractionResponse(response, this.Id, this.Token, options); | |||||
| return Discord.Rest.ApiClient.CreateInteractionResponseAsync(response, this.Id, this.Token, options); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -70,12 +70,6 @@ namespace Discord.WebSocket | |||||
| if (embeds == null && embed != null) | if (embeds == null && embed != null) | ||||
| embeds = new[] { embed }; | embeds = new[] { embed }; | ||||
| if (Discord.AlwaysAcknowledgeInteractions) | |||||
| { | |||||
| await FollowupAsync(text, embeds, isTTS, ephemeral, allowedMentions, options, component); | |||||
| return; | |||||
| } | |||||
| Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); | Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); | ||||
| Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); | Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); | ||||
| Preconditions.AtMost(embeds?.Length ?? 0, 10, nameof(embeds), "A max of 10 embeds are allowed."); | Preconditions.AtMost(embeds?.Length ?? 0, 10, nameof(embeds), "A max of 10 embeds are allowed."); | ||||
| @@ -244,7 +238,7 @@ namespace Discord.WebSocket | |||||
| } | } | ||||
| }; | }; | ||||
| return Discord.Rest.ApiClient.CreateInteractionResponse(response, this.Id, this.Token, options); | |||||
| return Discord.Rest.ApiClient.CreateInteractionResponseAsync(response, this.Id, this.Token, options); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||