Implement Audit Log Entry Create event (#1314)
* Implement GUILD_AUDIT_LOG_ENTRY_CREATE event. * Rename IntentGuildBans constant to IntentGuildModeration to match API documentation.
This commit is contained in:
parent
b7c431c368
commit
6958472163
3 changed files with 32 additions and 1 deletions
|
@ -19,6 +19,7 @@ const (
|
||||||
connectEventType = "__CONNECT__"
|
connectEventType = "__CONNECT__"
|
||||||
disconnectEventType = "__DISCONNECT__"
|
disconnectEventType = "__DISCONNECT__"
|
||||||
eventEventType = "__EVENT__"
|
eventEventType = "__EVENT__"
|
||||||
|
guildAuditLogEntryCreateEventType = "GUILD_AUDIT_LOG_ENTRY_CREATE"
|
||||||
guildBanAddEventType = "GUILD_BAN_ADD"
|
guildBanAddEventType = "GUILD_BAN_ADD"
|
||||||
guildBanRemoveEventType = "GUILD_BAN_REMOVE"
|
guildBanRemoveEventType = "GUILD_BAN_REMOVE"
|
||||||
guildCreateEventType = "GUILD_CREATE"
|
guildCreateEventType = "GUILD_CREATE"
|
||||||
|
@ -294,6 +295,26 @@ func (eh eventEventHandler) Handle(s *Session, i interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// guildAuditLogEntryCreateEventHandler is an event handler for GuildAuditLogEntryCreate events.
|
||||||
|
type guildAuditLogEntryCreateEventHandler func(*Session, *GuildAuditLogEntryCreate)
|
||||||
|
|
||||||
|
// Type returns the event type for GuildAuditLogEntryCreate events.
|
||||||
|
func (eh guildAuditLogEntryCreateEventHandler) Type() string {
|
||||||
|
return guildAuditLogEntryCreateEventType
|
||||||
|
}
|
||||||
|
|
||||||
|
// New returns a new instance of GuildAuditLogEntryCreate.
|
||||||
|
func (eh guildAuditLogEntryCreateEventHandler) New() interface{} {
|
||||||
|
return &GuildAuditLogEntryCreate{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle is the handler for GuildAuditLogEntryCreate events.
|
||||||
|
func (eh guildAuditLogEntryCreateEventHandler) Handle(s *Session, i interface{}) {
|
||||||
|
if t, ok := i.(*GuildAuditLogEntryCreate); ok {
|
||||||
|
eh(s, t)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// guildBanAddEventHandler is an event handler for GuildBanAdd events.
|
// guildBanAddEventHandler is an event handler for GuildBanAdd events.
|
||||||
type guildBanAddEventHandler func(*Session, *GuildBanAdd)
|
type guildBanAddEventHandler func(*Session, *GuildBanAdd)
|
||||||
|
|
||||||
|
@ -1277,6 +1298,8 @@ func handlerForInterface(handler interface{}) EventHandler {
|
||||||
return disconnectEventHandler(v)
|
return disconnectEventHandler(v)
|
||||||
case func(*Session, *Event):
|
case func(*Session, *Event):
|
||||||
return eventEventHandler(v)
|
return eventEventHandler(v)
|
||||||
|
case func(*Session, *GuildAuditLogEntryCreate):
|
||||||
|
return guildAuditLogEntryCreateEventHandler(v)
|
||||||
case func(*Session, *GuildBanAdd):
|
case func(*Session, *GuildBanAdd):
|
||||||
return guildBanAddEventHandler(v)
|
return guildBanAddEventHandler(v)
|
||||||
case func(*Session, *GuildBanRemove):
|
case func(*Session, *GuildBanRemove):
|
||||||
|
@ -1388,6 +1411,7 @@ func init() {
|
||||||
registerInterfaceProvider(channelDeleteEventHandler(nil))
|
registerInterfaceProvider(channelDeleteEventHandler(nil))
|
||||||
registerInterfaceProvider(channelPinsUpdateEventHandler(nil))
|
registerInterfaceProvider(channelPinsUpdateEventHandler(nil))
|
||||||
registerInterfaceProvider(channelUpdateEventHandler(nil))
|
registerInterfaceProvider(channelUpdateEventHandler(nil))
|
||||||
|
registerInterfaceProvider(guildAuditLogEntryCreateEventHandler(nil))
|
||||||
registerInterfaceProvider(guildBanAddEventHandler(nil))
|
registerInterfaceProvider(guildBanAddEventHandler(nil))
|
||||||
registerInterfaceProvider(guildBanRemoveEventHandler(nil))
|
registerInterfaceProvider(guildBanRemoveEventHandler(nil))
|
||||||
registerInterfaceProvider(guildCreateEventHandler(nil))
|
registerInterfaceProvider(guildCreateEventHandler(nil))
|
||||||
|
|
|
@ -401,3 +401,8 @@ type AutoModerationActionExecution struct {
|
||||||
MatchedKeyword string `json:"matched_keyword"`
|
MatchedKeyword string `json:"matched_keyword"`
|
||||||
MatchedContent string `json:"matched_content"`
|
MatchedContent string `json:"matched_content"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GuildAuditLogEntryCreate is the data for a GuildAuditLogEntryCreate event.
|
||||||
|
type GuildAuditLogEntryCreate struct {
|
||||||
|
*AuditLogEntry
|
||||||
|
}
|
||||||
|
|
|
@ -2351,7 +2351,7 @@ type Intent int
|
||||||
const (
|
const (
|
||||||
IntentGuilds Intent = 1 << 0
|
IntentGuilds Intent = 1 << 0
|
||||||
IntentGuildMembers Intent = 1 << 1
|
IntentGuildMembers Intent = 1 << 1
|
||||||
IntentGuildBans Intent = 1 << 2
|
IntentGuildModeration Intent = 1 << 2
|
||||||
IntentGuildEmojis Intent = 1 << 3
|
IntentGuildEmojis Intent = 1 << 3
|
||||||
IntentGuildIntegrations Intent = 1 << 4
|
IntentGuildIntegrations Intent = 1 << 4
|
||||||
IntentGuildWebhooks Intent = 1 << 5
|
IntentGuildWebhooks Intent = 1 << 5
|
||||||
|
@ -2371,6 +2371,8 @@ const (
|
||||||
|
|
||||||
// TODO: remove when compatibility is not needed
|
// TODO: remove when compatibility is not needed
|
||||||
|
|
||||||
|
IntentGuildBans Intent = IntentGuildModeration
|
||||||
|
|
||||||
IntentsGuilds Intent = 1 << 0
|
IntentsGuilds Intent = 1 << 0
|
||||||
IntentsGuildMembers Intent = 1 << 1
|
IntentsGuildMembers Intent = 1 << 1
|
||||||
IntentsGuildBans Intent = 1 << 2
|
IntentsGuildBans Intent = 1 << 2
|
||||||
|
|
Loading…
Reference in a new issue