lunibee 0.3.3 → 0.4.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 (125) hide show
  1. package/README.md +1 -1
  2. package/dist/builders/commands.d.ts +1 -1
  3. package/dist/builders/components.d.ts +9 -11
  4. package/dist/builders/embed.d.ts +1 -1
  5. package/dist/builders/index.d.ts +1 -1
  6. package/dist/builders/index.js +87 -1298
  7. package/dist/builders/index.js.map +3 -11
  8. package/dist/chunks/index-0wn81eng.js +2492 -0
  9. package/dist/chunks/index-0wn81eng.js.map +17 -0
  10. package/dist/chunks/index-2en489j6.js +40 -0
  11. package/dist/chunks/index-2en489j6.js.map +10 -0
  12. package/dist/chunks/index-3hyps48a.js +203 -0
  13. package/dist/chunks/index-3hyps48a.js.map +11 -0
  14. package/dist/chunks/index-57c5n3ms.js +2274 -0
  15. package/dist/chunks/index-57c5n3ms.js.map +19 -0
  16. package/dist/chunks/index-5yx92e36.js +1170 -0
  17. package/dist/chunks/index-5yx92e36.js.map +14 -0
  18. package/dist/chunks/index-690bp093.js +95 -0
  19. package/dist/chunks/index-690bp093.js.map +10 -0
  20. package/dist/chunks/index-7fp2hvmg.js +2155 -0
  21. package/dist/chunks/index-7fp2hvmg.js.map +24 -0
  22. package/dist/chunks/index-cnmsajvk.js +1119 -0
  23. package/dist/chunks/index-cnmsajvk.js.map +12 -0
  24. package/dist/chunks/index-fdvgk2sw.js +1310 -0
  25. package/dist/chunks/index-fdvgk2sw.js.map +21 -0
  26. package/dist/chunks/index-gyvps8b9.js +214 -0
  27. package/dist/chunks/index-gyvps8b9.js.map +12 -0
  28. package/dist/chunks/index-jzg4bh99.js +1533 -0
  29. package/dist/chunks/index-jzg4bh99.js.map +21 -0
  30. package/dist/chunks/index-mgw2yvrm.js +3547 -0
  31. package/dist/chunks/index-mgw2yvrm.js.map +25 -0
  32. package/dist/chunks/index-yh76b55h.js +3449 -0
  33. package/dist/chunks/index-yh76b55h.js.map +29 -0
  34. package/dist/collection/index.js +9 -1118
  35. package/dist/collection/index.js.map +3 -6
  36. package/dist/core/api.d.ts +3 -3
  37. package/dist/core/channel-create.d.ts +2 -2
  38. package/dist/core/commands.d.ts +3 -3
  39. package/dist/core/events.d.ts +4 -4
  40. package/dist/core/handles.d.ts +4 -4
  41. package/dist/core/index.d.ts +25 -20
  42. package/dist/core/index.js +68 -10130
  43. package/dist/core/index.js.map +3 -65
  44. package/dist/core/permissions.d.ts +1 -1
  45. package/dist/core/redis-cache.d.ts +1 -1
  46. package/dist/formatters/index.js +41 -110
  47. package/dist/formatters/index.js.map +3 -4
  48. package/dist/handlers/index.js +5 -37
  49. package/dist/handlers/index.js.map +3 -4
  50. package/dist/index.d.ts +21 -21
  51. package/dist/index.js +641 -16325
  52. package/dist/index.js.map +3 -92
  53. package/dist/managers/advanced.d.ts +3 -3
  54. package/dist/managers/application.d.ts +2 -2
  55. package/dist/managers/base.d.ts +1 -1
  56. package/dist/managers/emoji.d.ts +2 -2
  57. package/dist/managers/guild-resources.d.ts +6 -6
  58. package/dist/managers/guild.d.ts +3 -3
  59. package/dist/managers/index.d.ts +4 -8
  60. package/dist/managers/index.js +51 -4060
  61. package/dist/managers/index.js.map +3 -29
  62. package/dist/managers/member.d.ts +2 -2
  63. package/dist/managers/message.d.ts +14 -6
  64. package/dist/managers/role.d.ts +2 -2
  65. package/dist/managers/thread.d.ts +3 -3
  66. package/dist/managers/user.d.ts +7 -4
  67. package/dist/rest/index.d.ts +10 -35
  68. package/dist/rest/index.js +57 -2184
  69. package/dist/rest/index.js.map +3 -18
  70. package/dist/rest/limiter.d.ts +9 -1
  71. package/dist/rest/webhook.d.ts +2 -8
  72. package/dist/sharding/bus.d.ts +2 -2
  73. package/dist/sharding/cluster.d.ts +45 -5
  74. package/dist/sharding/context.d.ts +45 -3
  75. package/dist/sharding/gateway-bot.d.ts +2 -1
  76. package/dist/sharding/health.d.ts +1 -1
  77. package/dist/sharding/identify.d.ts +12 -0
  78. package/dist/sharding/index.d.ts +44 -11
  79. package/dist/sharding/index.js +60 -4620
  80. package/dist/sharding/index.js.map +3 -33
  81. package/dist/sharding/supervisor.d.ts +4 -2
  82. package/dist/structures/audit-log.d.ts +1 -1
  83. package/dist/structures/base.d.ts +6 -6
  84. package/dist/structures/channels.d.ts +1 -1
  85. package/dist/structures/embed.d.ts +1 -1
  86. package/dist/structures/index.d.ts +14 -14
  87. package/dist/structures/index.js +109 -2382
  88. package/dist/structures/index.js.map +3 -16
  89. package/dist/structures/interactions.d.ts +13 -9
  90. package/dist/structures/options.d.ts +1 -1
  91. package/dist/structures/permissions.d.ts +2 -2
  92. package/dist/structures/resources.d.ts +10 -10
  93. package/dist/structures/sticker.d.ts +1 -1
  94. package/dist/types/gateway.d.ts +2 -79
  95. package/dist/types/index.d.ts +0 -6
  96. package/dist/types/index.js +41 -272
  97. package/dist/types/index.js.map +3 -6
  98. package/dist/utils/index.js +23 -209
  99. package/dist/utils/index.js.map +3 -5
  100. package/dist/voice/connection.d.ts +200 -0
  101. package/dist/voice/crypto.d.ts +50 -0
  102. package/dist/voice/dave.d.ts +85 -0
  103. package/dist/voice/effects.d.ts +31 -0
  104. package/dist/voice/emitter.d.ts +14 -0
  105. package/dist/voice/gateway.d.ts +59 -0
  106. package/dist/voice/index.d.ts +25 -228
  107. package/dist/voice/index.js +111 -442
  108. package/dist/voice/index.js.map +3 -4
  109. package/dist/voice/libopus.d.ts +88 -0
  110. package/dist/voice/networking.d.ts +80 -0
  111. package/dist/voice/ogg.d.ts +24 -0
  112. package/dist/voice/opus.d.ts +18 -0
  113. package/dist/voice/player.d.ts +79 -0
  114. package/dist/voice/protocol.d.ts +76 -0
  115. package/dist/voice/receiver.d.ts +59 -0
  116. package/dist/voice/resource.d.ts +102 -0
  117. package/dist/voice/udp.d.ts +40 -0
  118. package/dist/ws/close-codes.d.ts +1 -1
  119. package/dist/ws/index.d.ts +25 -4
  120. package/dist/ws/index.js +47 -1336
  121. package/dist/ws/index.js.map +3 -17
  122. package/dist/ws/protocol.d.ts +1 -1
  123. package/dist/ws/send-budget.d.ts +0 -2
  124. package/dist/ws/state.d.ts +0 -10
  125. package/package.json +19 -16
@@ -0,0 +1,1170 @@
1
+ // @bun
2
+ import {
3
+ ComponentEnum2,
4
+ ButtonType2
5
+ } from "./index-gyvps8b9.js";
6
+
7
+ // packages/builders/src/clone.ts
8
+ function cloneData(value, depth = 0) {
9
+ if (value === null || typeof value !== "object")
10
+ return value;
11
+ if (depth > 64)
12
+ return structuredClone(value);
13
+ if (Array.isArray(value)) {
14
+ const out = new Array(value.length);
15
+ for (let i = 0;i < value.length; i++)
16
+ out[i] = cloneData(value[i], depth + 1);
17
+ return out;
18
+ }
19
+ const proto = Object.getPrototypeOf(value);
20
+ if (proto !== Object.prototype && proto !== null)
21
+ return structuredClone(value);
22
+ const from = value;
23
+ const out = {};
24
+ for (const key of Object.keys(from))
25
+ out[key] = cloneData(from[key], depth + 1);
26
+ return out;
27
+ }
28
+
29
+ // packages/builders/src/embed.ts
30
+ class CreateEmbed2 {
31
+ #data = {};
32
+ setTitle(value) {
33
+ if (value === null)
34
+ delete this.#data.title;
35
+ else
36
+ this.#data.title = validate(value, 256, "Embed title");
37
+ return this;
38
+ }
39
+ setDescription(value) {
40
+ if (value === null)
41
+ delete this.#data.description;
42
+ else
43
+ this.#data.description = validate(value, 4096, "Embed description");
44
+ return this;
45
+ }
46
+ setURL(value) {
47
+ if (value === null)
48
+ delete this.#data.url;
49
+ else
50
+ this.#data.url = url(value, "Embed URL");
51
+ return this;
52
+ }
53
+ setColor(value) {
54
+ if (!Number.isInteger(value) || value < 0 || value > 16777215)
55
+ throw new RangeError("Embed color must be an integer between 0 and 16777215.");
56
+ this.#data.color = value;
57
+ return this;
58
+ }
59
+ setTimestamp(value = new Date) {
60
+ const date = value instanceof Date ? value : new Date(value);
61
+ if (Number.isNaN(date.getTime()))
62
+ throw new RangeError("Embed timestamp must be a valid date.");
63
+ this.#data.timestamp = date.toISOString();
64
+ return this;
65
+ }
66
+ setFooter(value) {
67
+ this.#data.footer = {
68
+ text: validate(value.text, 2048, "Footer text"),
69
+ ...value.icon_url ? { icon_url: url(value.icon_url, "Footer icon URL") } : {}
70
+ };
71
+ return this;
72
+ }
73
+ setAuthor(value) {
74
+ this.#data.author = {
75
+ name: validate(value.name, 256, "Author name"),
76
+ ...value.url ? { url: url(value.url, "Author URL") } : {},
77
+ ...value.icon_url ? { icon_url: url(value.icon_url, "Author icon URL") } : {}
78
+ };
79
+ return this;
80
+ }
81
+ setThumbnail(value) {
82
+ if (value === null) {
83
+ delete this.#data.thumbnail;
84
+ return this;
85
+ }
86
+ const valueURL = typeof value === "string" ? value : value.url;
87
+ this.#data.thumbnail = { url: url(valueURL, "Thumbnail URL") };
88
+ return this;
89
+ }
90
+ setImage(value) {
91
+ if (value === null) {
92
+ delete this.#data.image;
93
+ return this;
94
+ }
95
+ const valueURL = typeof value === "string" ? value : value.url;
96
+ this.#data.image = { url: url(valueURL, "Image URL") };
97
+ return this;
98
+ }
99
+ addFields(...fields) {
100
+ const resolved = fields.length === 1 && Array.isArray(fields[0]) ? fields[0] : fields;
101
+ if (!resolved.length)
102
+ throw new TypeError("At least one embed field is required.");
103
+ const current = this.#data.fields ?? [];
104
+ if (current.length + resolved.length > 25)
105
+ throw new RangeError("An embed cannot contain more than 25 fields.");
106
+ for (const field of resolved) {
107
+ validate(field.name, 256, "Embed field name");
108
+ validate(field.value, 1024, "Embed field value");
109
+ }
110
+ this.#data.fields = [
111
+ ...current,
112
+ ...resolved.map((field) => ({ ...field }))
113
+ ];
114
+ return this;
115
+ }
116
+ setFields(fields) {
117
+ this.#data.fields = [];
118
+ return this.addFields(...fields);
119
+ }
120
+ spliceFields(index, deleteCount, ...fields) {
121
+ const current = [...this.#data.fields ?? []];
122
+ if (!Number.isInteger(index) || !Number.isInteger(deleteCount) || index < 0 || deleteCount < 0)
123
+ throw new RangeError("Field index and delete count must be non-negative integers.");
124
+ for (const field of fields) {
125
+ validate(field.name, 256, "Embed field name");
126
+ validate(field.value, 1024, "Embed field value");
127
+ }
128
+ current.splice(index, deleteCount, ...fields.map((f) => ({ ...f })));
129
+ if (current.length > 25)
130
+ throw new RangeError("An embed cannot contain more than 25 fields.");
131
+ this.#data.fields = current;
132
+ return this;
133
+ }
134
+ clearFields() {
135
+ delete this.#data.fields;
136
+ return this;
137
+ }
138
+ clearTitle() {
139
+ delete this.#data.title;
140
+ return this;
141
+ }
142
+ clearDescription() {
143
+ delete this.#data.description;
144
+ return this;
145
+ }
146
+ get data() {
147
+ return this.toJSON();
148
+ }
149
+ toJSON() {
150
+ const data = this.#data;
151
+ const total = (data.title?.length ?? 0) + (data.description?.length ?? 0) + (data.footer?.text.length ?? 0) + (data.author?.name.length ?? 0) + (data.fields ?? []).reduce((sum, field) => sum + field.name.length + field.value.length, 0);
152
+ if (total > 6000)
153
+ throw new RangeError(`An embed cannot contain more than 6000 characters in total (this one has ${total}).`);
154
+ return cloneData(data);
155
+ }
156
+ }
157
+ function validate(value, max, field) {
158
+ if (typeof value !== "string" || value.length === 0 || value.length > max)
159
+ throw new RangeError(`${field} must contain 1-${max} characters.`);
160
+ return value;
161
+ }
162
+ function url(value, field) {
163
+ let parsed;
164
+ try {
165
+ parsed = new URL(value);
166
+ } catch (error) {
167
+ throw new TypeError(`${field} must be a valid URL.`, { cause: error });
168
+ }
169
+ if (!["http:", "https:", "attachment:"].includes(parsed.protocol))
170
+ throw new TypeError(`${field} must use http, https or attachment.`);
171
+ return parsed.toString();
172
+ }
173
+ // packages/builders/src/components.ts
174
+ var TextInputType2 = { Short: 1, Paragraph: 2 };
175
+
176
+ class CreateActionRow2 {
177
+ #components = [];
178
+ addComponents(...components) {
179
+ if (!components.length)
180
+ throw new TypeError("At least one component is required.");
181
+ if (this.#components.length + components.length > 5)
182
+ throw new RangeError("An action row cannot contain more than 5 components.");
183
+ this.#components.push(...components);
184
+ return this;
185
+ }
186
+ clearComponents() {
187
+ this.#components.length = 0;
188
+ return this;
189
+ }
190
+ toJSON() {
191
+ const components = this.#components.map((component) => component.toJSON());
192
+ if (components.length === 0)
193
+ throw new RangeError("An action row needs at least one component.");
194
+ const types = components.map((component) => component.type);
195
+ if (types.some((type) => type !== ComponentEnum2.Button) && components.length > 1)
196
+ throw new RangeError("A select menu or text input must be alone in its action row.");
197
+ return { type: ComponentEnum2.ActionRow, components };
198
+ }
199
+ }
200
+
201
+ class CreateSelectMenu {
202
+ #select;
203
+ constructor(data) {
204
+ this.#select = data;
205
+ }
206
+ setCustomId(value) {
207
+ validateText(value, 100, "Component custom ID");
208
+ this.#select.custom_id = value;
209
+ return this;
210
+ }
211
+ setPlaceholder(value) {
212
+ validateText(value, 150, "Component placeholder");
213
+ this.#select.placeholder = value;
214
+ return this;
215
+ }
216
+ setMinValues(value) {
217
+ validateCount(value, "min_values", 0);
218
+ this.#select.min_values = value;
219
+ return this;
220
+ }
221
+ setMaxValues(value) {
222
+ validateCount(value, "max_values", 1);
223
+ this.#select.max_values = value;
224
+ return this;
225
+ }
226
+ setRequired(value = true) {
227
+ this.#select.required = value;
228
+ return this;
229
+ }
230
+ setDisabled(value = true) {
231
+ this.#select.disabled = value;
232
+ return this;
233
+ }
234
+ }
235
+
236
+ class CreateStringSelect2 extends CreateSelectMenu {
237
+ #data;
238
+ constructor() {
239
+ const data = {
240
+ type: ComponentEnum2.StringSelect
241
+ };
242
+ super(data);
243
+ this.#data = data;
244
+ }
245
+ addOptions(...options) {
246
+ if (!options.length)
247
+ throw new TypeError("At least one select option is required.");
248
+ const current = this.#data.options ?? [];
249
+ if (current.length + options.length > 25)
250
+ throw new RangeError("A string select cannot contain more than 25 options.");
251
+ for (const option of options) {
252
+ validateText(option.label, 100, "Select option label");
253
+ validateText(option.value, 100, "Select option value");
254
+ if (option.description)
255
+ validateText(option.description, 100, "Select option description");
256
+ }
257
+ this.#data.options = [
258
+ ...current,
259
+ ...options.map((option) => ({ ...option }))
260
+ ];
261
+ return this;
262
+ }
263
+ toJSON() {
264
+ assertSelect(this.#data);
265
+ const count = this.#data.options?.length ?? 0;
266
+ if (count === 0)
267
+ throw new RangeError("A string select needs at least one option.");
268
+ if ((this.#data.max_values ?? 1) > count)
269
+ throw new RangeError("max_values cannot exceed the number of options.");
270
+ return cloneData(this.#data);
271
+ }
272
+ }
273
+
274
+ class CreateButton2 {
275
+ #data = {
276
+ type: ComponentEnum2.Button,
277
+ style: ButtonType2.Secondary
278
+ };
279
+ setStyle(style) {
280
+ const data = this.#data;
281
+ data.style = style;
282
+ if (style === ButtonType2.Link) {
283
+ delete data.custom_id;
284
+ delete data.sku_id;
285
+ } else if (style === ButtonType2.Premium) {
286
+ delete data.custom_id;
287
+ delete data.url;
288
+ delete data.label;
289
+ delete data.emoji;
290
+ } else {
291
+ delete data.url;
292
+ delete data.sku_id;
293
+ }
294
+ return this;
295
+ }
296
+ setCustomId(value) {
297
+ validateText(value, 100, "Button custom ID");
298
+ if (this.#data.style === ButtonType2.Link)
299
+ throw new TypeError("Link buttons cannot use custom IDs.");
300
+ this.#data.custom_id = value;
301
+ return this;
302
+ }
303
+ setLabel(value) {
304
+ validateText(value, 80, "Button label");
305
+ this.#data.label = value;
306
+ return this;
307
+ }
308
+ setURL(value) {
309
+ validateText(value, 512, "Button URL");
310
+ let url;
311
+ try {
312
+ url = new URL(value);
313
+ } catch (error) {
314
+ throw new TypeError("Button URL must be a valid URL.", {
315
+ cause: error
316
+ });
317
+ }
318
+ if (!["http:", "https:", "discord:"].includes(url.protocol))
319
+ throw new TypeError("Button URL must use http, https or discord.");
320
+ this.setStyle(ButtonType2.Link);
321
+ this.#data.url = url.toString();
322
+ return this;
323
+ }
324
+ setSKUId(skuId) {
325
+ validateText(skuId, 20, "Button SKU ID");
326
+ this.setStyle(ButtonType2.Premium);
327
+ this.#data.sku_id = skuId;
328
+ return this;
329
+ }
330
+ setEmoji(emoji) {
331
+ this.#data.emoji = typeof emoji === "string" ? { name: emoji } : { ...emoji };
332
+ return this;
333
+ }
334
+ setDisabled(value = true) {
335
+ this.#data.disabled = value;
336
+ return this;
337
+ }
338
+ toJSON() {
339
+ const data = this.#data;
340
+ if (data.style === ButtonType2.Link) {
341
+ if (!data.url)
342
+ throw new TypeError("Link buttons require a URL.");
343
+ if (data.custom_id || data.sku_id)
344
+ throw new TypeError("Link buttons cannot have a custom ID or SKU ID.");
345
+ } else if (data.style === ButtonType2.Premium) {
346
+ if (!data.sku_id)
347
+ throw new TypeError("Premium buttons require a SKU ID.");
348
+ if (data.custom_id || data.url || data.label || data.emoji)
349
+ throw new TypeError("Premium buttons cannot have a custom ID, URL, label or emoji.");
350
+ } else {
351
+ if (!data.custom_id)
352
+ throw new TypeError("Non-link buttons require a custom ID.");
353
+ if (data.url || data.sku_id)
354
+ throw new TypeError("Only link buttons have a URL and only premium buttons have a SKU ID.");
355
+ }
356
+ if (data.style !== ButtonType2.Premium && !data.label && !data.emoji)
357
+ throw new TypeError("Buttons require a label or an emoji.");
358
+ return cloneData(data);
359
+ }
360
+ }
361
+
362
+ class CreateEntitySelect2 extends CreateSelectMenu {
363
+ #data;
364
+ constructor(type) {
365
+ if (type !== ComponentEnum2.UserSelect && type !== ComponentEnum2.RoleSelect && type !== ComponentEnum2.MentionableSelect && type !== ComponentEnum2.ChannelSelect)
366
+ throw new TypeError("Invalid select component type.");
367
+ const data = { type };
368
+ super(data);
369
+ this.#data = data;
370
+ }
371
+ setDefaultValues(...values) {
372
+ this.#data.default_values = values.map((value) => ({ ...value }));
373
+ return this;
374
+ }
375
+ toJSON() {
376
+ assertSelect(this.#data);
377
+ return cloneData(this.#data);
378
+ }
379
+ }
380
+
381
+ class CreateModal2 {
382
+ #components = [];
383
+ #custom_id;
384
+ #title;
385
+ setCustomId(value) {
386
+ validateText(value, 100, "Modal custom ID");
387
+ this.#custom_id = value;
388
+ return this;
389
+ }
390
+ setTitle(value) {
391
+ validateText(value, 45, "Modal title");
392
+ this.#title = value;
393
+ return this;
394
+ }
395
+ addComponents(...components) {
396
+ if (!components.length)
397
+ throw new TypeError("At least one modal component is required.");
398
+ if (this.#components.length + components.length > 5)
399
+ throw new RangeError("A modal cannot contain more than 5 action rows.");
400
+ this.#components.push(...components);
401
+ return this;
402
+ }
403
+ addTextInputs(...inputs) {
404
+ return this.addComponents(...inputs.map((input) => new CreateActionRow2().addComponents(input)));
405
+ }
406
+ toJSON() {
407
+ if (!this.#custom_id || !this.#title)
408
+ throw new TypeError("Modals require a custom ID and a title.");
409
+ if (this.#components.length === 0)
410
+ throw new RangeError("Modals require at least one component.");
411
+ return {
412
+ type: 9,
413
+ custom_id: this.#custom_id,
414
+ title: this.#title,
415
+ components: this.#components.map((component) => component.toJSON())
416
+ };
417
+ }
418
+ }
419
+
420
+ class CreateTextInput2 {
421
+ #data = {
422
+ type: ComponentEnum2.TextInput,
423
+ style: TextInputType2.Short
424
+ };
425
+ setStyle(style) {
426
+ this.#data.style = style;
427
+ return this;
428
+ }
429
+ setCustomId(value) {
430
+ validateText(value, 100, "Text input custom ID");
431
+ this.#data.custom_id = value;
432
+ return this;
433
+ }
434
+ setLabel(value) {
435
+ validateText(value, 45, "Text input label");
436
+ this.#data.label = value;
437
+ return this;
438
+ }
439
+ setPlaceholder(value) {
440
+ validateText(value, 100, "Text input placeholder");
441
+ this.#data.placeholder = value;
442
+ return this;
443
+ }
444
+ setMinLength(value) {
445
+ validateLength(value, "min_length", 4000);
446
+ this.#data.min_length = value;
447
+ return this;
448
+ }
449
+ setMaxLength(value) {
450
+ validateLength(value, "max_length", 4000);
451
+ this.#data.max_length = value;
452
+ return this;
453
+ }
454
+ setRequired(value = true) {
455
+ this.#data.required = value;
456
+ return this;
457
+ }
458
+ setValue(value) {
459
+ validateText(value, 4000, "Text input value");
460
+ this.#data.value = value;
461
+ return this;
462
+ }
463
+ toJSON() {
464
+ const data = this.#data;
465
+ if (!data.custom_id)
466
+ throw new TypeError("Text inputs require a custom ID.");
467
+ if (data.min_length !== undefined && data.max_length !== undefined && data.min_length > data.max_length)
468
+ throw new RangeError("min_length cannot exceed max_length.");
469
+ return cloneData(data);
470
+ }
471
+ }
472
+
473
+ class CreateContainer2 {
474
+ #components = [];
475
+ #accentColor;
476
+ #spoiler;
477
+ addComponents(...components) {
478
+ if (!components.length)
479
+ throw new TypeError("At least one component is required.");
480
+ this.#components.push(...components);
481
+ return this;
482
+ }
483
+ setAccentColor(color) {
484
+ if (!Number.isInteger(color) || color < 0 || color > 16777215) {
485
+ throw new RangeError("Accent color must be an integer between 0 and 16777215 (0xFFFFFF).");
486
+ }
487
+ this.#accentColor = color;
488
+ return this;
489
+ }
490
+ setSpoiler(spoiler = true) {
491
+ this.#spoiler = spoiler;
492
+ return this;
493
+ }
494
+ toJSON() {
495
+ const data = {
496
+ type: ComponentEnum2.Container,
497
+ components: this.#components.map((c) => c.toJSON())
498
+ };
499
+ if (this.#accentColor !== undefined)
500
+ data.accent_color = this.#accentColor;
501
+ if (this.#spoiler !== undefined)
502
+ data.spoiler = this.#spoiler;
503
+ return data;
504
+ }
505
+ }
506
+
507
+ class CreateSection2 {
508
+ #components = [];
509
+ #accessory;
510
+ addComponents(...components) {
511
+ if (!components.length)
512
+ throw new TypeError("At least one component is required.");
513
+ this.#components.push(...components);
514
+ return this;
515
+ }
516
+ setAccessory(accessory) {
517
+ this.#accessory = accessory;
518
+ return this;
519
+ }
520
+ toJSON() {
521
+ return {
522
+ type: ComponentEnum2.Section,
523
+ components: this.#components.length ? this.#components.map((c) => c.toJSON()) : undefined,
524
+ accessory: this.#accessory?.toJSON()
525
+ };
526
+ }
527
+ }
528
+
529
+ class CreateTextDisplay2 {
530
+ #content = "";
531
+ setContent(content) {
532
+ validateText(content, 4000, "Text display content");
533
+ this.#content = content;
534
+ return this;
535
+ }
536
+ toJSON() {
537
+ return {
538
+ type: ComponentEnum2.TextDisplay,
539
+ content: this.#content
540
+ };
541
+ }
542
+ }
543
+
544
+ class CreateMediaGallery2 {
545
+ #items = [];
546
+ addItems(...items) {
547
+ if (!items.length) {
548
+ throw new TypeError("At least one media gallery item is required.");
549
+ }
550
+ if (this.#items.length + items.length > 10) {
551
+ throw new RangeError("MediaGallery can only contain up to 10 items.");
552
+ }
553
+ this.#items.push(...items.map(({ url, description, spoiler }) => ({
554
+ media: { url },
555
+ ...description !== undefined ? { description } : {},
556
+ ...spoiler !== undefined ? { spoiler } : {}
557
+ })));
558
+ return this;
559
+ }
560
+ toJSON() {
561
+ return {
562
+ type: ComponentEnum2.MediaGallery,
563
+ items: cloneData(this.#items)
564
+ };
565
+ }
566
+ }
567
+
568
+ class CreateFileComponent2 {
569
+ #url = "";
570
+ #spoiler;
571
+ setUrl(url) {
572
+ validateText(url, 2048, "File component URL");
573
+ this.#url = url;
574
+ return this;
575
+ }
576
+ setSpoiler(spoiler = true) {
577
+ this.#spoiler = spoiler;
578
+ return this;
579
+ }
580
+ toJSON() {
581
+ if (!this.#url)
582
+ throw new Error("File component must have a URL.");
583
+ const data = {
584
+ type: ComponentEnum2.File,
585
+ file: { url: this.#url }
586
+ };
587
+ if (this.#spoiler !== undefined)
588
+ data.spoiler = this.#spoiler;
589
+ return data;
590
+ }
591
+ }
592
+
593
+ class CreateSeparator2 {
594
+ #spacing;
595
+ #divider;
596
+ setSpacing(spacing) {
597
+ this.#spacing = spacing;
598
+ return this;
599
+ }
600
+ setDivider(divider = true) {
601
+ this.#divider = divider;
602
+ return this;
603
+ }
604
+ toJSON() {
605
+ const data = {
606
+ type: ComponentEnum2.Separator
607
+ };
608
+ if (this.#spacing !== undefined)
609
+ data.spacing = this.#spacing;
610
+ if (this.#divider !== undefined)
611
+ data.divider = this.#divider;
612
+ return data;
613
+ }
614
+ }
615
+
616
+ class CreateThumbnail2 {
617
+ #url = "";
618
+ #description;
619
+ #spoiler;
620
+ setUrl(url) {
621
+ validateText(url, 2048, "Thumbnail URL");
622
+ this.#url = url;
623
+ return this;
624
+ }
625
+ setDescription(description) {
626
+ validateText(description, 1024, "Thumbnail description");
627
+ this.#description = description;
628
+ return this;
629
+ }
630
+ setSpoiler(spoiler = true) {
631
+ this.#spoiler = spoiler;
632
+ return this;
633
+ }
634
+ toJSON() {
635
+ const data = {
636
+ type: ComponentEnum2.Thumbnail,
637
+ media: { url: this.#url }
638
+ };
639
+ if (this.#description !== undefined)
640
+ data.description = this.#description;
641
+ if (this.#spoiler !== undefined)
642
+ data.spoiler = this.#spoiler;
643
+ return data;
644
+ }
645
+ }
646
+
647
+ class CreateContentInventoryEntry2 {
648
+ #id = "";
649
+ setId(id) {
650
+ validateText(id, 100, "Content inventory entry ID");
651
+ this.#id = id;
652
+ return this;
653
+ }
654
+ toJSON() {
655
+ return {
656
+ type: ComponentEnum2.ContentInventoryEntry,
657
+ id: this.#id
658
+ };
659
+ }
660
+ }
661
+ function validateText(value, max, field) {
662
+ if (typeof value !== "string")
663
+ throw new TypeError(`${field} must be a string.`);
664
+ if (!value.trim())
665
+ throw new RangeError(`${field} must be a non-empty string.`);
666
+ if (value.length > max)
667
+ throw new RangeError(`${field} cannot exceed ${max} characters.`);
668
+ }
669
+ function validateCount(value, field, min, max = 25) {
670
+ if (!Number.isInteger(value) || value < min || value > max)
671
+ throw new RangeError(`${field} must be an integer between ${min} and ${max}.`);
672
+ }
673
+ function validateLength(value, field, max = 4000) {
674
+ if (!Number.isInteger(value) || value < 0 || value > max)
675
+ throw new RangeError(`${field} must be an integer between 0 and ${max}.`);
676
+ }
677
+
678
+ class CreateUserSelect2 extends CreateEntitySelect2 {
679
+ constructor() {
680
+ super(ComponentEnum2.UserSelect);
681
+ }
682
+ }
683
+
684
+ class CreateRoleSelect2 extends CreateEntitySelect2 {
685
+ constructor() {
686
+ super(ComponentEnum2.RoleSelect);
687
+ }
688
+ }
689
+
690
+ class CreateMentionableSelect2 extends CreateEntitySelect2 {
691
+ constructor() {
692
+ super(ComponentEnum2.MentionableSelect);
693
+ }
694
+ }
695
+
696
+ class CreateChannelSelect2 extends CreateEntitySelect2 {
697
+ constructor() {
698
+ super(ComponentEnum2.ChannelSelect);
699
+ }
700
+ }
701
+ function assertSelect(data) {
702
+ if (!data.custom_id)
703
+ throw new TypeError("Select menus require a custom ID.");
704
+ if ((data.min_values ?? 1) > (data.max_values ?? 1))
705
+ throw new RangeError("min_values cannot exceed max_values.");
706
+ }
707
+ var IS_COMPONENTS_V2 = 1 << 15;
708
+ function componentsV2Message2(components, options) {
709
+ const list = Array.isArray(components) ? components : [components];
710
+ if (!list.length)
711
+ throw new TypeError("A Components V2 message needs at least one component.");
712
+ return {
713
+ ...options ?? {},
714
+ components: list.map((component) => component.toJSON()),
715
+ flags: (options?.flags ?? 0) | IS_COMPONENTS_V2
716
+ };
717
+ }
718
+ // packages/builders/src/commands.ts
719
+ var ApplicationCommandOptionEnum2 = {
720
+ Subcommand: 1,
721
+ SubcommandGroup: 2,
722
+ String: 3,
723
+ Integer: 4,
724
+ Boolean: 5,
725
+ User: 6,
726
+ Channel: 7,
727
+ Role: 8,
728
+ Mentionable: 9,
729
+ Number: 10,
730
+ Attachment: 11
731
+ };
732
+ function validateContexts(contexts) {
733
+ if (contexts.some((context) => context !== 0 && context !== 1 && context !== 2))
734
+ throw new RangeError("Command contexts must be 0, 1 or 2.");
735
+ }
736
+
737
+ class CreateSlashCommand2 {
738
+ #data = { type: 1 };
739
+ setName(name) {
740
+ validateName(name, "Command name");
741
+ this.#data.name = name;
742
+ return this;
743
+ }
744
+ setDescription(description) {
745
+ validateText2(description, "Command description", 100);
746
+ this.#data.description = description;
747
+ return this;
748
+ }
749
+ setContexts(...contexts) {
750
+ validateContexts(contexts);
751
+ this.#data.contexts = [...contexts];
752
+ return this;
753
+ }
754
+ setNSFW(nsfw = true) {
755
+ this.#data.nsfw = nsfw;
756
+ return this;
757
+ }
758
+ setNsfw(nsfw = true) {
759
+ return this.setNSFW(nsfw);
760
+ }
761
+ setDefaultMemberPermissions(permissions) {
762
+ this.#data.default_member_permissions = permissions === null ? null : BigInt(permissions).toString();
763
+ return this;
764
+ }
765
+ setIntegrationTypes(...types) {
766
+ this.#data.integration_types = [...types];
767
+ return this;
768
+ }
769
+ addStringOption(configure) {
770
+ return this.addOption(configure(new CreateStringOption2));
771
+ }
772
+ addIntegerOption(configure) {
773
+ return this.addOption(configure(new CreateIntegerOption2));
774
+ }
775
+ addNumberOption(configure) {
776
+ return this.addOption(configure(new CreateNumberOption2));
777
+ }
778
+ addBooleanOption(configure) {
779
+ return this.addOption(configure(new CreateBooleanOption2));
780
+ }
781
+ addUserOption(configure) {
782
+ return this.addOption(configure(new CreateUserOption2));
783
+ }
784
+ addChannelOption(configure) {
785
+ return this.addOption(configure(new CreateChannelOption2));
786
+ }
787
+ addRoleOption(configure) {
788
+ return this.addOption(configure(new CreateRoleOption2));
789
+ }
790
+ addMentionableOption(configure) {
791
+ return this.addOption(configure(new CreateMentionableOption2));
792
+ }
793
+ addAttachmentOption(configure) {
794
+ return this.addOption(configure(new CreateAttachmentOption2));
795
+ }
796
+ addSubcommand(configure) {
797
+ return this.addOption(configure(new CreateSubcommand2));
798
+ }
799
+ addSubcommandGroup(configure) {
800
+ return this.addOption(configure(new CreateSubcommandGroup2));
801
+ }
802
+ toJSON() {
803
+ return cloneData(this.#data);
804
+ }
805
+ addOption(option) {
806
+ this.#data.options = appendOption(this.#data.options, option.toJSON(), "application command");
807
+ return this;
808
+ }
809
+ }
810
+
811
+ class CreateCommandOption2 {
812
+ data;
813
+ constructor(type) {
814
+ this.data = { type };
815
+ }
816
+ setName(name) {
817
+ validateName(name, "Option name");
818
+ this.data.name = name;
819
+ return this;
820
+ }
821
+ setDescription(description) {
822
+ validateText2(description, "Option description", 100);
823
+ this.data.description = description;
824
+ return this;
825
+ }
826
+ setRequired(required = true) {
827
+ this.data.required = required;
828
+ return this;
829
+ }
830
+ setAutocomplete(enabled = true) {
831
+ if (enabled && Array.isArray(this.data.choices) && this.data.choices.length)
832
+ throw new RangeError("Autocomplete options cannot define choices.");
833
+ this.data.autocomplete = enabled;
834
+ return this;
835
+ }
836
+ toJSON() {
837
+ return cloneData(this.data);
838
+ }
839
+ }
840
+
841
+ class CreateStringOption2 extends CreateCommandOption2 {
842
+ constructor() {
843
+ super(ApplicationCommandOptionEnum2.String);
844
+ }
845
+ addChoices(...choices) {
846
+ for (const choice of choices)
847
+ validateText2(choice.value, "Choice value", 100);
848
+ appendChoices(this.data, choices);
849
+ return this;
850
+ }
851
+ setMinLength(value) {
852
+ validateIntegerRange(value, 0, 6000, "min_length");
853
+ this.data.min_length = value;
854
+ return this;
855
+ }
856
+ setMaxLength(value) {
857
+ validateIntegerRange(value, 1, 6000, "max_length");
858
+ if (this.data.min_length !== undefined && this.data.min_length > value)
859
+ throw new RangeError("min_length cannot exceed max_length.");
860
+ this.data.max_length = value;
861
+ return this;
862
+ }
863
+ }
864
+
865
+ class CreateNumericOption extends CreateCommandOption2 {
866
+ #integer;
867
+ constructor(type, integer) {
868
+ super(type);
869
+ this.#integer = integer;
870
+ }
871
+ setMinValue(value) {
872
+ validateNumberRange(value, -MAX_SAFE, MAX_SAFE, "min_value", this.#integer);
873
+ const max = this.data.max_value;
874
+ if (max !== undefined && value > max)
875
+ throw new RangeError("min_value cannot exceed max_value.");
876
+ this.data.min_value = value;
877
+ return this;
878
+ }
879
+ setMaxValue(value) {
880
+ validateNumberRange(value, -MAX_SAFE, MAX_SAFE, "max_value", this.#integer);
881
+ const min = this.data.min_value;
882
+ if (min !== undefined && min > value)
883
+ throw new RangeError("min_value cannot exceed max_value.");
884
+ this.data.max_value = value;
885
+ return this;
886
+ }
887
+ setAutocomplete(enabled = true) {
888
+ if (enabled && Array.isArray(this.data.choices) && this.data.choices.length)
889
+ throw new RangeError("Autocomplete options cannot define choices.");
890
+ this.data.autocomplete = enabled;
891
+ return this;
892
+ }
893
+ addChoices(...choices) {
894
+ appendChoices(this.data, choices);
895
+ return this;
896
+ }
897
+ }
898
+
899
+ class CreateIntegerOption2 extends CreateNumericOption {
900
+ constructor() {
901
+ super(ApplicationCommandOptionEnum2.Integer, true);
902
+ }
903
+ }
904
+
905
+ class CreateNumberOption2 extends CreateNumericOption {
906
+ constructor() {
907
+ super(ApplicationCommandOptionEnum2.Number, false);
908
+ }
909
+ }
910
+
911
+ class CreateBooleanOption2 extends CreateCommandOption2 {
912
+ constructor() {
913
+ super(ApplicationCommandOptionEnum2.Boolean);
914
+ }
915
+ }
916
+
917
+ class CreateUserOption2 extends CreateCommandOption2 {
918
+ constructor() {
919
+ super(ApplicationCommandOptionEnum2.User);
920
+ }
921
+ }
922
+
923
+ class CreateRoleOption2 extends CreateCommandOption2 {
924
+ constructor() {
925
+ super(ApplicationCommandOptionEnum2.Role);
926
+ }
927
+ }
928
+
929
+ class CreateMentionableOption2 extends CreateCommandOption2 {
930
+ constructor() {
931
+ super(ApplicationCommandOptionEnum2.Mentionable);
932
+ }
933
+ }
934
+
935
+ class CreateAttachmentOption2 extends CreateCommandOption2 {
936
+ constructor() {
937
+ super(ApplicationCommandOptionEnum2.Attachment);
938
+ }
939
+ }
940
+
941
+ class CreateChannelOption2 extends CreateCommandOption2 {
942
+ constructor() {
943
+ super(ApplicationCommandOptionEnum2.Channel);
944
+ }
945
+ addChannelTypes(...types) {
946
+ if (types.some((type) => !Number.isInteger(type) || type < 0))
947
+ throw new RangeError("Channel types must be non-negative integers.");
948
+ this.data.channel_types = [...new Set(types)];
949
+ return this;
950
+ }
951
+ }
952
+
953
+ class CreateSubcommand2 extends CreateCommandOption2 {
954
+ constructor() {
955
+ super(ApplicationCommandOptionEnum2.Subcommand);
956
+ }
957
+ addStringOption(configure) {
958
+ return this.addChildOption(configure(new CreateStringOption2));
959
+ }
960
+ addIntegerOption(configure) {
961
+ return this.addChildOption(configure(new CreateIntegerOption2));
962
+ }
963
+ addNumberOption(configure) {
964
+ return this.addChildOption(configure(new CreateNumberOption2));
965
+ }
966
+ addBooleanOption(configure) {
967
+ return this.addChildOption(configure(new CreateBooleanOption2));
968
+ }
969
+ addUserOption(configure) {
970
+ return this.addChildOption(configure(new CreateUserOption2));
971
+ }
972
+ addChannelOption(configure) {
973
+ return this.addChildOption(configure(new CreateChannelOption2));
974
+ }
975
+ addRoleOption(configure) {
976
+ return this.addChildOption(configure(new CreateRoleOption2));
977
+ }
978
+ addMentionableOption(configure) {
979
+ return this.addChildOption(configure(new CreateMentionableOption2));
980
+ }
981
+ addAttachmentOption(configure) {
982
+ return this.addChildOption(configure(new CreateAttachmentOption2));
983
+ }
984
+ addChildOption(option) {
985
+ const options = this.data.options ?? [];
986
+ if (options.some((existing) => existing.type === ApplicationCommandOptionEnum2.Subcommand))
987
+ throw new RangeError("Subcommands cannot contain nested subcommands.");
988
+ this.data.options = appendOption(options, option.toJSON(), "subcommand");
989
+ return this;
990
+ }
991
+ }
992
+
993
+ class CreateSubcommandGroup2 extends CreateCommandOption2 {
994
+ constructor() {
995
+ super(ApplicationCommandOptionEnum2.SubcommandGroup);
996
+ }
997
+ addSubcommand(configure) {
998
+ const options = this.data.options ?? [];
999
+ if (options.length >= 25)
1000
+ throw new RangeError("A subcommand group cannot contain more than 25 subcommands.");
1001
+ const payload = configure(new CreateSubcommand2).toJSON();
1002
+ if (options.some((existing) => existing.name === payload.name))
1003
+ throw new RangeError(`Duplicate subcommand name: ${String(payload.name)}.`);
1004
+ if (payload.type !== ApplicationCommandOptionEnum2.Subcommand)
1005
+ throw new TypeError("Subcommand group children must be subcommands.");
1006
+ options.push(payload);
1007
+ this.data.options = options;
1008
+ return this;
1009
+ }
1010
+ }
1011
+ var MAX_SAFE = Number.MAX_SAFE_INTEGER;
1012
+ function appendOption(options, payload, parent) {
1013
+ const list = options ?? [];
1014
+ if (list.length >= 25)
1015
+ throw new RangeError(`${parent === "subcommand" ? "A subcommand" : "An application command"} cannot contain more than 25 options.`);
1016
+ if (list.some((existing) => existing.name === payload.name))
1017
+ throw new RangeError(`Duplicate option name: ${String(payload.name)}.`);
1018
+ if (payload.required === true && list.some((existing) => existing.required !== true))
1019
+ throw new RangeError(`Required ${parent} options must be placed before optional options.`);
1020
+ return [...list, payload];
1021
+ }
1022
+ function appendChoices(data, choices) {
1023
+ const current = data.choices ?? [];
1024
+ if (!choices.length)
1025
+ throw new TypeError("At least one choice is required.");
1026
+ if (data.autocomplete === true)
1027
+ throw new RangeError("Autocomplete options cannot define choices.");
1028
+ if (current.length + choices.length > 25)
1029
+ throw new RangeError("An option cannot contain more than 25 choices.");
1030
+ for (const choice of choices) {
1031
+ validateText2(choice.name, "Choice name", 100);
1032
+ const value = choice.value;
1033
+ if (typeof value === "string" ? value.length === 0 || value.length > 100 : typeof value !== "number" || !Number.isFinite(value))
1034
+ throw new TypeError("Choice value must be a string of 1-100 characters or a finite number.");
1035
+ }
1036
+ data.choices = [...current, ...choices.map((choice) => ({ ...choice }))];
1037
+ }
1038
+ function validateName(value, field) {
1039
+ if (!/^[\p{L}\p{N}_-]{1,32}$/u.test(value) || value !== value.toLowerCase())
1040
+ throw new RangeError(`${field} must contain 1-32 lowercase letters, numbers, underscores, or hyphens.`);
1041
+ }
1042
+ function validateText2(value, field, max) {
1043
+ if (typeof value !== "string" || !value.trim() || value.length > max)
1044
+ throw new RangeError(`${field} must contain 1-${max} characters.`);
1045
+ }
1046
+ function validateIntegerRange(value, minimum, maximum, field) {
1047
+ if (!Number.isInteger(value) || value < minimum || value > maximum)
1048
+ throw new RangeError(`${field} must be an integer between ${minimum} and ${maximum}.`);
1049
+ }
1050
+ function validateNumberRange(value, minimum, maximum, field, integerOnly = true) {
1051
+ if (!Number.isFinite(value) || integerOnly && !Number.isInteger(value) || value < minimum || value > maximum)
1052
+ throw new RangeError(`${field} must be ${integerOnly ? "an integer" : "a number"} between ${minimum} and ${maximum}.`);
1053
+ }
1054
+
1055
+ class CreateContextMenuCommand2 {
1056
+ data;
1057
+ constructor(type = 2) {
1058
+ this.data = { type };
1059
+ }
1060
+ setType(type) {
1061
+ if (type !== 2 && type !== 3)
1062
+ throw new RangeError("Context menu command type must be 2 or 3.");
1063
+ this.data.type = type;
1064
+ return this;
1065
+ }
1066
+ setName(name) {
1067
+ if (typeof name !== "string" || name.trim().length < 1 || name.length > 32)
1068
+ throw new RangeError("Command name must contain 1-32 characters.");
1069
+ this.data.name = name;
1070
+ return this;
1071
+ }
1072
+ setDefaultMemberPermissions(permissions) {
1073
+ this.data.default_member_permissions = permissions === null ? null : BigInt(permissions).toString();
1074
+ return this;
1075
+ }
1076
+ setIntegrationTypes(...types) {
1077
+ this.data.integration_types = [...types];
1078
+ return this;
1079
+ }
1080
+ setContexts(...contexts) {
1081
+ validateContexts(contexts);
1082
+ this.data.contexts = [...contexts];
1083
+ return this;
1084
+ }
1085
+ setNameLocalizations(localizations) {
1086
+ this.data.name_localizations = localizations === null ? null : { ...localizations };
1087
+ return this;
1088
+ }
1089
+ toJSON() {
1090
+ return cloneData(this.data);
1091
+ }
1092
+ }
1093
+
1094
+ class CreateUserCommand2 extends CreateContextMenuCommand2 {
1095
+ constructor() {
1096
+ super(2);
1097
+ }
1098
+ }
1099
+
1100
+ class CreateMessageCommand2 extends CreateContextMenuCommand2 {
1101
+ constructor() {
1102
+ super(3);
1103
+ }
1104
+ }
1105
+ // packages/builders/src/attachment.ts
1106
+ import { readFile, realpath } from "fs/promises";
1107
+ import { basename, isAbsolute, relative, resolve } from "path";
1108
+
1109
+ class CreateAttachment2 {
1110
+ name;
1111
+ description;
1112
+ file;
1113
+ root;
1114
+ constructor(file, data) {
1115
+ this.file = file;
1116
+ if (typeof data === "string") {
1117
+ this.name = data;
1118
+ } else {
1119
+ this.name = data?.name ?? (typeof file === "string" ? basename(file) : "file.bin");
1120
+ this.description = data?.description;
1121
+ this.root = data?.root;
1122
+ }
1123
+ }
1124
+ setName(name) {
1125
+ this.name = name;
1126
+ return this;
1127
+ }
1128
+ setDescription(description) {
1129
+ this.description = description;
1130
+ return this;
1131
+ }
1132
+ setFile(file) {
1133
+ this.file = file;
1134
+ return this;
1135
+ }
1136
+ async toBuffer() {
1137
+ if (typeof this.file === "string") {
1138
+ const path = this.root === undefined ? this.file : await insideRoot(this.root, this.file);
1139
+ const buffer = await readFile(path);
1140
+ return new Uint8Array(buffer);
1141
+ }
1142
+ if (this.file instanceof Uint8Array)
1143
+ return this.file;
1144
+ if (this.file instanceof ArrayBuffer)
1145
+ return new Uint8Array(this.file);
1146
+ if (this.file instanceof Blob) {
1147
+ const buf = await this.file.arrayBuffer();
1148
+ return new Uint8Array(buf);
1149
+ }
1150
+ if (typeof Buffer !== "undefined" && Buffer.isBuffer(this.file)) {
1151
+ return new Uint8Array(this.file);
1152
+ }
1153
+ throw new TypeError("Attachment file must be a supported binary value or file path.");
1154
+ }
1155
+ }
1156
+ async function insideRoot(root, file) {
1157
+ const base = await realpath(root).catch(() => {
1158
+ throw new Error("Attachment root folder was not found.");
1159
+ });
1160
+ const target = await realpath(resolve(base, file)).catch(() => {
1161
+ throw new Error("Attachment file was not found inside its root.");
1162
+ });
1163
+ const rel = relative(base, target);
1164
+ if (rel === "" || rel === ".." || rel.startsWith("../") || rel.startsWith("..\\") || isAbsolute(rel))
1165
+ throw new Error("Attachment file is outside its root folder.");
1166
+ return target;
1167
+ }
1168
+ export { CreateEmbed2, TextInputType2, CreateActionRow2, CreateStringSelect2, CreateButton2, CreateEntitySelect2, CreateModal2, CreateTextInput2, CreateContainer2, CreateSection2, CreateTextDisplay2, CreateMediaGallery2, CreateFileComponent2, CreateSeparator2, CreateThumbnail2, CreateContentInventoryEntry2, CreateUserSelect2, CreateRoleSelect2, CreateMentionableSelect2, CreateChannelSelect2, componentsV2Message2, ApplicationCommandOptionEnum2, CreateSlashCommand2, CreateCommandOption2, CreateStringOption2, CreateIntegerOption2, CreateNumberOption2, CreateBooleanOption2, CreateUserOption2, CreateRoleOption2, CreateMentionableOption2, CreateAttachmentOption2, CreateChannelOption2, CreateSubcommand2, CreateSubcommandGroup2, CreateContextMenuCommand2, CreateUserCommand2, CreateMessageCommand2, CreateAttachment2 };
1169
+
1170
+ //# debugId=CF218B228D9DB4A464756E2164756E21