diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs index 349e2714f..e8e210e1a 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs @@ -46,6 +46,7 @@ namespace Discord.WebSocket private bool _isDisposed; private GatewayIntents _gatewayIntents; private ImmutableArray> _defaultStickers; + private SocketSelfUser _previousSessionUser; /// /// Provides access to a REST-only client with a shared state from this client. @@ -888,6 +889,7 @@ namespace Discord.WebSocket _sessionId = data.SessionId; _unavailableGuildCount = unavailableGuilds; CurrentUser = currentUser; + _previousSessionUser = CurrentUser; State = state; } catch (Exception ex) @@ -930,6 +932,9 @@ namespace Discord.WebSocket await GuildAvailableAsync(guild).ConfigureAwait(false); } + // Restore the previous sessions current user + CurrentUser = _previousSessionUser; + await _gatewayLogger.InfoAsync("Resumed previous session").ConfigureAwait(false); } break;