From b6a4266438a05650a02104a4e254e82997486434 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Mon, 14 Jun 2021 13:56:25 -0700 Subject: [PATCH] gateway: Allow custom SessionID --- gateway/gateway.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gateway/gateway.go b/gateway/gateway.go index da512fd..c5c86a7 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -278,6 +278,14 @@ func (g *Gateway) SessionID() string { return g.sessionID } +// UseSessionID overrides the internal session ID for the one the user provides. +func (g *Gateway) UseSessionID(sessionID string) { + g.sessionMu.Lock() + defer g.sessionMu.Unlock() + + g.sessionID = sessionID +} + // OnShardingRequired sets the function to be called if Discord closes with // error code 4011 aka Sharding Required. When called, the Gateway will already // be closed, and can (after increasing the number of shards) be reopened using