Fix Current user null on reconnect (#2092)

This commit is contained in:
Quin Lynch
2022-02-09 00:12:07 -04:00
committed by GitHub
parent 75e94feab0
commit b424bb2019

View File

@@ -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;