Start Twitch alerts and tickets off on new servers

Every module that can be switched on or off now starts off. A server
with no settings yet reads as off; setting the Twitch alert channel or
running /tickets setup for the first time turns that module on, and
existing settings are left as they are. schema.sql mirrors the API's
migration 000019.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
FernandoJVideiraandClaude Opus 5.5 committed 2026-10-21 22:56:26 +01:00
1 parent f285367511
commit 0218676e2d
3 files changed
+16 -12

No files matched your search

+6 -4
View File
@@ -93,9 +93,10 @@ func (r *Repo) GetSettings(ctx context.Context, guildID int64) (*Settings, error
err := r.db.QueryRowContext(ctx, q, guildID).Scan(&s.Enabled, &ch, &logCh, &panel, &s.PanelTitle, &s.PanelDescription, &s.MaxOpenPerUser)
switch {
case errors.Is(err, sql.ErrNoRows):
// Modules start off until the server sets them up.
return &Settings{
GuildID: guildID,
Enabled: true,
Enabled: false,
PanelTitle: DefaultPanelTitle,
PanelDescription: DefaultPanelDescription,
MaxOpenPerUser: DefaultMaxOpenPerUser,
@@ -109,11 +110,12 @@ func (r *Repo) GetSettings(ctx context.Context, guildID int64) (*Settings, error
}
// SetChannels saves where tickets live and where transcripts go. A zero log
// channel clears it.
// channel clears it. Setting tickets up for the first time turns them on
// (they start off); after that, the on/off switch is left alone.
func (r *Repo) SetChannels(ctx context.Context, guildID, channelID, logChannelID int64) error {
const q = `
INSERT INTO ticket_settings (guild_id, channel_id, log_channel_id)
VALUES ($1, $2, $3)
INSERT INTO ticket_settings (guild_id, channel_id, log_channel_id, enabled)
VALUES ($1, $2, $3, TRUE)
ON CONFLICT (guild_id) DO UPDATE SET
channel_id = EXCLUDED.channel_id,
log_channel_id = EXCLUDED.log_channel_id`