gralonium 0.4.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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommandBuilder = exports.validateDefaultMemberPermissions = void 0;
3
+ exports.CommandBuilder = exports.normalizeDescriptionLocalizations = exports.normalizeNameLocalizations = exports.validateDefaultMemberPermissions = void 0;
4
4
 
5
5
  const shapeshift_1 = require("@sapphire/shapeshift");
6
6
 
@@ -15,6 +15,36 @@ function validateDefaultMemberPermissions(permissions) {
15
15
  }
16
16
  exports.validateDefaultMemberPermissions = validateDefaultMemberPermissions;
17
17
 
18
+ function normalizeLocaleMap(map, maxLength) {
19
+ if (!map || typeof map !== "object" || Array.isArray(map)) return undefined;
20
+ const out = {};
21
+ let hasEntries = false;
22
+ for (const [locale, raw] of Object.entries(map)) {
23
+ if (typeof raw !== "string") continue;
24
+ const trimmed = raw.trim();
25
+ if (!trimmed) continue;
26
+ out[locale] = trimmed.slice(0, maxLength);
27
+ hasEntries = true;
28
+ }
29
+ return hasEntries ? out : undefined;
30
+ }
31
+
32
+ /**
33
+ * Normalizes a localization map for Discord command/option names (max 32 chars).
34
+ */
35
+ function normalizeNameLocalizations(map) {
36
+ return normalizeLocaleMap(map, 32);
37
+ }
38
+ exports.normalizeNameLocalizations = normalizeNameLocalizations;
39
+
40
+ /**
41
+ * Normalizes a localization map for Discord descriptions (max 100 chars).
42
+ */
43
+ function normalizeDescriptionLocalizations(map) {
44
+ return normalizeLocaleMap(map, 100);
45
+ }
46
+ exports.normalizeDescriptionLocalizations = normalizeDescriptionLocalizations;
47
+
18
48
  class CommandBuilder {
19
49
  name;
20
50
  aliases;
@@ -31,6 +61,8 @@ class CommandBuilder {
31
61
  cooldown;
32
62
  integrationTypes;
33
63
  contexts;
64
+ nameLocalizations;
65
+ descriptionLocalizations;
34
66
 
35
67
  constructor(options) {
36
68
  this.name = options?.name ?? "";
@@ -47,6 +79,10 @@ class CommandBuilder {
47
79
  this.cooldown = options?.cooldown;
48
80
  this.integrationTypes = options?.integrationTypes;
49
81
  this.contexts = options?.contexts;
82
+ this.nameLocalizations = normalizeNameLocalizations(options?.nameLocalizations ?? options?.name_localizations);
83
+ this.descriptionLocalizations = normalizeDescriptionLocalizations(
84
+ options?.descriptionLocalizations ?? options?.description_localizations
85
+ );
50
86
  }
51
87
 
52
88
  setName(name) {
@@ -109,12 +145,24 @@ class CommandBuilder {
109
145
  return this;
110
146
  }
111
147
 
148
+ setNameLocalizations(locales) {
149
+ this.nameLocalizations = normalizeNameLocalizations(locales);
150
+ return this;
151
+ }
152
+
153
+ setDescriptionLocalizations(locales) {
154
+ this.descriptionLocalizations = normalizeDescriptionLocalizations(locales);
155
+ return this;
156
+ }
157
+
112
158
  toJSON() {
113
159
  return {
114
160
  name: this.name,
115
- description: this.description,
161
+ description: String(this.description ?? "...").slice(0, 100),
116
162
  default_member_permissions: this.defaultMemberPermissions ? validateDefaultMemberPermissions(this.defaultMemberPermissions) : undefined,
117
163
  dm_permission: typeof this.guildOnly === "boolean" ? !this.guildOnly : undefined,
164
+ ...(this.nameLocalizations ? { name_localizations: this.nameLocalizations } : {}),
165
+ ...(this.descriptionLocalizations ? { description_localizations: this.descriptionLocalizations } : {}),
118
166
  ...(this.integrationTypes !== undefined ? { integration_types: this.integrationTypes } : {}),
119
167
  ...(this.contexts !== undefined ? { contexts: this.contexts } : {}),
120
168
  };
@@ -19,6 +19,7 @@ import {
19
19
  ThumbnailBuilder,
20
20
  } from "discord.js";
21
21
  import type { DisableComponentsOptions, EmojiInput, ParsedEmoji } from "./components/helpers";
22
+ import type { ButtonStyleInput } from "./components/StyleMapper";
22
23
  import type { V2CardOptions, V2ConfirmOptions, V2ImageViewOptions, V2ListOptions } from "./components/templates";
23
24
  import { V2Text, type V2FieldRow } from "./components/text";
24
25
 
@@ -223,6 +224,8 @@ export declare class ComponentsV2Builder {
223
224
  static readonly text: typeof V2Text;
224
225
  static clipText(text: string, maxLen?: number, fallback?: string): string;
225
226
  static resolveColor(color?: ColorResolvable, fallback?: ColorResolvable): number | null;
227
+ static setDefaultButtonStyle(style?: ButtonStyleInput | null): ButtonStyle;
228
+ static getDefaultButtonStyle(): ButtonStyle;
226
229
  static parseEmoji(emoji?: EmojiInput): ParsedEmoji | null;
227
230
  static isValidMediaUrl(url?: string | null): boolean;
228
231
  static isValidLinkUrl(url?: string | null): boolean;
@@ -171,6 +171,8 @@ class ComponentsV2Builder {
171
171
  static text = text_js_1.V2Text;
172
172
  static clipText = helpers_js_1.clipText;
173
173
  static resolveColor = helpers_js_1.resolveAccentColor;
174
+ static setDefaultButtonStyle = StyleMapper_js_1.setDefaultButtonStyle;
175
+ static getDefaultButtonStyle = StyleMapper_js_1.getDefaultButtonStyle;
174
176
  static parseEmoji = helpers_js_1.parseEmoji;
175
177
  static isValidMediaUrl = helpers_js_1.isValidMediaUrl;
176
178
  static isValidLinkUrl = helpers_js_1.isValidLinkUrl;
@@ -306,7 +308,7 @@ class ComponentsV2Builder {
306
308
  ? StyleMapper_js_1.mapButtonStyle(cfg.style)
307
309
  : cfg.url
308
310
  ? discord_js_1.ButtonStyle.Link
309
- : discord_js_1.ButtonStyle.Primary;
311
+ : StyleMapper_js_1.getDefaultButtonStyle();
310
312
 
311
313
  button.setStyle(resolvedStyle);
312
314
 
@@ -1,4 +1,5 @@
1
1
  import type { ApplicationIntegrationType, InteractionContextType } from "discord.js";
2
+ import type { LocalizationMap } from "./CommandBuilder.js";
2
3
  import { Command, Types } from "../Loader.js";
3
4
 
4
5
  type GroupBuilderOptions = {
@@ -14,6 +15,10 @@ type GroupBuilderOptions = {
14
15
  guards?: Array<(ctx: any) => boolean | Promise<boolean>>;
15
16
  integrationTypes?: Array<ApplicationIntegrationType | number>;
16
17
  contexts?: Array<InteractionContextType | number>;
18
+ nameLocalizations?: LocalizationMap;
19
+ name_localizations?: LocalizationMap;
20
+ descriptionLocalizations?: LocalizationMap;
21
+ description_localizations?: LocalizationMap;
17
22
  };
18
23
 
19
24
  export declare class GroupBuilder {
@@ -30,6 +35,8 @@ export declare class GroupBuilder {
30
35
  guards: Array<(ctx: any) => boolean | Promise<boolean>>;
31
36
  integrationTypes?: Array<ApplicationIntegrationType | number>;
32
37
  contexts?: Array<InteractionContextType | number>;
38
+ nameLocalizations?: LocalizationMap;
39
+ descriptionLocalizations?: LocalizationMap;
33
40
  constructor(ops?: GroupBuilderOptions);
34
41
  setName(name: string): GroupBuilder;
35
42
  setDescription(description: string): GroupBuilder;
@@ -41,12 +48,16 @@ export declare class GroupBuilder {
41
48
  allowSlash(allow: boolean): GroupBuilder;
42
49
  setIntegrationTypes(...types: Array<ApplicationIntegrationType | number | Array<ApplicationIntegrationType | number>>): GroupBuilder;
43
50
  setContexts(...contexts: Array<InteractionContextType | number | Array<InteractionContextType | number>>): GroupBuilder;
51
+ setNameLocalizations(locales?: LocalizationMap | null): GroupBuilder;
52
+ setDescriptionLocalizations(locales?: LocalizationMap | null): GroupBuilder;
44
53
  toJSON(): {
45
54
  name: string;
46
55
  description: string;
47
56
  options: any[];
48
57
  default_member_permissions: string | null | undefined;
49
58
  dm_permission: boolean | undefined;
59
+ name_localizations?: LocalizationMap;
60
+ description_localizations?: LocalizationMap;
50
61
  integration_types?: Array<ApplicationIntegrationType | number>;
51
62
  contexts?: Array<InteractionContextType | number>;
52
63
  };
@@ -22,6 +22,8 @@ class GroupBuilder {
22
22
  guards;
23
23
  integrationTypes;
24
24
  contexts;
25
+ nameLocalizations;
26
+ descriptionLocalizations;
25
27
 
26
28
  constructor(options) {
27
29
  this.commands = [];
@@ -37,6 +39,12 @@ class GroupBuilder {
37
39
  this.guards = options?.guards ?? [];
38
40
  this.integrationTypes = options?.integrationTypes;
39
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
+ );
40
48
  }
41
49
 
42
50
  setName(name) {
@@ -89,15 +97,27 @@ class GroupBuilder {
89
97
  return this;
90
98
  }
91
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
+
92
110
  toJSON() {
93
111
  return {
94
112
  name: this.name,
95
- description: this.description,
113
+ description: String(this.description ?? "...").slice(0, 100),
96
114
  options: [],
97
115
  default_member_permissions: this.defaultMemberPermissions
98
116
  ? (0, CommandBuilder_js_1.validateDefaultMemberPermissions)(this.defaultMemberPermissions)
99
117
  : undefined,
100
118
  dm_permission: typeof this.guildOnly === "boolean" ? !this.guildOnly : undefined,
119
+ ...(this.nameLocalizations ? { name_localizations: this.nameLocalizations } : {}),
120
+ ...(this.descriptionLocalizations ? { description_localizations: this.descriptionLocalizations } : {}),
101
121
  ...(this.integrationTypes !== undefined ? { integration_types: this.integrationTypes } : {}),
102
122
  ...(this.contexts !== undefined ? { contexts: this.contexts } : {}),
103
123
  };
@@ -1,3 +1,6 @@
1
+ import type { ApplicationCommandType, ApplicationIntegrationType, InteractionContextType } from "discord.js";
2
+ import type { LocalizationMap } from "./CommandBuilder.js";
3
+
1
4
  export declare enum Interactions {
2
5
  AnyInteraction = "anyInteraction",
3
6
  Autocomplete = "autocomplete",
@@ -21,6 +24,15 @@ export interface InteractionDataBuilder {
21
24
  description?: string;
22
25
  prefix?: string;
23
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;
24
36
  }
25
37
 
26
38
  export declare class InteractionBuilder {
@@ -29,11 +41,25 @@ export declare class InteractionBuilder {
29
41
  description: string;
30
42
  prefix?: string;
31
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;
32
51
  constructor(options?: InteractionDataBuilder);
33
52
  setName(name: string): this;
34
53
  setDescription(description: string): this;
35
54
  setPrefix(prefix: string): this;
36
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;
37
63
  hasPattern(): boolean;
38
64
  matches(key: string, interaction?: any): boolean;
39
65
  /**
@@ -42,6 +68,26 @@ export declare class InteractionBuilder {
42
68
  toJSON(): {
43
69
  name: string | undefined;
44
70
  description: string;
71
+ default_member_permissions?: string | null;
72
+ dm_permission?: boolean;
45
73
  prefix?: string;
74
+ name_localizations?: LocalizationMap;
75
+ description_localizations?: LocalizationMap;
76
+ integration_types?: Array<ApplicationIntegrationType | number>;
77
+ contexts?: Array<InteractionContextType | number>;
46
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;
47
93
  }
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InteractionBuilder = exports.Interactions = void 0;
4
4
 
5
+ const discord_js_1 = require("discord.js");
6
+ const CommandBuilder_js_1 = require("./CommandBuilder.js");
7
+
5
8
  var Interactions;
6
9
  (function (Interactions) {
7
10
  Interactions.AnyInteraction = "anyInteraction";
@@ -20,7 +23,8 @@ var Interactions;
20
23
 
21
24
  /**
22
25
  * Builder describing an interaction handler loaded by Gralonium.
23
- * Supports exact `name`/`customId` matching as well as `prefix` and `match` (RegExp or predicate).
26
+ * Supports exact `name`/`customId` matching, `prefix` / `match` routing,
27
+ * localizations, and context-menu application command metadata.
24
28
  */
25
29
  class InteractionBuilder {
26
30
  name;
@@ -28,6 +32,13 @@ class InteractionBuilder {
28
32
  description;
29
33
  prefix;
30
34
  match;
35
+ as_command;
36
+ guildOnly;
37
+ defaultMemberPermissions;
38
+ integrationTypes;
39
+ contexts;
40
+ nameLocalizations;
41
+ descriptionLocalizations;
31
42
 
32
43
  constructor(options) {
33
44
  this.name = options?.name;
@@ -35,6 +46,17 @@ class InteractionBuilder {
35
46
  this.description = options?.description || "...";
36
47
  this.prefix = options?.prefix;
37
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
+ );
38
60
  }
39
61
 
40
62
  setName(name) {
@@ -63,6 +85,41 @@ class InteractionBuilder {
63
85
  return this;
64
86
  }
65
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
+
66
123
  /**
67
124
  * Returns true if this builder uses a dynamic prefix, RegExp, or predicate matcher.
68
125
  */
@@ -93,10 +150,63 @@ class InteractionBuilder {
93
150
  toJSON() {
94
151
  return {
95
152
  name: this.name,
96
- description: this.description,
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 } : {}),
97
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 } : {}),
98
167
  };
99
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
+ }
100
210
  }
101
211
 
102
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
  }