@minesa-org/mini-interaction 0.0.13 → 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.
- package/dist/builders/ChannelSelectMenuBuilder.d.ts +0 -5
- package/dist/builders/ChannelSelectMenuBuilder.js +0 -9
- package/dist/builders/ModalChannelSelectMenuBuilder.d.ts +52 -0
- package/dist/builders/ModalChannelSelectMenuBuilder.js +98 -0
- package/dist/builders/ModalMentionableSelectMenuBuilder.d.ts +52 -0
- package/dist/builders/ModalMentionableSelectMenuBuilder.js +89 -0
- package/dist/builders/ModalRoleSelectMenuBuilder.d.ts +52 -0
- package/dist/builders/ModalRoleSelectMenuBuilder.js +98 -0
- package/dist/builders/ModalStringSelectMenuBuilder.d.ts +56 -0
- package/dist/builders/ModalStringSelectMenuBuilder.js +94 -0
- package/dist/builders/ModalUserSelectMenuBuilder.d.ts +52 -0
- package/dist/builders/ModalUserSelectMenuBuilder.js +98 -0
- package/dist/builders/RoleSelectMenuBuilder.d.ts +0 -5
- package/dist/builders/RoleSelectMenuBuilder.js +0 -9
- package/dist/builders/StringSelectMenuBuilder.d.ts +0 -5
- package/dist/builders/StringSelectMenuBuilder.js +0 -9
- package/dist/builders/index.d.ts +10 -0
- package/dist/builders/index.js +5 -0
- package/dist/clients/MiniInteraction.d.ts +11 -0
- package/dist/clients/MiniInteraction.js +88 -10
- package/dist/index.d.ts +1 -0
- package/dist/types/Commands.d.ts +4 -3
- package/dist/utils/ContextMenuInteraction.d.ts +36 -0
- package/dist/utils/ContextMenuInteraction.js +94 -0
- package/dist/utils/MessageComponentInteraction.d.ts +12 -12
- package/package.json +1 -1
|
@@ -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
|
+
}
|