refactor: atomic, DRY, and logging improvements

- Shared Redis channel constants as single source of truth (redis-channels.ts)
- commandHandler.ts split into VoiceHandler, MediaHandler, GuildHandler,
  ModerationHandler with handler-registry.ts dispatch
- messageStore.ts (1322 lines) split into domain-specific DB files:
  messages.db.ts, attachments.db.ts, reviews.db.ts,
  moderation-actions.db.ts, retention.db.ts
- recorder.ts startSpeaking callback extracted into speakingHandler.ts,
  streamSetup.ts, segmentFinalizer.ts
- autoDeleteManager.ts split into autoDeleteEligibility.ts,
  autoDeleteNotify.ts, autoDeleteLogger.ts
- Added createChildLogger() logging across 8 service files
- Backend messages.repository.ts migrated from raw SQL to Drizzle ORM
- Fixed biome.json to exclude packages/**/dist/* from lint
- Fixed config.ts GUILD_ID pre-existing type error

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
MythEclipse
2026-06-09 17:34:18 +07:00
co-authored by Claude Opus 4.8
parent 7108f6bb47
commit b68789fffc
37 changed files with 3620 additions and 2345 deletions
@@ -15,6 +15,10 @@ class MascotChatService {
context: MascotChatContext | undefined,
userId: string,
): Promise<string> {
logger.info(
{ userId, messageLength: message.length },
"processMessage called",
);
const recentContext = await this.getRecentConversationContext(userId);
const serverInsights = await mascotChatRepository.getServerInsights(
context?.guildId,
@@ -34,6 +38,7 @@ class MascotChatService {
}
async saveConversation(input: SaveConversationInput): Promise<void> {
logger.info({ userId: input.userId }, "saveConversation called");
await mascotChatRepository.saveConversation(input);
}
@@ -41,10 +46,12 @@ class MascotChatService {
userId: string,
limit: number,
): Promise<MascotChatHistoryRow[]> {
logger.debug({ userId, limit }, "getChatHistory called");
return mascotChatRepository.getChatHistory(userId, limit);
}
async clearChatHistory(userId: string): Promise<void> {
logger.info({ userId }, "clearChatHistory called");
await mascotChatRepository.clearChatHistory(userId);
}