Skip to content

Commit

Permalink
Fix Loader
Browse files Browse the repository at this point in the history
  • Loading branch information
Smaug6739 committed Jun 6, 2022
1 parent 42dccc7 commit 7b2d691
Show file tree
Hide file tree
Showing 31 changed files with 13 additions and 645 deletions.
6 changes: 6 additions & 0 deletions src/structures/BaseStructure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ export abstract class BaseStructure {
*/
public client: ShewenyClient;

/**
* The structure is loadable by the Loader
* @internal
* @type {string}
*/
static readonly _id: string = "ShewenyLoadable";
/**
* Path to file
* @type {string}
Expand Down
5 changes: 3 additions & 2 deletions src/utils/Loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { Class, Manager, Structure } from '../typescript/index.js';
}*/
type WithMainProperty<K extends string, V> = { [P in K]: V };
type StructureConstructed<MKN extends string, MKV, V> = V & WithMainProperty<MKN, MKV>;
type StructureConstructable<MKN extends string, MKV, S> = new (client: ShewenyClient) => S & WithMainProperty<MKN, MKV>;
type StructureConstructable<MKN extends string, MKV, S> = {_id:string} & (new (client: ShewenyClient) => S & WithMainProperty<MKN, MKV>);
type StructureType<MKN extends string, MKV> = BaseStructure & WithMainProperty<MKN, MKV>;

interface LoaderOptions {
Expand Down Expand Up @@ -94,6 +94,7 @@ export class Loader<MKN extends string, MKV, V extends StructureType<MKN, MKV>>
}
private async loadStructure(StructureToLoad: StructureConstructable<MKN, MKV, V>, path: string) {
try {
if(StructureToLoad["_id"] != "ShewenyLoadable") return;
const instance: StructureConstructed<MKN, MKV, V> = new StructureToLoad(this.client);
if (!instance) return;
// Bad instance
Expand All @@ -102,7 +103,7 @@ export class Loader<MKN extends string, MKV, V extends StructureType<MKN, MKV>>
return new ShewenyWarning(this.client, 'MISSING_PROPERTY_CLASS', this.mainKey, path);
}
if (this.collection.get(instance[this.mainKey])) {
return new ShewenyWarning(this.client, 'DUPLICATE_CLASS', path);
return new ShewenyWarning(this.client, 'DUPLICATE_CLASS', `${instance[this.mainKey]}`, path);
}

// Set data on structure
Expand Down
39 changes: 0 additions & 39 deletions test/build/commands/autocomplete/autocomplete.js

This file was deleted.

31 changes: 0 additions & 31 deletions test/build/commands/buttons/buttons-regex.js

This file was deleted.

24 changes: 0 additions & 24 deletions test/build/commands/buttons/buttons.js

This file was deleted.

26 changes: 0 additions & 26 deletions test/build/commands/context-menus/msg.js

This file was deleted.

21 changes: 0 additions & 21 deletions test/build/commands/context-menus/user.js

This file was deleted.

66 changes: 0 additions & 66 deletions test/build/commands/eval.js

This file was deleted.

36 changes: 0 additions & 36 deletions test/build/commands/modals/modal.js

This file was deleted.

44 changes: 0 additions & 44 deletions test/build/commands/msg-commands/arguments.js

This file was deleted.

18 changes: 0 additions & 18 deletions test/build/commands/msg-commands/test-msg.js

This file was deleted.

19 changes: 0 additions & 19 deletions test/build/commands/permissions.js

This file was deleted.

Loading

0 comments on commit 7b2d691

Please sign in to comment.