A powerful and extendable Discord bot, with it's own module system :3 thevoid.cafe/projects/voidy

🦺 Gracefully handle missing loader directories

Jo b91caae0 77656eb6

Changed files
+17 -12
src
core
+17 -12
src/core/Loader.ts
··· 26 26 const glob = new Glob(`**/**.ts`); 27 27 const iterator = glob.scan(this.dataSource); 28 28 29 - for await (const path of iterator) { 30 - let moduleDefault: T | null; 29 + try { 30 + for await (const path of iterator) { 31 + let moduleDefault: T | null; 31 32 32 - try { 33 - const module = (await import(`${this.dataSource}/${path}`)); 34 - moduleDefault = module.default; 33 + try { 34 + const module = (await import(`${this.dataSource}/${path}`)); 35 + moduleDefault = module.default; 35 36 36 - if (!moduleDefault) continue; 37 - } catch { 38 - continue; 39 - } 37 + if (!moduleDefault) continue; 38 + } catch { 39 + continue; 40 + } 40 41 41 - const final = await this.validate(moduleDefault); 42 - if (!final) continue; 42 + const final = await this.validate(moduleDefault); 43 + if (!final) continue; 43 44 44 - this.store.push(final); 45 + this.store.push(final); 46 + } 47 + } catch { 48 + console.error(`[Voidy] Specified loader target ${this.dataSource} doesn't exist. Skipping...`); 49 + return this; 45 50 } 46 51 47 52 return this;