gralonium 0.4.0 → 0.5.0

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 (40) hide show
  1. package/lib/classes/Client.d.ts +13 -3
  2. package/lib/classes/Client.js +23 -1
  3. package/lib/classes/Context.d.ts +2 -0
  4. package/lib/classes/Context.js +94 -21
  5. package/lib/classes/Cooldowns.d.ts +2 -0
  6. package/lib/classes/Cooldowns.js +28 -0
  7. package/lib/classes/Loader.d.ts +12 -3
  8. package/lib/classes/Loader.js +141 -19
  9. package/lib/classes/Plugins.js +3 -2
  10. package/lib/classes/Utils.d.ts +1 -1
  11. package/lib/classes/Utils.js +110 -20
  12. package/lib/classes/builders/CommandBuilder.d.ts +14 -0
  13. package/lib/classes/builders/CommandBuilder.js +50 -2
  14. package/lib/classes/builders/ComponentsV2Builder.d.ts +51 -3
  15. package/lib/classes/builders/ComponentsV2Builder.js +394 -72
  16. package/lib/classes/builders/GroupBuilder.d.ts +11 -0
  17. package/lib/classes/builders/GroupBuilder.js +21 -1
  18. package/lib/classes/builders/InteractionBuilder.d.ts +47 -0
  19. package/lib/classes/builders/InteractionBuilder.js +113 -2
  20. package/lib/classes/builders/ParamsBuilder.d.ts +118 -76
  21. package/lib/classes/builders/ParamsBuilder.js +167 -1
  22. package/lib/classes/builders/components/StyleMapper.d.ts +13 -1
  23. package/lib/classes/builders/components/StyleMapper.js +33 -8
  24. package/lib/classes/builders/components/helpers.d.ts +3 -0
  25. package/lib/classes/builders/components/helpers.js +56 -3
  26. package/lib/classes/builders/components/linter.d.ts +61 -0
  27. package/lib/classes/builders/components/linter.js +252 -0
  28. package/lib/classes/builders/components/overflow.d.ts +151 -0
  29. package/lib/classes/builders/components/overflow.js +534 -0
  30. package/lib/classes/views/V2Adaptive.d.ts +103 -0
  31. package/lib/classes/views/V2Adaptive.js +502 -0
  32. package/lib/classes/views/V2PersistentRouter.d.ts +124 -0
  33. package/lib/classes/views/V2PersistentRouter.js +511 -0
  34. package/lib/classes/views/V2View.d.ts +1 -0
  35. package/lib/classes/views/V2View.js +53 -15
  36. package/lib/experiments.d.ts +2 -0
  37. package/lib/experiments.js +2 -0
  38. package/lib/main.d.ts +4 -0
  39. package/lib/main.js +4 -0
  40. package/package.json +1 -1
@@ -7,6 +7,7 @@ const types_1 = require("util/types");
7
7
  const DJS = tslib_1.__importStar(require("discord.js"));
8
8
  const Errors = tslib_1.__importStar(require("./Errors.js"));
9
9
  const Cooldowns_js_1 = require("./Cooldowns.js");
10
+ const V2Adaptive_js_1 = require("./views/V2Adaptive.js");
10
11
 
11
12
  class Utils {
12
13
  static noop(n = null) {
@@ -133,7 +134,7 @@ class Utils {
133
134
  return paramsBuilder.params.map((param) => ({ ...param, value: undefined }));
134
135
  }
135
136
 
136
- static async transform(input, param, ctx, seeable = true) {
137
+ static async transform(input, param, ctx, seeable = true, attachmentIndex = 0) {
137
138
  if (!input && seeable) {
138
139
  return { break: false, value: null };
139
140
  }
@@ -149,27 +150,38 @@ class Utils {
149
150
 
150
151
  if (param.type === DJS.ApplicationCommandOptionType.String) {
151
152
  const value = String(input ?? "");
153
+ const maxLength = typeof param.max_length === "number" ? param.max_length : param.maxLength;
154
+ const minLength = typeof param.min_length === "number" ? param.min_length : param.minLength;
152
155
 
153
- if (typeof param.max_length === "number" && value.length > param.max_length) {
156
+ if (typeof maxLength === "number" && value.length > maxLength) {
154
157
  throw new Errors.InvalidParam(ctx, `${param.name} exceeds max length.`, { param });
155
158
  }
156
159
 
157
- if (typeof param.min_length === "number" && value.length < param.min_length) {
160
+ if (typeof minLength === "number" && value.length < minLength) {
158
161
  throw new Errors.InvalidParam(ctx, `${param.name} is under min length.`, { param });
159
162
  }
160
163
 
161
164
  return { break: false, value };
162
165
  }
163
166
 
164
- if (param.type === DJS.ApplicationCommandOptionType.Number) {
167
+ if (param.type === DJS.ApplicationCommandOptionType.Integer || param.type === DJS.ApplicationCommandOptionType.Number) {
165
168
  const value = Number(input);
166
- if (Number.isNaN(value)) throw new Errors.InvalidParamNumber(ctx, param);
169
+ if (String(input ?? "").trim() === "" || Number.isNaN(value)) {
170
+ throw new Errors.InvalidParamNumber(ctx, param);
171
+ }
172
+
173
+ if (param.type === DJS.ApplicationCommandOptionType.Integer && !Number.isInteger(value)) {
174
+ throw new Errors.InvalidParamNumber(ctx, param);
175
+ }
167
176
 
168
- if (typeof param.max_value === "number" && value > param.max_value) {
177
+ const maxValue = typeof param.max_value === "number" ? param.max_value : param.maxValue;
178
+ const minValue = typeof param.min_value === "number" ? param.min_value : param.minValue;
179
+
180
+ if (typeof maxValue === "number" && value > maxValue) {
169
181
  throw new Errors.InvalidParam(ctx, `${param.name} exceeds max value.`, { param });
170
182
  }
171
183
 
172
- if (typeof param.min_value === "number" && value < param.min_value) {
184
+ if (typeof minValue === "number" && value < minValue) {
173
185
  throw new Errors.InvalidParam(ctx, `${param.name} is under min value.`, { param });
174
186
  }
175
187
 
@@ -188,12 +200,33 @@ class Utils {
188
200
  throw new Errors.InvalidParamMember(ctx, param);
189
201
  }
190
202
 
203
+ if (param.type === DJS.ApplicationCommandOptionType.Mentionable) {
204
+ const rawInput = String(input ?? "").trim();
205
+ if (/^<@&\d+>$/.test(rawInput) && ctx.guild) {
206
+ const role = await Utils.getRole(rawInput, { guild: ctx.guild, force: true });
207
+ if (role) return { break: false, value: role };
208
+ }
209
+
210
+ const memberOrUser = ctx.guild
211
+ ? await Utils.getMember(rawInput, { guild: ctx.guild, force: true })
212
+ : await Utils.getUser(rawInput, ctx.bot);
213
+ if (memberOrUser) return { break: false, value: memberOrUser };
214
+
215
+ if (ctx.guild) {
216
+ const role = await Utils.getRole(rawInput, { guild: ctx.guild, force: true });
217
+ if (role) return { break: false, value: role };
218
+ }
219
+
220
+ throw new Errors.InvalidParam(ctx, `${param.name} must resolve to a valid user or role.`, { param });
221
+ }
222
+
191
223
  if (param.type === DJS.ApplicationCommandOptionType.Channel) {
192
224
  const channel = await Utils.getChannel(String(input), { guild: ctx.guild, force: true });
193
225
  if (!channel) throw new Errors.InvalidParamChannel(ctx, param);
194
226
 
195
- if (param.channel_types?.length && !param.channel_types.includes(channel.type)) {
196
- throw new Errors.InvalidChannelType(ctx, param, channel.type, param.channel_types);
227
+ const channelTypes = param.channel_types ?? param.channelTypes;
228
+ if (channelTypes?.length && !channelTypes.includes(channel.type)) {
229
+ throw new Errors.InvalidChannelType(ctx, param, channel.type, channelTypes);
197
230
  }
198
231
 
199
232
  return { break: false, value: channel };
@@ -206,7 +239,18 @@ class Utils {
206
239
  }
207
240
 
208
241
  if (param.type === DJS.ApplicationCommandOptionType.Attachment) {
209
- const attachment = ctx.message?.attachments?.first();
242
+ const attachments = ctx.message?.attachments;
243
+ const list = attachments
244
+ ? typeof attachments.values === "function"
245
+ ? [...attachments.values()]
246
+ : Array.isArray(attachments)
247
+ ? attachments
248
+ : []
249
+ : [];
250
+ const attachment =
251
+ list[attachmentIndex] ??
252
+ (attachmentIndex === 0 && typeof attachments?.first === "function" ? attachments.first() : null) ??
253
+ null;
210
254
  if (!attachment && param.required) throw new Errors.InvalidParamAttachment(ctx, param);
211
255
  return { break: false, value: attachment };
212
256
  }
@@ -223,12 +267,14 @@ class Utils {
223
267
  }
224
268
 
225
269
  let argIndex = 0;
270
+ let attachmentIndex = 0;
226
271
 
227
272
  for (let paramIndex = 0; paramIndex < params.length; paramIndex += 1) {
228
273
  const param = params[paramIndex];
229
274
 
230
275
  if (param.type === DJS.ApplicationCommandOptionType.Attachment) {
231
- const transformed = await Utils.transform("", param, ctx, false);
276
+ const transformed = await Utils.transform("", param, ctx, false, attachmentIndex);
277
+ attachmentIndex += 1;
232
278
  param.value = transformed.value;
233
279
  continue;
234
280
  }
@@ -277,12 +323,16 @@ class Utils {
277
323
  switch (param.type) {
278
324
  case DJS.ApplicationCommandOptionType.String:
279
325
  return interaction.options.getString(name, required);
326
+ case DJS.ApplicationCommandOptionType.Integer:
327
+ return interaction.options.getInteger(name, required);
280
328
  case DJS.ApplicationCommandOptionType.Number:
281
329
  return interaction.options.getNumber(name, required);
282
330
  case DJS.ApplicationCommandOptionType.Boolean:
283
331
  return interaction.options.getBoolean(name, required);
284
332
  case DJS.ApplicationCommandOptionType.User:
285
333
  return interaction.options.getMember(name) ?? interaction.options.getUser(name, required);
334
+ case DJS.ApplicationCommandOptionType.Mentionable:
335
+ return interaction.options.getMentionable(name, required);
286
336
  case DJS.ApplicationCommandOptionType.Channel:
287
337
  return interaction.options.getChannel(name, required);
288
338
  case DJS.ApplicationCommandOptionType.Role:
@@ -391,11 +441,12 @@ class Utils {
391
441
  const bucket = cooldown.bucket || Cooldowns_js_1.Bucket.User;
392
442
  const source = Utils.#resolveCooldownSource(ctx, bucket);
393
443
  const cooldownMs = cooldown.seconds * 1000;
444
+ const commandKey = Cooldowns_js_1.Cooldowns.resolveKey(command, ctx.parent);
394
445
 
395
- const active = await ctx.bot.cooldowns.check(command.data.name, source, cooldownMs, bucket);
446
+ const active = await ctx.bot.cooldowns.check(commandKey, source, cooldownMs, bucket);
396
447
  if (active) throw new Errors.CommandInCooldown(ctx, active.left);
397
448
 
398
- await ctx.bot.cooldowns.setCooldownSource(command.data.name, source, bucket, cooldownMs);
449
+ await ctx.bot.cooldowns.setCooldownSource(commandKey, source, bucket, cooldownMs);
399
450
  }
400
451
 
401
452
  static #validateContextRestrictions(ctx) {
@@ -471,7 +522,17 @@ class Utils {
471
522
  if (!canProceed) return;
472
523
 
473
524
  await Utils.#resolveCommandInput(ctx, command, options);
525
+
526
+ if (typeof ctx.bot?.ops?.beforeExecute === "function") {
527
+ const shouldContinue = await ctx.bot.ops.beforeExecute(ctx, command, options);
528
+ if (shouldContinue === false) return;
529
+ }
530
+
474
531
  await command.code(ctx);
532
+
533
+ if (typeof ctx.bot?.ops?.afterExecute === "function") {
534
+ await ctx.bot.ops.afterExecute(ctx, command, options);
535
+ }
475
536
  }
476
537
 
477
538
  static async #resolvePrefix(bot, ctx, message) {
@@ -593,6 +654,7 @@ class Utils {
593
654
 
594
655
  static #extractInteractionLookup(interaction) {
595
656
  const checks = [
657
+ ["isOverflowMenu", "overflowMenu", "customId"],
596
658
  ["isAutocomplete", "autocomplete", "commandName"],
597
659
  ["isButton", "button", "customId"],
598
660
  ["isModalSubmit", "modalSubmit", "customId"],
@@ -617,11 +679,26 @@ class Utils {
617
679
  const target = Utils.#extractInteractionLookup(interaction);
618
680
  if (!target) return null;
619
681
 
620
- const bucket = bot.loader.interactions?.[target.typeKey];
621
- const exact = bucket?.get?.(target.key);
622
- if (exact) return exact;
682
+ const resolveBucket = (typeKey, lookupKey = target.key) => {
683
+ if (!lookupKey) return null;
684
+ const bucket = bot.loader.interactions?.[typeKey];
685
+ const exact = bucket?.get?.(lookupKey);
686
+ if (exact) return exact;
687
+ return bot.loader.resolvePatternInteraction?.(typeKey, lookupKey, interaction) || null;
688
+ };
689
+
690
+ const direct = resolveBucket(target.typeKey);
691
+ if (direct) return direct;
692
+
693
+ if (target.typeKey === "overflowMenu") {
694
+ if (interaction.overflowMenuCustomId && interaction.overflowMenuCustomId !== target.key) {
695
+ const parentMatch = resolveBucket("overflowMenu", interaction.overflowMenuCustomId);
696
+ if (parentMatch) return parentMatch;
697
+ }
698
+ return resolveBucket("button");
699
+ }
623
700
 
624
- return bot.loader.resolvePatternInteraction?.(target.typeKey, target.key, interaction) || null;
701
+ return null;
625
702
  }
626
703
 
627
704
  static async #executeInteractionModule(bot, interaction, moduleData) {
@@ -648,13 +725,14 @@ class Utils {
648
725
  }
649
726
  }
650
727
 
651
- static async handleInteraction(bot, interaction) {
652
- if (!interaction) return;
728
+ static async handleInteraction(bot, rawInteraction) {
729
+ if (!rawInteraction) return;
653
730
 
731
+ const interaction = V2Adaptive_js_1.unwrapOverflowFallbackInteraction(rawInteraction);
654
732
  const ctx = bot.getContext(interaction);
655
733
  Utils.#validateContextRestrictions(ctx);
656
734
 
657
- if (interaction.isChatInputCommand()) {
735
+ if (interaction.isChatInputCommand?.()) {
658
736
  const resolved = Utils.#findSlashCommand(bot, interaction);
659
737
  if (!resolved) return;
660
738
 
@@ -667,6 +745,18 @@ class Utils {
667
745
  return;
668
746
  }
669
747
 
748
+ if (bot.persistentRouters?.size && typeof interaction.customId === "string") {
749
+ for (const router of bot.persistentRouters.values()) {
750
+ if (router.matches(interaction.customId)) {
751
+ const handled = await router.handle(interaction, bot);
752
+ if (handled) {
753
+ await Utils.#runAnyInteractionHooks(bot, interaction);
754
+ return;
755
+ }
756
+ }
757
+ }
758
+ }
759
+
670
760
  const matched = Utils.#resolveInteractionModule(bot, interaction);
671
761
  if (matched) {
672
762
  await Utils.#executeInteractionModule(bot, interaction, matched);
@@ -1,6 +1,10 @@
1
1
  import type { ApplicationIntegrationType, InteractionContextType } from "discord.js";
2
2
 
3
+ export type LocalizationMap = Record<string, string>;
4
+
3
5
  export declare function validateDefaultMemberPermissions(permissions: unknown): string | null | undefined;
6
+ export declare function normalizeNameLocalizations(map?: LocalizationMap | null): LocalizationMap | undefined;
7
+ export declare function normalizeDescriptionLocalizations(map?: LocalizationMap | null): LocalizationMap | undefined;
4
8
 
5
9
  export interface CommandDataBuilder {
6
10
  name: string;
@@ -18,6 +22,10 @@ export interface CommandDataBuilder {
18
22
  cooldown?: { seconds: number; bucket?: string };
19
23
  integrationTypes?: Array<ApplicationIntegrationType | number>;
20
24
  contexts?: Array<InteractionContextType | number>;
25
+ nameLocalizations?: LocalizationMap;
26
+ name_localizations?: LocalizationMap;
27
+ descriptionLocalizations?: LocalizationMap;
28
+ description_localizations?: LocalizationMap;
21
29
  }
22
30
 
23
31
  export declare class CommandBuilder {
@@ -36,6 +44,8 @@ export declare class CommandBuilder {
36
44
  cooldown?: { seconds: number; bucket?: string };
37
45
  integrationTypes?: Array<ApplicationIntegrationType | number>;
38
46
  contexts?: Array<InteractionContextType | number>;
47
+ nameLocalizations?: LocalizationMap;
48
+ descriptionLocalizations?: LocalizationMap;
39
49
  constructor(options?: CommandDataBuilder);
40
50
  setName(name: string): CommandBuilder;
41
51
  setDescription(description: string): CommandBuilder;
@@ -49,11 +59,15 @@ export declare class CommandBuilder {
49
59
  setCooldown(seconds: number, bucket?: string): CommandBuilder;
50
60
  setIntegrationTypes(...types: Array<ApplicationIntegrationType | number | Array<ApplicationIntegrationType | number>>): CommandBuilder;
51
61
  setContexts(...contexts: Array<InteractionContextType | number | Array<InteractionContextType | number>>): CommandBuilder;
62
+ setNameLocalizations(locales?: LocalizationMap | null): CommandBuilder;
63
+ setDescriptionLocalizations(locales?: LocalizationMap | null): CommandBuilder;
52
64
  toJSON(): {
53
65
  name: string;
54
66
  description: string;
55
67
  default_member_permissions: string | null | undefined;
56
68
  dm_permission: boolean | undefined;
69
+ name_localizations?: LocalizationMap;
70
+ description_localizations?: LocalizationMap;
57
71
  integration_types?: Array<ApplicationIntegrationType | number>;
58
72
  contexts?: Array<InteractionContextType | number>;
59
73
  };
@@ -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,8 +19,20 @@ import {
19
19
  ThumbnailBuilder,
20
20
  } from "discord.js";
21
21
  import type { DisableComponentsOptions, EmojiInput, ParsedEmoji } from "./components/helpers";
22
+ import type { V2LintOptions, V2LintResult } from "./components/linter";
23
+ import type {
24
+ MenuActionItemBuilder,
25
+ MenuActionItemStyle,
26
+ OverflowMenuBuilder,
27
+ OverflowMenuFallbackOptions,
28
+ OverflowMenuGroupBuilder,
29
+ OverflowMenuOptions,
30
+ OverflowMenuProxy,
31
+ } from "./components/overflow";
32
+ import type { ButtonStyleInput } from "./components/StyleMapper";
22
33
  import type { V2CardOptions, V2ConfirmOptions, V2ImageViewOptions, V2ListOptions } from "./components/templates";
23
34
  import { V2Text, type V2FieldRow } from "./components/text";
35
+ import type { Context, ContextSendOptions } from "../Context";
24
36
 
25
37
  export type ButtonStyleResolvable =
26
38
  | "primary"
@@ -109,9 +121,21 @@ export interface V2SectionOptions extends V2TextOptions {
109
121
  thumbnailDescription?: string;
110
122
  thumbnailSpoiler?: boolean;
111
123
  button?: ButtonBuilder | V2ButtonObjectOptions;
124
+ overflow?: OverflowMenuBuilder | OverflowMenuOptions | ((menu: OverflowMenuProxy) => unknown);
125
+ overflowFallback?: "select" | "buttons" | "none" | false | OverflowMenuFallbackOptions;
126
+ overflowPlaceholder?: string;
127
+ placeholder?: string;
112
128
  fallbackToText?: boolean;
113
129
  }
114
130
 
131
+ export interface V2OverflowSectionOptions extends V2TextOptions {
132
+ customId?: string;
133
+ disabled?: boolean;
134
+ placeholder?: string;
135
+ overflowPlaceholder?: string;
136
+ overflowFallback?: "select" | "buttons" | "none" | false | OverflowMenuFallbackOptions;
137
+ }
138
+
115
139
  export interface V2GalleryItemObject {
116
140
  url: string;
117
141
  description?: string;
@@ -185,6 +209,15 @@ export interface V2PayloadOptions {
185
209
  safeMentions?: boolean;
186
210
  allowedMentions?: MessageMentionOptions;
187
211
  files?: BaseMessageOptions["files"];
212
+ forceOverflowFallback?: boolean;
213
+ forceNativeOverflow?: boolean;
214
+ validate?: boolean;
215
+ }
216
+
217
+ export interface V2BuildOptions {
218
+ forceOverflowFallback?: boolean;
219
+ forceNativeOverflow?: boolean;
220
+ validate?: boolean;
188
221
  }
189
222
 
190
223
  export interface V2BuiltPayload {
@@ -223,6 +256,8 @@ export declare class ComponentsV2Builder {
223
256
  static readonly text: typeof V2Text;
224
257
  static clipText(text: string, maxLen?: number, fallback?: string): string;
225
258
  static resolveColor(color?: ColorResolvable, fallback?: ColorResolvable): number | null;
259
+ static setDefaultButtonStyle(style?: ButtonStyleInput | null): ButtonStyle;
260
+ static getDefaultButtonStyle(): ButtonStyle;
226
261
  static parseEmoji(emoji?: EmojiInput): ParsedEmoji | null;
227
262
  static isValidMediaUrl(url?: string | null): boolean;
228
263
  static isValidLinkUrl(url?: string | null): boolean;
@@ -230,6 +265,11 @@ export declare class ComponentsV2Builder {
230
265
  static disableMessageComponents(message: Message, options?: DisableComponentsOptions): Promise<Message | null>;
231
266
  static countTextLength(components: any[]): number;
232
267
  static countComponents(components: any[]): number;
268
+ static lint(target: unknown, options?: V2LintOptions): V2LintResult;
269
+ static OverflowMenuBuilder: typeof OverflowMenuBuilder;
270
+ static OverflowMenuGroupBuilder: typeof OverflowMenuGroupBuilder;
271
+ static MenuActionItemBuilder: typeof MenuActionItemBuilder;
272
+ static MenuActionItemStyle: typeof MenuActionItemStyle;
233
273
  static isBuilder(value: unknown): value is ComponentsV2Builder;
234
274
 
235
275
  constructor(options?: ComponentsV2BuilderOptions);
@@ -249,8 +289,12 @@ export declare class ComponentsV2Builder {
249
289
 
250
290
  addSection(
251
291
  texts: string | TextDisplayBuilder | Array<string | TextDisplayBuilder | false | null | undefined>,
252
- accessoryOrOptions?: ThumbnailBuilder | ButtonBuilder | V2SectionOptions
292
+ accessoryOrOptions?: ThumbnailBuilder | ButtonBuilder | OverflowMenuBuilder | V2SectionOptions
253
293
  ): this;
294
+ addOverflowSection(
295
+ texts: string | TextDisplayBuilder | Array<string | TextDisplayBuilder | false | null | undefined>,
296
+ options?: V2OverflowSectionOptions
297
+ ): OverflowMenuProxy;
254
298
 
255
299
  addGallery(itemsOrUrl: V2GalleryInput, options?: V2GalleryOptions): this;
256
300
  addAttachment(source: Buffer | Uint8Array | string | AttachmentBuilder, options?: V2AttachmentOptions): this;
@@ -278,11 +322,15 @@ export declare class ComponentsV2Builder {
278
322
  readonly remainingChars: number;
279
323
  readonly componentCount: number;
280
324
  readonly remainingComponents: number;
325
+ readonly hasOverflowMenu: boolean;
281
326
  readonly files: AttachmentBuilder[];
282
327
 
283
- build(): TopLevelV2Component[];
284
- toJSON(): Record<string, unknown>[];
328
+ build(options?: V2BuildOptions): TopLevelV2Component[];
329
+ toJSON(options?: V2BuildOptions): Record<string, unknown>[];
330
+ lint(options?: V2LintOptions): V2LintResult;
285
331
  toPayload(options?: V2PayloadOptions): V2BuiltPayload;
332
+ send(target: Context | any, options?: V2PayloadOptions & ContextSendOptions): Promise<any>;
333
+ edit(target: Message | any, options?: V2PayloadOptions): Promise<any>;
286
334
 
287
335
  static card(options?: V2CardOptions): ComponentsV2Builder;
288
336
  static imageView(options?: V2ImageViewOptions): ComponentsV2Builder;