From 55d19000a12980cd9fe4e7023b8ebc232a0af3b5 Mon Sep 17 00:00:00 2001 From: ayn2op <119342035+ayn2op@users.noreply.github.com> Date: Fri, 27 Jan 2023 15:04:50 +0530 Subject: [PATCH] discord: Rename IntentGuildBans; add GuildAuditLogEntryCreateEvent (#370) * Rename GuildBans intent & add GUILD_AUDIT_LOG_ENTRY_CREATE event * Add IntentGuildBans constant for backward compatibility --- gateway/event_methods.go | 7 +++++++ gateway/events.go | 7 +++++++ gateway/intents.go | 12 +++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/gateway/event_methods.go b/gateway/event_methods.go index c3f66fa..4c4840f 100644 --- a/gateway/event_methods.go +++ b/gateway/event_methods.go @@ -31,6 +31,7 @@ func init() { func() ws.Event { return new(GuildCreateEvent) }, func() ws.Event { return new(GuildUpdateEvent) }, func() ws.Event { return new(GuildDeleteEvent) }, + func() ws.Event { return new(GuildAuditLogEntryCreateEvent) }, func() ws.Event { return new(GuildBanAddEvent) }, func() ws.Event { return new(GuildBanRemoveEvent) }, func() ws.Event { return new(GuildEmojisUpdateEvent) }, @@ -228,6 +229,12 @@ func (*GuildDeleteEvent) Op() ws.OpCode { return dispatchOp } // EventType implements Event. func (*GuildDeleteEvent) EventType() ws.EventType { return "GUILD_DELETE" } +// Op implements Event. It always returns 0. +func (*GuildAuditLogEntryCreateEvent) Op() ws.OpCode { return dispatchOp } + +// EventType implements Event. +func (*GuildAuditLogEntryCreateEvent) EventType() ws.EventType { return "GUILD_AUDIT_LOG_ENTRY_CREATE" } + // Op implements Event. It always returns 0. func (*GuildBanAddEvent) Op() ws.OpCode { return dispatchOp } diff --git a/gateway/events.go b/gateway/events.go index 1a337ab..ba2c510 100644 --- a/gateway/events.go +++ b/gateway/events.go @@ -294,6 +294,13 @@ type GuildDeleteEvent struct { Unavailable bool `json:"unavailable"` } +// GuildAuditLogEntryCreateEvent is a dispatch event. + +// https://discord.com/developers/docs/topics/gateway#guilds +type GuildAuditLogEntryCreateEvent struct { + discord.AuditLogEntry +} + // GuildBanAddEvent is a dispatch event. // // https://discord.com/developers/docs/topics/gateway#guilds diff --git a/gateway/intents.go b/gateway/intents.go index ca4f895..c975f44 100644 --- a/gateway/intents.go +++ b/gateway/intents.go @@ -12,7 +12,7 @@ type Intents uint32 const ( IntentGuilds Intents = 1 << iota IntentGuildMembers - IntentGuildBans + IntentGuildModeration IntentGuildEmojis IntentGuildIntegrations IntentGuildWebhooks @@ -29,6 +29,11 @@ const ( IntentGuildScheduledEvents ) +// IntentGuildBans is an alias to IntentGuildModeration. +// +// Deprecated: IntentGuildModeration is the more correct constant to use. +const IntentGuildBans = IntentGuildModeration + // PrivilegedIntents contains a list of privileged intents that Discord requires // bots to have these intents explicitly enabled in the Developer Portal. var PrivilegedIntents = []Intents{ @@ -65,8 +70,9 @@ var EventIntents = map[ws.EventType]Intents{ "GUILD_MEMBER_REMOVE": IntentGuildMembers, "GUILD_MEMBER_UPDATE": IntentGuildMembers, - "GUILD_BAN_ADD": IntentGuildBans, - "GUILD_BAN_REMOVE": IntentGuildBans, + "GUILD_AUDIT_LOG_ENTRY_CREATE": IntentGuildModeration, + "GUILD_BAN_ADD": IntentGuildModeration, + "GUILD_BAN_REMOVE": IntentGuildModeration, "GUILD_EMOJIS_UPDATE": IntentGuildEmojis,