Skip to content
Merged
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
3 changes: 3 additions & 0 deletions multipaneltargets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
121 changes: 83 additions & 38 deletions panels.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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;
`
Expand Down Expand Up @@ -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;
`
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
`
Expand Down Expand Up @@ -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;
`
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;`
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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";`

Expand Down Expand Up @@ -680,6 +713,9 @@ RETURNING "panel_id";`
panel.TicketNotificationChannel,
panel.CooldownSeconds,
panel.TicketLimit,
panel.HideCloseButton,
panel.HideCloseWithReasonButton,
panel.HideClaimButton,
).Scan(&panelId)

return
Expand Down Expand Up @@ -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
;`
Expand Down Expand Up @@ -763,6 +802,9 @@ UPDATE panels
panel.TicketNotificationChannel,
panel.CooldownSeconds,
panel.TicketLimit,
panel.HideCloseButton,
panel.HideCloseWithReasonButton,
panel.HideClaimButton,
)

return err
Expand Down Expand Up @@ -883,5 +925,8 @@ func (p *Panel) fieldPtrs() []interface{} {
&p.TicketNotificationChannel,
&p.CooldownSeconds,
&p.TicketLimit,
&p.HideCloseButton,
&p.HideCloseWithReasonButton,
&p.HideClaimButton,
}
}
24 changes: 20 additions & 4 deletions settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -37,6 +39,8 @@ func defaultSettings() Settings {
OverflowEnabled: false,
OverflowCategoryId: nil,
ExitSurveyFormId: nil,
HideCloseButton: false,
HideCloseWithReasonButton: false,
}
}

Expand Down Expand Up @@ -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"),
Expand All @@ -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;
`
Expand All @@ -108,6 +116,8 @@ WHERE "guild_id" = $1;
&settings.OverflowEnabled,
&settings.OverflowCategoryId,
&settings.AnonymiseDashboardResponses,
&settings.HideCloseButton,
&settings.HideCloseWithReasonButton,
)

if err == nil {
Expand All @@ -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,
Expand All @@ -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
;
`

Expand All @@ -168,6 +182,8 @@ DO UPDATE SET
settings.OverflowEnabled,
settings.OverflowCategoryId,
settings.AnonymiseDashboardResponses,
settings.HideCloseButton,
settings.HideCloseWithReasonButton,
)

return
Expand Down