Fix Current user null on reconnect (#2092)
This commit is contained in:
@@ -46,6 +46,7 @@ namespace Discord.WebSocket
|
||||
private bool _isDisposed;
|
||||
private GatewayIntents _gatewayIntents;
|
||||
private ImmutableArray<StickerPack<SocketSticker>> _defaultStickers;
|
||||
private SocketSelfUser _previousSessionUser;
|
||||
|
||||
/// <summary>
|
||||
/// 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;
|
||||
|
||||
Reference in New Issue
Block a user