oopscord.js 0.0.30 → 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 +18 -1
- 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 +6 -2
- 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 +695 -316
- 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 +32 -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 +21 -22
- 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 +98 -137
- 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 +35 -35
- package/dist/structures/components/BaseSelectMenu.js.map +1 -0
- package/dist/structures/components/Listener.js +6 -1
- package/dist/structures/components/Listener.js.map +1 -0
- package/dist/structures/components/index.js +21 -4
- package/dist/structures/components/index.js.map +1 -0
- package/dist/structures/decorators/CommandDecorator.d.ts +38 -37
- package/dist/structures/decorators/CommandDecorator.d.ts.map +1 -1
- package/dist/structures/decorators/CommandDecorator.js +206 -280
- package/dist/structures/decorators/CommandDecorator.js.map +1 -0
- package/dist/structures/decorators/Constants.d.ts +7 -5
- package/dist/structures/decorators/Constants.d.ts.map +1 -1
- package/dist/structures/decorators/Constants.js +37 -31
- package/dist/structures/decorators/Constants.js.map +1 -0
- package/dist/structures/decorators/DiscordModuleDecorator.d.ts +7 -2
- package/dist/structures/decorators/DiscordModuleDecorator.d.ts.map +1 -1
- package/dist/structures/decorators/DiscordModuleDecorator.js +16 -33
- package/dist/structures/decorators/DiscordModuleDecorator.js.map +1 -0
- package/dist/structures/decorators/EventDecorator.d.ts +3 -2
- package/dist/structures/decorators/EventDecorator.d.ts.map +1 -1
- package/dist/structures/decorators/EventDecorator.js +19 -11
- 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 +53 -8
- package/dist/structures/decorators/InteractionHandlerDecorator.js.map +1 -0
- package/dist/structures/decorators/MessageComponentDecorator.d.ts +24 -39
- package/dist/structures/decorators/MessageComponentDecorator.d.ts.map +1 -1
- package/dist/structures/decorators/MessageComponentDecorator.js +128 -122
- 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 +3 -0
- package/dist/structures/decorators/index.d.ts.map +1 -1
- package/dist/structures/decorators/index.js +26 -6
- 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 +26 -6
- 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 +30 -11
- 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 +64 -38
- package/bun.lock +0 -264
- package/tsdown.config.json +0 -3
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BaseModal = void 0;
|
|
7
|
+
const Metadata_1 = require("../decorators/Metadata");
|
|
8
|
+
const discord_js_1 = require("discord.js");
|
|
9
|
+
const __1 = require("..");
|
|
10
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
11
|
+
const Util_1 = require("../../utils/Util");
|
|
5
12
|
/**
|
|
6
13
|
* The base class for modals created with the {@link Modal} decorator. This class is used to create a modal from the options and components defined in the class, and to override the default options and component values with new options and values when creating the modal.
|
|
7
14
|
*
|
|
8
15
|
* @example
|
|
9
16
|
* ```ts
|
|
10
|
-
* import { ModalSubmitInteraction } from "discord.js";
|
|
11
|
-
* 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";
|
|
12
19
|
*
|
|
13
20
|
* @Modal({
|
|
14
21
|
* customId: "my_modal",
|
|
@@ -20,9 +27,11 @@ import { Util } from "../../utils/Util";
|
|
|
20
27
|
* component: { type: "text_input", customId: "my_text_input", style: TextInputStyle.Short, placeholder: "Enter something...", required: true }
|
|
21
28
|
* })
|
|
22
29
|
* class MyModal extends BaseModal {
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
30
|
+
* @Interaction
|
|
31
|
+
* interaction!: ModalSubmitInteraction;
|
|
32
|
+
*
|
|
33
|
+
* @TextInputFieldInjection("my_text_input")
|
|
34
|
+
* textInputValue!: string;
|
|
26
35
|
*
|
|
27
36
|
* @Run
|
|
28
37
|
* async run() {
|
|
@@ -31,146 +40,98 @@ import { Util } from "../../utils/Util";
|
|
|
31
40
|
* }
|
|
32
41
|
* ```
|
|
33
42
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
static options;
|
|
37
|
-
static components = [];
|
|
38
|
-
/** Returns a new {@link ModalBuilder} that was created from the modal options and components. */
|
|
43
|
+
class BaseModal {
|
|
44
|
+
/** Creates an independent builder from the decorated template. */
|
|
39
45
|
static getModal() {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
throw new TypeError("Failed to get the modal.");
|
|
46
|
-
// Reverse the components because they are added to the modal in reverse order due to the way the decorators work.
|
|
47
|
-
const reversedComponents = [...components].reverse();
|
|
48
|
-
this.options = options;
|
|
49
|
-
this.components = [...reversedComponents];
|
|
50
|
-
this.modal = create(options, reversedComponents.map(c => c.component));
|
|
51
|
-
return 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());
|
|
52
51
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Returns a new {@link ModalBuilder} with the specified options and component values merged with the default options and components defined in the class.
|
|
55
|
-
*
|
|
56
|
-
* @param options The options to merge with the default options.
|
|
57
|
-
* @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.
|
|
58
|
-
*/
|
|
52
|
+
/** Overrides a copy of the template; label IDs and inner field IDs are distinct. */
|
|
59
53
|
static override(options = {}, ...values) {
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
if (!currentOptions)
|
|
54
|
+
const defaults = (0, Metadata_1.getMetadata)(__1.MODAL_OPTIONS_KEY, this);
|
|
55
|
+
if (!defaults)
|
|
63
56
|
throw new TypeError("Failed to get the modal options.");
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (matchingCheckboxGroupValue) {
|
|
107
|
-
const updatedComponent = new CheckboxGroupBuilder(component.data.component.toJSON());
|
|
108
|
-
if (typeof matchingCheckboxGroupValue.minValues == "number")
|
|
109
|
-
updatedComponent.setMinValues(matchingCheckboxGroupValue.minValues);
|
|
110
|
-
if (typeof matchingCheckboxGroupValue.maxValues == "number")
|
|
111
|
-
updatedComponent.setMaxValues(matchingCheckboxGroupValue.maxValues);
|
|
112
|
-
if ("required" in matchingCheckboxGroupValue)
|
|
113
|
-
updatedComponent.setRequired(matchingCheckboxGroupValue.required);
|
|
114
|
-
updatedComponent.setOptions(matchingCheckboxGroupValue.options);
|
|
115
|
-
component.setCheckboxGroupComponent(updatedComponent);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
else if (component.data.component instanceof CheckboxBuilder) {
|
|
119
|
-
const matchingCheckboxValue = values.find(v => v.customId === component.data.component.data.custom_id && v.type === 'checkbox');
|
|
120
|
-
if (matchingCheckboxValue) {
|
|
121
|
-
const updatedComponent = new CheckboxBuilder(component.data.component.toJSON());
|
|
122
|
-
if ("default" in matchingCheckboxValue)
|
|
123
|
-
updatedComponent.setDefault(matchingCheckboxValue.default);
|
|
124
|
-
component.setCheckboxComponent(updatedComponent);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
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);
|
|
128
99
|
}
|
|
129
|
-
else if (
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (matchingTextDisplayValue) {
|
|
133
|
-
updatedComponent.setContent(matchingTextDisplayValue.content);
|
|
134
|
-
}
|
|
135
|
-
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);
|
|
136
103
|
}
|
|
137
|
-
return
|
|
104
|
+
return copy;
|
|
138
105
|
});
|
|
139
|
-
|
|
140
|
-
return modal;
|
|
106
|
+
return create(Util_1.Util.mergeDefault(defaults, options), builders);
|
|
141
107
|
}
|
|
142
|
-
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
itr.showModal(this.getModal().setCustomId(id));
|
|
155
|
-
let listener = async (itr) => {
|
|
156
|
-
if (!itr.isModalSubmit() || itr.customId != id)
|
|
157
|
-
return;
|
|
158
|
-
await itr.deferUpdate();
|
|
159
|
-
r(itr.fields);
|
|
160
|
-
itr.client.off("interactionCreate", listener);
|
|
161
|
-
};
|
|
162
|
-
itr.client.on("interactionCreate", listener);
|
|
163
|
-
setTimeout(() => {
|
|
164
|
-
itr.client.off("interactionCreate", listener);
|
|
165
|
-
j("Timed out");
|
|
166
|
-
}, 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
|
|
167
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;
|
|
168
129
|
}
|
|
169
130
|
}
|
|
131
|
+
exports.BaseModal = BaseModal;
|
|
170
132
|
function create(options, components) {
|
|
171
|
-
const modal = new ModalBuilder()
|
|
172
|
-
.setTitle(options.title)
|
|
173
|
-
.setCustomId(options.customId);
|
|
133
|
+
const modal = new discord_js_1.ModalBuilder().setTitle(options.title).setCustomId(options.customId);
|
|
174
134
|
modal.components.push(...components);
|
|
175
135
|
return modal;
|
|
176
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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C;IACrC,OAAO,KAAK,CAAC;AACjB,CAAC"}
|
|
@@ -24,9 +24,8 @@ import { ChannelSelectMenuOptions, MentionableSelectMenuOptions, 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;IAC7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electMenu = void 0;
|
|
4
|
+
const Metadata_1 = require("../decorators/Metadata");
|
|
5
|
+
const discord_js_1 = require("discord.js");
|
|
6
|
+
const __1 = require("..");
|
|
7
|
+
const Util_1 = require("../../utils/Util");
|
|
4
8
|
/**
|
|
5
9
|
* 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.
|
|
6
10
|
*
|
|
@@ -25,9 +29,8 @@ import { Util } from "../../utils/Util";
|
|
|
25
29
|
* ]
|
|
26
30
|
* })
|
|
27
31
|
* class MySelectMenu extends BaseSelectMenu {
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* }
|
|
32
|
+
* @Interaction
|
|
33
|
+
* interaction!: StringSelectMenuInteraction;
|
|
31
34
|
*
|
|
32
35
|
* @Run
|
|
33
36
|
* async run() {
|
|
@@ -36,21 +39,14 @@ import { Util } from "../../utils/Util";
|
|
|
36
39
|
* }
|
|
37
40
|
* ```
|
|
38
41
|
*/
|
|
39
|
-
|
|
40
|
-
static genericSelectMenu;
|
|
41
|
-
static options;
|
|
42
|
+
class BaseSelectMenu {
|
|
42
43
|
/** Returns a new {@link SelectMenuBuilder} that was created from the select menu options. */
|
|
43
44
|
static getSelectMenu() {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const type = Reflect.getMetadata(SELECT_MENU_TYPE_KEY, this);
|
|
47
|
-
const options = Reflect.getMetadata(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);
|
|
48
47
|
if (!options)
|
|
49
48
|
throw new TypeError("Failed to get the select menu.");
|
|
50
|
-
|
|
51
|
-
this.genericSelectMenu.create(options);
|
|
52
|
-
this.options = options;
|
|
53
|
-
return this.genericSelectMenu.copy();
|
|
49
|
+
return new GenericSelectMenu(type).create(options);
|
|
54
50
|
}
|
|
55
51
|
/**
|
|
56
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).
|
|
@@ -59,24 +55,24 @@ export class BaseSelectMenu {
|
|
|
59
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.
|
|
60
56
|
*/
|
|
61
57
|
static override(options = {}, ...values) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const currentOptions = (this.options ?? Reflect.getMetadata(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);
|
|
66
61
|
if (!currentOptions)
|
|
67
62
|
throw new TypeError("Failed to get the select menu options.");
|
|
68
|
-
if (values.length > 0 && !
|
|
63
|
+
if (values.length > 0 && !selectMenu.isStringSelect())
|
|
69
64
|
throw new TypeError("Values can only be overridden for StringSelectMenu.");
|
|
70
|
-
const newOptions = values.length > 0 ? Util.mergeDefault(currentOptions, { ...options, options: values }) : Util.mergeDefault(currentOptions, options);
|
|
71
|
-
return
|
|
65
|
+
const newOptions = values.length > 0 ? Util_1.Util.mergeDefault(currentOptions, { ...options, options: values }) : Util_1.Util.mergeDefault(currentOptions, options);
|
|
66
|
+
return selectMenu.create(newOptions);
|
|
72
67
|
}
|
|
73
68
|
}
|
|
69
|
+
exports.BaseSelectMenu = BaseSelectMenu;
|
|
74
70
|
const SelectMenuBuilders = {
|
|
75
|
-
string: StringSelectMenuBuilder,
|
|
76
|
-
user: UserSelectMenuBuilder,
|
|
77
|
-
role: RoleSelectMenuBuilder,
|
|
78
|
-
channel: ChannelSelectMenuBuilder,
|
|
79
|
-
mentionable: MentionableSelectMenuBuilder,
|
|
71
|
+
string: discord_js_1.StringSelectMenuBuilder,
|
|
72
|
+
user: discord_js_1.UserSelectMenuBuilder,
|
|
73
|
+
role: discord_js_1.RoleSelectMenuBuilder,
|
|
74
|
+
channel: discord_js_1.ChannelSelectMenuBuilder,
|
|
75
|
+
mentionable: discord_js_1.MentionableSelectMenuBuilder,
|
|
80
76
|
};
|
|
81
77
|
class GenericSelectMenu {
|
|
82
78
|
kind;
|
|
@@ -101,13 +97,16 @@ class GenericSelectMenu {
|
|
|
101
97
|
else if (this.isRoleSelect() && "defaultRoles" in options) {
|
|
102
98
|
menu.setDefaultRoles(options.defaultRoles ?? []);
|
|
103
99
|
}
|
|
104
|
-
else if (this.isChannelSelect()
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
else if (this.isChannelSelect()) {
|
|
101
|
+
const channelOptions = options;
|
|
102
|
+
if (channelOptions.channelTypes)
|
|
103
|
+
menu.setChannelTypes(channelOptions.channelTypes);
|
|
104
|
+
menu.setDefaultChannels(channelOptions.defaultChannels ?? []);
|
|
107
105
|
}
|
|
108
|
-
else if (this.isMentionableSelect()
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
else if (this.isMentionableSelect()) {
|
|
107
|
+
const mentionableOptions = options;
|
|
108
|
+
menu.addDefaultUsers(mentionableOptions.defaultUsers ?? [])
|
|
109
|
+
.addDefaultRoles(mentionableOptions.defaultRoles ?? []);
|
|
111
110
|
}
|
|
112
111
|
menu.setCustomId(options.customId);
|
|
113
112
|
if (options.placeholder)
|
|
@@ -127,3 +126,4 @@ class GenericSelectMenu {
|
|
|
127
126
|
return this.selectMenu.constructor.from(this.selectMenu.toJSON());
|
|
128
127
|
}
|
|
129
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;QACxF,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAE/C,IAAI,CAAC,cAAc;YAAE,MAAM,IAAI,SAAS,CAAC,wCAAwC,CAAC,CAAC;QAEnF,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE;YAAE,MAAM,IAAI,SAAS,CAAC,qDAAqD,CAAC,CAAC;QAElI,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAI,CAAC,YA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AAS,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"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Listener = void 0;
|
|
1
4
|
/**
|
|
2
5
|
* Marker class for event listeners. This class is used to identify event listener classes in the event module system.
|
|
3
6
|
*
|
|
@@ -13,5 +16,7 @@
|
|
|
13
16
|
* }
|
|
14
17
|
* ```
|
|
15
18
|
*/
|
|
16
|
-
|
|
19
|
+
class Listener {
|
|
17
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,4 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./BaseButton"), exports);
|
|
18
|
+
__exportStar(require("./BaseSelectMenu"), exports);
|
|
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,5 +1,7 @@
|
|
|
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
6
|
commands?: (new (...args: any[]) => any)[];
|
|
5
7
|
};
|
|
@@ -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
|