lunibee 0.2.3 → 0.3.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.
- package/README.md +3 -3
- package/dist/builders/attachment.d.ts +8 -4
- package/dist/builders/commands.d.ts +122 -149
- package/dist/builders/components.d.ts +10 -150
- package/dist/builders/embed.d.ts +66 -37
- package/dist/builders/index.d.ts +0 -4
- package/dist/builders/index.js +112 -221
- package/dist/builders/index.js.map +10 -9
- package/dist/collection/cache.d.ts +15 -6
- package/dist/collection/index.d.ts +92 -17
- package/dist/collection/index.js +471 -279
- package/dist/collection/index.js.map +4 -4
- package/dist/core/api.d.ts +130 -0
- package/dist/core/channel-create.d.ts +72 -0
- package/dist/core/commands.d.ts +232 -0
- package/dist/core/events.d.ts +24 -7
- package/dist/core/handles.d.ts +157 -0
- package/dist/core/index.d.ts +68 -4
- package/dist/core/index.js +2639 -493
- package/dist/core/index.js.map +47 -37
- package/dist/core/permissions.d.ts +7 -7
- package/dist/formatters/index.js +9 -5
- package/dist/formatters/index.js.map +3 -3
- package/dist/handlers/index.js +5 -10
- package/dist/handlers/index.js.map +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9527 -7809
- package/dist/index.js.map +63 -53
- package/dist/managers/advanced.d.ts +29 -1
- package/dist/managers/base.d.ts +22 -14
- package/dist/managers/emoji.d.ts +0 -2
- package/dist/managers/guild-resources.d.ts +13 -5
- package/dist/managers/guild.d.ts +40 -4
- package/dist/managers/index.d.ts +21 -13
- package/dist/managers/index.js +969 -386
- package/dist/managers/index.js.map +30 -25
- package/dist/managers/member.d.ts +9 -2
- package/dist/managers/message.d.ts +10 -15
- package/dist/managers/role.d.ts +18 -10
- package/dist/managers/thread.d.ts +68 -0
- package/dist/managers/user.d.ts +18 -0
- package/dist/rest/errors.d.ts +14 -7
- package/dist/rest/index.d.ts +24 -12
- package/dist/rest/index.js +70 -20
- package/dist/rest/index.js.map +9 -9
- package/dist/rest/redis.d.ts +1 -1
- package/dist/rest/route.d.ts +8 -4
- package/dist/rest/routes.d.ts +122 -48
- package/dist/rest/transport.d.ts +10 -5
- package/dist/rest/webhook.d.ts +9 -5
- package/dist/sharding/bus.d.ts +47 -19
- package/dist/sharding/cluster.d.ts +11 -0
- package/dist/sharding/gateway-bot.d.ts +18 -0
- package/dist/sharding/index.d.ts +64 -25
- package/dist/sharding/index.js +439 -124
- package/dist/sharding/index.js.map +19 -14
- package/dist/sharding/supervisor.d.ts +32 -0
- package/dist/sharding/transport.d.ts +45 -0
- package/dist/structures/audit-log.d.ts +99 -2
- package/dist/structures/base.d.ts +40 -23
- package/dist/structures/channels.d.ts +45 -14
- package/dist/structures/index.d.ts +8 -12
- package/dist/structures/index.js +280 -132
- package/dist/structures/index.js.map +21 -15
- package/dist/structures/interactions.d.ts +91 -63
- package/dist/structures/resources.d.ts +99 -52
- package/dist/structures/sticker.d.ts +33 -0
- package/dist/types/channel-kind.d.ts +26 -0
- package/dist/types/gateway.d.ts +24 -12
- package/dist/types/index.d.ts +115 -113
- package/dist/types/index.js +53 -48
- package/dist/types/index.js.map +6 -5
- package/dist/voice/index.d.ts +12 -4
- package/dist/voice/index.js +14 -18
- package/dist/voice/index.js.map +3 -3
- package/dist/ws/decoder.d.ts +6 -2
- package/dist/ws/dispatcher.d.ts +19 -0
- package/dist/ws/index.d.ts +61 -15
- package/dist/ws/index.js +194 -77
- package/dist/ws/index.js.map +13 -11
- package/dist/ws/protocol.d.ts +10 -2
- package/dist/ws/reconnect.d.ts +10 -0
- package/dist/ws/send-budget.d.ts +6 -2
- package/dist/ws/session.d.ts +14 -4
- package/dist/ws/state.d.ts +22 -11
- package/package.json +20 -16
package/dist/builders/embed.d.ts
CHANGED
|
@@ -1,65 +1,94 @@
|
|
|
1
1
|
/** Discord API embed field payload. */
|
|
2
2
|
export interface EmbedField {
|
|
3
|
-
/** Field name. */
|
|
4
|
-
|
|
5
|
-
/**
|
|
3
|
+
/** Field name. */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Field value. */
|
|
6
|
+
value: string;
|
|
7
|
+
/** Whether the field is displayed inline. */
|
|
8
|
+
inline?: boolean;
|
|
6
9
|
}
|
|
7
10
|
/** Discord API embed footer payload. */
|
|
8
11
|
export interface EmbedFooter {
|
|
9
|
-
/** Footer text. */
|
|
10
|
-
|
|
12
|
+
/** Footer text. */
|
|
13
|
+
text: string;
|
|
14
|
+
/** Footer icon URL. */
|
|
15
|
+
icon_url?: string;
|
|
11
16
|
}
|
|
12
17
|
/** Discord API embed author payload. */
|
|
13
18
|
export interface EmbedAuthor {
|
|
14
|
-
/** Author display name. */
|
|
15
|
-
|
|
16
|
-
/** Author
|
|
19
|
+
/** Author display name. */
|
|
20
|
+
name: string;
|
|
21
|
+
/** Author URL. */
|
|
22
|
+
url?: string;
|
|
23
|
+
/** Author icon URL. */
|
|
24
|
+
icon_url?: string;
|
|
17
25
|
}
|
|
18
26
|
/** Strict Discord API embed payload. */
|
|
19
27
|
export interface APIEmbed {
|
|
20
|
-
/** Embed title. */
|
|
21
|
-
|
|
22
|
-
/** Embed
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
/** Embed
|
|
27
|
-
|
|
28
|
+
/** Embed title. */
|
|
29
|
+
title?: string;
|
|
30
|
+
/** Embed description. */
|
|
31
|
+
description?: string;
|
|
32
|
+
/** Embed URL. */
|
|
33
|
+
url?: string;
|
|
34
|
+
/** Embed color. */
|
|
35
|
+
color?: number;
|
|
36
|
+
/** ISO-8601 timestamp. */
|
|
37
|
+
timestamp?: string;
|
|
38
|
+
/** Embed footer. */
|
|
39
|
+
footer?: EmbedFooter;
|
|
40
|
+
/** Embed author. */
|
|
41
|
+
author?: EmbedAuthor;
|
|
42
|
+
/** Thumbnail payload. */
|
|
43
|
+
thumbnail?: {
|
|
28
44
|
url: string;
|
|
29
45
|
};
|
|
30
|
-
/** Image payload. */
|
|
46
|
+
/** Image payload. */
|
|
47
|
+
image?: {
|
|
31
48
|
url: string;
|
|
32
49
|
};
|
|
33
|
-
/** Embed fields. */
|
|
50
|
+
/** Embed fields. */
|
|
51
|
+
fields?: EmbedField[];
|
|
34
52
|
}
|
|
35
53
|
/** Builds compile-time-safe rich embed payloads for Discord API requests. */
|
|
36
54
|
export declare class CreateEmbed {
|
|
37
55
|
#private;
|
|
38
|
-
/** Sets the embed title. @param value Title text, or null to clear. @returns This builder. @throws {RangeError} If title exceeds Discord's limit. */
|
|
39
|
-
|
|
40
|
-
/** Sets the embed
|
|
41
|
-
|
|
42
|
-
/** Sets the embed
|
|
43
|
-
|
|
44
|
-
/** Sets the embed
|
|
45
|
-
|
|
56
|
+
/** Sets the embed title. @param value Title text, or null to clear. @returns This builder. @throws {RangeError} If title exceeds Discord's limit. */
|
|
57
|
+
setTitle(value: string | null): this;
|
|
58
|
+
/** Sets the embed description. @param value Description text, or null to clear. @returns This builder. @throws {RangeError} If description exceeds Discord's limit. */
|
|
59
|
+
setDescription(value: string | null): this;
|
|
60
|
+
/** Sets the embed URL. @param value Absolute URL, or null to clear. @returns This builder. @throws {TypeError} If URL is invalid. */
|
|
61
|
+
setURL(value: string | null): this;
|
|
62
|
+
/** Sets the embed color. @param value RGB integer. @returns This builder. @throws {RangeError} If color is outside 24-bit RGB range. */
|
|
63
|
+
setColor(value: number): this;
|
|
64
|
+
/** Sets the embed timestamp. @param value Date value. @returns This builder. @throws {RangeError} If date is invalid. */
|
|
65
|
+
setTimestamp(value?: Date): this;
|
|
66
|
+
/** Sets the embed footer. @param value Footer payload. @returns This builder. @throws {RangeError} If footer text exceeds Discord's limit. */
|
|
67
|
+
setFooter(value: EmbedFooter): this;
|
|
68
|
+
/** Sets the embed author. @param value Author payload. @returns This builder. @throws {RangeError} If author name exceeds Discord's limit. */
|
|
69
|
+
setAuthor(value: EmbedAuthor): this;
|
|
70
|
+
/** Sets the thumbnail URL. @param value Thumbnail URL or payload, or null to clear. @returns This builder. @throws {TypeError} If URL is invalid. */
|
|
71
|
+
setThumbnail(value: {
|
|
46
72
|
url: string;
|
|
47
73
|
} | string | null): this;
|
|
48
|
-
/** Sets the image URL. @param value Image URL or payload, or null to clear. @returns This builder. @throws {TypeError} If URL is invalid. */
|
|
74
|
+
/** Sets the image URL. @param value Image URL or payload, or null to clear. @returns This builder. @throws {TypeError} If URL is invalid. */
|
|
75
|
+
setImage(value: {
|
|
49
76
|
url: string;
|
|
50
77
|
} | string | null): this;
|
|
51
78
|
/** Adds embed fields. Accepts both the spread form `addFields(a, b)` and the
|
|
52
79
|
* single-array form `addFields([a, b])` for discord.js `RestOrArray` parity.
|
|
53
|
-
* @param fields Field payloads, spread or as a single array. @returns This builder. @throws {RangeError} If the 25-field limit is exceeded. */
|
|
80
|
+
* @param fields Field payloads, spread or as a single array. @returns This builder. @throws {RangeError} If the 25-field limit is exceeded. */
|
|
81
|
+
addFields(...fields: EmbedField[] | [EmbedField[]]): this;
|
|
54
82
|
setFields(fields: EmbedField[]): this;
|
|
55
|
-
/** Replaces fields starting at an index. @param index Start index. @param deleteCount Number of fields to remove. @param fields Replacement fields. @returns This builder. @throws {RangeError} If arguments are invalid or the 25-field limit is exceeded. */
|
|
56
|
-
|
|
57
|
-
/** Removes
|
|
58
|
-
|
|
59
|
-
/**
|
|
83
|
+
/** Replaces fields starting at an index. @param index Start index. @param deleteCount Number of fields to remove. @param fields Replacement fields. @returns This builder. @throws {RangeError} If arguments are invalid or the 25-field limit is exceeded. */
|
|
84
|
+
spliceFields(index: number, deleteCount: number, ...fields: EmbedField[]): this;
|
|
85
|
+
/** Removes all embed fields. @returns This builder. */
|
|
86
|
+
clearFields(): this;
|
|
87
|
+
/** Removes the embed title. @returns This builder. */
|
|
88
|
+
clearTitle(): this;
|
|
89
|
+
/** Removes the embed description. @returns This builder. */
|
|
90
|
+
clearDescription(): this;
|
|
91
|
+
/** Returns a deep-cloned Discord API payload. @returns Strict embed payload. */
|
|
92
|
+
get data(): APIEmbed;
|
|
60
93
|
toJSON(): APIEmbed;
|
|
61
94
|
}
|
|
62
|
-
/** @deprecated Use {@link CreateEmbed}. Removed in 0.3.0. */
|
|
63
|
-
export declare const EmbedBuilder: typeof CreateEmbed;
|
|
64
|
-
/** @deprecated Use {@link CreateEmbed}. Removed in 0.3.0. */
|
|
65
|
-
export type EmbedBuilder = CreateEmbed;
|
package/dist/builders/index.d.ts
CHANGED
|
@@ -3,8 +3,4 @@ export type { EmbedField } from "./embed.js";
|
|
|
3
3
|
export { CreateButton, ButtonType, ComponentEnum, CreateActionRow, CreateStringSelect, CreateStringSelectMenu, CreateEntitySelect, CreateUserSelectMenu, CreateRoleSelectMenu, CreateMentionableSelectMenu, CreateChannelSelectMenu, CreateModal, CreateTextInput, TextInputType, CreateContainer, CreateSection, CreateTextDisplay, CreateMediaGallery, CreateFileComponent, CreateSeparator, CreateThumbnail, CreateContentInventoryEntry, componentsV2Message, } from "./components.js";
|
|
4
4
|
export { CreateSlashCommand, CreateCommandOption, CreateStringOption, CreateIntegerOption, CreateNumberOption, CreateBooleanOption, CreateUserOption, CreateChannelOption, CreateRoleOption, CreateMentionableOption, CreateAttachmentOption, CreateSubcommand, CreateSubcommandGroup, ApplicationCommandOptionEnum, CreateUserCommand, CreateMessageCommand, CreateContextMenuCommand, } from "./commands.js";
|
|
5
5
|
export { CreateAttachment, type AttachmentData } from "./attachment.js";
|
|
6
|
-
export { AttachmentBuilder } from "./attachment.js";
|
|
7
|
-
export { EmbedBuilder } from "./embed.js";
|
|
8
|
-
export { AttachmentOptionBuilder, BooleanOptionBuilder, ChannelOptionBuilder, CommandOptionBuilder, ContextMenuCommandBuilder, IntegerOptionBuilder, MentionableOptionBuilder, MessageCommandBuilder, NumberOptionBuilder, RoleOptionBuilder, SlashCommandBuilder, StringOptionBuilder, SubcommandBuilder, SubcommandGroupBuilder, UserCommandBuilder, UserOptionBuilder, ApplicationCommandOptionType, } from "./commands.js";
|
|
9
|
-
export { ButtonBuilder, ChannelSelectMenuBuilder, ContainerBuilder, ContentInventoryEntryBuilder, EntitySelectBuilder, FileComponentBuilder, MediaGalleryBuilder, MentionableSelectMenuBuilder, ModalBuilder, RoleSelectMenuBuilder, SectionBuilder, SeparatorBuilder, StringSelectBuilder, StringSelectMenuBuilder, TextDisplayBuilder, TextInputBuilder, ThumbnailBuilder, UserSelectMenuBuilder, ActionRowBuilder, ButtonStyle, TextInputStyle, ComponentType, } from "./components.js";
|
|
10
6
|
export type { APIComponent, APIComponentEmoji, APIActionRowChild, APIActionRowComponent, APIButtonComponent, APISelectOption, APISelectDefaultValue, APIStringSelectComponent, APIEntitySelectComponent, APITextInputComponent, APIModalComponent, APIContainerComponent, APISectionComponent, APITextDisplayComponent, APIMediaGalleryComponent, APIFileComponent, APISeparatorComponent, APIThumbnailComponent, APIContentInventoryEntryComponent, } from "./components.js";
|
package/dist/builders/index.js
CHANGED
|
@@ -131,7 +131,21 @@ function url(value, field) {
|
|
|
131
131
|
throw new TypeError(`${field} must be a valid URL.`, { cause: error });
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
|
|
134
|
+
// packages/types/src/channel-kind.ts
|
|
135
|
+
var ChannelKinds = {
|
|
136
|
+
text: [0],
|
|
137
|
+
dm: [1],
|
|
138
|
+
voice: [2],
|
|
139
|
+
"group-dm": [3],
|
|
140
|
+
category: [4],
|
|
141
|
+
announcement: [5],
|
|
142
|
+
thread: [10, 11, 12],
|
|
143
|
+
stage: [13],
|
|
144
|
+
directory: [14],
|
|
145
|
+
forum: [15],
|
|
146
|
+
media: [16]
|
|
147
|
+
};
|
|
148
|
+
var KIND_OF_TYPE = new Map(Object.keys(ChannelKinds).flatMap((kind) => ChannelKinds[kind].map((type) => [type, kind])));
|
|
135
149
|
// packages/types/src/gateway.ts
|
|
136
150
|
var GatewayIntentBits = {
|
|
137
151
|
Guilds: 1 << 0,
|
|
@@ -185,16 +199,6 @@ var IntentBits = {
|
|
|
185
199
|
directMessagePolls: 1 << 25
|
|
186
200
|
};
|
|
187
201
|
// packages/types/src/index.ts
|
|
188
|
-
var ButtonType = {
|
|
189
|
-
Primary: 1,
|
|
190
|
-
Secondary: 2,
|
|
191
|
-
Success: 3,
|
|
192
|
-
Danger: 4,
|
|
193
|
-
Link: 5,
|
|
194
|
-
Premium: 6
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
// packages/builders/src/components.ts
|
|
198
202
|
var ComponentEnum = {
|
|
199
203
|
ActionRow: 1,
|
|
200
204
|
Button: 2,
|
|
@@ -213,6 +217,16 @@ var ComponentEnum = {
|
|
|
213
217
|
ContentInventoryEntry: 16,
|
|
214
218
|
Container: 17
|
|
215
219
|
};
|
|
220
|
+
var ButtonType = {
|
|
221
|
+
Primary: 1,
|
|
222
|
+
Secondary: 2,
|
|
223
|
+
Success: 3,
|
|
224
|
+
Danger: 4,
|
|
225
|
+
Link: 5,
|
|
226
|
+
Premium: 6
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
// packages/builders/src/components.ts
|
|
216
230
|
var TextInputType = { Short: 1, Paragraph: 2 };
|
|
217
231
|
|
|
218
232
|
class CreateActionRow {
|
|
@@ -240,38 +254,50 @@ class CreateActionRow {
|
|
|
240
254
|
}
|
|
241
255
|
}
|
|
242
256
|
|
|
243
|
-
class
|
|
244
|
-
#
|
|
245
|
-
|
|
246
|
-
|
|
257
|
+
class CreateSelectMenu {
|
|
258
|
+
#select;
|
|
259
|
+
constructor(data) {
|
|
260
|
+
this.#select = data;
|
|
261
|
+
}
|
|
247
262
|
setCustomId(value) {
|
|
248
263
|
validateText(value, 100, "Component custom ID");
|
|
249
|
-
this.#
|
|
264
|
+
this.#select.custom_id = value;
|
|
250
265
|
return this;
|
|
251
266
|
}
|
|
252
267
|
setPlaceholder(value) {
|
|
253
268
|
validateText(value, 150, "Component placeholder");
|
|
254
|
-
this.#
|
|
269
|
+
this.#select.placeholder = value;
|
|
255
270
|
return this;
|
|
256
271
|
}
|
|
257
272
|
setMinValues(value) {
|
|
258
273
|
validateCount(value, "min_values", 0);
|
|
259
|
-
this.#
|
|
274
|
+
this.#select.min_values = value;
|
|
260
275
|
return this;
|
|
261
276
|
}
|
|
262
277
|
setMaxValues(value) {
|
|
263
278
|
validateCount(value, "max_values", 1);
|
|
264
|
-
this.#
|
|
279
|
+
this.#select.max_values = value;
|
|
265
280
|
return this;
|
|
266
281
|
}
|
|
267
282
|
setRequired(value = true) {
|
|
268
|
-
this.#
|
|
283
|
+
this.#select.required = value;
|
|
269
284
|
return this;
|
|
270
285
|
}
|
|
271
286
|
setDisabled(value = true) {
|
|
272
|
-
this.#
|
|
287
|
+
this.#select.disabled = value;
|
|
273
288
|
return this;
|
|
274
289
|
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
class CreateStringSelect extends CreateSelectMenu {
|
|
293
|
+
#data;
|
|
294
|
+
constructor() {
|
|
295
|
+
const data = {
|
|
296
|
+
type: ComponentEnum.StringSelect
|
|
297
|
+
};
|
|
298
|
+
super(data);
|
|
299
|
+
this.#data = data;
|
|
300
|
+
}
|
|
275
301
|
addOptions(...options) {
|
|
276
302
|
if (!options.length)
|
|
277
303
|
throw new TypeError("At least one select option is required.");
|
|
@@ -387,40 +413,14 @@ class CreateButton {
|
|
|
387
413
|
}
|
|
388
414
|
}
|
|
389
415
|
|
|
390
|
-
class CreateEntitySelect {
|
|
416
|
+
class CreateEntitySelect extends CreateSelectMenu {
|
|
391
417
|
#data;
|
|
392
418
|
constructor(type) {
|
|
393
419
|
if (type !== ComponentEnum.UserSelect && type !== ComponentEnum.RoleSelect && type !== ComponentEnum.MentionableSelect && type !== ComponentEnum.ChannelSelect)
|
|
394
420
|
throw new TypeError("Invalid select component type.");
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
validateText(value, 100, "Component custom ID");
|
|
399
|
-
this.#data.custom_id = value;
|
|
400
|
-
return this;
|
|
401
|
-
}
|
|
402
|
-
setPlaceholder(value) {
|
|
403
|
-
validateText(value, 150, "Component placeholder");
|
|
404
|
-
this.#data.placeholder = value;
|
|
405
|
-
return this;
|
|
406
|
-
}
|
|
407
|
-
setMinValues(value) {
|
|
408
|
-
validateCount(value, "min_values", 0);
|
|
409
|
-
this.#data.min_values = value;
|
|
410
|
-
return this;
|
|
411
|
-
}
|
|
412
|
-
setMaxValues(value) {
|
|
413
|
-
validateCount(value, "max_values", 1);
|
|
414
|
-
this.#data.max_values = value;
|
|
415
|
-
return this;
|
|
416
|
-
}
|
|
417
|
-
setRequired(value = true) {
|
|
418
|
-
this.#data.required = value;
|
|
419
|
-
return this;
|
|
420
|
-
}
|
|
421
|
-
setDisabled(value = true) {
|
|
422
|
-
this.#data.disabled = value;
|
|
423
|
-
return this;
|
|
421
|
+
const data = { type };
|
|
422
|
+
super(data);
|
|
423
|
+
this.#data = data;
|
|
424
424
|
}
|
|
425
425
|
setDefaultValues(...values) {
|
|
426
426
|
this.#data.default_values = values.map((value) => ({ ...value }));
|
|
@@ -764,28 +764,6 @@ function componentsV2Message(components, options) {
|
|
|
764
764
|
flags: (options?.flags ?? 0) | IS_COMPONENTS_V2
|
|
765
765
|
};
|
|
766
766
|
}
|
|
767
|
-
var ButtonBuilder = CreateButton;
|
|
768
|
-
var ChannelSelectMenuBuilder = CreateChannelSelectMenu;
|
|
769
|
-
var ContainerBuilder = CreateContainer;
|
|
770
|
-
var ContentInventoryEntryBuilder = CreateContentInventoryEntry;
|
|
771
|
-
var EntitySelectBuilder = CreateEntitySelect;
|
|
772
|
-
var FileComponentBuilder = CreateFileComponent;
|
|
773
|
-
var MediaGalleryBuilder = CreateMediaGallery;
|
|
774
|
-
var MentionableSelectMenuBuilder = CreateMentionableSelectMenu;
|
|
775
|
-
var ModalBuilder = CreateModal;
|
|
776
|
-
var RoleSelectMenuBuilder = CreateRoleSelectMenu;
|
|
777
|
-
var SectionBuilder = CreateSection;
|
|
778
|
-
var SeparatorBuilder = CreateSeparator;
|
|
779
|
-
var StringSelectBuilder = CreateStringSelect;
|
|
780
|
-
var StringSelectMenuBuilder = CreateStringSelect;
|
|
781
|
-
var TextDisplayBuilder = CreateTextDisplay;
|
|
782
|
-
var TextInputBuilder = CreateTextInput;
|
|
783
|
-
var ThumbnailBuilder = CreateThumbnail;
|
|
784
|
-
var UserSelectMenuBuilder = CreateUserSelectMenu;
|
|
785
|
-
var ActionRowBuilder = CreateActionRow;
|
|
786
|
-
var ButtonStyle = ButtonType;
|
|
787
|
-
var TextInputStyle = TextInputType;
|
|
788
|
-
var ComponentType = ComponentEnum;
|
|
789
767
|
// packages/builders/src/commands.ts
|
|
790
768
|
var ApplicationCommandOptionEnum = {
|
|
791
769
|
Subcommand: 1,
|
|
@@ -822,10 +800,6 @@ class CreateSlashCommand {
|
|
|
822
800
|
this.#data.contexts = [...contexts];
|
|
823
801
|
return this;
|
|
824
802
|
}
|
|
825
|
-
setDMPermission(enabled) {
|
|
826
|
-
this.#data.dm_permission = enabled;
|
|
827
|
-
return this;
|
|
828
|
-
}
|
|
829
803
|
setNSFW(nsfw = true) {
|
|
830
804
|
this.#data.nsfw = nsfw;
|
|
831
805
|
return this;
|
|
@@ -878,16 +852,7 @@ class CreateSlashCommand {
|
|
|
878
852
|
return structuredClone(this.#data);
|
|
879
853
|
}
|
|
880
854
|
addOption(option) {
|
|
881
|
-
|
|
882
|
-
if (options.length >= 25)
|
|
883
|
-
throw new RangeError("An application command cannot contain more than 25 options.");
|
|
884
|
-
const payload = option.toJSON();
|
|
885
|
-
if (options.some((existing) => existing.name === payload.name))
|
|
886
|
-
throw new RangeError(`Duplicate option name: ${String(payload.name)}.`);
|
|
887
|
-
if (payload.required === true && options.some((existing) => existing.required !== true))
|
|
888
|
-
throw new RangeError("Required application command options must be placed before optional options.");
|
|
889
|
-
options.push(payload);
|
|
890
|
-
this.#data.options = options;
|
|
855
|
+
this.#data.options = appendOption(this.#data.options, option.toJSON(), "application command");
|
|
891
856
|
return this;
|
|
892
857
|
}
|
|
893
858
|
}
|
|
@@ -925,21 +890,9 @@ class CreateStringOption extends CreateCommandOption {
|
|
|
925
890
|
super(ApplicationCommandOptionEnum.String);
|
|
926
891
|
}
|
|
927
892
|
addChoices(...choices) {
|
|
928
|
-
const
|
|
929
|
-
if (!choices.length)
|
|
930
|
-
throw new TypeError("At least one choice is required.");
|
|
931
|
-
if (this.data.autocomplete === true)
|
|
932
|
-
throw new RangeError("Autocomplete options cannot define choices.");
|
|
933
|
-
if (current.length + choices.length > 25)
|
|
934
|
-
throw new RangeError("An option cannot contain more than 25 choices.");
|
|
935
|
-
for (const choice of choices) {
|
|
936
|
-
validateText2(choice.name, "Choice name", 100);
|
|
893
|
+
for (const choice of choices)
|
|
937
894
|
validateText2(choice.value, "Choice value", 100);
|
|
938
|
-
|
|
939
|
-
this.data.choices = [
|
|
940
|
-
...current,
|
|
941
|
-
...choices.map((choice) => ({ ...choice }))
|
|
942
|
-
];
|
|
895
|
+
appendChoices(this.data, choices);
|
|
943
896
|
return this;
|
|
944
897
|
}
|
|
945
898
|
setMinLength(value) {
|
|
@@ -956,18 +909,21 @@ class CreateStringOption extends CreateCommandOption {
|
|
|
956
909
|
}
|
|
957
910
|
}
|
|
958
911
|
|
|
959
|
-
class
|
|
960
|
-
|
|
961
|
-
|
|
912
|
+
class CreateNumericOption extends CreateCommandOption {
|
|
913
|
+
#integer;
|
|
914
|
+
constructor(type, integer) {
|
|
915
|
+
super(type);
|
|
916
|
+
this.#integer = integer;
|
|
962
917
|
}
|
|
963
918
|
setMinValue(value) {
|
|
964
|
-
validateNumberRange(value, -
|
|
919
|
+
validateNumberRange(value, -MAX_SAFE, MAX_SAFE, "min_value", this.#integer);
|
|
965
920
|
this.data.min_value = value;
|
|
966
921
|
return this;
|
|
967
922
|
}
|
|
968
923
|
setMaxValue(value) {
|
|
969
|
-
validateNumberRange(value, -
|
|
970
|
-
|
|
924
|
+
validateNumberRange(value, -MAX_SAFE, MAX_SAFE, "max_value", this.#integer);
|
|
925
|
+
const min = this.data.min_value;
|
|
926
|
+
if (min !== undefined && min > value)
|
|
971
927
|
throw new RangeError("min_value cannot exceed max_value.");
|
|
972
928
|
this.data.max_value = value;
|
|
973
929
|
return this;
|
|
@@ -979,50 +935,20 @@ class CreateIntegerOption extends CreateCommandOption {
|
|
|
979
935
|
return this;
|
|
980
936
|
}
|
|
981
937
|
addChoices(...choices) {
|
|
982
|
-
|
|
983
|
-
if (!choices.length)
|
|
984
|
-
throw new TypeError("At least one choice is required.");
|
|
985
|
-
if (this.data.autocomplete === true)
|
|
986
|
-
throw new RangeError("Autocomplete options cannot define choices.");
|
|
987
|
-
if (current.length + choices.length > 25)
|
|
988
|
-
throw new RangeError("An option cannot contain more than 25 choices.");
|
|
989
|
-
this.data.choices = [...current, ...choices];
|
|
938
|
+
appendChoices(this.data, choices);
|
|
990
939
|
return this;
|
|
991
940
|
}
|
|
992
941
|
}
|
|
993
942
|
|
|
994
|
-
class
|
|
943
|
+
class CreateIntegerOption extends CreateNumericOption {
|
|
995
944
|
constructor() {
|
|
996
|
-
super(ApplicationCommandOptionEnum.
|
|
997
|
-
}
|
|
998
|
-
setMinValue(value) {
|
|
999
|
-
validateNumberRange(value, -9007199254740991, 9007199254740991, "min_value", false);
|
|
1000
|
-
this.data.min_value = value;
|
|
1001
|
-
return this;
|
|
945
|
+
super(ApplicationCommandOptionEnum.Integer, true);
|
|
1002
946
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
return this;
|
|
1009
|
-
}
|
|
1010
|
-
setAutocomplete(enabled = true) {
|
|
1011
|
-
if (enabled && Array.isArray(this.data.choices) && this.data.choices.length)
|
|
1012
|
-
throw new RangeError("Autocomplete options cannot define choices.");
|
|
1013
|
-
this.data.autocomplete = enabled;
|
|
1014
|
-
return this;
|
|
1015
|
-
}
|
|
1016
|
-
addChoices(...choices) {
|
|
1017
|
-
const current = this.data.choices ?? [];
|
|
1018
|
-
if (!choices.length)
|
|
1019
|
-
throw new TypeError("At least one choice is required.");
|
|
1020
|
-
if (this.data.autocomplete === true)
|
|
1021
|
-
throw new RangeError("Autocomplete options cannot define choices.");
|
|
1022
|
-
if (current.length + choices.length > 25)
|
|
1023
|
-
throw new RangeError("An option cannot contain more than 25 choices.");
|
|
1024
|
-
this.data.choices = [...current, ...choices];
|
|
1025
|
-
return this;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
class CreateNumberOption extends CreateNumericOption {
|
|
950
|
+
constructor() {
|
|
951
|
+
super(ApplicationCommandOptionEnum.Number, false);
|
|
1026
952
|
}
|
|
1027
953
|
}
|
|
1028
954
|
|
|
@@ -1101,17 +1027,9 @@ class CreateSubcommand extends CreateCommandOption {
|
|
|
1101
1027
|
}
|
|
1102
1028
|
addChildOption(option) {
|
|
1103
1029
|
const options = this.data.options ?? [];
|
|
1104
|
-
if (options.length >= 25)
|
|
1105
|
-
throw new RangeError("A subcommand cannot contain more than 25 options.");
|
|
1106
|
-
const payload = option.toJSON();
|
|
1107
|
-
if (options.some((existing) => existing.name === payload.name))
|
|
1108
|
-
throw new RangeError(`Duplicate option name: ${String(payload.name)}.`);
|
|
1109
|
-
if (payload.required === true && options.some((existing) => existing.required !== true))
|
|
1110
|
-
throw new RangeError("Required subcommand options must be placed before optional options.");
|
|
1111
1030
|
if (options.some((existing) => existing.type === ApplicationCommandOptionEnum.Subcommand))
|
|
1112
1031
|
throw new RangeError("Subcommands cannot contain nested subcommands.");
|
|
1113
|
-
options.
|
|
1114
|
-
this.data.options = options;
|
|
1032
|
+
this.data.options = appendOption(options, option.toJSON(), "subcommand");
|
|
1115
1033
|
return this;
|
|
1116
1034
|
}
|
|
1117
1035
|
}
|
|
@@ -1134,6 +1052,29 @@ class CreateSubcommandGroup extends CreateCommandOption {
|
|
|
1134
1052
|
return this;
|
|
1135
1053
|
}
|
|
1136
1054
|
}
|
|
1055
|
+
var MAX_SAFE = Number.MAX_SAFE_INTEGER;
|
|
1056
|
+
function appendOption(options, payload, parent) {
|
|
1057
|
+
const list = options ?? [];
|
|
1058
|
+
if (list.length >= 25)
|
|
1059
|
+
throw new RangeError(`${parent === "subcommand" ? "A subcommand" : "An application command"} cannot contain more than 25 options.`);
|
|
1060
|
+
if (list.some((existing) => existing.name === payload.name))
|
|
1061
|
+
throw new RangeError(`Duplicate option name: ${String(payload.name)}.`);
|
|
1062
|
+
if (payload.required === true && list.some((existing) => existing.required !== true))
|
|
1063
|
+
throw new RangeError(`Required ${parent} options must be placed before optional options.`);
|
|
1064
|
+
return [...list, payload];
|
|
1065
|
+
}
|
|
1066
|
+
function appendChoices(data, choices) {
|
|
1067
|
+
const current = data.choices ?? [];
|
|
1068
|
+
if (!choices.length)
|
|
1069
|
+
throw new TypeError("At least one choice is required.");
|
|
1070
|
+
if (data.autocomplete === true)
|
|
1071
|
+
throw new RangeError("Autocomplete options cannot define choices.");
|
|
1072
|
+
if (current.length + choices.length > 25)
|
|
1073
|
+
throw new RangeError("An option cannot contain more than 25 choices.");
|
|
1074
|
+
for (const choice of choices)
|
|
1075
|
+
validateText2(choice.name, "Choice name", 100);
|
|
1076
|
+
data.choices = [...current, ...choices.map((choice) => ({ ...choice }))];
|
|
1077
|
+
}
|
|
1137
1078
|
function validateName(value, field) {
|
|
1138
1079
|
if (!/^[\p{L}\p{N}_-]{1,32}$/u.test(value) || value !== value.toLowerCase())
|
|
1139
1080
|
throw new RangeError(`${field} must contain 1-32 lowercase letters, numbers, underscores, or hyphens.`);
|
|
@@ -1172,10 +1113,6 @@ class CreateContextMenuCommand {
|
|
|
1172
1113
|
this.data.default_member_permissions = permissions === null ? null : BigInt(permissions).toString();
|
|
1173
1114
|
return this;
|
|
1174
1115
|
}
|
|
1175
|
-
setDMPermission(enabled) {
|
|
1176
|
-
this.data.dm_permission = enabled;
|
|
1177
|
-
return this;
|
|
1178
|
-
}
|
|
1179
1116
|
setIntegrationTypes(...types) {
|
|
1180
1117
|
this.data.integration_types = [...types];
|
|
1181
1118
|
return this;
|
|
@@ -1205,31 +1142,15 @@ class CreateMessageCommand extends CreateContextMenuCommand {
|
|
|
1205
1142
|
super(3);
|
|
1206
1143
|
}
|
|
1207
1144
|
}
|
|
1208
|
-
var AttachmentOptionBuilder = CreateAttachmentOption;
|
|
1209
|
-
var BooleanOptionBuilder = CreateBooleanOption;
|
|
1210
|
-
var ChannelOptionBuilder = CreateChannelOption;
|
|
1211
|
-
var CommandOptionBuilder = CreateCommandOption;
|
|
1212
|
-
var ContextMenuCommandBuilder = CreateContextMenuCommand;
|
|
1213
|
-
var IntegerOptionBuilder = CreateIntegerOption;
|
|
1214
|
-
var MentionableOptionBuilder = CreateMentionableOption;
|
|
1215
|
-
var MessageCommandBuilder = CreateMessageCommand;
|
|
1216
|
-
var NumberOptionBuilder = CreateNumberOption;
|
|
1217
|
-
var RoleOptionBuilder = CreateRoleOption;
|
|
1218
|
-
var SlashCommandBuilder = CreateSlashCommand;
|
|
1219
|
-
var StringOptionBuilder = CreateStringOption;
|
|
1220
|
-
var SubcommandBuilder = CreateSubcommand;
|
|
1221
|
-
var SubcommandGroupBuilder = CreateSubcommandGroup;
|
|
1222
|
-
var UserCommandBuilder = CreateUserCommand;
|
|
1223
|
-
var UserOptionBuilder = CreateUserOption;
|
|
1224
|
-
var ApplicationCommandOptionType = ApplicationCommandOptionEnum;
|
|
1225
1145
|
// packages/builders/src/attachment.ts
|
|
1226
|
-
import { readFile } from "fs/promises";
|
|
1227
|
-
import { basename } from "path";
|
|
1146
|
+
import { readFile, realpath } from "fs/promises";
|
|
1147
|
+
import { basename, isAbsolute, relative, resolve } from "path";
|
|
1228
1148
|
|
|
1229
1149
|
class CreateAttachment {
|
|
1230
1150
|
name;
|
|
1231
1151
|
description;
|
|
1232
1152
|
file;
|
|
1153
|
+
root;
|
|
1233
1154
|
constructor(file, data) {
|
|
1234
1155
|
this.file = file;
|
|
1235
1156
|
if (typeof data === "string") {
|
|
@@ -1237,6 +1158,7 @@ class CreateAttachment {
|
|
|
1237
1158
|
} else {
|
|
1238
1159
|
this.name = data?.name ?? (typeof file === "string" ? basename(file) : "file.bin");
|
|
1239
1160
|
this.description = data?.description;
|
|
1161
|
+
this.root = data?.root;
|
|
1240
1162
|
}
|
|
1241
1163
|
}
|
|
1242
1164
|
setName(name) {
|
|
@@ -1253,7 +1175,8 @@ class CreateAttachment {
|
|
|
1253
1175
|
}
|
|
1254
1176
|
async toBuffer() {
|
|
1255
1177
|
if (typeof this.file === "string") {
|
|
1256
|
-
const
|
|
1178
|
+
const path = this.root === undefined ? this.file : await insideRoot(this.root, this.file);
|
|
1179
|
+
const buffer = await readFile(path);
|
|
1257
1180
|
return new Uint8Array(buffer);
|
|
1258
1181
|
}
|
|
1259
1182
|
if (this.file instanceof Uint8Array)
|
|
@@ -1270,25 +1193,20 @@ class CreateAttachment {
|
|
|
1270
1193
|
throw new TypeError("Attachment file must be a supported binary value or file path.");
|
|
1271
1194
|
}
|
|
1272
1195
|
}
|
|
1273
|
-
|
|
1196
|
+
async function insideRoot(root, file) {
|
|
1197
|
+
const base = await realpath(root);
|
|
1198
|
+
const target = await realpath(resolve(base, file)).catch(() => {
|
|
1199
|
+
throw new Error("Attachment file was not found inside its root.");
|
|
1200
|
+
});
|
|
1201
|
+
const rel = relative(base, target);
|
|
1202
|
+
if (rel === "" || rel.startsWith("..") || isAbsolute(rel))
|
|
1203
|
+
throw new Error("Attachment file is outside its root folder.");
|
|
1204
|
+
return target;
|
|
1205
|
+
}
|
|
1274
1206
|
export {
|
|
1275
|
-
ActionRowBuilder,
|
|
1276
1207
|
ApplicationCommandOptionEnum,
|
|
1277
|
-
ApplicationCommandOptionType,
|
|
1278
|
-
AttachmentBuilder,
|
|
1279
|
-
AttachmentOptionBuilder,
|
|
1280
|
-
BooleanOptionBuilder,
|
|
1281
|
-
ButtonBuilder,
|
|
1282
|
-
ButtonStyle,
|
|
1283
1208
|
ButtonType,
|
|
1284
|
-
ChannelOptionBuilder,
|
|
1285
|
-
ChannelSelectMenuBuilder,
|
|
1286
|
-
CommandOptionBuilder,
|
|
1287
1209
|
ComponentEnum,
|
|
1288
|
-
ComponentType,
|
|
1289
|
-
ContainerBuilder,
|
|
1290
|
-
ContentInventoryEntryBuilder,
|
|
1291
|
-
ContextMenuCommandBuilder,
|
|
1292
1210
|
CreateActionRow,
|
|
1293
1211
|
CreateAttachment,
|
|
1294
1212
|
CreateAttachmentOption,
|
|
@@ -1326,35 +1244,8 @@ export {
|
|
|
1326
1244
|
CreateUserCommand,
|
|
1327
1245
|
CreateUserOption,
|
|
1328
1246
|
CreateUserSelectMenu,
|
|
1329
|
-
EmbedBuilder,
|
|
1330
|
-
EntitySelectBuilder,
|
|
1331
|
-
FileComponentBuilder,
|
|
1332
|
-
IntegerOptionBuilder,
|
|
1333
|
-
MediaGalleryBuilder,
|
|
1334
|
-
MentionableOptionBuilder,
|
|
1335
|
-
MentionableSelectMenuBuilder,
|
|
1336
|
-
MessageCommandBuilder,
|
|
1337
|
-
ModalBuilder,
|
|
1338
|
-
NumberOptionBuilder,
|
|
1339
|
-
RoleOptionBuilder,
|
|
1340
|
-
RoleSelectMenuBuilder,
|
|
1341
|
-
SectionBuilder,
|
|
1342
|
-
SeparatorBuilder,
|
|
1343
|
-
SlashCommandBuilder,
|
|
1344
|
-
StringOptionBuilder,
|
|
1345
|
-
StringSelectBuilder,
|
|
1346
|
-
StringSelectMenuBuilder,
|
|
1347
|
-
SubcommandBuilder,
|
|
1348
|
-
SubcommandGroupBuilder,
|
|
1349
|
-
TextDisplayBuilder,
|
|
1350
|
-
TextInputBuilder,
|
|
1351
|
-
TextInputStyle,
|
|
1352
1247
|
TextInputType,
|
|
1353
|
-
ThumbnailBuilder,
|
|
1354
|
-
UserCommandBuilder,
|
|
1355
|
-
UserOptionBuilder,
|
|
1356
|
-
UserSelectMenuBuilder,
|
|
1357
1248
|
componentsV2Message
|
|
1358
1249
|
};
|
|
1359
1250
|
|
|
1360
|
-
//# debugId=
|
|
1251
|
+
//# debugId=C9A7870D27CD731F64756E2164756E21
|