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.
Files changed (103) hide show
  1. package/LICENSE +674 -201
  2. package/README.md +212 -11
  3. package/dist/index.js +18 -1
  4. package/dist/index.js.map +1 -0
  5. package/dist/structures/Constants.d.ts +2 -2
  6. package/dist/structures/Constants.d.ts.map +1 -1
  7. package/dist/structures/Constants.js +6 -2
  8. package/dist/structures/Constants.js.map +1 -0
  9. package/dist/structures/DiscordApp.d.ts +28 -10
  10. package/dist/structures/DiscordApp.d.ts.map +1 -1
  11. package/dist/structures/DiscordApp.js +695 -316
  12. package/dist/structures/DiscordApp.js.map +1 -0
  13. package/dist/structures/Plugin.d.ts +68 -0
  14. package/dist/structures/Plugin.d.ts.map +1 -1
  15. package/dist/structures/Plugin.js +32 -1
  16. package/dist/structures/Plugin.js.map +1 -0
  17. package/dist/structures/PluginManager.d.ts +122 -0
  18. package/dist/structures/PluginManager.d.ts.map +1 -0
  19. package/dist/structures/PluginManager.js +371 -0
  20. package/dist/structures/PluginManager.js.map +1 -0
  21. package/dist/structures/components/BaseButton.d.ts +2 -5
  22. package/dist/structures/components/BaseButton.d.ts.map +1 -1
  23. package/dist/structures/components/BaseButton.js +21 -22
  24. package/dist/structures/components/BaseButton.js.map +1 -0
  25. package/dist/structures/components/BaseModal.d.ts +13 -21
  26. package/dist/structures/components/BaseModal.d.ts.map +1 -1
  27. package/dist/structures/components/BaseModal.js +98 -137
  28. package/dist/structures/components/BaseModal.js.map +1 -0
  29. package/dist/structures/components/BaseSelectMenu.d.ts +2 -5
  30. package/dist/structures/components/BaseSelectMenu.d.ts.map +1 -1
  31. package/dist/structures/components/BaseSelectMenu.js +35 -35
  32. package/dist/structures/components/BaseSelectMenu.js.map +1 -0
  33. package/dist/structures/components/Listener.js +6 -1
  34. package/dist/structures/components/Listener.js.map +1 -0
  35. package/dist/structures/components/index.js +21 -4
  36. package/dist/structures/components/index.js.map +1 -0
  37. package/dist/structures/decorators/CommandDecorator.d.ts +38 -37
  38. package/dist/structures/decorators/CommandDecorator.d.ts.map +1 -1
  39. package/dist/structures/decorators/CommandDecorator.js +206 -280
  40. package/dist/structures/decorators/CommandDecorator.js.map +1 -0
  41. package/dist/structures/decorators/Constants.d.ts +7 -5
  42. package/dist/structures/decorators/Constants.d.ts.map +1 -1
  43. package/dist/structures/decorators/Constants.js +37 -31
  44. package/dist/structures/decorators/Constants.js.map +1 -0
  45. package/dist/structures/decorators/DiscordModuleDecorator.d.ts +7 -2
  46. package/dist/structures/decorators/DiscordModuleDecorator.d.ts.map +1 -1
  47. package/dist/structures/decorators/DiscordModuleDecorator.js +16 -33
  48. package/dist/structures/decorators/DiscordModuleDecorator.js.map +1 -0
  49. package/dist/structures/decorators/EventDecorator.d.ts +3 -2
  50. package/dist/structures/decorators/EventDecorator.d.ts.map +1 -1
  51. package/dist/structures/decorators/EventDecorator.js +19 -11
  52. package/dist/structures/decorators/EventDecorator.js.map +1 -0
  53. package/dist/structures/decorators/ExecutionDecorator.d.ts +19 -0
  54. package/dist/structures/decorators/ExecutionDecorator.d.ts.map +1 -0
  55. package/dist/structures/decorators/ExecutionDecorator.js +23 -0
  56. package/dist/structures/decorators/ExecutionDecorator.js.map +1 -0
  57. package/dist/structures/decorators/InjectionMetadata.d.ts +35 -0
  58. package/dist/structures/decorators/InjectionMetadata.d.ts.map +1 -0
  59. package/dist/structures/decorators/InjectionMetadata.js +34 -0
  60. package/dist/structures/decorators/InjectionMetadata.js.map +1 -0
  61. package/dist/structures/decorators/InteractionHandlerDecorator.d.ts +17 -2
  62. package/dist/structures/decorators/InteractionHandlerDecorator.d.ts.map +1 -1
  63. package/dist/structures/decorators/InteractionHandlerDecorator.js +53 -8
  64. package/dist/structures/decorators/InteractionHandlerDecorator.js.map +1 -0
  65. package/dist/structures/decorators/MessageComponentDecorator.d.ts +24 -39
  66. package/dist/structures/decorators/MessageComponentDecorator.d.ts.map +1 -1
  67. package/dist/structures/decorators/MessageComponentDecorator.js +128 -122
  68. package/dist/structures/decorators/MessageComponentDecorator.js.map +1 -0
  69. package/dist/structures/decorators/Metadata.d.ts +16 -0
  70. package/dist/structures/decorators/Metadata.d.ts.map +1 -0
  71. package/dist/structures/decorators/Metadata.js +50 -0
  72. package/dist/structures/decorators/Metadata.js.map +1 -0
  73. package/dist/structures/decorators/PluginDecorator.d.ts +41 -0
  74. package/dist/structures/decorators/PluginDecorator.d.ts.map +1 -0
  75. package/dist/structures/decorators/PluginDecorator.js +36 -0
  76. package/dist/structures/decorators/PluginDecorator.js.map +1 -0
  77. package/dist/structures/decorators/UseDecorator.d.ts +44 -0
  78. package/dist/structures/decorators/UseDecorator.d.ts.map +1 -0
  79. package/dist/structures/decorators/UseDecorator.js +49 -0
  80. package/dist/structures/decorators/UseDecorator.js.map +1 -0
  81. package/dist/structures/decorators/index.d.ts +3 -0
  82. package/dist/structures/decorators/index.d.ts.map +1 -1
  83. package/dist/structures/decorators/index.js +26 -6
  84. package/dist/structures/decorators/index.js.map +1 -0
  85. package/dist/structures/index.d.ts +3 -1
  86. package/dist/structures/index.d.ts.map +1 -1
  87. package/dist/structures/index.js +26 -6
  88. package/dist/structures/index.js.map +1 -0
  89. package/dist/utils/Util.d.ts +2 -0
  90. package/dist/utils/Util.d.ts.map +1 -1
  91. package/dist/utils/Util.js +30 -11
  92. package/dist/utils/Util.js.map +1 -0
  93. package/dist/utils/cache.d.ts +4 -0
  94. package/dist/utils/cache.d.ts.map +1 -0
  95. package/dist/utils/cache.js +17 -0
  96. package/dist/utils/cache.js.map +1 -0
  97. package/dist/utils/customId.d.ts +12 -0
  98. package/dist/utils/customId.d.ts.map +1 -0
  99. package/dist/utils/customId.js +49 -0
  100. package/dist/utils/customId.js.map +1 -0
  101. package/package.json +64 -38
  102. package/bun.lock +0 -264
  103. package/tsdown.config.json +0 -3
@@ -1,14 +1,21 @@
1
- import { CheckboxBuilder, CheckboxGroupBuilder, LabelBuilder, ModalBuilder, RadioGroupBuilder, StringSelectMenuBuilder, TextDisplayBuilder, TextInputBuilder } from "discord.js";
2
- import { MODAL_COMPONENTS_KEY, MODAL_OPTIONS_KEY } from "..";
3
- import crypto from "node:crypto";
4
- import { Util } from "../../utils/Util";
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
- * constructor(@Interaction readonly interaction: ModalSubmitInteraction, @TextInputFieldInjection("my_text_input") readonly textInputValue: string) {
24
- * super();
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
- export class BaseModal {
35
- static modal = null;
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
- if (this.modal)
41
- return ModalBuilder.from(this.modal.toJSON());
42
- const options = Reflect.getMetadata(MODAL_OPTIONS_KEY, this);
43
- const components = Reflect.getMetadata(MODAL_COMPONENTS_KEY, this) ?? [];
44
- if (!options || !components)
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 currentOptions = this.options ?? Reflect.getMetadata(MODAL_OPTIONS_KEY, this);
61
- const currentComponents = this.components.length > 0 ? this.components : Reflect.getMetadata(MODAL_COMPONENTS_KEY, this)?.reverse();
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 newOptions = Util.mergeDefault(currentOptions, options);
65
- const newComponents = currentComponents.map(c => {
66
- const { customId, component } = c;
67
- if (component instanceof LabelBuilder) {
68
- const updatedComponent = new LabelBuilder(component.toJSON());
69
- const matchingLabelValue = values.find(v => v.customId === customId && v.type === 'label');
70
- if (matchingLabelValue) {
71
- if (matchingLabelValue.label)
72
- updatedComponent.setLabel(matchingLabelValue.label);
73
- if (matchingLabelValue.description)
74
- updatedComponent.setDescription(matchingLabelValue.description);
75
- }
76
- if (component.data.component instanceof TextInputBuilder) {
77
- const matchingTextInputValue = values.find(v => v.customId === component.data.component.data.custom_id && v.type === 'text_input');
78
- if (matchingTextInputValue) {
79
- if ("value" in component.data.component.data) {
80
- const updatedTextInput = TextInputBuilder.from(component.data.component.toJSON());
81
- updatedTextInput.setValue(matchingTextInputValue.value);
82
- updatedComponent.setTextInputComponent(updatedTextInput);
83
- }
84
- }
85
- }
86
- else if (component.data.component instanceof StringSelectMenuBuilder) {
87
- const matchingStringSelectValue = values.find(v => v.customId === component.data.component.data.custom_id && v.type === 'string_select');
88
- if (matchingStringSelectValue) {
89
- const updatedComponent = StringSelectMenuBuilder.from(component.data.component.toJSON());
90
- updatedComponent.setOptions(matchingStringSelectValue.options);
91
- component.setStringSelectMenuComponent(updatedComponent);
92
- }
93
- }
94
- else if (component.data.component instanceof RadioGroupBuilder) {
95
- const matchingRadioGroupValue = values.find(v => v.customId === component.data.component.data.custom_id && v.type === 'radio_group');
96
- if (matchingRadioGroupValue) {
97
- const updatedComponent = new RadioGroupBuilder(component.data.component.toJSON());
98
- if ("required" in matchingRadioGroupValue)
99
- updatedComponent.setRequired(matchingRadioGroupValue.required);
100
- updatedComponent.setOptions(matchingRadioGroupValue.options);
101
- component.setRadioGroupComponent(updatedComponent);
102
- }
103
- }
104
- else if (component.data.component instanceof CheckboxGroupBuilder) {
105
- const matchingCheckboxGroupValue = values.find(v => v.customId === component.data.component.data.custom_id && v.type === 'checkbox_group');
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 (component instanceof TextDisplayBuilder) {
130
- const updatedComponent = new TextDisplayBuilder(component.toJSON());
131
- const matchingTextDisplayValue = values.find(v => v.customId === customId && v.type === 'text_display');
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 { customId, component };
104
+ return copy;
138
105
  });
139
- const modal = create(newOptions, [...newComponents].map(c => c.component));
140
- return modal;
106
+ return create(Util_1.Util.mergeDefault(defaults, options), builders);
141
107
  }
142
- /**
143
- * Shows modal to user and recieve the input.
144
- * @param itr The interaction to show the modal to. Must be a command or button interaction.
145
- * @returns The fields submitted by the user in the modal.
146
- */
147
- static getInput(itr) {
148
- return new Promise((r, j) => {
149
- if (itr.replied || itr.deferred)
150
- return j("Interaction already replied.");
151
- const id = crypto.createHash("md5")
152
- .update(Math.floor(Math.random() * (99999999 - 10000000) + 10000000).toString())
153
- .digest("hex");
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,CAA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C,CAAC,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvF,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;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
- * constructor(@Interaction readonly interaction: StringSelectMenuInteraction) {
28
- * super();
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":"AAAA,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAoC;IACpE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAwB;IAE9C,6FAA6F;IAC7F,MAAM,CAAC,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AC;AAC7E,KAAK,UAAU,CAAC,CAAC,SAAS,cAAc,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC"}
@@ -1,6 +1,10 @@
1
- import { ChannelSelectMenuBuilder, MentionableSelectMenuBuilder, RoleSelectMenuBuilder, StringSelectMenuBuilder, UserSelectMenuBuilder } from "discord.js";
2
- import { SELECT_MENU_OPTIONS_KEY, SELECT_MENU_TYPE_KEY } from "..";
3
- import { Util } from "../../utils/Util";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseSelectMenu = 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
- * constructor(@Interaction readonly interaction: StringSelectMenuInteraction) {
29
- * super();
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
- export class BaseSelectMenu {
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
- if (this.genericSelectMenu)
45
- return this.genericSelectMenu.copy();
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
- this.genericSelectMenu = new GenericSelectMenu(type);
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
- if (!this.genericSelectMenu) {
63
- this.getSelectMenu();
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 && !this.genericSelectMenu.isStringSelect())
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 this.genericSelectMenu.create(newOptions);
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() && "channelTypes" in options) {
105
- menu.setChannelTypes(options.channelTypes ?? [])
106
- .setDefaultChannels(options.defaultChannels ?? []);
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() && "defaultUsers" in options && "defaultRoles" in options) {
109
- menu.addDefaultUsers(options.defaultUsers ?? [])
110
- .addDefaultRoles(options.defaultRoles ?? []);
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":"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e,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
- export class Listener {
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
- export * from "./BaseButton";
2
- export * from "./BaseSelectMenu";
3
- export * from "./BaseModal";
4
- export * from "./Listener";
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 { ApplicationCommandOptionAllowedChannelTypes, CommandInteractionOptionResolver, ContextMenuCommandType } from "discord.js";
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: string;
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: ApplicationCommandOptionAllowedChannelTypes[];
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): ClassDecorator;
41
- export declare function IntegrationTypes(...types: ApplicationIntegrationType[][] | ApplicationIntegrationType[]): ClassDecorator;
42
- export declare function Command(option: CommandOptions): ClassDecorator;
43
- export declare function Subcommand(option: CommandOptions): ClassDecorator;
44
- export declare function Private(guild: string): <TFunction extends Function>(constructor: TFunction) => void;
45
- export declare function AddSubcommand(subcommand: Function): <T extends Function>(constructor: T) => void;
46
- export declare function AddSubcommandGroup(option: BaseOptions, ...subcommands: Function[]): <T extends Function>(constructor: T) => void;
47
- export declare function StringOption(option: StringOptions): ClassDecorator;
48
- export declare function StringOptionWithChoices(option: OptionWithChoices<string>): ClassDecorator;
49
- export declare function IntegerOption(option: NumericOptions): ClassDecorator;
50
- export declare function IntegerOptionWithChoices(option: OptionWithChoices<number>): ClassDecorator;
51
- export declare function NumberOption(option: NumericOptions): ClassDecorator;
52
- export declare function NumberOptionWithChoices(option: OptionWithChoices<number>): ClassDecorator;
53
- export declare function BooleanOption(option: BaseOptions): <T extends Function>(constructor: T) => void;
54
- export declare function UserOption(option: BaseOptions): <T extends Function>(constructor: T) => void;
55
- export declare function ChannelOption(option: ChannelOptions): <T extends Function>(constructor: T) => void;
56
- export declare function RoleOption(option: BaseOptions): <T extends Function>(constructor: T) => void;
57
- export declare function MentionableOption(option: BaseOptions): <T extends Function>(constructor: T) => void;
58
- export declare function AttachmentOption(option: BaseOptions): <T extends Function>(constructor: T) => void;
59
- export declare function StringOptionInjection(name: string): (target: Object, _propertyKey: string | symbol | undefined, parameterIndex: number) => void;
60
- export declare function IntegerOptionInjection(name: string): (target: Object, _propertyKey: string | symbol | undefined, parameterIndex: number) => void;
61
- export declare function NumberOptionInjection(name: string): (target: Object, _propertyKey: string | symbol | undefined, parameterIndex: number) => void;
62
- export declare function BooleanOptionInjection(name: string): (target: Object, _propertyKey: string | symbol | undefined, parameterIndex: number) => void;
63
- export declare function UserOptionInjection(name: string): (target: Object, _propertyKey: string | symbol | undefined, parameterIndex: number) => void;
64
- export declare function ChannelOptionInjection(name: string): (target: Object, _propertyKey: string | symbol | undefined, parameterIndex: number) => void;
65
- export declare function RoleOptionInjection(name: string): (target: Object, _propertyKey: string | symbol | undefined, parameterIndex: number) => void;
66
- export declare function MentionableOptionInjection(name: string): (target: Object, _propertyKey: string | symbol | undefined, parameterIndex: number) => void;
67
- export declare function AttachmentOptionInjection(name: string): (target: Object, _propertyKey: string | symbol | undefined, parameterIndex: number) => void;
68
- export declare function ContextMenu(option: ContextMenuOptions): ClassDecorator;
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