Skip to content

Commit b424bb2

Browse files
authored
Fix Current user null on reconnect (#2092)
1 parent 75e94fe commit b424bb2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Discord.Net.WebSocket/DiscordSocketClient.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public partial class DiscordSocketClient : BaseSocketClient, IDiscordClient
4646
private bool _isDisposed;
4747
private GatewayIntents _gatewayIntents;
4848
private ImmutableArray<StickerPack<SocketSticker>> _defaultStickers;
49+
private SocketSelfUser _previousSessionUser;
4950

5051
/// <summary>
5152
/// Provides access to a REST-only client with a shared state from this client.
@@ -888,6 +889,7 @@ private async Task ProcessMessageAsync(GatewayOpCode opCode, int? seq, string ty
888889
_sessionId = data.SessionId;
889890
_unavailableGuildCount = unavailableGuilds;
890891
CurrentUser = currentUser;
892+
_previousSessionUser = CurrentUser;
891893
State = state;
892894
}
893895
catch (Exception ex)
@@ -930,6 +932,9 @@ private async Task ProcessMessageAsync(GatewayOpCode opCode, int? seq, string ty
930932
await GuildAvailableAsync(guild).ConfigureAwait(false);
931933
}
932934

935+
// Restore the previous sessions current user
936+
CurrentUser = _previousSessionUser;
937+
933938
await _gatewayLogger.InfoAsync("Resumed previous session").ConfigureAwait(false);
934939
}
935940
break;

0 commit comments

Comments
 (0)