fixed extension loader

This commit is contained in:
2025-12-11 19:50:00 +01:00
parent c9a9f847f7
commit 8d5462213e

View File

@@ -52,7 +52,8 @@ async function loadExtension(fileName) {
const filePath = path.join(extensionsDir, fileName); const filePath = path.join(extensionsDir, fileName);
if (!fs.existsSync(filePath)) { if (!fs.existsSync(filePath)) {
throw new Error("Extension file does not exist"); console.warn(`⚠️ Extension not found: ${fileName}`);
return;
} }
try { try {
@@ -65,26 +66,24 @@ async function loadExtension(fileName) {
: (ExtensionClass.default ? new ExtensionClass.default() : null); : (ExtensionClass.default ? new ExtensionClass.default() : null);
if (!instance) { if (!instance) {
throw new Error("Invalid extension export"); console.warn(`⚠️ Invalid extension: ${fileName}`);
return;
} }
if ( if (!["anime-board", "book-board", "image-board"].includes(instance.type)) {
instance.type !== "anime-board" && console.warn(`⚠️ Invalid extension (${instance.type}): ${fileName}`);
instance.type !== "book-board" && return;
instance.type !== "image-board"
) {
throw new Error(`Invalid extension type: ${instance.type}`);
} }
const name = instance.constructor.name; const name = instance.constructor.name;
instance.scrape = scrape; instance.scrape = scrape;
extensions.set(name, instance); extensions.set(name, instance);
console.log(`📦 Installed & Loaded Extension: ${name}`); console.log(`📦 Installed & loaded: ${name}`);
return name; return name;
} catch (err) { } catch (err) {
throw new Error(`LoadExtension failed: ${err.message}`); console.warn(`⚠️ Error loading ${fileName}: ${err.message}`);
} }
} }