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