lunibee 0.1.8 → 0.2.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 +2 -0
- package/dist/builders/components.d.ts +5 -0
- package/dist/builders/index.js +72 -12
- package/dist/builders/index.js.map +5 -5
- package/dist/collection/index.d.ts +68 -1
- package/dist/collection/index.js +334 -1
- package/dist/collection/index.js.map +3 -3
- package/dist/core/collector.d.ts +13 -0
- package/dist/core/events.d.ts +29 -3
- package/dist/core/index.d.ts +22 -8
- package/dist/core/index.js +1526 -124
- package/dist/core/index.js.map +26 -22
- package/dist/core/permissions.d.ts +48 -0
- package/dist/index.js +1578 -268
- package/dist/index.js.map +30 -29
- package/dist/managers/advanced.d.ts +116 -0
- package/dist/managers/base.d.ts +13 -2
- package/dist/managers/emoji.d.ts +1 -1
- package/dist/managers/guild.d.ts +28 -2
- package/dist/managers/index.d.ts +37 -5
- package/dist/managers/index.js +870 -152
- package/dist/managers/index.js.map +18 -16
- package/dist/managers/message.d.ts +10 -1
- package/dist/rest/errors.d.ts +33 -0
- package/dist/rest/index.d.ts +1 -1
- package/dist/rest/index.js +52 -6
- package/dist/rest/index.js.map +5 -5
- package/dist/rest/routes.d.ts +20 -0
- package/dist/sharding/index.d.ts +29 -0
- package/dist/sharding/index.js +99 -15
- package/dist/sharding/index.js.map +8 -8
- package/dist/structures/base.d.ts +2 -0
- package/dist/structures/index.js +96 -42
- package/dist/structures/index.js.map +10 -9
- package/dist/structures/interactions.d.ts +26 -0
- package/dist/types/gateway.d.ts +16 -0
- package/dist/types/index.d.ts +55 -1
- package/dist/types/index.js.map +2 -2
- package/dist/voice/index.d.ts +3 -0
- package/dist/voice/index.js +15 -1
- package/dist/voice/index.js.map +3 -3
- package/dist/ws/index.js +13 -5
- package/dist/ws/index.js.map +6 -6
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -130,6 +130,8 @@ Resource managers maintain canonical instances by Discord resource ID. Re-resolv
|
|
|
130
130
|
|
|
131
131
|
REST-created and Gateway-updated resources are routed through manager cache mutation APIs so the same resource is not represented by unrelated structure instances.
|
|
132
132
|
|
|
133
|
+
Discord resources are stored with `Collection.setWithoutTTL()` and leave the cache only through Gateway delete events or an explicit `delete()`, never through expiry. Messages are cached only with the `messageCache: { maxSize?, ttl? }` client option, and `cache: { users, members, roles, emojis }` turns off per-resource caching on large bots. For your own data, `new Collection(null, { ttl, maxSize, onEvict })` is a TTL/LRU cache. See the [0.2.0 upgrade guide](https://lunibee.js.org/getting-started/upgrading/).
|
|
134
|
+
|
|
133
135
|
## Permissions
|
|
134
136
|
|
|
135
137
|
`PermissionSet` provides named and raw permission checks:
|
|
@@ -35,6 +35,8 @@ export interface APIButtonComponent {
|
|
|
35
35
|
label?: string;
|
|
36
36
|
emoji?: APIComponentEmoji;
|
|
37
37
|
url?: string;
|
|
38
|
+
/** SKU for premium (style 6) buttons. */
|
|
39
|
+
sku_id?: string;
|
|
38
40
|
disabled?: boolean;
|
|
39
41
|
}
|
|
40
42
|
export interface APISelectOption {
|
|
@@ -164,10 +166,13 @@ export declare class StringSelectBuilder {
|
|
|
164
166
|
}
|
|
165
167
|
export declare class ButtonBuilder {
|
|
166
168
|
#private;
|
|
169
|
+
/** Sets the style and drops fields that style cannot carry. */
|
|
167
170
|
setStyle(style: APIButtonComponent["style"]): this;
|
|
168
171
|
setCustomId(value: string): this;
|
|
169
172
|
setLabel(value: string): this;
|
|
170
173
|
setURL(value: string): this;
|
|
174
|
+
/** Makes this a premium (purchase) button for a SKU. Premium buttons carry no label, emoji, custom ID or URL. */
|
|
175
|
+
setSKUId(skuId: string): this;
|
|
171
176
|
setEmoji(emoji: APIComponentEmoji | string): this;
|
|
172
177
|
setDisabled(value?: boolean): this;
|
|
173
178
|
toJSON(): APIButtonComponent;
|
package/dist/builders/index.js
CHANGED
|
@@ -212,10 +212,13 @@ class ActionRowBuilder {
|
|
|
212
212
|
return this;
|
|
213
213
|
}
|
|
214
214
|
toJSON() {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
215
|
+
const components = this.#components.map((component) => component.toJSON());
|
|
216
|
+
if (components.length === 0)
|
|
217
|
+
throw new RangeError("An action row needs at least one component.");
|
|
218
|
+
const types = components.map((component) => component.type);
|
|
219
|
+
if (types.some((type) => type !== ComponentType.Button) && components.length > 1)
|
|
220
|
+
throw new RangeError("A select menu or text input must be alone in its action row.");
|
|
221
|
+
return { type: ComponentType.ActionRow, components };
|
|
219
222
|
}
|
|
220
223
|
}
|
|
221
224
|
|
|
@@ -270,6 +273,12 @@ class StringSelectBuilder {
|
|
|
270
273
|
return this;
|
|
271
274
|
}
|
|
272
275
|
toJSON() {
|
|
276
|
+
assertSelect(this.#data);
|
|
277
|
+
const count = this.#data.options?.length ?? 0;
|
|
278
|
+
if (count === 0)
|
|
279
|
+
throw new RangeError("A string select needs at least one option.");
|
|
280
|
+
if ((this.#data.max_values ?? 1) > count)
|
|
281
|
+
throw new RangeError("max_values cannot exceed the number of options.");
|
|
273
282
|
return structuredClone(this.#data);
|
|
274
283
|
}
|
|
275
284
|
}
|
|
@@ -280,9 +289,20 @@ class ButtonBuilder {
|
|
|
280
289
|
style: ButtonStyle.Secondary
|
|
281
290
|
};
|
|
282
291
|
setStyle(style) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
292
|
+
const data = this.#data;
|
|
293
|
+
data.style = style;
|
|
294
|
+
if (style === ButtonStyle.Link) {
|
|
295
|
+
delete data.custom_id;
|
|
296
|
+
delete data.sku_id;
|
|
297
|
+
} else if (style === ButtonStyle.Premium) {
|
|
298
|
+
delete data.custom_id;
|
|
299
|
+
delete data.url;
|
|
300
|
+
delete data.label;
|
|
301
|
+
delete data.emoji;
|
|
302
|
+
} else {
|
|
303
|
+
delete data.url;
|
|
304
|
+
delete data.sku_id;
|
|
305
|
+
}
|
|
286
306
|
return this;
|
|
287
307
|
}
|
|
288
308
|
setCustomId(value) {
|
|
@@ -307,11 +327,16 @@ class ButtonBuilder {
|
|
|
307
327
|
cause: error
|
|
308
328
|
});
|
|
309
329
|
}
|
|
310
|
-
this
|
|
311
|
-
delete this.#data.custom_id;
|
|
330
|
+
this.setStyle(ButtonStyle.Link);
|
|
312
331
|
this.#data.url = url.toString();
|
|
313
332
|
return this;
|
|
314
333
|
}
|
|
334
|
+
setSKUId(skuId) {
|
|
335
|
+
validateText(skuId, 20, "Button SKU ID");
|
|
336
|
+
this.setStyle(ButtonStyle.Premium);
|
|
337
|
+
this.#data.sku_id = skuId;
|
|
338
|
+
return this;
|
|
339
|
+
}
|
|
315
340
|
setEmoji(emoji) {
|
|
316
341
|
this.#data.emoji = typeof emoji === "string" ? { name: emoji } : { ...emoji };
|
|
317
342
|
return this;
|
|
@@ -321,7 +346,26 @@ class ButtonBuilder {
|
|
|
321
346
|
return this;
|
|
322
347
|
}
|
|
323
348
|
toJSON() {
|
|
324
|
-
|
|
349
|
+
const data = this.#data;
|
|
350
|
+
if (data.style === ButtonStyle.Link) {
|
|
351
|
+
if (!data.url)
|
|
352
|
+
throw new TypeError("Link buttons require a URL.");
|
|
353
|
+
if (data.custom_id || data.sku_id)
|
|
354
|
+
throw new TypeError("Link buttons cannot have a custom ID or SKU ID.");
|
|
355
|
+
} else if (data.style === ButtonStyle.Premium) {
|
|
356
|
+
if (!data.sku_id)
|
|
357
|
+
throw new TypeError("Premium buttons require a SKU ID.");
|
|
358
|
+
if (data.custom_id || data.url || data.label || data.emoji)
|
|
359
|
+
throw new TypeError("Premium buttons cannot have a custom ID, URL, label or emoji.");
|
|
360
|
+
} else {
|
|
361
|
+
if (!data.custom_id)
|
|
362
|
+
throw new TypeError("Non-link buttons require a custom ID.");
|
|
363
|
+
if (data.url || data.sku_id)
|
|
364
|
+
throw new TypeError("Only link buttons have a URL and only premium buttons have a SKU ID.");
|
|
365
|
+
}
|
|
366
|
+
if (data.style !== ButtonStyle.Premium && !data.label && !data.emoji)
|
|
367
|
+
throw new TypeError("Buttons require a label or an emoji.");
|
|
368
|
+
return structuredClone(data);
|
|
325
369
|
}
|
|
326
370
|
}
|
|
327
371
|
|
|
@@ -365,6 +409,7 @@ class EntitySelectBuilder {
|
|
|
365
409
|
return this;
|
|
366
410
|
}
|
|
367
411
|
toJSON() {
|
|
412
|
+
assertSelect(this.#data);
|
|
368
413
|
return structuredClone(this.#data);
|
|
369
414
|
}
|
|
370
415
|
}
|
|
@@ -392,6 +437,10 @@ class ModalBuilder {
|
|
|
392
437
|
return this;
|
|
393
438
|
}
|
|
394
439
|
toJSON() {
|
|
440
|
+
if (!this.#custom_id || !this.#title)
|
|
441
|
+
throw new TypeError("Modals require a custom ID and a title.");
|
|
442
|
+
if (this.#components.length === 0)
|
|
443
|
+
throw new RangeError("Modals require at least one component.");
|
|
395
444
|
return {
|
|
396
445
|
type: 9,
|
|
397
446
|
...this.#custom_id ? { custom_id: this.#custom_id } : {},
|
|
@@ -445,7 +494,12 @@ class TextInputBuilder {
|
|
|
445
494
|
return this;
|
|
446
495
|
}
|
|
447
496
|
toJSON() {
|
|
448
|
-
|
|
497
|
+
const data = this.#data;
|
|
498
|
+
if (!data.custom_id)
|
|
499
|
+
throw new TypeError("Text inputs require a custom ID.");
|
|
500
|
+
if (data.min_length !== undefined && data.max_length !== undefined && data.min_length > data.max_length)
|
|
501
|
+
throw new RangeError("min_length cannot exceed max_length.");
|
|
502
|
+
return structuredClone(data);
|
|
449
503
|
}
|
|
450
504
|
}
|
|
451
505
|
|
|
@@ -672,6 +726,12 @@ class ChannelSelectMenuBuilder extends EntitySelectBuilder {
|
|
|
672
726
|
super(ComponentType.ChannelSelect);
|
|
673
727
|
}
|
|
674
728
|
}
|
|
729
|
+
function assertSelect(data) {
|
|
730
|
+
if (!data.custom_id)
|
|
731
|
+
throw new TypeError("Select menus require a custom ID.");
|
|
732
|
+
if ((data.min_values ?? 1) > (data.max_values ?? 1))
|
|
733
|
+
throw new RangeError("min_values cannot exceed max_values.");
|
|
734
|
+
}
|
|
675
735
|
// packages/builders/src/commands.ts
|
|
676
736
|
var ApplicationCommandOptionType = {
|
|
677
737
|
Subcommand: 1,
|
|
@@ -1164,4 +1224,4 @@ export {
|
|
|
1164
1224
|
UserSelectMenuBuilder
|
|
1165
1225
|
};
|
|
1166
1226
|
|
|
1167
|
-
//# debugId=
|
|
1227
|
+
//# debugId=91BF5BFA3419A2E364756E2164756E21
|