oopscord.js 0.0.29 → 0.1.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/LICENSE +674 -201
- package/README.md +212 -11
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/structures/Constants.d.ts +2 -2
- package/dist/structures/Constants.d.ts.map +1 -1
- package/dist/structures/Constants.js +1 -0
- package/dist/structures/Constants.js.map +1 -0
- package/dist/structures/DiscordApp.d.ts +28 -10
- package/dist/structures/DiscordApp.d.ts.map +1 -1
- package/dist/structures/DiscordApp.js +681 -295
- package/dist/structures/DiscordApp.js.map +1 -0
- package/dist/structures/Plugin.d.ts +68 -0
- package/dist/structures/Plugin.d.ts.map +1 -1
- package/dist/structures/Plugin.js +28 -1
- package/dist/structures/Plugin.js.map +1 -0
- package/dist/structures/PluginManager.d.ts +122 -0
- package/dist/structures/PluginManager.d.ts.map +1 -0
- package/dist/structures/PluginManager.js +371 -0
- package/dist/structures/PluginManager.js.map +1 -0
- package/dist/structures/components/BaseButton.d.ts +2 -5
- package/dist/structures/components/BaseButton.d.ts.map +1 -1
- package/dist/structures/components/BaseButton.js +9 -14
- package/dist/structures/components/BaseButton.js.map +1 -0
- package/dist/structures/components/BaseModal.d.ts +13 -21
- package/dist/structures/components/BaseModal.d.ts.map +1 -1
- package/dist/structures/components/BaseModal.js +86 -132
- package/dist/structures/components/BaseModal.js.map +1 -0
- package/dist/structures/components/BaseSelectMenu.d.ts +2 -5
- package/dist/structures/components/BaseSelectMenu.d.ts.map +1 -1
- package/dist/structures/components/BaseSelectMenu.js +21 -25
- package/dist/structures/components/BaseSelectMenu.js.map +1 -0
- package/dist/structures/components/Listener.d.ts +18 -0
- package/dist/structures/components/Listener.d.ts.map +1 -0
- package/dist/structures/components/Listener.js +22 -0
- package/dist/structures/components/Listener.js.map +1 -0
- package/dist/structures/components/index.d.ts +1 -0
- package/dist/structures/components/index.d.ts.map +1 -1
- package/dist/structures/components/index.js +2 -0
- package/dist/structures/components/index.js.map +1 -0
- package/dist/structures/decorators/CommandDecorator.d.ts +39 -38
- package/dist/structures/decorators/CommandDecorator.d.ts.map +1 -1
- package/dist/structures/decorators/CommandDecorator.js +145 -250
- package/dist/structures/decorators/CommandDecorator.js.map +1 -0
- package/dist/structures/decorators/Constants.d.ts +12 -8
- package/dist/structures/decorators/Constants.d.ts.map +1 -1
- package/dist/structures/decorators/Constants.js +13 -8
- package/dist/structures/decorators/Constants.js.map +1 -0
- package/dist/structures/decorators/DiscordModuleDecorator.d.ts +11 -19
- package/dist/structures/decorators/DiscordModuleDecorator.d.ts.map +1 -1
- package/dist/structures/decorators/DiscordModuleDecorator.js +12 -54
- package/dist/structures/decorators/DiscordModuleDecorator.js.map +1 -0
- package/dist/structures/decorators/EventDecorator.d.ts +45 -0
- package/dist/structures/decorators/EventDecorator.d.ts.map +1 -0
- package/dist/structures/decorators/EventDecorator.js +52 -0
- package/dist/structures/decorators/EventDecorator.js.map +1 -0
- package/dist/structures/decorators/ExecutionDecorator.d.ts +19 -0
- package/dist/structures/decorators/ExecutionDecorator.d.ts.map +1 -0
- package/dist/structures/decorators/ExecutionDecorator.js +23 -0
- package/dist/structures/decorators/ExecutionDecorator.js.map +1 -0
- package/dist/structures/decorators/InjectionMetadata.d.ts +35 -0
- package/dist/structures/decorators/InjectionMetadata.d.ts.map +1 -0
- package/dist/structures/decorators/InjectionMetadata.js +34 -0
- package/dist/structures/decorators/InjectionMetadata.js.map +1 -0
- package/dist/structures/decorators/InteractionHandlerDecorator.d.ts +17 -2
- package/dist/structures/decorators/InteractionHandlerDecorator.d.ts.map +1 -1
- package/dist/structures/decorators/InteractionHandlerDecorator.js +48 -7
- package/dist/structures/decorators/InteractionHandlerDecorator.js.map +1 -0
- package/dist/structures/decorators/MessageComponentDecorator.d.ts +25 -40
- package/dist/structures/decorators/MessageComponentDecorator.d.ts.map +1 -1
- package/dist/structures/decorators/MessageComponentDecorator.js +66 -78
- package/dist/structures/decorators/MessageComponentDecorator.js.map +1 -0
- package/dist/structures/decorators/Metadata.d.ts +16 -0
- package/dist/structures/decorators/Metadata.d.ts.map +1 -0
- package/dist/structures/decorators/Metadata.js +50 -0
- package/dist/structures/decorators/Metadata.js.map +1 -0
- package/dist/structures/decorators/PluginDecorator.d.ts +41 -0
- package/dist/structures/decorators/PluginDecorator.d.ts.map +1 -0
- package/dist/structures/decorators/PluginDecorator.js +36 -0
- package/dist/structures/decorators/PluginDecorator.js.map +1 -0
- package/dist/structures/decorators/UseDecorator.d.ts +44 -0
- package/dist/structures/decorators/UseDecorator.d.ts.map +1 -0
- package/dist/structures/decorators/UseDecorator.js +49 -0
- package/dist/structures/decorators/UseDecorator.js.map +1 -0
- package/dist/structures/decorators/index.d.ts +4 -0
- package/dist/structures/decorators/index.d.ts.map +1 -1
- package/dist/structures/decorators/index.js +5 -0
- package/dist/structures/decorators/index.js.map +1 -0
- package/dist/structures/index.d.ts +3 -1
- package/dist/structures/index.d.ts.map +1 -1
- package/dist/structures/index.js +5 -1
- package/dist/structures/index.js.map +1 -0
- package/dist/utils/Util.d.ts +2 -0
- package/dist/utils/Util.d.ts.map +1 -1
- package/dist/utils/Util.js +23 -8
- package/dist/utils/Util.js.map +1 -0
- package/dist/utils/cache.d.ts +4 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +17 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/customId.d.ts +12 -0
- package/dist/utils/customId.d.ts.map +1 -0
- package/dist/utils/customId.js +49 -0
- package/dist/utils/customId.js.map +1 -0
- package/package.json +35 -9
- package/bun.lock +0 -264
|
@@ -16,65 +16,67 @@ exports.FileUploadFieldInjection = FileUploadFieldInjection;
|
|
|
16
16
|
exports.RadioGroupFieldInjection = RadioGroupFieldInjection;
|
|
17
17
|
exports.CheckboxFieldInjection = CheckboxFieldInjection;
|
|
18
18
|
exports.CheckboxGroupFieldInjection = CheckboxGroupFieldInjection;
|
|
19
|
+
const Metadata_1 = require("./Metadata");
|
|
19
20
|
const discord_js_1 = require("discord.js");
|
|
20
|
-
const
|
|
21
|
-
const
|
|
21
|
+
const Constants_1 = require("./Constants");
|
|
22
|
+
const Constants_2 = require("../Constants");
|
|
23
|
+
const InjectionMetadata_1 = require("./InjectionMetadata");
|
|
22
24
|
function MessageComponentModule(options) {
|
|
23
|
-
return
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
25
|
+
return (0, Metadata_1.classDecorator)(metadata => {
|
|
26
|
+
metadata[Constants_1.MODULE_TYPE_KEY] = Constants_1.ModuleType.MESSAGE_COMPONENT;
|
|
27
|
+
metadata[Constants_1.MESSAGE_COMPONENT_MODULE_COMPONENTS_KEY] = options.components ?? [];
|
|
28
|
+
});
|
|
27
29
|
}
|
|
28
30
|
function Button(options) {
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
31
|
+
return (0, Metadata_1.classDecorator)(metadata => {
|
|
32
|
+
metadata[Constants_1.INTERACTION_TYPE_KEY] = Constants_2.InteractionType.BUTTON;
|
|
33
|
+
metadata[Constants_1.BUTTON_OPTIONS_KEY] = options;
|
|
34
|
+
});
|
|
33
35
|
}
|
|
34
36
|
function StringSelectMenu(options) {
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
37
|
+
return (0, Metadata_1.classDecorator)(metadata => {
|
|
38
|
+
metadata[Constants_1.INTERACTION_TYPE_KEY] = Constants_2.InteractionType.SELECT_MENU;
|
|
39
|
+
metadata[Constants_1.SELECT_MENU_TYPE_KEY] = "string";
|
|
40
|
+
metadata[Constants_1.SELECT_MENU_OPTIONS_KEY] = options;
|
|
41
|
+
});
|
|
40
42
|
}
|
|
41
43
|
function UserSelectMenu(options) {
|
|
42
|
-
return
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
};
|
|
44
|
+
return (0, Metadata_1.classDecorator)(metadata => {
|
|
45
|
+
metadata[Constants_1.INTERACTION_TYPE_KEY] = Constants_2.InteractionType.SELECT_MENU;
|
|
46
|
+
metadata[Constants_1.SELECT_MENU_TYPE_KEY] = "user";
|
|
47
|
+
metadata[Constants_1.SELECT_MENU_OPTIONS_KEY] = options;
|
|
48
|
+
});
|
|
47
49
|
}
|
|
48
50
|
function ChannelSelectMenu(options) {
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
51
|
+
return (0, Metadata_1.classDecorator)(metadata => {
|
|
52
|
+
metadata[Constants_1.INTERACTION_TYPE_KEY] = Constants_2.InteractionType.SELECT_MENU;
|
|
53
|
+
metadata[Constants_1.SELECT_MENU_TYPE_KEY] = "channel";
|
|
54
|
+
metadata[Constants_1.SELECT_MENU_OPTIONS_KEY] = options;
|
|
55
|
+
});
|
|
54
56
|
}
|
|
55
57
|
function RoleSelectMenu(options) {
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
};
|
|
58
|
+
return (0, Metadata_1.classDecorator)(metadata => {
|
|
59
|
+
metadata[Constants_1.INTERACTION_TYPE_KEY] = Constants_2.InteractionType.SELECT_MENU;
|
|
60
|
+
metadata[Constants_1.SELECT_MENU_TYPE_KEY] = "role";
|
|
61
|
+
metadata[Constants_1.SELECT_MENU_OPTIONS_KEY] = options;
|
|
62
|
+
});
|
|
61
63
|
}
|
|
62
64
|
function MentionableSelectMenu(options) {
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
};
|
|
65
|
+
return (0, Metadata_1.classDecorator)(metadata => {
|
|
66
|
+
metadata[Constants_1.INTERACTION_TYPE_KEY] = Constants_2.InteractionType.SELECT_MENU;
|
|
67
|
+
metadata[Constants_1.SELECT_MENU_TYPE_KEY] = "mentionable";
|
|
68
|
+
metadata[Constants_1.SELECT_MENU_OPTIONS_KEY] = options;
|
|
69
|
+
});
|
|
68
70
|
}
|
|
69
71
|
function Modal(options) {
|
|
70
|
-
return
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
};
|
|
72
|
+
return (0, Metadata_1.classDecorator)(metadata => {
|
|
73
|
+
metadata[Constants_1.INTERACTION_TYPE_KEY] = Constants_2.InteractionType.MODAL_SUBMIT;
|
|
74
|
+
metadata[Constants_1.MODAL_OPTIONS_KEY] = options;
|
|
75
|
+
});
|
|
74
76
|
}
|
|
75
77
|
function ModalLabel(options) {
|
|
76
|
-
return
|
|
77
|
-
const components =
|
|
78
|
+
return (0, Metadata_1.classDecorator)(metadata => {
|
|
79
|
+
const components = [...(metadata[Constants_1.MODAL_COMPONENTS_KEY] ?? [])];
|
|
78
80
|
const label = new discord_js_1.LabelBuilder();
|
|
79
81
|
label.setLabel(options.label);
|
|
80
82
|
if (options.description)
|
|
@@ -212,58 +214,44 @@ function ModalLabel(options) {
|
|
|
212
214
|
label.setCheckboxGroupComponent(checkboxGroup);
|
|
213
215
|
break;
|
|
214
216
|
}
|
|
215
|
-
components.push({ customId:
|
|
216
|
-
|
|
217
|
-
};
|
|
217
|
+
components.push({ customId: options.customId, component: label, outerType: "label", innerType: component.type });
|
|
218
|
+
metadata[Constants_1.MODAL_COMPONENTS_KEY] = components;
|
|
219
|
+
});
|
|
218
220
|
}
|
|
219
221
|
function ModalTextDisplay(options) {
|
|
220
|
-
return
|
|
221
|
-
const components =
|
|
222
|
+
return (0, Metadata_1.classDecorator)(metadata => {
|
|
223
|
+
const components = [...(metadata[Constants_1.MODAL_COMPONENTS_KEY] ?? [])];
|
|
222
224
|
const textDisplay = new discord_js_1.TextDisplayBuilder()
|
|
223
225
|
.setContent(options.content);
|
|
224
226
|
components.push({ customId: options.customId, component: textDisplay, outerType: "text_display" });
|
|
225
|
-
|
|
226
|
-
};
|
|
227
|
+
metadata[Constants_1.MODAL_COMPONENTS_KEY] = components;
|
|
228
|
+
});
|
|
227
229
|
}
|
|
230
|
+
function modalFieldInjection(customId, type) {
|
|
231
|
+
return (0, InjectionMetadata_1.injectionDecorator)({ kind: "modal_field", customId, type });
|
|
232
|
+
}
|
|
233
|
+
/** Injects a submitted text input into an instance field. */
|
|
228
234
|
function TextInputFieldInjection(customId) {
|
|
229
|
-
return
|
|
230
|
-
const fields = Reflect.getMetadata(_1.MODAL_TEXT_INPUT_VALUE_INDEX_KEY, target) ?? [];
|
|
231
|
-
fields.push({ index: parameterIndex, customId, type: "text_input" });
|
|
232
|
-
Reflect.defineMetadata(_1.MODAL_TEXT_INPUT_VALUE_INDEX_KEY, fields, target);
|
|
233
|
-
};
|
|
235
|
+
return modalFieldInjection(customId, "text_input");
|
|
234
236
|
}
|
|
237
|
+
/** Injects a submitted select menu's values into an instance field. */
|
|
235
238
|
function SelectMenuFieldInjection(customId) {
|
|
236
|
-
return
|
|
237
|
-
const fields = Reflect.getMetadata(_1.MODAL_SELECT_MENU_VALUE_INDEX_KEY, target) ?? [];
|
|
238
|
-
fields.push({ index: parameterIndex, customId, type: "select_menu" });
|
|
239
|
-
Reflect.defineMetadata(_1.MODAL_SELECT_MENU_VALUE_INDEX_KEY, fields, target);
|
|
240
|
-
};
|
|
239
|
+
return modalFieldInjection(customId, "select_menu");
|
|
241
240
|
}
|
|
241
|
+
/** Injects submitted files into an instance field. */
|
|
242
242
|
function FileUploadFieldInjection(customId) {
|
|
243
|
-
return
|
|
244
|
-
const fields = Reflect.getMetadata(_1.MODAL_FILE_UPLOAD_VALUE_INDEX_KEY, target) ?? [];
|
|
245
|
-
fields.push({ index: parameterIndex, customId, type: "file_upload" });
|
|
246
|
-
Reflect.defineMetadata(_1.MODAL_FILE_UPLOAD_VALUE_INDEX_KEY, fields, target);
|
|
247
|
-
};
|
|
243
|
+
return modalFieldInjection(customId, "file_upload");
|
|
248
244
|
}
|
|
245
|
+
/** Injects a submitted radio group's value into an instance field. */
|
|
249
246
|
function RadioGroupFieldInjection(customId) {
|
|
250
|
-
return
|
|
251
|
-
const fields = Reflect.getMetadata(_1.MODAL_SELECT_MENU_VALUE_INDEX_KEY, target) ?? [];
|
|
252
|
-
fields.push({ index: parameterIndex, customId, type: "radio_group" });
|
|
253
|
-
Reflect.defineMetadata(_1.MODAL_SELECT_MENU_VALUE_INDEX_KEY, fields, target);
|
|
254
|
-
};
|
|
247
|
+
return modalFieldInjection(customId, "radio_group");
|
|
255
248
|
}
|
|
249
|
+
/** Injects a submitted checkbox's value into an instance field. */
|
|
256
250
|
function CheckboxFieldInjection(customId) {
|
|
257
|
-
return
|
|
258
|
-
const fields = Reflect.getMetadata(_1.MODAL_SELECT_MENU_VALUE_INDEX_KEY, target) ?? [];
|
|
259
|
-
fields.push({ index: parameterIndex, customId, type: "checkbox" });
|
|
260
|
-
Reflect.defineMetadata(_1.MODAL_SELECT_MENU_VALUE_INDEX_KEY, fields, target);
|
|
261
|
-
};
|
|
251
|
+
return modalFieldInjection(customId, "checkbox");
|
|
262
252
|
}
|
|
253
|
+
/** Injects a submitted checkbox group's values into an instance field. */
|
|
263
254
|
function CheckboxGroupFieldInjection(customId) {
|
|
264
|
-
return
|
|
265
|
-
const fields = Reflect.getMetadata(_1.MODAL_SELECT_MENU_VALUE_INDEX_KEY, target) ?? [];
|
|
266
|
-
fields.push({ index: parameterIndex, customId, type: "checkbox_group" });
|
|
267
|
-
Reflect.defineMetadata(_1.MODAL_SELECT_MENU_VALUE_INDEX_KEY, fields, target);
|
|
268
|
-
};
|
|
255
|
+
return modalFieldInjection(customId, "checkbox_group");
|
|
269
256
|
}
|
|
257
|
+
//# sourceMappingURL=MessageComponentDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageComponentDecorator.js","sourceRoot":"","sources":["../../../src/structures/decorators/MessageComponentDecorator.ts"],"names":[],"mappings":";;AAwDA,wDAKC;AAED,wBAKC;AAED,4CAMC;AAED,wCAMC;AAED,8CAMC;AAED,wCAMC;AAED,sDAMC;AAED,sBAKC;AAED,gCAsJC;AAED,4CAWC;AAOD,0DAEC;AAGD,4DAEC;AAGD,4DAEC;AAGD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AAsD;AACtD,SAAgB,wBAAwB,CAAC,QAAgB;IACrD,OAAO,mBAAmB,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;AACxD,CAAC;AAED,sEAAsE;AACtE,SAAgB,wBAAwB,CAAC,QAAgB;IACrD,OAAO,mBAAmB,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;AACxD,CAAC;AAED,mEAAmE;AACnE,SAAgB,sBAAsB,CAAC,QAAgB;IACnD,OAAO,mBAAmB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AACrD,CAAC;AAED,0EAA0E;AAC1E,SAAgB,2BAA2B,CAAC,QAAgB;IACxD,OAAO,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type StandardClassDecorator = <T extends abstract new (...args: any[]) => any>(constructor: T, context?: ClassDecoratorContext<T>) => void;
|
|
2
|
+
/** Reads standard decorator metadata, including inherited values. */
|
|
3
|
+
export declare function getMetadata(key: symbol, constructor: Function): any;
|
|
4
|
+
/** Requires the shared metadata object provided by standard decorators. */
|
|
5
|
+
export declare function requireMetadata(context: {
|
|
6
|
+
metadata?: DecoratorMetadataObject;
|
|
7
|
+
}): DecoratorMetadataObject;
|
|
8
|
+
/** Creates a standard class decorator that can also be applied programmatically. */
|
|
9
|
+
export declare function classDecorator(apply: (metadata: DecoratorMetadataObject) => void): StandardClassDecorator;
|
|
10
|
+
/** Restricts routed methods to instance methods accessible by the dispatcher. */
|
|
11
|
+
export declare function assertHandlerMethod(context: {
|
|
12
|
+
kind: string;
|
|
13
|
+
static: boolean;
|
|
14
|
+
private: boolean;
|
|
15
|
+
}): void;
|
|
16
|
+
//# sourceMappingURL=Metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Metadata.d.ts","sourceRoot":"","sources":["../../../src/structures/decorators/Metadata.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,SAAS,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAChF,WAAW,EAAE,CAAC,EACd,OAAO,CAAC,EAAE,qBAAqB,CAAC,CAAC,CAAC,KACjC,IAAI,CAAC;AAEV,qEAAqE;AACrE,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,GAAG,GAAG,CAEnE;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,EAAE,uBAAuB,CAAA;CAAE,GAAG,uBAAuB,CAGxG;AAED,oFAAoF;AACpF,wBAAgB,cAAc,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,uBAAuB,KAAK,IAAI,GAAG,sBAAsB,CAmBzG;AAED,iFAAiF;AACjF,wBAAgB,mBAAmB,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAItG"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMetadata = getMetadata;
|
|
4
|
+
exports.requireMetadata = requireMetadata;
|
|
5
|
+
exports.classDecorator = classDecorator;
|
|
6
|
+
exports.assertHandlerMethod = assertHandlerMethod;
|
|
7
|
+
// Node versions supported by the package may not provide Symbol.metadata yet.
|
|
8
|
+
if (!Symbol.metadata) {
|
|
9
|
+
Object.defineProperty(Symbol, "metadata", { value: Symbol("Symbol.metadata") });
|
|
10
|
+
}
|
|
11
|
+
/** Reads standard decorator metadata, including inherited values. */
|
|
12
|
+
function getMetadata(key, constructor) {
|
|
13
|
+
return constructor[Symbol.metadata]?.[key];
|
|
14
|
+
}
|
|
15
|
+
/** Requires the shared metadata object provided by standard decorators. */
|
|
16
|
+
function requireMetadata(context) {
|
|
17
|
+
if (!context.metadata)
|
|
18
|
+
throw new TypeError("oopscord.js requires standard decorators with Symbol.metadata support.");
|
|
19
|
+
return context.metadata;
|
|
20
|
+
}
|
|
21
|
+
/** Creates a standard class decorator that can also be applied programmatically. */
|
|
22
|
+
function classDecorator(apply) {
|
|
23
|
+
return (constructor, context) => {
|
|
24
|
+
let metadata;
|
|
25
|
+
if (context) {
|
|
26
|
+
if (context.kind !== "class")
|
|
27
|
+
throw new TypeError("Expected a class decorator context.");
|
|
28
|
+
metadata = requireMetadata(context);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const target = constructor;
|
|
32
|
+
if (!Object.hasOwn(target, Symbol.metadata)) {
|
|
33
|
+
Object.defineProperty(target, Symbol.metadata, {
|
|
34
|
+
value: Object.create(target[Symbol.metadata] ?? null),
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
metadata = target[Symbol.metadata];
|
|
40
|
+
}
|
|
41
|
+
apply(metadata);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Restricts routed methods to instance methods accessible by the dispatcher. */
|
|
45
|
+
function assertHandlerMethod(context) {
|
|
46
|
+
if (context.kind !== "method" || context.static || context.private) {
|
|
47
|
+
throw new TypeError("Handler decorators require a public instance method.");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=Metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Metadata.js","sourceRoot":"","sources":["../../../src/structures/decorators/Metadata.ts"],"names":[],"mappings":";;AAWA,kCAEC;AAGD,0CAGC;AAGD,wCAmBC;AAGD,kDAIC;AAhDD,8EAA8E;AAC9E,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IACnB,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,iBAAiB,CA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AAgB,mBAAmB,CAAC,OAA4D;IAC5F,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACjE,MAAM,IAAI,SAAS,CAAC,sDAAsD,CAAC,CAAC;IAChF,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { StandardClassDecorator } from "./Metadata";
|
|
2
|
+
import { Listener } from "../components/Listener";
|
|
3
|
+
import type { SupportSource } from "./UseDecorator";
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for the `PluginModule` decorator.
|
|
6
|
+
*
|
|
7
|
+
* - `imports`: command, message component, and event modules that belong to the plugin.
|
|
8
|
+
* - `commands`, `components`, `listeners`: handlers registered directly, like the options of `DiscordModule`.
|
|
9
|
+
* - `supports`: classes or instances the plugin provides to `@Use`. They are available only while the plugin is enabled,
|
|
10
|
+
* and a plugin that uses one depends on this plugin.
|
|
11
|
+
* - `scope`: `"module"` (default) runs `prefix`, `postfix`, and `onError` only for what the plugin owns;
|
|
12
|
+
* `"global"` runs them for every interaction and error in the application.
|
|
13
|
+
*/
|
|
14
|
+
export interface PluginModuleOptions {
|
|
15
|
+
imports?: (new (...args: any[]) => any)[];
|
|
16
|
+
commands?: (new (...args: any[]) => any)[];
|
|
17
|
+
components?: (new (...args: any[]) => any)[];
|
|
18
|
+
listeners?: typeof Listener[];
|
|
19
|
+
supports?: SupportSource[];
|
|
20
|
+
scope?: "module" | "global";
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Class decorator that lets a {@link Plugin} own commands, components, and listeners, so it works like a module.
|
|
24
|
+
*
|
|
25
|
+
* The plugin is still registered as a plugin, through `DiscordApp.create(AppModule, { plugins: [...] })`, either as
|
|
26
|
+
* an instance or as a class. A class is constructed once with `(client, logger)`. Everything the plugin owns is
|
|
27
|
+
* registered with the application, and `@EventHandler` methods on the plugin class itself are registered too.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* @PluginModule({ commands: [Ban], components: [ConfirmBan] })
|
|
32
|
+
* class Moderation extends Plugin {
|
|
33
|
+
* onEnable({ logger }: PluginContext) { logger.info("Moderation enabled."); }
|
|
34
|
+
* prefix({ interaction }: PluginInteractionContext) { return interaction.inGuild(); }
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* DiscordApp.create(AppModule, { plugins: [Moderation] });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function PluginModule(options?: PluginModuleOptions): StandardClassDecorator;
|
|
41
|
+
//# sourceMappingURL=PluginDecorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginDecorator.d.ts","sourceRoot":"","sources":["../../../src/structures/decorators/PluginDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAGjF,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;;;;;;;;GASG;AACH,MAAM,WAAW,mBAAmB;IAChC,OAAO,CAAC,EAAE,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC;IAC1C,QAAQ,CAAC,EAAE,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC;IAC3C,UAAU,CAAC,EAAE,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC;IAC7C,SAAS,CAAC,EAAE,OAAO,QAAQ,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,sBAAsB,CAStF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PluginModule = PluginModule;
|
|
4
|
+
const Metadata_1 = require("./Metadata");
|
|
5
|
+
const Constants_1 = require("./Constants");
|
|
6
|
+
/**
|
|
7
|
+
* Class decorator that lets a {@link Plugin} own commands, components, and listeners, so it works like a module.
|
|
8
|
+
*
|
|
9
|
+
* The plugin is still registered as a plugin, through `DiscordApp.create(AppModule, { plugins: [...] })`, either as
|
|
10
|
+
* an instance or as a class. A class is constructed once with `(client, logger)`. Everything the plugin owns is
|
|
11
|
+
* registered with the application, and `@EventHandler` methods on the plugin class itself are registered too.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* @PluginModule({ commands: [Ban], components: [ConfirmBan] })
|
|
16
|
+
* class Moderation extends Plugin {
|
|
17
|
+
* onEnable({ logger }: PluginContext) { logger.info("Moderation enabled."); }
|
|
18
|
+
* prefix({ interaction }: PluginInteractionContext) { return interaction.inGuild(); }
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* DiscordApp.create(AppModule, { plugins: [Moderation] });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
function PluginModule(options = {}) {
|
|
25
|
+
const scope = options.scope ?? "module";
|
|
26
|
+
if (scope !== "module" && scope !== "global")
|
|
27
|
+
throw new TypeError("Plugin scope must be \"module\" or \"global\".");
|
|
28
|
+
return (0, Metadata_1.classDecorator)(metadata => {
|
|
29
|
+
for (const module of options.imports ?? []) {
|
|
30
|
+
if (typeof (0, Metadata_1.getMetadata)(Constants_1.MODULE_TYPE_KEY, module) !== "number")
|
|
31
|
+
throw new TypeError(`${module.name} is not a module.`);
|
|
32
|
+
}
|
|
33
|
+
metadata[Constants_1.PLUGIN_MODULE_OPTIONS_KEY] = { ...options, scope };
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=PluginDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginDecorator.js","sourceRoot":"","sources":["../../../src/structures/decorators/PluginDecorator.ts"],"names":[],"mappings":";;AA2CA,oCASC;AApDD,yCAAiF;AACjF,2CAAyE;AAwBzE;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,YAAY,CAAC,UAA+B,EAAE;IAC1D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,QAAQ,CAAC;IACxC,IAAI,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,gDAAgD,CAAC,CAAC;IACpH,OAAO,IAAA,yBAAc,EAAC,QAAQ,CAAC,EAAE;QAC7B,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;YACzC,IAAI,OAAO,IAAA,sBAAW,EAAC,2BAAe,EAAE,MAAM,CAAC,KAAK,QAAQ;gBAAE,MAAM,IAAI,SAAS,CAAC,GAAG,MAAM,CAAC,IAAI,mBAAmB,CAAC,CAAC;QACzH,CAAC;QACD,QAAQ,CAAC,qCAAyB,CAAC,GAAG,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC;IAChE,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** A class to inject, concrete or abstract. */
|
|
2
|
+
export type UseTarget<T = any> = abstract new (...args: any[]) => T;
|
|
3
|
+
/**
|
|
4
|
+
* A support to register with `supports`: a class, created once with `(client, logger)`, or an instance you made,
|
|
5
|
+
* for example one that holds configuration. `@Use` finds it by class, including through a base class.
|
|
6
|
+
*/
|
|
7
|
+
export type SupportSource = UseTarget | object;
|
|
8
|
+
/**
|
|
9
|
+
* Injects a shared instance of a class into an instance field, so classes can use what another class provides.
|
|
10
|
+
* The field type must accept the class type. It works in interaction handlers, listeners, event modules, the root
|
|
11
|
+
* module, plugins, and the classes injected this way.
|
|
12
|
+
*
|
|
13
|
+
* - A registered plugin (a plugin of that class, or a subclass) is injected as it is.
|
|
14
|
+
* - A support registered with `supports`, in `DiscordModule` or provided by a plugin through `PluginModule`, is
|
|
15
|
+
* injected as it is. Its own `@Use` fields are injected too, so supports may use each other.
|
|
16
|
+
* - Any other class needs no registration: it is created once per application with `(client, logger)`, when the
|
|
17
|
+
* application is created, and shared by everyone who uses it.
|
|
18
|
+
* - A `Plugin` subclass that is not registered fails startup, since a second copy without lifecycle is never wanted.
|
|
19
|
+
*
|
|
20
|
+
* While a plugin that a handler uses, or that provides a support it uses, is not enabled, the handler answers
|
|
21
|
+
* "This feature is currently disabled." and a listener's event handlers do not run. On a plugin, `@Use(Other)` also
|
|
22
|
+
* declares a dependency on `Other`, or on the plugin that provides it: that plugin is enabled first and disabled
|
|
23
|
+
* last, and circular uses fail at startup. Plugin fields are set after every plugin is registered and before any
|
|
24
|
+
* hook runs, so they are not available in constructors.
|
|
25
|
+
*
|
|
26
|
+
* Pass the class, or an arrow function returning it when two declarations refer to each other: a plugin that owns
|
|
27
|
+
* a handler through `@PluginModule` is usually declared after it, so the handler writes `@Use(() => Support)`.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* @Command({ name: "ticket", description: "Open a ticket" })
|
|
32
|
+
* class Ticket {
|
|
33
|
+
* @Use(TicketStore) store!: TicketStore;
|
|
34
|
+
* @Use(() => Support) support!: Support;
|
|
35
|
+
*
|
|
36
|
+
* @Run
|
|
37
|
+
* async run() { await this.support.open(await this.store.create()); }
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function Use<T extends object>(target: UseTarget<T> | (() => UseTarget<T>)): <This, Value>(_value: undefined, context: ClassFieldDecoratorContext<This, Value> & (T extends Value ? unknown : never)) => void;
|
|
42
|
+
/** Resolves what `@Use` was given: a class, or an arrow function returning one. @internal */
|
|
43
|
+
export declare function resolveUsed(reference: UseTarget | (() => UseTarget)): UseTarget;
|
|
44
|
+
//# sourceMappingURL=UseDecorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseDecorator.d.ts","sourceRoot":"","sources":["../../../src/structures/decorators/UseDecorator.ts"],"names":[],"mappings":"AAEA,+CAA+C;AAC/C,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,GAAG,IAAI,QAAQ,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAEpE;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,SAAS,CAAC,CAAC,CAAC,CAAC,IACrE,IAAI,EAAE,KAAK,EAAE,QAAQ,SAAS,EAAE,SAAS,0BAA0B,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,SAAS,KAAK,GAAG,OAAO,GAAG,KAAK,CAAC,KAAG,IAAI,CAGxI;AAED,6FAA6F;AAC7F,wBAAgB,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG,CAAC,MAAM,SAAS,CAAC,GAAG,SAAS,CAG/E"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Use = Use;
|
|
4
|
+
exports.resolveUsed = resolveUsed;
|
|
5
|
+
const InjectionMetadata_1 = require("./InjectionMetadata");
|
|
6
|
+
/**
|
|
7
|
+
* Injects a shared instance of a class into an instance field, so classes can use what another class provides.
|
|
8
|
+
* The field type must accept the class type. It works in interaction handlers, listeners, event modules, the root
|
|
9
|
+
* module, plugins, and the classes injected this way.
|
|
10
|
+
*
|
|
11
|
+
* - A registered plugin (a plugin of that class, or a subclass) is injected as it is.
|
|
12
|
+
* - A support registered with `supports`, in `DiscordModule` or provided by a plugin through `PluginModule`, is
|
|
13
|
+
* injected as it is. Its own `@Use` fields are injected too, so supports may use each other.
|
|
14
|
+
* - Any other class needs no registration: it is created once per application with `(client, logger)`, when the
|
|
15
|
+
* application is created, and shared by everyone who uses it.
|
|
16
|
+
* - A `Plugin` subclass that is not registered fails startup, since a second copy without lifecycle is never wanted.
|
|
17
|
+
*
|
|
18
|
+
* While a plugin that a handler uses, or that provides a support it uses, is not enabled, the handler answers
|
|
19
|
+
* "This feature is currently disabled." and a listener's event handlers do not run. On a plugin, `@Use(Other)` also
|
|
20
|
+
* declares a dependency on `Other`, or on the plugin that provides it: that plugin is enabled first and disabled
|
|
21
|
+
* last, and circular uses fail at startup. Plugin fields are set after every plugin is registered and before any
|
|
22
|
+
* hook runs, so they are not available in constructors.
|
|
23
|
+
*
|
|
24
|
+
* Pass the class, or an arrow function returning it when two declarations refer to each other: a plugin that owns
|
|
25
|
+
* a handler through `@PluginModule` is usually declared after it, so the handler writes `@Use(() => Support)`.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* @Command({ name: "ticket", description: "Open a ticket" })
|
|
30
|
+
* class Ticket {
|
|
31
|
+
* @Use(TicketStore) store!: TicketStore;
|
|
32
|
+
* @Use(() => Support) support!: Support;
|
|
33
|
+
*
|
|
34
|
+
* @Run
|
|
35
|
+
* async run() { await this.support.open(await this.store.create()); }
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
function Use(target) {
|
|
40
|
+
return (_value, context) => {
|
|
41
|
+
(0, InjectionMetadata_1.registerInjection)(context, { kind: "use", use: target });
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Resolves what `@Use` was given: a class, or an arrow function returning one. @internal */
|
|
45
|
+
function resolveUsed(reference) {
|
|
46
|
+
// Class prototypes are not writable; the prototype of an ordinary function is, and an arrow function has none.
|
|
47
|
+
return Object.getOwnPropertyDescriptor(reference, "prototype")?.writable === false ? reference : reference();
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=UseDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseDecorator.js","sourceRoot":"","sources":["../../../src/structures/decorators/UseDecorator.ts"],"names":[],"mappings":";;AA4CA,kBAIC;AAGD,kCAGC;AAtDD,2DAAwD;AAWxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,SAAgB,GAAG,CAAmB,MAA2C;IAC7E,OAAO,CAAc,MAAiB,EAAE,OAAsF,EAAQ,EAAE;QACpI,IAAA,qCAAiB,EAAC,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC;AACN,CAAC;AAED,6FAA6F;AAC7F,SAAgB,WAAW,CAAC,SAAwC;IAChE,+GAA+G;IAC/G,OAAO,MAAM,CAAC,wBAAwB,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,SAAsB,CAAC,CAAC,CAAE,SAA6B,EAAE,CAAC;AACnJ,CAAC"}
|
|
@@ -3,4 +3,8 @@ export * from "./Constants";
|
|
|
3
3
|
export * from "./DiscordModuleDecorator";
|
|
4
4
|
export * from "./InteractionHandlerDecorator";
|
|
5
5
|
export * from "./MessageComponentDecorator";
|
|
6
|
+
export * from "./EventDecorator";
|
|
7
|
+
export * from "./ExecutionDecorator";
|
|
8
|
+
export * from "./PluginDecorator";
|
|
9
|
+
export * from "./UseDecorator";
|
|
6
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/structures/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/structures/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
|
|
@@ -19,3 +19,8 @@ __exportStar(require("./Constants"), exports);
|
|
|
19
19
|
__exportStar(require("./DiscordModuleDecorator"), exports);
|
|
20
20
|
__exportStar(require("./InteractionHandlerDecorator"), exports);
|
|
21
21
|
__exportStar(require("./MessageComponentDecorator"), exports);
|
|
22
|
+
__exportStar(require("./EventDecorator"), exports);
|
|
23
|
+
__exportStar(require("./ExecutionDecorator"), exports);
|
|
24
|
+
__exportStar(require("./PluginDecorator"), exports);
|
|
25
|
+
__exportStar(require("./UseDecorator"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/structures/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,8CAA4B;AAC5B,2DAAyC;AACzC,gEAA8C;AAC9C,8DAA4C;AAC5C,mDAAiC;AACjC,uDAAqC;AACrC,oDAAkC;AAClC,iDAA+B"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import "
|
|
1
|
+
import "./decorators/Metadata";
|
|
2
2
|
export * from "./decorators";
|
|
3
3
|
export * from "./components";
|
|
4
4
|
export * from "./Constants";
|
|
5
5
|
export * from "./DiscordApp";
|
|
6
6
|
export * from "./Plugin";
|
|
7
|
+
export { PluginManager } from "./PluginManager";
|
|
8
|
+
export type { PluginInfo, PluginReference, PluginState } from "./PluginManager";
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/structures/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/structures/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAE/B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAE7B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/structures/index.js
CHANGED
|
@@ -14,9 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
17
|
+
exports.PluginManager = void 0;
|
|
18
|
+
require("./decorators/Metadata");
|
|
18
19
|
__exportStar(require("./decorators"), exports);
|
|
19
20
|
__exportStar(require("./components"), exports);
|
|
20
21
|
__exportStar(require("./Constants"), exports);
|
|
21
22
|
__exportStar(require("./DiscordApp"), exports);
|
|
22
23
|
__exportStar(require("./Plugin"), exports);
|
|
24
|
+
var PluginManager_1 = require("./PluginManager");
|
|
25
|
+
Object.defineProperty(exports, "PluginManager", { enumerable: true, get: function () { return PluginManager_1.PluginManager; } });
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/structures/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iCAA+B;AAE/B,+CAA6B;AAC7B,+CAA6B;AAE7B,8CAA4B;AAC5B,+CAA6B;AAC7B,2CAAyB;AACzB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA"}
|
package/dist/utils/Util.d.ts
CHANGED
package/dist/utils/Util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../src/utils/Util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AAEjH,qBAAa,IAAI;IACb,MAAM,CAAC,0BAA0B,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,GAAG,OAAO,IAAI,wBAAwB;IAI7H,MAAM,CAAC,YAAY,CAAC,CAAC,SAAS;QAAE,CAAC,GAAG,EAAE,WAAW,GAAG,GAAG,CAAA;KAAE,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../src/utils/Util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AAEjH,qBAAa,IAAI;IACb,MAAM,CAAC,0BAA0B,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,GAAG,OAAO,IAAI,wBAAwB;IAI7H,MAAM,CAAC,YAAY,CAAC,CAAC,SAAS;QAAE,CAAC,GAAG,EAAE,WAAW,GAAG,GAAG,CAAA;KAAE,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAexF,OAAO,CAAC,MAAM,CAAC,aAAa;IAK5B,OAAO,CAAC,MAAM,CAAC,KAAK;CAKvB"}
|
package/dist/utils/Util.js
CHANGED
|
@@ -7,17 +7,32 @@ class Util {
|
|
|
7
7
|
return options.style != v10_1.ButtonStyle.Link;
|
|
8
8
|
}
|
|
9
9
|
static mergeDefault(def, given) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (
|
|
14
|
-
|
|
10
|
+
const result = { ...def };
|
|
11
|
+
for (const key of new Set([...Object.keys(def), ...Object.keys(given ?? {})])) {
|
|
12
|
+
const value = given?.[key] === undefined ? def[key] : given[key];
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
result[key] = value.map(item => this.clone(item));
|
|
15
15
|
}
|
|
16
|
-
else if (
|
|
17
|
-
|
|
16
|
+
else if (this.isPlainObject(value)) {
|
|
17
|
+
result[key] = this.mergeDefault(this.isPlainObject(def[key]) ? def[key] : {}, value);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
result[key] = value;
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
|
-
return
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
static isPlainObject(value) {
|
|
26
|
+
return value !== null && typeof value === "object" &&
|
|
27
|
+
(Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
28
|
+
}
|
|
29
|
+
static clone(value) {
|
|
30
|
+
if (Array.isArray(value))
|
|
31
|
+
return value.map(item => this.clone(item));
|
|
32
|
+
if (this.isPlainObject(value))
|
|
33
|
+
return this.mergeDefault({}, value);
|
|
34
|
+
return value;
|
|
21
35
|
}
|
|
22
36
|
}
|
|
23
37
|
exports.Util = Util;
|
|
38
|
+
//# sourceMappingURL=Util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Util.js","sourceRoot":"","sources":["../../src/utils/Util.ts"],"names":[],"mappings":";;;AAAA,+CAAoD;AAGpD,MAAa,IAAI;I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