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] 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);
///