// wrapper for the database drivers in ./database/ import logger from "#utils/logger.js"; import { detectRuntime, getEnv } from "#utils/runtime.js"; import { type DBGuild, isError, type Tag } from "#utils/types.js"; export declare class DatabasePlugin { constructor(connectString: string); setup: () => Promise; stop: () => Promise; upgrade: () => Promise; addCount: (command: string) => Promise; getCounts: (all?: boolean) => Promise>; disableCommand: (guild: string, command: string) => Promise; enableCommand: (guild: string, command: string) => Promise; disableChannel: (channel: string, guild: string) => Promise; enableChannel: (channel: string, guild: string) => Promise; getTag: (guild: string, tag: string) => Promise; getTags: (guild: string) => Promise>; setTag: (tag: Tag, guild: string) => Promise; removeTag: (name: string, guild: string) => Promise; editTag: (tag: Tag, guild: string) => Promise; addTagRole: (guild: string, role: string) => Promise; removeTagRole: (guild: string, role: string) => Promise; setBroadcast: (msg?: string) => Promise; getBroadcast: () => Promise; setPrefix: (prefix: string, guild: string) => Promise; getGuild: (query: string) => Promise; } export async function init(): Promise { const db = getEnv("DB"); if (db) { const dbtype = db.split("://")[0]; try { const construct = (await import(`./database/${dbtype}.${detectRuntime().tsLoad ? "ts" : "js"}`)).default; return new construct(db); } catch (error) { if (isError(error) && error.code === "ERR_MODULE_NOT_FOUND") { logger.error(`DB config option has unknown database type '${dbtype}'`); } throw error; } } else { logger.warn("No database configured, running in stateless mode..."); return; } }