From 62c3885fb1c7976c91e89b499a31bd54d61a0869 Mon Sep 17 00:00:00 2001 From: Quin Lynch <49576606+quinchs@users.noreply.github.com> Date: Tue, 3 Aug 2021 20:28:21 -0300 Subject: [PATCH 1/5] Update README.md --- README.md | 103 +++++++++++++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 41c902b0d..000d326ab 100644 --- a/README.md +++ b/README.md @@ -15,16 +15,16 @@ Setting up labs in your project is really simple, here's how to do it: ## Branches ### Dev -The main branch we pull off of to introduce new features into, the dev branch is the same as Discord.Nets dev branch +This branch is kept up to date with dnets dev branch. we pull of it to ensure that labs will work with pre existing dnet code. -### Interactions -This branch is for anything todo with Discord Interactions, such as [Slash commands](https://discord.com/developers/docs/interactions/slash-commands) and [Message Components](https://discord.com/developers/docs/interactions/message-components). This branch is stable enough to use but does not contain all the features of interactions. +### release/2.x +This branch is what will be pushed to nuget, sometimes its not up to date as we wait for other features to be finished. -### SlashCommandService -This branch is on pause and does not work currently, Once everything is stable with the Interaction branch we will continue working on a slash command service for it. +### old/SlashCommandService +This branch is on pause and does not work currently, There is a pull request open to implement a working version of a slash command service. It can be found [here](https://github.com/Discord-Net-Labs/Discord.Net-Labs/pull/52) -### web/SlashCommandService -webmilio's spin on the SlashCommandService branch, again the state of this is unknown. +### feature/xyz +These branches are features for new things, you are more than welcome to clone them and give feedback in the discord server or issues tab. ## Listening for interactions ```cs @@ -32,52 +32,65 @@ webmilio's spin on the SlashCommandService branch, again the state of this is un client.InteractionCreated += Client_InteractionCreated; ... -private async Task Client_InteractionCreated(SocketInteraction arg) +private async Task Client_InteractionCreated(SocketInteraction interaction) { - switch (arg.Type) // We want to check the type of this interaction + // Checking the type of this interaction + switch (interaction) { - //Slash commands - case InteractionType.ApplicationCommand: - await MySlashCommandHandler(arg); + // Slash commands + case SocketSlashCommand commandInteraction: + await MySlashCommandHandler(commandInteraction); break; - //Button clicks/selection dropdowns - case InteractionType.MessageComponent: - await MyMessageComponentHandler(arg); + + // Button clicks/selection dropdowns + case SocketMessageComponent componentInteraction: + await MyMessageComponentHandler(componentInteraction); break; - //Unused - case InteractionType.Ping: - break; - //Unknown/Unsupported + + // Unused or Unknown/Unsupported default: - Console.WriteLine("Unsupported interaction type: " + arg.Type); break; } } ``` -### Handling button clicks and selection dropdowns +### Simple handling slash commands ```cs -private async Task MyMessageComponentHandler(SocketInteraction arg) +private async Task MySlashCommandHandler(SocketSlashCommand interaction) +{ + // Checking command name + if (interaction.Data.Name == "ping") + { + // Respond to interaction with message. + // You can also use "ephemeral" so that only the original user of the interaction sees the message + await interaction.RespondAsync($"Pong!", ephemeral: true); + + // Also you can followup with a additional messages, which also can be "ephemeral" + await interaction.FollowupAsync($"PongPong!", ephemeral: true); + } +} +``` + +### Simple handling button clicks and selection dropdowns +```cs +private async Task MyMessageComponentHandler(SocketMessageComponent interaction) { - // Parse the arg - var parsedArg = (SocketMessageComponent) arg; // Get the custom ID - var customId = parsedArg.Data.CustomId; + var customId = interaction.Data.CustomId; // Get the user - var user = (SocketGuildUser) arg.User; + var user = (SocketGuildUser) interaction.User; // Get the guild var guild = user.Guild; - // Respond with the update message response type. This edits the original message if you have set AlwaysAcknowledgeInteractions to false. - // You can also use "ephemeral" so that only the original user of the interaction sees the message - await parsedArg.RespondAsync($"Clicked {parsedArg.Data.CustomId}!", type: InteractionResponseType.UpdateMessage, ephemeral: true); + // Respond with the update message. This edits the message which this component resides. + await interaction.UpdateAsync(msgProps => msgProps.Content = $"Clicked {interaction.Data.CustomId}!"); - // You can also followup with a second message - await parsedArg.FollowupAsync($"Clicked {parsedArg.Data.CustomId}!", type: InteractionResponseType.ChannelMessageWithSource, ephemeral: true); + // Also you can followup with a additional messages + await interaction.FollowupAsync($"Clicked {interaction.Data.CustomId}!", ephemeral: true); - //If you are using selection dropdowns, you can get the selected label and values using these: - var selectedLabel = ((SelectMenu) parsedArg.Message.Components.First().Components.First()).Options.FirstOrDefault(x => x.Value == parsedArg.Data.Values.FirstOrDefault())?.Label; - var selectedValue = parsedArg.Data.Values.First(); + // If you are using selection dropdowns, you can get the selected label and values using these + var selectedLabel = ((SelectMenu) interaction.Message.Components.First().Components.First()).Options.FirstOrDefault(x => x.Value == interaction.Data.Values.FirstOrDefault())?.Label; + var selectedValue = interaction.Data.Values.First(); } ``` @@ -97,22 +110,18 @@ var builder = new ComponentBuilder() .WithSelectMenu(new SelectMenuBuilder() .WithCustomId("id_2") .WithPlaceholder("This is a placeholder") - .WithOptions(new List() - { - new SelectMenuOptionBuilder() - .WithLabel("Option A") - .WithEmote(Emote.Parse("<:evanpog:810017136814194698>")) - .WithDescription("Evan pog champ") - .WithValue("value1"), - new SelectMenuOptionBuilder() - .WithLabel("Option B") - .WithDescription("Option B is poggers") - .WithValue("value2") - })); + .AddOption( + label: "Option", + value: "value1", + description: "Evan pog champ", + emote: Emote.Parse("<:evanpog:810017136814194698>") + ) + .AddOption("Option B", "value2", "Option B is poggers"); + await Context.Channel.SendMessageAsync("Test selection!", component: builder.Build()); ``` > Note: You can only have 5 buttons per row and 5 rows per message. If a row contains a selection dropdown it cannot contain any buttons. ## Slash commands -Slash command example how to's can be found [here](https://github.com/Discord-Net-Labs/Discord.Net-Labs/tree/Interactions/docs/guides/slash-commands). If you want to read some code using slash commands, you can do that [here](https://github.com/quinchs/SwissbotCore/blob/master/SwissbotCore/Handlers/AutoMod/Censor.cs) +Slash command example how to's can be found [here](https://github.com/Discord-Net-Labs/Discord.Net-Labs/tree/Interactions/docs/guides/slash-commands). From 6e9d4c63900c6f8e57f1ec49cf5334468786f4f8 Mon Sep 17 00:00:00 2001 From: Quin Lynch <49576606+quinchs@users.noreply.github.com> Date: Tue, 3 Aug 2021 20:43:16 -0300 Subject: [PATCH 2/5] Update README.md --- README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 000d326ab..f0d40c20c 100644 --- a/README.md +++ b/README.md @@ -108,15 +108,16 @@ Theres a new field in all `SendMessageAsync` functions that takes in a `MessageC ```cs var builder = new ComponentBuilder() .WithSelectMenu(new SelectMenuBuilder() - .WithCustomId("id_2") - .WithPlaceholder("This is a placeholder") - .AddOption( - label: "Option", - value: "value1", - description: "Evan pog champ", - emote: Emote.Parse("<:evanpog:810017136814194698>") - ) - .AddOption("Option B", "value2", "Option B is poggers"); + .WithCustomId("id_2") + .WithPlaceholder("This is a placeholder") + .AddOption( + label: "Option", + value: "value1", + description: "Evan pog champ", + emote: Emote.Parse("<:evanpog:810017136814194698>") + ) + .AddOption("Option B", "value2", "Option B is poggers") + ); await Context.Channel.SendMessageAsync("Test selection!", component: builder.Build()); ``` From ea75a6df2c251b7ca34d5b3d8dfa9d71950f00d3 Mon Sep 17 00:00:00 2001 From: MrCakeSlayer <13650699+MrCakeSlayer@users.noreply.github.com> Date: Fri, 6 Aug 2021 20:46:41 -0400 Subject: [PATCH 3/5] Update label/description lengths for selects (ref: https://github.com/discord/discord-api-docs/pull/3598/files) (#91) https://github.com/discord/discord-api-docs/pull/3598/files --- .../Message Components/ComponentBuilder.cs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs index bb2f80a81..8d4a710ea 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs @@ -13,7 +13,7 @@ namespace Discord /// /// The max length of a . /// - public const int MaxLabelLength = 80; + public const int MaxButtonLabelLength = 80; /// /// The max length of a . @@ -310,14 +310,14 @@ namespace Discord /// /// Gets or sets the label of the current button. /// - /// length exceeds . + /// length exceeds . public string Label { get => _label; set { - if (value != null && value.Length > ComponentBuilder.MaxLabelLength) - throw new ArgumentException(message: $"Button label must be {ComponentBuilder.MaxLabelLength} characters or less!", paramName: nameof(Label)); + if (value != null && value.Length > ComponentBuilder.MaxButtonLabelLength) + throw new ArgumentException(message: $"Button label must be {ComponentBuilder.MaxButtonLabelLength} characters or less!", paramName: nameof(Label)); _label = value; } @@ -834,20 +834,25 @@ namespace Discord /// /// The maximum length of a . /// - public const int MaxDescriptionLength = 50; + public const int MaxDescriptionLength = 100; + + /// + /// The maximum length of a . + /// + public const int MaxSelectLabelLength = 100; /// /// Gets or sets the label of the current select menu. /// - /// length exceeds + /// length exceeds public string Label { get => _label; set { if (value != null) - if (value.Length > ComponentBuilder.MaxLabelLength) - throw new ArgumentException(message: $"Button label must be {ComponentBuilder.MaxLabelLength} characters or less!", paramName: nameof(Label)); + if (value.Length > MaxSelectLabelLength) + throw new ArgumentException(message: $"Button label must be {MaxSelectLabelLength} characters or less!", paramName: nameof(Label)); _label = value; } From c3580fd8931ff57be660da77a779ef0be2d6bc6c Mon Sep 17 00:00:00 2001 From: Cenk Ergen <57065323+Cenngo@users.noreply.github.com> Date: Sun, 8 Aug 2021 19:53:55 +0300 Subject: [PATCH 4/5] Interface Method Declarations for Interaction Methods (#99) * added interface method declarations * inline docs --- src/Discord.Net.Core/Discord.Net.Core.xml | 121 ++++++++++++++++-- .../Entities/Guilds/IGuild.cs | 10 ++ .../Interactions/IApplicationCommand.cs | 9 +- .../Interactions/IDiscordInteraction.cs | 54 ++++++++ src/Discord.Net.Rest/Discord.Net.Rest.xml | 13 ++ .../Entities/Guilds/RestGuild.cs | 15 +++ .../Discord.Net.WebSocket.xml | 28 +++- .../Entities/Guilds/SocketGuild.cs | 3 + .../Entities/Interaction/SocketInteraction.cs | 15 +++ 9 files changed, 243 insertions(+), 25 deletions(-) diff --git a/src/Discord.Net.Core/Discord.Net.Core.xml b/src/Discord.Net.Core/Discord.Net.Core.xml index 1ab7ab78d..dfbb2fc50 100644 --- a/src/Discord.Net.Core/Discord.Net.Core.xml +++ b/src/Discord.Net.Core/Discord.Net.Core.xml @@ -3723,6 +3723,16 @@ A task that represents the asynchronous removal operation. + + + Gets this guilds slash commands commands + + The options to be used when sending the request. + + A task that represents the asynchronous get operation. The task result contains a read-only collection + of application commands found within the guild. + + Holds information for a guild integration feature. @@ -4293,13 +4303,6 @@ If the option is a subcommand or subcommand group type, this nested options will be the parameters. - - - Deletes this command - - The options to be used when sending the request. - A task that represents the asynchronous delete operation. - Represents data of an Interaction Command, see . @@ -4433,6 +4436,58 @@ read-only property, always 1. + + + Responds to an Interaction with type . + + The text of the message to be sent. + A array of embeds to send with this response. Max 10 + if the message should be read out by a text-to-speech reader, otherwise . + if the response should be hidden to everyone besides the invoker of the command, otherwise . + The allowed mentions for this response. + The request options for this response. + A to be sent with this response + A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. + + + + Sends a followup message for this interaction. + + The text of the message to be sent + A array of embeds to send with this response. Max 10 + if the message should be read out by a text-to-speech reader, otherwise . + if the response should be hidden to everyone besides the invoker of the command, otherwise . + The allowed mentions for this response. + The request options for this response. + A to be sent with this response + A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. + + The sent message. + + + + + Gets the original response for this interaction. + + The request options for this async request. + A that represents the initial response. + + + + Edits original response for this interaction. + + A delegate containing the properties to modify the message with. + The request options for this async request. + A that represents the initial response. + + + + Acknowledges this interaction. + + + A task that represents the asynchronous operation of acknowledging the interaction. + + Represents an interface used to specify classes that they are a vaild dataype of a class. @@ -4583,7 +4638,7 @@ Represents a builder for creating a . - + The max length of a . @@ -4710,7 +4765,7 @@ Gets or sets the label of the current button. - length exceeds . + length exceeds . @@ -5035,11 +5090,16 @@ The maximum length of a . + + + The maximum length of a . + + Gets or sets the label of the current select menu. - length exceeds + length exceeds @@ -7554,10 +7614,38 @@ The message for when a news channel subscription is added to a text channel. + + + The message for when a guild is disqualified from discovery. + + + + + The message for when a guild is requalified for discovery. + + + + + The message for when the initial warning is sent for the initial grace period discovery. + + + + + The message for when the final warning is sent for the initial grace period discovery. + + + + + The message for when a thread is created. + + The message is an inline reply. + + Only available in API v8 + @@ -7567,6 +7655,19 @@ Only available in API v8 + + + The message that starts a thread. + + + Only available in API v9 + + + + + The message for a invite reminder + + A metadata containing reaction information. diff --git a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs index b8fd858df..fb26bdd36 100644 --- a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs +++ b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs @@ -892,5 +892,15 @@ namespace Discord /// A task that represents the asynchronous removal operation. /// Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null); + + /// + /// Gets this guilds slash commands commands + /// + /// The options to be used when sending the request. + /// + /// A task that represents the asynchronous get operation. The task result contains a read-only collection + /// of application commands found within the guild. + /// + Task> GetApplicationCommandsAsync (RequestOptions options = null); } } diff --git a/src/Discord.Net.Core/Entities/Interactions/IApplicationCommand.cs b/src/Discord.Net.Core/Entities/Interactions/IApplicationCommand.cs index eb61c539f..a1a33acea 100644 --- a/src/Discord.Net.Core/Entities/Interactions/IApplicationCommand.cs +++ b/src/Discord.Net.Core/Entities/Interactions/IApplicationCommand.cs @@ -9,7 +9,7 @@ namespace Discord /// /// The base command model that belongs to an application. see /// - public interface IApplicationCommand : ISnowflakeEntity + public interface IApplicationCommand : ISnowflakeEntity, IDeletable { /// /// Gets the unique id of the parent application. @@ -35,12 +35,5 @@ namespace Discord /// If the option is a subcommand or subcommand group type, this nested options will be the parameters. /// IReadOnlyCollection Options { get; } - - /// - /// Deletes this command - /// - /// The options to be used when sending the request. - /// A task that represents the asynchronous delete operation. - Task DeleteAsync(RequestOptions options = null); } } diff --git a/src/Discord.Net.Core/Entities/Interactions/IDiscordInteraction.cs b/src/Discord.Net.Core/Entities/Interactions/IDiscordInteraction.cs index 466bf3e91..b5afddca2 100644 --- a/src/Discord.Net.Core/Entities/Interactions/IDiscordInteraction.cs +++ b/src/Discord.Net.Core/Entities/Interactions/IDiscordInteraction.cs @@ -39,5 +39,59 @@ namespace Discord /// read-only property, always 1. /// int Version { get; } + + /// + /// Responds to an Interaction with type . + /// + /// The text of the message to be sent. + /// A array of embeds to send with this response. Max 10 + /// if the message should be read out by a text-to-speech reader, otherwise . + /// if the response should be hidden to everyone besides the invoker of the command, otherwise . + /// The allowed mentions for this response. + /// The request options for this response. + /// A to be sent with this response + /// A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. + Task RespondAsync (string text = null, Embed[] embeds = null, bool isTTS = false, + bool ephemeral = false, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent component = null, Embed embed = null); + + /// + /// Sends a followup message for this interaction. + /// + /// The text of the message to be sent + /// A array of embeds to send with this response. Max 10 + /// if the message should be read out by a text-to-speech reader, otherwise . + /// if the response should be hidden to everyone besides the invoker of the command, otherwise . + /// The allowed mentions for this response. + /// The request options for this response. + /// A to be sent with this response + /// A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. + /// + /// The sent message. + /// + Task FollowupAsync (string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, + AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent component = null, Embed embed = null); + + /// + /// Gets the original response for this interaction. + /// + /// The request options for this async request. + /// A that represents the initial response. + Task GetOriginalResponseAsync (RequestOptions options = null); + + /// + /// Edits original response for this interaction. + /// + /// A delegate containing the properties to modify the message with. + /// The request options for this async request. + /// A that represents the initial response. + Task ModifyOriginalResponseAsync (Action func, RequestOptions options = null); + + /// + /// Acknowledges this interaction. + /// + /// + /// A task that represents the asynchronous operation of acknowledging the interaction. + /// + Task DeferAsync (RequestOptions options = null); } } diff --git a/src/Discord.Net.Rest/Discord.Net.Rest.xml b/src/Discord.Net.Rest/Discord.Net.Rest.xml index eda180f01..a9630f382 100644 --- a/src/Discord.Net.Rest/Discord.Net.Rest.xml +++ b/src/Discord.Net.Rest/Discord.Net.Rest.xml @@ -3403,6 +3403,16 @@ of webhooks found within the guild. + + + Gets this guilds slash commands commands + + The options to be used when sending the request. + + A task that represents the asynchronous get operation. The task result contains a read-only collection + of application commands found within the guild. + + Returns the name of the guild. @@ -3548,6 +3558,9 @@ + + + diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs index 37491909c..9c6f6011e 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs @@ -808,6 +808,18 @@ namespace Discord.Rest public Task> GetWebhooksAsync(RequestOptions options = null) => GuildHelper.GetWebhooksAsync(this, Discord, options); + //Interactions + /// + /// Gets this guilds slash commands commands + /// + /// The options to be used when sending the request. + /// + /// A task that represents the asynchronous get operation. The task result contains a read-only collection + /// of application commands found within the guild. + /// + public async Task> GetApplicationCommandsAsync (RequestOptions options = null) + => await ClientHelper.GetGuildApplicationCommands(Discord, Id, options).ConfigureAwait(false); + /// /// Returns the name of the guild. /// @@ -1061,5 +1073,8 @@ namespace Discord.Rest /// async Task> IGuild.GetWebhooksAsync(RequestOptions options) => await GetWebhooksAsync(options).ConfigureAwait(false); + /// + async Task> IGuild.GetApplicationCommandsAsync (RequestOptions options) + => await GetApplicationCommandsAsync(options).ConfigureAwait(false); } } diff --git a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml index b17f73024..72ec97e58 100644 --- a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml +++ b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml @@ -3477,6 +3477,9 @@ + + + Represents a Websocket-based interaction type for Message Components. @@ -3492,7 +3495,7 @@ The message that contained the trigger for this interaction. - + @@ -3503,7 +3506,7 @@ The request options for this async request. A task that represents the asynchronous operation of updating the message. - + @@ -3619,10 +3622,10 @@ The data associated with this interaction. - + - + @@ -3708,12 +3711,12 @@ if the token is valid for replying to, otherwise . - + Responds to an Interaction with type . If you have set to , You should use - instead. + instead. The text of the message to be sent. @@ -3723,10 +3726,11 @@ The allowed mentions for this response. The request options for this response. A to be sent with this response + A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. Message content is too long, length must be less or equal to . The parameters provided were invalid or the token was invalid. - + Sends a followup message for this interaction. @@ -3737,6 +3741,7 @@ The allowed mentions for this response. The request options for this response. A to be sent with this response + A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. The sent message. @@ -3772,6 +3777,15 @@ A task that represents the asynchronous operation of acknowledging the interaction. + + + + + + + + + Represents a WebSocket-based invite to a guild. diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs index f720db018..ce188e707 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs @@ -1436,6 +1436,9 @@ namespace Discord.WebSocket /// async Task> IGuild.GetWebhooksAsync(RequestOptions options) => await GetWebhooksAsync(options).ConfigureAwait(false); + /// + async Task> IGuild.GetApplicationCommandsAsync (RequestOptions options) + => await GetApplicationCommandsAsync(options).ConfigureAwait(false); void IDisposable.Dispose() { diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs index 4b2e3baec..5547fed1e 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs @@ -171,5 +171,20 @@ namespace Discord.WebSocket // Tokens last for 15 minutes according to https://discord.com/developers/docs/interactions/slash-commands#responding-to-an-interaction return (DateTime.UtcNow - this.CreatedAt.UtcDateTime).TotalMinutes <= 15d; } + + // IDiscordInteraction + + /// + async Task IDiscordInteraction.FollowupAsync (string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions, + RequestOptions options, MessageComponent component, Embed embed) + => await FollowupAsync(text, embeds, isTTS, ephemeral, allowedMentions, options, component, embed).ConfigureAwait(false); + + /// + async Task IDiscordInteraction.GetOriginalResponseAsync (RequestOptions options) + => await GetOriginalResponseAsync(options).ConfigureAwait(false); + + /// + async Task IDiscordInteraction.ModifyOriginalResponseAsync (Action func, RequestOptions options) + => await ModifyOriginalResponseAsync(func, options).ConfigureAwait(false); } } From 07962445072e57f231a531f237e01f859fc95871 Mon Sep 17 00:00:00 2001 From: Cenk Ergen <57065323+Cenngo@users.noreply.github.com> Date: Wed, 11 Aug 2021 03:49:25 +0300 Subject: [PATCH 5/5] Assign CurrentUserId in Sharded Client (#100) * added interface method declarations * inline docs * current user id assignment in sharded client --- src/Discord.Net.WebSocket/DiscordShardedClient.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Discord.Net.WebSocket/DiscordShardedClient.cs b/src/Discord.Net.WebSocket/DiscordShardedClient.cs index 386f9f7e5..99a60607a 100644 --- a/src/Discord.Net.WebSocket/DiscordShardedClient.cs +++ b/src/Discord.Net.WebSocket/DiscordShardedClient.cs @@ -30,7 +30,16 @@ namespace Discord.WebSocket /// public override IActivity Activity { get => _shards[0].Activity; protected set { } } - internal new DiscordSocketApiClient ApiClient => base.ApiClient as DiscordSocketApiClient; + internal new DiscordSocketApiClient ApiClient + { + get + { + if (base.ApiClient.CurrentUserId == null) + base.ApiClient.CurrentUserId = CurrentUser?.Id; + + return base.ApiClient; + } + } /// public override IReadOnlyCollection Guilds => GetGuilds().ToReadOnlyCollection(GetGuildCount); ///