gralonium 0.3.0 → 0.4.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 (44) hide show
  1. package/lib/classes/Client.d.ts +9 -3
  2. package/lib/classes/Client.js +2 -2
  3. package/lib/classes/Context.d.ts +42 -1
  4. package/lib/classes/Context.js +276 -13
  5. package/lib/classes/Cooldowns.d.ts +2 -0
  6. package/lib/classes/Cooldowns.js +28 -0
  7. package/lib/classes/HelpCommand.d.ts +55 -13
  8. package/lib/classes/HelpCommand.js +319 -1
  9. package/lib/classes/Loader.d.ts +10 -1
  10. package/lib/classes/Loader.js +143 -58
  11. package/lib/classes/Plugins.js +3 -2
  12. package/lib/classes/Utils.d.ts +1 -1
  13. package/lib/classes/Utils.js +103 -24
  14. package/lib/classes/builders/CommandBuilder.d.ts +24 -0
  15. package/lib/classes/builders/CommandBuilder.js +66 -2
  16. package/lib/classes/builders/ComponentsV2Builder.d.ts +288 -113
  17. package/lib/classes/builders/ComponentsV2Builder.js +1071 -180
  18. package/lib/classes/builders/GroupBuilder.d.ts +20 -0
  19. package/lib/classes/builders/GroupBuilder.js +37 -1
  20. package/lib/classes/builders/InteractionBuilder.d.ts +86 -25
  21. package/lib/classes/builders/InteractionBuilder.js +212 -1
  22. package/lib/classes/builders/ParamsBuilder.d.ts +118 -76
  23. package/lib/classes/builders/ParamsBuilder.js +167 -1
  24. package/lib/classes/builders/components/StyleMapper.d.ts +14 -2
  25. package/lib/classes/builders/components/StyleMapper.js +35 -9
  26. package/lib/classes/builders/components/helpers.d.ts +68 -4
  27. package/lib/classes/builders/components/helpers.js +366 -7
  28. package/lib/classes/builders/components/templates.d.ts +151 -9
  29. package/lib/classes/builders/components/templates.js +376 -17
  30. package/lib/classes/builders/components/text.d.ts +24 -0
  31. package/lib/classes/builders/components/text.js +91 -0
  32. package/lib/classes/experiments/Confirmator.d.ts +44 -26
  33. package/lib/classes/experiments/Confirmator.js +37 -21
  34. package/lib/classes/experiments/Paginator.d.ts +48 -29
  35. package/lib/classes/experiments/Paginator.js +48 -19
  36. package/lib/classes/views/V2Paginator.d.ts +91 -0
  37. package/lib/classes/views/V2Paginator.js +268 -0
  38. package/lib/classes/views/V2View.d.ts +113 -0
  39. package/lib/classes/views/V2View.js +438 -0
  40. package/lib/experiments.d.ts +2 -0
  41. package/lib/experiments.js +9 -1
  42. package/lib/main.d.ts +3 -0
  43. package/lib/main.js +3 -0
  44. package/package.json +3 -1
@@ -1,3 +1,5 @@
1
+ import type { ApplicationIntegrationType, InteractionContextType } from "discord.js";
2
+ import type { LocalizationMap } from "./CommandBuilder.js";
1
3
  import { Command, Types } from "../Loader.js";
2
4
 
3
5
  type GroupBuilderOptions = {
@@ -11,6 +13,12 @@ type GroupBuilderOptions = {
11
13
  userPermissions?: string[];
12
14
  botPermissions?: string[];
13
15
  guards?: Array<(ctx: any) => boolean | Promise<boolean>>;
16
+ integrationTypes?: Array<ApplicationIntegrationType | number>;
17
+ contexts?: Array<InteractionContextType | number>;
18
+ nameLocalizations?: LocalizationMap;
19
+ name_localizations?: LocalizationMap;
20
+ descriptionLocalizations?: LocalizationMap;
21
+ description_localizations?: LocalizationMap;
14
22
  };
15
23
 
16
24
  export declare class GroupBuilder {
@@ -25,6 +33,10 @@ export declare class GroupBuilder {
25
33
  userPermissions: string[];
26
34
  botPermissions: string[];
27
35
  guards: Array<(ctx: any) => boolean | Promise<boolean>>;
36
+ integrationTypes?: Array<ApplicationIntegrationType | number>;
37
+ contexts?: Array<InteractionContextType | number>;
38
+ nameLocalizations?: LocalizationMap;
39
+ descriptionLocalizations?: LocalizationMap;
28
40
  constructor(ops?: GroupBuilderOptions);
29
41
  setName(name: string): GroupBuilder;
30
42
  setDescription(description: string): GroupBuilder;
@@ -34,12 +46,20 @@ export declare class GroupBuilder {
34
46
  setBotPermissions(...permissions: string[]): GroupBuilder;
35
47
  allowPrefix(allow: boolean): GroupBuilder;
36
48
  allowSlash(allow: boolean): GroupBuilder;
49
+ setIntegrationTypes(...types: Array<ApplicationIntegrationType | number | Array<ApplicationIntegrationType | number>>): GroupBuilder;
50
+ setContexts(...contexts: Array<InteractionContextType | number | Array<InteractionContextType | number>>): GroupBuilder;
51
+ setNameLocalizations(locales?: LocalizationMap | null): GroupBuilder;
52
+ setDescriptionLocalizations(locales?: LocalizationMap | null): GroupBuilder;
37
53
  toJSON(): {
38
54
  name: string;
39
55
  description: string;
40
56
  options: any[];
41
57
  default_member_permissions: string | null | undefined;
42
58
  dm_permission: boolean | undefined;
59
+ name_localizations?: LocalizationMap;
60
+ description_localizations?: LocalizationMap;
61
+ integration_types?: Array<ApplicationIntegrationType | number>;
62
+ contexts?: Array<InteractionContextType | number>;
43
63
  };
44
64
  }
45
65
 
@@ -20,6 +20,10 @@ class GroupBuilder {
20
20
  userPermissions;
21
21
  botPermissions;
22
22
  guards;
23
+ integrationTypes;
24
+ contexts;
25
+ nameLocalizations;
26
+ descriptionLocalizations;
23
27
 
24
28
  constructor(options) {
25
29
  this.commands = [];
@@ -33,6 +37,14 @@ class GroupBuilder {
33
37
  this.userPermissions = permissionArrayPredicate.parse(options?.userPermissions ?? []);
34
38
  this.botPermissions = permissionArrayPredicate.parse(options?.botPermissions ?? []);
35
39
  this.guards = options?.guards ?? [];
40
+ this.integrationTypes = options?.integrationTypes;
41
+ this.contexts = options?.contexts;
42
+ this.nameLocalizations = (0, CommandBuilder_js_1.normalizeNameLocalizations)(
43
+ options?.nameLocalizations ?? options?.name_localizations
44
+ );
45
+ this.descriptionLocalizations = (0, CommandBuilder_js_1.normalizeDescriptionLocalizations)(
46
+ options?.descriptionLocalizations ?? options?.description_localizations
47
+ );
36
48
  }
37
49
 
38
50
  setName(name) {
@@ -75,15 +87,39 @@ class GroupBuilder {
75
87
  return this;
76
88
  }
77
89
 
90
+ setIntegrationTypes(...types) {
91
+ this.integrationTypes = types.flat();
92
+ return this;
93
+ }
94
+
95
+ setContexts(...contexts) {
96
+ this.contexts = contexts.flat();
97
+ return this;
98
+ }
99
+
100
+ setNameLocalizations(locales) {
101
+ this.nameLocalizations = (0, CommandBuilder_js_1.normalizeNameLocalizations)(locales);
102
+ return this;
103
+ }
104
+
105
+ setDescriptionLocalizations(locales) {
106
+ this.descriptionLocalizations = (0, CommandBuilder_js_1.normalizeDescriptionLocalizations)(locales);
107
+ return this;
108
+ }
109
+
78
110
  toJSON() {
79
111
  return {
80
112
  name: this.name,
81
- description: this.description,
113
+ description: String(this.description ?? "...").slice(0, 100),
82
114
  options: [],
83
115
  default_member_permissions: this.defaultMemberPermissions
84
116
  ? (0, CommandBuilder_js_1.validateDefaultMemberPermissions)(this.defaultMemberPermissions)
85
117
  : undefined,
86
118
  dm_permission: typeof this.guildOnly === "boolean" ? !this.guildOnly : undefined,
119
+ ...(this.nameLocalizations ? { name_localizations: this.nameLocalizations } : {}),
120
+ ...(this.descriptionLocalizations ? { description_localizations: this.descriptionLocalizations } : {}),
121
+ ...(this.integrationTypes !== undefined ? { integration_types: this.integrationTypes } : {}),
122
+ ...(this.contexts !== undefined ? { contexts: this.contexts } : {}),
87
123
  };
88
124
  }
89
125
  }
@@ -1,32 +1,93 @@
1
+ import type { ApplicationCommandType, ApplicationIntegrationType, InteractionContextType } from "discord.js";
2
+ import type { LocalizationMap } from "./CommandBuilder.js";
3
+
1
4
  export declare enum Interactions {
2
- AnyInteraction = "anyInteraction",
3
- Autocomplete = "autocomplete",
4
- Button = "button",
5
- ChatInput = "chatInput",
6
- MessageContextMenu = "messageContextMenu",
7
- Modal = "modalSubmit",
8
- UserContextMenu = "userContextMenu",
9
- ChannelSelectMenu = "channelSelectMenu",
10
- RoleSelectMenu = "roleSelectMenu",
11
- StringSelectMenu = "stringSelectMenu",
12
- UserSelectMenu = "userSelectMenu",
13
- MentionableSelectMenu = "mentionableSelectMenu"
5
+ AnyInteraction = "anyInteraction",
6
+ Autocomplete = "autocomplete",
7
+ Button = "button",
8
+ ChatInput = "chatInput",
9
+ MessageContextMenu = "messageContextMenu",
10
+ Modal = "modalSubmit",
11
+ UserContextMenu = "userContextMenu",
12
+ ChannelSelectMenu = "channelSelectMenu",
13
+ RoleSelectMenu = "roleSelectMenu",
14
+ StringSelectMenu = "stringSelectMenu",
15
+ UserSelectMenu = "userSelectMenu",
16
+ MentionableSelectMenu = "mentionableSelectMenu"
14
17
  }
18
+
19
+ export type InteractionMatcher = RegExp | ((key: string, interaction: any) => boolean);
20
+
15
21
  export interface InteractionDataBuilder {
16
- name?: string;
17
- type: Interactions;
18
- description?: string;
22
+ name?: string;
23
+ type: Interactions;
24
+ description?: string;
25
+ prefix?: string;
26
+ match?: InteractionMatcher;
27
+ as_command?: boolean;
28
+ guildOnly?: boolean;
29
+ defaultMemberPermissions?: string | bigint;
30
+ integrationTypes?: Array<ApplicationIntegrationType | number>;
31
+ contexts?: Array<InteractionContextType | number>;
32
+ nameLocalizations?: LocalizationMap;
33
+ name_localizations?: LocalizationMap;
34
+ descriptionLocalizations?: LocalizationMap;
35
+ description_localizations?: LocalizationMap;
19
36
  }
37
+
20
38
  export declare class InteractionBuilder {
21
- name?: string;
22
- type: Interactions;
39
+ name?: string;
40
+ type: Interactions;
41
+ description: string;
42
+ prefix?: string;
43
+ match?: InteractionMatcher;
44
+ as_command: boolean;
45
+ guildOnly: boolean | undefined;
46
+ defaultMemberPermissions?: string | bigint | undefined;
47
+ integrationTypes?: Array<ApplicationIntegrationType | number>;
48
+ contexts?: Array<InteractionContextType | number>;
49
+ nameLocalizations?: LocalizationMap;
50
+ descriptionLocalizations?: LocalizationMap;
51
+ constructor(options?: InteractionDataBuilder);
52
+ setName(name: string): this;
53
+ setDescription(description: string): this;
54
+ setPrefix(prefix: string): this;
55
+ setMatcher(matcher: InteractionMatcher): this;
56
+ setNameLocalizations(locales?: LocalizationMap | null): this;
57
+ setDescriptionLocalizations(locales?: LocalizationMap | null): this;
58
+ setIntegrationTypes(...types: Array<ApplicationIntegrationType | number | Array<ApplicationIntegrationType | number>>): this;
59
+ setContexts(...contexts: Array<InteractionContextType | number | Array<InteractionContextType | number>>): this;
60
+ setDefaultMemberPermissions(permissions: string | bigint | undefined): this;
61
+ setGuildOnly(guildOnly?: boolean): this;
62
+ allowCommand(allow?: boolean): this;
63
+ hasPattern(): boolean;
64
+ matches(key: string, interaction?: any): boolean;
65
+ /**
66
+ * Returns the interaction data parsed as JSON.
67
+ */
68
+ toJSON(): {
69
+ name: string | undefined;
23
70
  description: string;
24
- constructor(options?: InteractionDataBuilder);
25
- /**
26
- * Returns the command data parsed as JSON.
27
- */
28
- toJSON(): {
29
- name: string | undefined;
30
- description: string;
31
- };
71
+ default_member_permissions?: string | null;
72
+ dm_permission?: boolean;
73
+ prefix?: string;
74
+ name_localizations?: LocalizationMap;
75
+ description_localizations?: LocalizationMap;
76
+ integration_types?: Array<ApplicationIntegrationType | number>;
77
+ contexts?: Array<InteractionContextType | number>;
78
+ };
79
+ /**
80
+ * Returns the application command payload for context menu commands (`type: 2` / `type: 3`).
81
+ */
82
+ toCommandJSON(): {
83
+ name: string | undefined;
84
+ type: ApplicationCommandType;
85
+ description?: string;
86
+ default_member_permissions?: string | null;
87
+ dm_permission?: boolean;
88
+ name_localizations?: LocalizationMap;
89
+ description_localizations?: LocalizationMap;
90
+ integration_types?: Array<ApplicationIntegrationType | number>;
91
+ contexts?: Array<InteractionContextType | number>;
92
+ } | null;
32
93
  }
@@ -1 +1,212 @@
1
- "use strict";var Interactions;Object.defineProperty(exports,"__esModule",{value:!0}),exports.InteractionBuilder=exports.Interactions=void 0,function(e){e.AnyInteraction="anyInteraction",e.Autocomplete="autocomplete",e.Button="button",e.ChatInput="chatInput",e.MessageContextMenu="messageContextMenu",e.Modal="modalSubmit",e.UserContextMenu="userContextMenu",e.ChannelSelectMenu="channelSelectMenu",e.RoleSelectMenu="roleSelectMenu",e.StringSelectMenu="stringSelectMenu",e.UserSelectMenu="userSelectMenu",e.MentionableSelectMenu="mentionableSelectMenu"}(Interactions||(exports.Interactions=Interactions={}));class InteractionBuilder{name;type;description;constructor(e){this.name=e?.name,this.type=e?.type||Interactions.ChatInput,this.description=e?.description||"..."}toJSON(){return{name:this.name,description:this.description}}}exports.InteractionBuilder=InteractionBuilder;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InteractionBuilder = exports.Interactions = void 0;
4
+
5
+ const discord_js_1 = require("discord.js");
6
+ const CommandBuilder_js_1 = require("./CommandBuilder.js");
7
+
8
+ var Interactions;
9
+ (function (Interactions) {
10
+ Interactions.AnyInteraction = "anyInteraction";
11
+ Interactions.Autocomplete = "autocomplete";
12
+ Interactions.Button = "button";
13
+ Interactions.ChatInput = "chatInput";
14
+ Interactions.MessageContextMenu = "messageContextMenu";
15
+ Interactions.Modal = "modalSubmit";
16
+ Interactions.UserContextMenu = "userContextMenu";
17
+ Interactions.ChannelSelectMenu = "channelSelectMenu";
18
+ Interactions.RoleSelectMenu = "roleSelectMenu";
19
+ Interactions.StringSelectMenu = "stringSelectMenu";
20
+ Interactions.UserSelectMenu = "userSelectMenu";
21
+ Interactions.MentionableSelectMenu = "mentionableSelectMenu";
22
+ })(Interactions || (exports.Interactions = Interactions = {}));
23
+
24
+ /**
25
+ * Builder describing an interaction handler loaded by Gralonium.
26
+ * Supports exact `name`/`customId` matching, `prefix` / `match` routing,
27
+ * localizations, and context-menu application command metadata.
28
+ */
29
+ class InteractionBuilder {
30
+ name;
31
+ type;
32
+ description;
33
+ prefix;
34
+ match;
35
+ as_command;
36
+ guildOnly;
37
+ defaultMemberPermissions;
38
+ integrationTypes;
39
+ contexts;
40
+ nameLocalizations;
41
+ descriptionLocalizations;
42
+
43
+ constructor(options) {
44
+ this.name = options?.name;
45
+ this.type = options?.type || Interactions.ChatInput;
46
+ this.description = options?.description || "...";
47
+ this.prefix = options?.prefix;
48
+ this.match = options?.match;
49
+ this.as_command = options?.as_command ?? true;
50
+ this.guildOnly = options?.guildOnly;
51
+ this.defaultMemberPermissions = options?.defaultMemberPermissions;
52
+ this.integrationTypes = options?.integrationTypes;
53
+ this.contexts = options?.contexts;
54
+ this.nameLocalizations = (0, CommandBuilder_js_1.normalizeNameLocalizations)(
55
+ options?.nameLocalizations ?? options?.name_localizations
56
+ );
57
+ this.descriptionLocalizations = (0, CommandBuilder_js_1.normalizeDescriptionLocalizations)(
58
+ options?.descriptionLocalizations ?? options?.description_localizations
59
+ );
60
+ }
61
+
62
+ setName(name) {
63
+ this.name = name;
64
+ return this;
65
+ }
66
+
67
+ setDescription(description) {
68
+ this.description = description;
69
+ return this;
70
+ }
71
+
72
+ /**
73
+ * Matches any interaction key (`customId` or `commandName`) starting with `prefix`.
74
+ */
75
+ setPrefix(prefix) {
76
+ this.prefix = prefix;
77
+ return this;
78
+ }
79
+
80
+ /**
81
+ * Sets a RegExp or predicate `(key, interaction) => boolean` for dynamic interaction routing.
82
+ */
83
+ setMatcher(matcher) {
84
+ this.match = matcher;
85
+ return this;
86
+ }
87
+
88
+ setNameLocalizations(locales) {
89
+ this.nameLocalizations = (0, CommandBuilder_js_1.normalizeNameLocalizations)(locales);
90
+ return this;
91
+ }
92
+
93
+ setDescriptionLocalizations(locales) {
94
+ this.descriptionLocalizations = (0, CommandBuilder_js_1.normalizeDescriptionLocalizations)(locales);
95
+ return this;
96
+ }
97
+
98
+ setIntegrationTypes(...types) {
99
+ this.integrationTypes = types.flat();
100
+ return this;
101
+ }
102
+
103
+ setContexts(...contexts) {
104
+ this.contexts = contexts.flat();
105
+ return this;
106
+ }
107
+
108
+ setDefaultMemberPermissions(permissions) {
109
+ this.defaultMemberPermissions = permissions;
110
+ return this;
111
+ }
112
+
113
+ setGuildOnly(guildOnly = true) {
114
+ this.guildOnly = Boolean(guildOnly);
115
+ return this;
116
+ }
117
+
118
+ allowCommand(allow = true) {
119
+ this.as_command = Boolean(allow);
120
+ return this;
121
+ }
122
+
123
+ /**
124
+ * Returns true if this builder uses a dynamic prefix, RegExp, or predicate matcher.
125
+ */
126
+ hasPattern() {
127
+ return Boolean(this.prefix || this.match);
128
+ }
129
+
130
+ /**
131
+ * Evaluates whether a given interaction key (`customId` / `commandName`) matches this handler.
132
+ */
133
+ matches(key, interaction) {
134
+ if (this.name !== undefined && this.name !== null && this.name !== "" && key === this.name) {
135
+ return true;
136
+ }
137
+ if (this.prefix && typeof key === "string" && key.startsWith(this.prefix)) {
138
+ return true;
139
+ }
140
+ if (this.match instanceof RegExp) {
141
+ this.match.lastIndex = 0;
142
+ return this.match.test(String(key ?? ""));
143
+ }
144
+ if (typeof this.match === "function") {
145
+ return Boolean(this.match(key, interaction));
146
+ }
147
+ return false;
148
+ }
149
+
150
+ toJSON() {
151
+ return {
152
+ name: this.name,
153
+ description: String(this.description ?? "...").slice(0, 100),
154
+ ...(this.defaultMemberPermissions !== undefined
155
+ ? {
156
+ default_member_permissions: (0, CommandBuilder_js_1.validateDefaultMemberPermissions)(
157
+ this.defaultMemberPermissions
158
+ ),
159
+ }
160
+ : {}),
161
+ ...(typeof this.guildOnly === "boolean" ? { dm_permission: !this.guildOnly } : {}),
162
+ ...(this.prefix !== undefined ? { prefix: this.prefix } : {}),
163
+ ...(this.nameLocalizations ? { name_localizations: this.nameLocalizations } : {}),
164
+ ...(this.descriptionLocalizations ? { description_localizations: this.descriptionLocalizations } : {}),
165
+ ...(this.integrationTypes !== undefined ? { integration_types: this.integrationTypes } : {}),
166
+ ...(this.contexts !== undefined ? { contexts: this.contexts } : {}),
167
+ };
168
+ }
169
+
170
+ /**
171
+ * Builds the Discord application command payload for context menu commands (`type: 2` / `type: 3`).
172
+ */
173
+ toCommandJSON() {
174
+ if (this.as_command === false) {
175
+ return null;
176
+ }
177
+
178
+ const commandType =
179
+ this.type === Interactions.UserContextMenu
180
+ ? discord_js_1.ApplicationCommandType.User
181
+ : this.type === Interactions.MessageContextMenu
182
+ ? discord_js_1.ApplicationCommandType.Message
183
+ : discord_js_1.ApplicationCommandType.ChatInput;
184
+
185
+ const payload = {
186
+ name: this.name,
187
+ type: commandType,
188
+ ...(this.defaultMemberPermissions !== undefined
189
+ ? {
190
+ default_member_permissions: (0, CommandBuilder_js_1.validateDefaultMemberPermissions)(
191
+ this.defaultMemberPermissions
192
+ ),
193
+ }
194
+ : {}),
195
+ ...(typeof this.guildOnly === "boolean" ? { dm_permission: !this.guildOnly } : {}),
196
+ ...(this.nameLocalizations ? { name_localizations: this.nameLocalizations } : {}),
197
+ ...(this.integrationTypes !== undefined ? { integration_types: this.integrationTypes } : {}),
198
+ ...(this.contexts !== undefined ? { contexts: this.contexts } : {}),
199
+ };
200
+
201
+ if (commandType === discord_js_1.ApplicationCommandType.ChatInput) {
202
+ payload.description = String(this.description ?? "...").slice(0, 100);
203
+ if (this.descriptionLocalizations) {
204
+ payload.description_localizations = this.descriptionLocalizations;
205
+ }
206
+ }
207
+
208
+ return payload;
209
+ }
210
+ }
211
+
212
+ exports.InteractionBuilder = InteractionBuilder;
@@ -1,87 +1,129 @@
1
1
  import { ApplicationCommandOptionType, ChannelType } from "discord.js";
2
+ import type { LocalizationMap } from "./CommandBuilder.js";
3
+
4
+ export interface ParamChoice<V = string | number> {
5
+ name: string;
6
+ value: V;
7
+ name_localizations?: LocalizationMap;
8
+ nameLocalizations?: LocalizationMap;
9
+ }
10
+
2
11
  export interface BaseParam {
3
- /** The name for this parameter. */
4
- name: string;
5
- /** The description for this parameter. */
6
- description: string;
7
- /** Mark this param as required or not. */
8
- required: boolean;
9
- /** Parameter type. (if needed) */
10
- type?: ApplicationCommandOptionType;
11
- /** Parameter default value. */
12
- value?: any;
13
- /** Mostly to be used for string. Return all arguments after this parameter (including this one) */
14
- ellipsis?: boolean;
12
+ /** The name for this parameter. */
13
+ name: string;
14
+ /** The description for this parameter. */
15
+ description: string;
16
+ /** Mark this param as required or not. */
17
+ required?: boolean;
18
+ /** Localized option names. */
19
+ name_localizations?: LocalizationMap;
20
+ nameLocalizations?: LocalizationMap;
21
+ /** Localized option descriptions. */
22
+ description_localizations?: LocalizationMap;
23
+ descriptionLocalizations?: LocalizationMap;
24
+ /** Parameter type. (if needed) */
25
+ type?: ApplicationCommandOptionType;
26
+ /** Parameter default value. */
27
+ value?: any;
28
+ /** Mostly to be used for string. Return all arguments after this parameter (including this one) */
29
+ ellipsis?: boolean;
15
30
  }
31
+
16
32
  export interface StringParam extends BaseParam {
17
- /** String choices. */
18
- choices?: {
19
- name: string;
20
- value: string;
21
- }[];
22
- /** Maximum string length. */
23
- max_length?: number;
24
- /** Minimum string length. */
25
- min_length?: number;
26
- /** Mark this command as automplete */
27
- autocomplete?: boolean;
33
+ /** String choices. */
34
+ choices?: ParamChoice<string>[];
35
+ /** Maximum string length. */
36
+ max_length?: number;
37
+ maxLength?: number;
38
+ /** Minimum string length. */
39
+ min_length?: number;
40
+ minLength?: number;
41
+ /** Mark this command as autocomplete. */
42
+ autocomplete?: boolean;
28
43
  }
44
+
29
45
  export interface NumberParam extends BaseParam {
30
- /** Maximum number length. */
31
- max_value?: number;
32
- /** Minimum string length. */
33
- min_value?: number;
34
- /** Number choices. */
35
- choices?: {
36
- name: string;
37
- value: string;
38
- }[];
46
+ /** Maximum number value. */
47
+ max_value?: number;
48
+ maxValue?: number;
49
+ /** Minimum number value. */
50
+ min_value?: number;
51
+ minValue?: number;
52
+ /** Number choices. */
53
+ choices?: ParamChoice<number | string>[];
54
+ autocomplete?: boolean;
55
+ }
56
+
57
+ export interface IntegerParam extends BaseParam {
58
+ /** Maximum integer value. */
59
+ max_value?: number;
60
+ maxValue?: number;
61
+ /** Minimum integer value. */
62
+ min_value?: number;
63
+ minValue?: number;
64
+ /** Integer choices. */
65
+ choices?: ParamChoice<number | string>[];
66
+ autocomplete?: boolean;
39
67
  }
68
+
40
69
  export interface ChannelParam extends BaseParam {
41
- /** An array of allowed channel types. */
42
- channel_types?: ChannelType[];
70
+ /** An array of allowed channel types. */
71
+ channel_types?: ChannelType[];
72
+ channelTypes?: ChannelType[];
43
73
  }
74
+
75
+ export type MentionableParam = BaseParam;
76
+
44
77
  export declare class ParamsBuilder {
45
- params: BaseParam[];
46
- quoted: boolean;
47
- /**
48
- * Enable or disable quoted arguments.
49
- * @param value Boolean value.
50
- */
51
- setQuoted(value: boolean): ParamsBuilder;
52
- /**
53
- * Adds a string option.
54
- * @param param Parameter data.
55
- */
56
- addString(param: StringParam): ParamsBuilder;
57
- /**
58
- * Adds a number option.
59
- * @param param Parameter data.
60
- */
61
- addNumber(param: NumberParam): ParamsBuilder;
62
- /**
63
- * Adds a boolean option.
64
- * @param param Parameter data.
65
- */
66
- addBoolean(param: BaseParam): ParamsBuilder;
67
- /**
68
- * Adds a guild member option.
69
- * @param param Parameter data.
70
- */
71
- addMember(param: BaseParam): ParamsBuilder;
72
- /**
73
- * Adds a guild channel option.
74
- * @param param Parameter data.
75
- */
76
- addChannel(param: ChannelParam): ParamsBuilder;
77
- /**
78
- * Adds a role option.
79
- * @param param Parameter data.
80
- */
81
- addRole(param: BaseParam): ParamsBuilder;
82
- /**
83
- * Adds an attachment option.
84
- * @param param Parameter data.
85
- */
86
- addAttachment(param: BaseParam): ParamsBuilder;
78
+ params: BaseParam[];
79
+ quoted: boolean;
80
+ /**
81
+ * Enable or disable quoted arguments.
82
+ * @param value Boolean value.
83
+ */
84
+ setQuoted(value: boolean): ParamsBuilder;
85
+ /**
86
+ * Adds a string option.
87
+ */
88
+ addString(param: StringParam): ParamsBuilder;
89
+ /**
90
+ * Adds a number option.
91
+ */
92
+ addNumber(param: NumberParam): ParamsBuilder;
93
+ /**
94
+ * Adds an integer option.
95
+ */
96
+ addInteger(param: IntegerParam): ParamsBuilder;
97
+ /**
98
+ * Adds a boolean option.
99
+ */
100
+ addBoolean(param: BaseParam): ParamsBuilder;
101
+ /**
102
+ * Adds a guild member / user option.
103
+ */
104
+ addMember(param: BaseParam): ParamsBuilder;
105
+ /**
106
+ * Alias of `addMember`.
107
+ */
108
+ addUser(param: BaseParam): ParamsBuilder;
109
+ /**
110
+ * Adds a guild channel option.
111
+ */
112
+ addChannel(param: ChannelParam): ParamsBuilder;
113
+ /**
114
+ * Adds a role option.
115
+ */
116
+ addRole(param: BaseParam): ParamsBuilder;
117
+ /**
118
+ * Adds an attachment option.
119
+ */
120
+ addAttachment(param: BaseParam): ParamsBuilder;
121
+ /**
122
+ * Adds a mentionable (user or role) option.
123
+ */
124
+ addMentionable(param: MentionableParam): ParamsBuilder;
125
+ /**
126
+ * Serializes options cleanly for Discord ApplicationCommand registration.
127
+ */
128
+ toJSON(): Record<string, any>[];
87
129
  }