lunibee 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builders/components.d.ts +25 -2
- package/dist/builders/embed.d.ts +7 -7
- package/dist/builders/index.d.ts +1 -1
- package/dist/builders/index.js +39 -7
- package/dist/builders/index.js.map +5 -5
- package/dist/core/index.d.ts +4 -2
- package/dist/core/index.js +241 -32
- package/dist/core/index.js.map +15 -15
- package/dist/index.js +468 -38
- package/dist/index.js.map +20 -19
- package/dist/managers/guild-resources.d.ts +22 -2
- package/dist/managers/guild.d.ts +3 -1
- package/dist/managers/index.d.ts +2 -2
- package/dist/managers/index.js +142 -24
- package/dist/managers/index.js.map +12 -12
- package/dist/managers/member.d.ts +13 -12
- package/dist/managers/message.d.ts +11 -3
- package/dist/rest/index.js +2 -2
- package/dist/rest/index.js.map +1 -1
- package/dist/sharding/index.js +2 -2
- package/dist/sharding/index.js.map +1 -1
- package/dist/structures/base.d.ts +36 -0
- package/dist/structures/index.d.ts +29 -0
- package/dist/structures/index.js +116 -8
- package/dist/structures/index.js.map +10 -10
- package/dist/structures/interactions.d.ts +26 -2
- package/dist/structures/options.d.ts +2 -0
- package/dist/structures/resources.d.ts +29 -3
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.js.map +2 -2
- package/dist/utils/args.d.ts +79 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +190 -2
- package/dist/utils/index.js.map +5 -4
- package/package.json +14 -14
|
@@ -23,6 +23,10 @@ export declare const TextInputStyle: {
|
|
|
23
23
|
readonly Short: 1;
|
|
24
24
|
readonly Paragraph: 2;
|
|
25
25
|
};
|
|
26
|
+
/** One {@link TextInputStyle} value, usable as a type. */
|
|
27
|
+
export type TextInputStyle = (typeof TextInputStyle)[keyof typeof TextInputStyle];
|
|
28
|
+
/** One {@link ComponentType} value, usable as a type. */
|
|
29
|
+
export type ComponentType = (typeof ComponentType)[keyof typeof ComponentType];
|
|
26
30
|
export interface APIComponentEmoji {
|
|
27
31
|
id?: string | null;
|
|
28
32
|
name?: string | null;
|
|
@@ -79,8 +83,8 @@ export interface APITextInputComponent {
|
|
|
79
83
|
}
|
|
80
84
|
export interface APIModalComponent {
|
|
81
85
|
type: 9;
|
|
82
|
-
custom_id
|
|
83
|
-
title
|
|
86
|
+
custom_id: string;
|
|
87
|
+
title: string;
|
|
84
88
|
components: APIActionRowComponent[];
|
|
85
89
|
}
|
|
86
90
|
export type APIActionRowChild = APIButtonComponent | APIStringSelectComponent | APIEntitySelectComponent | APITextInputComponent;
|
|
@@ -196,6 +200,8 @@ export declare class ModalBuilder {
|
|
|
196
200
|
addComponents(...components: Array<{
|
|
197
201
|
toJSON(): APIActionRowComponent;
|
|
198
202
|
}>): this;
|
|
203
|
+
/** Adds text inputs, each in its own action row (Discord's modal layout). @param inputs Text inputs, at most 5 per modal. */
|
|
204
|
+
addTextInputs(...inputs: TextInputBuilder[]): this;
|
|
199
205
|
toJSON(): APIModalComponent;
|
|
200
206
|
}
|
|
201
207
|
export declare class TextInputBuilder {
|
|
@@ -287,3 +293,20 @@ export declare class MentionableSelectMenuBuilder extends EntitySelectBuilder {
|
|
|
287
293
|
export declare class ChannelSelectMenuBuilder extends EntitySelectBuilder {
|
|
288
294
|
constructor();
|
|
289
295
|
}
|
|
296
|
+
/**
|
|
297
|
+
* A message payload laid out with Components V2: the components, and the flag
|
|
298
|
+
* Discord requires for them. A V2 message cannot also carry `content` or `embeds`.
|
|
299
|
+
* @param components Top-level components (containers, sections, text displays, action rows...).
|
|
300
|
+
* @param options Extra message fields, such as `allowed_mentions` or `ephemeral`; `flags` are combined.
|
|
301
|
+
* @example channel.send(componentsV2Message(new ContainerBuilder().addComponents(new TextDisplayBuilder().setContent("Hi"))))
|
|
302
|
+
*/
|
|
303
|
+
export declare function componentsV2Message<T extends Record<string, unknown> = Record<string, never>>(components: {
|
|
304
|
+
toJSON(): APIComponent;
|
|
305
|
+
} | Array<{
|
|
306
|
+
toJSON(): APIComponent;
|
|
307
|
+
}>, options?: T & {
|
|
308
|
+
flags?: number;
|
|
309
|
+
}): {
|
|
310
|
+
components: APIComponent[];
|
|
311
|
+
flags: number;
|
|
312
|
+
} & T;
|
package/dist/builders/embed.d.ts
CHANGED
|
@@ -35,19 +35,19 @@ export interface APIEmbed {
|
|
|
35
35
|
/** Builds compile-time-safe rich embed payloads for Discord API requests. */
|
|
36
36
|
export declare class EmbedBuilder {
|
|
37
37
|
#private;
|
|
38
|
-
/** Sets the embed title. @param value Title text. @returns This builder. @throws {RangeError} If title exceeds Discord's limit. */ setTitle(value: string): this;
|
|
39
|
-
/** Sets the embed description. @param value Description text. @returns This builder. @throws {RangeError} If description exceeds Discord's limit. */ setDescription(value: string): this;
|
|
40
|
-
/** Sets the embed URL. @param value Absolute URL. @returns This builder. @throws {TypeError} If URL is invalid. */ setURL(value: string): this;
|
|
38
|
+
/** Sets the embed title. @param value Title text, or null to clear. @returns This builder. @throws {RangeError} If title exceeds Discord's limit. */ setTitle(value: string | null): this;
|
|
39
|
+
/** Sets the embed description. @param value Description text, or null to clear. @returns This builder. @throws {RangeError} If description exceeds Discord's limit. */ setDescription(value: string | null): this;
|
|
40
|
+
/** Sets the embed URL. @param value Absolute URL, or null to clear. @returns This builder. @throws {TypeError} If URL is invalid. */ setURL(value: string | null): this;
|
|
41
41
|
/** Sets the embed color. @param value RGB integer. @returns This builder. @throws {RangeError} If color is outside 24-bit RGB range. */ setColor(value: number): this;
|
|
42
42
|
/** Sets the embed timestamp. @param value Date value. @returns This builder. @throws {RangeError} If date is invalid. */ setTimestamp(value?: Date): this;
|
|
43
43
|
/** Sets the embed footer. @param value Footer payload. @returns This builder. @throws {RangeError} If footer text exceeds Discord's limit. */ setFooter(value: EmbedFooter): this;
|
|
44
44
|
/** Sets the embed author. @param value Author payload. @returns This builder. @throws {RangeError} If author name exceeds Discord's limit. */ setAuthor(value: EmbedAuthor): this;
|
|
45
|
-
/** Sets the thumbnail URL. @param value Thumbnail URL or payload. @returns This builder. @throws {TypeError} If URL is invalid. */ setThumbnail(value: {
|
|
45
|
+
/** Sets the thumbnail URL. @param value Thumbnail URL or payload, or null to clear. @returns This builder. @throws {TypeError} If URL is invalid. */ setThumbnail(value: {
|
|
46
46
|
url: string;
|
|
47
|
-
} | string): this;
|
|
48
|
-
/** Sets the image URL. @param value Image URL or payload. @returns This builder. @throws {TypeError} If URL is invalid. */ setImage(value: {
|
|
47
|
+
} | 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. */ setImage(value: {
|
|
49
49
|
url: string;
|
|
50
|
-
} | string): this;
|
|
50
|
+
} | string | null): this;
|
|
51
51
|
/** Adds embed fields. Accepts both the spread form `addFields(a, b)` and the
|
|
52
52
|
* single-array form `addFields([a, b])` for discord.js `RestOrArray` parity.
|
|
53
53
|
* @param fields Field payloads, spread or as a single array. @returns This builder. @throws {RangeError} If the 25-field limit is exceeded. */ addFields(...fields: EmbedField[] | [EmbedField[]]): this;
|
package/dist/builders/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { EmbedBuilder } from "./embed.js";
|
|
2
2
|
export type { EmbedField } from "./embed.js";
|
|
3
|
-
export { ButtonBuilder, ButtonStyle, ComponentType, ActionRowBuilder, StringSelectBuilder, StringSelectMenuBuilder, EntitySelectBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, MentionableSelectMenuBuilder, ChannelSelectMenuBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ContainerBuilder, SectionBuilder, TextDisplayBuilder, MediaGalleryBuilder, FileComponentBuilder, SeparatorBuilder, ThumbnailBuilder, ContentInventoryEntryBuilder, } from "./components.js";
|
|
3
|
+
export { ButtonBuilder, ButtonStyle, ComponentType, ActionRowBuilder, StringSelectBuilder, StringSelectMenuBuilder, EntitySelectBuilder, UserSelectMenuBuilder, RoleSelectMenuBuilder, MentionableSelectMenuBuilder, ChannelSelectMenuBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ContainerBuilder, SectionBuilder, TextDisplayBuilder, MediaGalleryBuilder, FileComponentBuilder, SeparatorBuilder, ThumbnailBuilder, ContentInventoryEntryBuilder, componentsV2Message, } from "./components.js";
|
|
4
4
|
export { SlashCommandBuilder, StringOptionBuilder, IntegerOptionBuilder, NumberOptionBuilder, BooleanOptionBuilder, UserOptionBuilder, ChannelOptionBuilder, RoleOptionBuilder, MentionableOptionBuilder, AttachmentOptionBuilder, SubcommandBuilder, SubcommandGroupBuilder, ApplicationCommandOptionType, UserCommandBuilder, MessageCommandBuilder, ContextMenuCommandBuilder, } from "./commands.js";
|
|
5
5
|
export { AttachmentBuilder, type AttachmentData } from "./attachment.js";
|
package/dist/builders/index.js
CHANGED
|
@@ -3,15 +3,24 @@
|
|
|
3
3
|
class EmbedBuilder {
|
|
4
4
|
#data = {};
|
|
5
5
|
setTitle(value) {
|
|
6
|
-
|
|
6
|
+
if (value === null)
|
|
7
|
+
delete this.#data.title;
|
|
8
|
+
else
|
|
9
|
+
this.#data.title = validate(value, 256, "Embed title");
|
|
7
10
|
return this;
|
|
8
11
|
}
|
|
9
12
|
setDescription(value) {
|
|
10
|
-
|
|
13
|
+
if (value === null)
|
|
14
|
+
delete this.#data.description;
|
|
15
|
+
else
|
|
16
|
+
this.#data.description = validate(value, 4096, "Embed description");
|
|
11
17
|
return this;
|
|
12
18
|
}
|
|
13
19
|
setURL(value) {
|
|
14
|
-
|
|
20
|
+
if (value === null)
|
|
21
|
+
delete this.#data.url;
|
|
22
|
+
else
|
|
23
|
+
this.#data.url = url(value, "Embed URL");
|
|
15
24
|
return this;
|
|
16
25
|
}
|
|
17
26
|
setColor(value) {
|
|
@@ -43,11 +52,19 @@ class EmbedBuilder {
|
|
|
43
52
|
return this;
|
|
44
53
|
}
|
|
45
54
|
setThumbnail(value) {
|
|
55
|
+
if (value === null) {
|
|
56
|
+
delete this.#data.thumbnail;
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
46
59
|
const valueURL = typeof value === "string" ? value : value.url;
|
|
47
60
|
this.#data.thumbnail = { url: url(valueURL, "Thumbnail URL") };
|
|
48
61
|
return this;
|
|
49
62
|
}
|
|
50
63
|
setImage(value) {
|
|
64
|
+
if (value === null) {
|
|
65
|
+
delete this.#data.image;
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
51
68
|
const valueURL = typeof value === "string" ? value : value.url;
|
|
52
69
|
this.#data.image = { url: url(valueURL, "Image URL") };
|
|
53
70
|
return this;
|
|
@@ -436,6 +453,9 @@ class ModalBuilder {
|
|
|
436
453
|
this.#components.push(...components);
|
|
437
454
|
return this;
|
|
438
455
|
}
|
|
456
|
+
addTextInputs(...inputs) {
|
|
457
|
+
return this.addComponents(...inputs.map((input) => new ActionRowBuilder().addComponents(input)));
|
|
458
|
+
}
|
|
439
459
|
toJSON() {
|
|
440
460
|
if (!this.#custom_id || !this.#title)
|
|
441
461
|
throw new TypeError("Modals require a custom ID and a title.");
|
|
@@ -443,8 +463,8 @@ class ModalBuilder {
|
|
|
443
463
|
throw new RangeError("Modals require at least one component.");
|
|
444
464
|
return {
|
|
445
465
|
type: 9,
|
|
446
|
-
|
|
447
|
-
|
|
466
|
+
custom_id: this.#custom_id,
|
|
467
|
+
title: this.#title,
|
|
448
468
|
components: this.#components.map((component) => component.toJSON())
|
|
449
469
|
};
|
|
450
470
|
}
|
|
@@ -732,6 +752,17 @@ function assertSelect(data) {
|
|
|
732
752
|
if ((data.min_values ?? 1) > (data.max_values ?? 1))
|
|
733
753
|
throw new RangeError("min_values cannot exceed max_values.");
|
|
734
754
|
}
|
|
755
|
+
var IS_COMPONENTS_V2 = 1 << 15;
|
|
756
|
+
function componentsV2Message(components, options) {
|
|
757
|
+
const list = Array.isArray(components) ? components : [components];
|
|
758
|
+
if (!list.length)
|
|
759
|
+
throw new TypeError("A Components V2 message needs at least one component.");
|
|
760
|
+
return {
|
|
761
|
+
...options ?? {},
|
|
762
|
+
components: list.map((component) => component.toJSON()),
|
|
763
|
+
flags: (options?.flags ?? 0) | IS_COMPONENTS_V2
|
|
764
|
+
};
|
|
765
|
+
}
|
|
735
766
|
// packages/builders/src/commands.ts
|
|
736
767
|
var ApplicationCommandOptionType = {
|
|
737
768
|
Subcommand: 1,
|
|
@@ -1221,7 +1252,8 @@ export {
|
|
|
1221
1252
|
ThumbnailBuilder,
|
|
1222
1253
|
UserCommandBuilder,
|
|
1223
1254
|
UserOptionBuilder,
|
|
1224
|
-
UserSelectMenuBuilder
|
|
1255
|
+
UserSelectMenuBuilder,
|
|
1256
|
+
componentsV2Message
|
|
1225
1257
|
};
|
|
1226
1258
|
|
|
1227
|
-
//# debugId=
|
|
1259
|
+
//# debugId=8C8B25AA416C8B5064756E2164756E21
|