Files
aurorabot/shared/db/schema/guild-settings.ts
syntaxbullet 6eb4a32a12 refactor: consolidate config types and remove file-based config
Tickets: #2, #3

- Remove duplicate type definitions from shared/lib/config.ts
- Import types from schema files (game-settings.ts, guild-settings.ts)
- Add GuildConfig interface to guild-settings.ts schema
- Rename ModerationConfig to ModerationCaseConfig in moderation.service.ts
- Delete shared/config/config.json and shared/scripts/migrate-config-to-db.ts
- Update settings API to use gameSettingsService exclusively
- Return DB format (strings) from API instead of runtime BigInts
- Fix moderation service tests to pass config as parameter

Breaking Changes:
- Removes legacy file-based configuration system
- API now returns database format with string values for BigInt fields
2026-02-13 13:24:02 +01:00

52 lines
2.0 KiB
TypeScript

import {
pgTable,
bigint,
timestamp,
text,
jsonb,
} from 'drizzle-orm/pg-core';
import { relations, type InferSelectModel, type InferInsertModel } from 'drizzle-orm';
export type GuildSettings = InferSelectModel<typeof guildSettings>;
export type GuildSettingsInsert = InferInsertModel<typeof guildSettings>;
export interface GuildConfig {
studentRole?: string;
visitorRole?: string;
colorRoles: string[];
welcomeChannelId?: string;
welcomeMessage?: string;
feedbackChannelId?: string;
terminal?: {
channelId: string;
messageId: string;
};
moderation: {
cases: {
dmOnWarn: boolean;
logChannelId?: string;
autoTimeoutThreshold?: number;
};
};
}
export const guildSettings = pgTable('guild_settings', {
guildId: bigint('guild_id', { mode: 'bigint' }).primaryKey(),
studentRoleId: bigint('student_role_id', { mode: 'bigint' }),
visitorRoleId: bigint('visitor_role_id', { mode: 'bigint' }),
colorRoleIds: jsonb('color_role_ids').$type<string[]>().default([]),
welcomeChannelId: bigint('welcome_channel_id', { mode: 'bigint' }),
welcomeMessage: text('welcome_message'),
feedbackChannelId: bigint('feedback_channel_id', { mode: 'bigint' }),
terminalChannelId: bigint('terminal_channel_id', { mode: 'bigint' }),
terminalMessageId: bigint('terminal_message_id', { mode: 'bigint' }),
moderationLogChannelId: bigint('moderation_log_channel_id', { mode: 'bigint' }),
moderationDmOnWarn: jsonb('moderation_dm_on_warn').$type<boolean>().default(true),
moderationAutoTimeoutThreshold: jsonb('moderation_auto_timeout_threshold').$type<number>(),
featureOverrides: jsonb('feature_overrides').$type<Record<string, boolean>>().default({}),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
});
export const guildSettingsRelations = relations(guildSettings, () => ({}));