From cd85709ea81871f424554562922a7ff44268c4ed Mon Sep 17 00:00:00 2001 From: mlnrDev Date: Fri, 1 Sep 2023 17:50:11 +0200 Subject: [PATCH 1/4] Add guild incidents --- discord/guild.go | 11 +++++++++++ rest/guilds.go | 7 +++++++ rest/rest_endpoints.go | 2 ++ 3 files changed, 20 insertions(+) diff --git a/discord/guild.go b/discord/guild.go index 879a25189..0cb1a4beb 100644 --- a/discord/guild.go +++ b/discord/guild.go @@ -164,6 +164,7 @@ type Guild struct { PremiumProgressBarEnabled bool `json:"premium_progress_bar_enabled"` JoinedAt time.Time `json:"joined_at"` SafetyAlertsChannelID *snowflake.ID `json:"safety_alerts_channel_id"` + IncidentsData *GuildIncidentsData `json:"incidents_data"` // only over GET /guilds/{guild.id} ApproximateMemberCount int `json:"approximate_member_count"` @@ -299,6 +300,16 @@ type GuildPreview struct { Stickers []Sticker `json:"stickers"` } +type GuildIncidentsData struct { + InvitesDisabledUntil *time.Time `json:"invites_disabled_until"` + DmsDisabledUntil *time.Time `json:"dms_disabled_until"` +} + +type GuildIncidentActionsUpdate struct { + InvitesDisabledUntil *json.Nullable[time.Time] `json:"invites_disabled_until,omitempty"` + DmsDisabledUntil *json.Nullable[time.Time] `json:"dms_disabled_until,omitempty"` +} + // GuildCreate is the payload used to create a Guild type GuildCreate struct { Name string `json:"name"` diff --git a/rest/guilds.go b/rest/guilds.go index a382356d3..86211bfec 100644 --- a/rest/guilds.go +++ b/rest/guilds.go @@ -58,6 +58,8 @@ type Guilds interface { GetGuildOnboarding(guildID snowflake.ID, opts ...RequestOpt) (*discord.GuildOnboarding, error) UpdateGuildOnboarding(guildID snowflake.ID, onboardingUpdate discord.GuildOnboardingUpdate, opts ...RequestOpt) (*discord.GuildOnboarding, error) + + UpdateGuildIncidentActions(guildID snowflake.ID, actionsUpdate discord.GuildIncidentActionsUpdate, opts ...RequestOpt) (*discord.GuildIncidentsData, error) } type guildImpl struct { @@ -310,3 +312,8 @@ func (s *guildImpl) UpdateGuildOnboarding(guildID snowflake.ID, onboardingUpdate err = s.client.Do(UpdateGuildOnboarding.Compile(nil, guildID), onboardingUpdate, &guildOnboarding, opts...) return } + +func (s *guildImpl) UpdateGuildIncidentActions(guildID snowflake.ID, actionsUpdate discord.GuildIncidentActionsUpdate, opts ...RequestOpt) (incidentsData *discord.GuildIncidentsData, err error) { + err = s.client.Do(UpdateGuildIncidentActions.Compile(nil, guildID), actionsUpdate, &incidentsData, opts...) + return +} diff --git a/rest/rest_endpoints.go b/rest/rest_endpoints.go index 1cb2a12d7..375dacb2d 100644 --- a/rest/rest_endpoints.go +++ b/rest/rest_endpoints.go @@ -92,6 +92,8 @@ var ( GetGuildOnboarding = NewEndpoint(http.MethodGet, "/guilds/{guild.id}/onboarding") UpdateGuildOnboarding = NewEndpoint(http.MethodPut, "/guilds/{guild.id}/onboarding") + UpdateGuildIncidentActions = NewEndpoint(http.MethodPut, "/guilds/{guild.id}/incident-actions") + UpdateCurrentUserVoiceState = NewEndpoint(http.MethodPatch, "/guilds/{guild.id}/voice-states/@me") UpdateUserVoiceState = NewEndpoint(http.MethodPatch, "/guilds/{guild.id}/voice-states/{user.id}") ) From 51e433703194358bd19fc6b15e37ee37d7f19f95 Mon Sep 17 00:00:00 2001 From: mlnrDev Date: Sun, 3 Dec 2023 15:44:41 +0100 Subject: [PATCH 2/4] add incident message types --- discord/message.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/discord/message.go b/discord/message.go index 93ef38181..818a3aa3c 100644 --- a/discord/message.go +++ b/discord/message.go @@ -48,6 +48,13 @@ const ( _ MessageTypeStageTopic MessageTypeGuildApplicationPremiumSubscription + _ + _ + _ + MessageTypeGuildIncidentAlertModeEnabled + MessageTypeGuildIncidentAlertModeDisabled + MessageTypeGuildIncidentReportRaid + MessageTypeGuildIncidentReportFalseAlarm ) func (t MessageType) System() bool { @@ -65,7 +72,9 @@ func (t MessageType) Deleteable() bool { case MessageTypeRecipientAdd, MessageTypeRecipientRemove, MessageTypeCall, MessageTypeChannelNameChange, MessageTypeChannelIconChange, MessageTypeGuildDiscoveryDisqualified, MessageTypeGuildDiscoveryRequalified, MessageTypeGuildDiscoveryGracePeriodInitialWarning, - MessageTypeGuildDiscoveryGracePeriodFinalWarning, MessageTypeThreadStarterMessage: + MessageTypeGuildDiscoveryGracePeriodFinalWarning, MessageTypeThreadStarterMessage, + MessageTypeGuildIncidentAlertModeEnabled, MessageTypeGuildIncidentAlertModeDisabled, + MessageTypeGuildIncidentReportRaid, MessageTypeGuildIncidentReportFalseAlarm: return false default: From 81b0c27bf2c694513cb2f7aaea18b880969fb2d1 Mon Sep 17 00:00:00 2001 From: mlnrDev Date: Thu, 25 Apr 2024 19:00:43 +0200 Subject: [PATCH 3/4] add new fields --- discord/guild.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/discord/guild.go b/discord/guild.go index 0cb1a4beb..820e5f2be 100644 --- a/discord/guild.go +++ b/discord/guild.go @@ -302,12 +302,14 @@ type GuildPreview struct { type GuildIncidentsData struct { InvitesDisabledUntil *time.Time `json:"invites_disabled_until"` - DmsDisabledUntil *time.Time `json:"dms_disabled_until"` + DMsDisabledUntil *time.Time `json:"dms_disabled_until"` + DMSpamDetectedAt *time.Time `json:"dm_spam_detected_at"` + RaidDetectedAt *time.Time `json:"raid_detected_at"` } type GuildIncidentActionsUpdate struct { InvitesDisabledUntil *json.Nullable[time.Time] `json:"invites_disabled_until,omitempty"` - DmsDisabledUntil *json.Nullable[time.Time] `json:"dms_disabled_until,omitempty"` + DMsDisabledUntil *json.Nullable[time.Time] `json:"dms_disabled_until,omitempty"` } // GuildCreate is the payload used to create a Guild From eaee5bfdc04061c0992078dba1c56faaacfe1317 Mon Sep 17 00:00:00 2001 From: mlnrDev Date: Wed, 15 May 2024 18:25:09 +0200 Subject: [PATCH 4/4] make new types deletable --- discord/message.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/discord/message.go b/discord/message.go index 818a3aa3c..ea46176b7 100644 --- a/discord/message.go +++ b/discord/message.go @@ -72,9 +72,7 @@ func (t MessageType) Deleteable() bool { case MessageTypeRecipientAdd, MessageTypeRecipientRemove, MessageTypeCall, MessageTypeChannelNameChange, MessageTypeChannelIconChange, MessageTypeGuildDiscoveryDisqualified, MessageTypeGuildDiscoveryRequalified, MessageTypeGuildDiscoveryGracePeriodInitialWarning, - MessageTypeGuildDiscoveryGracePeriodFinalWarning, MessageTypeThreadStarterMessage, - MessageTypeGuildIncidentAlertModeEnabled, MessageTypeGuildIncidentAlertModeDisabled, - MessageTypeGuildIncidentReportRaid, MessageTypeGuildIncidentReportFalseAlarm: + MessageTypeGuildDiscoveryGracePeriodFinalWarning, MessageTypeThreadStarterMessage: return false default: