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.
Files changed (86) hide show
  1. package/README.md +3 -3
  2. package/dist/builders/attachment.d.ts +8 -4
  3. package/dist/builders/commands.d.ts +122 -149
  4. package/dist/builders/components.d.ts +10 -150
  5. package/dist/builders/embed.d.ts +66 -37
  6. package/dist/builders/index.d.ts +0 -4
  7. package/dist/builders/index.js +112 -221
  8. package/dist/builders/index.js.map +10 -9
  9. package/dist/collection/cache.d.ts +15 -6
  10. package/dist/collection/index.d.ts +92 -17
  11. package/dist/collection/index.js +471 -279
  12. package/dist/collection/index.js.map +4 -4
  13. package/dist/core/api.d.ts +130 -0
  14. package/dist/core/channel-create.d.ts +72 -0
  15. package/dist/core/commands.d.ts +232 -0
  16. package/dist/core/events.d.ts +24 -7
  17. package/dist/core/handles.d.ts +157 -0
  18. package/dist/core/index.d.ts +68 -4
  19. package/dist/core/index.js +2639 -493
  20. package/dist/core/index.js.map +47 -37
  21. package/dist/core/permissions.d.ts +7 -7
  22. package/dist/formatters/index.js +9 -5
  23. package/dist/formatters/index.js.map +3 -3
  24. package/dist/handlers/index.js +5 -10
  25. package/dist/handlers/index.js.map +3 -3
  26. package/dist/index.d.ts +2 -2
  27. package/dist/index.js +9527 -7809
  28. package/dist/index.js.map +63 -53
  29. package/dist/managers/advanced.d.ts +29 -1
  30. package/dist/managers/base.d.ts +22 -14
  31. package/dist/managers/emoji.d.ts +0 -2
  32. package/dist/managers/guild-resources.d.ts +13 -5
  33. package/dist/managers/guild.d.ts +40 -4
  34. package/dist/managers/index.d.ts +21 -13
  35. package/dist/managers/index.js +969 -386
  36. package/dist/managers/index.js.map +30 -25
  37. package/dist/managers/member.d.ts +9 -2
  38. package/dist/managers/message.d.ts +10 -15
  39. package/dist/managers/role.d.ts +18 -10
  40. package/dist/managers/thread.d.ts +68 -0
  41. package/dist/managers/user.d.ts +18 -0
  42. package/dist/rest/errors.d.ts +14 -7
  43. package/dist/rest/index.d.ts +24 -12
  44. package/dist/rest/index.js +70 -20
  45. package/dist/rest/index.js.map +9 -9
  46. package/dist/rest/redis.d.ts +1 -1
  47. package/dist/rest/route.d.ts +8 -4
  48. package/dist/rest/routes.d.ts +122 -48
  49. package/dist/rest/transport.d.ts +10 -5
  50. package/dist/rest/webhook.d.ts +9 -5
  51. package/dist/sharding/bus.d.ts +47 -19
  52. package/dist/sharding/cluster.d.ts +11 -0
  53. package/dist/sharding/gateway-bot.d.ts +18 -0
  54. package/dist/sharding/index.d.ts +64 -25
  55. package/dist/sharding/index.js +439 -124
  56. package/dist/sharding/index.js.map +19 -14
  57. package/dist/sharding/supervisor.d.ts +32 -0
  58. package/dist/sharding/transport.d.ts +45 -0
  59. package/dist/structures/audit-log.d.ts +99 -2
  60. package/dist/structures/base.d.ts +40 -23
  61. package/dist/structures/channels.d.ts +45 -14
  62. package/dist/structures/index.d.ts +8 -12
  63. package/dist/structures/index.js +280 -132
  64. package/dist/structures/index.js.map +21 -15
  65. package/dist/structures/interactions.d.ts +91 -63
  66. package/dist/structures/resources.d.ts +99 -52
  67. package/dist/structures/sticker.d.ts +33 -0
  68. package/dist/types/channel-kind.d.ts +26 -0
  69. package/dist/types/gateway.d.ts +24 -12
  70. package/dist/types/index.d.ts +115 -113
  71. package/dist/types/index.js +53 -48
  72. package/dist/types/index.js.map +6 -5
  73. package/dist/voice/index.d.ts +12 -4
  74. package/dist/voice/index.js +14 -18
  75. package/dist/voice/index.js.map +3 -3
  76. package/dist/ws/decoder.d.ts +6 -2
  77. package/dist/ws/dispatcher.d.ts +19 -0
  78. package/dist/ws/index.d.ts +61 -15
  79. package/dist/ws/index.js +194 -77
  80. package/dist/ws/index.js.map +13 -11
  81. package/dist/ws/protocol.d.ts +10 -2
  82. package/dist/ws/reconnect.d.ts +10 -0
  83. package/dist/ws/send-budget.d.ts +6 -2
  84. package/dist/ws/session.d.ts +14 -4
  85. package/dist/ws/state.d.ts +22 -11
  86. package/package.json +20 -16
@@ -1,5 +1,6 @@
1
1
  /** Discord API snowflake identifier. */
2
2
  export type Snowflake = string;
3
+ export * from "./channel-kind.js";
3
4
  export * from "./gateway.js";
4
5
  export * from "./gateway-events.js";
5
6
  /** Discord user object. */
@@ -267,8 +268,66 @@ export interface MessagePayload {
267
268
  /** Discord message flags, e.g. `MessageFlags.SuppressEmbeds`. */
268
269
  flags?: number;
269
270
  tts?: boolean;
271
+ /** Attachment metadata for files sent with the message. */
272
+ attachments?: Array<{
273
+ id: number | string;
274
+ filename?: string;
275
+ description?: string;
276
+ }>;
270
277
  [key: string]: unknown;
271
278
  }
279
+ /** A file to upload with a message. */
280
+ export interface MessageFile {
281
+ name: string;
282
+ data: Blob | Uint8Array | ArrayBuffer | string;
283
+ contentType?: string;
284
+ }
285
+ /** A poll to send; Discord fills in `results` and `expiry` when it is read back. */
286
+ export interface MessagePoll {
287
+ question: {
288
+ text?: string;
289
+ emoji?: APIPartialEmoji;
290
+ };
291
+ answers: Array<{
292
+ poll_media: {
293
+ text?: string;
294
+ emoji?: APIPartialEmoji;
295
+ };
296
+ }>;
297
+ /** Hours the poll stays open (1-768). */
298
+ duration?: number;
299
+ allow_multiselect?: boolean;
300
+ layout_type?: number;
301
+ }
302
+ /** What `send()` takes. */
303
+ export interface MessageCreateOptions extends MessagePayload {
304
+ /** Files to upload; the message is sent as multipart. */
305
+ files?: MessageFile[];
306
+ /** Reply to or forward another message. */
307
+ message_reference?: APIMessageReference;
308
+ poll?: MessagePoll;
309
+ sticker_ids?: Snowflake[];
310
+ /** Returned on the Gateway event so the client can match its own message. */
311
+ nonce?: string | number;
312
+ enforce_nonce?: boolean;
313
+ }
314
+ /** What `edit()` takes: the fields Discord lets you change after sending. */
315
+ export interface MessageEditOptions extends MessagePayload {
316
+ files?: MessageFile[];
317
+ }
318
+ /** What a reply, edit-reply, follow-up or update to an interaction takes. */
319
+ export interface InteractionReplyOptions extends MessagePayload {
320
+ /** Only the person who ran the command sees it. */
321
+ ephemeral?: boolean;
322
+ files?: MessageFile[];
323
+ poll?: MessagePoll;
324
+ /** On `reply()` / `update()`: return the created message (one request, no `fetchReply()`). */
325
+ withResponse?: boolean;
326
+ }
327
+ /** What `update()` on a component interaction takes. */
328
+ export type InteractionUpdateOptions = InteractionReplyOptions;
329
+ /** What `followUp()` takes. */
330
+ export type FollowUpOptions = InteractionReplyOptions;
272
331
  /** Raw Discord attachment object. */
273
332
  export interface APIAttachment {
274
333
  id: Snowflake;
@@ -437,6 +496,20 @@ export interface APIThreadMetadata {
437
496
  invitable?: boolean;
438
497
  create_timestamp?: string | null;
439
498
  }
499
+ /** Fields for a forum or media channel tag. */
500
+ export interface ForumTagInput {
501
+ name: string;
502
+ /** Only moderators (Manage Threads) can apply it. */
503
+ moderated?: boolean;
504
+ emoji_id?: Snowflake | null;
505
+ emoji_name?: string | null;
506
+ }
507
+ /** A role's colours: a solid colour, or a gradient or holographic style. */
508
+ export interface APIRoleColors {
509
+ primary_color: number;
510
+ secondary_color: number | null;
511
+ tertiary_color: number | null;
512
+ }
440
513
  /** Raw Discord forum tag. */
441
514
  export interface APIForumTag {
442
515
  id: Snowflake;
@@ -453,6 +526,45 @@ export interface APIThreadMember {
453
526
  flags: number;
454
527
  member?: APIGuildMember;
455
528
  }
529
+ /** A channel shown on the welcome screen. */
530
+ export interface APIWelcomeScreenChannel {
531
+ channel_id: Snowflake;
532
+ description: string;
533
+ emoji_id: Snowflake | null;
534
+ emoji_name: string | null;
535
+ }
536
+ /** Raw Discord welcome screen. */
537
+ export interface APIWelcomeScreen {
538
+ description: string | null;
539
+ welcome_channels: APIWelcomeScreenChannel[];
540
+ }
541
+ /** One answer to an onboarding question. */
542
+ export interface APIOnboardingOption {
543
+ id: Snowflake;
544
+ channel_ids: Snowflake[];
545
+ role_ids: Snowflake[];
546
+ emoji?: APIPartialEmoji;
547
+ title: string;
548
+ description: string | null;
549
+ }
550
+ /** A question in a guild's onboarding. */
551
+ export interface APIOnboardingPrompt {
552
+ id: Snowflake;
553
+ type: number;
554
+ options: APIOnboardingOption[];
555
+ title: string;
556
+ single_select: boolean;
557
+ required: boolean;
558
+ in_onboarding: boolean;
559
+ }
560
+ /** Raw Discord guild onboarding. */
561
+ export interface APIGuildOnboarding {
562
+ guild_id: Snowflake;
563
+ prompts: APIOnboardingPrompt[];
564
+ default_channel_ids: Snowflake[];
565
+ enabled: boolean;
566
+ mode: number;
567
+ }
456
568
  /** Raw Discord role object. */
457
569
  export interface APIRole {
458
570
  id: Snowflake;
@@ -461,6 +573,8 @@ export interface APIRole {
461
573
  hoist: boolean;
462
574
  icon?: string | null;
463
575
  unicode_emoji?: string | null;
576
+ /** Gradient and holographic colours; `color` stays the primary colour. */
577
+ colors?: APIRoleColors;
464
578
  position: number;
465
579
  permissions: string;
466
580
  managed: boolean;
@@ -516,6 +630,7 @@ export interface APIGuild {
516
630
  preferred_locale?: string;
517
631
  public_updates_channel_id?: Snowflake | null;
518
632
  max_video_channel_users?: number;
633
+ premium_progress_bar_enabled?: boolean;
519
634
  approximate_member_count?: number;
520
635
  approximate_presence_count?: number;
521
636
  nsfw_level?: number;
@@ -864,8 +979,6 @@ export interface APIApplicationCommand {
864
979
  description: string;
865
980
  options?: APIApplicationCommandOption[];
866
981
  default_member_permissions?: string | null;
867
- /** @deprecated Discord deprecated this field. Use `contexts`. Removed in 0.3.0. */
868
- dm_permission?: boolean;
869
982
  /** Where the command can be used: 0 guilds, 1 the bot's DMs, 2 other DMs. */
870
983
  contexts?: number[];
871
984
  nsfw?: boolean;
@@ -878,8 +991,6 @@ export interface ApplicationCommandData {
878
991
  type?: number;
879
992
  options?: APIApplicationCommandOption[];
880
993
  default_member_permissions?: string | null;
881
- /** @deprecated Discord deprecated this field. Use `contexts`. Removed in 0.3.0. */
882
- dm_permission?: boolean;
883
994
  /** Where the command can be used: 0 guilds, 1 the bot's DMs, 2 other DMs. */
884
995
  contexts?: number[];
885
996
  nsfw?: boolean;
@@ -938,112 +1049,3 @@ export interface APISubscription {
938
1049
  canceled_at: string | null;
939
1050
  country?: string;
940
1051
  }
941
- /** @deprecated Use {@link ButtonType}. Removed in 0.3.0. */
942
- export declare const ButtonStyle: {
943
- readonly Primary: 1;
944
- readonly Secondary: 2;
945
- readonly Success: 3;
946
- readonly Danger: 4;
947
- readonly Link: 5;
948
- readonly Premium: 6;
949
- };
950
- /** @deprecated Use {@link ButtonType}. Removed in 0.3.0. */
951
- export type ButtonStyle = ButtonType;
952
- /** @deprecated Use {@link TextInputType}. Removed in 0.3.0. */
953
- export declare const TextInputStyle: {
954
- readonly Short: 1;
955
- readonly Paragraph: 2;
956
- };
957
- /** @deprecated Use {@link TextInputType}. Removed in 0.3.0. */
958
- export type TextInputStyle = TextInputType;
959
- /** @deprecated Use {@link ChannelEnum}. Removed in 0.3.0. */
960
- export declare const ChannelType: {
961
- readonly GuildText: 0;
962
- readonly DM: 1;
963
- readonly GuildVoice: 2;
964
- readonly GroupDM: 3;
965
- readonly GuildCategory: 4;
966
- readonly GuildAnnouncement: 5;
967
- readonly AnnouncementThread: 10;
968
- readonly PublicThread: 11;
969
- readonly PrivateThread: 12;
970
- readonly GuildStageVoice: 13;
971
- readonly GuildDirectory: 14;
972
- readonly GuildForum: 15;
973
- readonly GuildMedia: 16;
974
- };
975
- /** @deprecated Use {@link ChannelEnum}. Removed in 0.3.0. */
976
- export type ChannelType = ChannelEnum;
977
- /** @deprecated Use {@link ComponentEnum}. Removed in 0.3.0. */
978
- export declare const ComponentType: {
979
- readonly ActionRow: 1;
980
- readonly Button: 2;
981
- readonly StringSelect: 3;
982
- readonly TextInput: 4;
983
- readonly UserSelect: 5;
984
- readonly RoleSelect: 6;
985
- readonly MentionableSelect: 7;
986
- readonly ChannelSelect: 8;
987
- readonly Section: 9;
988
- readonly TextDisplay: 10;
989
- readonly Thumbnail: 11;
990
- readonly MediaGallery: 12;
991
- readonly File: 13;
992
- readonly Separator: 14;
993
- readonly ContentInventoryEntry: 16;
994
- readonly Container: 17;
995
- };
996
- /** @deprecated Use {@link ComponentEnum}. Removed in 0.3.0. */
997
- export type ComponentType = ComponentEnum;
998
- /** @deprecated Use {@link InteractionResponseEnum}. Removed in 0.3.0. */
999
- export declare const InteractionResponseType: {
1000
- readonly Pong: 1;
1001
- readonly ChannelMessage: 4;
1002
- readonly DeferredChannelMessage: 5;
1003
- readonly DeferredMessageUpdate: 6;
1004
- readonly MessageUpdate: 7;
1005
- readonly Autocomplete: 8;
1006
- readonly Modal: 9;
1007
- };
1008
- /** @deprecated Use {@link InteractionResponseEnum}. Removed in 0.3.0. */
1009
- export type InteractionResponseType = InteractionResponseEnum;
1010
- /** @deprecated Use {@link ApplicationCommandEnum}. Removed in 0.3.0. */
1011
- export declare const ApplicationCommandType: {
1012
- readonly ChatInput: 1;
1013
- readonly User: 2;
1014
- readonly Message: 3;
1015
- };
1016
- /** @deprecated Use {@link ApplicationCommandEnum}. Removed in 0.3.0. */
1017
- export type ApplicationCommandType = ApplicationCommandEnum;
1018
- /** @deprecated Use {@link ApplicationCommandOptionEnum}. Removed in 0.3.0. */
1019
- export declare const ApplicationCommandOptionType: {
1020
- readonly SubCommand: 1;
1021
- readonly SubCommandGroup: 2;
1022
- readonly String: 3;
1023
- readonly Integer: 4;
1024
- readonly Boolean: 5;
1025
- readonly User: 6;
1026
- readonly Channel: 7;
1027
- readonly Role: 8;
1028
- readonly Mentionable: 9;
1029
- readonly Number: 10;
1030
- readonly Attachment: 11;
1031
- };
1032
- /** @deprecated Use {@link ApplicationCommandOptionEnum}. Removed in 0.3.0. */
1033
- export type ApplicationCommandOptionType = ApplicationCommandOptionEnum;
1034
- /** @deprecated Use {@link StickerEnum}. Removed in 0.3.0. */
1035
- export declare const StickerType: {
1036
- readonly Standard: 1;
1037
- readonly Guild: 2;
1038
- };
1039
- /** @deprecated Use {@link StickerEnum}. Removed in 0.3.0. */
1040
- export type StickerType = StickerEnum;
1041
- /** @deprecated Use {@link StickerFormatEnum}. Removed in 0.3.0. */
1042
- export declare const StickerFormatType: {
1043
- readonly PNG: 1;
1044
- readonly APNG: 2;
1045
- readonly Lottie: 3;
1046
- readonly GIF: 4;
1047
- };
1048
- /** @deprecated Use {@link StickerFormatEnum}. Removed in 0.3.0. */
1049
- export type StickerFormatType = StickerFormatEnum;
@@ -1,4 +1,25 @@
1
1
  // @bun
2
+ // packages/types/src/channel-kind.ts
3
+ var ChannelKinds = {
4
+ text: [0],
5
+ dm: [1],
6
+ voice: [2],
7
+ "group-dm": [3],
8
+ category: [4],
9
+ announcement: [5],
10
+ thread: [10, 11, 12],
11
+ stage: [13],
12
+ directory: [14],
13
+ forum: [15],
14
+ media: [16]
15
+ };
16
+ var KIND_OF_TYPE = new Map(Object.keys(ChannelKinds).flatMap((kind) => ChannelKinds[kind].map((type) => [type, kind])));
17
+ function channelKindOf(type) {
18
+ return KIND_OF_TYPE.get(type) ?? "unknown";
19
+ }
20
+ function channelTypesOf(kind) {
21
+ return ChannelKinds[kind];
22
+ }
2
23
  // packages/types/src/gateway.ts
3
24
  var GatewayIntentBits = {
4
25
  Guilds: 1 << 0,
@@ -53,58 +74,57 @@ var IntentBits = {
53
74
  };
54
75
  var Intents = IntentBits;
55
76
  function resolveGatewayIntents(intents) {
56
- if (typeof intents === "number")
57
- return intents;
58
- if (intents && typeof intents === "object" && !Array.isArray(intents))
59
- return intents.bitfield;
60
- if (Array.isArray(intents)) {
61
- return intents.reduce((acc, intent) => {
62
- return acc | resolveGatewayIntents(intent);
63
- }, 0);
64
- }
65
- if (typeof intents === "string") {
66
- if (intents in GatewayIntentBits)
67
- return GatewayIntentBits[intents];
68
- if (intents in IntentBits)
69
- return IntentBits[intents];
70
- const lower = intents.charAt(0).toLowerCase() + intents.slice(1);
71
- if (lower in IntentBits)
72
- return IntentBits[lower];
73
- const num = Number(intents);
74
- if (!Number.isNaN(num))
75
- return num;
76
- }
77
- return 0;
77
+ if (!Array.isArray(intents))
78
+ throw new TypeError("Gateway intents must be an array, e.g. [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages].");
79
+ return intents.reduce((acc, intent) => acc | resolveIntent(intent), 0);
80
+ }
81
+ function resolveIntent(intent) {
82
+ if (typeof intent === "number")
83
+ return intent;
84
+ const bits = {
85
+ ...IntentBits,
86
+ ...GatewayIntentBits
87
+ };
88
+ const lower = intent.charAt(0).toLowerCase() + intent.slice(1);
89
+ if (Object.hasOwn(bits, intent))
90
+ return bits[intent];
91
+ if (Object.hasOwn(bits, lower))
92
+ return bits[lower];
93
+ const num = Number(intent);
94
+ return Number.isNaN(num) ? 0 : num;
95
+ }
96
+ function resolveInput(bits) {
97
+ return resolveGatewayIntents(Array.isArray(bits) ? bits : [bits]);
78
98
  }
79
99
 
80
100
  class IntentsBitField {
81
101
  static Flags = GatewayIntentBits;
82
102
  bitfield;
83
- constructor(bits = 0) {
84
- this.bitfield = resolveGatewayIntents(bits);
103
+ constructor(bits = []) {
104
+ this.bitfield = resolveInput(bits);
85
105
  }
86
106
  has(bits) {
87
- const resolved = resolveGatewayIntents(bits);
107
+ const resolved = resolveInput(bits);
88
108
  return (this.bitfield & resolved) === resolved;
89
109
  }
90
110
  any(bits) {
91
- return (this.bitfield & resolveGatewayIntents(bits)) !== 0;
111
+ return (this.bitfield & resolveInput(bits)) !== 0;
92
112
  }
93
113
  add(...bits) {
94
114
  for (const bit of bits)
95
- this.bitfield |= resolveGatewayIntents(bit);
115
+ this.bitfield |= resolveInput(bit);
96
116
  return this;
97
117
  }
98
118
  remove(...bits) {
99
119
  for (const bit of bits)
100
- this.bitfield &= ~resolveGatewayIntents(bit);
120
+ this.bitfield &= ~resolveInput(bit);
101
121
  return this;
102
122
  }
103
123
  toArray() {
104
124
  return Object.keys(GatewayIntentBits).filter((name) => this.has(GatewayIntentBits[name]));
105
125
  }
106
126
  equals(bits) {
107
- return this.bitfield === resolveGatewayIntents(bits);
127
+ return this.bitfield === resolveInput(bits);
108
128
  }
109
129
  valueOf() {
110
130
  return this.bitfield;
@@ -229,43 +249,28 @@ var ApplicationCommandEnum = {
229
249
  User: 2,
230
250
  Message: 3
231
251
  };
232
- var ButtonStyle = ButtonType;
233
- var TextInputStyle = TextInputType;
234
- var ChannelType = ChannelEnum;
235
- var ComponentType = ComponentEnum;
236
- var InteractionResponseType = InteractionResponseEnum;
237
- var ApplicationCommandType = ApplicationCommandEnum;
238
- var ApplicationCommandOptionType = ApplicationCommandOptionEnum;
239
- var StickerType = StickerEnum;
240
- var StickerFormatType = StickerFormatEnum;
241
252
  export {
242
253
  ActivityEnum,
243
254
  ApplicationCommandEnum,
244
255
  ApplicationCommandOptionEnum,
245
- ApplicationCommandOptionType,
246
- ApplicationCommandType,
247
- ButtonStyle,
248
256
  ButtonType,
249
257
  ChannelEnum,
250
- ChannelType,
258
+ ChannelKinds,
251
259
  ComponentEnum,
252
- ComponentType,
253
260
  GatewayIntentBits,
254
261
  IntentBits,
255
262
  Intents,
256
263
  IntentsBitField,
257
264
  InteractionResponseEnum,
258
- InteractionResponseType,
259
265
  MessageFlags,
260
266
  PremiumTier,
261
267
  StickerEnum,
262
268
  StickerFormatEnum,
263
- StickerFormatType,
264
- StickerType,
265
- TextInputStyle,
266
269
  TextInputType,
267
270
  VerificationLevel,
271
+ channelKindOf,
272
+ channelTypesOf,
268
273
  resolveGatewayIntents
269
274
  };
270
275
 
271
- //# debugId=40CBDDAEDFA8DAF664756E2164756E21
276
+ //# debugId=32ECC6A3971AFBC464756E2164756E21