Skip to content

Commit

Permalink
Fix Current user null on reconnect (#2092)
Browse files Browse the repository at this point in the history
  • Loading branch information
quinchs authored Feb 9, 2022
1 parent 75e94fe commit b424bb2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Discord.Net.WebSocket/DiscordSocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public partial class DiscordSocketClient : BaseSocketClient, IDiscordClient
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.
Expand Down Expand Up @@ -888,6 +889,7 @@ private async Task ProcessMessageAsync(GatewayOpCode opCode, int? seq, string ty
_sessionId = data.SessionId;
_unavailableGuildCount = unavailableGuilds;
CurrentUser = currentUser;
_previousSessionUser = CurrentUser;
State = state;
}
catch (Exception ex)
Expand Down Expand Up @@ -930,6 +932,9 @@ private async Task ProcessMessageAsync(GatewayOpCode opCode, int? seq, string ty
await GuildAvailableAsync(guild).ConfigureAwait(false);
}

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

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

0 comments on commit b424bb2

Please sign in to comment.