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
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.BaseModal = void 0;
|
|
7
|
+
const Metadata_1 = require("../decorators/Metadata");
|
|
7
8
|
const discord_js_1 = require("discord.js");
|
|
8
9
|
const __1 = require("..");
|
|
9
10
|
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
@@ -13,8 +14,8 @@ const Util_1 = require("../../utils/Util");
|
|
|
13
14
|
*
|
|
14
15
|
* @example
|
|
15
16
|
* ```ts
|
|
16
|
-
* import { ModalSubmitInteraction } from "discord.js";
|
|
17
|
-
* import { Modal, BaseModal, Interaction, Run } from "oopscord.js";
|
|
17
|
+
* import { ModalSubmitInteraction, TextInputStyle } from "discord.js";
|
|
18
|
+
* import { Modal, ModalLabel, BaseModal, Interaction, Run, TextInputFieldInjection } from "oopscord.js";
|
|
18
19
|
*
|
|
19
20
|
* @Modal({
|
|
20
21
|
* customId: "my_modal",
|
|
@@ -26,9 +27,11 @@ const Util_1 = require("../../utils/Util");
|
|
|
26
27
|
* component: { type: "text_input", customId: "my_text_input", style: TextInputStyle.Short, placeholder: "Enter something...", required: true }
|
|
27
28
|
* })
|
|
28
29
|
* class MyModal extends BaseModal {
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
30
|
+
* @Interaction
|
|
31
|
+
* interaction!: ModalSubmitInteraction;
|
|
32
|
+
*
|
|
33
|
+
* @TextInputFieldInjection("my_text_input")
|
|
34
|
+
* textInputValue!: string;
|
|
32
35
|
*
|
|
33
36
|
* @Run
|
|
34
37
|
* async run() {
|
|
@@ -38,146 +41,97 @@ const Util_1 = require("../../utils/Util");
|
|
|
38
41
|
* ```
|
|
39
42
|
*/
|
|
40
43
|
class BaseModal {
|
|
41
|
-
|
|
42
|
-
static options;
|
|
43
|
-
static components = [];
|
|
44
|
-
/** Returns a new {@link ModalBuilder} that was created from the modal options and components. */
|
|
44
|
+
/** Creates an independent builder from the decorated template. */
|
|
45
45
|
static getModal() {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
throw new TypeError("Failed to get the modal.");
|
|
52
|
-
// Reverse the components because they are added to the modal in reverse order due to the way the decorators work.
|
|
53
|
-
const reversedComponents = [...components].reverse();
|
|
54
|
-
this.options = options;
|
|
55
|
-
this.components = [...reversedComponents];
|
|
56
|
-
this.modal = create(options, reversedComponents.map(c => c.component));
|
|
57
|
-
return discord_js_1.ModalBuilder.from(this.modal.toJSON());
|
|
46
|
+
const options = (0, Metadata_1.getMetadata)(__1.MODAL_OPTIONS_KEY, this);
|
|
47
|
+
const components = [...((0, Metadata_1.getMetadata)(__1.MODAL_COMPONENTS_KEY, this) ?? [])].reverse();
|
|
48
|
+
if (!options)
|
|
49
|
+
throw new TypeError("Failed to get the modal options.");
|
|
50
|
+
return discord_js_1.ModalBuilder.from(create(options, components.map(c => c.component)).toJSON());
|
|
58
51
|
}
|
|
59
|
-
/**
|
|
60
|
-
* Returns a new {@link ModalBuilder} with the specified options and component values merged with the default options and components defined in the class.
|
|
61
|
-
*
|
|
62
|
-
* @param options The options to merge with the default options.
|
|
63
|
-
* @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.
|
|
64
|
-
*/
|
|
52
|
+
/** Overrides a copy of the template; label IDs and inner field IDs are distinct. */
|
|
65
53
|
static override(options = {}, ...values) {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
if (!currentOptions)
|
|
54
|
+
const defaults = (0, Metadata_1.getMetadata)(__1.MODAL_OPTIONS_KEY, this);
|
|
55
|
+
if (!defaults)
|
|
69
56
|
throw new TypeError("Failed to get the modal options.");
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (matchingCheckboxGroupValue) {
|
|
113
|
-
const updatedComponent = new discord_js_1.CheckboxGroupBuilder(component.data.component.toJSON());
|
|
114
|
-
if (typeof matchingCheckboxGroupValue.minValues == "number")
|
|
115
|
-
updatedComponent.setMinValues(matchingCheckboxGroupValue.minValues);
|
|
116
|
-
if (typeof matchingCheckboxGroupValue.maxValues == "number")
|
|
117
|
-
updatedComponent.setMaxValues(matchingCheckboxGroupValue.maxValues);
|
|
118
|
-
if ("required" in matchingCheckboxGroupValue)
|
|
119
|
-
updatedComponent.setRequired(matchingCheckboxGroupValue.required);
|
|
120
|
-
updatedComponent.setOptions(matchingCheckboxGroupValue.options);
|
|
121
|
-
component.setCheckboxGroupComponent(updatedComponent);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else if (component.data.component instanceof discord_js_1.CheckboxBuilder) {
|
|
125
|
-
const matchingCheckboxValue = values.find(v => v.customId === component.data.component.data.custom_id && v.type === 'checkbox');
|
|
126
|
-
if (matchingCheckboxValue) {
|
|
127
|
-
const updatedComponent = new discord_js_1.CheckboxBuilder(component.data.component.toJSON());
|
|
128
|
-
if ("default" in matchingCheckboxValue)
|
|
129
|
-
updatedComponent.setDefault(matchingCheckboxValue.default);
|
|
130
|
-
component.setCheckboxComponent(updatedComponent);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return { customId, component: updatedComponent };
|
|
57
|
+
const components = [...((0, Metadata_1.getMetadata)(__1.MODAL_COMPONENTS_KEY, this) ?? [])].reverse();
|
|
58
|
+
const builders = components.map(({ customId, component }) => {
|
|
59
|
+
if (component instanceof discord_js_1.TextDisplayBuilder) {
|
|
60
|
+
const copy = new discord_js_1.TextDisplayBuilder(component.toJSON());
|
|
61
|
+
const value = values.find(v => v.type === "text_display" && v.customId === customId);
|
|
62
|
+
if (value?.type === "text_display")
|
|
63
|
+
copy.setContent(value.content);
|
|
64
|
+
return copy;
|
|
65
|
+
}
|
|
66
|
+
const copy = new discord_js_1.LabelBuilder(component.toJSON());
|
|
67
|
+
const label = values.find(v => v.type === "label" && v.customId === customId);
|
|
68
|
+
if (label?.type === "label") {
|
|
69
|
+
if (label.label !== undefined)
|
|
70
|
+
copy.setLabel(label.label);
|
|
71
|
+
if (label.description !== undefined)
|
|
72
|
+
copy.setDescription(label.description);
|
|
73
|
+
}
|
|
74
|
+
const inner = copy.data.component;
|
|
75
|
+
if (!inner)
|
|
76
|
+
return copy;
|
|
77
|
+
const value = values.find(v => v.type !== "label" && v.customId === inner.data.custom_id);
|
|
78
|
+
if (!value)
|
|
79
|
+
return copy;
|
|
80
|
+
if (inner.data.type === discord_js_1.ComponentType.TextInput && value.type === "text_input") {
|
|
81
|
+
inner.setValue(value.value);
|
|
82
|
+
}
|
|
83
|
+
else if (inner.data.type === discord_js_1.ComponentType.StringSelect && value.type === "string_select") {
|
|
84
|
+
inner.setOptions(value.options);
|
|
85
|
+
}
|
|
86
|
+
else if (inner.data.type === discord_js_1.ComponentType.RadioGroup && value.type === "radio_group") {
|
|
87
|
+
inner.setOptions(value.options);
|
|
88
|
+
if (value.required !== undefined)
|
|
89
|
+
inner.setRequired(value.required);
|
|
90
|
+
}
|
|
91
|
+
else if (inner.data.type === discord_js_1.ComponentType.CheckboxGroup && value.type === "checkbox_group") {
|
|
92
|
+
inner.setOptions(value.options);
|
|
93
|
+
if (value.minValues !== undefined)
|
|
94
|
+
inner.setMinValues(value.minValues);
|
|
95
|
+
if (value.maxValues !== undefined)
|
|
96
|
+
inner.setMaxValues(value.maxValues);
|
|
97
|
+
if (value.required !== undefined)
|
|
98
|
+
inner.setRequired(value.required);
|
|
134
99
|
}
|
|
135
|
-
else if (
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (matchingTextDisplayValue) {
|
|
139
|
-
updatedComponent.setContent(matchingTextDisplayValue.content);
|
|
140
|
-
}
|
|
141
|
-
return { customId, component: updatedComponent };
|
|
100
|
+
else if (inner.data.type === discord_js_1.ComponentType.Checkbox && value.type === "checkbox") {
|
|
101
|
+
if (value.default !== undefined)
|
|
102
|
+
inner.setDefault(value.default);
|
|
142
103
|
}
|
|
143
|
-
return
|
|
104
|
+
return copy;
|
|
144
105
|
});
|
|
145
|
-
|
|
146
|
-
return modal;
|
|
106
|
+
return create(Util_1.Util.mergeDefault(defaults, options), builders);
|
|
147
107
|
}
|
|
148
|
-
/**
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
itr.showModal(this.getModal().setCustomId(id));
|
|
161
|
-
let listener = async (itr) => {
|
|
162
|
-
if (!itr.isModalSubmit() || itr.customId != id)
|
|
163
|
-
return;
|
|
164
|
-
await itr.deferUpdate();
|
|
165
|
-
r(itr.fields);
|
|
166
|
-
itr.client.off("interactionCreate", listener);
|
|
167
|
-
};
|
|
168
|
-
itr.client.on("interactionCreate", listener);
|
|
169
|
-
setTimeout(() => {
|
|
170
|
-
itr.client.off("interactionCreate", listener);
|
|
171
|
-
j("Timed out");
|
|
172
|
-
}, 180 * 1000);
|
|
108
|
+
/** Shows a modal and collects input from the invoking user. Errors reject immediately. */
|
|
109
|
+
static async getInput(itr, options = {}) {
|
|
110
|
+
if (itr.replied || itr.deferred)
|
|
111
|
+
throw new Error("Interaction already replied.");
|
|
112
|
+
const time = options.time ?? 180_000;
|
|
113
|
+
if (!Number.isFinite(time) || time <= 0)
|
|
114
|
+
throw new RangeError("Modal timeout must be positive.");
|
|
115
|
+
const id = node_crypto_1.default.randomUUID();
|
|
116
|
+
await itr.showModal(this.getModal().setCustomId(id));
|
|
117
|
+
const submission = await itr.awaitModalSubmit({
|
|
118
|
+
filter: candidate => candidate.customId === id && candidate.user.id === itr.user.id,
|
|
119
|
+
time
|
|
173
120
|
});
|
|
121
|
+
if (submission.isFromMessage()) {
|
|
122
|
+
await submission.deferUpdate();
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
await submission.deferReply({ flags: discord_js_1.MessageFlags.Ephemeral });
|
|
126
|
+
await submission.deleteReply();
|
|
127
|
+
}
|
|
128
|
+
return submission.fields;
|
|
174
129
|
}
|
|
175
130
|
}
|
|
176
131
|
exports.BaseModal = BaseModal;
|
|
177
132
|
function create(options, components) {
|
|
178
|
-
const modal = new discord_js_1.ModalBuilder()
|
|
179
|
-
.setTitle(options.title)
|
|
180
|
-
.setCustomId(options.customId);
|
|
133
|
+
const modal = new discord_js_1.ModalBuilder().setTitle(options.title).setCustomId(options.customId);
|
|
181
134
|
modal.components.push(...components);
|
|
182
135
|
return modal;
|
|
183
136
|
}
|
|
137
|
+
//# sourceMappingURL=BaseModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseModal.js","sourceRoot":"","sources":["../../../src/structures/components/BaseModal.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAqD;AACrD,2CAA+Q;AAC/Q,0BAAsH;AACtH,8DAAiC;AACjC,2CAAwC;AAWxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAa,SAAS;IAClB,kEAAkE;IAClE,MAAM,CAAC,QAAQ;QACX,MAAM,OAAO,GAAG,IAAA,sBAAW,EAAC,qBAAiB,EAAE,IAAI,CAA6B,CAAC;QACjF,MAAM,UAAU,GAAG,CAAC,GAAG,CAAC,IAAA,sBAAW,EAAC,wBAAoB,EAAE,IAAI,CAAyB,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QAC1G,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,SAAS,CAAC,kCAAkC,CAAC,CAAC;QACtE,OAAO,yBAAY,CAA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MenuOptions, RoleSelectMenuO
|
|
|
24
24
|
* ]
|
|
25
25
|
* })
|
|
26
26
|
* class MySelectMenu extends BaseSelectMenu {
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* }
|
|
27
|
+
* @Interaction
|
|
28
|
+
* interaction!: StringSelectMenuInteraction;
|
|
30
29
|
*
|
|
31
30
|
* @Run
|
|
32
31
|
* async run() {
|
|
@@ -36,8 +35,6 @@ import { ChannelSelectMenuOptions, MentionableSelectMenuOptions, RoleSelectMenuO
|
|
|
36
35
|
* ```
|
|
37
36
|
*/
|
|
38
37
|
export declare class BaseSelectMenu {
|
|
39
|
-
private static genericSelectMenu;
|
|
40
|
-
private static options;
|
|
41
38
|
/** Returns a new {@link SelectMenuBuilder} that was created from the select menu options. */
|
|
42
39
|
static getSelectMenu(): StringSelectMenuBuilder | UserSelectMenuBuilder | ChannelSelectMenuBuilder | RoleSelectMenuBuilder | MentionableSelectMenuBuilder;
|
|
43
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseSelectMenu.d.ts","sourceRoot":"","sources":["../../../src/structures/components/BaseSelectMenu.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BaseSelectMenu.d.ts","sourceRoot":"","sources":["../../../src/structures/components/BaseSelectMenu.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC3J,OAAO,EAAyB,wBAAwB,EAAE,4BAA4B,EAAE,qBAAqB,EAAiD,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,IAAI,CAAC;AAGzN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAAa,cAAc;IACvB,6FAA6F;IAC7F,MAAM,CAAC,aAAa;IASpB;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,cAAc,EAAE,OAAO,GAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAM,EAAE,GAAG,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC;CAa3L;AAED,UAAU,aAAa;IACnB,MAAM,EAAE;QAAE,OAAO,EAAE,uBAAuB,CAAC;QAAC,OAAO,EAAE,uBAAuB,CAAA;KAAE,CAAC;IAC/E,IAAI,EAAE;QAAE,OAAO,EAAE,qBAAqB,CAAC;QAAC,OAAO,EAAE,qBAAqB,CAAA;KAAE,CAAC;IACzE,IAAI,EAAE;QAAE,OAAO,EAAE,qBAAqB,CAAC;QAAC,OAAO,EAAE,qBAAqB,CAAA;KAAE,CAAC;IACzE,OAAO,EAAE;QAAE,OAAO,EAAE,wBAAwB,CAAC;QAAC,OAAO,EAAE,wBAAwB,CAAA;KAAE,CAAC;IAClF,WAAW,EAAE;QAAE,OAAO,EAAE,4BAA4B,CAAC;QAAC,OAAO,EAAE,4BAA4B,CAAA;KAAE,CAAC;CACjG;AAED,KAAK,cAAc,GAAG,MAAM,aAAa,CAAC;AAU1C,KAAK,eAAe,CAAC,CAAC,SAAS,cAAc,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAC7E,KAAK,UAAU,CAAC,CAAC,SAAS,cAAc,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseSelectMenu = void 0;
|
|
4
|
+
const Metadata_1 = require("../decorators/Metadata");
|
|
4
5
|
const discord_js_1 = require("discord.js");
|
|
5
6
|
const __1 = require("..");
|
|
6
7
|
const Util_1 = require("../../utils/Util");
|
|
@@ -28,9 +29,8 @@ const Util_1 = require("../../utils/Util");
|
|
|
28
29
|
* ]
|
|
29
30
|
* })
|
|
30
31
|
* class MySelectMenu extends BaseSelectMenu {
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* }
|
|
32
|
+
* @Interaction
|
|
33
|
+
* interaction!: StringSelectMenuInteraction;
|
|
34
34
|
*
|
|
35
35
|
* @Run
|
|
36
36
|
* async run() {
|
|
@@ -40,20 +40,13 @@ const Util_1 = require("../../utils/Util");
|
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
42
|
class BaseSelectMenu {
|
|
43
|
-
static genericSelectMenu;
|
|
44
|
-
static options;
|
|
45
43
|
/** Returns a new {@link SelectMenuBuilder} that was created from the select menu options. */
|
|
46
44
|
static getSelectMenu() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const type = Reflect.getMetadata(__1.SELECT_MENU_TYPE_KEY, this);
|
|
50
|
-
const options = Reflect.getMetadata(__1.SELECT_MENU_OPTIONS_KEY, this);
|
|
45
|
+
const type = (0, Metadata_1.getMetadata)(__1.SELECT_MENU_TYPE_KEY, this);
|
|
46
|
+
const options = (0, Metadata_1.getMetadata)(__1.SELECT_MENU_OPTIONS_KEY, this);
|
|
51
47
|
if (!options)
|
|
52
48
|
throw new TypeError("Failed to get the select menu.");
|
|
53
|
-
|
|
54
|
-
this.genericSelectMenu.create(options);
|
|
55
|
-
this.options = options;
|
|
56
|
-
return this.genericSelectMenu.copy();
|
|
49
|
+
return new GenericSelectMenu(type).create(options);
|
|
57
50
|
}
|
|
58
51
|
/**
|
|
59
52
|
* 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).
|
|
@@ -62,16 +55,15 @@ class BaseSelectMenu {
|
|
|
62
55
|
* @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
56
|
*/
|
|
64
57
|
static override(options = {}, ...values) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const currentOptions = (this.options ?? Reflect.getMetadata(__1.SELECT_MENU_OPTIONS_KEY, this));
|
|
58
|
+
const type = (0, Metadata_1.getMetadata)(__1.SELECT_MENU_TYPE_KEY, this);
|
|
59
|
+
const currentOptions = (0, Metadata_1.getMetadata)(__1.SELECT_MENU_OPTIONS_KEY, this);
|
|
60
|
+
const selectMenu = new GenericSelectMenu(type);
|
|
69
61
|
if (!currentOptions)
|
|
70
62
|
throw new TypeError("Failed to get the select menu options.");
|
|
71
|
-
if (values.length > 0 && !
|
|
63
|
+
if (values.length > 0 && !selectMenu.isStringSelect())
|
|
72
64
|
throw new TypeError("Values can only be overridden for StringSelectMenu.");
|
|
73
65
|
const newOptions = values.length > 0 ? Util_1.Util.mergeDefault(currentOptions, { ...options, options: values }) : Util_1.Util.mergeDefault(currentOptions, options);
|
|
74
|
-
return
|
|
66
|
+
return selectMenu.create(newOptions);
|
|
75
67
|
}
|
|
76
68
|
}
|
|
77
69
|
exports.BaseSelectMenu = BaseSelectMenu;
|
|
@@ -105,13 +97,16 @@ class GenericSelectMenu {
|
|
|
105
97
|
else if (this.isRoleSelect() && "defaultRoles" in options) {
|
|
106
98
|
menu.setDefaultRoles(options.defaultRoles ?? []);
|
|
107
99
|
}
|
|
108
|
-
else if (this.isChannelSelect()
|
|
109
|
-
|
|
110
|
-
|
|
100
|
+
else if (this.isChannelSelect()) {
|
|
101
|
+
const channelOptions = options;
|
|
102
|
+
if (channelOptions.channelTypes)
|
|
103
|
+
menu.setChannelTypes(channelOptions.channelTypes);
|
|
104
|
+
menu.setDefaultChannels(channelOptions.defaultChannels ?? []);
|
|
111
105
|
}
|
|
112
|
-
else if (this.isMentionableSelect()
|
|
113
|
-
|
|
114
|
-
|
|
106
|
+
else if (this.isMentionableSelect()) {
|
|
107
|
+
const mentionableOptions = options;
|
|
108
|
+
menu.addDefaultUsers(mentionableOptions.defaultUsers ?? [])
|
|
109
|
+
.addDefaultRoles(mentionableOptions.defaultRoles ?? []);
|
|
115
110
|
}
|
|
116
111
|
menu.setCustomId(options.customId);
|
|
117
112
|
if (options.placeholder)
|
|
@@ -131,3 +126,4 @@ class GenericSelectMenu {
|
|
|
131
126
|
return this.selectMenu.constructor.from(this.selectMenu.toJSON());
|
|
132
127
|
}
|
|
133
128
|
}
|
|
129
|
+
//# sourceMappingURL=BaseSelectMenu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseSelectMenu.js","sourceRoot":"","sources":["../../../src/structures/components/BaseSelectMenu.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACrD,2CAA2J;AAC3J,0BAAyN;AACzN,2CAAwC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAa,cAAc;IACvB,6FAA6F;IAC7F,MAAM,CAAC,aAAa;QAChB,MAAM,IAAI,GAAG,IAAA,sBAAW,EAAC,wBAAoB,EAAE,IAAI,CAAmB,CAAC;QACvE,MAAM,OAAO,GAAG,IAAA,sBAAW,EAAC,2BAAuB,EAAE,IAAI,CAA0B,CAAC;QAEpF,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,SAAS,CAAC,gCAAgC,CAAC,CAAC;QAEpE,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAA2B,UAAuC,EAAE,EAAE,GAAG,MAAgF;QACpK,MAAM,IAAI,GAAG,IAAA,sBAAW,EAAC,wBAAoB,EAAE,IAAI,CAAM,CAAC;QAC1D,MAAM,cAAc,GAAG,IAAA,sBAAW,EAAC,2BAAuB,EAAE,IAAI,CAAuB,CAAC;QAC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AE,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAClE,IAAI,OAAO,CAAC,QAAQ;YAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACzD,IAAI,OAAO,OAAO,CAAC,SAAS,KAAK,QAAQ;YAAE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAChF,IAAI,OAAO,OAAO,CAAC,SAAS,KAAK,QAAQ;YAAE,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAEhF,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QAEvB,OAAQ,OAAe,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,IAAI;QACA,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,MAAM,IAAI,SAAS,CAAC,uCAAuC,CAAC,CAAC;QAEnF,OAAQ,IAAI,CAAC,UAAU,CAAC,WAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAkB,CAAC;IAChG,CAAC;CACJ"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marker class for event listeners. This class is used to identify event listener classes in the event module system.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { Listener } from "oopscord.js";
|
|
7
|
+
*
|
|
8
|
+
* class MyListener extends Listener {
|
|
9
|
+
* @EventHandler("messageCreate")
|
|
10
|
+
* onMessageCreate(message: Message) {
|
|
11
|
+
* message.reply("Hello, World!");
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare class Listener {
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=Listener.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Listener.d.ts","sourceRoot":"","sources":["../../../src/structures/components/Listener.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,qBAAa,QAAQ;CAAG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Listener = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Marker class for event listeners. This class is used to identify event listener classes in the event module system.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { Listener } from "oopscord.js";
|
|
10
|
+
*
|
|
11
|
+
* class MyListener extends Listener {
|
|
12
|
+
* @EventHandler("messageCreate")
|
|
13
|
+
* onMessageCreate(message: Message) {
|
|
14
|
+
* message.reply("Hello, World!");
|
|
15
|
+
* }
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
class Listener {
|
|
20
|
+
}
|
|
21
|
+
exports.Listener = Listener;
|
|
22
|
+
//# sourceMappingURL=Listener.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Listener.js","sourceRoot":"","sources":["../../../src/structures/components/Listener.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAa,QAAQ;CAAG;AAAxB,4BAAwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/structures/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/structures/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
|
@@ -17,3 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./BaseButton"), exports);
|
|
18
18
|
__exportStar(require("./BaseSelectMenu"), exports);
|
|
19
19
|
__exportStar(require("./BaseModal"), exports);
|
|
20
|
+
__exportStar(require("./Listener"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/structures/components/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,mDAAiC;AACjC,8CAA4B;AAC5B,6CAA2B"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StandardClassDecorator } from "./Metadata";
|
|
2
|
+
import { ApplicationCommandOptionAllowedChannelTypes, ContextMenuCommandType } from "discord.js";
|
|
2
3
|
import { APIApplicationCommandOptionChoice, ApplicationIntegrationType } from "discord-api-types/v10";
|
|
4
|
+
import { InjectionDecorator } from "./InjectionMetadata";
|
|
3
5
|
export type CommandModuleOptions = {
|
|
4
|
-
commands
|
|
6
|
+
commands?: (new (...args: any[]) => any)[];
|
|
5
7
|
};
|
|
6
8
|
export type CommandOptions = {
|
|
7
9
|
name: string;
|
|
@@ -11,8 +13,9 @@ export type ContextMenuOptions = {
|
|
|
11
13
|
name: string;
|
|
12
14
|
type: ContextMenuCommandType;
|
|
13
15
|
};
|
|
16
|
+
/** Option names default to the decorated property name. Optional values are injected as null. */
|
|
14
17
|
export type BaseOptions = {
|
|
15
|
-
name
|
|
18
|
+
name?: string;
|
|
16
19
|
description: string;
|
|
17
20
|
required?: boolean;
|
|
18
21
|
};
|
|
@@ -30,40 +33,38 @@ export type NumericOptions = BaseOptions & {
|
|
|
30
33
|
autocomplete?: boolean;
|
|
31
34
|
};
|
|
32
35
|
export type ChannelOptions = BaseOptions & {
|
|
33
|
-
channelTypes
|
|
34
|
-
};
|
|
35
|
-
export type OptionsIndex = {
|
|
36
|
-
name: string;
|
|
37
|
-
getMethod: keyof Omit<CommandInteractionOptionResolver, "getMessage" | "getFocused">;
|
|
38
|
-
index: number;
|
|
36
|
+
channelTypes?: ApplicationCommandOptionAllowedChannelTypes[];
|
|
39
37
|
};
|
|
40
|
-
export declare function CommandModule(options: CommandModuleOptions):
|
|
41
|
-
export declare function IntegrationTypes(...types: ApplicationIntegrationType[][] | ApplicationIntegrationType[]):
|
|
42
|
-
export declare function Command(option: CommandOptions):
|
|
43
|
-
export declare function Subcommand(option: CommandOptions):
|
|
44
|
-
export declare function Private(guild: string):
|
|
45
|
-
export declare function AddSubcommand(subcommand: Function):
|
|
46
|
-
export declare function AddSubcommandGroup(option:
|
|
47
|
-
|
|
48
|
-
export declare function
|
|
49
|
-
|
|
50
|
-
export declare function
|
|
51
|
-
|
|
52
|
-
export declare function
|
|
53
|
-
|
|
54
|
-
export declare function
|
|
55
|
-
|
|
56
|
-
export declare function
|
|
57
|
-
|
|
58
|
-
export declare function
|
|
59
|
-
|
|
60
|
-
export declare function
|
|
61
|
-
|
|
62
|
-
export declare function
|
|
63
|
-
|
|
64
|
-
export declare function
|
|
65
|
-
|
|
66
|
-
export declare function
|
|
67
|
-
|
|
68
|
-
export declare function
|
|
38
|
+
export declare function CommandModule(options: CommandModuleOptions): StandardClassDecorator;
|
|
39
|
+
export declare function IntegrationTypes(...types: ApplicationIntegrationType[][] | ApplicationIntegrationType[]): StandardClassDecorator;
|
|
40
|
+
export declare function Command(option: CommandOptions): StandardClassDecorator;
|
|
41
|
+
export declare function Subcommand(option: CommandOptions): StandardClassDecorator;
|
|
42
|
+
export declare function Private(guild: string): StandardClassDecorator;
|
|
43
|
+
export declare function AddSubcommand(subcommand: Function): StandardClassDecorator;
|
|
44
|
+
export declare function AddSubcommandGroup(option: CommandOptions, ...subcommands: Function[]): StandardClassDecorator;
|
|
45
|
+
/** Declares a command option and injects its value into this property. */
|
|
46
|
+
export declare function StringOption(option: StringOptions): InjectionDecorator;
|
|
47
|
+
/** Declares a command option and injects its value into this property. */
|
|
48
|
+
export declare function StringOptionWithChoices(option: OptionWithChoices<string>): InjectionDecorator;
|
|
49
|
+
/** Declares a command option and injects its value into this property. */
|
|
50
|
+
export declare function IntegerOption(option: NumericOptions): InjectionDecorator;
|
|
51
|
+
/** Declares a command option and injects its value into this property. */
|
|
52
|
+
export declare function IntegerOptionWithChoices(option: OptionWithChoices<number>): InjectionDecorator;
|
|
53
|
+
/** Declares a command option and injects its value into this property. */
|
|
54
|
+
export declare function NumberOption(option: NumericOptions): InjectionDecorator;
|
|
55
|
+
/** Declares a command option and injects its value into this property. */
|
|
56
|
+
export declare function NumberOptionWithChoices(option: OptionWithChoices<number>): InjectionDecorator;
|
|
57
|
+
/** Declares a command option and injects its value into this property. */
|
|
58
|
+
export declare function BooleanOption(option: BaseOptions): InjectionDecorator;
|
|
59
|
+
/** Declares a command option and injects its value into this property. */
|
|
60
|
+
export declare function UserOption(option: BaseOptions): InjectionDecorator;
|
|
61
|
+
/** Declares a command option and injects its value into this property. */
|
|
62
|
+
export declare function ChannelOption(option: ChannelOptions): InjectionDecorator;
|
|
63
|
+
/** Declares a command option and injects its value into this property. */
|
|
64
|
+
export declare function RoleOption(option: BaseOptions): InjectionDecorator;
|
|
65
|
+
/** Declares a command option and injects its value into this property. */
|
|
66
|
+
export declare function MentionableOption(option: BaseOptions): InjectionDecorator;
|
|
67
|
+
/** Declares a command option and injects its value into this property. */
|
|
68
|
+
export declare function AttachmentOption(option: BaseOptions): InjectionDecorator;
|
|
69
|
+
export declare function ContextMenu(option: ContextMenuOptions): StandardClassDecorator;
|
|
69
70
|
//# sourceMappingURL=CommandDecorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandDecorator.d.ts","sourceRoot":"","sources":["../../../src/structures/decorators/CommandDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"CommandDecorator.d.ts","sourceRoot":"","sources":["../../../src/structures/decorators/C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