diff --git a/multipaneltargets.go b/multipaneltargets.go index f3206b2..43f869c 100644 --- a/multipaneltargets.go +++ b/multipaneltargets.go @@ -75,6 +75,9 @@ SELECT panels.ticket_notification_channel, panels.cooldown_seconds, panels.ticket_limit, + panels.hide_close_button, + panels.hide_close_with_reason_button, + panels.hide_claim_button, multi_panel_targets.custom_label, multi_panel_targets.description, multi_panel_targets.custom_emoji_name, diff --git a/panels.go b/panels.go index e9bab4f..2b39c07 100644 --- a/panels.go +++ b/panels.go @@ -9,35 +9,38 @@ import ( ) type Panel struct { - PanelId int `json:"panel_id"` - MessageId uint64 `json:"message_id,string"` - ChannelId uint64 `json:"channel_id,string"` - GuildId uint64 `json:"guild_id,string"` - Title string `json:"title"` - Content string `json:"content"` - Colour int32 `json:"colour"` - TargetCategory uint64 `json:"category_id,string"` - EmojiName *string `json:"emoji_name"` - EmojiId *uint64 `json:"emoji_id,string"` - WelcomeMessageEmbed *int `json:"welcome_message_embed"` - WithDefaultTeam bool `json:"default_team"` - CustomId string `json:"custom_id"` - ImageUrl *string `json:"image_url,omitempty"` - ThumbnailUrl *string `json:"thumbnail_url,omitempty"` - ButtonStyle int `json:"button_style"` - ButtonLabel string `json:"button_label"` - FormId *int `json:"form_id"` - NamingScheme *string `json:"naming_scheme"` - ForceDisabled bool `json:"force_disabled"` - Disabled bool `json:"disabled"` - ExitSurveyFormId *int `json:"exit_survey_form_id"` - PendingCategory *uint64 `json:"pending_category,string"` - DeleteMentions bool `json:"delete_mentions"` - TranscriptChannelId *uint64 `json:"transcript_channel_id,string,omitempty"` - UseThreads bool `json:"use_threads"` - TicketNotificationChannel *uint64 `json:"ticket_notification_channel,string,omitempty"` - CooldownSeconds int `json:"cooldown_seconds"` - TicketLimit *uint8 `json:"ticket_limit,omitempty"` + PanelId int `json:"panel_id"` + MessageId uint64 `json:"message_id,string"` + ChannelId uint64 `json:"channel_id,string"` + GuildId uint64 `json:"guild_id,string"` + Title string `json:"title"` + Content string `json:"content"` + Colour int32 `json:"colour"` + TargetCategory uint64 `json:"category_id,string"` + EmojiName *string `json:"emoji_name"` + EmojiId *uint64 `json:"emoji_id,string"` + WelcomeMessageEmbed *int `json:"welcome_message_embed"` + WithDefaultTeam bool `json:"default_team"` + CustomId string `json:"custom_id"` + ImageUrl *string `json:"image_url,omitempty"` + ThumbnailUrl *string `json:"thumbnail_url,omitempty"` + ButtonStyle int `json:"button_style"` + ButtonLabel string `json:"button_label"` + FormId *int `json:"form_id"` + NamingScheme *string `json:"naming_scheme"` + ForceDisabled bool `json:"force_disabled"` + Disabled bool `json:"disabled"` + ExitSurveyFormId *int `json:"exit_survey_form_id"` + PendingCategory *uint64 `json:"pending_category,string"` + DeleteMentions bool `json:"delete_mentions"` + TranscriptChannelId *uint64 `json:"transcript_channel_id,string,omitempty"` + UseThreads bool `json:"use_threads"` + TicketNotificationChannel *uint64 `json:"ticket_notification_channel,string,omitempty"` + CooldownSeconds int `json:"cooldown_seconds"` + TicketLimit *uint8 `json:"ticket_limit,omitempty"` + HideCloseButton bool `json:"hide_close_button"` + HideCloseWithReasonButton bool `json:"hide_close_with_reason_button"` + HideClaimButton bool `json:"hide_claim_button"` } type PanelWithWelcomeMessage struct { @@ -88,6 +91,9 @@ CREATE TABLE IF NOT EXISTS panels( "ticket_notification_channel" int8 DEFAULT NULL, "cooldown_seconds" int NOT NULL DEFAULT 0, "ticket_limit" int2 DEFAULT NULL, + "hide_close_button" bool NOT NULL DEFAULT false, + "hide_close_with_reason_button" bool NOT NULL DEFAULT false, + "hide_claim_button" bool NOT NULL DEFAULT false, FOREIGN KEY ("welcome_message") REFERENCES embeds("id") ON DELETE SET NULL, FOREIGN KEY ("form_id") REFERENCES forms("form_id"), FOREIGN KEY ("exit_survey_form_id") REFERENCES forms("form_id"), @@ -131,7 +137,10 @@ SELECT use_threads, ticket_notification_channel, cooldown_seconds, - ticket_limit + ticket_limit, + hide_close_button, + hide_close_with_reason_button, + hide_claim_button FROM panels WHERE "message_id" = $1; ` @@ -175,7 +184,10 @@ SELECT use_threads, ticket_notification_channel, cooldown_seconds, - ticket_limit + ticket_limit, + hide_close_button, + hide_close_with_reason_button, + hide_claim_button FROM panels WHERE "panel_id" = $1; ` @@ -220,6 +232,9 @@ SELECT panels.ticket_notification_channel, panels.cooldown_seconds, panels.ticket_limit, + panels.hide_close_button, + panels.hide_close_with_reason_button, + panels.hide_claim_button, embeds.id, embeds.guild_id, embeds.title, @@ -325,7 +340,10 @@ SELECT use_threads, ticket_notification_channel, cooldown_seconds, - ticket_limit + ticket_limit, + hide_close_button, + hide_close_with_reason_button, + hide_claim_button FROM panels WHERE "guild_id" = $1 AND "custom_id" = $2; ` @@ -372,7 +390,10 @@ SELECT use_threads, ticket_notification_channel, cooldown_seconds, - ticket_limit + ticket_limit, + hide_close_button, + hide_close_with_reason_button, + hide_claim_button FROM panels WHERE "guild_id" = $1 AND "form_id" = $2; ` @@ -419,7 +440,10 @@ SELECT panels.use_threads, panels.ticket_notification_channel, panels.cooldown_seconds, - panels.ticket_limit + panels.ticket_limit, + panels.hide_close_button, + panels.hide_close_with_reason_button, + panels.hide_claim_button FROM panels INNER JOIN forms ON forms.form_id = panels.form_id @@ -468,7 +492,10 @@ SELECT use_threads, ticket_notification_channel, cooldown_seconds, - ticket_limit + ticket_limit, + hide_close_button, + hide_close_with_reason_button, + hide_claim_button FROM panels WHERE "guild_id" = $1 ORDER BY "panel_id" ASC;` @@ -523,6 +550,9 @@ SELECT panels.ticket_notification_channel, panels.cooldown_seconds, panels.ticket_limit, + panels.hide_close_button, + panels.hide_close_with_reason_button, + panels.hide_claim_button, embeds.id, embeds.guild_id, embeds.title, @@ -645,9 +675,12 @@ INSERT INTO panels( "use_threads", "ticket_notification_channel", "cooldown_seconds", - "ticket_limit" + "ticket_limit", + "hide_close_button", + "hide_close_with_reason_button", + "hide_claim_button" ) -VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28) +VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31) ON CONFLICT("message_id") DO NOTHING RETURNING "panel_id";` @@ -680,6 +713,9 @@ RETURNING "panel_id";` panel.TicketNotificationChannel, panel.CooldownSeconds, panel.TicketLimit, + panel.HideCloseButton, + panel.HideCloseWithReasonButton, + panel.HideClaimButton, ).Scan(&panelId) return @@ -729,7 +765,10 @@ UPDATE panels "use_threads" = $25, "ticket_notification_channel" = $26, "cooldown_seconds" = $27, - "ticket_limit" = $28 + "ticket_limit" = $28, + "hide_close_button" = $29, + "hide_close_with_reason_button" = $30, + "hide_claim_button" = $31 WHERE "panel_id" = $1 ;` @@ -763,6 +802,9 @@ UPDATE panels panel.TicketNotificationChannel, panel.CooldownSeconds, panel.TicketLimit, + panel.HideCloseButton, + panel.HideCloseWithReasonButton, + panel.HideClaimButton, ) return err @@ -883,5 +925,8 @@ func (p *Panel) fieldPtrs() []interface{} { &p.TicketNotificationChannel, &p.CooldownSeconds, &p.TicketLimit, + &p.HideCloseButton, + &p.HideCloseWithReasonButton, + &p.HideClaimButton, } } diff --git a/settings.go b/settings.go index 2af4849..213568b 100644 --- a/settings.go +++ b/settings.go @@ -21,6 +21,8 @@ type Settings struct { OverflowCategoryId *uint64 `json:"overflow_category_id,string"` // If overflow_enabled and nil, use root ExitSurveyFormId *uint64 `json:"exit_survey_form_id,string"` AnonymiseDashboardResponses bool `json:"anonymise_dashboard_responses"` + HideCloseButton bool `json:"hide_close_button"` + HideCloseWithReasonButton bool `json:"hide_close_with_reason_button"` } func defaultSettings() Settings { @@ -37,6 +39,8 @@ func defaultSettings() Settings { OverflowEnabled: false, OverflowCategoryId: nil, ExitSurveyFormId: nil, + HideCloseButton: false, + HideCloseWithReasonButton: false, } } @@ -67,6 +71,8 @@ CREATE TABLE IF NOT EXISTS settings( "overflow_category_id" int8 DEFAULT NULL, "exit_survey_form_id" int4 DEFAULT NULL, "anonymise_dashboard_responses" bool DEFAULT 'f', + "hide_close_button" bool DEFAULT 'f', + "hide_close_with_reason_button" bool DEFAULT 'f', FOREIGN KEY("context_menu_panel") REFERENCES panels("panel_id") ON DELETE SET NULL, FOREIGN KEY("exit_survey_form_id") REFERENCES forms("form_id") ON DELETE SET NULL, PRIMARY KEY("guild_id"), @@ -89,7 +95,9 @@ SELECT "thread_archive_duration", "overflow_enabled", "overflow_category_id", - "anonymise_dashboard_responses" + "anonymise_dashboard_responses", + "hide_close_button", + "hide_close_with_reason_button" FROM settings WHERE "guild_id" = $1; ` @@ -108,6 +116,8 @@ WHERE "guild_id" = $1; &settings.OverflowEnabled, &settings.OverflowCategoryId, &settings.AnonymiseDashboardResponses, + &settings.HideCloseButton, + &settings.HideCloseWithReasonButton, ) if err == nil { @@ -134,9 +144,11 @@ INSERT INTO settings( "thread_archive_duration", "overflow_enabled", "overflow_category_id", - "anonymise_dashboard_responses" + "anonymise_dashboard_responses", + "hide_close_button", + "hide_close_with_reason_button" ) -VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) +VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15) ON CONFLICT("guild_id") DO UPDATE SET "hide_claim_button" = $2, @@ -150,7 +162,9 @@ DO UPDATE SET "thread_archive_duration" = $10, "overflow_enabled" = $11, "overflow_category_id" = $12, - "anonymise_dashboard_responses" = $13 + "anonymise_dashboard_responses" = $13, + "hide_close_button" = $14, + "hide_close_with_reason_button" = $15 ; ` @@ -168,6 +182,8 @@ DO UPDATE SET settings.OverflowEnabled, settings.OverflowCategoryId, settings.AnonymiseDashboardResponses, + settings.HideCloseButton, + settings.HideCloseWithReasonButton, ) return