lunibee 0.1.6 → 0.1.8

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 (80) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +223 -223
  3. package/dist/builders/commands.d.ts +39 -0
  4. package/dist/builders/components.d.ts +37 -12
  5. package/dist/builders/embed.d.ts +3 -1
  6. package/dist/builders/index.d.ts +2 -2
  7. package/dist/builders/index.js +192 -29
  8. package/dist/builders/index.js.map +9 -7
  9. package/dist/collection/index.d.ts +30 -0
  10. package/dist/collection/index.js +79 -5
  11. package/dist/collection/index.js.map +4 -4
  12. package/dist/core/events.d.ts +88 -2
  13. package/dist/core/index.d.ts +46 -85
  14. package/dist/core/index.js +2395 -789
  15. package/dist/core/index.js.map +44 -22
  16. package/dist/core/permissions.d.ts +112 -53
  17. package/dist/formatters/index.d.ts +43 -3
  18. package/dist/formatters/index.js +64 -1
  19. package/dist/formatters/index.js.map +3 -3
  20. package/dist/handlers/index.js.map +2 -2
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +3783 -1009
  23. package/dist/index.js.map +63 -38
  24. package/dist/managers/emoji.d.ts +38 -0
  25. package/dist/managers/guild-resources.d.ts +109 -0
  26. package/dist/managers/guild.d.ts +117 -1
  27. package/dist/managers/index.d.ts +37 -1
  28. package/dist/managers/index.js +1125 -81
  29. package/dist/managers/index.js.map +25 -20
  30. package/dist/rest/decoder.d.ts +23 -0
  31. package/dist/rest/errors.d.ts +20 -0
  32. package/dist/rest/index.d.ts +119 -25
  33. package/dist/rest/index.js +676 -204
  34. package/dist/rest/index.js.map +14 -6
  35. package/dist/rest/limiter.d.ts +42 -0
  36. package/dist/rest/redis.d.ts +54 -0
  37. package/dist/rest/route.d.ts +31 -0
  38. package/dist/rest/routes.d.ts +24 -0
  39. package/dist/rest/scheduler.d.ts +42 -0
  40. package/dist/rest/store.d.ts +67 -0
  41. package/dist/rest/transport.d.ts +40 -0
  42. package/dist/rest/webhook.d.ts +2 -2
  43. package/dist/sharding/bus.d.ts +31 -0
  44. package/dist/sharding/cluster.d.ts +71 -0
  45. package/dist/sharding/index.d.ts +18 -2
  46. package/dist/sharding/index.js +1202 -317
  47. package/dist/sharding/index.js.map +18 -7
  48. package/dist/structures/audit-log.d.ts +26 -0
  49. package/dist/structures/base.d.ts +40 -0
  50. package/dist/structures/channels.d.ts +56 -0
  51. package/dist/structures/index.d.ts +30 -1
  52. package/dist/structures/index.js +963 -87
  53. package/dist/structures/index.js.map +17 -10
  54. package/dist/structures/interactions.d.ts +12 -52
  55. package/dist/structures/options.d.ts +55 -0
  56. package/dist/structures/resources.d.ts +194 -6
  57. package/dist/types/gateway-events.d.ts +132 -0
  58. package/dist/types/gateway.d.ts +181 -0
  59. package/dist/types/index.d.ts +78 -263
  60. package/dist/types/index.js +44 -2
  61. package/dist/types/index.js.map +5 -4
  62. package/dist/utils/index.js.map +2 -2
  63. package/dist/voice/index.d.ts +116 -0
  64. package/dist/voice/index.js +261 -10
  65. package/dist/voice/index.js.map +3 -3
  66. package/dist/ws/close-codes.d.ts +23 -0
  67. package/dist/ws/decoder.d.ts +58 -0
  68. package/dist/ws/heartbeat.d.ts +87 -0
  69. package/dist/ws/index.d.ts +24 -32
  70. package/dist/ws/index.js +920 -318
  71. package/dist/ws/index.js.map +15 -5
  72. package/dist/ws/opcodes.d.ts +14 -0
  73. package/dist/ws/protocol.d.ts +110 -0
  74. package/dist/ws/reconnect.d.ts +108 -0
  75. package/dist/ws/send-budget.d.ts +17 -0
  76. package/dist/ws/session.d.ts +100 -0
  77. package/dist/ws/state.d.ts +27 -0
  78. package/dist/ws/transport.d.ts +80 -0
  79. package/package.json +23 -22
  80. package/dist/structures/permissions.d.ts +0 -73
@@ -118,6 +118,18 @@ class Channel extends BaseStructure {
118
118
  update(options) {
119
119
  return this.edit(options);
120
120
  }
121
+ isThread() {
122
+ return this.type === 10 || this.type === 11 || this.type === 12;
123
+ }
124
+ isTextBased() {
125
+ return [0, 1, 2, 3, 5, 10, 11, 12, 13].includes(this.type);
126
+ }
127
+ isVoiceBased() {
128
+ return this.type === 2 || this.type === 13;
129
+ }
130
+ isDMBased() {
131
+ return this.type === 1 || this.type === 3;
132
+ }
121
133
  toString() {
122
134
  return `<#${this.id}>`;
123
135
  }
@@ -141,6 +153,13 @@ class Guild extends BaseStructure {
141
153
  vanityUrlCode;
142
154
  nsfwLevel;
143
155
  discoverySplash;
156
+ rulesChannelId;
157
+ systemChannelId;
158
+ systemChannelFlags;
159
+ maxMembers;
160
+ mfaLevel;
161
+ explicitContentFilter;
162
+ defaultMessageNotifications;
144
163
  constructor(data) {
145
164
  super(data.id);
146
165
  if (!data.name)
@@ -162,6 +181,14 @@ class Guild extends BaseStructure {
162
181
  this.vanityUrlCode = data.vanity_url_code ?? null;
163
182
  this.nsfwLevel = data.nsfw_level ?? 0;
164
183
  this.discoverySplash = data.discovery_splash ?? null;
184
+ const d = data;
185
+ this.rulesChannelId = d.rules_channel_id ?? null;
186
+ this.systemChannelId = d.system_channel_id ?? null;
187
+ this.systemChannelFlags = d.system_channel_flags ?? 0;
188
+ this.maxMembers = d.max_members ?? 0;
189
+ this.mfaLevel = d.mfa_level ?? 0;
190
+ this.explicitContentFilter = d.explicit_content_filter ?? 0;
191
+ this.defaultMessageNotifications = d.default_message_notifications ?? 0;
165
192
  }
166
193
  iconURL(options = {}) {
167
194
  if (!this.icon)
@@ -183,12 +210,27 @@ class Guild extends BaseStructure {
183
210
  return null;
184
211
  return cdnURL(`/discovery-splashes/${this.id}`, this.discoverySplash, options);
185
212
  }
213
+ widgetImageURL(style = "shield") {
214
+ return `https://discord.com/api/guilds/${this.id}/widget.png?style=${style}`;
215
+ }
186
216
  hasFeature(feature) {
187
217
  return this.features.includes(feature);
188
218
  }
189
219
  get isCommunity() {
190
220
  return this.hasFeature("COMMUNITY");
191
221
  }
222
+ get isPartnered() {
223
+ return this.hasFeature("PARTNERED");
224
+ }
225
+ get isVerified() {
226
+ return this.hasFeature("VERIFIED");
227
+ }
228
+ get isBoosted() {
229
+ return this.premiumSubscriptionCount > 0;
230
+ }
231
+ get boostLevel() {
232
+ return this.premiumTier;
233
+ }
192
234
  get hasVanityUrl() {
193
235
  return this.vanityUrlCode !== null;
194
236
  }
@@ -199,7 +241,58 @@ class Guild extends BaseStructure {
199
241
  return this.name;
200
242
  }
201
243
  }
202
- // packages/structures/src/permissions.ts
244
+ // packages/core/src/permissions.ts
245
+ var Permission = {
246
+ createInstantInvite: 1n << 0n,
247
+ kickMembers: 1n << 1n,
248
+ banMembers: 1n << 2n,
249
+ administrator: 1n << 3n,
250
+ manageChannels: 1n << 4n,
251
+ manageGuild: 1n << 5n,
252
+ addReactions: 1n << 6n,
253
+ viewAuditLog: 1n << 7n,
254
+ prioritySpeaker: 1n << 8n,
255
+ stream: 1n << 9n,
256
+ viewChannel: 1n << 10n,
257
+ sendMessages: 1n << 11n,
258
+ sendTTSMessages: 1n << 12n,
259
+ manageMessages: 1n << 13n,
260
+ embedLinks: 1n << 14n,
261
+ attachFiles: 1n << 15n,
262
+ readMessageHistory: 1n << 16n,
263
+ mentionEveryone: 1n << 17n,
264
+ useExternalEmojis: 1n << 18n,
265
+ viewGuildInsights: 1n << 19n,
266
+ connect: 1n << 20n,
267
+ speak: 1n << 21n,
268
+ muteMembers: 1n << 22n,
269
+ deafenMembers: 1n << 23n,
270
+ moveMembers: 1n << 24n,
271
+ useVAD: 1n << 25n,
272
+ changeNickname: 1n << 26n,
273
+ manageNicknames: 1n << 27n,
274
+ manageRoles: 1n << 28n,
275
+ manageWebhooks: 1n << 29n,
276
+ manageGuildExpressions: 1n << 30n,
277
+ useApplicationCommands: 1n << 31n,
278
+ requestToSpeak: 1n << 32n,
279
+ manageEvents: 1n << 33n,
280
+ manageThreads: 1n << 34n,
281
+ createPublicThreads: 1n << 35n,
282
+ createPrivateThreads: 1n << 36n,
283
+ useExternalStickers: 1n << 37n,
284
+ sendMessagesInThreads: 1n << 38n,
285
+ useEmbeddedActivities: 1n << 39n,
286
+ moderateMembers: 1n << 40n,
287
+ viewCreatorMonetizationAnalytics: 1n << 41n,
288
+ useSoundboard: 1n << 42n,
289
+ createGuildExpressions: 1n << 43n,
290
+ createEvents: 1n << 44n,
291
+ useExternalSounds: 1n << 45n,
292
+ sendVoiceMessages: 1n << 46n,
293
+ sendPolls: 1n << 49n,
294
+ useExternalApps: 1n << 50n
295
+ };
203
296
  var Permissions = {
204
297
  CreateInstantInvite: 1n << 0n,
205
298
  KickMembers: 1n << 1n,
@@ -251,6 +344,57 @@ var Permissions = {
251
344
  SendPolls: 1n << 49n,
252
345
  UseExternalApps: 1n << 50n
253
346
  };
347
+ var PermissionFlagsBits = {
348
+ CreateInstantInvite: 1n << 0n,
349
+ KickMembers: 1n << 1n,
350
+ BanMembers: 1n << 2n,
351
+ Administrator: 1n << 3n,
352
+ ManageChannels: 1n << 4n,
353
+ ManageGuild: 1n << 5n,
354
+ AddReactions: 1n << 6n,
355
+ ViewAuditLog: 1n << 7n,
356
+ PrioritySpeaker: 1n << 8n,
357
+ Stream: 1n << 9n,
358
+ ViewChannel: 1n << 10n,
359
+ SendMessages: 1n << 11n,
360
+ SendTTSMessages: 1n << 12n,
361
+ ManageMessages: 1n << 13n,
362
+ EmbedLinks: 1n << 14n,
363
+ AttachFiles: 1n << 15n,
364
+ ReadMessageHistory: 1n << 16n,
365
+ MentionEveryone: 1n << 17n,
366
+ UseExternalEmojis: 1n << 18n,
367
+ ViewGuildInsights: 1n << 19n,
368
+ Connect: 1n << 20n,
369
+ Speak: 1n << 21n,
370
+ MuteMembers: 1n << 22n,
371
+ DeafenMembers: 1n << 23n,
372
+ MoveMembers: 1n << 24n,
373
+ UseVAD: 1n << 25n,
374
+ ChangeNickname: 1n << 26n,
375
+ ManageNicknames: 1n << 27n,
376
+ ManageRoles: 1n << 28n,
377
+ ManageWebhooks: 1n << 29n,
378
+ ManageGuildExpressions: 1n << 30n,
379
+ UseApplicationCommands: 1n << 31n,
380
+ RequestToSpeak: 1n << 32n,
381
+ ManageEvents: 1n << 33n,
382
+ ManageThreads: 1n << 34n,
383
+ CreatePublicThreads: 1n << 35n,
384
+ CreatePrivateThreads: 1n << 36n,
385
+ UseExternalStickers: 1n << 37n,
386
+ SendMessagesInThreads: 1n << 38n,
387
+ UseEmbeddedActivities: 1n << 39n,
388
+ ModerateMembers: 1n << 40n,
389
+ ViewCreatorMonetizationAnalytics: 1n << 41n,
390
+ UseSoundboard: 1n << 42n,
391
+ CreateGuildExpressions: 1n << 43n,
392
+ CreateEvents: 1n << 44n,
393
+ UseExternalSounds: 1n << 45n,
394
+ SendVoiceMessages: 1n << 46n,
395
+ SendPolls: 1n << 49n,
396
+ UseExternalApps: 1n << 50n
397
+ };
254
398
 
255
399
  class PermissionSet {
256
400
  bitfield;
@@ -258,8 +402,9 @@ class PermissionSet {
258
402
  try {
259
403
  if (Array.isArray(value)) {
260
404
  let bit = 0n;
261
- for (const item of value)
405
+ for (const item of value) {
262
406
  bit |= this.#resolve(item);
407
+ }
263
408
  this.bitfield = bit;
264
409
  } else if (value instanceof PermissionSet) {
265
410
  this.bitfield = value.bitfield;
@@ -275,22 +420,195 @@ class PermissionSet {
275
420
  throw new TypeError("Permission bitfield must be a valid non-negative integer.", { cause: error });
276
421
  }
277
422
  }
423
+ get createInstantInvite() {
424
+ return (this.bitfield & Permission.createInstantInvite) === Permission.createInstantInvite;
425
+ }
426
+ get kickMembers() {
427
+ return (this.bitfield & Permission.kickMembers) === Permission.kickMembers;
428
+ }
429
+ get banMembers() {
430
+ return (this.bitfield & Permission.banMembers) === Permission.banMembers;
431
+ }
432
+ get administrator() {
433
+ return (this.bitfield & Permission.administrator) === Permission.administrator;
434
+ }
435
+ get manageChannels() {
436
+ return (this.bitfield & Permission.manageChannels) === Permission.manageChannels;
437
+ }
438
+ get manageGuild() {
439
+ return (this.bitfield & Permission.manageGuild) === Permission.manageGuild;
440
+ }
441
+ get addReactions() {
442
+ return (this.bitfield & Permission.addReactions) === Permission.addReactions;
443
+ }
444
+ get viewAuditLog() {
445
+ return (this.bitfield & Permission.viewAuditLog) === Permission.viewAuditLog;
446
+ }
447
+ get prioritySpeaker() {
448
+ return (this.bitfield & Permission.prioritySpeaker) === Permission.prioritySpeaker;
449
+ }
450
+ get stream() {
451
+ return (this.bitfield & Permission.stream) === Permission.stream;
452
+ }
453
+ get viewChannel() {
454
+ return (this.bitfield & Permission.viewChannel) === Permission.viewChannel;
455
+ }
456
+ get sendMessages() {
457
+ return (this.bitfield & Permission.sendMessages) === Permission.sendMessages;
458
+ }
459
+ get sendTTSMessages() {
460
+ return (this.bitfield & Permission.sendTTSMessages) === Permission.sendTTSMessages;
461
+ }
462
+ get manageMessages() {
463
+ return (this.bitfield & Permission.manageMessages) === Permission.manageMessages;
464
+ }
465
+ get embedLinks() {
466
+ return (this.bitfield & Permission.embedLinks) === Permission.embedLinks;
467
+ }
468
+ get attachFiles() {
469
+ return (this.bitfield & Permission.attachFiles) === Permission.attachFiles;
470
+ }
471
+ get readMessageHistory() {
472
+ return (this.bitfield & Permission.readMessageHistory) === Permission.readMessageHistory;
473
+ }
474
+ get mentionEveryone() {
475
+ return (this.bitfield & Permission.mentionEveryone) === Permission.mentionEveryone;
476
+ }
477
+ get useExternalEmojis() {
478
+ return (this.bitfield & Permission.useExternalEmojis) === Permission.useExternalEmojis;
479
+ }
480
+ get viewGuildInsights() {
481
+ return (this.bitfield & Permission.viewGuildInsights) === Permission.viewGuildInsights;
482
+ }
483
+ get connect() {
484
+ return (this.bitfield & Permission.connect) === Permission.connect;
485
+ }
486
+ get speak() {
487
+ return (this.bitfield & Permission.speak) === Permission.speak;
488
+ }
489
+ get muteMembers() {
490
+ return (this.bitfield & Permission.muteMembers) === Permission.muteMembers;
491
+ }
492
+ get deafenMembers() {
493
+ return (this.bitfield & Permission.deafenMembers) === Permission.deafenMembers;
494
+ }
495
+ get moveMembers() {
496
+ return (this.bitfield & Permission.moveMembers) === Permission.moveMembers;
497
+ }
498
+ get useVAD() {
499
+ return (this.bitfield & Permission.useVAD) === Permission.useVAD;
500
+ }
501
+ get changeNickname() {
502
+ return (this.bitfield & Permission.changeNickname) === Permission.changeNickname;
503
+ }
504
+ get manageNicknames() {
505
+ return (this.bitfield & Permission.manageNicknames) === Permission.manageNicknames;
506
+ }
507
+ get manageRoles() {
508
+ return (this.bitfield & Permission.manageRoles) === Permission.manageRoles;
509
+ }
510
+ get manageWebhooks() {
511
+ return (this.bitfield & Permission.manageWebhooks) === Permission.manageWebhooks;
512
+ }
513
+ get manageGuildExpressions() {
514
+ return (this.bitfield & Permission.manageGuildExpressions) === Permission.manageGuildExpressions;
515
+ }
516
+ get useApplicationCommands() {
517
+ return (this.bitfield & Permission.useApplicationCommands) === Permission.useApplicationCommands;
518
+ }
519
+ get requestToSpeak() {
520
+ return (this.bitfield & Permission.requestToSpeak) === Permission.requestToSpeak;
521
+ }
522
+ get manageEvents() {
523
+ return (this.bitfield & Permission.manageEvents) === Permission.manageEvents;
524
+ }
525
+ get manageThreads() {
526
+ return (this.bitfield & Permission.manageThreads) === Permission.manageThreads;
527
+ }
528
+ get createPublicThreads() {
529
+ return (this.bitfield & Permission.createPublicThreads) === Permission.createPublicThreads;
530
+ }
531
+ get createPrivateThreads() {
532
+ return (this.bitfield & Permission.createPrivateThreads) === Permission.createPrivateThreads;
533
+ }
534
+ get useExternalStickers() {
535
+ return (this.bitfield & Permission.useExternalStickers) === Permission.useExternalStickers;
536
+ }
537
+ get sendMessagesInThreads() {
538
+ return (this.bitfield & Permission.sendMessagesInThreads) === Permission.sendMessagesInThreads;
539
+ }
540
+ get useEmbeddedActivities() {
541
+ return (this.bitfield & Permission.useEmbeddedActivities) === Permission.useEmbeddedActivities;
542
+ }
543
+ get moderateMembers() {
544
+ return (this.bitfield & Permission.moderateMembers) === Permission.moderateMembers;
545
+ }
546
+ get viewCreatorMonetizationAnalytics() {
547
+ return (this.bitfield & Permission.viewCreatorMonetizationAnalytics) === Permission.viewCreatorMonetizationAnalytics;
548
+ }
549
+ get useSoundboard() {
550
+ return (this.bitfield & Permission.useSoundboard) === Permission.useSoundboard;
551
+ }
552
+ get createGuildExpressions() {
553
+ return (this.bitfield & Permission.createGuildExpressions) === Permission.createGuildExpressions;
554
+ }
555
+ get createEvents() {
556
+ return (this.bitfield & Permission.createEvents) === Permission.createEvents;
557
+ }
558
+ get useExternalSounds() {
559
+ return (this.bitfield & Permission.useExternalSounds) === Permission.useExternalSounds;
560
+ }
561
+ get sendVoiceMessages() {
562
+ return (this.bitfield & Permission.sendVoiceMessages) === Permission.sendVoiceMessages;
563
+ }
564
+ get sendPolls() {
565
+ return (this.bitfield & Permission.sendPolls) === Permission.sendPolls;
566
+ }
567
+ get useExternalApps() {
568
+ return (this.bitfield & Permission.useExternalApps) === Permission.useExternalApps;
569
+ }
278
570
  has(...permissions) {
279
- return permissions.every((permission) => (this.bitfield & this.#resolve(permission)) === this.#resolve(permission));
571
+ if (permissions.length === 1) {
572
+ const p = permissions[0];
573
+ const bit = typeof p === "bigint" ? p : this.#resolve(p);
574
+ return (this.bitfield & bit) === bit;
575
+ }
576
+ for (let i = 0;i < permissions.length; i++) {
577
+ const p = permissions[i];
578
+ const bit = typeof p === "bigint" ? p : this.#resolve(p);
579
+ if ((this.bitfield & bit) !== bit)
580
+ return false;
581
+ }
582
+ return true;
280
583
  }
281
584
  any(...permissions) {
282
- return permissions.some((permission) => (this.bitfield & this.#resolve(permission)) !== 0n);
585
+ if (permissions.length === 1) {
586
+ const p = permissions[0];
587
+ const bit = typeof p === "bigint" ? p : this.#resolve(p);
588
+ return (this.bitfield & bit) !== 0n;
589
+ }
590
+ for (let i = 0;i < permissions.length; i++) {
591
+ const p = permissions[i];
592
+ const bit = typeof p === "bigint" ? p : this.#resolve(p);
593
+ if ((this.bitfield & bit) !== 0n)
594
+ return true;
595
+ }
596
+ return false;
283
597
  }
284
598
  add(...permissions) {
285
599
  let bitfield = this.bitfield;
286
- for (const permission of permissions)
287
- bitfield |= this.#resolve(permission);
600
+ for (let i = 0;i < permissions.length; i++) {
601
+ const p = permissions[i];
602
+ bitfield |= typeof p === "bigint" ? p : this.#resolve(p);
603
+ }
288
604
  return new PermissionSet(bitfield);
289
605
  }
290
606
  remove(...permissions) {
291
607
  let bitfield = this.bitfield;
292
- for (const permission of permissions)
293
- bitfield &= ~this.#resolve(permission);
608
+ for (let i = 0;i < permissions.length; i++) {
609
+ const p = permissions[i];
610
+ bitfield &= ~(typeof p === "bigint" ? p : this.#resolve(p));
611
+ }
294
612
  return new PermissionSet(bitfield);
295
613
  }
296
614
  equals(other) {
@@ -300,27 +618,31 @@ class PermissionSet {
300
618
  return this.bitfield.toString();
301
619
  }
302
620
  toArray() {
303
- return Object.keys(Permissions).filter((permission) => this.has(permission));
621
+ return Object.keys(Permission).filter((permission) => this.has(permission));
304
622
  }
305
623
  #resolve(permission) {
306
- if (permission instanceof PermissionSet)
307
- return permission.bitfield;
308
624
  if (typeof permission === "bigint")
309
625
  return permission;
310
626
  if (typeof permission === "number")
311
627
  return BigInt(permission);
628
+ if (permission instanceof PermissionSet)
629
+ return permission.bitfield;
312
630
  if (Array.isArray(permission)) {
313
631
  let bit = 0n;
314
- for (const p of permission)
315
- bit |= this.#resolve(p);
632
+ for (let i = 0;i < permission.length; i++)
633
+ bit |= this.#resolve(permission[i]);
316
634
  return bit;
317
635
  }
318
636
  if (typeof permission === "string") {
637
+ if (permission in Permission)
638
+ return Permission[permission];
319
639
  if (permission in Permissions)
320
640
  return Permissions[permission];
321
- const matchedKey = Object.keys(Permissions).find((k) => k.toLowerCase() === permission.toLowerCase());
322
- if (matchedKey)
323
- return Permissions[matchedKey];
641
+ if (permission in PermissionFlagsBits)
642
+ return PermissionFlagsBits[permission];
643
+ const lower = permission.charAt(0).toLowerCase() + permission.slice(1);
644
+ if (lower in Permission)
645
+ return Permission[lower];
324
646
  return BigInt(permission);
325
647
  }
326
648
  return 0n;
@@ -328,12 +650,138 @@ class PermissionSet {
328
650
  }
329
651
 
330
652
  class PermissionsBitField extends PermissionSet {
653
+ static Flags = PermissionFlagsBits;
654
+ static All = Permission;
331
655
  constructor(value = 0n) {
332
656
  super(value);
333
657
  }
334
658
  }
659
+ // packages/types/src/gateway.ts
660
+ var GatewayIntentBits = {
661
+ Guilds: 1 << 0,
662
+ GuildMembers: 1 << 1,
663
+ GuildModeration: 1 << 2,
664
+ GuildExpressions: 1 << 3,
665
+ GuildIntegrations: 1 << 4,
666
+ GuildWebhooks: 1 << 5,
667
+ GuildInvites: 1 << 6,
668
+ GuildVoiceStates: 1 << 7,
669
+ GuildPresences: 1 << 8,
670
+ GuildMessages: 1 << 9,
671
+ GuildMessageReactions: 1 << 10,
672
+ GuildMessageTyping: 1 << 11,
673
+ DirectMessages: 1 << 12,
674
+ DirectMessageReactions: 1 << 13,
675
+ DirectMessageTyping: 1 << 14,
676
+ MessageContent: 1 << 15,
677
+ GuildScheduledEvents: 1 << 16,
678
+ AutoModerationConfiguration: 1 << 20,
679
+ AutoModerationExecution: 1 << 21,
680
+ GuildMessagePolls: 1 << 24,
681
+ DirectMessagePolls: 1 << 25
682
+ };
683
+ var IntentBits = {
684
+ guild: 1 << 0,
685
+ guilds: 1 << 0,
686
+ guildMembers: 1 << 1,
687
+ guildModeration: 1 << 2,
688
+ guildBans: 1 << 2,
689
+ guildExpressions: 1 << 3,
690
+ guildEmojis: 1 << 3,
691
+ guildEmojisAndStickers: 1 << 3,
692
+ guildIntegrations: 1 << 4,
693
+ guildWebhooks: 1 << 5,
694
+ guildInvites: 1 << 6,
695
+ guildVoiceStates: 1 << 7,
696
+ guildPresences: 1 << 8,
697
+ guildMessages: 1 << 9,
698
+ guildMessage: 1 << 9,
699
+ guildMessageReactions: 1 << 10,
700
+ guildMessageTyping: 1 << 11,
701
+ directMessages: 1 << 12,
702
+ directMessageReactions: 1 << 13,
703
+ directMessageTyping: 1 << 14,
704
+ messageContent: 1 << 15,
705
+ guildScheduledEvents: 1 << 16,
706
+ autoModerationConfiguration: 1 << 20,
707
+ autoModerationExecution: 1 << 21,
708
+ guildMessagePolls: 1 << 24,
709
+ directMessagePolls: 1 << 25
710
+ };
711
+ // packages/types/src/index.ts
712
+ var InteractionResponseType = {
713
+ Pong: 1,
714
+ ChannelMessage: 4,
715
+ DeferredChannelMessage: 5,
716
+ DeferredMessageUpdate: 6,
717
+ MessageUpdate: 7,
718
+ Autocomplete: 8,
719
+ Modal: 9
720
+ };
721
+ // packages/rest/package.json
722
+ var package_default = {
723
+ name: "@lunibee/rest",
724
+ version: "0.1.8",
725
+ type: "module",
726
+ module: "./src/index.ts",
727
+ types: "./src/index.ts",
728
+ exports: {
729
+ ".": "./src/index.ts"
730
+ }
731
+ };
335
732
 
733
+ // packages/rest/src/index.ts
734
+ var LIBRARY_VERSION = package_default.version;
735
+ var LIBRARY_URL = "https://github.com/Ekretos/lunibee";
736
+ var USER_AGENT = `DiscordBot (${LIBRARY_URL}, ${package_default.version})`;
737
+ var REQUEST_DATA_KEYS = new Set([
738
+ "body",
739
+ "files",
740
+ "query",
741
+ "headers",
742
+ "reason",
743
+ "auth",
744
+ "signal"
745
+ ]);
746
+ // packages/ws/src/close-codes.ts
747
+ var GatewayCloseCodes = {
748
+ UnknownError: 4000,
749
+ UnknownOpcode: 4001,
750
+ DecodeError: 4002,
751
+ NotAuthenticated: 4003,
752
+ AuthenticationFailed: 4004,
753
+ AlreadyAuthenticated: 4005,
754
+ InvalidSeq: 4007,
755
+ RateLimited: 4008,
756
+ SessionTimedOut: 4009,
757
+ InvalidShard: 4010,
758
+ ShardingRequired: 4011,
759
+ InvalidAPIVersion: 4012,
760
+ InvalidIntents: 4013,
761
+ DisallowedIntents: 4014
762
+ };
763
+
764
+ // packages/ws/src/reconnect.ts
765
+ var FATAL_CLOSE_CODES = [
766
+ GatewayCloseCodes.AuthenticationFailed,
767
+ GatewayCloseCodes.InvalidShard,
768
+ GatewayCloseCodes.ShardingRequired,
769
+ GatewayCloseCodes.InvalidAPIVersion,
770
+ GatewayCloseCodes.InvalidIntents,
771
+ GatewayCloseCodes.DisallowedIntents
772
+ ];
773
+ var IDENTIFY_CLOSE_CODES = [
774
+ GatewayCloseCodes.InvalidSeq,
775
+ GatewayCloseCodes.SessionTimedOut
776
+ ];
336
777
  // packages/structures/src/resources.ts
778
+ function toDateOrNull(value) {
779
+ if (!value)
780
+ return null;
781
+ const date = new Date(value);
782
+ return Number.isNaN(date.getTime()) ? null : date;
783
+ }
784
+
337
785
  class GuildMember {
338
786
  user;
339
787
  guildId;
@@ -342,6 +790,10 @@ class GuildMember {
342
790
  pending;
343
791
  joinedAt;
344
792
  permissions;
793
+ avatarHash;
794
+ premiumSince;
795
+ timedOutUntil;
796
+ flags;
345
797
  constructor(data) {
346
798
  this.user = new User(data.user);
347
799
  if (!/^\d{1,20}$/.test(data.guild_id))
@@ -354,10 +806,25 @@ class GuildMember {
354
806
  if (this.joinedAt?.toString() === "Invalid Date")
355
807
  throw new RangeError("Member joined_at must be a valid date.");
356
808
  this.permissions = new PermissionsBitField(data.permissions ?? 0n);
809
+ this.avatarHash = data.avatar ?? null;
810
+ this.premiumSince = toDateOrNull(data.premium_since);
811
+ this.timedOutUntil = toDateOrNull(data.communication_disabled_until);
812
+ this.flags = data.flags ?? 0;
357
813
  }
358
814
  get displayName() {
359
815
  return this.nickname ?? this.user.displayName;
360
816
  }
817
+ get isTimedOut() {
818
+ return this.timedOutUntil !== null && this.timedOutUntil > new Date;
819
+ }
820
+ avatarURL(options = {}) {
821
+ if (this.avatarHash)
822
+ return cdnURL(`/guilds/${this.guildId}/users/${this.user.id}/avatars`, this.avatarHash, options);
823
+ return this.user.avatarURL(options);
824
+ }
825
+ displayAvatarURL(options = {}) {
826
+ return this.avatarURL(options) ?? this.user.displayAvatarURL(options);
827
+ }
361
828
  toString() {
362
829
  return this.user.toString();
363
830
  }
@@ -370,6 +837,10 @@ class Role extends BaseStructure {
370
837
  permissions;
371
838
  managed;
372
839
  mentionable;
840
+ position;
841
+ unicodeEmoji;
842
+ iconHash;
843
+ tags;
373
844
  constructor(data) {
374
845
  super(data.id);
375
846
  if (!data.name)
@@ -380,6 +851,21 @@ class Role extends BaseStructure {
380
851
  this.permissions = new PermissionsBitField(data.permissions ?? 0n);
381
852
  this.managed = data.managed ?? false;
382
853
  this.mentionable = data.mentionable ?? false;
854
+ this.position = data.position ?? 0;
855
+ this.unicodeEmoji = data.unicode_emoji ?? null;
856
+ this.iconHash = data.icon ?? null;
857
+ this.tags = data.tags ?? null;
858
+ }
859
+ get colorHex() {
860
+ return `#${this.color.toString(16).padStart(6, "0").toUpperCase()}`;
861
+ }
862
+ iconURL(options = {}) {
863
+ if (!this.iconHash)
864
+ return null;
865
+ return cdnURL(`/role-icons/${this.id}`, this.iconHash, options);
866
+ }
867
+ isEveryone(guildId) {
868
+ return this.id === guildId;
383
869
  }
384
870
  toString() {
385
871
  return `<@&${this.id}>`;
@@ -394,76 +880,321 @@ class TextChannel extends Channel {
394
880
  return `<#${this.id}>`;
395
881
  }
396
882
  }
397
- // packages/types/src/index.ts
398
- var GatewayIntentBits = {
399
- Guilds: 1 << 0,
400
- GuildMembers: 1 << 1,
401
- GuildModeration: 1 << 2,
402
- GuildExpressions: 1 << 3,
403
- GuildIntegrations: 1 << 4,
404
- GuildWebhooks: 1 << 5,
405
- GuildInvites: 1 << 6,
406
- GuildVoiceStates: 1 << 7,
407
- GuildPresences: 1 << 8,
408
- GuildMessages: 1 << 9,
409
- GuildMessageReactions: 1 << 10,
410
- GuildMessageTyping: 1 << 11,
411
- DirectMessages: 1 << 12,
412
- DirectMessageReactions: 1 << 13,
413
- DirectMessageTyping: 1 << 14,
414
- MessageContent: 1 << 15,
415
- GuildScheduledEvents: 1 << 16,
416
- AutoModerationConfiguration: 1 << 20,
417
- AutoModerationExecution: 1 << 21,
418
- GuildMessagePolls: 1 << 24,
419
- DirectMessagePolls: 1 << 25
420
- };
421
- var IntentBits = {
422
- guild: 1 << 0,
423
- guilds: 1 << 0,
424
- guildMembers: 1 << 1,
425
- guildModeration: 1 << 2,
426
- guildBans: 1 << 2,
427
- guildExpressions: 1 << 3,
428
- guildEmojis: 1 << 3,
429
- guildEmojisAndStickers: 1 << 3,
430
- guildIntegrations: 1 << 4,
431
- guildWebhooks: 1 << 5,
432
- guildInvites: 1 << 6,
433
- guildVoiceStates: 1 << 7,
434
- guildPresences: 1 << 8,
435
- guildMessages: 1 << 9,
436
- guildMessage: 1 << 9,
437
- guildMessageReactions: 1 << 10,
438
- guildMessageTyping: 1 << 11,
439
- directMessages: 1 << 12,
440
- directMessageReactions: 1 << 13,
441
- directMessageTyping: 1 << 14,
442
- messageContent: 1 << 15,
443
- guildScheduledEvents: 1 << 16,
444
- autoModerationConfiguration: 1 << 20,
445
- autoModerationExecution: 1 << 21,
446
- guildMessagePolls: 1 << 24,
447
- directMessagePolls: 1 << 25
448
- };
449
- var InteractionResponseType = {
450
- Pong: 1,
451
- ChannelMessage: 4,
452
- DeferredChannelMessage: 5,
453
- DeferredMessageUpdate: 6,
454
- MessageUpdate: 7,
455
- Autocomplete: 8,
456
- Modal: 9
457
- };
458
883
 
459
- // packages/structures/src/interactions.ts
460
- var InteractionType = {
461
- Ping: 1,
462
- ApplicationCommand: 2,
463
- MessageComponent: 3,
464
- ApplicationCommandAutocomplete: 4,
465
- ModalSubmit: 5
884
+ class Invite {
885
+ code;
886
+ guildId;
887
+ channelId;
888
+ inviter;
889
+ uses;
890
+ maxUses;
891
+ maxAge;
892
+ temporary;
893
+ createdAt;
894
+ expiresAt;
895
+ constructor(data) {
896
+ if (!data.code)
897
+ throw new TypeError("An invite requires a code.");
898
+ this.code = data.code;
899
+ this.guildId = data.guild?.id ?? null;
900
+ this.channelId = data.channel?.id ?? null;
901
+ this.inviter = data.inviter ? new User(data.inviter) : null;
902
+ this.uses = data.uses ?? 0;
903
+ this.maxUses = data.max_uses ?? 0;
904
+ this.maxAge = data.max_age ?? 0;
905
+ this.temporary = data.temporary ?? false;
906
+ this.createdAt = data.created_at ? new Date(data.created_at) : null;
907
+ this.expiresAt = data.expires_at ? new Date(data.expires_at) : null;
908
+ }
909
+ get url() {
910
+ return `https://discord.gg/${this.code}`;
911
+ }
912
+ toString() {
913
+ return this.url;
914
+ }
915
+ }
916
+ var WebhookType = {
917
+ Incoming: 1,
918
+ ChannelFollower: 2,
919
+ Application: 3
466
920
  };
921
+
922
+ class Webhook extends BaseStructure {
923
+ type;
924
+ name;
925
+ avatarHash;
926
+ channelId;
927
+ guildId;
928
+ applicationId;
929
+ token;
930
+ constructor(data) {
931
+ super(data.id);
932
+ this.type = data.type ?? WebhookType.Incoming;
933
+ this.name = data.name ?? null;
934
+ this.avatarHash = data.avatar ?? null;
935
+ this.channelId = data.channel_id ?? null;
936
+ this.guildId = data.guild_id ?? null;
937
+ this.applicationId = data.application_id ?? null;
938
+ this.token = data.token ?? null;
939
+ }
940
+ avatarURL(options = {}) {
941
+ if (!this.avatarHash)
942
+ return null;
943
+ return cdnURL(`/avatars/${this.id}`, this.avatarHash, options);
944
+ }
945
+ get url() {
946
+ return this.token ? `https://discord.com/api/webhooks/${this.id}/${this.token}` : null;
947
+ }
948
+ toString() {
949
+ return this.url ?? this.id;
950
+ }
951
+ }
952
+
953
+ class Emoji extends BaseStructure {
954
+ name;
955
+ roleIds;
956
+ user;
957
+ requireColons;
958
+ managed;
959
+ animated;
960
+ available;
961
+ constructor(data) {
962
+ super(data.id ?? "0");
963
+ if (data.id === null)
964
+ this.id = "unicode";
965
+ this.name = data.name;
966
+ this.roleIds = data.roles ?? [];
967
+ this.user = data.user ? new User(data.user) : null;
968
+ this.requireColons = data.require_colons ?? false;
969
+ this.managed = data.managed ?? false;
970
+ this.animated = data.animated ?? false;
971
+ this.available = data.available ?? true;
972
+ }
973
+ url(options = {}) {
974
+ if (!this.id || this.id === "unicode")
975
+ return null;
976
+ const ext = options.extension ?? (this.animated ? "gif" : "png");
977
+ const size = options.size ? `?size=${options.size}` : "";
978
+ return `${CDN_BASE}/emojis/${this.id}.${ext}${size}`;
979
+ }
980
+ toString() {
981
+ return this.id !== "unicode" ? `<${this.animated ? "a" : ""}:${this.name}:${this.id}>` : this.name ?? "";
982
+ }
983
+ }
984
+
985
+ class AutoModerationRule extends BaseStructure {
986
+ guildId;
987
+ name;
988
+ creatorId;
989
+ eventType;
990
+ triggerType;
991
+ triggerMetadata;
992
+ actions;
993
+ enabled;
994
+ exemptRoles;
995
+ exemptChannels;
996
+ constructor(data) {
997
+ super(data.id);
998
+ if (!/^\d{1,20}$/.test(data.guild_id))
999
+ throw new TypeError("AutoModerationRule guild_id must be a valid snowflake.");
1000
+ this.guildId = data.guild_id;
1001
+ this.name = data.name;
1002
+ this.creatorId = data.creator_id;
1003
+ this.eventType = data.event_type;
1004
+ this.triggerType = data.trigger_type;
1005
+ this.triggerMetadata = data.trigger_metadata;
1006
+ this.actions = data.actions;
1007
+ this.enabled = data.enabled;
1008
+ this.exemptRoles = data.exempt_roles;
1009
+ this.exemptChannels = data.exempt_channels;
1010
+ }
1011
+ toJSON() {
1012
+ return {
1013
+ id: this.id,
1014
+ guildId: this.guildId,
1015
+ name: this.name,
1016
+ creatorId: this.creatorId,
1017
+ eventType: this.eventType,
1018
+ triggerType: this.triggerType,
1019
+ triggerMetadata: this.triggerMetadata,
1020
+ actions: this.actions,
1021
+ enabled: this.enabled,
1022
+ exemptRoles: this.exemptRoles,
1023
+ exemptChannels: this.exemptChannels
1024
+ };
1025
+ }
1026
+ }
1027
+
1028
+ class WelcomeScreenChannel {
1029
+ channelId;
1030
+ description;
1031
+ emojiId;
1032
+ emojiName;
1033
+ constructor(data) {
1034
+ this.channelId = data.channel_id;
1035
+ this.description = data.description;
1036
+ this.emojiId = data.emoji_id;
1037
+ this.emojiName = data.emoji_name;
1038
+ }
1039
+ }
1040
+
1041
+ class GuildWelcomeScreen2 {
1042
+ description;
1043
+ channels;
1044
+ constructor(data) {
1045
+ this.description = data.description;
1046
+ this.channels = data.welcome_channels.map((c) => new WelcomeScreenChannel(c));
1047
+ }
1048
+ }
1049
+
1050
+ class OnboardingPromptOption extends BaseStructure {
1051
+ channelIds;
1052
+ roleIds;
1053
+ emoji;
1054
+ title;
1055
+ description;
1056
+ constructor(data) {
1057
+ super(data.id);
1058
+ this.channelIds = data.channel_ids;
1059
+ this.roleIds = data.role_ids;
1060
+ this.emoji = data.emoji;
1061
+ this.title = data.title;
1062
+ this.description = data.description;
1063
+ }
1064
+ }
1065
+
1066
+ class OnboardingPrompt extends BaseStructure {
1067
+ type;
1068
+ options;
1069
+ title;
1070
+ singleSelect;
1071
+ required;
1072
+ inOnboarding;
1073
+ constructor(data) {
1074
+ super(data.id);
1075
+ this.type = data.type;
1076
+ this.options = data.options.map((o) => new OnboardingPromptOption(o));
1077
+ this.title = data.title;
1078
+ this.singleSelect = data.single_select;
1079
+ this.required = data.required;
1080
+ this.inOnboarding = data.in_onboarding;
1081
+ }
1082
+ }
1083
+
1084
+ class GuildOnboarding2 extends BaseStructure {
1085
+ prompts;
1086
+ defaultChannelIds;
1087
+ enabled;
1088
+ mode;
1089
+ constructor(data) {
1090
+ super(data.guild_id);
1091
+ this.prompts = data.prompts.map((p) => new OnboardingPrompt(p));
1092
+ this.defaultChannelIds = data.default_channel_ids;
1093
+ this.enabled = data.enabled;
1094
+ this.mode = data.mode;
1095
+ }
1096
+ }
1097
+ // packages/structures/src/channels.ts
1098
+ class NewsChannel extends TextChannel {
1099
+ }
1100
+
1101
+ class DMChannel extends Channel {
1102
+ recipients;
1103
+ ownerId;
1104
+ constructor(data, context) {
1105
+ super(data, context);
1106
+ this.recipients = (data.recipients ?? []).map((u) => new User(u));
1107
+ this.ownerId = data.owner_id ?? null;
1108
+ }
1109
+ }
1110
+
1111
+ class VoiceChannel extends Channel {
1112
+ bitrate;
1113
+ userLimit;
1114
+ rtcRegion;
1115
+ videoQualityMode;
1116
+ constructor(data, context) {
1117
+ super(data, context);
1118
+ this.bitrate = data.bitrate ?? 64000;
1119
+ this.userLimit = data.user_limit ?? 0;
1120
+ this.rtcRegion = data.rtc_region ?? null;
1121
+ this.videoQualityMode = data.video_quality_mode ?? 1;
1122
+ }
1123
+ }
1124
+
1125
+ class StageChannel extends VoiceChannel {
1126
+ }
1127
+
1128
+ class CategoryChannel extends Channel {
1129
+ }
1130
+
1131
+ class ThreadChannel extends Channel {
1132
+ ownerId;
1133
+ messageCount;
1134
+ memberCount;
1135
+ metadata;
1136
+ constructor(data, context) {
1137
+ super(data, context);
1138
+ this.ownerId = data.owner_id ?? null;
1139
+ this.messageCount = data.message_count ?? 0;
1140
+ this.memberCount = data.member_count ?? 0;
1141
+ this.metadata = data.thread_metadata ?? null;
1142
+ }
1143
+ get archived() {
1144
+ return this.metadata?.archived ?? false;
1145
+ }
1146
+ get locked() {
1147
+ return this.metadata?.locked ?? false;
1148
+ }
1149
+ get autoArchiveDuration() {
1150
+ return this.metadata?.auto_archive_duration ?? null;
1151
+ }
1152
+ }
1153
+
1154
+ class ForumChannel extends Channel {
1155
+ availableTags;
1156
+ defaultReactionEmoji;
1157
+ defaultThreadRateLimitPerUser;
1158
+ defaultAutoArchiveDuration;
1159
+ constructor(data, context) {
1160
+ super(data, context);
1161
+ this.availableTags = data.available_tags ?? [];
1162
+ this.defaultReactionEmoji = data.default_reaction_emoji ?? null;
1163
+ this.defaultThreadRateLimitPerUser = data.default_thread_rate_limit_per_user ?? 0;
1164
+ this.defaultAutoArchiveDuration = data.default_auto_archive_duration ?? null;
1165
+ }
1166
+ }
1167
+
1168
+ class MediaChannel extends ForumChannel {
1169
+ }
1170
+ function createChannel(data, context) {
1171
+ switch (data.type) {
1172
+ case 0:
1173
+ return new TextChannel(data, context);
1174
+ case 1:
1175
+ case 3:
1176
+ return new DMChannel(data, context);
1177
+ case 2:
1178
+ return new VoiceChannel(data, context);
1179
+ case 4:
1180
+ return new CategoryChannel(data, context);
1181
+ case 5:
1182
+ return new NewsChannel(data, context);
1183
+ case 10:
1184
+ case 11:
1185
+ case 12:
1186
+ return new ThreadChannel(data, context);
1187
+ case 13:
1188
+ return new StageChannel(data, context);
1189
+ case 15:
1190
+ return new ForumChannel(data, context);
1191
+ case 16:
1192
+ return new MediaChannel(data, context);
1193
+ default:
1194
+ return new Channel(data, context);
1195
+ }
1196
+ }
1197
+ // packages/structures/src/options.ts
467
1198
  var OptionType = {
468
1199
  SubCommand: 1,
469
1200
  SubCommandGroup: 2,
@@ -519,6 +1250,12 @@ class CommandOptions {
519
1250
  }
520
1251
  return this.#subcommandGroup;
521
1252
  }
1253
+ getFocused(full = false) {
1254
+ const focused = this.#options.find((o) => o.focused);
1255
+ if (!focused)
1256
+ throw new TypeError("No focused option was provided.");
1257
+ return full ? focused : focused.value ?? "";
1258
+ }
522
1259
  getString(name, required = false) {
523
1260
  const opt = this.#get(name);
524
1261
  if (!opt || opt.type !== OptionType.String) {
@@ -624,6 +1361,14 @@ class CommandOptions {
624
1361
  return this.#options;
625
1362
  }
626
1363
  }
1364
+ // packages/structures/src/interactions.ts
1365
+ var InteractionType = {
1366
+ Ping: 1,
1367
+ ApplicationCommand: 2,
1368
+ MessageComponent: 3,
1369
+ ApplicationCommandAutocomplete: 4,
1370
+ ModalSubmit: 5
1371
+ };
627
1372
 
628
1373
  class InteractionResponse {
629
1374
  type;
@@ -687,6 +1432,30 @@ class Interaction {
687
1432
  isAutocomplete() {
688
1433
  return this.type === InteractionType.ApplicationCommandAutocomplete;
689
1434
  }
1435
+ #componentType() {
1436
+ return this.isMessageComponent() ? this.data.data?.component_type ?? 0 : 0;
1437
+ }
1438
+ isButton() {
1439
+ return this.#componentType() === 2;
1440
+ }
1441
+ isStringSelectMenu() {
1442
+ return this.#componentType() === 3;
1443
+ }
1444
+ isUserSelectMenu() {
1445
+ return this.#componentType() === 5;
1446
+ }
1447
+ isRoleSelectMenu() {
1448
+ return this.#componentType() === 6;
1449
+ }
1450
+ isMentionableSelectMenu() {
1451
+ return this.#componentType() === 7;
1452
+ }
1453
+ isChannelSelectMenu() {
1454
+ return this.#componentType() === 8;
1455
+ }
1456
+ isAnySelectMenu() {
1457
+ return [3, 5, 6, 7, 8].includes(this.#componentType());
1458
+ }
690
1459
  assertUnacknowledged() {
691
1460
  if (this.replied || this.deferred)
692
1461
  throw new Error("Interaction has already been acknowledged.");
@@ -746,8 +1515,7 @@ class CommandInteraction extends Interaction {
746
1515
  super(client, data);
747
1516
  const rawOptions = data.data?.options ?? [];
748
1517
  const resolved = data.data?.resolved ?? {};
749
- const sub = rawOptions.find((o) => o.type === 1 || o.type === 2);
750
- this.options = new CommandOptions(sub?.options ?? rawOptions, resolved);
1518
+ this.options = new CommandOptions(rawOptions, resolved);
751
1519
  }
752
1520
  }
753
1521
 
@@ -798,6 +1566,11 @@ class ModalSubmitInteraction extends Interaction {
798
1566
  }
799
1567
 
800
1568
  class AutocompleteInteraction extends Interaction {
1569
+ options;
1570
+ constructor(client, data) {
1571
+ super(client, data);
1572
+ this.options = new CommandOptions(data.data?.options ?? []);
1573
+ }
801
1574
  get commandName() {
802
1575
  return this.data?.data?.name ?? "";
803
1576
  }
@@ -977,8 +1750,38 @@ class Embed {
977
1750
  return new Embed(data);
978
1751
  }
979
1752
  }
1753
+ // packages/structures/src/audit-log.ts
1754
+ class AuditLogEntry extends BaseStructure {
1755
+ targetId;
1756
+ userId;
1757
+ actionType;
1758
+ changes;
1759
+ options;
1760
+ reason;
1761
+ constructor(data) {
1762
+ super(data.id);
1763
+ this.targetId = data.target_id;
1764
+ this.userId = data.user_id;
1765
+ this.actionType = data.action_type;
1766
+ this.changes = data.changes ?? [];
1767
+ this.options = data.options ?? null;
1768
+ this.reason = data.reason ?? null;
1769
+ }
1770
+ }
1771
+
1772
+ class AuditLog {
1773
+ entries;
1774
+ constructor(data) {
1775
+ this.entries = new Map;
1776
+ for (const entryData of data.audit_log_entries) {
1777
+ this.entries.set(entryData.id, new AuditLogEntry(entryData));
1778
+ }
1779
+ }
1780
+ }
980
1781
 
981
1782
  // packages/structures/src/index.ts
1783
+ var NON_SYSTEM_MESSAGE_TYPES = new Set([0, 19, 20, 23]);
1784
+
982
1785
  class Message extends BaseStructure {
983
1786
  content;
984
1787
  author;
@@ -1024,6 +1827,12 @@ class Message extends BaseStructure {
1024
1827
  get embedsSuppressed() {
1025
1828
  return (this.flags & 4) !== 0;
1026
1829
  }
1830
+ get createdTimestamp() {
1831
+ return this.timestamp.getTime();
1832
+ }
1833
+ get createdAt() {
1834
+ return this.timestamp;
1835
+ }
1027
1836
  edit(options) {
1028
1837
  if (!this.#context)
1029
1838
  throw new Error("This message is not attached to a client.");
@@ -1078,27 +1887,94 @@ class Message extends BaseStructure {
1078
1887
  throw new Error("This message is not attached to a client.");
1079
1888
  return this.#context.unpinMessage(this.channelId, this.id);
1080
1889
  }
1890
+ get isEphemeral() {
1891
+ return (this.flags & 64) !== 0;
1892
+ }
1893
+ get isPinned() {
1894
+ return this.pinned;
1895
+ }
1896
+ get isSystemMessage() {
1897
+ return !NON_SYSTEM_MESSAGE_TYPES.has(this.type);
1898
+ }
1899
+ get isCrosspost() {
1900
+ return (this.flags & 2) !== 0;
1901
+ }
1902
+ get hasAttachments() {
1903
+ return this.attachments.length > 0;
1904
+ }
1905
+ get hasEmbeds() {
1906
+ return this.embeds.length > 0;
1907
+ }
1908
+ get hasComponents() {
1909
+ return this.components.length > 0;
1910
+ }
1911
+ suppressEmbeds() {
1912
+ return this.edit({ flags: this.flags | 4 });
1913
+ }
1914
+ toJSON() {
1915
+ return {
1916
+ id: this.id,
1917
+ content: this.content,
1918
+ channelId: this.channelId,
1919
+ guildId: this.guildId,
1920
+ flags: this.flags,
1921
+ pinned: this.pinned,
1922
+ mentionEveryone: this.mentionEveryone,
1923
+ type: this.type,
1924
+ timestamp: this.timestamp.toISOString(),
1925
+ author: { id: this.author.id, username: this.author.username },
1926
+ attachments: [...this.attachments],
1927
+ embeds: [...this.embeds],
1928
+ components: [...this.components],
1929
+ mentions: this.mentions.map((u) => u.id),
1930
+ mentionRoles: [...this.mentionRoles],
1931
+ reference: this.reference,
1932
+ referencedMessage: this.referencedMessage ? this.referencedMessage.id : this.referencedMessage
1933
+ };
1934
+ }
1081
1935
  }
1082
1936
  export {
1937
+ AuditLog,
1938
+ AuditLogEntry,
1939
+ AutoModerationRule,
1083
1940
  AutocompleteInteraction,
1084
1941
  BaseStructure,
1942
+ CategoryChannel,
1085
1943
  Channel,
1086
1944
  CommandInteraction,
1087
1945
  CommandOptions,
1088
1946
  ComponentInteraction,
1947
+ DMChannel,
1089
1948
  Embed,
1949
+ Emoji,
1950
+ ForumChannel,
1090
1951
  Guild,
1091
1952
  GuildMember,
1953
+ GuildOnboarding2 as GuildOnboarding,
1954
+ GuildWelcomeScreen2 as GuildWelcomeScreen,
1092
1955
  Interaction,
1093
1956
  InteractionResponse,
1094
1957
  InteractionResponseType,
1095
1958
  InteractionType,
1959
+ Invite,
1960
+ MediaChannel,
1096
1961
  Message,
1097
1962
  ModalSubmitInteraction,
1963
+ NewsChannel,
1964
+ OnboardingPrompt,
1965
+ OnboardingPromptOption,
1966
+ PermissionsBitField,
1098
1967
  Role,
1968
+ StageChannel,
1099
1969
  TextChannel,
1970
+ ThreadChannel,
1100
1971
  User,
1972
+ VoiceChannel,
1973
+ Webhook,
1974
+ WebhookType,
1975
+ WelcomeScreenChannel,
1976
+ createChannel,
1101
1977
  createInteraction
1102
1978
  };
1103
1979
 
1104
- //# debugId=CEF93D39CC02DA4464756E2164756E21
1980
+ //# debugId=8FB0F7F12180BD8364756E2164756E21