@spatulox/discord-module 0.2.1 → 0.3.0
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/CHANGELOG.md +15 -0
- package/README.md +6 -3
- package/dist/index.d.mts +17 -9
- package/dist/index.d.ts +17 -9
- package/dist/index.js +67 -25
- package/dist/index.mjs +66 -25
- package/package.json +2 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
Date format : dd/mm/yyy
|
|
3
|
+
|
|
4
|
+
### 13/04/2026 - 0.3.0
|
|
5
|
+
- InteractionManager : adds support for prefix and suffix identifier matching
|
|
6
|
+
|
|
7
|
+
### 08/04/2026 - 0.2.1
|
|
8
|
+
- Add usage example for InteractionManager
|
|
9
|
+
|
|
10
|
+
### 08/04/2026 - 0.2.0
|
|
11
|
+
- Introduce an InteractionManager to register interaction, same as module system
|
|
12
|
+
|
|
13
|
+
### 18/03/2026 - 0.1.0
|
|
14
|
+
- First official release
|
|
15
|
+
- Add a Module system
|
package/README.md
CHANGED
|
@@ -16,6 +16,8 @@ Turn your Discord bot into independent modules that can be enabled or disabled a
|
|
|
16
16
|
|
|
17
17
|
🔄 Hot reload : Enable/Disable problematic modules without restarting the bot !
|
|
18
18
|
|
|
19
|
+
✅ Automatic Interactions Binding (name <-> function/method) : No more mess between interactions detection, dispatch and function/method call
|
|
20
|
+
|
|
19
21
|
Discordjs : Always up to date and completely compatible
|
|
20
22
|
|
|
21
23
|
## 🎮 Usage (2 minutes)
|
|
@@ -55,13 +57,13 @@ Turn your Discord bot into independent modules that can be enabled or disabled a
|
|
|
55
57
|
```ts
|
|
56
58
|
client.once(Events.ClientReady, () => {
|
|
57
59
|
const manager = ModuleManager.createInstance(client); // ModuleManager is a singleton
|
|
58
|
-
const interactionManager = InteractionManager.createInstance(client); //
|
|
60
|
+
const interactionManager = InteractionManager.createInstance(client); // InteractionManager is a singleton
|
|
59
61
|
manager.register(new PongModule(client)); // You can register a Module or a MultiModule (Menu for Module)
|
|
60
62
|
manager.enableAll(); // By default, a Module is disable
|
|
61
63
|
manager.sendUIToChannel("channelID") // Optionnal, only if you want to dynamically toggle modules
|
|
62
64
|
|
|
63
65
|
// Register commands
|
|
64
|
-
|
|
66
|
+
interactionManager.registerSlash("ping", PongModule.pong_interaction)
|
|
65
67
|
});
|
|
66
68
|
```
|
|
67
69
|
|
|
@@ -69,4 +71,5 @@ client.once(Events.ClientReady, () => {
|
|
|
69
71
|
|---------------------|------------------|---------------|
|
|
70
72
|
| Hidden client.on | ❌ | ✅ |
|
|
71
73
|
| Live module enabled | ❌ (Need restart) | ✅ (One click) |
|
|
72
|
-
| Organised | ❌ | ✅ |
|
|
74
|
+
| Organised | ❌ | ✅ |
|
|
75
|
+
| Automatic interaction binding | ❌ | ✅ |
|
package/dist/index.d.mts
CHANGED
|
@@ -76,7 +76,14 @@ declare enum InteractionType {
|
|
|
76
76
|
SLASH = "SLASH"
|
|
77
77
|
}
|
|
78
78
|
type InteractionHandler = (...args: any[]) => any;
|
|
79
|
+
declare enum InteractionMatchType {
|
|
80
|
+
EXACT = 0,
|
|
81
|
+
START_WITH = 1,
|
|
82
|
+
END_WITH = 2
|
|
83
|
+
}
|
|
79
84
|
declare class InteractionsManager {
|
|
85
|
+
private startWithSet;
|
|
86
|
+
private endWithSet;
|
|
80
87
|
private interactionMap;
|
|
81
88
|
private client;
|
|
82
89
|
private static instance;
|
|
@@ -88,17 +95,18 @@ declare class InteractionsManager {
|
|
|
88
95
|
register(type: InteractionType, interaction: {
|
|
89
96
|
name: string;
|
|
90
97
|
func: InteractionHandler;
|
|
98
|
+
matchType: InteractionMatchType;
|
|
91
99
|
}): boolean;
|
|
92
100
|
private createMap;
|
|
93
101
|
private _register;
|
|
94
|
-
registerAutocomplete(name: string, func: (...args: any[]) => any): boolean;
|
|
95
|
-
registerButton(name: string, func: (...args: any[]) => any): boolean;
|
|
96
|
-
registerMessageContextMenus(name: string, func: (...args: any[]) => any): boolean;
|
|
97
|
-
registerUserContextMenus(name: string, func: (...args: any[]) => any): boolean;
|
|
98
|
-
registerModal(name: string, func: (...args: any[]) => any): boolean;
|
|
99
|
-
registerPrimaryEntryPoint(name: string, func: (...args: any[]) => any): boolean;
|
|
100
|
-
registerSelectMenu(name: string, func: (...args: any[]) => any): boolean;
|
|
101
|
-
registerSlash(name: string, func: (...args: any[]) => any): boolean;
|
|
102
|
+
registerAutocomplete(name: string, func: (...args: any[]) => any, matchType?: InteractionMatchType): boolean;
|
|
103
|
+
registerButton(name: string, func: (...args: any[]) => any, matchType?: InteractionMatchType): boolean;
|
|
104
|
+
registerMessageContextMenus(name: string, func: (...args: any[]) => any, matchType?: InteractionMatchType): boolean;
|
|
105
|
+
registerUserContextMenus(name: string, func: (...args: any[]) => any, matchType?: InteractionMatchType): boolean;
|
|
106
|
+
registerModal(name: string, func: (...args: any[]) => any, matchType?: InteractionMatchType): boolean;
|
|
107
|
+
registerPrimaryEntryPoint(name: string, func: (...args: any[]) => any, matchType?: InteractionMatchType): boolean;
|
|
108
|
+
registerSelectMenu(name: string, func: (...args: any[]) => any, matchType?: InteractionMatchType): boolean;
|
|
109
|
+
registerSlash(name: string, func: (...args: any[]) => any, matchType?: InteractionMatchType): boolean;
|
|
102
110
|
}
|
|
103
111
|
|
|
104
|
-
export { InteractionType, InteractionsManager, Module, type ModuleEventsMap, ModuleManager, MultiModule };
|
|
112
|
+
export { InteractionMatchType, InteractionType, InteractionsManager, Module, type ModuleEventsMap, ModuleManager, MultiModule };
|
package/dist/index.d.ts
CHANGED
|
@@ -76,7 +76,14 @@ declare enum InteractionType {
|
|
|
76
76
|
SLASH = "SLASH"
|
|
77
77
|
}
|
|
78
78
|
type InteractionHandler = (...args: any[]) => any;
|
|
79
|
+
declare enum InteractionMatchType {
|
|
80
|
+
EXACT = 0,
|
|
81
|
+
START_WITH = 1,
|
|
82
|
+
END_WITH = 2
|
|
83
|
+
}
|
|
79
84
|
declare class InteractionsManager {
|
|
85
|
+
private startWithSet;
|
|
86
|
+
private endWithSet;
|
|
80
87
|
private interactionMap;
|
|
81
88
|
private client;
|
|
82
89
|
private static instance;
|
|
@@ -88,17 +95,18 @@ declare class InteractionsManager {
|
|
|
88
95
|
register(type: InteractionType, interaction: {
|
|
89
96
|
name: string;
|
|
90
97
|
func: InteractionHandler;
|
|
98
|
+
matchType: InteractionMatchType;
|
|
91
99
|
}): boolean;
|
|
92
100
|
private createMap;
|
|
93
101
|
private _register;
|
|
94
|
-
registerAutocomplete(name: string, func: (...args: any[]) => any): boolean;
|
|
95
|
-
registerButton(name: string, func: (...args: any[]) => any): boolean;
|
|
96
|
-
registerMessageContextMenus(name: string, func: (...args: any[]) => any): boolean;
|
|
97
|
-
registerUserContextMenus(name: string, func: (...args: any[]) => any): boolean;
|
|
98
|
-
registerModal(name: string, func: (...args: any[]) => any): boolean;
|
|
99
|
-
registerPrimaryEntryPoint(name: string, func: (...args: any[]) => any): boolean;
|
|
100
|
-
registerSelectMenu(name: string, func: (...args: any[]) => any): boolean;
|
|
101
|
-
registerSlash(name: string, func: (...args: any[]) => any): boolean;
|
|
102
|
+
registerAutocomplete(name: string, func: (...args: any[]) => any, matchType?: InteractionMatchType): boolean;
|
|
103
|
+
registerButton(name: string, func: (...args: any[]) => any, matchType?: InteractionMatchType): boolean;
|
|
104
|
+
registerMessageContextMenus(name: string, func: (...args: any[]) => any, matchType?: InteractionMatchType): boolean;
|
|
105
|
+
registerUserContextMenus(name: string, func: (...args: any[]) => any, matchType?: InteractionMatchType): boolean;
|
|
106
|
+
registerModal(name: string, func: (...args: any[]) => any, matchType?: InteractionMatchType): boolean;
|
|
107
|
+
registerPrimaryEntryPoint(name: string, func: (...args: any[]) => any, matchType?: InteractionMatchType): boolean;
|
|
108
|
+
registerSelectMenu(name: string, func: (...args: any[]) => any, matchType?: InteractionMatchType): boolean;
|
|
109
|
+
registerSlash(name: string, func: (...args: any[]) => any, matchType?: InteractionMatchType): boolean;
|
|
102
110
|
}
|
|
103
111
|
|
|
104
|
-
export { InteractionType, InteractionsManager, Module, type ModuleEventsMap, ModuleManager, MultiModule };
|
|
112
|
+
export { InteractionMatchType, InteractionType, InteractionsManager, Module, type ModuleEventsMap, ModuleManager, MultiModule };
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
InteractionMatchType: () => InteractionMatchType,
|
|
23
24
|
InteractionType: () => InteractionType,
|
|
24
25
|
InteractionsManager: () => InteractionsManager,
|
|
25
26
|
Module: () => Module,
|
|
@@ -311,7 +312,15 @@ var InteractionType = /* @__PURE__ */ ((InteractionType2) => {
|
|
|
311
312
|
InteractionType2["SLASH"] = "SLASH";
|
|
312
313
|
return InteractionType2;
|
|
313
314
|
})(InteractionType || {});
|
|
315
|
+
var InteractionMatchType = /* @__PURE__ */ ((InteractionMatchType2) => {
|
|
316
|
+
InteractionMatchType2[InteractionMatchType2["EXACT"] = 0] = "EXACT";
|
|
317
|
+
InteractionMatchType2[InteractionMatchType2["START_WITH"] = 1] = "START_WITH";
|
|
318
|
+
InteractionMatchType2[InteractionMatchType2["END_WITH"] = 2] = "END_WITH";
|
|
319
|
+
return InteractionMatchType2;
|
|
320
|
+
})(InteractionMatchType || {});
|
|
314
321
|
var InteractionsManager = class _InteractionsManager {
|
|
322
|
+
startWithSet = /* @__PURE__ */ new Set();
|
|
323
|
+
endWithSet = /* @__PURE__ */ new Set();
|
|
315
324
|
interactionMap = {
|
|
316
325
|
["AUTOCOMPLETE" /* AUTOCOMPLETE */]: {},
|
|
317
326
|
["BUTTON" /* BUTTON */]: {},
|
|
@@ -336,10 +345,10 @@ var InteractionsManager = class _InteractionsManager {
|
|
|
336
345
|
client.on(import_discord4.Events.InteractionCreate, async (interaction) => {
|
|
337
346
|
const info = this.getInteractionInfo(interaction);
|
|
338
347
|
if (!info) throw new Error("Interaction info not found");
|
|
339
|
-
const { type
|
|
348
|
+
const { type } = info;
|
|
340
349
|
const map = this.interactionMap[type];
|
|
341
350
|
if (map) {
|
|
342
|
-
await this.handle(map,
|
|
351
|
+
await this.handle(map, info, interaction);
|
|
343
352
|
}
|
|
344
353
|
});
|
|
345
354
|
}
|
|
@@ -362,20 +371,46 @@ var InteractionsManager = class _InteractionsManager {
|
|
|
362
371
|
if (interaction.isAutocomplete()) return { type: "AUTOCOMPLETE" /* AUTOCOMPLETE */, identifier: interaction.commandName };
|
|
363
372
|
return void 0;
|
|
364
373
|
}
|
|
365
|
-
async handle(interactionMap,
|
|
366
|
-
|
|
374
|
+
async handle(interactionMap, infos, interaction) {
|
|
375
|
+
let handler = interactionMap[infos.identifier];
|
|
376
|
+
if (handler) {
|
|
377
|
+
await handler(interaction);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
let prefix;
|
|
381
|
+
for (const key of this.startWithSet) {
|
|
382
|
+
if (infos.identifier.startsWith(key)) {
|
|
383
|
+
prefix = key;
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
if (!prefix) {
|
|
388
|
+
for (const key of this.endWithSet) {
|
|
389
|
+
if (infos.identifier.endsWith(key)) {
|
|
390
|
+
prefix = key;
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (prefix) {
|
|
396
|
+
handler = interactionMap[prefix];
|
|
397
|
+
if (handler) {
|
|
398
|
+
await handler(interaction);
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
367
402
|
if (!handler) {
|
|
368
|
-
throw new Error(`No handler registered for "${
|
|
403
|
+
throw new Error(`No handler registered for "${infos.identifier}"`);
|
|
369
404
|
}
|
|
370
|
-
await handler(interaction);
|
|
371
405
|
}
|
|
372
406
|
register(type, interaction) {
|
|
373
|
-
return this._register(type, { key: interaction.name, value: interaction.func });
|
|
407
|
+
return this._register(type, { key: interaction.name, value: interaction.func, matchType: interaction.matchType });
|
|
374
408
|
}
|
|
375
|
-
createMap(name, func) {
|
|
409
|
+
createMap(name, func, matchType) {
|
|
376
410
|
return {
|
|
377
411
|
key: name,
|
|
378
|
-
value: func
|
|
412
|
+
value: func,
|
|
413
|
+
matchType
|
|
379
414
|
};
|
|
380
415
|
}
|
|
381
416
|
_register(type, interaction) {
|
|
@@ -383,35 +418,42 @@ var InteractionsManager = class _InteractionsManager {
|
|
|
383
418
|
throw new Error(`Duplicate entry when registering ${type}`);
|
|
384
419
|
}
|
|
385
420
|
this.interactionMap[type][interaction.key] = interaction.value;
|
|
421
|
+
if (interaction.matchType == 1 /* START_WITH */) {
|
|
422
|
+
this.startWithSet.add(interaction.key);
|
|
423
|
+
}
|
|
424
|
+
if (interaction.matchType == 0 /* EXACT */) {
|
|
425
|
+
this.endWithSet.add(interaction.key);
|
|
426
|
+
}
|
|
386
427
|
return true;
|
|
387
428
|
}
|
|
388
|
-
registerAutocomplete(name, func) {
|
|
389
|
-
return this._register("AUTOCOMPLETE" /* AUTOCOMPLETE */, this.createMap(name, func));
|
|
429
|
+
registerAutocomplete(name, func, matchType = 0 /* EXACT */) {
|
|
430
|
+
return this._register("AUTOCOMPLETE" /* AUTOCOMPLETE */, this.createMap(name, func, matchType));
|
|
390
431
|
}
|
|
391
|
-
registerButton(name, func) {
|
|
392
|
-
return this._register("BUTTON" /* BUTTON */, this.createMap(name, func));
|
|
432
|
+
registerButton(name, func, matchType = 0 /* EXACT */) {
|
|
433
|
+
return this._register("BUTTON" /* BUTTON */, this.createMap(name, func, matchType));
|
|
393
434
|
}
|
|
394
|
-
registerMessageContextMenus(name, func) {
|
|
395
|
-
return this._register("MESSAGE_CONTEXT_MENU" /* MESSAGE_CONTEXT_MENU */, this.createMap(name, func));
|
|
435
|
+
registerMessageContextMenus(name, func, matchType = 0 /* EXACT */) {
|
|
436
|
+
return this._register("MESSAGE_CONTEXT_MENU" /* MESSAGE_CONTEXT_MENU */, this.createMap(name, func, matchType));
|
|
396
437
|
}
|
|
397
|
-
registerUserContextMenus(name, func) {
|
|
398
|
-
return this._register("USER_CONTEXT_MENU" /* USER_CONTEXT_MENU */, this.createMap(name, func));
|
|
438
|
+
registerUserContextMenus(name, func, matchType = 0 /* EXACT */) {
|
|
439
|
+
return this._register("USER_CONTEXT_MENU" /* USER_CONTEXT_MENU */, this.createMap(name, func, matchType));
|
|
399
440
|
}
|
|
400
|
-
registerModal(name, func) {
|
|
401
|
-
return this._register("MODAL" /* MODAL */, this.createMap(name, func));
|
|
441
|
+
registerModal(name, func, matchType = 0 /* EXACT */) {
|
|
442
|
+
return this._register("MODAL" /* MODAL */, this.createMap(name, func, matchType));
|
|
402
443
|
}
|
|
403
|
-
registerPrimaryEntryPoint(name, func) {
|
|
404
|
-
return this._register("PRIMARY_ENTRY_POINT" /* PRIMARY_ENTRY_POINT */, this.createMap(name, func));
|
|
444
|
+
registerPrimaryEntryPoint(name, func, matchType = 0 /* EXACT */) {
|
|
445
|
+
return this._register("PRIMARY_ENTRY_POINT" /* PRIMARY_ENTRY_POINT */, this.createMap(name, func, matchType));
|
|
405
446
|
}
|
|
406
|
-
registerSelectMenu(name, func) {
|
|
407
|
-
return this._register("SELECT_MENU" /* SELECT_MENU */, this.createMap(name, func));
|
|
447
|
+
registerSelectMenu(name, func, matchType = 0 /* EXACT */) {
|
|
448
|
+
return this._register("SELECT_MENU" /* SELECT_MENU */, this.createMap(name, func, matchType));
|
|
408
449
|
}
|
|
409
|
-
registerSlash(name, func) {
|
|
410
|
-
return this._register("SLASH" /* SLASH */, this.createMap(name, func));
|
|
450
|
+
registerSlash(name, func, matchType = 0 /* EXACT */) {
|
|
451
|
+
return this._register("SLASH" /* SLASH */, this.createMap(name, func, matchType));
|
|
411
452
|
}
|
|
412
453
|
};
|
|
413
454
|
// Annotate the CommonJS export names for ESM import in node:
|
|
414
455
|
0 && (module.exports = {
|
|
456
|
+
InteractionMatchType,
|
|
415
457
|
InteractionType,
|
|
416
458
|
InteractionsManager,
|
|
417
459
|
Module,
|
package/dist/index.mjs
CHANGED
|
@@ -300,7 +300,15 @@ var InteractionType = /* @__PURE__ */ ((InteractionType2) => {
|
|
|
300
300
|
InteractionType2["SLASH"] = "SLASH";
|
|
301
301
|
return InteractionType2;
|
|
302
302
|
})(InteractionType || {});
|
|
303
|
+
var InteractionMatchType = /* @__PURE__ */ ((InteractionMatchType2) => {
|
|
304
|
+
InteractionMatchType2[InteractionMatchType2["EXACT"] = 0] = "EXACT";
|
|
305
|
+
InteractionMatchType2[InteractionMatchType2["START_WITH"] = 1] = "START_WITH";
|
|
306
|
+
InteractionMatchType2[InteractionMatchType2["END_WITH"] = 2] = "END_WITH";
|
|
307
|
+
return InteractionMatchType2;
|
|
308
|
+
})(InteractionMatchType || {});
|
|
303
309
|
var InteractionsManager = class _InteractionsManager {
|
|
310
|
+
startWithSet = /* @__PURE__ */ new Set();
|
|
311
|
+
endWithSet = /* @__PURE__ */ new Set();
|
|
304
312
|
interactionMap = {
|
|
305
313
|
["AUTOCOMPLETE" /* AUTOCOMPLETE */]: {},
|
|
306
314
|
["BUTTON" /* BUTTON */]: {},
|
|
@@ -325,10 +333,10 @@ var InteractionsManager = class _InteractionsManager {
|
|
|
325
333
|
client.on(Events2.InteractionCreate, async (interaction) => {
|
|
326
334
|
const info = this.getInteractionInfo(interaction);
|
|
327
335
|
if (!info) throw new Error("Interaction info not found");
|
|
328
|
-
const { type
|
|
336
|
+
const { type } = info;
|
|
329
337
|
const map = this.interactionMap[type];
|
|
330
338
|
if (map) {
|
|
331
|
-
await this.handle(map,
|
|
339
|
+
await this.handle(map, info, interaction);
|
|
332
340
|
}
|
|
333
341
|
});
|
|
334
342
|
}
|
|
@@ -351,20 +359,46 @@ var InteractionsManager = class _InteractionsManager {
|
|
|
351
359
|
if (interaction.isAutocomplete()) return { type: "AUTOCOMPLETE" /* AUTOCOMPLETE */, identifier: interaction.commandName };
|
|
352
360
|
return void 0;
|
|
353
361
|
}
|
|
354
|
-
async handle(interactionMap,
|
|
355
|
-
|
|
362
|
+
async handle(interactionMap, infos, interaction) {
|
|
363
|
+
let handler = interactionMap[infos.identifier];
|
|
364
|
+
if (handler) {
|
|
365
|
+
await handler(interaction);
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
let prefix;
|
|
369
|
+
for (const key of this.startWithSet) {
|
|
370
|
+
if (infos.identifier.startsWith(key)) {
|
|
371
|
+
prefix = key;
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (!prefix) {
|
|
376
|
+
for (const key of this.endWithSet) {
|
|
377
|
+
if (infos.identifier.endsWith(key)) {
|
|
378
|
+
prefix = key;
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
if (prefix) {
|
|
384
|
+
handler = interactionMap[prefix];
|
|
385
|
+
if (handler) {
|
|
386
|
+
await handler(interaction);
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
356
390
|
if (!handler) {
|
|
357
|
-
throw new Error(`No handler registered for "${
|
|
391
|
+
throw new Error(`No handler registered for "${infos.identifier}"`);
|
|
358
392
|
}
|
|
359
|
-
await handler(interaction);
|
|
360
393
|
}
|
|
361
394
|
register(type, interaction) {
|
|
362
|
-
return this._register(type, { key: interaction.name, value: interaction.func });
|
|
395
|
+
return this._register(type, { key: interaction.name, value: interaction.func, matchType: interaction.matchType });
|
|
363
396
|
}
|
|
364
|
-
createMap(name, func) {
|
|
397
|
+
createMap(name, func, matchType) {
|
|
365
398
|
return {
|
|
366
399
|
key: name,
|
|
367
|
-
value: func
|
|
400
|
+
value: func,
|
|
401
|
+
matchType
|
|
368
402
|
};
|
|
369
403
|
}
|
|
370
404
|
_register(type, interaction) {
|
|
@@ -372,34 +406,41 @@ var InteractionsManager = class _InteractionsManager {
|
|
|
372
406
|
throw new Error(`Duplicate entry when registering ${type}`);
|
|
373
407
|
}
|
|
374
408
|
this.interactionMap[type][interaction.key] = interaction.value;
|
|
409
|
+
if (interaction.matchType == 1 /* START_WITH */) {
|
|
410
|
+
this.startWithSet.add(interaction.key);
|
|
411
|
+
}
|
|
412
|
+
if (interaction.matchType == 0 /* EXACT */) {
|
|
413
|
+
this.endWithSet.add(interaction.key);
|
|
414
|
+
}
|
|
375
415
|
return true;
|
|
376
416
|
}
|
|
377
|
-
registerAutocomplete(name, func) {
|
|
378
|
-
return this._register("AUTOCOMPLETE" /* AUTOCOMPLETE */, this.createMap(name, func));
|
|
417
|
+
registerAutocomplete(name, func, matchType = 0 /* EXACT */) {
|
|
418
|
+
return this._register("AUTOCOMPLETE" /* AUTOCOMPLETE */, this.createMap(name, func, matchType));
|
|
379
419
|
}
|
|
380
|
-
registerButton(name, func) {
|
|
381
|
-
return this._register("BUTTON" /* BUTTON */, this.createMap(name, func));
|
|
420
|
+
registerButton(name, func, matchType = 0 /* EXACT */) {
|
|
421
|
+
return this._register("BUTTON" /* BUTTON */, this.createMap(name, func, matchType));
|
|
382
422
|
}
|
|
383
|
-
registerMessageContextMenus(name, func) {
|
|
384
|
-
return this._register("MESSAGE_CONTEXT_MENU" /* MESSAGE_CONTEXT_MENU */, this.createMap(name, func));
|
|
423
|
+
registerMessageContextMenus(name, func, matchType = 0 /* EXACT */) {
|
|
424
|
+
return this._register("MESSAGE_CONTEXT_MENU" /* MESSAGE_CONTEXT_MENU */, this.createMap(name, func, matchType));
|
|
385
425
|
}
|
|
386
|
-
registerUserContextMenus(name, func) {
|
|
387
|
-
return this._register("USER_CONTEXT_MENU" /* USER_CONTEXT_MENU */, this.createMap(name, func));
|
|
426
|
+
registerUserContextMenus(name, func, matchType = 0 /* EXACT */) {
|
|
427
|
+
return this._register("USER_CONTEXT_MENU" /* USER_CONTEXT_MENU */, this.createMap(name, func, matchType));
|
|
388
428
|
}
|
|
389
|
-
registerModal(name, func) {
|
|
390
|
-
return this._register("MODAL" /* MODAL */, this.createMap(name, func));
|
|
429
|
+
registerModal(name, func, matchType = 0 /* EXACT */) {
|
|
430
|
+
return this._register("MODAL" /* MODAL */, this.createMap(name, func, matchType));
|
|
391
431
|
}
|
|
392
|
-
registerPrimaryEntryPoint(name, func) {
|
|
393
|
-
return this._register("PRIMARY_ENTRY_POINT" /* PRIMARY_ENTRY_POINT */, this.createMap(name, func));
|
|
432
|
+
registerPrimaryEntryPoint(name, func, matchType = 0 /* EXACT */) {
|
|
433
|
+
return this._register("PRIMARY_ENTRY_POINT" /* PRIMARY_ENTRY_POINT */, this.createMap(name, func, matchType));
|
|
394
434
|
}
|
|
395
|
-
registerSelectMenu(name, func) {
|
|
396
|
-
return this._register("SELECT_MENU" /* SELECT_MENU */, this.createMap(name, func));
|
|
435
|
+
registerSelectMenu(name, func, matchType = 0 /* EXACT */) {
|
|
436
|
+
return this._register("SELECT_MENU" /* SELECT_MENU */, this.createMap(name, func, matchType));
|
|
397
437
|
}
|
|
398
|
-
registerSlash(name, func) {
|
|
399
|
-
return this._register("SLASH" /* SLASH */, this.createMap(name, func));
|
|
438
|
+
registerSlash(name, func, matchType = 0 /* EXACT */) {
|
|
439
|
+
return this._register("SLASH" /* SLASH */, this.createMap(name, func, matchType));
|
|
400
440
|
}
|
|
401
441
|
};
|
|
402
442
|
export {
|
|
443
|
+
InteractionMatchType,
|
|
403
444
|
InteractionType,
|
|
404
445
|
InteractionsManager,
|
|
405
446
|
Module,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spatulox/discord-module",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Automatic Module Manager for Discordjs",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"keywords": [
|
|
28
28
|
"discordjs",
|
|
29
29
|
"discord",
|
|
30
|
-
"
|
|
30
|
+
"framework",
|
|
31
31
|
"modules"
|
|
32
32
|
],
|
|
33
33
|
"author": "Spatulox",
|