diff --git a/event.go b/event.go index 906c2aa..1524f32 100644 --- a/event.go +++ b/event.go @@ -156,12 +156,20 @@ func (s *Session) removeEventHandlerInstance(t string, ehi *eventHandlerInstance // Handles calling permanent and once handlers for an event type. func (s *Session) handle(t string, i interface{}) { for _, eh := range s.handlers[t] { - go eh.eventHandler.Handle(s, i) + if s.SyncEvents { + eh.eventHandler.Handle(s, i) + } else { + go eh.eventHandler.Handle(s, i) + } } if len(s.onceHandlers[t]) > 0 { for _, eh := range s.onceHandlers[t] { - go eh.eventHandler.Handle(s, i) + if s.SyncEvents { + eh.eventHandler.Handle(s, i) + } else { + go eh.eventHandler.Handle(s, i) + } } s.onceHandlers[t] = nil } diff --git a/structs.go b/structs.go index d9f9699..50f414c 100644 --- a/structs.go +++ b/structs.go @@ -50,6 +50,10 @@ type Session struct { // active guilds and the members of the guilds. StateEnabled bool + // Whether or not to call event handlers synchronously. + // e.g false = launch event handlers in their own goroutines. + SyncEvents bool + // Exposed but should not be modified by User. // Whether the Data Websocket is ready