forked from pothtonswer/discordmuffin
feat(events): add support for IntegrationXXX events (#1545)
--------- Co-authored-by: Fedor Lapshin <fe.lap.prog@gmail.com>
This commit is contained in:
parent
dec4d43ba0
commit
d23158b3a3
2 changed files with 91 additions and 0 deletions
|
@ -39,6 +39,9 @@ const (
|
||||||
guildScheduledEventUserAddEventType = "GUILD_SCHEDULED_EVENT_USER_ADD"
|
guildScheduledEventUserAddEventType = "GUILD_SCHEDULED_EVENT_USER_ADD"
|
||||||
guildScheduledEventUserRemoveEventType = "GUILD_SCHEDULED_EVENT_USER_REMOVE"
|
guildScheduledEventUserRemoveEventType = "GUILD_SCHEDULED_EVENT_USER_REMOVE"
|
||||||
guildUpdateEventType = "GUILD_UPDATE"
|
guildUpdateEventType = "GUILD_UPDATE"
|
||||||
|
integrationCreateEventType = "INTEGRATION_CREATE"
|
||||||
|
integrationDeleteEventType = "INTEGRATION_DELETE"
|
||||||
|
integrationUpdateEventType = "INTEGRATION_UPDATE"
|
||||||
interactionCreateEventType = "INTERACTION_CREATE"
|
interactionCreateEventType = "INTERACTION_CREATE"
|
||||||
inviteCreateEventType = "INVITE_CREATE"
|
inviteCreateEventType = "INVITE_CREATE"
|
||||||
inviteDeleteEventType = "INVITE_DELETE"
|
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.
|
// interactionCreateEventHandler is an event handler for InteractionCreate events.
|
||||||
type interactionCreateEventHandler func(*Session, *InteractionCreate)
|
type interactionCreateEventHandler func(*Session, *InteractionCreate)
|
||||||
|
|
||||||
|
@ -1380,6 +1443,12 @@ func handlerForInterface(handler interface{}) EventHandler {
|
||||||
return guildScheduledEventUserRemoveEventHandler(v)
|
return guildScheduledEventUserRemoveEventHandler(v)
|
||||||
case func(*Session, *GuildUpdate):
|
case func(*Session, *GuildUpdate):
|
||||||
return guildUpdateEventHandler(v)
|
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):
|
case func(*Session, *InteractionCreate):
|
||||||
return interactionCreateEventHandler(v)
|
return interactionCreateEventHandler(v)
|
||||||
case func(*Session, *InviteCreate):
|
case func(*Session, *InviteCreate):
|
||||||
|
@ -1477,6 +1546,9 @@ func init() {
|
||||||
registerInterfaceProvider(guildScheduledEventUserAddEventHandler(nil))
|
registerInterfaceProvider(guildScheduledEventUserAddEventHandler(nil))
|
||||||
registerInterfaceProvider(guildScheduledEventUserRemoveEventHandler(nil))
|
registerInterfaceProvider(guildScheduledEventUserRemoveEventHandler(nil))
|
||||||
registerInterfaceProvider(guildUpdateEventHandler(nil))
|
registerInterfaceProvider(guildUpdateEventHandler(nil))
|
||||||
|
registerInterfaceProvider(integrationCreateEventHandler(nil))
|
||||||
|
registerInterfaceProvider(integrationDeleteEventHandler(nil))
|
||||||
|
registerInterfaceProvider(integrationUpdateEventHandler(nil))
|
||||||
registerInterfaceProvider(interactionCreateEventHandler(nil))
|
registerInterfaceProvider(interactionCreateEventHandler(nil))
|
||||||
registerInterfaceProvider(inviteCreateEventHandler(nil))
|
registerInterfaceProvider(inviteCreateEventHandler(nil))
|
||||||
registerInterfaceProvider(inviteDeleteEventHandler(nil))
|
registerInterfaceProvider(inviteDeleteEventHandler(nil))
|
||||||
|
|
19
events.go
19
events.go
|
@ -241,6 +241,25 @@ type GuildScheduledEventUserRemove struct {
|
||||||
GuildID string `json:"guild_id"`
|
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.
|
// MessageCreate is the data for a MessageCreate event.
|
||||||
type MessageCreate struct {
|
type MessageCreate struct {
|
||||||
*Message
|
*Message
|
||||||
|
|
Loading…
Reference in a new issue