diff --git a/gateway/gateway_events.go b/gateway/gateway_events.go index a2f717d5..484ad95e 100644 --- a/gateway/gateway_events.go +++ b/gateway/gateway_events.go @@ -43,6 +43,12 @@ type EventReady struct { func (EventReady) messageData() {} func (EventReady) eventData() {} +// EventResumed is the event sent by discord when you successfully resume +type EventResumed struct{} + +func (EventResumed) messageData() {} +func (EventResumed) eventData() {} + type EventApplicationCommandPermissionsUpdate struct { discord.ApplicationCommandPermissions } diff --git a/gateway/gateway_impl.go b/gateway/gateway_impl.go index 3eaf1855..92b3cb8b 100644 --- a/gateway/gateway_impl.go +++ b/gateway/gateway_impl.go @@ -424,12 +424,6 @@ loop: return } - case OpcodeResume: - g.config.Logger.Debug(g.formatLogs("resume successful")) - g.status = StatusReady - readyChan <- nil - close(readyChan) - case OpcodeDispatch: // set last sequence received g.config.LastSequenceReceived = &message.S @@ -462,6 +456,12 @@ loop: } g.eventHandlerFunc(message.T, message.S, g.config.ShardID, eventData) if _, ok = eventData.(EventReady); ok { + g.config.Logger.Debug(g.formatLogs("ready successful")) + readyChan <- nil + close(readyChan) + } else if _, ok = eventData.(EventResumed); ok { + g.config.Logger.Debug(g.formatLogs("resume successful")) + g.status = StatusReady readyChan <- nil close(readyChan) } diff --git a/gateway/gateway_messages.go b/gateway/gateway_messages.go index 301f8fa6..efbcafb8 100644 --- a/gateway/gateway_messages.go +++ b/gateway/gateway_messages.go @@ -112,7 +112,7 @@ func UnmarshalEventData(data []byte, eventType EventType) (EventData, error) { eventData = d case EventTypeResumed: - // no data + eventData = EventResumed{} case EventTypeApplicationCommandPermissionsUpdate: var d EventApplicationCommandPermissionsUpdate