Fix Current user null on reconnect (#2092)
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user