oopscord.js 0.0.24 → 0.0.25

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.
@@ -172,7 +172,7 @@ class DiscordApp {
172
172
  if (!modal)
173
173
  return;
174
174
  let runMethod = Reflect.getMetadata(Constants_1.INTERACTION_RUN_METHOD_KEY, modal);
175
- let preArgs = [Reflect.getMetadata(Constants_1.INTERACTION_PARAMETER_INDEX_KEY, modal), ...(Reflect.getMetadata(Constants_1.MODAL_FIELD_INDEX_KEY, modal) || [])];
175
+ let preArgs = [Reflect.getMetadata(Constants_1.INTERACTION_PARAMETER_INDEX_KEY, modal), ...(Reflect.getMetadata(Constants_1.MODAL_TEXT_INPUT_VALUE_INDEX_KEY, modal) || [])];
176
176
  let args = Array(preArgs.length).fill(null);
177
177
  preArgs.forEach(arg => {
178
178
  if (typeof arg == "number")
@@ -1 +1 @@
1
- {"version":3,"file":"BaseModal.d.ts","sourceRoot":"","sources":["../../../src/structures/components/BaseModal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoD,YAAY,EAAE,MAAM,YAAY,CAAC;AAG5F,qBAAa,SAAS;IAClB,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAQ;IAEzC,MAAM,CAAC,QAAQ;IAoBf,MAAM,CAAC,iBAAiB,CAAC,GAAG,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE;CAc5E"}
1
+ {"version":3,"file":"BaseModal.d.ts","sourceRoot":"","sources":["../../../src/structures/components/BaseModal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoD,YAAY,EAAoB,MAAM,YAAY,CAAC;AAG9G,qBAAa,SAAS;IAClB,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAQ;IAEzC,MAAM,CAAC,QAAQ;IAuBf,MAAM,CAAC,iBAAiB,CAAC,GAAG,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE;CA8B5E"}
@@ -13,21 +13,37 @@ class BaseModal {
13
13
  const components = Reflect.getMetadata(__1.MODAL_COMPONENTS_KEY, this) ?? [];
14
14
  if (!options)
15
15
  throw new TypeError("Failed to get the modal.");
16
+ // Reverse the components because they are added to the modal in reverse order due to the way the decorators work.
17
+ const reversedComponents = [...components].reverse();
16
18
  modal
17
19
  .setTitle(options.title)
18
20
  .setCustomId(options.customId);
19
- modal.setComponents(components.map(c => new discord_js_1.ActionRowBuilder().addComponents(c)));
21
+ modal.components.push(...reversedComponents);
20
22
  this.modal = modal;
21
23
  return modal;
22
24
  }
23
25
  static withDefaultValues(...values) {
24
26
  const modal = discord_js_1.ModalBuilder.from(this.getModal().toJSON());
25
- modal.setComponents(modal.components.map(c => c.setComponents(c.components.map(input => {
26
- const value = values.find(v => v.customId == input.data.custom_id);
27
- if (value)
28
- input.setValue(value.value);
29
- return input;
30
- }))));
27
+ modal.components.push(...modal.components.map(row => {
28
+ if (row instanceof discord_js_1.ActionRowBuilder) {
29
+ const actionRow = discord_js_1.ActionRowBuilder.from(row);
30
+ actionRow.setComponents(actionRow.components.map(component => {
31
+ if (component instanceof discord_js_1.TextInputBuilder) {
32
+ const matchingValue = values.find(v => v.customId === component.data.custom_id);
33
+ if (matchingValue) {
34
+ if ("value" in component.data) {
35
+ const updatedComponent = discord_js_1.TextInputBuilder.from(component.toJSON());
36
+ updatedComponent.setValue(matchingValue.value);
37
+ return updatedComponent;
38
+ }
39
+ }
40
+ }
41
+ return component;
42
+ }));
43
+ return actionRow;
44
+ }
45
+ return row;
46
+ }));
31
47
  return modal;
32
48
  }
33
49
  }
@@ -1,7 +1,7 @@
1
1
  import { ChannelSelectMenuBuilder, MentionableSelectMenuBuilder, RoleSelectMenuBuilder, StringSelectMenuBuilder, UserSelectMenuBuilder } from "discord.js";
2
2
  export declare class BaseSelectMenu {
3
3
  static selelctMenu: StringSelectMenuBuilder | UserSelectMenuBuilder | RoleSelectMenuBuilder | ChannelSelectMenuBuilder | MentionableSelectMenuBuilder | null;
4
- static getSelectMenu(): StringSelectMenuBuilder | UserSelectMenuBuilder | RoleSelectMenuBuilder | ChannelSelectMenuBuilder | MentionableSelectMenuBuilder;
4
+ static getSelectMenu(): StringSelectMenuBuilder | UserSelectMenuBuilder | ChannelSelectMenuBuilder | RoleSelectMenuBuilder | MentionableSelectMenuBuilder;
5
5
  static withValues(...values: {
6
6
  label: string;
7
7
  value: string;
@@ -28,6 +28,7 @@ class BaseSelectMenu {
28
28
  break;
29
29
  case "channel":
30
30
  selectMenu = new discord_js_1.ChannelSelectMenuBuilder()
31
+ .setChannelTypes(options.channelTypes ?? [])
31
32
  .setDefaultChannels(options.defaultChannels ?? []);
32
33
  break;
33
34
  case "mentionable":
@@ -39,9 +40,9 @@ class BaseSelectMenu {
39
40
  default:
40
41
  throw new TypeError("Invalid select menu type.");
41
42
  }
42
- selectMenu
43
- .setCustomId(options.customId)
44
- .setPlaceholder(options.placeholder);
43
+ selectMenu.setCustomId(options.customId);
44
+ if ("placeholder" in options)
45
+ selectMenu.setPlaceholder(options.placeholder);
45
46
  if (options.disabled)
46
47
  selectMenu.setDisabled(options.disabled);
47
48
  if (typeof options.minValues == 'number')
@@ -22,7 +22,8 @@ export declare const SELECT_MENU_TYPE_KEY: unique symbol;
22
22
  export declare const SELECT_MENU_OPTIONS_KEY: unique symbol;
23
23
  export declare const MODAL_OPTIONS_KEY: unique symbol;
24
24
  export declare const MODAL_COMPONENTS_KEY: unique symbol;
25
- export declare const MODAL_FIELD_INDEX_KEY: unique symbol;
25
+ export declare const MODAL_TEXT_INPUT_VALUE_INDEX_KEY: unique symbol;
26
+ export declare const MODAL_SELECT_MENU_VALUE_INDEX_KEY: unique symbol;
26
27
  export declare enum ModuleType {
27
28
  COMMAND = 0,
28
29
  MESSAGE_COMPONENT = 1
@@ -1 +1 @@
1
- {"version":3,"file":"Constants.d.ts","sourceRoot":"","sources":["../../../src/structures/decorators/Constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,eAAiB,CAAC;AAE9C,eAAO,MAAM,2BAA2B,eAAqB,CAAC;AAE9D,eAAO,MAAM,iCAAiC,eAA8B,CAAC;AAE7E,eAAO,MAAM,0BAA0B,eAAuB,CAAC;AAC/D,eAAO,MAAM,+BAA+B,eAAwC,CAAC;AACrF,eAAO,MAAM,oBAAoB,eAAiB,CAAC;AAEnD,eAAO,MAAM,gBAAgB,eAAiB,CAAC;AAC/C,eAAO,MAAM,uBAAuB,eAAwB,CAAC;AAC7D,eAAO,MAAM,mBAAmB,eAAoB,CAAC;AACrD,eAAO,MAAM,yBAAyB,eAA0B,CAAC;AACjE,eAAO,MAAM,mBAAmB,eAAoB,CAAC;AACrD,eAAO,MAAM,6BAA6B,eAA8B,CAAC;AACzE,eAAO,MAAM,uBAAuB,eAAwB,CAAC;AAE7D,eAAO,MAAM,qBAAqB,eAA8B,CAAC;AAEjE,eAAO,MAAM,2BAA2B,eAAoC,CAAC;AAE7E,eAAO,MAAM,0BAA0B,eAAoB,CAAC;AAC5D,eAAO,MAAM,kCAAkC,eAA4B,CAAC;AAC5E,eAAO,MAAM,kCAAkC,eAA4B,CAAC;AAE5E,eAAO,MAAM,uCAAuC,eAAuB,CAAC;AAE5E,eAAO,MAAM,kBAAkB,eAAoB,CAAC;AAEpD,eAAO,MAAM,oBAAoB,eAAiB,CAAC;AACnD,eAAO,MAAM,uBAAuB,eAAoB,CAAC;AAEzD,eAAO,MAAM,iBAAiB,eAAoB,CAAC;AACnD,eAAO,MAAM,oBAAoB,eAAuB,CAAC;AACzD,eAAO,MAAM,qBAAqB,eAAwB,CAAC;AAE3D,oBAAY,UAAU;IAClB,OAAO,IAAA;IACP,iBAAiB,IAAA;CACpB"}
1
+ {"version":3,"file":"Constants.d.ts","sourceRoot":"","sources":["../../../src/structures/decorators/Constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,eAAiB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ONS_KEY = exports.SELECT_MENU_OPTIONS_KEY = exports.SELECT_MENU_TYPE_KEY = exports.BUTTON_OPTIONS_KEY = exports.MESSAGE_COMPONENT_MODULE_COMPONENTS_KEY = exports.DISCORD_MODULE_EXTERNAL_EVENTS_KEY = exports.DISCORD_MODULE_INTERNAL_EVENTS_KEY = exports.DICSORD_MODULE_OPTIONS_KEY = exports.OPTIONS_PARAMETER_INDEX_KEY = exports.CONTEXT_MENU_TYPE_KEY = exports.COMMAND_SUBCOMMANDS_KEY = exports.COMMAND_SUBCOMMAND_GROUPS_KEY = exports.COMMAND_OPTIONS_KEY = exports.COMMAND_PRIVATE_GUILD_KEY = exports.COMMAND_PRIVATE_KEY = exports.COMMAND_DESCRIPTION_KEY = exports.COMMAND_NAME_KEY = exports.INTERACTION_TYPE_KEY = exports.INTERACTION_PARAMETER_INDEX_KEY = exports.INTERACTION_RUN_METHOD_KEY = exports.INTERACTION_INTEGRATION_TYPES_KEY = exports.COMMAND_MODULE_COMMANDS_KEY = exports.MODULE_TYPE_KEY = void 0;
3
+ exports.ModuleType = exports.MODAL_SELECT_MENU_VALUE_INDEX_KEY = exports.MODAL_TEXT_INPUT_VALUE_INDEX_KEY = exports.MODAL_COMPONENTS_KEY = exports.MODAL_OPTIONS_KEY = exports.SELECT_MENU_OPTIONS_KEY = exports.SELECT_MENU_TYPE_KEY = exports.BUTTON_OPTIONS_KEY = exports.MESSAGE_COMPONENT_MODULE_COMPONENTS_KEY = exports.DISCORD_MODULE_EXTERNAL_EVENTS_KEY = exports.DISCORD_MODULE_INTERNAL_EVENTS_KEY = exports.DICSORD_MODULE_OPTIONS_KEY = exports.OPTIONS_PARAMETER_INDEX_KEY = exports.CONTEXT_MENU_TYPE_KEY = exports.COMMAND_SUBCOMMANDS_KEY = exports.COMMAND_SUBCOMMAND_GROUPS_KEY = exports.COMMAND_OPTIONS_KEY = exports.COMMAND_PRIVATE_GUILD_KEY = exports.COMMAND_PRIVATE_KEY = exports.COMMAND_DESCRIPTION_KEY = exports.COMMAND_NAME_KEY = exports.INTERACTION_TYPE_KEY = exports.INTERACTION_PARAMETER_INDEX_KEY = exports.INTERACTION_RUN_METHOD_KEY = exports.INTERACTION_INTEGRATION_TYPES_KEY = exports.COMMAND_MODULE_COMMANDS_KEY = exports.MODULE_TYPE_KEY = void 0;
4
4
  exports.MODULE_TYPE_KEY = Symbol("type");
5
5
  exports.COMMAND_MODULE_COMMANDS_KEY = Symbol("commands");
6
6
  exports.INTERACTION_INTEGRATION_TYPES_KEY = Symbol("integration_types");
@@ -25,7 +25,8 @@ exports.SELECT_MENU_TYPE_KEY = Symbol("type");
25
25
  exports.SELECT_MENU_OPTIONS_KEY = Symbol("options");
26
26
  exports.MODAL_OPTIONS_KEY = Symbol("options");
27
27
  exports.MODAL_COMPONENTS_KEY = Symbol("components");
28
- exports.MODAL_FIELD_INDEX_KEY = Symbol("field_index");
28
+ exports.MODAL_TEXT_INPUT_VALUE_INDEX_KEY = Symbol("field_index");
29
+ exports.MODAL_SELECT_MENU_VALUE_INDEX_KEY = Symbol("field_index");
29
30
  var ModuleType;
30
31
  (function (ModuleType) {
31
32
  ModuleType[ModuleType["COMMAND"] = 0] = "COMMAND";
@@ -1,5 +1,6 @@
1
- import { ComponentEmojiResolvable } from "discord.js";
2
- import { ButtonStyle, TextInputStyle } from "discord-api-types/v10";
1
+ import { ActionRowBuilder, ComponentEmojiResolvable, LabelBuilder, ModalActionRowComponentBuilder, TextDisplayBuilder } from "discord.js";
2
+ import { ButtonStyle, ChannelType, TextInputStyle } from "discord-api-types/v10";
3
+ type DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;
3
4
  export type ButtonOptions = InteractionButtonOptions | LinkButtonOptions | PremiumButtonOptions;
4
5
  export type MessageComponentModuleOptions = {
5
6
  components: (new (...args: any[]) => any)[];
@@ -25,7 +26,7 @@ export type PremiumButtonOptions = {
25
26
  };
26
27
  export type BaseSelectMenuOptions = {
27
28
  customId: string;
28
- placeholder: string;
29
+ placeholder?: string;
29
30
  disabled?: boolean;
30
31
  minValues?: number;
31
32
  maxValues?: number;
@@ -43,6 +44,7 @@ export type UserSelectMenuOptions = BaseSelectMenuOptions & {
43
44
  };
44
45
  export type ChannelSelectMenuOptions = BaseSelectMenuOptions & {
45
46
  defaultChannels?: string[];
47
+ channelTypes?: ChannelType[];
46
48
  };
47
49
  export type RoleSelectMenuOptions = BaseSelectMenuOptions & {
48
50
  defaultRoles?: string[];
@@ -55,9 +57,9 @@ export type ModalOptions = {
55
57
  customId: string;
56
58
  title: string;
57
59
  };
58
- export type TextInputOptions = {
60
+ export type ModalTextInput = {
61
+ type: "text_input";
59
62
  customId: string;
60
- label: string;
61
63
  style: TextInputStyle;
62
64
  placeholder?: string;
63
65
  value?: string;
@@ -65,6 +67,42 @@ export type TextInputOptions = {
65
67
  minLength?: number;
66
68
  maxLength?: number;
67
69
  };
70
+ export type ModalStringSelect = StringSelectMenuOptions & {
71
+ type: "string_select";
72
+ };
73
+ export type ModalUserSelect = UserSelectMenuOptions & {
74
+ type: "user_select";
75
+ };
76
+ export type ModalChannelSelect = ChannelSelectMenuOptions & {
77
+ type: "channel_select";
78
+ };
79
+ export type ModalRoleSelect = RoleSelectMenuOptions & {
80
+ type: "role_select";
81
+ };
82
+ export type ModalMentionableSelect = MentionableSelectMenuOptions & {
83
+ type: "mentionable_select";
84
+ };
85
+ export type ModalFileUploadOptions = {
86
+ type: "file_upload";
87
+ customId: string;
88
+ minValues?: number;
89
+ maxValues?: number;
90
+ required?: boolean;
91
+ };
92
+ export type ModalTextDisplayOptions = {
93
+ content: string;
94
+ };
95
+ export type ModalLabelOptions = {
96
+ label: string;
97
+ description?: string;
98
+ component: ModalLabelComponent;
99
+ };
100
+ export type ModalComponentBuilder = ActionRowBuilder<ModalActionRowComponentBuilder> | LabelBuilder | TextDisplayBuilder;
101
+ type ModalComponentBase = ModalTextInput | ModalFileUploadOptions | ModalStringSelect | ModalUserSelect | ModalChannelSelect | ModalRoleSelect | ModalMentionableSelect;
102
+ export type ModalLabelComponent = DistributiveOmit<ModalComponentBase & {
103
+ required?: boolean;
104
+ disabled?: never;
105
+ }, "disabled">;
68
106
  export type FieldIndex = {
69
107
  index: number;
70
108
  customId: string;
@@ -77,6 +115,8 @@ export declare function ChannelSelectMenu(options: ChannelSelectMenuOptions): <T
77
115
  export declare function RoleSelectMenu(options: RoleSelectMenuOptions): <T extends Function>(constructor: T) => void;
78
116
  export declare function MentionableSelectMenu(options: MentionableSelectMenuOptions): <T extends Function>(constructor: T) => void;
79
117
  export declare function Modal(options: ModalOptions): <T extends Function>(constructor: T) => void;
80
- export declare function TextInput(options: TextInputOptions): <T extends Function>(constructor: T) => void;
118
+ export declare function ModalLabel(options: ModalLabelOptions): <T extends Function>(constructor: T) => void;
119
+ export declare function ModalTextDisplay(options: ModalTextDisplayOptions): <T extends Function>(constructor: T) => void;
81
120
  export declare function TextInputFieldInjection(customId: string): (target: Object, _propertyKey: string | symbol | undefined, parameterIndex: number) => void;
121
+ export {};
82
122
  //# sourceMappingURL=MessageComponentDecorator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MessageComponentDecorator.d.ts","sourceRoot":"","sources":["../../../src/structures/decorators/MessageComponentDecorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAA6E,MAAM,YAAY,CAAC;AACjI,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAIpE,MAAM,MAAM,aAAa,GAAG,wBAAwB,GAAG,iBAAiB,GAAG,oBAAoB,CAAC;AAChG,MAAM,MAAM,6BAA6B,GAAG;IAAE,UAAU,EAAE,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,EAAE,CAAA;CAAE,CAAA;AAC3F,MAAM,MAAM,wBAAwB,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MA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,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,IACzC,CAAC,SAAS,QAAQ,EAAE,aAAa,CAAC,UAKrD;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,IAC/C,CAAC,SAAS,QAAQ,EAAE,aAAa,CAAC,UAKrD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,IACzC,CAAC,SAAS,QAAQ,EAAE,aAAa,CAAC,UAKrD;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,IACvD,CAAC,SAAS,QAAQ,EAAE,aAAa,CAAC,UAKrD;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,YAAY,IACvB,CAAC,SAAS,QAAQ,EAAE,aAAa,CAAC,UAIrD;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,IACjC,CAAC,SAAS,QAAQ,EAAE,aAAa,CAAC,UA2GrD;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,IAC7C,CAAC,SAAS,QAAQ,EAAE,aAAa,CAAC,UAUrD;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,IACnC,QAAQ,MAAM,EAAE,cAAc,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,gBAAgB,MAAM,UAOrG"}
@@ -8,7 +8,8 @@ exports.ChannelSelectMenu = ChannelSelectMenu;
8
8
  exports.RoleSelectMenu = RoleSelectMenu;
9
9
  exports.MentionableSelectMenu = MentionableSelectMenu;
10
10
  exports.Modal = Modal;
11
- exports.TextInput = TextInput;
11
+ exports.ModalLabel = ModalLabel;
12
+ exports.ModalTextDisplay = ModalTextDisplay;
12
13
  exports.TextInputFieldInjection = TextInputFieldInjection;
13
14
  const discord_js_1 = require("discord.js");
14
15
  const _1 = require(".");
@@ -66,31 +67,135 @@ function Modal(options) {
66
67
  Reflect.defineMetadata(_1.MODAL_OPTIONS_KEY, options, constructor);
67
68
  };
68
69
  }
69
- function TextInput(options) {
70
+ function ModalLabel(options) {
70
71
  return function (constructor) {
71
72
  const components = Reflect.getMetadata(_1.MODAL_COMPONENTS_KEY, constructor) ?? [];
72
- const component = new discord_js_1.TextInputBuilder()
73
- .setCustomId(options.customId)
74
- .setLabel(options.label)
75
- .setStyle(options.style);
76
- if (options.placeholder)
77
- component.setPlaceholder(options.placeholder);
78
- if (options.value)
79
- component.setValue(options.value);
80
- if (options.required)
81
- component.setRequired(options.required);
82
- if (typeof options.minLength == 'number')
83
- component.setMinLength(options.minLength);
84
- if (typeof options.maxLength == 'number')
85
- component.setMaxLength(options.maxLength);
86
- components.push(component);
73
+ const label = new discord_js_1.LabelBuilder();
74
+ label.setLabel(options.label);
75
+ if (options.description)
76
+ label.setDescription(options.description);
77
+ const component = options.component;
78
+ switch (component.type) {
79
+ case "text_input":
80
+ const textInput = new discord_js_1.TextInputBuilder()
81
+ .setCustomId(component.customId)
82
+ .setStyle(component.style);
83
+ if ("placeholder" in component)
84
+ textInput.setPlaceholder(component.placeholder);
85
+ if ("value" in component)
86
+ textInput.setValue(component.value);
87
+ if ("minLength" in component)
88
+ textInput.setMinLength(component.minLength);
89
+ if ("maxLength" in component)
90
+ textInput.setMaxLength(component.maxLength);
91
+ if ("required" in component)
92
+ textInput.setRequired(component.required);
93
+ label.setTextInputComponent(textInput);
94
+ break;
95
+ case "string_select":
96
+ const selectMenu = new discord_js_1.StringSelectMenuBuilder()
97
+ .setCustomId(component.customId)
98
+ .addOptions(component.options);
99
+ if (component.placeholder)
100
+ selectMenu.setPlaceholder(component.placeholder);
101
+ if (typeof component.minValues == "number")
102
+ selectMenu.setMinValues(component.minValues);
103
+ if (typeof component.maxValues == "number")
104
+ selectMenu.setMaxValues(component.maxValues);
105
+ if ("required" in component)
106
+ selectMenu.setRequired(component.required);
107
+ label.setStringSelectMenuComponent(selectMenu);
108
+ break;
109
+ case "user_select":
110
+ const userSelectMenu = new discord_js_1.UserSelectMenuBuilder()
111
+ .setCustomId(component.customId);
112
+ if (component.placeholder)
113
+ userSelectMenu.setPlaceholder(component.placeholder);
114
+ if (typeof component.minValues == "number")
115
+ userSelectMenu.setMinValues(component.minValues);
116
+ if (typeof component.maxValues == "number")
117
+ userSelectMenu.setMaxValues(component.maxValues);
118
+ if (component && component.defaultUsers)
119
+ userSelectMenu.setDefaultUsers(component.defaultUsers);
120
+ if ("required" in component)
121
+ userSelectMenu.setRequired(component.required);
122
+ label.setUserSelectMenuComponent(userSelectMenu);
123
+ break;
124
+ case "channel_select":
125
+ const channelSelectMenu = new discord_js_1.ChannelSelectMenuBuilder()
126
+ .setCustomId(component.customId);
127
+ if (component.placeholder)
128
+ channelSelectMenu.setPlaceholder(component.placeholder);
129
+ if (typeof component.minValues == "number")
130
+ channelSelectMenu.setMinValues(component.minValues);
131
+ if (typeof component.maxValues == "number")
132
+ channelSelectMenu.setMaxValues(component.maxValues);
133
+ if (component && component.defaultChannels)
134
+ channelSelectMenu.setDefaultChannels(component.defaultChannels);
135
+ if (component.channelTypes)
136
+ channelSelectMenu.setChannelTypes(component.channelTypes);
137
+ if ("required" in component)
138
+ channelSelectMenu.setRequired(component.required);
139
+ label.setChannelSelectMenuComponent(channelSelectMenu);
140
+ break;
141
+ case "role_select":
142
+ const roleSelectMenu = new discord_js_1.RoleSelectMenuBuilder()
143
+ .setCustomId(component.customId);
144
+ if (component.placeholder)
145
+ roleSelectMenu.setPlaceholder(component.placeholder);
146
+ if (typeof component.minValues == "number")
147
+ roleSelectMenu.setMinValues(component.minValues);
148
+ if (typeof component.maxValues == "number")
149
+ roleSelectMenu.setMaxValues(component.maxValues);
150
+ if (component && component.defaultRoles)
151
+ roleSelectMenu.setDefaultRoles(component.defaultRoles);
152
+ if ("required" in component)
153
+ roleSelectMenu.setRequired(component.required);
154
+ label.setRoleSelectMenuComponent(roleSelectMenu);
155
+ break;
156
+ case "mentionable_select":
157
+ const mentionableSelectMenu = new discord_js_1.MentionableSelectMenuBuilder()
158
+ .setCustomId(component.customId);
159
+ if (component.placeholder)
160
+ mentionableSelectMenu.setPlaceholder(component.placeholder);
161
+ if (typeof component.minValues == "number")
162
+ mentionableSelectMenu.setMinValues(component.minValues);
163
+ if (typeof component.maxValues == "number")
164
+ mentionableSelectMenu.setMaxValues(component.maxValues);
165
+ if (component && component.defaultUsers)
166
+ mentionableSelectMenu.addDefaultUsers(component.defaultUsers);
167
+ if (component && component.defaultRoles)
168
+ mentionableSelectMenu.addDefaultRoles(component.defaultRoles);
169
+ if ("required" in component)
170
+ mentionableSelectMenu.setRequired(component.required);
171
+ label.setMentionableSelectMenuComponent(mentionableSelectMenu);
172
+ break;
173
+ case "file_upload":
174
+ const fileUpload = new discord_js_1.FileUploadBuilder()
175
+ .setCustomId(component.customId)
176
+ .setMinValues(component.minValues ?? 1)
177
+ .setMaxValues(component.maxValues ?? 1);
178
+ if ("required" in component)
179
+ fileUpload.setRequired(component.required);
180
+ label.setFileUploadComponent(fileUpload);
181
+ }
182
+ components.push(label);
183
+ Reflect.defineMetadata(_1.MODAL_COMPONENTS_KEY, components, constructor);
184
+ };
185
+ }
186
+ function ModalTextDisplay(options) {
187
+ return function (constructor) {
188
+ const components = Reflect.getMetadata(_1.MODAL_COMPONENTS_KEY, constructor) ?? [];
189
+ const textDisplay = new discord_js_1.TextDisplayBuilder()
190
+ .setContent(options.content);
191
+ components.push(textDisplay);
87
192
  Reflect.defineMetadata(_1.MODAL_COMPONENTS_KEY, components, constructor);
88
193
  };
89
194
  }
90
195
  function TextInputFieldInjection(customId) {
91
196
  return function (target, _propertyKey, parameterIndex) {
92
- const fields = Reflect.getMetadata(_1.MODAL_FIELD_INDEX_KEY, target) ?? [];
197
+ const fields = Reflect.getMetadata(_1.MODAL_TEXT_INPUT_VALUE_INDEX_KEY, target) ?? [];
93
198
  fields.push({ index: parameterIndex, customId });
94
- Reflect.defineMetadata(_1.MODAL_FIELD_INDEX_KEY, fields, target);
199
+ Reflect.defineMetadata(_1.MODAL_TEXT_INPUT_VALUE_INDEX_KEY, fields, target);
95
200
  };
96
201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oopscord.js",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "description": "An easy way to make discord apps in typescript.",
5
5
  "main": "dist",
6
6
  "scripts": {
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "^20.10.4",
33
- "discord.js": "^14.20.0",
33
+ "discord.js": "^14.25.1",
34
34
  "typescript": "^5.8.3",
35
35
  "yarn": "^1.22.21"
36
36
  }