diff --git a/eventhandlers.go b/eventhandlers.go index 1d0a61638..659b6748e 100644 --- a/eventhandlers.go +++ b/eventhandlers.go @@ -39,6 +39,9 @@ const ( guildScheduledEventUserAddEventType = "GUILD_SCHEDULED_EVENT_USER_ADD" guildScheduledEventUserRemoveEventType = "GUILD_SCHEDULED_EVENT_USER_REMOVE" guildUpdateEventType = "GUILD_UPDATE" + integrationCreateEventType = "INTEGRATION_CREATE" + integrationDeleteEventType = "INTEGRATION_DELETE" + integrationUpdateEventType = "INTEGRATION_UPDATE" interactionCreateEventType = "INTERACTION_CREATE" inviteCreateEventType = "INVITE_CREATE" inviteDeleteEventType = "INVITE_DELETE" @@ -697,6 +700,66 @@ func (eh guildUpdateEventHandler) Handle(s *Session, i interface{}) { } } +// integrationCreateEventHandler is an event handler for IntegrationCreate events. +type integrationCreateEventHandler func(*Session, *IntegrationCreate) + +// Type returns the event type for IntegrationCreate events. +func (eh integrationCreateEventHandler) Type() string { + return integrationCreateEventType +} + +// New returns a new instance of IntegrationCreate. +func (eh integrationCreateEventHandler) New() interface{} { + return &IntegrationCreate{} +} + +// Handle is the handler for IntegrationCreate events. +func (eh integrationCreateEventHandler) Handle(s *Session, i interface{}) { + if t, ok := i.(*IntegrationCreate); ok { + eh(s, t) + } +} + +// integrationDeleteEventHandler is an event handler for IntegrationDelete events. +type integrationDeleteEventHandler func(*Session, *IntegrationDelete) + +// Type returns the event type for IntegrationDelete events. +func (eh integrationDeleteEventHandler) Type() string { + return integrationDeleteEventType +} + +// New returns a new instance of IntegrationDelete. +func (eh integrationDeleteEventHandler) New() interface{} { + return &IntegrationDelete{} +} + +// Handle is the handler for IntegrationDelete events. +func (eh integrationDeleteEventHandler) Handle(s *Session, i interface{}) { + if t, ok := i.(*IntegrationDelete); ok { + eh(s, t) + } +} + +// integrationUpdateEventHandler is an event handler for IntegrationUpdate events. +type integrationUpdateEventHandler func(*Session, *IntegrationUpdate) + +// Type returns the event type for IntegrationUpdate events. +func (eh integrationUpdateEventHandler) Type() string { + return integrationUpdateEventType +} + +// New returns a new instance of IntegrationUpdate. +func (eh integrationUpdateEventHandler) New() interface{} { + return &IntegrationUpdate{} +} + +// Handle is the handler for IntegrationUpdate events. +func (eh integrationUpdateEventHandler) Handle(s *Session, i interface{}) { + if t, ok := i.(*IntegrationUpdate); ok { + eh(s, t) + } +} + // interactionCreateEventHandler is an event handler for InteractionCreate events. type interactionCreateEventHandler func(*Session, *InteractionCreate) @@ -1380,6 +1443,12 @@ func handlerForInterface(handler interface{}) EventHandler { return guildScheduledEventUserRemoveEventHandler(v) case func(*Session, *GuildUpdate): return guildUpdateEventHandler(v) + case func(*Session, *IntegrationCreate): + return integrationCreateEventHandler(v) + case func(*Session, *IntegrationDelete): + return integrationDeleteEventHandler(v) + case func(*Session, *IntegrationUpdate): + return integrationUpdateEventHandler(v) case func(*Session, *InteractionCreate): return interactionCreateEventHandler(v) case func(*Session, *InviteCreate): @@ -1477,6 +1546,9 @@ func init() { registerInterfaceProvider(guildScheduledEventUserAddEventHandler(nil)) registerInterfaceProvider(guildScheduledEventUserRemoveEventHandler(nil)) registerInterfaceProvider(guildUpdateEventHandler(nil)) + registerInterfaceProvider(integrationCreateEventHandler(nil)) + registerInterfaceProvider(integrationDeleteEventHandler(nil)) + registerInterfaceProvider(integrationUpdateEventHandler(nil)) registerInterfaceProvider(interactionCreateEventHandler(nil)) registerInterfaceProvider(inviteCreateEventHandler(nil)) registerInterfaceProvider(inviteDeleteEventHandler(nil)) diff --git a/events.go b/events.go index e19290ec0..6a23a9e23 100644 --- a/events.go +++ b/events.go @@ -241,6 +241,25 @@ type GuildScheduledEventUserRemove struct { GuildID string `json:"guild_id"` } +// IntegrationCreate is the data for a IntegrationCreate event. +type IntegrationCreate struct { + *Integration + GuildID string `json:"guild_id"` +} + +// IntegrationUpdate is the data for a IntegrationUpdate event. +type IntegrationUpdate struct { + *Integration + GuildID string `json:"guild_id"` +} + +// IntegrationDelete is the data for a IntegrationDelete event. +type IntegrationDelete struct { + ID string `json:"id"` + GuildID string `json:"guild_id"` + ApplicationID string `json:"application_id,omitempty"` +} + // MessageCreate is the data for a MessageCreate event. type MessageCreate struct { *Message