@stelliajs/framework 1.5.3 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,7 +11,6 @@ Recommended architecture for StelliaJS project.
11
11
 
12
12
  ```
13
13
  .
14
- ├── dist // Build folder
15
14
  ├── src/
16
15
  │ ├── commands/
17
16
  │ │ ├── contextMenus/
@@ -41,7 +40,7 @@ Recommended architecture for StelliaJS project.
41
40
  │ └── index.ts
42
41
  ├── .env
43
42
  ├── package.json
44
- ├── package-lock.json
43
+ ├── pnpm-lock.yaml
45
44
  ├── stellia.json
46
45
  └── tsconfig.json
47
46
  ```
@@ -11,8 +11,8 @@ export declare class StelliaClient<Ready extends boolean = boolean> extends Clie
11
11
  getGuildsConfiguration: <CustomGuildsConfiguration extends GuildsConfiguration>() => Promise<CustomGuildsConfiguration>;
12
12
  getGuildConfiguration: <CustomGuildConfiguration extends GuildConfiguration>(guildId: string) => CustomGuildConfiguration | undefined;
13
13
  handleInteraction: (interaction: Interaction<"cached">) => Promise<void>;
14
- private areManagersLoaded;
15
- private static convertFilePathToProduction;
14
+ private readonly areManagersLoaded;
15
+ private static readonly convertFilePathToProduction;
16
16
  }
17
17
  interface StelliaOptions {
18
18
  managers: {
@@ -1,6 +1,6 @@
1
1
  import * as fs from "node:fs";
2
- import path from "path";
3
- import { pathToFileURL } from "url";
2
+ import path from "node:path";
3
+ import { pathToFileURL } from "node:url";
4
4
  import { Client } from "discord.js";
5
5
  import { StelliaUtils } from "./index.js";
6
6
  import { AutoCompleteManager, ButtonManager, CommandManager, ContextMenuManager, EventManager, ModalManager, SelectMenuManager } from "../managers/index.js";
@@ -67,24 +67,20 @@ export class StelliaClient extends Client {
67
67
  return new Promise((resolve, reject) => {
68
68
  fs.readFile(filePath, async (err, data) => {
69
69
  if (err) {
70
- return reject(err);
70
+ return reject(new Error("stellia.json file not found"));
71
71
  }
72
- try {
73
- const environments = JSON.parse(data.toString()).environments;
74
- if (!Object.keys(environments).includes(chosenEnvironment)) {
75
- return reject(new Error("Invalid environment"));
76
- }
77
- const environmentData = environments[chosenEnvironment];
78
- const environmentPath = environmentData.production
79
- ? StelliaClient.convertFilePathToProduction(environmentData.file)
80
- : environmentData.file;
81
- const environmentAbsolutePath = pathToFileURL(path.join(srcPath, "..", environmentPath)).href;
82
- const environmentFile = await import(environmentAbsolutePath);
83
- resolve(environmentFile.environment);
84
- }
85
- catch (error) {
86
- reject(error);
72
+ const environments = JSON.parse(data.toString()).environments;
73
+ if (!Object.keys(environments).includes(chosenEnvironment)) {
74
+ return reject(new Error("Invalid environment"));
87
75
  }
76
+ const environmentData = environments[chosenEnvironment];
77
+ const environmentPath = environmentData.production
78
+ ? StelliaClient.convertFilePathToProduction(environmentData.file)
79
+ : environmentData.file;
80
+ const environmentAbsolutePath = pathToFileURL(path.join(srcPath, "..", environmentPath)).href;
81
+ import(environmentAbsolutePath)
82
+ .then((environmentFile) => resolve(environmentFile.environment))
83
+ .catch(() => reject(new Error("Error parsing stellia.json file")));
88
84
  });
89
85
  });
90
86
  };
@@ -9,13 +9,13 @@ export declare class StelliaUtils {
9
9
  initializeCommands: () => Promise<void>;
10
10
  getGuildConfiguration: <CustomGuildConfiguration extends GuildConfiguration>(guildId: string) => CustomGuildConfiguration | undefined;
11
11
  handleInteraction: (interaction: Interaction<"cached">) => Promise<void>;
12
- private handleAutoCompleteInteraction;
13
- private handleButtonInteraction;
14
- private handleCommandInteraction;
15
- private handleContextMenuInteraction;
16
- private handleModalInteraction;
17
- private handleSelectMenuInteraction;
18
- private handleMessageContextMenuInteraction;
19
- private handleUserContextMenuInteraction;
12
+ private readonly handleAutoCompleteInteraction;
13
+ private readonly handleButtonInteraction;
14
+ private readonly handleCommandInteraction;
15
+ private readonly handleContextMenuInteraction;
16
+ private readonly handleModalInteraction;
17
+ private readonly handleSelectMenuInteraction;
18
+ private readonly handleMessageContextMenuInteraction;
19
+ private readonly handleUserContextMenuInteraction;
20
20
  private getInteractionType;
21
21
  }
@@ -6,7 +6,7 @@ export declare class AutoCompleteManager extends BaseManager {
6
6
  private interactions;
7
7
  constructor(client: StelliaClient, directory: string);
8
8
  loadData(): Promise<void>;
9
- getByCustomId<AutoCompleteStructure>(id: InteractionCustomId): AutoCompleteStructure | undefined;
10
- getByRegex<AutoCompleteStructure>(id: InteractionCustomId): AutoCompleteStructure | undefined;
9
+ getByCustomId<AutoCompleteStructure>(id: InteractionCustomId): AutoCompleteStructure | null;
10
+ getByRegex<AutoCompleteStructure>(id: InteractionCustomId): AutoCompleteStructure | null;
11
11
  getAll<AutoCompleteStructure>(): Collection<StructureCustomId, AutoCompleteStructure>;
12
12
  }
@@ -12,11 +12,18 @@ export class AutoCompleteManager extends BaseManager {
12
12
  this.setManagerLoaded();
13
13
  }
14
14
  getByCustomId(id) {
15
- const autoComplete = this.interactions.get(id) ?? undefined;
15
+ const autoComplete = this.interactions.get(id) ?? null;
16
16
  return autoComplete;
17
17
  }
18
18
  getByRegex(id) {
19
- return undefined;
19
+ let autoComplete = null;
20
+ for (const [customId, action] of this.interactions.entries()) {
21
+ if (customId instanceof RegExp && customId.test(id)) {
22
+ autoComplete = action;
23
+ break;
24
+ }
25
+ }
26
+ return autoComplete;
20
27
  }
21
28
  getAll() {
22
29
  const autoCompletes = this.interactions;
@@ -12,8 +12,8 @@ export declare abstract class BaseManager {
12
12
  constructor(client: StelliaClient, directory: string);
13
13
  isManagerLoaded(): boolean;
14
14
  setManagerLoaded(): void;
15
- abstract loadData(): void;
16
- abstract getByCustomId<InteractionStructure extends AnyInteractionStructure>(id: InteractionCustomId): InteractionStructure | undefined;
17
- abstract getByRegex<InteractionStructure extends AnyInteractionStructure>(id: InteractionCustomId): InteractionStructure | undefined;
15
+ abstract loadData(): Promise<void>;
16
+ abstract getByCustomId<InteractionStructure extends AnyInteractionStructure>(id: InteractionCustomId): InteractionStructure | null;
17
+ abstract getByRegex<InteractionStructure extends AnyInteractionStructure>(id: InteractionCustomId): InteractionStructure | null;
18
18
  abstract getAll<InteractionStructure extends AnyInteractionStructure>(): Collection<StructureCustomId, InteractionStructure>;
19
19
  }
@@ -7,7 +7,7 @@ export declare class ButtonManager extends BaseManager {
7
7
  interactions: Collection<StructureCustomId, ButtonStructure>;
8
8
  constructor(client: StelliaClient, directory: string);
9
9
  loadData(): Promise<void>;
10
- getByCustomId<ButtonStructure>(id: InteractionCustomId): ButtonStructure | undefined;
11
- getByRegex<ButtonStructure>(id: InteractionCustomId): ButtonStructure | undefined;
10
+ getByCustomId<ButtonStructure>(id: InteractionCustomId): ButtonStructure | null;
11
+ getByRegex<ButtonStructure>(id: InteractionCustomId): ButtonStructure | null;
12
12
  getAll<ButtonStructure>(): Collection<StructureCustomId, ButtonStructure>;
13
13
  }
@@ -12,11 +12,11 @@ export class ButtonManager extends BaseManager {
12
12
  this.setManagerLoaded();
13
13
  }
14
14
  getByCustomId(id) {
15
- const button = this.interactions.get(id) ?? undefined;
15
+ const button = this.interactions.get(id) ?? null;
16
16
  return button;
17
17
  }
18
18
  getByRegex(id) {
19
- let button;
19
+ let button = null;
20
20
  for (const [customId, action] of this.interactions.entries()) {
21
21
  if (customId instanceof RegExp && customId.test(id)) {
22
22
  button = action;
@@ -6,7 +6,7 @@ export declare class CommandManager extends BaseManager {
6
6
  private interactions;
7
7
  constructor(client: StelliaClient, directory: string);
8
8
  loadData(): Promise<void>;
9
- getByCustomId<CommandStructure>(id: InteractionCustomId): CommandStructure | undefined;
10
- getByRegex<CommandStructure>(id: InteractionCustomId): CommandStructure | undefined;
9
+ getByCustomId<CommandStructure>(id: InteractionCustomId): CommandStructure | null;
10
+ getByRegex<CommandStructure>(id: InteractionCustomId): CommandStructure | null;
11
11
  getAll<CommandStructure>(): Collection<StructureCustomId, CommandStructure>;
12
12
  }
@@ -12,11 +12,18 @@ export class CommandManager extends BaseManager {
12
12
  this.setManagerLoaded();
13
13
  }
14
14
  getByCustomId(id) {
15
- const command = this.interactions.get(id) ?? undefined;
15
+ const command = this.interactions.get(id) ?? null;
16
16
  return command;
17
17
  }
18
18
  getByRegex(id) {
19
- return undefined;
19
+ let command = null;
20
+ for (const [customId, action] of this.interactions.entries()) {
21
+ if (customId instanceof RegExp && customId.test(id)) {
22
+ command = action;
23
+ break;
24
+ }
25
+ }
26
+ return command;
20
27
  }
21
28
  getAll() {
22
29
  const commands = this.interactions;
@@ -6,7 +6,7 @@ export declare class ContextMenuManager extends BaseManager {
6
6
  private interactions;
7
7
  constructor(client: StelliaClient, directory: string);
8
8
  loadData(): Promise<void>;
9
- getByCustomId<ContextMenuStructure>(id: InteractionCustomId): ContextMenuStructure | undefined;
10
- getByRegex<ContextMenuStructure>(id: InteractionCustomId): ContextMenuStructure | undefined;
9
+ getByCustomId<ContextMenuStructure>(id: InteractionCustomId): ContextMenuStructure | null;
10
+ getByRegex<ContextMenuStructure>(id: InteractionCustomId): ContextMenuStructure | null;
11
11
  getAll<ContextMenuStructure>(): Collection<StructureCustomId, ContextMenuStructure>;
12
12
  }
@@ -12,11 +12,18 @@ export class ContextMenuManager extends BaseManager {
12
12
  this.setManagerLoaded();
13
13
  }
14
14
  getByCustomId(id) {
15
- const contextMenu = this.interactions.get(id) ?? undefined;
15
+ const contextMenu = this.interactions.get(id) ?? null;
16
16
  return contextMenu;
17
17
  }
18
18
  getByRegex(id) {
19
- return undefined;
19
+ let contextMenu = null;
20
+ for (const [customId, action] of this.interactions.entries()) {
21
+ if (customId instanceof RegExp && customId.test(id)) {
22
+ contextMenu = action;
23
+ break;
24
+ }
25
+ }
26
+ return contextMenu;
20
27
  }
21
28
  getAll() {
22
29
  const contextMenus = this.interactions;
@@ -7,11 +7,11 @@ export declare class EventManager extends BaseManager {
7
7
  private guildsConfiguration;
8
8
  constructor(client: StelliaClient, directoryPath: string);
9
9
  loadData(): Promise<void>;
10
- getByCustomId<EventStructure>(id: InteractionCustomId): EventStructure | undefined;
11
- getByRegex<EventStructure>(id: InteractionCustomId): EventStructure | undefined;
10
+ getByCustomId<EventStructure>(id: InteractionCustomId): EventStructure | null;
11
+ getByRegex<EventStructure>(id: InteractionCustomId): EventStructure | null;
12
12
  getAll<EventStructure>(): Collection<StructureCustomId, EventStructure>;
13
13
  private loadEventWithGuildConfiguration;
14
- private eventHandler;
14
+ private readonly eventHandler;
15
15
  private loadEventWithoutGuildConfiguration;
16
16
  private getGuildConfiguration;
17
17
  }
@@ -31,11 +31,18 @@ export class EventManager extends BaseManager {
31
31
  this.setManagerLoaded();
32
32
  }
33
33
  getByCustomId(id) {
34
- const event = this.interactions.get(id) ?? undefined;
34
+ const event = this.interactions.get(id) ?? null;
35
35
  return event;
36
36
  }
37
37
  getByRegex(id) {
38
- return undefined;
38
+ let event = null;
39
+ for (const [customId, action] of this.interactions.entries()) {
40
+ if (customId instanceof RegExp && customId.test(id)) {
41
+ event = action;
42
+ break;
43
+ }
44
+ }
45
+ return event;
39
46
  }
40
47
  getAll() {
41
48
  const events = this.interactions;
@@ -6,7 +6,7 @@ export declare class ModalManager extends BaseManager {
6
6
  private interactions;
7
7
  constructor(client: StelliaClient, directory: string);
8
8
  loadData(): Promise<void>;
9
- getByCustomId<ModalStructure>(id: InteractionCustomId): ModalStructure | undefined;
10
- getByRegex<ModalStructure>(id: InteractionCustomId): ModalStructure | undefined;
9
+ getByCustomId<ModalStructure>(id: InteractionCustomId): ModalStructure | null;
10
+ getByRegex<ModalStructure>(id: InteractionCustomId): ModalStructure | null;
11
11
  getAll<ModalStructure>(): Collection<StructureCustomId, ModalStructure>;
12
12
  }
@@ -12,11 +12,11 @@ export class ModalManager extends BaseManager {
12
12
  this.setManagerLoaded();
13
13
  }
14
14
  getByCustomId(id) {
15
- const modal = this.interactions.get(id) ?? undefined;
15
+ const modal = this.interactions.get(id) ?? null;
16
16
  return modal;
17
17
  }
18
18
  getByRegex(id) {
19
- let modal;
19
+ let modal = null;
20
20
  for (const [customId, action] of this.interactions.entries()) {
21
21
  if (customId instanceof RegExp && customId.test(id)) {
22
22
  modal = action;
@@ -6,7 +6,7 @@ export declare class SelectMenuManager extends BaseManager {
6
6
  private interactions;
7
7
  constructor(client: StelliaClient, directory: string);
8
8
  loadData(): Promise<void>;
9
- getByCustomId<SelectMenuStructure>(id: InteractionCustomId): SelectMenuStructure | undefined;
10
- getByRegex<SelectMenuStructure>(id: InteractionCustomId): SelectMenuStructure | undefined;
9
+ getByCustomId<SelectMenuStructure>(id: InteractionCustomId): SelectMenuStructure | null;
10
+ getByRegex<SelectMenuStructure>(id: InteractionCustomId): SelectMenuStructure | null;
11
11
  getAll<SelectMenuStructure>(): Collection<StructureCustomId, SelectMenuStructure>;
12
12
  }
@@ -12,18 +12,18 @@ export class SelectMenuManager extends BaseManager {
12
12
  this.setManagerLoaded();
13
13
  }
14
14
  getByCustomId(id) {
15
- const selectMenu = this.interactions.get(id) ?? undefined;
15
+ const selectMenu = this.interactions.get(id) ?? null;
16
16
  return selectMenu;
17
17
  }
18
18
  getByRegex(id) {
19
- let button;
19
+ let selectMenu = null;
20
20
  for (const [customId, action] of this.interactions.entries()) {
21
21
  if (customId instanceof RegExp && customId.test(id)) {
22
- button = action;
22
+ selectMenu = action;
23
23
  break;
24
24
  }
25
25
  }
26
- return button;
26
+ return selectMenu;
27
27
  }
28
28
  getAll() {
29
29
  const selectMenus = this.interactions;
@@ -1,5 +1,5 @@
1
- import { readdirSync, statSync } from "fs";
2
- import path from "path";
1
+ import { readdirSync, statSync } from "node:fs";
2
+ import path from "node:path";
3
3
  import { Collection } from "discord.js";
4
4
  export const requiredFiles = async (directoryPath) => {
5
5
  const collection = new Collection();
@@ -12,18 +12,13 @@ export const requiredFiles = async (directoryPath) => {
12
12
  return collection;
13
13
  };
14
14
  const loadInteraction = async (filePath) => {
15
- try {
16
- const module = await import(`file://${filePath}`);
17
- const data = module.default;
18
- return data;
19
- }
20
- catch (error) {
21
- throw error;
22
- }
15
+ const module = await import(`file://${filePath}`);
16
+ const data = module.default;
17
+ return data;
23
18
  };
24
19
  const getAllFilesPath = (dirPath, arrayOfFiles = []) => {
25
20
  const files = readdirSync(dirPath);
26
- files.forEach((file) => {
21
+ for (const file of files) {
27
22
  if (statSync(dirPath + "/" + file).isDirectory()) {
28
23
  arrayOfFiles = getAllFilesPath(dirPath + "/" + file, arrayOfFiles);
29
24
  }
@@ -31,6 +26,6 @@ const getAllFilesPath = (dirPath, arrayOfFiles = []) => {
31
26
  const __dirname = path.resolve();
32
27
  arrayOfFiles.push(path.join(__dirname, dirPath, "/", file));
33
28
  }
34
- });
29
+ }
35
30
  return arrayOfFiles;
36
31
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stelliajs/framework",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "scripts": {
@@ -23,19 +23,19 @@
23
23
  "framework"
24
24
  ],
25
25
  "dependencies": {
26
- "discord.js": "^14.21.0",
27
- "i18next": "^25.3.4",
26
+ "discord.js": "^14.22.1",
27
+ "i18next": "^25.5.2",
28
28
  "log-symbols": "^7.0.1"
29
29
  },
30
30
  "devDependencies": {
31
- "@eslint/js": "^9.33.0",
32
- "eslint-config-prettier": "^10.1.8",
33
- "eslint-import-resolver-typescript": "^4.4.4",
34
- "eslint-plugin-import": "^2.32.0",
35
- "prettier": "^3.6.2",
36
- "tsc-alias": "^1.8.16",
37
- "typescript-eslint": "^8.39.1"
31
+ "@eslint/js": "^9.36.0",
32
+ "eslint-config-prettier": "^10.1.8",
33
+ "eslint-import-resolver-typescript": "^4.4.4",
34
+ "eslint-plugin-import": "^2.32.0",
35
+ "prettier": "^3.6.2",
36
+ "tsc-alias": "^1.8.16",
37
+ "typescript-eslint": "^8.44.1"
38
38
  },
39
39
  "type": "module",
40
- "packageManager": "pnpm@10.14.0"
40
+ "packageManager": "pnpm@10.17.1"
41
41
  }