Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add guild incidents #303

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions discord/guild.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -299,6 +300,18 @@ type GuildPreview struct {
Stickers []Sticker `json:"stickers"`
}

type GuildIncidentsData struct {
InvitesDisabledUntil *time.Time `json:"invites_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"`
}

// GuildCreate is the payload used to create a Guild
type GuildCreate struct {
Name string `json:"name"`
Expand Down
7 changes: 7 additions & 0 deletions discord/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ const (
_
MessageTypeStageTopic
MessageTypeGuildApplicationPremiumSubscription
_
_
_
MessageTypeGuildIncidentAlertModeEnabled
MessageTypeGuildIncidentAlertModeDisabled
MessageTypeGuildIncidentReportRaid
MessageTypeGuildIncidentReportFalseAlarm
)

func (t MessageType) System() bool {
Expand Down
7 changes: 7 additions & 0 deletions rest/guilds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions rest/rest_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
)
Expand Down
Loading