@stelliajs/framework 1.0.6 → 1.1.0-dev-1

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.
@@ -44,7 +44,7 @@ export class StelliaUtils {
44
44
  handleAutoCompleteInteraction = async (interaction) => {
45
45
  try {
46
46
  const interactionAutoComplete = interaction;
47
- const autoComplete = this.client.managers.autoCompletes?.get(interactionAutoComplete.commandName);
47
+ const autoComplete = this.client.managers.autoCompletes?.getByCustomId(interactionAutoComplete.commandName);
48
48
  if (!autoComplete)
49
49
  return;
50
50
  await autoComplete.execute(this.client, interactionAutoComplete);
@@ -56,7 +56,7 @@ export class StelliaUtils {
56
56
  handleButtonInteraction = async (interaction) => {
57
57
  try {
58
58
  const buttonInteraction = interaction;
59
- const button = this.client.managers.buttons?.get(buttonInteraction.customId);
59
+ const button = this.client.managers.buttons?.getByCustomId(buttonInteraction.customId);
60
60
  if (!button)
61
61
  return;
62
62
  await button.execute(this.client, buttonInteraction);
@@ -68,7 +68,7 @@ export class StelliaUtils {
68
68
  handleCommandInteraction = async (interaction) => {
69
69
  try {
70
70
  const interactionCommand = interaction;
71
- const command = this.client.managers.commands?.get(interactionCommand.commandName);
71
+ const command = this.client.managers.commands?.getByCustomId(interactionCommand.commandName);
72
72
  if (!command)
73
73
  return;
74
74
  await command.execute(this.client, interactionCommand);
@@ -96,7 +96,7 @@ export class StelliaUtils {
96
96
  handleModalInteraction = async (interaction) => {
97
97
  try {
98
98
  const interactionModal = interaction;
99
- const modal = this.client.managers.modals?.get(interactionModal.customId);
99
+ const modal = this.client.managers.modals?.getByCustomId(interactionModal.customId);
100
100
  if (!modal)
101
101
  return;
102
102
  await modal.execute(this.client, interactionModal);
@@ -108,7 +108,7 @@ export class StelliaUtils {
108
108
  handleSelectMenuInteraction = async (interaction) => {
109
109
  try {
110
110
  const interactionSelectMenu = interaction;
111
- const selectMenu = this.client.managers.selectMenus?.get(interactionSelectMenu.customId);
111
+ const selectMenu = this.client.managers.selectMenus?.getByCustomId(interactionSelectMenu.customId);
112
112
  if (!selectMenu)
113
113
  return;
114
114
  await selectMenu.execute(this.client, interactionSelectMenu);
@@ -119,7 +119,7 @@ export class StelliaUtils {
119
119
  };
120
120
  handleMessageContextMenuInteraction = async (interaction) => {
121
121
  try {
122
- const messageContextMenu = this.client.managers.contextMenus?.get(interaction.commandName);
122
+ const messageContextMenu = this.client.managers.contextMenus?.getByCustomId(interaction.commandName);
123
123
  if (!messageContextMenu)
124
124
  return;
125
125
  await messageContextMenu.execute(this.client, interaction);
@@ -130,7 +130,7 @@ export class StelliaUtils {
130
130
  };
131
131
  handleUserContextMenuInteraction = async (interaction) => {
132
132
  try {
133
- const userContextMenu = this.client.managers.contextMenus?.get(interaction.commandName);
133
+ const userContextMenu = this.client.managers.contextMenus?.getByCustomId(interaction.commandName);
134
134
  if (!userContextMenu)
135
135
  return;
136
136
  await userContextMenu.execute(this.client, interaction);
@@ -1,11 +1,12 @@
1
1
  import { Collection } from "discord.js";
2
2
  import { type StelliaClient } from "../client/index.js";
3
3
  import { BaseManager } from "./index.js";
4
- import { type CustomId } from "../typescript/index.js";
4
+ import { type StructureCustomId, type InteractionCustomId } from "../typescript/index.js";
5
5
  export declare class AutoCompleteManager extends BaseManager {
6
- private autoCompletes;
6
+ private interactions;
7
7
  constructor(client: StelliaClient, directory: string);
8
8
  loadData(): Promise<void>;
9
- get<AutoCompleteStructure>(id: CustomId): AutoCompleteStructure | undefined;
10
- getAll<AutoCompleteStructure>(): Collection<CustomId, AutoCompleteStructure>;
9
+ getByCustomId<AutoCompleteStructure>(id: InteractionCustomId): AutoCompleteStructure | undefined;
10
+ getByRegex<AutoCompleteStructure>(id: InteractionCustomId): AutoCompleteStructure | undefined;
11
+ getAll<AutoCompleteStructure>(): Collection<StructureCustomId, AutoCompleteStructure>;
11
12
  }
@@ -2,20 +2,23 @@ import { Collection } from "discord.js";
2
2
  import { BaseManager } from "./index.js";
3
3
  import { requiredFiles } from "../utils/index.js";
4
4
  export class AutoCompleteManager extends BaseManager {
5
- autoCompletes = new Collection();
5
+ interactions = new Collection();
6
6
  constructor(client, directory) {
7
7
  super(client, directory);
8
8
  }
9
9
  async loadData() {
10
10
  const autoCompletes = await requiredFiles(this.directoryPath);
11
- this.autoCompletes = autoCompletes;
11
+ this.interactions = autoCompletes;
12
12
  }
13
- get(id) {
14
- const autoComplete = this.autoCompletes.get(id) ?? undefined;
13
+ getByCustomId(id) {
14
+ const autoComplete = this.interactions.get(id) ?? undefined;
15
15
  return autoComplete;
16
16
  }
17
+ getByRegex(id) {
18
+ return undefined;
19
+ }
17
20
  getAll() {
18
- const autoCompletes = this.autoCompletes;
21
+ const autoCompletes = this.interactions;
19
22
  return autoCompletes;
20
23
  }
21
24
  }
@@ -1,6 +1,6 @@
1
1
  import { Collection } from "discord.js";
2
2
  import { type StelliaClient } from "../client/index.js";
3
- import { type CustomId } from "../typescript/index.js";
3
+ import { type StructureCustomId, type InteractionCustomId } from "../typescript/index.js";
4
4
  import { type AnyInteractionStructure } from "../structures/index.js";
5
5
  export interface ManagerOptions {
6
6
  directoryPath: string;
@@ -10,6 +10,7 @@ export declare abstract class BaseManager {
10
10
  readonly directoryPath: string;
11
11
  constructor(client: StelliaClient, directory: string);
12
12
  abstract loadData(): void;
13
- abstract get<InteractionStructure extends AnyInteractionStructure>(id: CustomId): InteractionStructure | undefined;
14
- abstract getAll<InteractionStructure extends AnyInteractionStructure>(): Collection<CustomId, InteractionStructure>;
13
+ abstract getByCustomId<InteractionStructure extends AnyInteractionStructure>(id: InteractionCustomId): InteractionStructure | undefined;
14
+ abstract getByRegex<InteractionStructure extends AnyInteractionStructure>(id: InteractionCustomId): InteractionStructure | undefined;
15
+ abstract getAll<InteractionStructure extends AnyInteractionStructure>(): Collection<StructureCustomId, InteractionStructure>;
15
16
  }
@@ -2,11 +2,12 @@ import { Collection } from "discord.js";
2
2
  import { type StelliaClient } from "../client/index.js";
3
3
  import { BaseManager } from "./index.js";
4
4
  import { type ButtonStructure } from "../structures/index.js";
5
- import { type CustomId } from "../typescript/index.js";
5
+ import { type StructureCustomId, type InteractionCustomId } from "../typescript/index.js";
6
6
  export declare class ButtonManager extends BaseManager {
7
- buttons: Collection<CustomId, ButtonStructure>;
7
+ interactions: Collection<StructureCustomId, ButtonStructure>;
8
8
  constructor(client: StelliaClient, directory: string);
9
9
  loadData(): Promise<void>;
10
- get<ButtonStructure>(id: CustomId): ButtonStructure | undefined;
11
- getAll<ButtonStructure>(): Collection<CustomId, ButtonStructure>;
10
+ getByCustomId<ButtonStructure>(id: InteractionCustomId): ButtonStructure | undefined;
11
+ getByRegex<ButtonStructure>(id: InteractionCustomId): ButtonStructure | undefined;
12
+ getAll<ButtonStructure>(): Collection<StructureCustomId, ButtonStructure>;
12
13
  }
@@ -2,20 +2,30 @@ import { Collection } from "discord.js";
2
2
  import { BaseManager } from "./index.js";
3
3
  import { requiredFiles } from "../utils/index.js";
4
4
  export class ButtonManager extends BaseManager {
5
- buttons = new Collection();
5
+ interactions = new Collection();
6
6
  constructor(client, directory) {
7
7
  super(client, directory);
8
8
  }
9
9
  async loadData() {
10
10
  const buttons = await requiredFiles(this.directoryPath);
11
- this.buttons = buttons;
11
+ this.interactions = buttons;
12
12
  }
13
- get(id) {
14
- const button = this.buttons.get(id) ?? undefined;
13
+ getByCustomId(id) {
14
+ const button = this.interactions.get(id) ?? undefined;
15
+ return button;
16
+ }
17
+ getByRegex(id) {
18
+ let button;
19
+ for (const [customId, action] of this.interactions.entries()) {
20
+ if (customId instanceof RegExp && customId.test(id)) {
21
+ button = action;
22
+ break;
23
+ }
24
+ }
15
25
  return button;
16
26
  }
17
27
  getAll() {
18
- const buttons = this.buttons;
28
+ const buttons = this.interactions;
19
29
  return buttons;
20
30
  }
21
31
  }
@@ -2,11 +2,12 @@ import { Collection } from "discord.js";
2
2
  import { type StelliaClient } from "../client/index.js";
3
3
  import { BaseManager } from "./index.js";
4
4
  import { type CommandStructure } from "../structures/index.js";
5
- import { type CustomId } from "../typescript/index.js";
5
+ import { type StructureCustomId, type InteractionCustomId } from "../typescript/index.js";
6
6
  export declare class CommandManager extends BaseManager {
7
- commands: Collection<CustomId, CommandStructure>;
7
+ interactions: Collection<StructureCustomId, CommandStructure>;
8
8
  constructor(client: StelliaClient, directory: string);
9
9
  loadData(): Promise<void>;
10
- get<CommandStructure>(id: CustomId): CommandStructure | undefined;
11
- getAll<CommandStructure>(): Collection<CustomId, CommandStructure>;
10
+ getByCustomId<CommandStructure>(id: InteractionCustomId): CommandStructure | undefined;
11
+ getByRegex<CommandStructure>(id: InteractionCustomId): CommandStructure | undefined;
12
+ getAll<CommandStructure>(): Collection<StructureCustomId, CommandStructure>;
12
13
  }
@@ -2,20 +2,23 @@ import { Collection } from "discord.js";
2
2
  import { BaseManager } from "./index.js";
3
3
  import { requiredFiles } from "../utils/index.js";
4
4
  export class CommandManager extends BaseManager {
5
- commands = new Collection();
5
+ interactions = new Collection();
6
6
  constructor(client, directory) {
7
7
  super(client, directory);
8
8
  }
9
9
  async loadData() {
10
10
  const commands = await requiredFiles(this.directoryPath);
11
- this.commands = commands;
11
+ this.interactions = commands;
12
12
  }
13
- get(id) {
14
- const command = this.commands.get(id) ?? undefined;
13
+ getByCustomId(id) {
14
+ const command = this.interactions.get(id) ?? undefined;
15
15
  return command;
16
16
  }
17
+ getByRegex(id) {
18
+ return undefined;
19
+ }
17
20
  getAll() {
18
- const commands = this.commands;
21
+ const commands = this.interactions;
19
22
  return commands;
20
23
  }
21
24
  }
@@ -2,11 +2,12 @@ import { Collection } from "discord.js";
2
2
  import { type StelliaClient } from "../client/index.js";
3
3
  import { BaseManager } from "./index.js";
4
4
  import { type ContextMenuStructure } from "../structures/index.js";
5
- import { type CustomId } from "../typescript/index.js";
5
+ import { type StructureCustomId, type InteractionCustomId } from "../typescript/index.js";
6
6
  export declare class ContextMenuManager extends BaseManager {
7
- contextMenus: Collection<CustomId, ContextMenuStructure>;
7
+ interactions: Collection<StructureCustomId, ContextMenuStructure>;
8
8
  constructor(client: StelliaClient, directory: string);
9
9
  loadData(): Promise<void>;
10
- get<ContextMenuStructure>(id: CustomId): ContextMenuStructure | undefined;
11
- getAll<ContextMenuStructure>(): Collection<CustomId, ContextMenuStructure>;
10
+ getByCustomId<ContextMenuStructure>(id: InteractionCustomId): ContextMenuStructure | undefined;
11
+ getByRegex<ContextMenuStructure>(id: InteractionCustomId): ContextMenuStructure | undefined;
12
+ getAll<ContextMenuStructure>(): Collection<StructureCustomId, ContextMenuStructure>;
12
13
  }
@@ -2,20 +2,23 @@ import { Collection } from "discord.js";
2
2
  import { BaseManager } from "./index.js";
3
3
  import { requiredFiles } from "../utils/index.js";
4
4
  export class ContextMenuManager extends BaseManager {
5
- contextMenus = new Collection();
5
+ interactions = new Collection();
6
6
  constructor(client, directory) {
7
7
  super(client, directory);
8
8
  }
9
9
  async loadData() {
10
10
  const contextMenus = await requiredFiles(this.directoryPath);
11
- this.contextMenus = contextMenus;
11
+ this.interactions = contextMenus;
12
12
  }
13
- get(id) {
14
- const contextMenu = this.contextMenus.get(id) ?? undefined;
13
+ getByCustomId(id) {
14
+ const contextMenu = this.interactions.get(id) ?? undefined;
15
15
  return contextMenu;
16
16
  }
17
+ getByRegex(id) {
18
+ return undefined;
19
+ }
17
20
  getAll() {
18
- const contextMenus = this.contextMenus;
21
+ const contextMenus = this.interactions;
19
22
  return contextMenus;
20
23
  }
21
24
  }
@@ -2,11 +2,12 @@ import { Collection } from "discord.js";
2
2
  import { type StelliaClient } from "../client/index.js";
3
3
  import { BaseManager } from "./index.js";
4
4
  import { type EventStructure } from "../structures/index.js";
5
- import { type CustomId } from "../typescript/index.js";
5
+ import { type StructureCustomId, type InteractionCustomId } from "../typescript/index.js";
6
6
  export declare class EventManager extends BaseManager {
7
- events: Collection<CustomId, EventStructure>;
7
+ interactions: Collection<StructureCustomId, EventStructure>;
8
8
  constructor(client: StelliaClient, directoryPath: string);
9
9
  loadData(): Promise<void>;
10
- get<EventStructure>(id: CustomId): EventStructure | undefined;
11
- getAll<EventStructure>(): Collection<CustomId, EventStructure>;
10
+ getByCustomId<EventStructure>(id: InteractionCustomId): EventStructure | undefined;
11
+ getByRegex<EventStructure>(id: InteractionCustomId): EventStructure | undefined;
12
+ getAll<EventStructure>(): Collection<StructureCustomId, EventStructure>;
12
13
  }
@@ -2,14 +2,14 @@ import { Collection } from "discord.js";
2
2
  import { BaseManager } from "./index.js";
3
3
  import { requiredFiles } from "../utils/index.js";
4
4
  export class EventManager extends BaseManager {
5
- events = new Collection();
5
+ interactions = new Collection();
6
6
  constructor(client, directoryPath) {
7
7
  super(client, directoryPath);
8
8
  }
9
9
  async loadData() {
10
10
  const events = await requiredFiles(this.directoryPath);
11
- this.events = events;
12
- for (const event of this.events.values()) {
11
+ this.interactions = events;
12
+ for (const event of this.interactions.values()) {
13
13
  const { name, once } = event.data;
14
14
  if (once) {
15
15
  this.client.once(name, (...args) => event.execute(this.client, ...args));
@@ -19,12 +19,15 @@ export class EventManager extends BaseManager {
19
19
  }
20
20
  }
21
21
  }
22
- get(id) {
23
- const event = this.events.get(id) ?? undefined;
22
+ getByCustomId(id) {
23
+ const event = this.interactions.get(id) ?? undefined;
24
24
  return event;
25
25
  }
26
+ getByRegex(id) {
27
+ return undefined;
28
+ }
26
29
  getAll() {
27
- const events = this.events;
30
+ const events = this.interactions;
28
31
  return events;
29
32
  }
30
33
  }
@@ -2,11 +2,12 @@ import { Collection } from "discord.js";
2
2
  import { type StelliaClient } from "../client/index.js";
3
3
  import { BaseManager } from "./index.js";
4
4
  import { type ModalStructure } from "../structures/index.js";
5
- import { type CustomId } from "../typescript/index.js";
5
+ import { type StructureCustomId, type InteractionCustomId } from "../typescript/index.js";
6
6
  export declare class ModalManager extends BaseManager {
7
- modals: Collection<CustomId, ModalStructure>;
7
+ interactions: Collection<StructureCustomId, ModalStructure>;
8
8
  constructor(client: StelliaClient, directory: string);
9
9
  loadData(): Promise<void>;
10
- get<ModalStructure>(id: CustomId): ModalStructure | undefined;
11
- getAll<ModalStructure>(): Collection<CustomId, ModalStructure>;
10
+ getByCustomId<ModalStructure>(id: InteractionCustomId): ModalStructure | undefined;
11
+ getByRegex<ModalStructure>(id: InteractionCustomId): ModalStructure | undefined;
12
+ getAll<ModalStructure>(): Collection<StructureCustomId, ModalStructure>;
12
13
  }
@@ -2,20 +2,30 @@ import { Collection } from "discord.js";
2
2
  import { BaseManager } from "./index.js";
3
3
  import { requiredFiles } from "../utils/index.js";
4
4
  export class ModalManager extends BaseManager {
5
- modals = new Collection();
5
+ interactions = new Collection();
6
6
  constructor(client, directory) {
7
7
  super(client, directory);
8
8
  }
9
9
  async loadData() {
10
10
  const modals = await requiredFiles(this.directoryPath);
11
- this.modals = modals;
11
+ this.interactions = modals;
12
12
  }
13
- get(id) {
14
- const modal = this.modals.get(id) ?? undefined;
13
+ getByCustomId(id) {
14
+ const modal = this.interactions.get(id) ?? undefined;
15
+ return modal;
16
+ }
17
+ getByRegex(id) {
18
+ let modal;
19
+ for (const [customId, action] of this.interactions.entries()) {
20
+ if (customId instanceof RegExp && customId.test(id)) {
21
+ modal = action;
22
+ break;
23
+ }
24
+ }
15
25
  return modal;
16
26
  }
17
27
  getAll() {
18
- const modals = this.modals;
28
+ const modals = this.interactions;
19
29
  return modals;
20
30
  }
21
31
  }
@@ -2,11 +2,12 @@ import { Collection } from "discord.js";
2
2
  import { type StelliaClient } from "../client/index.js";
3
3
  import { BaseManager } from "./index.js";
4
4
  import { type SelectMenuStructure } from "../structures/index.js";
5
- import { type CustomId } from "../typescript/index.js";
5
+ import { type StructureCustomId, type InteractionCustomId } from "../typescript/index.js";
6
6
  export declare class SelectMenuManager extends BaseManager {
7
- selectMenus: Collection<CustomId, SelectMenuStructure>;
7
+ interactions: Collection<StructureCustomId, SelectMenuStructure>;
8
8
  constructor(client: StelliaClient, directory: string);
9
9
  loadData(): Promise<void>;
10
- get<SelectMenuStructure>(id: CustomId): SelectMenuStructure | undefined;
11
- getAll<SelectMenuStructure>(): Collection<CustomId, SelectMenuStructure>;
10
+ getByCustomId<SelectMenuStructure>(id: InteractionCustomId): SelectMenuStructure | undefined;
11
+ getByRegex<SelectMenuStructure>(id: InteractionCustomId): SelectMenuStructure | undefined;
12
+ getAll<SelectMenuStructure>(): Collection<StructureCustomId, SelectMenuStructure>;
12
13
  }
@@ -2,20 +2,30 @@ import { Collection } from "discord.js";
2
2
  import { BaseManager } from "./index.js";
3
3
  import { requiredFiles } from "../utils/index.js";
4
4
  export class SelectMenuManager extends BaseManager {
5
- selectMenus = new Collection();
5
+ interactions = new Collection();
6
6
  constructor(client, directory) {
7
7
  super(client, directory);
8
8
  }
9
9
  async loadData() {
10
10
  const selectMenus = await requiredFiles(this.directoryPath);
11
- this.selectMenus = selectMenus;
11
+ this.interactions = selectMenus;
12
12
  }
13
- get(id) {
14
- const selectMenu = this.selectMenus.get(id) ?? undefined;
13
+ getByCustomId(id) {
14
+ const selectMenu = this.interactions.get(id) ?? undefined;
15
15
  return selectMenu;
16
16
  }
17
+ getByRegex(id) {
18
+ let button;
19
+ for (const [customId, action] of this.interactions.entries()) {
20
+ if (customId instanceof RegExp && customId.test(id)) {
21
+ button = action;
22
+ break;
23
+ }
24
+ }
25
+ return button;
26
+ }
17
27
  getAll() {
18
- const selectMenus = this.selectMenus;
28
+ const selectMenus = this.interactions;
19
29
  return selectMenus;
20
30
  }
21
31
  }
@@ -1,11 +1,9 @@
1
1
  import { type Awaitable, type ClientEvents } from "discord.js";
2
2
  import { type StelliaClient } from "../client/index.js";
3
- type EventArguments<Event extends keyof ClientEvents> = ClientEvents[Event];
4
3
  export interface EventStructure<Event extends keyof ClientEvents = keyof ClientEvents> {
5
4
  data: {
6
- name: keyof ClientEvents;
5
+ name: Event;
7
6
  once: boolean;
8
7
  };
9
- execute(client: StelliaClient, ...args: EventArguments<Event>): Awaitable<unknown>;
8
+ execute(client: StelliaClient, ...args: ClientEvents[Event]): Awaitable<unknown>;
10
9
  }
11
- export {};
@@ -26,7 +26,7 @@ export interface SelectMenuStructure {
26
26
  }
27
27
  export type AnyInteractionStructure = AutoCompleteStructure | ButtonStructure | CommandStructure | ContextMenuStructure | ModalStructure | SelectMenuStructure;
28
28
  interface DefaultDataStructure {
29
- name: string;
29
+ name: string | RegExp;
30
30
  once: boolean;
31
31
  }
32
32
  export {};
@@ -1,6 +1,7 @@
1
1
  import { type AnySelectMenuInteraction, type AutocompleteInteraction, type ButtonInteraction, type ChatInputCommandInteraction, type ContextMenuCommandInteraction, type ModalSubmitInteraction, type UserContextMenuCommandInteraction } from "discord.js";
2
2
  import { type AutoCompleteManager, type ButtonManager, type CommandManager, type ContextMenuManager, type EventManager, type ModalManager, type SelectMenuManager } from "../managers/index.js";
3
- export type CustomId = string;
3
+ export type StructureCustomId = string | RegExp;
4
+ export type InteractionCustomId = string;
4
5
  export type AnyInteraction = AutocompleteInteraction<"cached"> | ButtonInteraction<"cached"> | ChatInputCommandInteraction<"cached"> | ContextMenuCommandInteraction<"cached"> | ModalSubmitInteraction<"cached"> | AnySelectMenuInteraction<"cached"> | UserContextMenuCommandInteraction<"cached">;
5
6
  export declare enum InteractionType {
6
7
  Autocomplete = "Autocomplete",
@@ -1,4 +1,4 @@
1
1
  import { Collection } from "discord.js";
2
2
  import { type AnyInteractionStructure } from "../structures/index.js";
3
- import { type CustomId } from "../typescript/index.js";
4
- export declare const requiredFiles: <InteractionStructure extends AnyInteractionStructure>(directoryPath: string) => Promise<Collection<CustomId, InteractionStructure>>;
3
+ import { type StructureCustomId } from "../typescript/index.js";
4
+ export declare const requiredFiles: <InteractionStructure extends AnyInteractionStructure>(directoryPath: string) => Promise<Collection<StructureCustomId, InteractionStructure>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stelliajs/framework",
3
- "version": "1.0.6",
3
+ "version": "1.1.0-dev-1",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "scripts": {