Browse Source

Fix Current user null on reconnect (#2092)

tags/3.3.0
Quin Lynch GitHub 3 years ago
parent
commit
b424bb2019
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions
  1. +5
    -0
      src/Discord.Net.WebSocket/DiscordSocketClient.cs

+ 5
- 0
src/Discord.Net.WebSocket/DiscordSocketClient.cs View File

@@ -46,6 +46,7 @@ namespace Discord.WebSocket
private bool _isDisposed; private bool _isDisposed;
private GatewayIntents _gatewayIntents; private GatewayIntents _gatewayIntents;
private ImmutableArray<StickerPack<SocketSticker>> _defaultStickers; private ImmutableArray<StickerPack<SocketSticker>> _defaultStickers;
private SocketSelfUser _previousSessionUser;


/// <summary> /// <summary>
/// Provides access to a REST-only client with a shared state from this client. /// Provides access to a REST-only client with a shared state from this client.
@@ -888,6 +889,7 @@ namespace Discord.WebSocket
_sessionId = data.SessionId; _sessionId = data.SessionId;
_unavailableGuildCount = unavailableGuilds; _unavailableGuildCount = unavailableGuilds;
CurrentUser = currentUser; CurrentUser = currentUser;
_previousSessionUser = CurrentUser;
State = state; State = state;
} }
catch (Exception ex) catch (Exception ex)
@@ -930,6 +932,9 @@ namespace Discord.WebSocket
await GuildAvailableAsync(guild).ConfigureAwait(false); await GuildAvailableAsync(guild).ConfigureAwait(false);
} }


// Restore the previous sessions current user
CurrentUser = _previousSessionUser;

await _gatewayLogger.InfoAsync("Resumed previous session").ConfigureAwait(false); await _gatewayLogger.InfoAsync("Resumed previous session").ConfigureAwait(false);
} }
break; break;


Loading…
Cancel
Save