rashi-discord-bot-lib
Version:
🚀 Powerful Discord bot framework with built-in database, event handling, and utilities
198 lines • 6.08 kB
TypeScript
import { Client, Message, AutocompleteInteraction, ChatInputCommandInteraction } from "discord.js";
import { BotStatistics } from "../utils/BotStatistics";
import { SlashCommandBuilder, SlashCommandSubcommandsOnlyBuilder, SlashCommandOptionsOnlyBuilder, PermissionResolvable } from 'discord.js';
export interface LoggerOptions {
name: string;
color?: string;
debug?: boolean;
}
export interface MusicConfig {
enable: boolean;
defaultSearchEngine?: 'youtube' | 'youtubemusic' | 'soundcloud' | 'spotify';
nodes: Array<{
name: string;
url: string;
auth: string;
secure?: boolean;
}>;
}
export interface BotStarterOptions {
bot: {
token: string;
logs?: LogsConfig;
avatar?: string;
BotInfo?: BotInfoConfig;
Database: DatabaseConfig;
};
/** 🔊 AI opcje (jeśli chcesz) */
AI?: {
openaiKey?: string;
googleKey?: string;
stabilityKey?: string;
};
/** ⬇️ MUZYKA na głównym poziomie (NIE w `bot`) */
Music?: MusicConfig;
events: EventsConfig;
commands?: CommandsConfig;
anticrash?: AntiCrashConfig;
}
export interface LogsConfig {
devLogs?: {
enable: boolean;
pathToWatch: string;
webhookURL: string;
mention?: string;
};
terminal?: boolean;
updates?: {
webhookURL?: string;
mentionId?: string;
};
}
export interface BotInfoConfig {
perms?: string[];
serverId?: string;
botInvite?: string;
serverInvite?: string;
ownerId?: string;
avatar?: string;
}
export interface DatabaseConfig {
verse?: VerseConfig;
mongo?: MongoConfig;
}
export interface VerseConfig {
/** Wybór adaptera dla Verse */
adapterType: "json" | "yaml" | "sql" | "mongo" | "sqlite";
/** Ścieżka dla adapterów plikowych */
path?: string;
/** Parametry połączenia dla adaptera mongo (1-doc storage) */
mongoURI?: string;
dbName?: string;
collection?: string;
documentId?: string;
dev?: {
enable: boolean;
logsPath?: string;
};
secure?: {
enable: boolean;
secret: string;
};
}
export interface MongoConfig {
mongoURI?: string;
}
/** Interfejs adaptera (JSON/YAML/SQL/Mongo) pod Verse */
export interface DatabaseAdapter {
read(): Promise<any>;
write(data: any): Promise<void>;
exists(): boolean;
backup(path: string): Promise<void>;
restore(path: string): Promise<void>;
/** Opcjonalne dla adapterów z połączeniem sieciowym */
connect?(): Promise<void>;
disconnect?(): Promise<void>;
}
/** Publiczne API Verse (KV) używane przez komendy */
export interface VerseDatabase {
get(key: string): any;
set(key: string, value: any): Promise<void>;
delete(key: string): Promise<void>;
has(key: string): boolean;
all(): any[];
clear(): Promise<void>;
backup(path?: string): Promise<void>;
restore(path: string): Promise<void>;
/** Do statystyk (adapter/keys/size) */
getStats(): Promise<{
adapter: string;
keys: number;
size: number;
}>;
}
export interface EventsConfig {
path: string;
recursive?: boolean;
eventBlacklist?: string[];
}
export interface CommandsConfig {
slashPath?: string;
prefixPath?: string;
prefix?: string;
}
export interface AntiCrashConfig {
enable: boolean;
webhookURL: string;
mention?: string;
}
/** Opcje wspólne dla Slash/Prefix */
export interface CommandOptions {
/** ⏳ Cooldown in seconds */
cooldown?: number;
/** ⚡ Allow quick usage (custom behavior) */
fastUse?: boolean;
/** 🔓 Required Discord permissions (user & bot – chyba że guardy rozdzielisz) */
permissions?: PermissionResolvable[];
/** 👑 Owner only */
ownerOnly?: boolean;
/** 👨💻 Devs only (from env) */
devOnly?: boolean;
/** 🏠 Guild only */
guildOnly?: boolean;
/** 💌 DM only */
dmOnly?: boolean;
/** 🧨 (opcjonalnie) niestandardowy klucz cooldownu, np. per-guild */
cooldownKey?: (ctx: {
userId: string;
guildId?: string;
command: string;
}) => string;
/** 🧰 (opcjonalnie) własna obsługa błędów komendy */
onError?: (error: unknown) => void | Promise<void>;
}
/** Dowolny wariant buildera slash commands */
export type AnySlashBuilder = SlashCommandBuilder | SlashCommandSubcommandsOnlyBuilder | SlashCommandOptionsOnlyBuilder;
export interface SlashCommand extends CommandOptions {
data: AnySlashBuilder;
permissions?: PermissionResolvable[];
guildOnly?: boolean;
cooldown?: number;
execute: (interaction: ChatInputCommandInteraction, client: Client, language: string) => Promise<void>;
autocomplete?: (interaction: AutocompleteInteraction) => Promise<any>;
}
export interface PrefixCommand extends CommandOptions {
name: string;
description: string;
aliases?: string[];
usage?: string;
execute: (message: Message, args: string[], client: Client, language: string) => Promise<void>;
}
export interface Event {
name: string;
once?: boolean;
execute: (...args: any[]) => Promise<void>;
}
export interface BotStartResult {
client: Client;
versedb?: any;
mongodb?: any;
slashSize: number;
prefixSize: number;
eventSize: number;
getDb?: () => any;
db?: any;
statistics: BotStatistics;
/** Manager muzyki (opcjonalny) – TYPE-ONLY import, zero runtime zależności */
music?: import('../music/MusicManager').MusicManager;
/** ⬇️ Dodaj AIChat (i inne AI jeśli chcesz) */
/** 🧠 Komponenty AI – opcjonalnie inicjalizowane w zależności od kluczy API */
ai?: {
chat?: import('../ai/AIChat').AIChat;
tts?: import('../ai/TTSService').TTSService;
stt?: import('../ai/STTService').STTService;
image?: import('../ai/ImageGenerator').ImageGenerator;
memory?: import('../ai/ChatMemory').ChatMemory;
};
}
//# sourceMappingURL=index.d.ts.map