Initial commit: Gaming Hub foundation
Plugin-based Discord bot framework with web frontend: - Core: Discord.js client, SSE broadcast, JSON persistence - Plugin system: lifecycle hooks (init, onReady, routes, snapshot, destroy) - Web: React 19 + Vite 6 + TypeScript, tab-based navigation - Docker: multi-stage build (Node 24, static ffmpeg, yt-dlp) - GitLab CI: Kaniko with LAN registry caching Ready for plugin development.
This commit is contained in:
parent
1ae431dd2f
commit
ae1c41f0ae
19 changed files with 954 additions and 0 deletions
39
server/src/core/plugin.ts
Normal file
39
server/src/core/plugin.ts
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import { Client } from 'discord.js';
|
||||
import express from 'express';
|
||||
|
||||
export interface Plugin {
|
||||
name: string;
|
||||
version: string;
|
||||
description: string;
|
||||
|
||||
/** Called once when plugin is loaded */
|
||||
init(ctx: PluginContext): Promise<void>;
|
||||
|
||||
/** Called when Discord client is ready */
|
||||
onReady?(ctx: PluginContext): Promise<void>;
|
||||
|
||||
/** Called to register Express routes */
|
||||
registerRoutes?(app: express.Application, ctx: PluginContext): void;
|
||||
|
||||
/** Called to build SSE snapshot data for new clients */
|
||||
getSnapshot?(ctx: PluginContext): Record<string, any>;
|
||||
|
||||
/** Called on graceful shutdown */
|
||||
destroy?(ctx: PluginContext): Promise<void>;
|
||||
}
|
||||
|
||||
export interface PluginContext {
|
||||
client: Client;
|
||||
dataDir: string;
|
||||
}
|
||||
|
||||
const loadedPlugins: Plugin[] = [];
|
||||
|
||||
export function registerPlugin(plugin: Plugin): void {
|
||||
loadedPlugins.push(plugin);
|
||||
console.log(`[Plugin] Registered: ${plugin.name} v${plugin.version}`);
|
||||
}
|
||||
|
||||
export function getPlugins(): Plugin[] {
|
||||
return [...loadedPlugins];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue