From ea7882b14391ac402f7421c0c62d78ecb3c29d98 Mon Sep 17 00:00:00 2001 From: Nix Krystik Date: Fri, 29 May 2026 14:46:58 +0800 Subject: [PATCH] I'm just a little daft for this one. --- src/shared/Database.ts | 19 +--- src/types/database-types.d.ts | 159 +++++++++++++++++----------------- 2 files changed, 82 insertions(+), 96 deletions(-) diff --git a/src/shared/Database.ts b/src/shared/Database.ts index 58af821..a7fa4d7 100644 --- a/src/shared/Database.ts +++ b/src/shared/Database.ts @@ -1,7 +1,7 @@ import sqlite3 from 'sqlite3'; import { open, Database as SqliteDatabase } from 'sqlite'; import { serializeMessage, wait } from '../utils'; -import { GuildSettings, LoggedMessage, TicketMessage, TicketPhrase, Note, Ban, GuildArraySetting, GithubUserMapping, KnowledgebaseItem, PrivateHelpTicket } from '../types'; +import { GuildSettings, LoggedMessage, TicketMessage, TicketPhrase, Note, Ban, GuildArraySetting, GithubUserMapping, KnowledgebaseItem, PrivateHelpTicket, GuildSetting } from '../types'; import { Message } from '../events'; const DB_SCHEMA = ` @@ -114,21 +114,6 @@ export const enum PrivateHelpTicketStatus { CLOSED = 1 } -type GuildSettingKey = - | 'general_chat_id' - | 'tickets_channel_id' - | 'event_logs_channel_id' - | 'discord_logs_channel_id' - | 'audit_logs_channel_id' - | 'voice_logs_channel_id' - | 'new_member_channel_id' - | 'moderator_channel_id' - | 'admin_role_id' - | 'private_help_role_id' - | 'devwatch_role_id' - | 'github_release_channel' - | 'private_help_channel_id'; - export class Database { private static db: SqliteDatabase; @@ -199,7 +184,7 @@ export class Database { await Database.db.run('INSERT INTO settings(guild_id) VALUES (?)', guildId); } - static async updateGuildSettings(guildId: string, key: GuildSettingKey, value: string) { + static async updateGuildSettings(guildId: string, key: GuildSetting, value: string) { await Database.db.run(`UPDATE settings SET ${key} = ? WHERE guild_id = ?`, value, guildId); } diff --git a/src/types/database-types.d.ts b/src/types/database-types.d.ts index 310d36c..0ed29ba 100644 --- a/src/types/database-types.d.ts +++ b/src/types/database-types.d.ts @@ -1,79 +1,80 @@ -export type LoggedMessage = { - id: string - author_id: string - author_name: string - channel_id: string - attachments: string - stickers: string - content: string -} - -export type GuildSettings = { - guild_id: string - general_chat_id?: string - new_member_channel_id?: string - tickets_channel_id?: string - event_logs_channel_id?: string - discord_logs_channel_id?: string - audit_logs_channel_id?: string - voice_logs_channel_id?: string - admin_role_id?: string - private_help_role_id?: string - devwatch_role_id?: string - staff_categories?: string - safe_channels?: string - link_skip_channels?: string - github_release_channel?: string - moderator_channel_id?: string - private_help_channel_id?: string -} - -export type GuildArraySetting = 'staff_categories' | 'safe_channels' | 'link_skip_channels'; - -export type TicketMessage = { - id: number - message_id: string -} - -export type TicketPhrase = { - id: number - user_id: string - phrase: string -} - -export type Note = { - id: number - user_id: string - reason: string - mod_id: string - timestamp: string -} - -export type Ban = { - id: number - user_id: string - expires: 0 | 1 - expires_at: string - full_ban: 0 | 1 -} - -export type GithubUserMapping = { - id: number - discord_id: string - github_username: string -} - -export type KnowledgebaseItem = { - id: number - guild_id: string - name: string - content: string -} - -export type PrivateHelpTicket = { - id: number - user_id: string - thread_id: string - status: PrivateHelpTicketStatus - timestamp: string -} \ No newline at end of file +export type LoggedMessage = { + id: string + author_id: string + author_name: string + channel_id: string + attachments: string + stickers: string + content: string +} + +export type GuildSettings = { + guild_id: string + general_chat_id?: string + new_member_channel_id?: string + tickets_channel_id?: string + event_logs_channel_id?: string + discord_logs_channel_id?: string + audit_logs_channel_id?: string + voice_logs_channel_id?: string + admin_role_id?: string + private_help_role_id?: string + devwatch_role_id?: string + staff_categories?: string + safe_channels?: string + link_skip_channels?: string + github_release_channel?: string + moderator_channel_id?: string + private_help_channel_id?: string +} + +type GuildSetting = Exclude +export type GuildArraySetting = 'staff_categories' | 'safe_channels' | 'link_skip_channels'; + +export type TicketMessage = { + id: number + message_id: string +} + +export type TicketPhrase = { + id: number + user_id: string + phrase: string +} + +export type Note = { + id: number + user_id: string + reason: string + mod_id: string + timestamp: string +} + +export type Ban = { + id: number + user_id: string + expires: 0 | 1 + expires_at: string + full_ban: 0 | 1 +} + +export type GithubUserMapping = { + id: number + discord_id: string + github_username: string +} + +export type KnowledgebaseItem = { + id: number + guild_id: string + name: string + content: string +} + +export type PrivateHelpTicket = { + id: number + user_id: string + thread_id: string + status: PrivateHelpTicketStatus + timestamp: string +}