oopscord.js 0.0.25 → 0.0.26
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/structures/Constants.d.ts +2 -0
- package/dist/structures/Constants.d.ts.map +1 -1
- package/dist/structures/Constants.js +1 -0
- package/dist/structures/DiscordApp.d.ts +79 -2
- package/dist/structures/DiscordApp.d.ts.map +1 -1
- package/dist/structures/DiscordApp.js +215 -56
- package/dist/structures/components/BaseButton.d.ts +35 -1
- package/dist/structures/components/BaseButton.d.ts.map +1 -1
- package/dist/structures/components/BaseButton.js +70 -24
- package/dist/structures/components/BaseModal.d.ts +75 -6
- package/dist/structures/components/BaseModal.d.ts.map +1 -1
- package/dist/structures/components/BaseModal.js +128 -28
- package/dist/structures/components/BaseModal.test.d.ts +2 -0
- package/dist/structures/components/BaseModal.test.d.ts.map +1 -0
- package/dist/structures/components/BaseModal.test.js +109 -0
- package/dist/structures/components/BaseSelectMenu.d.ts +73 -3
- package/dist/structures/components/BaseSelectMenu.d.ts.map +1 -1
- package/dist/structures/components/BaseSelectMenu.js +117 -47
- package/dist/structures/decorators/Constants.d.ts +2 -0
- package/dist/structures/decorators/Constants.d.ts.map +1 -1
- package/dist/structures/decorators/Constants.js +3 -1
- package/dist/structures/decorators/DiscordModuleDecorator.d.ts +27 -0
- package/dist/structures/decorators/DiscordModuleDecorator.d.ts.map +1 -1
- package/dist/structures/decorators/DiscordModuleDecorator.js +27 -0
- package/dist/structures/decorators/MessageComponentDecorator.d.ts +28 -2
- package/dist/structures/decorators/MessageComponentDecorator.d.ts.map +1 -1
- package/dist/structures/decorators/MessageComponentDecorator.js +19 -3
- package/dist/utils/Util.d.ts +3 -0
- package/dist/utils/Util.d.ts.map +1 -1
- package/dist/utils/Util.js +15 -2
- package/package.json +3 -2
|
@@ -3,61 +3,131 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BaseSelectMenu = void 0;
|
|
4
4
|
const discord_js_1 = require("discord.js");
|
|
5
5
|
const __1 = require("..");
|
|
6
|
+
const Util_1 = require("../../utils/Util");
|
|
7
|
+
/**
|
|
8
|
+
* The base class for select menus created with the {@link StringSelectMenu}, {@link UserSelectMenu}, {@link RoleSelectMenu}, {@link ChannelSelectMenu}, and {@link MentionableSelectMenu} decorators. This class is used to create a select menu from the options defined in the class, and to override the default options with new options when creating the select menu.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* The select menu type is determined by the decorator used to create the select menu class, and can be one of the following:
|
|
12
|
+
* - `string` for {@link StringSelectMenu}
|
|
13
|
+
* - `user` for {@link UserSelectMenu}
|
|
14
|
+
* - `role` for {@link RoleSelectMenu}
|
|
15
|
+
* - `channel` for {@link ChannelSelectMenu}
|
|
16
|
+
* - `mentionable` for {@link MentionableSelectMenu}
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { StringSelectMenuInteraction } from "discord.js";
|
|
20
|
+
* import { StringSelectMenu, BaseSelectMenu, Interaction, Run } from "oopscord.js";
|
|
21
|
+
*
|
|
22
|
+
* @StringSelectMenu({
|
|
23
|
+
* customId: "my_select_menu",
|
|
24
|
+
* options: [
|
|
25
|
+
* { label: "Option 1", value: "option_1" },
|
|
26
|
+
* { label: "Option 2", value: "option_2" },
|
|
27
|
+
* { label: "Option 3", value: "option_3" }
|
|
28
|
+
* ]
|
|
29
|
+
* })
|
|
30
|
+
* class MySelectMenu extends BaseSelectMenu {
|
|
31
|
+
* constructor(@Interaction readonly interaction: StringSelectMenuInteraction) {
|
|
32
|
+
* super();
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* @Run
|
|
36
|
+
* async run() {
|
|
37
|
+
* await this.interaction.reply(`You selected: ${this.interaction.values.join(", ")}`);
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
6
42
|
class BaseSelectMenu {
|
|
7
|
-
static
|
|
43
|
+
static genericSelectMenu;
|
|
44
|
+
static options;
|
|
45
|
+
/** Returns a new {@link SelectMenuBuilder} that was created from the select menu options. */
|
|
8
46
|
static getSelectMenu() {
|
|
9
|
-
if (this.
|
|
10
|
-
return this.
|
|
11
|
-
let selectMenu;
|
|
47
|
+
if (this.genericSelectMenu)
|
|
48
|
+
return this.genericSelectMenu.copy();
|
|
12
49
|
const type = Reflect.getMetadata(__1.SELECT_MENU_TYPE_KEY, this);
|
|
13
50
|
const options = Reflect.getMetadata(__1.SELECT_MENU_OPTIONS_KEY, this);
|
|
14
51
|
if (!options)
|
|
15
52
|
throw new TypeError("Failed to get the select menu.");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
53
|
+
this.genericSelectMenu = new GenericSelectMenu(type);
|
|
54
|
+
this.genericSelectMenu.create(options);
|
|
55
|
+
this.options = options;
|
|
56
|
+
return this.genericSelectMenu.copy();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Returns a new {@link SelectMenuBuilder} with the specified options merged with the default options defined in the class, and the specified values merged with the default values defined in the class if the options include a `options` property (for StringSelectMenu) or `defaultUsers`/`defaultRoles`/`defaultChannels` property (for UserSelectMenu, RoleSelectMenu, ChannelSelectMenu, and MentionableSelectMenu).
|
|
60
|
+
*
|
|
61
|
+
* @param options The options to merge with the default options.
|
|
62
|
+
* @param values The component values to merge with the default components. The `customId` property is used to match the values with the correct components, and the `type` property is used to determine which type of component the value is for.
|
|
63
|
+
*/
|
|
64
|
+
static override(options = {}, ...values) {
|
|
65
|
+
if (!this.genericSelectMenu) {
|
|
66
|
+
this.getSelectMenu();
|
|
67
|
+
}
|
|
68
|
+
const currentOptions = (this.options ?? Reflect.getMetadata(__1.SELECT_MENU_OPTIONS_KEY, this));
|
|
69
|
+
if (!currentOptions)
|
|
70
|
+
throw new TypeError("Failed to get the select menu options.");
|
|
71
|
+
if (values.length > 0 && !this.genericSelectMenu.isStringSelect())
|
|
72
|
+
throw new TypeError("Values can only be overridden for StringSelectMenu.");
|
|
73
|
+
const newOptions = values.length > 0 ? Util_1.Util.mergeDefault(currentOptions, { ...options, options: values }) : Util_1.Util.mergeDefault(currentOptions, options);
|
|
74
|
+
return this.genericSelectMenu.create(newOptions);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.BaseSelectMenu = BaseSelectMenu;
|
|
78
|
+
const SelectMenuBuilders = {
|
|
79
|
+
string: discord_js_1.StringSelectMenuBuilder,
|
|
80
|
+
user: discord_js_1.UserSelectMenuBuilder,
|
|
81
|
+
role: discord_js_1.RoleSelectMenuBuilder,
|
|
82
|
+
channel: discord_js_1.ChannelSelectMenuBuilder,
|
|
83
|
+
mentionable: discord_js_1.MentionableSelectMenuBuilder,
|
|
84
|
+
};
|
|
85
|
+
class GenericSelectMenu {
|
|
86
|
+
kind;
|
|
87
|
+
selectMenu = null;
|
|
88
|
+
constructor(kind) {
|
|
89
|
+
this.kind = kind;
|
|
90
|
+
}
|
|
91
|
+
isStringSelect() { return this.kind === "string"; }
|
|
92
|
+
isUserSelect() { return this.kind === "user"; }
|
|
93
|
+
isRoleSelect() { return this.kind === "role"; }
|
|
94
|
+
isChannelSelect() { return this.kind === "channel"; }
|
|
95
|
+
isMentionableSelect() { return this.kind === "mentionable"; }
|
|
96
|
+
create(options) {
|
|
97
|
+
const Builder = SelectMenuBuilders[this.kind];
|
|
98
|
+
const menu = new Builder();
|
|
99
|
+
if (this.isStringSelect() && "options" in options) {
|
|
100
|
+
menu.addOptions(options.options);
|
|
42
101
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
102
|
+
else if (this.isUserSelect() && "defaultUsers" in options) {
|
|
103
|
+
menu.setDefaultUsers(options.defaultUsers ?? []);
|
|
104
|
+
}
|
|
105
|
+
else if (this.isRoleSelect() && "defaultRoles" in options) {
|
|
106
|
+
menu.setDefaultRoles(options.defaultRoles ?? []);
|
|
107
|
+
}
|
|
108
|
+
else if (this.isChannelSelect() && "channelTypes" in options) {
|
|
109
|
+
menu.setChannelTypes(options.channelTypes ?? [])
|
|
110
|
+
.setDefaultChannels(options.defaultChannels ?? []);
|
|
111
|
+
}
|
|
112
|
+
else if (this.isMentionableSelect() && "defaultUsers" in options && "defaultRoles" in options) {
|
|
113
|
+
menu.addDefaultUsers(options.defaultUsers ?? [])
|
|
114
|
+
.addDefaultRoles(options.defaultRoles ?? []);
|
|
115
|
+
}
|
|
116
|
+
menu.setCustomId(options.customId);
|
|
117
|
+
if (options.placeholder)
|
|
118
|
+
menu.setPlaceholder(options.placeholder);
|
|
46
119
|
if (options.disabled)
|
|
47
|
-
|
|
48
|
-
if (typeof options.minValues
|
|
49
|
-
|
|
50
|
-
if (typeof options.maxValues
|
|
51
|
-
|
|
52
|
-
this.
|
|
53
|
-
return
|
|
120
|
+
menu.setDisabled(options.disabled);
|
|
121
|
+
if (typeof options.minValues === 'number')
|
|
122
|
+
menu.setMinValues(options.minValues);
|
|
123
|
+
if (typeof options.maxValues === 'number')
|
|
124
|
+
menu.setMaxValues(options.maxValues);
|
|
125
|
+
this.selectMenu = menu;
|
|
126
|
+
return Builder.from(menu.toJSON());
|
|
54
127
|
}
|
|
55
|
-
|
|
56
|
-
if (this.
|
|
57
|
-
throw new TypeError("
|
|
58
|
-
|
|
59
|
-
selectMenu.setOptions(values);
|
|
60
|
-
return selectMenu;
|
|
128
|
+
copy() {
|
|
129
|
+
if (!this.selectMenu)
|
|
130
|
+
throw new TypeError("Select menu has not been created yet.");
|
|
131
|
+
return this.selectMenu.constructor.from(this.selectMenu.toJSON());
|
|
61
132
|
}
|
|
62
133
|
}
|
|
63
|
-
exports.BaseSelectMenu = BaseSelectMenu;
|
|
@@ -20,10 +20,12 @@ export declare const MESSAGE_COMPONENT_MODULE_COMPONENTS_KEY: unique symbol;
|
|
|
20
20
|
export declare const BUTTON_OPTIONS_KEY: unique symbol;
|
|
21
21
|
export declare const SELECT_MENU_TYPE_KEY: unique symbol;
|
|
22
22
|
export declare const SELECT_MENU_OPTIONS_KEY: unique symbol;
|
|
23
|
+
export declare const SELECT_MENU_VALUES_INDEX_KEY: unique symbol;
|
|
23
24
|
export declare const MODAL_OPTIONS_KEY: unique symbol;
|
|
24
25
|
export declare const MODAL_COMPONENTS_KEY: unique symbol;
|
|
25
26
|
export declare const MODAL_TEXT_INPUT_VALUE_INDEX_KEY: unique symbol;
|
|
26
27
|
export declare const MODAL_SELECT_MENU_VALUE_INDEX_KEY: unique symbol;
|
|
28
|
+
export declare const MODAL_FILE_UPLOAD_VALUE_INDEX_KEY: unique symbol;
|
|
27
29
|
export declare enum ModuleType {
|
|
28
30
|
COMMAND = 0,
|
|
29
31
|
MESSAGE_COMPONENT = 1
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Constants.d.ts","sourceRoot":"","sources":["../../../src/structures/decorators/Constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,eAAiB,CAAC;AAE9C,eAAO,MAAM,2BAA2B,eAAqB,CAAC;AAE9D,eAAO,MAAM,iCAAiC,eAA8B,CAAC;AAE7E,eAAO,MAAM,0BAA0B,eAAuB,CAAC;AAC/D,eAAO,MAAM,+BAA+B,eAAwC,CAAC;AACrF,eAAO,MAAM,oBAAoB,eAAiB,CAAC;AAEnD,eAAO,MAAM,gBAAgB,eAAiB,CAAC;AAC/C,eAAO,MAAM,uBAAuB,eAAwB,CAAC;AAC7D,eAAO,MAAM,mBAAmB,eAAoB,CAAC;AACrD,eAAO,MAAM,yBAAyB,eAA0B,CAAC;AACjE,eAAO,MAAM,mBAAmB,eAAoB,CAAC;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O,MAAM,kCAAkC,eAA4B,CAAC;AAE5E,eAAO,MAAM,uCAAuC,eAAuB,CAAC;AAE5E,eAAO,MAAM,kBAAkB,eAAoB,CAAC;AAEpD,eAAO,MAAM,oBAAoB,eAAiB,CAAC;AACnD,eAAO,MAAM,uBAAuB,eAAoB,CAAC;AACzD,eAAO,MAAM,4BAA4B,eAAyB,CAAC;AAEnE,eAAO,MAAM,iBAAiB,eAAoB,CAAC;AACnD,eAAO,MAAM,oBAAoB,eAAuB,CAAC;AACzD,eAAO,MAAM,gCAAgC,eAAwB,CAAC;AACtE,eAAO,MAAM,iCAAiC,eAAwB,CAAC;AACvE,eAAO,MAAM,iCAAiC,eAAwB,CAAC;AAEvE,oBAAY,UAAU;IAClB,OAAO,IAAA;IACP,iBAAiB,IAAA;CACpB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ModuleType = exports.MODAL_SELECT_MENU_VALUE_INDEX_KEY = exports.MODAL_TEXT_INPUT_VALUE_INDEX_KEY = exports.MODAL_COMPONENTS_KEY = exports.MODAL_OPTIONS_KEY = exports.SELECT_MENU_OPTIONS_KEY = exports.SELECT_MENU_TYPE_KEY = exports.BUTTON_OPTIONS_KEY = exports.MESSAGE_COMPONENT_MODULE_COMPONENTS_KEY = exports.DISCORD_MODULE_EXTERNAL_EVENTS_KEY = exports.DISCORD_MODULE_INTERNAL_EVENTS_KEY = exports.DICSORD_MODULE_OPTIONS_KEY = exports.OPTIONS_PARAMETER_INDEX_KEY = exports.CONTEXT_MENU_TYPE_KEY = exports.COMMAND_SUBCOMMANDS_KEY = exports.COMMAND_SUBCOMMAND_GROUPS_KEY = exports.COMMAND_OPTIONS_KEY = exports.COMMAND_PRIVATE_GUILD_KEY = exports.COMMAND_PRIVATE_KEY = exports.COMMAND_DESCRIPTION_KEY = exports.COMMAND_NAME_KEY = exports.INTERACTION_TYPE_KEY = exports.INTERACTION_PARAMETER_INDEX_KEY = exports.INTERACTION_RUN_METHOD_KEY = exports.INTERACTION_INTEGRATION_TYPES_KEY = exports.COMMAND_MODULE_COMMANDS_KEY = exports.MODULE_TYPE_KEY = void 0;
|
|
3
|
+
exports.ModuleType = exports.MODAL_FILE_UPLOAD_VALUE_INDEX_KEY = exports.MODAL_SELECT_MENU_VALUE_INDEX_KEY = exports.MODAL_TEXT_INPUT_VALUE_INDEX_KEY = exports.MODAL_COMPONENTS_KEY = exports.MODAL_OPTIONS_KEY = exports.SELECT_MENU_VALUES_INDEX_KEY = exports.SELECT_MENU_OPTIONS_KEY = exports.SELECT_MENU_TYPE_KEY = exports.BUTTON_OPTIONS_KEY = exports.MESSAGE_COMPONENT_MODULE_COMPONENTS_KEY = exports.DISCORD_MODULE_EXTERNAL_EVENTS_KEY = exports.DISCORD_MODULE_INTERNAL_EVENTS_KEY = exports.DICSORD_MODULE_OPTIONS_KEY = exports.OPTIONS_PARAMETER_INDEX_KEY = exports.CONTEXT_MENU_TYPE_KEY = exports.COMMAND_SUBCOMMANDS_KEY = exports.COMMAND_SUBCOMMAND_GROUPS_KEY = exports.COMMAND_OPTIONS_KEY = exports.COMMAND_PRIVATE_GUILD_KEY = exports.COMMAND_PRIVATE_KEY = exports.COMMAND_DESCRIPTION_KEY = exports.COMMAND_NAME_KEY = exports.INTERACTION_TYPE_KEY = exports.INTERACTION_PARAMETER_INDEX_KEY = exports.INTERACTION_RUN_METHOD_KEY = exports.INTERACTION_INTEGRATION_TYPES_KEY = exports.COMMAND_MODULE_COMMANDS_KEY = exports.MODULE_TYPE_KEY = void 0;
|
|
4
4
|
exports.MODULE_TYPE_KEY = Symbol("type");
|
|
5
5
|
exports.COMMAND_MODULE_COMMANDS_KEY = Symbol("commands");
|
|
6
6
|
exports.INTERACTION_INTEGRATION_TYPES_KEY = Symbol("integration_types");
|
|
@@ -23,10 +23,12 @@ exports.MESSAGE_COMPONENT_MODULE_COMPONENTS_KEY = Symbol("components");
|
|
|
23
23
|
exports.BUTTON_OPTIONS_KEY = Symbol("options");
|
|
24
24
|
exports.SELECT_MENU_TYPE_KEY = Symbol("type");
|
|
25
25
|
exports.SELECT_MENU_OPTIONS_KEY = Symbol("options");
|
|
26
|
+
exports.SELECT_MENU_VALUES_INDEX_KEY = Symbol("values_index");
|
|
26
27
|
exports.MODAL_OPTIONS_KEY = Symbol("options");
|
|
27
28
|
exports.MODAL_COMPONENTS_KEY = Symbol("components");
|
|
28
29
|
exports.MODAL_TEXT_INPUT_VALUE_INDEX_KEY = Symbol("field_index");
|
|
29
30
|
exports.MODAL_SELECT_MENU_VALUE_INDEX_KEY = Symbol("field_index");
|
|
31
|
+
exports.MODAL_FILE_UPLOAD_VALUE_INDEX_KEY = Symbol("field_index");
|
|
30
32
|
var ModuleType;
|
|
31
33
|
(function (ModuleType) {
|
|
32
34
|
ModuleType[ModuleType["COMMAND"] = 0] = "COMMAND";
|
|
@@ -8,11 +8,38 @@ export interface ModuleOptions extends ClientOptions {
|
|
|
8
8
|
};
|
|
9
9
|
disableCache?: boolean;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Default configuration options for Discord modules.
|
|
13
|
+
*/
|
|
11
14
|
export declare const defaultModuleOptions: ModuleOptions;
|
|
12
15
|
export interface DiscordModuleEvents {
|
|
13
16
|
eventName: keyof ClientEvents;
|
|
14
17
|
methodName: string;
|
|
15
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Decorator that marks a class as a Discord module.
|
|
21
|
+
*
|
|
22
|
+
* @param option1 - The configuration options for the module
|
|
23
|
+
* @returns A decorator function that applies module metadata to the target class
|
|
24
|
+
*
|
|
25
|
+
* @throws {TypeError} If any of the imported modules are not valid Discord modules
|
|
26
|
+
*/
|
|
16
27
|
export declare function DiscordModule(option1: ModuleOptions): <TFunction extends Function>(constructor: TFunction) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Decorator that registers a method as an event handler for a Discord client event.
|
|
30
|
+
*
|
|
31
|
+
* @param eventName - The name of the Discord client event to listen for
|
|
32
|
+
* @returns A method decorator that registers the decorated method as an event handler
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* class MyModule {
|
|
37
|
+
* @EventHandler('messageCreate')
|
|
38
|
+
* onMessageCreate(message: Message) {
|
|
39
|
+
* // Handle message creation
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
17
44
|
export declare function EventHandler(eventName: keyof ClientEvents): MethodDecorator;
|
|
18
45
|
//# sourceMappingURL=DiscordModuleDecorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DiscordModuleDecorator.d.ts","sourceRoot":"","sources":["../../../src/structures/decorators/DiscordModuleDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGzD,MAAM,WAAW,aAAc,SAAQ,aAAa;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC;IACzC,IAAI,CAAC,EAAE;QACH,MAAM,EAAE,OAAO,CAAC;QAChB,KAAK,EAAE,IAAI,GAAG,MAAM,CAAA;KACvB,CAAC;IACF,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,eAAO,MAAM,oBAAoB,EAAE,aASlC,CAAA;AAED,MAAM,WAAW,mBAAmB;IAChC,SAAS,EAAE,MAAM,YAAY,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;CACtB;AAQD,wBAAgB,aAAa,CAAC,OAAO,EAAE,aAAa,IAChC,SAAS,SAAS,QAAQ,EAAE,aAAa,SAAS,UASrE;
|
|
1
|
+
{"version":3,"file":"DiscordModuleDecorator.d.ts","sourceRoot":"","sources":["../../../src/structures/decorators/DiscordModuleDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGzD,MAAM,WAAW,aAAc,SAAQ,aAAa;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,EAAE,CAAC;IACzC,IAAI,CAAC,EAAE;QACH,MAAM,EAAE,OAAO,CAAC;QAChB,KAAK,EAAE,IAAI,GAAG,MAAM,CAAA;KACvB,CAAC;IACF,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,aASlC,CAAA;AAED,MAAM,WAAW,mBAAmB;IAChC,SAAS,EAAE,MAAM,YAAY,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;CACtB;AAQD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,aAAa,IAChC,SAAS,SAAS,QAAQ,EAAE,aAAa,SAAS,UASrE;AAGD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,YAAY,GAAG,eAAe,CAQ3E"}
|
|
@@ -4,6 +4,9 @@ exports.defaultModuleOptions = void 0;
|
|
|
4
4
|
exports.DiscordModule = DiscordModule;
|
|
5
5
|
exports.EventHandler = EventHandler;
|
|
6
6
|
const Constants_1 = require("./Constants");
|
|
7
|
+
/**
|
|
8
|
+
* Default configuration options for Discord modules.
|
|
9
|
+
*/
|
|
7
10
|
exports.defaultModuleOptions = {
|
|
8
11
|
token: "",
|
|
9
12
|
imports: [],
|
|
@@ -19,6 +22,14 @@ exports.defaultModuleOptions = {
|
|
|
19
22
|
// methodName: string;
|
|
20
23
|
// eventEmitter: EventEmitter;
|
|
21
24
|
// }
|
|
25
|
+
/**
|
|
26
|
+
* Decorator that marks a class as a Discord module.
|
|
27
|
+
*
|
|
28
|
+
* @param option1 - The configuration options for the module
|
|
29
|
+
* @returns A decorator function that applies module metadata to the target class
|
|
30
|
+
*
|
|
31
|
+
* @throws {TypeError} If any of the imported modules are not valid Discord modules
|
|
32
|
+
*/
|
|
22
33
|
function DiscordModule(option1) {
|
|
23
34
|
return function (constructor) {
|
|
24
35
|
const options = mergeDefault(exports.defaultModuleOptions, option1);
|
|
@@ -29,6 +40,22 @@ function DiscordModule(option1) {
|
|
|
29
40
|
Reflect.defineMetadata(Constants_1.DICSORD_MODULE_OPTIONS_KEY, options, constructor);
|
|
30
41
|
};
|
|
31
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Decorator that registers a method as an event handler for a Discord client event.
|
|
45
|
+
*
|
|
46
|
+
* @param eventName - The name of the Discord client event to listen for
|
|
47
|
+
* @returns A method decorator that registers the decorated method as an event handler
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* class MyModule {
|
|
52
|
+
* @EventHandler('messageCreate')
|
|
53
|
+
* onMessageCreate(message: Message) {
|
|
54
|
+
* // Handle message creation
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
32
59
|
function EventHandler(eventName) {
|
|
33
60
|
return function (target, propertyKey, propertyDescriptor) {
|
|
34
61
|
const events = Reflect.getMetadata(Constants_1.DISCORD_MODULE_INTERNAL_EVENTS_KEY, target.constructor) ?? [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentEmojiResolvable, LabelBuilder, TextDisplayBuilder } from "discord.js";
|
|
2
2
|
import { ButtonStyle, ChannelType, TextInputStyle } from "discord-api-types/v10";
|
|
3
3
|
type DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;
|
|
4
4
|
export type ButtonOptions = InteractionButtonOptions | LinkButtonOptions | PremiumButtonOptions;
|
|
@@ -53,6 +53,18 @@ export type MentionableSelectMenuOptions = BaseSelectMenuOptions & {
|
|
|
53
53
|
defaultUsers?: string[];
|
|
54
54
|
defaultRoles?: string[];
|
|
55
55
|
};
|
|
56
|
+
export type ModalLabelComponentData = {
|
|
57
|
+
customId: string;
|
|
58
|
+
component: LabelBuilder;
|
|
59
|
+
outerType: "label";
|
|
60
|
+
innerType: "string_select" | "user_select" | "channel_select" | "role_select" | "mentionable_select" | "text_input" | "file_upload";
|
|
61
|
+
};
|
|
62
|
+
export type ModalTextDisplayComponentData = {
|
|
63
|
+
customId: string;
|
|
64
|
+
component: TextDisplayBuilder;
|
|
65
|
+
outerType: "text_display";
|
|
66
|
+
};
|
|
67
|
+
export type ModalComponentData = ModalLabelComponentData | ModalTextDisplayComponentData;
|
|
56
68
|
export type ModalOptions = {
|
|
57
69
|
customId: string;
|
|
58
70
|
title: string;
|
|
@@ -90,14 +102,16 @@ export type ModalFileUploadOptions = {
|
|
|
90
102
|
required?: boolean;
|
|
91
103
|
};
|
|
92
104
|
export type ModalTextDisplayOptions = {
|
|
105
|
+
customId: string;
|
|
93
106
|
content: string;
|
|
94
107
|
};
|
|
95
108
|
export type ModalLabelOptions = {
|
|
109
|
+
customId: string;
|
|
96
110
|
label: string;
|
|
97
111
|
description?: string;
|
|
98
112
|
component: ModalLabelComponent;
|
|
99
113
|
};
|
|
100
|
-
export type ModalComponentBuilder =
|
|
114
|
+
export type ModalComponentBuilder = LabelBuilder | TextDisplayBuilder;
|
|
101
115
|
type ModalComponentBase = ModalTextInput | ModalFileUploadOptions | ModalStringSelect | ModalUserSelect | ModalChannelSelect | ModalRoleSelect | ModalMentionableSelect;
|
|
102
116
|
export type ModalLabelComponent = DistributiveOmit<ModalComponentBase & {
|
|
103
117
|
required?: boolean;
|
|
@@ -107,6 +121,16 @@ export type FieldIndex = {
|
|
|
107
121
|
index: number;
|
|
108
122
|
customId: string;
|
|
109
123
|
};
|
|
124
|
+
export type TextInputFieldIndex = FieldIndex & {
|
|
125
|
+
type: "text_input";
|
|
126
|
+
};
|
|
127
|
+
export type SelectMenuFieldIndex = FieldIndex & {
|
|
128
|
+
type: "select_menu";
|
|
129
|
+
};
|
|
130
|
+
export type FileUploadFieldIndex = FieldIndex & {
|
|
131
|
+
type: "file_upload";
|
|
132
|
+
};
|
|
133
|
+
export type ModalFieldIndex = TextInputFieldIndex | SelectMenuFieldIndex | FileUploadFieldIndex;
|
|
110
134
|
export declare function MessageComponentModule(options: MessageComponentModuleOptions): <T extends Function>(constructor: T) => void;
|
|
111
135
|
export declare function Button(options: InteractionButtonOptions | LinkButtonOptions): <T extends Function>(constructor: T) => void;
|
|
112
136
|
export declare function StringSelectMenu(options: StringSelectMenuOptions): <T extends Function>(constructor: T) => void;
|
|
@@ -118,5 +142,7 @@ export declare function Modal(options: ModalOptions): <T extends Function>(const
|
|
|
118
142
|
export declare function ModalLabel(options: ModalLabelOptions): <T extends Function>(constructor: T) => void;
|
|
119
143
|
export declare function ModalTextDisplay(options: ModalTextDisplayOptions): <T extends Function>(constructor: T) => void;
|
|
120
144
|
export declare function TextInputFieldInjection(customId: string): (target: Object, _propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
|
145
|
+
export declare function SelectMenuFieldInjection(customId: string): (target: Object, _propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
|
146
|
+
export declare function FileUploadFieldInjection(customId: string): (target: Object, _propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
|
121
147
|
export {};
|
|
122
148
|
//# sourceMappingURL=MessageComponentDecorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageComponentDecorator.d.ts","sourceRoot":"","sources":["../../../src/structures/decorators/MessageComponentDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"MessageComponentDecorator.d.ts","sourceRoot":"","sources":["../../../src/structures/decorators/MessageComponentDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,wBAAwB,EAAqB,YAAY,EAAgF,kBAAkB,EAA2C,MAAM,YAAY,CAAC;AAC5P,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,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ieldInjection = TextInputFieldInjection;
|
|
14
|
+
exports.SelectMenuFieldInjection = SelectMenuFieldInjection;
|
|
15
|
+
exports.FileUploadFieldInjection = FileUploadFieldInjection;
|
|
14
16
|
const discord_js_1 = require("discord.js");
|
|
15
17
|
const _1 = require(".");
|
|
16
18
|
const Constants_1 = require("../Constants");
|
|
@@ -179,7 +181,7 @@ function ModalLabel(options) {
|
|
|
179
181
|
fileUpload.setRequired(component.required);
|
|
180
182
|
label.setFileUploadComponent(fileUpload);
|
|
181
183
|
}
|
|
182
|
-
components.push(label);
|
|
184
|
+
components.push({ customId: component.customId, component: label, outerType: "label", innerType: component.type });
|
|
183
185
|
Reflect.defineMetadata(_1.MODAL_COMPONENTS_KEY, components, constructor);
|
|
184
186
|
};
|
|
185
187
|
}
|
|
@@ -188,14 +190,28 @@ function ModalTextDisplay(options) {
|
|
|
188
190
|
const components = Reflect.getMetadata(_1.MODAL_COMPONENTS_KEY, constructor) ?? [];
|
|
189
191
|
const textDisplay = new discord_js_1.TextDisplayBuilder()
|
|
190
192
|
.setContent(options.content);
|
|
191
|
-
components.push(textDisplay);
|
|
193
|
+
components.push({ customId: options.customId, component: textDisplay, outerType: "text_display" });
|
|
192
194
|
Reflect.defineMetadata(_1.MODAL_COMPONENTS_KEY, components, constructor);
|
|
193
195
|
};
|
|
194
196
|
}
|
|
195
197
|
function TextInputFieldInjection(customId) {
|
|
196
198
|
return function (target, _propertyKey, parameterIndex) {
|
|
197
199
|
const fields = Reflect.getMetadata(_1.MODAL_TEXT_INPUT_VALUE_INDEX_KEY, target) ?? [];
|
|
198
|
-
fields.push({ index: parameterIndex, customId });
|
|
200
|
+
fields.push({ index: parameterIndex, customId, type: "text_input" });
|
|
199
201
|
Reflect.defineMetadata(_1.MODAL_TEXT_INPUT_VALUE_INDEX_KEY, fields, target);
|
|
200
202
|
};
|
|
201
203
|
}
|
|
204
|
+
function SelectMenuFieldInjection(customId) {
|
|
205
|
+
return function (target, _propertyKey, parameterIndex) {
|
|
206
|
+
const fields = Reflect.getMetadata(_1.MODAL_SELECT_MENU_VALUE_INDEX_KEY, target) ?? [];
|
|
207
|
+
fields.push({ index: parameterIndex, customId, type: "select_menu" });
|
|
208
|
+
Reflect.defineMetadata(_1.MODAL_SELECT_MENU_VALUE_INDEX_KEY, fields, target);
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function FileUploadFieldInjection(customId) {
|
|
212
|
+
return function (target, _propertyKey, parameterIndex) {
|
|
213
|
+
const fields = Reflect.getMetadata(_1.MODAL_FILE_UPLOAD_VALUE_INDEX_KEY, target) ?? [];
|
|
214
|
+
fields.push({ index: parameterIndex, customId, type: "file_upload" });
|
|
215
|
+
Reflect.defineMetadata(_1.MODAL_FILE_UPLOAD_VALUE_INDEX_KEY, fields, target);
|
|
216
|
+
};
|
|
217
|
+
}
|
package/dist/utils/Util.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { InteractionButtonOptions, LinkButtonOptions } from "../structures/decorators/MessageComponentDecorator";
|
|
2
2
|
export declare class Util {
|
|
3
3
|
static isInteractionButtonOptions(options: InteractionButtonOptions | LinkButtonOptions): options is InteractionButtonOptions;
|
|
4
|
+
static mergeDefault<T extends {
|
|
5
|
+
[key: PropertyKey]: any;
|
|
6
|
+
}>(def: T, given: Partial<T>): T;
|
|
4
7
|
}
|
|
5
8
|
//# sourceMappingURL=Util.d.ts.map
|
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;
|
|
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;CAa3F"}
|
package/dist/utils/Util.js
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Util = void 0;
|
|
4
|
-
const
|
|
4
|
+
const v10_1 = require("discord-api-types/v10");
|
|
5
5
|
class Util {
|
|
6
6
|
static isInteractionButtonOptions(options) {
|
|
7
|
-
return options.style !=
|
|
7
|
+
return options.style != v10_1.ButtonStyle.Link;
|
|
8
|
+
}
|
|
9
|
+
static mergeDefault(def, given) {
|
|
10
|
+
if (!given)
|
|
11
|
+
return def;
|
|
12
|
+
for (const key in def) {
|
|
13
|
+
if (!Object.hasOwn(given, key) || given[key] === undefined) {
|
|
14
|
+
given[key] = def[key];
|
|
15
|
+
}
|
|
16
|
+
else if (given[key] === Object(given[key])) {
|
|
17
|
+
given[key] = this.mergeDefault(def[key], given[key]);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return given;
|
|
8
21
|
}
|
|
9
22
|
}
|
|
10
23
|
exports.Util = Util;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oopscord.js",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26",
|
|
4
4
|
"description": "An easy way to make discord apps in typescript.",
|
|
5
5
|
"main": "dist",
|
|
6
6
|
"scripts": {
|
|
@@ -29,9 +29,10 @@
|
|
|
29
29
|
"reflect-metadata": "^0.1.14"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@types/node": "^20.
|
|
32
|
+
"@types/node": "^20.19.35",
|
|
33
33
|
"discord.js": "^14.25.1",
|
|
34
34
|
"typescript": "^5.8.3",
|
|
35
|
+
"vitest": "^4.0.18",
|
|
35
36
|
"yarn": "^1.22.21"
|
|
36
37
|
}
|
|
37
38
|
}
|