Commands for everything a dashboard can do
- /music skip, pause, resume, stop, repeat, remove, move (DJ role) - /config view, clear, toggletwitch, streamers, beta-features (server owner) - /slvl status, remove-reward; /moderation bans, timeouts; /security history - /beta is now the bot owner's DM-only command: set, off, servers, remove-server, status - betasettings service and repo methods, with integration tests Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
1 parent
acdb5ead35
commit
132a2cd986
26 files changed
+1062
-65
No files matched your search
@@ -475,3 +475,43 @@ func (r *Repo) SetBetaRegistered(ctx context.Context, guildID string, registered
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// SetBetaServer saves the beta server and the Beta Tester role (0 clears the
|
||||
// role, which turns beta features off for everyone).
|
||||
func (r *Repo) SetBetaServer(ctx context.Context, guildID, roleID, updatedBy int64) error {
|
||||
const q = `
|
||||
INSERT INTO beta_settings (id, guild_id, role_id, updated_by, updated_at)
|
||||
VALUES (TRUE, $1, $2, $3, NOW())
|
||||
ON CONFLICT (id) DO UPDATE SET guild_id = EXCLUDED.guild_id, role_id = EXCLUDED.role_id,
|
||||
updated_by = EXCLUDED.updated_by, updated_at = NOW()`
|
||||
_, err := r.db.ExecContext(ctx, q, guildID, sql.NullInt64{Int64: roleID, Valid: roleID != 0}, updatedBy)
|
||||
return err
|
||||
}
|
||||
|
||||
// SetBetaGuild opts a server in or out of beta features.
|
||||
func (r *Repo) SetBetaGuild(ctx context.Context, guildID, enabledBy int64, enabled bool) error {
|
||||
if enabled {
|
||||
_, err := r.db.ExecContext(ctx, `INSERT INTO beta_guilds (guild_id, enabled_by) VALUES ($1, $2) ON CONFLICT (guild_id) DO NOTHING`, guildID, enabledBy)
|
||||
return err
|
||||
}
|
||||
_, err := r.db.ExecContext(ctx, `DELETE FROM beta_guilds WHERE guild_id = $1`, guildID)
|
||||
return err
|
||||
}
|
||||
|
||||
// IsBetaGuild reports whether a server opted in to beta features.
|
||||
func (r *Repo) IsBetaGuild(ctx context.Context, guildID int64) (bool, error) {
|
||||
var on bool
|
||||
err := r.db.QueryRowContext(ctx, `SELECT EXISTS (SELECT 1 FROM beta_guilds WHERE guild_id = $1)`, guildID).Scan(&on)
|
||||
return on, err
|
||||
}
|
||||
|
||||
// DeleteRoleRewardForLevel removes the role reward of a level and reports
|
||||
// whether there was one.
|
||||
func (r *Repo) DeleteRoleRewardForLevel(ctx context.Context, guildID int64, level int) (bool, error) {
|
||||
res, err := r.db.ExecContext(ctx, `DELETE FROM levelrewards WHERE guild_id = $1 AND levelreq = $2`, guildID, level)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
n, err := res.RowsAffected()
|
||||
return n > 0, err
|
||||
}
|
||||
Reference in new issue
Block a user