func (c *Client) eventHandler() {
	for {
		var err error
		var evt websocket.DiscordWSEvent

		evt, err = waitForEvent(c.socketEvtChan)
		if err != nil {
			return
		}

		evtName := evt.Name()
		var box eventBox

		switch evtName {
		case EventReady:
			box = &Ready{}
		case EventResumed:
			box = &Resumed{}
		case EventChannelCreate:
			box = &ChannelCreate{}
		case EventChannelUpdate:
			box = &ChannelUpdate{}
		case EventChannelDelete:
			box = &ChannelDelete{}
		case EventChannelPinsUpdate:
			box = &ChannelPinsUpdate{}
		case EventGuildCreate:
			box = &GuildCreate{}
		case EventGuildUpdate:
			box = &GuildUpdate{}
		case EventGuildDelete:
			box = &GuildDelete{}
		case EventGuildBanAdd:
			box = &GuildBanAdd{}
		case EventGuildBanRemove:
			box = &GuildBanRemove{}
		case EventGuildEmojisUpdate:
			box = &GuildEmojisUpdate{}
		case EventGuildIntegrationsUpdate:
			box = &GuildIntegrationsUpdate{}
		case EventGuildMemberAdd:
			box = &GuildMemberAdd{}
		case EventGuildMemberRemove:
			box = &GuildMemberRemove{}
		case EventGuildMemberUpdate:
			box = &GuildMemberUpdate{}
		case EventGuildMembersChunk:
			box = &GuildMembersChunk{}
		case EventGuildRoleCreate:
			box = &GuildRoleCreate{}
		case EventGuildRoleUpdate:
			box = &GuildRoleUpdate{}
		case EventGuildRoleDelete:
			box = &GuildRoleDelete{}
		case EventMessageCreate:
			box = &MessageCreate{}
		case EventMessageUpdate:
			box = &MessageUpdate{}
		case EventMessageDelete:
			box = &MessageDelete{}
		case EventMessageDeleteBulk:
			box = &MessageDeleteBulk{}
		case EventMessageReactionAdd:
			box = &MessageReactionAdd{}
		case EventMessageReactionRemove:
			box = &MessageReactionRemove{}
		case EventMessageReactionRemoveAll:
			box = &MessageReactionRemoveAll{}
		case EventPresenceUpdate:
			box = &PresenceUpdate{}
		case EventTypingStart:
			box = &TypingStart{}
		case EventUserUpdate:
			box = &UserUpdate{}
		case EventVoiceStateUpdate:
			box = &VoiceStateUpdate{}
		case EventVoiceServerUpdate:
			box = &VoiceServerUpdate{}
		case EventWebhooksUpdate:
			box = &WebhooksUpdate{}
		default:
			fmt.Printf("------\nTODO\nImplement event handler for `%s`, data: \n%+v\n------\n\n", evtName, string(evt.Data()))
			continue // move on to next event
		}

		// populate box
		ctx := context.Background()
		data := evt.Data()

		box.registerContext(ctx)
		err = unmarshal(data, box)
		if err != nil {
			logrus.Error(err)
			continue // ignore event
			// TODO: if an event is ignored, should it not at least send a signal for listeners with no parameters?
		}

		// trigger listeners
		c.evtDispatch.triggerChan(ctx, evtName, c, box)
		c.evtDispatch.triggerCallbacks(ctx, evtName, c, box)
	}
}
// eventHandler Takes a incoming event from the websocket package, parses it, and sends
// trigger requests to the event dispatcher and state cacher.
eventHandler Takes a incoming event from the websocket package, parses it, and sends
trigger requests to the event dispatcher and state cacher.
// eventHandler Takes a incoming event from the websocket package parses it and sends // trigger requests to the event dispatcher and state cacher .
func (c *Client) eventHandler() {
	for {
		var err error
		var evt websocket.DiscordWSEvent
		evt, err = waitForEvent(c.socketEvtChan)
		if err != nil {
			return
		}
		evtName := evt.Name()
		var box eventBox
		switch evtName {
		case EventReady:
			box = &Ready{}
		case EventResumed:
			box = &Resumed{}
		case EventChannelCreate:
			box = &ChannelCreate{}
		case EventChannelUpdate:
			box = &ChannelUpdate{}
		case EventChannelDelete:
			box = &ChannelDelete{}
		case EventChannelPinsUpdate:
			box = &ChannelPinsUpdate{}
		case EventGuildCreate:
			box = &GuildCreate{}
		case EventGuildUpdate:
			box = &GuildUpdate{}
		case EventGuildDelete:
			box = &GuildDelete{}
		case EventGuildBanAdd:
			box = &GuildBanAdd{}
		case EventGuildBanRemove:
			box = &GuildBanRemove{}
		case EventGuildEmojisUpdate:
			box = &GuildEmojisUpdate{}
		case EventGuildIntegrationsUpdate:
			box = &GuildIntegrationsUpdate{}
		case EventGuildMemberAdd:
			box = &GuildMemberAdd{}
		case EventGuildMemberRemove:
			box = &GuildMemberRemove{}
		case EventGuildMemberUpdate:
			box = &GuildMemberUpdate{}
		case EventGuildMembersChunk:
			box = &GuildMembersChunk{}
		case EventGuildRoleCreate:
			box = &GuildRoleCreate{}
		case EventGuildRoleUpdate:
			box = &GuildRoleUpdate{}
		case EventGuildRoleDelete:
			box = &GuildRoleDelete{}
		case EventMessageCreate:
			box = &MessageCreate{}
		case EventMessageUpdate:
			box = &MessageUpdate{}
		case EventMessageDelete:
			box = &MessageDelete{}
		case EventMessageDeleteBulk:
			box = &MessageDeleteBulk{}
		case EventMessageReactionAdd:
			box = &MessageReactionAdd{}
		case EventMessageReactionRemove:
			box = &MessageReactionRemove{}
		case EventMessageReactionRemoveAll:
			box = &MessageReactionRemoveAll{}
		case EventPresenceUpdate:
			box = &PresenceUpdate{}
		case EventTypingStart:
			box = &TypingStart{}
		case EventUserUpdate:
			box = &UserUpdate{}
		case EventVoiceStateUpdate:
			box = &VoiceStateUpdate{}
		case EventVoiceServerUpdate:
			box = &VoiceServerUpdate{}
		case EventWebhooksUpdate:
			box = &WebhooksUpdate{}
		default:
			fmt.Printf("------\nTODO\nImplement event handler for `%s`, data: \n%+v\n------\n\n", evtName, string(evt.Data()))
			continue 
		}
		ctx := context.Background()
		data := evt.Data()
		box.registerContext(ctx)
		err = unmarshal(data, box)
		if err != nil {
			logrus.Error(err)
			continue 
		}
		c.evtDispatch.triggerChan(ctx, evtName, c, box)
		c.evtDispatch.triggerCallbacks(ctx, evtName, c, box)
	}
}
func ( c * Client ) eventHandler ( ) { for { var err error var evt websocket . DiscordWSEvent evt , err = waitForEvent ( c . socketEvtChan ) if err != nil { return } evtName := evt . Name ( ) var box eventBox switch evtName { case EventReady : box = & Ready { } case EventResumed : box = & Resumed { } case EventChannelCreate : box = & ChannelCreate { } case EventChannelUpdate : box = & ChannelUpdate { } case EventChannelDelete : box = & ChannelDelete { } case EventChannelPinsUpdate : box = & ChannelPinsUpdate { } case EventGuildCreate : box = & GuildCreate { } case EventGuildUpdate : box = & GuildUpdate { } case EventGuildDelete : box = & GuildDelete { } case EventGuildBanAdd : box = & GuildBanAdd { } case EventGuildBanRemove : box = & GuildBanRemove { } case EventGuildEmojisUpdate : box = & GuildEmojisUpdate { } case EventGuildIntegrationsUpdate : box = & GuildIntegrationsUpdate { } case EventGuildMemberAdd : box = & GuildMemberAdd { } case EventGuildMemberRemove : box = & GuildMemberRemove { } case EventGuildMemberUpdate : box = & GuildMemberUpdate { } case EventGuildMembersChunk : box = & GuildMembersChunk { } case EventGuildRoleCreate : box = & GuildRoleCreate { } case EventGuildRoleUpdate : box = & GuildRoleUpdate { } case EventGuildRoleDelete : box = & GuildRoleDelete { } case EventMessageCreate : box = & MessageCreate { } case EventMessageUpdate : box = & MessageUpdate { } case EventMessageDelete : box = & MessageDelete { } case EventMessageDeleteBulk : box = & MessageDeleteBulk { } case EventMessageReactionAdd : box = & MessageReactionAdd { } case EventMessageReactionRemove : box = & MessageReactionRemove { } case EventMessageReactionRemoveAll : box = & MessageReactionRemoveAll { } case EventPresenceUpdate : box = & PresenceUpdate { } case EventTypingStart : box = & TypingStart { } case EventUserUpdate : box = & UserUpdate { } case EventVoiceStateUpdate : box = & VoiceStateUpdate { } case EventVoiceServerUpdate : box = & VoiceServerUpdate { } case EventWebhooksUpdate : box = & WebhooksUpdate { } default : fmt . Printf ( " \n \n \n \n \n \n " , evtName , string ( evt . Data ( ) ) ) continue } ctx := context . Background ( ) data := evt . Data ( ) box . registerContext ( ctx ) err = unmarshal ( data , box ) if err != nil { logrus . Error ( err ) continue } c . evtDispatch . triggerChan ( ctx , evtName , c , box ) c . evtDispatch . triggerCallbacks ( ctx , evtName , c , box ) } }
eventHandler Takes a incoming event from the websocket package, parses it, and sends
trigger requests to the event dispatcher and state cacher.
eventHandler Takes a incoming event from the websocket package parses it and sends trigger requests to the event dispatcher and state cacher .
// move on to next event // populate box // ignore event // TODO: if an event is ignored, should it not at least send a signal for listeners with no parameters? // trigger listeners