Skip to content

Commit

Permalink
actually handle the resumed event
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Oct 10, 2023
1 parent 8d8433f commit 68bdea0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions gateway/gateway_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
12 changes: 6 additions & 6 deletions gateway/gateway_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion gateway/gateway_messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 68bdea0

Please sign in to comment.