@stelliajs/framework 1.0.6 → 1.1.0-dev-2
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/dist/client/StelliaUtils.js +28 -7
- package/dist/managers/AutoCompleteManager.d.ts +5 -4
- package/dist/managers/AutoCompleteManager.js +8 -5
- package/dist/managers/BaseManager.d.ts +4 -3
- package/dist/managers/ButtonManager.d.ts +5 -4
- package/dist/managers/ButtonManager.js +15 -5
- package/dist/managers/CommandManager.d.ts +5 -4
- package/dist/managers/CommandManager.js +8 -5
- package/dist/managers/ContextMenuManager.d.ts +5 -4
- package/dist/managers/ContextMenuManager.js +8 -5
- package/dist/managers/EventManager.d.ts +5 -4
- package/dist/managers/EventManager.js +9 -6
- package/dist/managers/ModalManager.d.ts +5 -4
- package/dist/managers/ModalManager.js +15 -5
- package/dist/managers/SelectMenuManager.d.ts +5 -4
- package/dist/managers/SelectMenuManager.js +15 -5
- package/dist/structures/Event.d.ts +2 -4
- package/dist/structures/Interaction.d.ts +1 -1
- package/dist/typescript/types.d.ts +2 -1
- package/dist/utils/files.d.ts +2 -2
- package/package.json +1 -1
|
@@ -44,7 +44,10 @@ export class StelliaUtils {
|
|
|
44
44
|
handleAutoCompleteInteraction = async (interaction) => {
|
|
45
45
|
try {
|
|
46
46
|
const interactionAutoComplete = interaction;
|
|
47
|
-
const
|
|
47
|
+
const autoCompleteManager = this.client.managers.autoCompletes;
|
|
48
|
+
if (!autoCompleteManager)
|
|
49
|
+
return;
|
|
50
|
+
const autoComplete = autoCompleteManager.getByCustomId(interactionAutoComplete.commandName);
|
|
48
51
|
if (!autoComplete)
|
|
49
52
|
return;
|
|
50
53
|
await autoComplete.execute(this.client, interactionAutoComplete);
|
|
@@ -56,7 +59,10 @@ export class StelliaUtils {
|
|
|
56
59
|
handleButtonInteraction = async (interaction) => {
|
|
57
60
|
try {
|
|
58
61
|
const buttonInteraction = interaction;
|
|
59
|
-
const
|
|
62
|
+
const buttonManager = this.client.managers.buttons;
|
|
63
|
+
if (!buttonManager)
|
|
64
|
+
return;
|
|
65
|
+
const button = buttonManager.getByCustomId(buttonInteraction.customId) || buttonManager.getByRegex(buttonInteraction.customId);
|
|
60
66
|
if (!button)
|
|
61
67
|
return;
|
|
62
68
|
await button.execute(this.client, buttonInteraction);
|
|
@@ -68,7 +74,10 @@ export class StelliaUtils {
|
|
|
68
74
|
handleCommandInteraction = async (interaction) => {
|
|
69
75
|
try {
|
|
70
76
|
const interactionCommand = interaction;
|
|
71
|
-
const
|
|
77
|
+
const commandManager = this.client.managers.commands;
|
|
78
|
+
if (!commandManager)
|
|
79
|
+
return;
|
|
80
|
+
const command = commandManager.getByCustomId(interactionCommand.commandName);
|
|
72
81
|
if (!command)
|
|
73
82
|
return;
|
|
74
83
|
await command.execute(this.client, interactionCommand);
|
|
@@ -96,7 +105,10 @@ export class StelliaUtils {
|
|
|
96
105
|
handleModalInteraction = async (interaction) => {
|
|
97
106
|
try {
|
|
98
107
|
const interactionModal = interaction;
|
|
99
|
-
const
|
|
108
|
+
const modalManager = this.client.managers.modals;
|
|
109
|
+
if (!modalManager)
|
|
110
|
+
return;
|
|
111
|
+
const modal = modalManager.getByCustomId(interactionModal.customId) || modalManager.getByRegex(interactionModal.customId);
|
|
100
112
|
if (!modal)
|
|
101
113
|
return;
|
|
102
114
|
await modal.execute(this.client, interactionModal);
|
|
@@ -108,7 +120,10 @@ export class StelliaUtils {
|
|
|
108
120
|
handleSelectMenuInteraction = async (interaction) => {
|
|
109
121
|
try {
|
|
110
122
|
const interactionSelectMenu = interaction;
|
|
111
|
-
const
|
|
123
|
+
const selectMenuManager = this.client.managers.selectMenus;
|
|
124
|
+
if (!selectMenuManager)
|
|
125
|
+
return;
|
|
126
|
+
const selectMenu = selectMenuManager.getByCustomId(interactionSelectMenu.customId) || selectMenuManager.getByRegex(interactionSelectMenu.customId);
|
|
112
127
|
if (!selectMenu)
|
|
113
128
|
return;
|
|
114
129
|
await selectMenu.execute(this.client, interactionSelectMenu);
|
|
@@ -119,7 +134,10 @@ export class StelliaUtils {
|
|
|
119
134
|
};
|
|
120
135
|
handleMessageContextMenuInteraction = async (interaction) => {
|
|
121
136
|
try {
|
|
122
|
-
const
|
|
137
|
+
const contextMenuManager = this.client.managers.contextMenus;
|
|
138
|
+
if (!contextMenuManager)
|
|
139
|
+
return;
|
|
140
|
+
const messageContextMenu = contextMenuManager.getByCustomId(interaction.commandName);
|
|
123
141
|
if (!messageContextMenu)
|
|
124
142
|
return;
|
|
125
143
|
await messageContextMenu.execute(this.client, interaction);
|
|
@@ -130,7 +148,10 @@ export class StelliaUtils {
|
|
|
130
148
|
};
|
|
131
149
|
handleUserContextMenuInteraction = async (interaction) => {
|
|
132
150
|
try {
|
|
133
|
-
const
|
|
151
|
+
const contextMenuManager = this.client.managers.contextMenus;
|
|
152
|
+
if (!contextMenuManager)
|
|
153
|
+
return;
|
|
154
|
+
const userContextMenu = contextMenuManager.getByCustomId(interaction.commandName);
|
|
134
155
|
if (!userContextMenu)
|
|
135
156
|
return;
|
|
136
157
|
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
|
|
4
|
+
import { type StructureCustomId, type InteractionCustomId } from "../typescript/index.js";
|
|
5
5
|
export declare class AutoCompleteManager extends BaseManager {
|
|
6
|
-
private
|
|
6
|
+
private interactions;
|
|
7
7
|
constructor(client: StelliaClient, directory: string);
|
|
8
8
|
loadData(): Promise<void>;
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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.
|
|
11
|
+
this.interactions = autoCompletes;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
const autoComplete = this.
|
|
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.
|
|
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
|
|
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
|
|
14
|
-
abstract
|
|
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
|
|
5
|
+
import { type StructureCustomId, type InteractionCustomId } from "../typescript/index.js";
|
|
6
6
|
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
|
-
|
|
11
|
-
|
|
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
|
-
|
|
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.
|
|
11
|
+
this.interactions = buttons;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
const button = this.
|
|
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.
|
|
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
|
|
5
|
+
import { type StructureCustomId, type InteractionCustomId } from "../typescript/index.js";
|
|
6
6
|
export declare class CommandManager extends BaseManager {
|
|
7
|
-
|
|
7
|
+
interactions: Collection<StructureCustomId, CommandStructure>;
|
|
8
8
|
constructor(client: StelliaClient, directory: string);
|
|
9
9
|
loadData(): Promise<void>;
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
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.
|
|
11
|
+
this.interactions = commands;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
const command = this.
|
|
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.
|
|
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
|
|
5
|
+
import { type StructureCustomId, type InteractionCustomId } from "../typescript/index.js";
|
|
6
6
|
export declare class ContextMenuManager extends BaseManager {
|
|
7
|
-
|
|
7
|
+
interactions: Collection<StructureCustomId, ContextMenuStructure>;
|
|
8
8
|
constructor(client: StelliaClient, directory: string);
|
|
9
9
|
loadData(): Promise<void>;
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
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.
|
|
11
|
+
this.interactions = contextMenus;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
const contextMenu = this.
|
|
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.
|
|
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
|
|
5
|
+
import { type StructureCustomId, type InteractionCustomId } from "../typescript/index.js";
|
|
6
6
|
export declare class EventManager extends BaseManager {
|
|
7
|
-
|
|
7
|
+
interactions: Collection<StructureCustomId, EventStructure>;
|
|
8
8
|
constructor(client: StelliaClient, directoryPath: string);
|
|
9
9
|
loadData(): Promise<void>;
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
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.
|
|
12
|
-
for (const event of this.
|
|
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
|
-
|
|
23
|
-
const event = this.
|
|
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.
|
|
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
|
|
5
|
+
import { type StructureCustomId, type InteractionCustomId } from "../typescript/index.js";
|
|
6
6
|
export declare class ModalManager extends BaseManager {
|
|
7
|
-
|
|
7
|
+
interactions: Collection<StructureCustomId, ModalStructure>;
|
|
8
8
|
constructor(client: StelliaClient, directory: string);
|
|
9
9
|
loadData(): Promise<void>;
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
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.
|
|
11
|
+
this.interactions = modals;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
const modal = this.
|
|
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.
|
|
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
|
|
5
|
+
import { type StructureCustomId, type InteractionCustomId } from "../typescript/index.js";
|
|
6
6
|
export declare class SelectMenuManager extends BaseManager {
|
|
7
|
-
|
|
7
|
+
interactions: Collection<StructureCustomId, SelectMenuStructure>;
|
|
8
8
|
constructor(client: StelliaClient, directory: string);
|
|
9
9
|
loadData(): Promise<void>;
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
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.
|
|
11
|
+
this.interactions = selectMenus;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
const selectMenu = this.
|
|
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.
|
|
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:
|
|
5
|
+
name: Event;
|
|
7
6
|
once: boolean;
|
|
8
7
|
};
|
|
9
|
-
execute(client: StelliaClient, ...args:
|
|
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
|
|
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",
|
package/dist/utils/files.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Collection } from "discord.js";
|
|
2
2
|
import { type AnyInteractionStructure } from "../structures/index.js";
|
|
3
|
-
import { type
|
|
4
|
-
export declare const requiredFiles: <InteractionStructure extends AnyInteractionStructure>(directoryPath: string) => Promise<Collection<
|
|
3
|
+
import { type StructureCustomId } from "../typescript/index.js";
|
|
4
|
+
export declare const requiredFiles: <InteractionStructure extends AnyInteractionStructure>(directoryPath: string) => Promise<Collection<StructureCustomId, InteractionStructure>>;
|