@minesa-org/mini-interaction 0.0.1

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 (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +3 -0
  3. package/dist/builders/ActionRowBuilder.d.ts +25 -0
  4. package/dist/builders/ActionRowBuilder.js +35 -0
  5. package/dist/builders/ButtonBuilder.d.ts +53 -0
  6. package/dist/builders/ButtonBuilder.js +124 -0
  7. package/dist/builders/ChannelSelectMenuBuilder.d.ts +58 -0
  8. package/dist/builders/ChannelSelectMenuBuilder.js +111 -0
  9. package/dist/builders/ModalBuilder.d.ts +40 -0
  10. package/dist/builders/ModalBuilder.js +65 -0
  11. package/dist/builders/RoleSelectMenuBuilder.d.ts +52 -0
  12. package/dist/builders/RoleSelectMenuBuilder.js +98 -0
  13. package/dist/builders/StringSelectMenuBuilder.d.ts +56 -0
  14. package/dist/builders/StringSelectMenuBuilder.js +100 -0
  15. package/dist/builders/index.d.ts +14 -0
  16. package/dist/builders/index.js +7 -0
  17. package/dist/builders/shared.d.ts +8 -0
  18. package/dist/builders/shared.js +11 -0
  19. package/dist/clients/MiniInteraction.d.ts +176 -0
  20. package/dist/clients/MiniInteraction.js +578 -0
  21. package/dist/commands/CommandBuilder.d.ts +278 -0
  22. package/dist/commands/CommandBuilder.js +687 -0
  23. package/dist/index.d.ts +16 -0
  24. package/dist/index.js +9 -0
  25. package/dist/types/ButtonStyle.d.ts +16 -0
  26. package/dist/types/ButtonStyle.js +17 -0
  27. package/dist/types/ChannelType.d.ts +2 -0
  28. package/dist/types/ChannelType.js +2 -0
  29. package/dist/types/Commands.d.ts +11 -0
  30. package/dist/types/Commands.js +1 -0
  31. package/dist/types/ComponentTypes.d.ts +5 -0
  32. package/dist/types/ComponentTypes.js +1 -0
  33. package/dist/types/InteractionFlags.d.ts +10 -0
  34. package/dist/types/InteractionFlags.js +12 -0
  35. package/dist/types/RoleConnectionMetadataTypes.d.ts +11 -0
  36. package/dist/types/RoleConnectionMetadataTypes.js +12 -0
  37. package/dist/utils/CommandInteractionOptions.d.ts +143 -0
  38. package/dist/utils/CommandInteractionOptions.js +376 -0
  39. package/dist/utils/MessageComponentInteraction.d.ts +19 -0
  40. package/dist/utils/MessageComponentInteraction.js +60 -0
  41. package/dist/utils/constants.d.ts +16 -0
  42. package/dist/utils/constants.js +16 -0
  43. package/dist/utils/interactionMessageHelpers.d.ts +30 -0
  44. package/dist/utils/interactionMessageHelpers.js +32 -0
  45. package/package.json +50 -0
@@ -0,0 +1,278 @@
1
+ import { ChannelType, type APIApplicationCommandAttachmentOption, type APIApplicationCommandBasicOption, type APIApplicationCommandChannelOption, type APIApplicationCommandMentionableOption, type APIApplicationCommandNumberOption, type APIApplicationCommandOption, type APIApplicationCommandOptionChoice, type APIApplicationCommandRoleOption, type APIApplicationCommandStringOption, type APIApplicationCommandSubcommandGroupOption, type APIApplicationCommandSubcommandOption, type APIApplicationCommandUserOption, type LocalizationMap, type Permissions, type RESTPostAPIChatInputApplicationCommandsJSONBody } from "discord-api-types/v10";
2
+ /** Supported integration types for Discord application commands. */
3
+ export declare enum IntegrationType {
4
+ GuildInstall = 0,
5
+ UserInstall = 1
6
+ }
7
+ /** Supported contexts where a command can be invoked. */
8
+ export declare enum CommandContext {
9
+ Guild = 0,
10
+ Bot = 1,
11
+ DM = 2
12
+ }
13
+ /**
14
+ * Provides shared builder utilities for application command option definitions.
15
+ */
16
+ declare abstract class BaseOptionBuilder<Data extends APIApplicationCommandOption> {
17
+ protected readonly data: Data;
18
+ /**
19
+ * Creates a new option builder wrapper around an underlying option payload.
20
+ */
21
+ protected constructor(data: Data);
22
+ /**
23
+ * Sets the option name while validating Discord's requirements.
24
+ */
25
+ setName(name: string): this;
26
+ /**
27
+ * Sets localized translations for the option name.
28
+ */
29
+ setNameLocalizations(localizations: LocalizationMap | null): this;
30
+ /**
31
+ * Sets the option description while validating Discord's length requirements.
32
+ */
33
+ setDescription(description: string): this;
34
+ /**
35
+ * Sets localized translations for the option description.
36
+ */
37
+ setDescriptionLocalizations(localizations: LocalizationMap | null): this;
38
+ /**
39
+ * Produces a deep copy of the built option payload for safe reuse.
40
+ */
41
+ toJSON(): Data;
42
+ }
43
+ /**
44
+ * Extends {@link BaseOptionBuilder} with helpers specific to basic command options.
45
+ */
46
+ declare abstract class BaseCommandOptionBuilder<Data extends APIApplicationCommandBasicOption> extends BaseOptionBuilder<Data> {
47
+ /**
48
+ * Marks the option as required within its parent context.
49
+ */
50
+ setRequired(required?: boolean): this;
51
+ }
52
+ /** Builder for attachment command options. */
53
+ declare class AttachmentOptionBuilder extends BaseCommandOptionBuilder<APIApplicationCommandAttachmentOption> {
54
+ constructor();
55
+ }
56
+ /** Builder for user command options. */
57
+ declare class UserOptionBuilder extends BaseCommandOptionBuilder<APIApplicationCommandUserOption> {
58
+ constructor();
59
+ }
60
+ /** Builder for role command options. */
61
+ declare class RoleOptionBuilder extends BaseCommandOptionBuilder<APIApplicationCommandRoleOption> {
62
+ constructor();
63
+ }
64
+ /** Builder for mentionable command options. */
65
+ declare class MentionableOptionBuilder extends BaseCommandOptionBuilder<APIApplicationCommandMentionableOption> {
66
+ constructor();
67
+ }
68
+ /** Builder for channel command options with channel type filtering support. */
69
+ declare class ChannelOptionBuilder extends BaseCommandOptionBuilder<APIApplicationCommandChannelOption> {
70
+ constructor();
71
+ /**
72
+ * Limits selectable channels to the provided channel types.
73
+ */
74
+ addChannelTypes(...channelTypes: ChannelType[]): this;
75
+ }
76
+ /** Builder for string command options, including choice and autocomplete support. */
77
+ declare class StringOptionBuilder extends BaseCommandOptionBuilder<APIApplicationCommandStringOption> {
78
+ constructor();
79
+ /**
80
+ * Adds a single choice option for the string command option.
81
+ */
82
+ addChoice(name: string, value: string): this;
83
+ /**
84
+ * Adds multiple choice entries for the string command option.
85
+ */
86
+ addChoices(...choices: APIApplicationCommandOptionChoice<string>[]): this;
87
+ /**
88
+ * Replaces the existing choice set with the provided entries.
89
+ */
90
+ setChoices(...choices: APIApplicationCommandOptionChoice<string>[]): this;
91
+ /**
92
+ * Enables or disables autocomplete for the string option.
93
+ */
94
+ setAutocomplete(autocomplete?: boolean): this;
95
+ /**
96
+ * Sets the minimum string length accepted for the option value.
97
+ */
98
+ setMinLength(minLength: number): this;
99
+ /**
100
+ * Sets the maximum string length accepted for the option value.
101
+ */
102
+ setMaxLength(maxLength: number): this;
103
+ }
104
+ /** Builder for numeric command options with choice and range support. */
105
+ declare class NumberOptionBuilder extends BaseCommandOptionBuilder<APIApplicationCommandNumberOption> {
106
+ constructor();
107
+ /**
108
+ * Adds a single numeric choice for the option.
109
+ */
110
+ addChoice(name: string, value: number): this;
111
+ /**
112
+ * Adds multiple numeric choice entries for the option.
113
+ */
114
+ addChoices(...choices: APIApplicationCommandOptionChoice<number>[]): this;
115
+ /**
116
+ * Replaces the current choice set with the provided entries.
117
+ */
118
+ setChoices(...choices: APIApplicationCommandOptionChoice<number>[]): this;
119
+ /**
120
+ * Enables or disables autocomplete for the numeric option.
121
+ */
122
+ setAutocomplete(autocomplete?: boolean): this;
123
+ /**
124
+ * Sets the minimum numeric value allowed for the option.
125
+ */
126
+ setMinValue(minValue: number): this;
127
+ /**
128
+ * Sets the maximum numeric value allowed for the option.
129
+ */
130
+ setMaxValue(maxValue: number): this;
131
+ }
132
+ /** Callback type accepted by option builder helper methods for customization. */
133
+ type OptionBuilderCallback<Builder> = (builder: Builder) => Builder | void;
134
+ /** Builder used to compose individual slash command subcommands. */
135
+ declare class SubcommandBuilder extends BaseOptionBuilder<APIApplicationCommandSubcommandOption> {
136
+ constructor();
137
+ /**
138
+ * Ensures the subcommand does not exceed Discord's option limit.
139
+ */
140
+ private assertOptionLimit;
141
+ /**
142
+ * Adds a string option configured through the supplied callback.
143
+ */
144
+ addStringOption(callback: OptionBuilderCallback<StringOptionBuilder>): this;
145
+ /**
146
+ * Adds a number option configured through the supplied callback.
147
+ */
148
+ addNumberOption(callback: OptionBuilderCallback<NumberOptionBuilder>): this;
149
+ /**
150
+ * Adds an attachment option configured through the supplied callback.
151
+ */
152
+ addAttachmentOption(callback: OptionBuilderCallback<AttachmentOptionBuilder>): this;
153
+ /**
154
+ * Adds a user option configured through the supplied callback.
155
+ */
156
+ addUserOption(callback: OptionBuilderCallback<UserOptionBuilder>): this;
157
+ /**
158
+ * Adds a role option configured through the supplied callback.
159
+ */
160
+ addRoleOption(callback: OptionBuilderCallback<RoleOptionBuilder>): this;
161
+ /**
162
+ * Adds a mentionable option configured through the supplied callback.
163
+ */
164
+ addMentionableOption(callback: OptionBuilderCallback<MentionableOptionBuilder>): this;
165
+ /**
166
+ * Adds a channel option configured through the supplied callback.
167
+ */
168
+ addChannelOption(callback: OptionBuilderCallback<ChannelOptionBuilder>): this;
169
+ /**
170
+ * Produces a serialisable representation of the subcommand configuration.
171
+ */
172
+ toJSON(): APIApplicationCommandSubcommandOption;
173
+ }
174
+ /** Builder used to compose groups of subcommands. */
175
+ declare class SubcommandGroupBuilder extends BaseOptionBuilder<APIApplicationCommandSubcommandGroupOption> {
176
+ constructor();
177
+ /**
178
+ * Ensures the group does not exceed Discord's subcommand limit.
179
+ */
180
+ private assertSubcommandLimit;
181
+ /**
182
+ * Adds a subcommand configured through the supplied callback.
183
+ */
184
+ addSubcommand(callback: OptionBuilderCallback<SubcommandBuilder>): this;
185
+ /**
186
+ * Produces a serialisable representation of the subcommand group configuration.
187
+ */
188
+ toJSON(): APIApplicationCommandSubcommandGroupOption;
189
+ }
190
+ /** Fluent builder for constructing Discord chat input command payloads. */
191
+ export declare class CommandBuilder {
192
+ private readonly data;
193
+ /**
194
+ * Ensures the command does not exceed Discord's option limit.
195
+ */
196
+ private assertOptionLimit;
197
+ /**
198
+ * Sets the command name while validating Discord's requirements.
199
+ */
200
+ setName(name: string): this;
201
+ /**
202
+ * Sets localized translations for the command name.
203
+ */
204
+ setNameLocalizations(localizations: LocalizationMap | null): this;
205
+ /**
206
+ * Sets the command description while enforcing Discord's length rules.
207
+ */
208
+ setDescription(description: string): this;
209
+ /**
210
+ * Sets localized translations for the command description.
211
+ */
212
+ setDescriptionLocalizations(localizations: LocalizationMap | null): this;
213
+ /**
214
+ * Configures the default member permissions required to use the command.
215
+ */
216
+ setDefaultMemberPermissions(permissions: Permissions | bigint | number | string | null): this;
217
+ /**
218
+ * Sets whether the command is available in direct messages.
219
+ */
220
+ setDMPermission(dmPermission: boolean): this;
221
+ /**
222
+ * Marks the command as not safe for work.
223
+ */
224
+ setNSFW(nsfw: boolean): this;
225
+ /**
226
+ * Limits the contexts in which the command can appear.
227
+ */
228
+ setContexts(contexts: CommandContext[] | null): this;
229
+ /**
230
+ * Specifies the integration types supported by the command.
231
+ */
232
+ setIntegrationTypes(integrationTypes: IntegrationType[]): this;
233
+ /**
234
+ * Adds a subcommand to the command definition.
235
+ */
236
+ addSubcommand(callback: OptionBuilderCallback<SubcommandBuilder>): this;
237
+ /**
238
+ * Adds a subcommand group to the command definition.
239
+ */
240
+ addSubcommandGroup(callback: OptionBuilderCallback<SubcommandGroupBuilder>): this;
241
+ /**
242
+ * Adds a string option to the command definition.
243
+ */
244
+ addStringOption(callback: OptionBuilderCallback<StringOptionBuilder>): this;
245
+ /**
246
+ * Adds a number option to the command definition.
247
+ */
248
+ addNumberOption(callback: OptionBuilderCallback<NumberOptionBuilder>): this;
249
+ /**
250
+ * Adds an attachment option to the command definition.
251
+ */
252
+ addAttachmentOption(callback: OptionBuilderCallback<AttachmentOptionBuilder>): this;
253
+ /**
254
+ * Adds a user option to the command definition.
255
+ */
256
+ addUserOption(callback: OptionBuilderCallback<UserOptionBuilder>): this;
257
+ /**
258
+ * Adds a role option to the command definition.
259
+ */
260
+ addRoleOption(callback: OptionBuilderCallback<RoleOptionBuilder>): this;
261
+ /**
262
+ * Adds a mentionable option to the command definition.
263
+ */
264
+ addMentionableOption(callback: OptionBuilderCallback<MentionableOptionBuilder>): this;
265
+ /**
266
+ * Adds a channel option to the command definition.
267
+ */
268
+ addChannelOption(callback: OptionBuilderCallback<ChannelOptionBuilder>): this;
269
+ /**
270
+ * Produces the final REST payload for the configured command.
271
+ */
272
+ toJSON(): RESTPostAPIChatInputApplicationCommandsJSONBody;
273
+ /**
274
+ * Allows the builder to be coerced into its JSON payload automatically.
275
+ */
276
+ valueOf(): RESTPostAPIChatInputApplicationCommandsJSONBody;
277
+ }
278
+ export type { AttachmentOptionBuilder, ChannelOptionBuilder, MentionableOptionBuilder, NumberOptionBuilder, RoleOptionBuilder, StringOptionBuilder, SubcommandBuilder, SubcommandGroupBuilder, UserOptionBuilder, };