@minesa-org/mini-interaction 0.0.14 → 0.0.15

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.
@@ -8,7 +8,6 @@ export type ChannelSelectMenuBuilderData = {
8
8
  minValues?: number;
9
9
  maxValues?: number;
10
10
  disabled?: boolean;
11
- required?: boolean;
12
11
  channelTypes?: ChannelType[];
13
12
  defaultValues?: APISelectMenuDefaultValue<SelectMenuDefaultValueType.Channel>[];
14
13
  };
@@ -39,10 +38,6 @@ export declare class ChannelSelectMenuBuilder implements JSONEncodable<APIChanne
39
38
  * Toggles whether the select menu is disabled.
40
39
  */
41
40
  setDisabled(disabled: boolean): this;
42
- /**
43
- * Marks the select menu as requiring at least the minimum number of selections.
44
- */
45
- setRequired(required: boolean): this;
46
41
  /**
47
42
  * Filters selectable channels by the provided channel types.
48
43
  */
@@ -12,7 +12,6 @@ export class ChannelSelectMenuBuilder {
12
12
  minValues: data.minValues,
13
13
  maxValues: data.maxValues,
14
14
  disabled: data.disabled,
15
- required: data.required,
16
15
  channelTypes: data.channelTypes
17
16
  ? [...data.channelTypes]
18
17
  : undefined,
@@ -59,13 +58,6 @@ export class ChannelSelectMenuBuilder {
59
58
  this.data.disabled = disabled;
60
59
  return this;
61
60
  }
62
- /**
63
- * Marks the select menu as requiring at least the minimum number of selections.
64
- */
65
- setRequired(required) {
66
- this.data.required = required;
67
- return this;
68
- }
69
61
  /**
70
62
  * Filters selectable channels by the provided channel types.
71
63
  */
@@ -98,7 +90,6 @@ export class ChannelSelectMenuBuilder {
98
90
  min_values: this.data.minValues,
99
91
  max_values: this.data.maxValues,
100
92
  disabled: this.data.disabled,
101
- required: this.data.required,
102
93
  channel_types: this.data.channelTypes
103
94
  ? [...this.data.channelTypes]
104
95
  : undefined,
@@ -0,0 +1,52 @@
1
+ import { SelectMenuDefaultValueType, type APIChannelSelectComponent, type APISelectMenuDefaultValue } from "discord-api-types/v10";
2
+ import type { JSONEncodable } from "./shared.js";
3
+ /** Shape describing initial modal channel select menu data accepted by the builder. */
4
+ export type ModalChannelSelectMenuBuilderData = {
5
+ customId?: string;
6
+ placeholder?: string;
7
+ minValues?: number;
8
+ maxValues?: number;
9
+ disabled?: boolean;
10
+ required?: boolean;
11
+ defaultValues?: APISelectMenuDefaultValue<SelectMenuDefaultValueType.Channel>[];
12
+ };
13
+ /** Builder for Discord channel select menu components in modals. */
14
+ export declare class ModalChannelSelectMenuBuilder implements JSONEncodable<APIChannelSelectComponent> {
15
+ private data;
16
+ /**
17
+ * Creates a new modal channel select menu builder with optional seed data.
18
+ */
19
+ constructor(data?: ModalChannelSelectMenuBuilderData);
20
+ /**
21
+ * Sets the unique custom identifier for the select menu interaction.
22
+ */
23
+ setCustomId(customId: string): this;
24
+ /**
25
+ * Sets or clears the placeholder text displayed when no channel is selected.
26
+ */
27
+ setPlaceholder(placeholder: string | null | undefined): this;
28
+ /**
29
+ * Sets the minimum number of channels that must be selected.
30
+ */
31
+ setMinValues(minValues: number | null | undefined): this;
32
+ /**
33
+ * Sets the maximum number of channels that can be selected.
34
+ */
35
+ setMaxValues(maxValues: number | null | undefined): this;
36
+ /**
37
+ * Toggles whether the select menu is disabled.
38
+ */
39
+ setDisabled(disabled: boolean): this;
40
+ /**
41
+ * Marks the select menu as required in the modal.
42
+ */
43
+ setRequired(required: boolean): this;
44
+ /**
45
+ * Replaces the default channel selections displayed when the menu renders.
46
+ */
47
+ setDefaultValues(defaultValues: Iterable<APISelectMenuDefaultValue<SelectMenuDefaultValueType.Channel>>): this;
48
+ /**
49
+ * Serialises the builder into an API compatible channel select menu payload.
50
+ */
51
+ toJSON(): APIChannelSelectComponent;
52
+ }
@@ -0,0 +1,98 @@
1
+ import { ComponentType, SelectMenuDefaultValueType, } from "discord-api-types/v10";
2
+ /** Builder for Discord channel select menu components in modals. */
3
+ export class ModalChannelSelectMenuBuilder {
4
+ data;
5
+ /**
6
+ * Creates a new modal channel select menu builder with optional seed data.
7
+ */
8
+ constructor(data = {}) {
9
+ this.data = {
10
+ customId: data.customId,
11
+ placeholder: data.placeholder,
12
+ minValues: data.minValues,
13
+ maxValues: data.maxValues,
14
+ disabled: data.disabled,
15
+ required: data.required,
16
+ defaultValues: data.defaultValues
17
+ ? data.defaultValues.map((value) => ({
18
+ ...value,
19
+ type: SelectMenuDefaultValueType.Channel,
20
+ }))
21
+ : undefined,
22
+ };
23
+ }
24
+ /**
25
+ * Sets the unique custom identifier for the select menu interaction.
26
+ */
27
+ setCustomId(customId) {
28
+ this.data.customId = customId;
29
+ return this;
30
+ }
31
+ /**
32
+ * Sets or clears the placeholder text displayed when no channel is selected.
33
+ */
34
+ setPlaceholder(placeholder) {
35
+ this.data.placeholder = placeholder ?? undefined;
36
+ return this;
37
+ }
38
+ /**
39
+ * Sets the minimum number of channels that must be selected.
40
+ */
41
+ setMinValues(minValues) {
42
+ this.data.minValues = minValues ?? undefined;
43
+ return this;
44
+ }
45
+ /**
46
+ * Sets the maximum number of channels that can be selected.
47
+ */
48
+ setMaxValues(maxValues) {
49
+ this.data.maxValues = maxValues ?? undefined;
50
+ return this;
51
+ }
52
+ /**
53
+ * Toggles whether the select menu is disabled.
54
+ */
55
+ setDisabled(disabled) {
56
+ this.data.disabled = disabled;
57
+ return this;
58
+ }
59
+ /**
60
+ * Marks the select menu as required in the modal.
61
+ */
62
+ setRequired(required) {
63
+ this.data.required = required;
64
+ return this;
65
+ }
66
+ /**
67
+ * Replaces the default channel selections displayed when the menu renders.
68
+ */
69
+ setDefaultValues(defaultValues) {
70
+ this.data.defaultValues = Array.from(defaultValues, (value) => ({
71
+ ...value,
72
+ type: SelectMenuDefaultValueType.Channel,
73
+ }));
74
+ return this;
75
+ }
76
+ /**
77
+ * Serialises the builder into an API compatible channel select menu payload.
78
+ */
79
+ toJSON() {
80
+ const { customId } = this.data;
81
+ if (!customId) {
82
+ throw new Error("[ModalChannelSelectMenuBuilder] custom id is required.");
83
+ }
84
+ return {
85
+ type: ComponentType.ChannelSelect,
86
+ custom_id: customId,
87
+ placeholder: this.data.placeholder,
88
+ min_values: this.data.minValues,
89
+ max_values: this.data.maxValues,
90
+ disabled: this.data.disabled,
91
+ required: this.data.required,
92
+ default_values: this.data.defaultValues?.map((value) => ({
93
+ ...value,
94
+ type: SelectMenuDefaultValueType.Channel,
95
+ })),
96
+ };
97
+ }
98
+ }
@@ -0,0 +1,52 @@
1
+ import { SelectMenuDefaultValueType, type APIMentionableSelectComponent, type APISelectMenuDefaultValue } from "discord-api-types/v10";
2
+ import type { JSONEncodable } from "./shared.js";
3
+ /** Shape describing initial modal mentionable select menu data accepted by the builder. */
4
+ export type ModalMentionableSelectMenuBuilderData = {
5
+ customId?: string;
6
+ placeholder?: string;
7
+ minValues?: number;
8
+ maxValues?: number;
9
+ disabled?: boolean;
10
+ required?: boolean;
11
+ defaultValues?: (APISelectMenuDefaultValue<SelectMenuDefaultValueType.User> | APISelectMenuDefaultValue<SelectMenuDefaultValueType.Role>)[];
12
+ };
13
+ /** Builder for Discord mentionable select menu components in modals. */
14
+ export declare class ModalMentionableSelectMenuBuilder implements JSONEncodable<APIMentionableSelectComponent> {
15
+ private data;
16
+ /**
17
+ * Creates a new modal mentionable select menu builder with optional seed data.
18
+ */
19
+ constructor(data?: ModalMentionableSelectMenuBuilderData);
20
+ /**
21
+ * Sets the unique custom identifier for the select menu interaction.
22
+ */
23
+ setCustomId(customId: string): this;
24
+ /**
25
+ * Sets or clears the placeholder text displayed when no mentionable is selected.
26
+ */
27
+ setPlaceholder(placeholder: string | null | undefined): this;
28
+ /**
29
+ * Sets the minimum number of mentionables that must be selected.
30
+ */
31
+ setMinValues(minValues: number | null | undefined): this;
32
+ /**
33
+ * Sets the maximum number of mentionables that can be selected.
34
+ */
35
+ setMaxValues(maxValues: number | null | undefined): this;
36
+ /**
37
+ * Toggles whether the select menu is disabled.
38
+ */
39
+ setDisabled(disabled: boolean): this;
40
+ /**
41
+ * Marks the select menu as required in the modal.
42
+ */
43
+ setRequired(required: boolean): this;
44
+ /**
45
+ * Replaces the default mentionable selections displayed when the menu renders.
46
+ */
47
+ setDefaultValues(defaultValues: Iterable<APISelectMenuDefaultValue<SelectMenuDefaultValueType.User> | APISelectMenuDefaultValue<SelectMenuDefaultValueType.Role>>): this;
48
+ /**
49
+ * Serialises the builder into an API compatible mentionable select menu payload.
50
+ */
51
+ toJSON(): APIMentionableSelectComponent;
52
+ }
@@ -0,0 +1,89 @@
1
+ import { ComponentType, } from "discord-api-types/v10";
2
+ /** Builder for Discord mentionable select menu components in modals. */
3
+ export class ModalMentionableSelectMenuBuilder {
4
+ data;
5
+ /**
6
+ * Creates a new modal mentionable select menu builder with optional seed data.
7
+ */
8
+ constructor(data = {}) {
9
+ this.data = {
10
+ customId: data.customId,
11
+ placeholder: data.placeholder,
12
+ minValues: data.minValues,
13
+ maxValues: data.maxValues,
14
+ disabled: data.disabled,
15
+ required: data.required,
16
+ defaultValues: data.defaultValues
17
+ ? [...data.defaultValues]
18
+ : undefined,
19
+ };
20
+ }
21
+ /**
22
+ * Sets the unique custom identifier for the select menu interaction.
23
+ */
24
+ setCustomId(customId) {
25
+ this.data.customId = customId;
26
+ return this;
27
+ }
28
+ /**
29
+ * Sets or clears the placeholder text displayed when no mentionable is selected.
30
+ */
31
+ setPlaceholder(placeholder) {
32
+ this.data.placeholder = placeholder ?? undefined;
33
+ return this;
34
+ }
35
+ /**
36
+ * Sets the minimum number of mentionables that must be selected.
37
+ */
38
+ setMinValues(minValues) {
39
+ this.data.minValues = minValues ?? undefined;
40
+ return this;
41
+ }
42
+ /**
43
+ * Sets the maximum number of mentionables that can be selected.
44
+ */
45
+ setMaxValues(maxValues) {
46
+ this.data.maxValues = maxValues ?? undefined;
47
+ return this;
48
+ }
49
+ /**
50
+ * Toggles whether the select menu is disabled.
51
+ */
52
+ setDisabled(disabled) {
53
+ this.data.disabled = disabled;
54
+ return this;
55
+ }
56
+ /**
57
+ * Marks the select menu as required in the modal.
58
+ */
59
+ setRequired(required) {
60
+ this.data.required = required;
61
+ return this;
62
+ }
63
+ /**
64
+ * Replaces the default mentionable selections displayed when the menu renders.
65
+ */
66
+ setDefaultValues(defaultValues) {
67
+ this.data.defaultValues = Array.from(defaultValues);
68
+ return this;
69
+ }
70
+ /**
71
+ * Serialises the builder into an API compatible mentionable select menu payload.
72
+ */
73
+ toJSON() {
74
+ const { customId } = this.data;
75
+ if (!customId) {
76
+ throw new Error("[ModalMentionableSelectMenuBuilder] custom id is required.");
77
+ }
78
+ return {
79
+ type: ComponentType.MentionableSelect,
80
+ custom_id: customId,
81
+ placeholder: this.data.placeholder,
82
+ min_values: this.data.minValues,
83
+ max_values: this.data.maxValues,
84
+ disabled: this.data.disabled,
85
+ required: this.data.required,
86
+ default_values: this.data.defaultValues,
87
+ };
88
+ }
89
+ }
@@ -0,0 +1,52 @@
1
+ import { SelectMenuDefaultValueType, type APIRoleSelectComponent, type APISelectMenuDefaultValue } from "discord-api-types/v10";
2
+ import type { JSONEncodable } from "./shared.js";
3
+ /** Shape describing initial modal role select menu data accepted by the builder. */
4
+ export type ModalRoleSelectMenuBuilderData = {
5
+ customId?: string;
6
+ placeholder?: string;
7
+ minValues?: number;
8
+ maxValues?: number;
9
+ disabled?: boolean;
10
+ required?: boolean;
11
+ defaultValues?: APISelectMenuDefaultValue<SelectMenuDefaultValueType.Role>[];
12
+ };
13
+ /** Builder for Discord role select menu components in modals. */
14
+ export declare class ModalRoleSelectMenuBuilder implements JSONEncodable<APIRoleSelectComponent> {
15
+ private data;
16
+ /**
17
+ * Creates a new modal role select menu builder with optional seed data.
18
+ */
19
+ constructor(data?: ModalRoleSelectMenuBuilderData);
20
+ /**
21
+ * Sets the unique custom identifier for the select menu interaction.
22
+ */
23
+ setCustomId(customId: string): this;
24
+ /**
25
+ * Sets or clears the placeholder text displayed when no role is selected.
26
+ */
27
+ setPlaceholder(placeholder: string | null | undefined): this;
28
+ /**
29
+ * Sets the minimum number of roles that must be selected.
30
+ */
31
+ setMinValues(minValues: number | null | undefined): this;
32
+ /**
33
+ * Sets the maximum number of roles that can be selected.
34
+ */
35
+ setMaxValues(maxValues: number | null | undefined): this;
36
+ /**
37
+ * Toggles whether the select menu is disabled.
38
+ */
39
+ setDisabled(disabled: boolean): this;
40
+ /**
41
+ * Marks the select menu as required in the modal.
42
+ */
43
+ setRequired(required: boolean): this;
44
+ /**
45
+ * Replaces the default role selections displayed when the menu renders.
46
+ */
47
+ setDefaultValues(defaultValues: Iterable<APISelectMenuDefaultValue<SelectMenuDefaultValueType.Role>>): this;
48
+ /**
49
+ * Serialises the builder into an API compatible role select menu payload.
50
+ */
51
+ toJSON(): APIRoleSelectComponent;
52
+ }
@@ -0,0 +1,98 @@
1
+ import { ComponentType, SelectMenuDefaultValueType, } from "discord-api-types/v10";
2
+ /** Builder for Discord role select menu components in modals. */
3
+ export class ModalRoleSelectMenuBuilder {
4
+ data;
5
+ /**
6
+ * Creates a new modal role select menu builder with optional seed data.
7
+ */
8
+ constructor(data = {}) {
9
+ this.data = {
10
+ customId: data.customId,
11
+ placeholder: data.placeholder,
12
+ minValues: data.minValues,
13
+ maxValues: data.maxValues,
14
+ disabled: data.disabled,
15
+ required: data.required,
16
+ defaultValues: data.defaultValues
17
+ ? data.defaultValues.map((value) => ({
18
+ ...value,
19
+ type: SelectMenuDefaultValueType.Role,
20
+ }))
21
+ : undefined,
22
+ };
23
+ }
24
+ /**
25
+ * Sets the unique custom identifier for the select menu interaction.
26
+ */
27
+ setCustomId(customId) {
28
+ this.data.customId = customId;
29
+ return this;
30
+ }
31
+ /**
32
+ * Sets or clears the placeholder text displayed when no role is selected.
33
+ */
34
+ setPlaceholder(placeholder) {
35
+ this.data.placeholder = placeholder ?? undefined;
36
+ return this;
37
+ }
38
+ /**
39
+ * Sets the minimum number of roles that must be selected.
40
+ */
41
+ setMinValues(minValues) {
42
+ this.data.minValues = minValues ?? undefined;
43
+ return this;
44
+ }
45
+ /**
46
+ * Sets the maximum number of roles that can be selected.
47
+ */
48
+ setMaxValues(maxValues) {
49
+ this.data.maxValues = maxValues ?? undefined;
50
+ return this;
51
+ }
52
+ /**
53
+ * Toggles whether the select menu is disabled.
54
+ */
55
+ setDisabled(disabled) {
56
+ this.data.disabled = disabled;
57
+ return this;
58
+ }
59
+ /**
60
+ * Marks the select menu as required in the modal.
61
+ */
62
+ setRequired(required) {
63
+ this.data.required = required;
64
+ return this;
65
+ }
66
+ /**
67
+ * Replaces the default role selections displayed when the menu renders.
68
+ */
69
+ setDefaultValues(defaultValues) {
70
+ this.data.defaultValues = Array.from(defaultValues, (value) => ({
71
+ ...value,
72
+ type: SelectMenuDefaultValueType.Role,
73
+ }));
74
+ return this;
75
+ }
76
+ /**
77
+ * Serialises the builder into an API compatible role select menu payload.
78
+ */
79
+ toJSON() {
80
+ const { customId } = this.data;
81
+ if (!customId) {
82
+ throw new Error("[ModalRoleSelectMenuBuilder] custom id is required.");
83
+ }
84
+ return {
85
+ type: ComponentType.RoleSelect,
86
+ custom_id: customId,
87
+ placeholder: this.data.placeholder,
88
+ min_values: this.data.minValues,
89
+ max_values: this.data.maxValues,
90
+ disabled: this.data.disabled,
91
+ required: this.data.required,
92
+ default_values: this.data.defaultValues?.map((value) => ({
93
+ ...value,
94
+ type: SelectMenuDefaultValueType.Role,
95
+ })),
96
+ };
97
+ }
98
+ }
@@ -0,0 +1,56 @@
1
+ import { type APISelectMenuOption, type APIStringSelectComponent } from "discord-api-types/v10";
2
+ import type { JSONEncodable } from "./shared.js";
3
+ /** Shape describing initial modal string select menu data accepted by the builder. */
4
+ export type ModalStringSelectMenuBuilderData = {
5
+ customId?: string;
6
+ placeholder?: string;
7
+ minValues?: number;
8
+ maxValues?: number;
9
+ disabled?: boolean;
10
+ required?: boolean;
11
+ options?: APISelectMenuOption[];
12
+ };
13
+ /** Builder for Discord string select menu components in modals. */
14
+ export declare class ModalStringSelectMenuBuilder implements JSONEncodable<APIStringSelectComponent> {
15
+ private data;
16
+ /**
17
+ * Creates a new modal string select menu builder with optional seed data.
18
+ */
19
+ constructor(data?: ModalStringSelectMenuBuilderData);
20
+ /**
21
+ * Sets the unique custom identifier for the select menu interaction.
22
+ */
23
+ setCustomId(customId: string): this;
24
+ /**
25
+ * Sets or clears the placeholder text displayed when no option is selected.
26
+ */
27
+ setPlaceholder(placeholder: string | null | undefined): this;
28
+ /**
29
+ * Sets the minimum number of options that must be selected.
30
+ */
31
+ setMinValues(minValues: number | null | undefined): this;
32
+ /**
33
+ * Sets the maximum number of options that can be selected.
34
+ */
35
+ setMaxValues(maxValues: number | null | undefined): this;
36
+ /**
37
+ * Toggles whether the select menu is disabled.
38
+ */
39
+ setDisabled(disabled: boolean): this;
40
+ /**
41
+ * Marks the select menu as required in the modal.
42
+ */
43
+ setRequired(required: boolean): this;
44
+ /**
45
+ * Adds an option to the select menu.
46
+ */
47
+ addOption(option: APISelectMenuOption): this;
48
+ /**
49
+ * Replaces all options in the select menu.
50
+ */
51
+ setOptions(options: Iterable<APISelectMenuOption>): this;
52
+ /**
53
+ * Serialises the builder into an API compatible string select menu payload.
54
+ */
55
+ toJSON(): APIStringSelectComponent;
56
+ }
@@ -0,0 +1,94 @@
1
+ import { ComponentType, } from "discord-api-types/v10";
2
+ /** Builder for Discord string select menu components in modals. */
3
+ export class ModalStringSelectMenuBuilder {
4
+ data;
5
+ /**
6
+ * Creates a new modal string select menu builder with optional seed data.
7
+ */
8
+ constructor(data = {}) {
9
+ this.data = {
10
+ customId: data.customId,
11
+ placeholder: data.placeholder,
12
+ minValues: data.minValues,
13
+ maxValues: data.maxValues,
14
+ disabled: data.disabled,
15
+ required: data.required,
16
+ options: data.options ? [...data.options] : [],
17
+ };
18
+ }
19
+ /**
20
+ * Sets the unique custom identifier for the select menu interaction.
21
+ */
22
+ setCustomId(customId) {
23
+ this.data.customId = customId;
24
+ return this;
25
+ }
26
+ /**
27
+ * Sets or clears the placeholder text displayed when no option is selected.
28
+ */
29
+ setPlaceholder(placeholder) {
30
+ this.data.placeholder = placeholder ?? undefined;
31
+ return this;
32
+ }
33
+ /**
34
+ * Sets the minimum number of options that must be selected.
35
+ */
36
+ setMinValues(minValues) {
37
+ this.data.minValues = minValues ?? undefined;
38
+ return this;
39
+ }
40
+ /**
41
+ * Sets the maximum number of options that can be selected.
42
+ */
43
+ setMaxValues(maxValues) {
44
+ this.data.maxValues = maxValues ?? undefined;
45
+ return this;
46
+ }
47
+ /**
48
+ * Toggles whether the select menu is disabled.
49
+ */
50
+ setDisabled(disabled) {
51
+ this.data.disabled = disabled;
52
+ return this;
53
+ }
54
+ /**
55
+ * Marks the select menu as required in the modal.
56
+ */
57
+ setRequired(required) {
58
+ this.data.required = required;
59
+ return this;
60
+ }
61
+ /**
62
+ * Adds an option to the select menu.
63
+ */
64
+ addOption(option) {
65
+ this.data.options.push(option);
66
+ return this;
67
+ }
68
+ /**
69
+ * Replaces all options in the select menu.
70
+ */
71
+ setOptions(options) {
72
+ this.data.options = Array.from(options);
73
+ return this;
74
+ }
75
+ /**
76
+ * Serialises the builder into an API compatible string select menu payload.
77
+ */
78
+ toJSON() {
79
+ const { customId } = this.data;
80
+ if (!customId) {
81
+ throw new Error("[ModalStringSelectMenuBuilder] custom id is required.");
82
+ }
83
+ return {
84
+ type: ComponentType.StringSelect,
85
+ custom_id: customId,
86
+ placeholder: this.data.placeholder,
87
+ min_values: this.data.minValues,
88
+ max_values: this.data.maxValues,
89
+ disabled: this.data.disabled,
90
+ required: this.data.required,
91
+ options: this.data.options,
92
+ };
93
+ }
94
+ }
@@ -0,0 +1,52 @@
1
+ import { SelectMenuDefaultValueType, type APIUserSelectComponent, type APISelectMenuDefaultValue } from "discord-api-types/v10";
2
+ import type { JSONEncodable } from "./shared.js";
3
+ /** Shape describing initial modal user select menu data accepted by the builder. */
4
+ export type ModalUserSelectMenuBuilderData = {
5
+ customId?: string;
6
+ placeholder?: string;
7
+ minValues?: number;
8
+ maxValues?: number;
9
+ disabled?: boolean;
10
+ required?: boolean;
11
+ defaultValues?: APISelectMenuDefaultValue<SelectMenuDefaultValueType.User>[];
12
+ };
13
+ /** Builder for Discord user select menu components in modals. */
14
+ export declare class ModalUserSelectMenuBuilder implements JSONEncodable<APIUserSelectComponent> {
15
+ private data;
16
+ /**
17
+ * Creates a new modal user select menu builder with optional seed data.
18
+ */
19
+ constructor(data?: ModalUserSelectMenuBuilderData);
20
+ /**
21
+ * Sets the unique custom identifier for the select menu interaction.
22
+ */
23
+ setCustomId(customId: string): this;
24
+ /**
25
+ * Sets or clears the placeholder text displayed when no user is selected.
26
+ */
27
+ setPlaceholder(placeholder: string | null | undefined): this;
28
+ /**
29
+ * Sets the minimum number of users that must be selected.
30
+ */
31
+ setMinValues(minValues: number | null | undefined): this;
32
+ /**
33
+ * Sets the maximum number of users that can be selected.
34
+ */
35
+ setMaxValues(maxValues: number | null | undefined): this;
36
+ /**
37
+ * Toggles whether the select menu is disabled.
38
+ */
39
+ setDisabled(disabled: boolean): this;
40
+ /**
41
+ * Marks the select menu as required in the modal.
42
+ */
43
+ setRequired(required: boolean): this;
44
+ /**
45
+ * Replaces the default user selections displayed when the menu renders.
46
+ */
47
+ setDefaultValues(defaultValues: Iterable<APISelectMenuDefaultValue<SelectMenuDefaultValueType.User>>): this;
48
+ /**
49
+ * Serialises the builder into an API compatible user select menu payload.
50
+ */
51
+ toJSON(): APIUserSelectComponent;
52
+ }
@@ -0,0 +1,98 @@
1
+ import { ComponentType, SelectMenuDefaultValueType, } from "discord-api-types/v10";
2
+ /** Builder for Discord user select menu components in modals. */
3
+ export class ModalUserSelectMenuBuilder {
4
+ data;
5
+ /**
6
+ * Creates a new modal user select menu builder with optional seed data.
7
+ */
8
+ constructor(data = {}) {
9
+ this.data = {
10
+ customId: data.customId,
11
+ placeholder: data.placeholder,
12
+ minValues: data.minValues,
13
+ maxValues: data.maxValues,
14
+ disabled: data.disabled,
15
+ required: data.required,
16
+ defaultValues: data.defaultValues
17
+ ? data.defaultValues.map((value) => ({
18
+ ...value,
19
+ type: SelectMenuDefaultValueType.User,
20
+ }))
21
+ : undefined,
22
+ };
23
+ }
24
+ /**
25
+ * Sets the unique custom identifier for the select menu interaction.
26
+ */
27
+ setCustomId(customId) {
28
+ this.data.customId = customId;
29
+ return this;
30
+ }
31
+ /**
32
+ * Sets or clears the placeholder text displayed when no user is selected.
33
+ */
34
+ setPlaceholder(placeholder) {
35
+ this.data.placeholder = placeholder ?? undefined;
36
+ return this;
37
+ }
38
+ /**
39
+ * Sets the minimum number of users that must be selected.
40
+ */
41
+ setMinValues(minValues) {
42
+ this.data.minValues = minValues ?? undefined;
43
+ return this;
44
+ }
45
+ /**
46
+ * Sets the maximum number of users that can be selected.
47
+ */
48
+ setMaxValues(maxValues) {
49
+ this.data.maxValues = maxValues ?? undefined;
50
+ return this;
51
+ }
52
+ /**
53
+ * Toggles whether the select menu is disabled.
54
+ */
55
+ setDisabled(disabled) {
56
+ this.data.disabled = disabled;
57
+ return this;
58
+ }
59
+ /**
60
+ * Marks the select menu as required in the modal.
61
+ */
62
+ setRequired(required) {
63
+ this.data.required = required;
64
+ return this;
65
+ }
66
+ /**
67
+ * Replaces the default user selections displayed when the menu renders.
68
+ */
69
+ setDefaultValues(defaultValues) {
70
+ this.data.defaultValues = Array.from(defaultValues, (value) => ({
71
+ ...value,
72
+ type: SelectMenuDefaultValueType.User,
73
+ }));
74
+ return this;
75
+ }
76
+ /**
77
+ * Serialises the builder into an API compatible user select menu payload.
78
+ */
79
+ toJSON() {
80
+ const { customId } = this.data;
81
+ if (!customId) {
82
+ throw new Error("[ModalUserSelectMenuBuilder] custom id is required.");
83
+ }
84
+ return {
85
+ type: ComponentType.UserSelect,
86
+ custom_id: customId,
87
+ placeholder: this.data.placeholder,
88
+ min_values: this.data.minValues,
89
+ max_values: this.data.maxValues,
90
+ disabled: this.data.disabled,
91
+ required: this.data.required,
92
+ default_values: this.data.defaultValues?.map((value) => ({
93
+ ...value,
94
+ type: SelectMenuDefaultValueType.User,
95
+ })),
96
+ };
97
+ }
98
+ }
@@ -7,7 +7,6 @@ export type RoleSelectMenuBuilderData = {
7
7
  minValues?: number;
8
8
  maxValues?: number;
9
9
  disabled?: boolean;
10
- required?: boolean;
11
10
  defaultValues?: APISelectMenuDefaultValue<SelectMenuDefaultValueType.Role>[];
12
11
  };
13
12
  /** Builder for Discord role select menu components. */
@@ -37,10 +36,6 @@ export declare class RoleSelectMenuBuilder implements JSONEncodable<APIRoleSelec
37
36
  * Toggles whether the select menu is disabled.
38
37
  */
39
38
  setDisabled(disabled: boolean): this;
40
- /**
41
- * Marks the select menu as requiring at least the minimum number of selections.
42
- */
43
- setRequired(required: boolean): this;
44
39
  /**
45
40
  * Replaces the default role selections displayed when the menu renders.
46
41
  */
@@ -12,7 +12,6 @@ export class RoleSelectMenuBuilder {
12
12
  minValues: data.minValues,
13
13
  maxValues: data.maxValues,
14
14
  disabled: data.disabled,
15
- required: data.required,
16
15
  defaultValues: data.defaultValues
17
16
  ? data.defaultValues.map((value) => ({
18
17
  ...value,
@@ -56,13 +55,6 @@ export class RoleSelectMenuBuilder {
56
55
  this.data.disabled = disabled;
57
56
  return this;
58
57
  }
59
- /**
60
- * Marks the select menu as requiring at least the minimum number of selections.
61
- */
62
- setRequired(required) {
63
- this.data.required = required;
64
- return this;
65
- }
66
58
  /**
67
59
  * Replaces the default role selections displayed when the menu renders.
68
60
  */
@@ -88,7 +80,6 @@ export class RoleSelectMenuBuilder {
88
80
  min_values: this.data.minValues,
89
81
  max_values: this.data.maxValues,
90
82
  disabled: this.data.disabled,
91
- required: this.data.required,
92
83
  default_values: this.data.defaultValues?.map((value) => ({
93
84
  ...value,
94
85
  type: SelectMenuDefaultValueType.Role,
@@ -7,7 +7,6 @@ export type StringSelectMenuBuilderData = {
7
7
  minValues?: number;
8
8
  maxValues?: number;
9
9
  disabled?: boolean;
10
- required?: boolean;
11
10
  options?: APISelectMenuOption[];
12
11
  };
13
12
  /** Builder for Discord string select menu components. */
@@ -37,10 +36,6 @@ export declare class StringSelectMenuBuilder implements JSONEncodable<APIStringS
37
36
  * Toggles whether the select menu is disabled.
38
37
  */
39
38
  setDisabled(disabled: boolean): this;
40
- /**
41
- * Marks the select menu options as required.
42
- */
43
- setRequired(required: boolean): this;
44
39
  /**
45
40
  * Appends new option entries to the select menu.
46
41
  */
@@ -12,7 +12,6 @@ export class StringSelectMenuBuilder {
12
12
  minValues: data.minValues,
13
13
  maxValues: data.maxValues,
14
14
  disabled: data.disabled,
15
- required: data.required,
16
15
  options: data.options ? [...data.options] : [],
17
16
  };
18
17
  }
@@ -51,13 +50,6 @@ export class StringSelectMenuBuilder {
51
50
  this.data.disabled = disabled;
52
51
  return this;
53
52
  }
54
- /**
55
- * Marks the select menu options as required.
56
- */
57
- setRequired(required) {
58
- this.data.required = required;
59
- return this;
60
- }
61
53
  /**
62
54
  * Appends new option entries to the select menu.
63
55
  */
@@ -93,7 +85,6 @@ export class StringSelectMenuBuilder {
93
85
  min_values: this.data.minValues,
94
86
  max_values: this.data.maxValues,
95
87
  disabled: this.data.disabled,
96
- required: this.data.required,
97
88
  options: options.map((option) => ({ ...option })),
98
89
  };
99
90
  }
@@ -9,6 +9,16 @@ export { RoleSelectMenuBuilder } from "./RoleSelectMenuBuilder.js";
9
9
  export type { RoleSelectMenuBuilderData } from "./RoleSelectMenuBuilder.js";
10
10
  export { ChannelSelectMenuBuilder } from "./ChannelSelectMenuBuilder.js";
11
11
  export type { ChannelSelectMenuBuilderData } from "./ChannelSelectMenuBuilder.js";
12
+ export { ModalStringSelectMenuBuilder } from "./ModalStringSelectMenuBuilder.js";
13
+ export type { ModalStringSelectMenuBuilderData } from "./ModalStringSelectMenuBuilder.js";
14
+ export { ModalRoleSelectMenuBuilder } from "./ModalRoleSelectMenuBuilder.js";
15
+ export type { ModalRoleSelectMenuBuilderData } from "./ModalRoleSelectMenuBuilder.js";
16
+ export { ModalUserSelectMenuBuilder } from "./ModalUserSelectMenuBuilder.js";
17
+ export type { ModalUserSelectMenuBuilderData } from "./ModalUserSelectMenuBuilder.js";
18
+ export { ModalChannelSelectMenuBuilder } from "./ModalChannelSelectMenuBuilder.js";
19
+ export type { ModalChannelSelectMenuBuilderData } from "./ModalChannelSelectMenuBuilder.js";
20
+ export { ModalMentionableSelectMenuBuilder } from "./ModalMentionableSelectMenuBuilder.js";
21
+ export type { ModalMentionableSelectMenuBuilderData } from "./ModalMentionableSelectMenuBuilder.js";
12
22
  export { ModalBuilder } from "./ModalBuilder.js";
13
23
  export type { ModalBuilderData, ModalComponentLike } from "./ModalBuilder.js";
14
24
  export { TextInputBuilder } from "./TextInputBuilder.js";
@@ -4,6 +4,11 @@ export { ButtonBuilder } from "./ButtonBuilder.js";
4
4
  export { StringSelectMenuBuilder } from "./StringSelectMenuBuilder.js";
5
5
  export { RoleSelectMenuBuilder } from "./RoleSelectMenuBuilder.js";
6
6
  export { ChannelSelectMenuBuilder } from "./ChannelSelectMenuBuilder.js";
7
+ export { ModalStringSelectMenuBuilder } from "./ModalStringSelectMenuBuilder.js";
8
+ export { ModalRoleSelectMenuBuilder } from "./ModalRoleSelectMenuBuilder.js";
9
+ export { ModalUserSelectMenuBuilder } from "./ModalUserSelectMenuBuilder.js";
10
+ export { ModalChannelSelectMenuBuilder } from "./ModalChannelSelectMenuBuilder.js";
11
+ export { ModalMentionableSelectMenuBuilder } from "./ModalMentionableSelectMenuBuilder.js";
7
12
  export { ModalBuilder } from "./ModalBuilder.js";
8
13
  export { TextInputBuilder } from "./TextInputBuilder.js";
9
14
  export { LabelBuilder } from "./LabelBuilder.js";
@@ -201,11 +201,22 @@ export declare class MiniInteraction {
201
201
  private isSupportedModuleFile;
202
202
  /**
203
203
  * Dynamically imports and validates a command module from disk.
204
+ * Supports multiple export patterns:
205
+ * - export default { data, handler }
206
+ * - export const command = { data, handler }
207
+ * - export const ping_command = { data, handler }
208
+ * - export const data = ...; export const handler = ...;
204
209
  */
205
210
  private importCommandModule;
206
211
  /**
207
212
  * Dynamically imports and validates a component module from disk.
208
213
  * Also handles modal components if they're in a "modals" subdirectory.
214
+ * Supports multiple export patterns:
215
+ * - export default { customId, handler }
216
+ * - export const component = { customId, handler }
217
+ * - export const ping_button = { customId, handler }
218
+ * - export const customId = "..."; export const handler = ...;
219
+ * - export const components = [{ customId, handler }, ...]
209
220
  */
210
221
  private importComponentModule;
211
222
  /**
@@ -515,15 +515,44 @@ export class MiniInteraction {
515
515
  }
516
516
  /**
517
517
  * Dynamically imports and validates a command module from disk.
518
+ * Supports multiple export patterns:
519
+ * - export default { data, handler }
520
+ * - export const command = { data, handler }
521
+ * - export const ping_command = { data, handler }
522
+ * - export const data = ...; export const handler = ...;
518
523
  */
519
524
  async importCommandModule(absolutePath) {
520
525
  try {
521
526
  const moduleUrl = pathToFileURL(absolutePath).href;
522
527
  const imported = await import(moduleUrl);
523
- const candidate = imported.default ??
528
+ // Try to find a command object from various export patterns
529
+ let candidate = imported.default ??
524
530
  imported.command ??
525
- imported.commandDefinition ??
526
- imported;
531
+ imported.commandDefinition;
532
+ // If not found, look for named exports ending with "_command"
533
+ if (!candidate) {
534
+ for (const [key, value] of Object.entries(imported)) {
535
+ if (key.endsWith("_command") &&
536
+ typeof value === "object" &&
537
+ value !== null) {
538
+ candidate = value;
539
+ break;
540
+ }
541
+ }
542
+ }
543
+ // If still not found, try to construct from separate data/handler exports
544
+ if (!candidate) {
545
+ if (imported.data && imported.handler) {
546
+ candidate = {
547
+ data: imported.data,
548
+ handler: imported.handler,
549
+ };
550
+ }
551
+ else {
552
+ // Last resort: use the entire module
553
+ candidate = imported;
554
+ }
555
+ }
527
556
  if (!candidate || typeof candidate !== "object") {
528
557
  console.warn(`[MiniInteraction] Command module "${absolutePath}" does not export a command object. Skipping.`);
529
558
  return null;
@@ -547,21 +576,55 @@ export class MiniInteraction {
547
576
  /**
548
577
  * Dynamically imports and validates a component module from disk.
549
578
  * Also handles modal components if they're in a "modals" subdirectory.
579
+ * Supports multiple export patterns:
580
+ * - export default { customId, handler }
581
+ * - export const component = { customId, handler }
582
+ * - export const ping_button = { customId, handler }
583
+ * - export const customId = "..."; export const handler = ...;
584
+ * - export const components = [{ customId, handler }, ...]
550
585
  */
551
586
  async importComponentModule(absolutePath) {
552
587
  try {
553
588
  const moduleUrl = pathToFileURL(absolutePath).href;
554
589
  const imported = await import(moduleUrl);
555
- const candidate = imported.default ??
590
+ // Collect all potential component candidates
591
+ const candidates = [];
592
+ // Try standard exports first
593
+ const standardExport = imported.default ??
556
594
  imported.component ??
557
595
  imported.components ??
558
596
  imported.componentDefinition ??
559
597
  imported.modal ??
560
- imported.modals ??
561
- imported;
562
- const candidates = Array.isArray(candidate)
563
- ? candidate
564
- : [candidate];
598
+ imported.modals;
599
+ if (standardExport) {
600
+ if (Array.isArray(standardExport)) {
601
+ candidates.push(...standardExport);
602
+ }
603
+ else {
604
+ candidates.push(standardExport);
605
+ }
606
+ }
607
+ // Look for named exports ending with "_button", "_select", "_modal", etc.
608
+ for (const [key, value] of Object.entries(imported)) {
609
+ if ((key.endsWith("_button") ||
610
+ key.endsWith("_select") ||
611
+ key.endsWith("_modal") ||
612
+ key.endsWith("_component")) &&
613
+ typeof value === "object" &&
614
+ value !== null &&
615
+ !candidates.includes(value)) {
616
+ candidates.push(value);
617
+ }
618
+ }
619
+ // If no candidates found, try to construct from separate customId/handler exports
620
+ if (candidates.length === 0) {
621
+ if (imported.customId && imported.handler) {
622
+ candidates.push({
623
+ customId: imported.customId,
624
+ handler: imported.handler,
625
+ });
626
+ }
627
+ }
565
628
  const components = [];
566
629
  // Check if this file is in a "modals" subdirectory
567
630
  const isModalFile = absolutePath.includes(path.sep + "modals" + path.sep) ||
@@ -30,49 +30,49 @@ type BaseComponentInteractionHelpers = {
30
30
  * Button interaction with helper methods.
31
31
  * Buttons don't have values or resolved data.
32
32
  */
33
- export type ButtonInteraction = Omit<APIMessageComponentInteraction, "data"> & {
33
+ export interface ButtonInteraction extends Omit<APIMessageComponentInteraction, "data">, BaseComponentInteractionHelpers {
34
34
  data: APIMessageButtonInteractionData;
35
- } & BaseComponentInteractionHelpers;
35
+ }
36
36
  /**
37
37
  * String select menu interaction with helper methods.
38
38
  */
39
- export type StringSelectInteraction = Omit<APIMessageComponentInteraction, "data"> & {
39
+ export interface StringSelectInteraction extends Omit<APIMessageComponentInteraction, "data">, BaseComponentInteractionHelpers {
40
40
  data: APIMessageStringSelectInteractionData;
41
41
  values: string[];
42
42
  getStringValues: () => string[];
43
- } & BaseComponentInteractionHelpers;
43
+ }
44
44
  /**
45
45
  * Role select menu interaction with helper methods.
46
46
  */
47
- export type RoleSelectInteraction = Omit<APIMessageComponentInteraction, "data"> & {
47
+ export interface RoleSelectInteraction extends Omit<APIMessageComponentInteraction, "data">, BaseComponentInteractionHelpers {
48
48
  data: APIMessageRoleSelectInteractionData;
49
49
  values: string[];
50
50
  getRoles: () => APIRole[];
51
- } & BaseComponentInteractionHelpers;
51
+ }
52
52
  /**
53
53
  * User select menu interaction with helper methods.
54
54
  */
55
- export type UserSelectInteraction = Omit<APIMessageComponentInteraction, "data"> & {
55
+ export interface UserSelectInteraction extends Omit<APIMessageComponentInteraction, "data">, BaseComponentInteractionHelpers {
56
56
  data: APIMessageUserSelectInteractionData;
57
57
  values: string[];
58
58
  getUsers: () => ResolvedUserOption[];
59
- } & BaseComponentInteractionHelpers;
59
+ }
60
60
  /**
61
61
  * Channel select menu interaction with helper methods.
62
62
  */
63
- export type ChannelSelectInteraction = Omit<APIMessageComponentInteraction, "data"> & {
63
+ export interface ChannelSelectInteraction extends Omit<APIMessageComponentInteraction, "data">, BaseComponentInteractionHelpers {
64
64
  data: APIMessageChannelSelectInteractionData;
65
65
  values: string[];
66
66
  getChannels: () => APIInteractionDataResolvedChannel[];
67
- } & BaseComponentInteractionHelpers;
67
+ }
68
68
  /**
69
69
  * Mentionable select menu interaction with helper methods.
70
70
  */
71
- export type MentionableSelectInteraction = Omit<APIMessageComponentInteraction, "data"> & {
71
+ export interface MentionableSelectInteraction extends Omit<APIMessageComponentInteraction, "data">, BaseComponentInteractionHelpers {
72
72
  data: APIMessageMentionableSelectInteractionData;
73
73
  values: string[];
74
74
  getMentionables: () => ResolvedMentionableOption[];
75
- } & BaseComponentInteractionHelpers;
75
+ }
76
76
  /**
77
77
  * Represents a component interaction augmented with helper response methods.
78
78
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minesa-org/mini-interaction",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "description": "Mini interaction, connecting your app with Discord via HTTP-interaction (Vercel support).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",