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,4 +1,91 @@
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
+ // packages/types/src/gateway.ts
21
+ var GatewayIntentBits = {
22
+ Guilds: 1 << 0,
23
+ GuildMembers: 1 << 1,
24
+ GuildModeration: 1 << 2,
25
+ GuildExpressions: 1 << 3,
26
+ GuildIntegrations: 1 << 4,
27
+ GuildWebhooks: 1 << 5,
28
+ GuildInvites: 1 << 6,
29
+ GuildVoiceStates: 1 << 7,
30
+ GuildPresences: 1 << 8,
31
+ GuildMessages: 1 << 9,
32
+ GuildMessageReactions: 1 << 10,
33
+ GuildMessageTyping: 1 << 11,
34
+ DirectMessages: 1 << 12,
35
+ DirectMessageReactions: 1 << 13,
36
+ DirectMessageTyping: 1 << 14,
37
+ MessageContent: 1 << 15,
38
+ GuildScheduledEvents: 1 << 16,
39
+ AutoModerationConfiguration: 1 << 20,
40
+ AutoModerationExecution: 1 << 21,
41
+ GuildMessagePolls: 1 << 24,
42
+ DirectMessagePolls: 1 << 25
43
+ };
44
+ var IntentBits = {
45
+ guild: 1 << 0,
46
+ guilds: 1 << 0,
47
+ guildMembers: 1 << 1,
48
+ guildModeration: 1 << 2,
49
+ guildBans: 1 << 2,
50
+ guildExpressions: 1 << 3,
51
+ guildEmojis: 1 << 3,
52
+ guildEmojisAndStickers: 1 << 3,
53
+ guildIntegrations: 1 << 4,
54
+ guildWebhooks: 1 << 5,
55
+ guildInvites: 1 << 6,
56
+ guildVoiceStates: 1 << 7,
57
+ guildPresences: 1 << 8,
58
+ guildMessages: 1 << 9,
59
+ guildMessage: 1 << 9,
60
+ guildMessageReactions: 1 << 10,
61
+ guildMessageTyping: 1 << 11,
62
+ directMessages: 1 << 12,
63
+ directMessageReactions: 1 << 13,
64
+ directMessageTyping: 1 << 14,
65
+ messageContent: 1 << 15,
66
+ guildScheduledEvents: 1 << 16,
67
+ autoModerationConfiguration: 1 << 20,
68
+ autoModerationExecution: 1 << 21,
69
+ guildMessagePolls: 1 << 24,
70
+ directMessagePolls: 1 << 25
71
+ };
72
+ // packages/types/src/index.ts
73
+ var InteractionResponseEnum = {
74
+ Pong: 1,
75
+ ChannelMessage: 4,
76
+ DeferredChannelMessage: 5,
77
+ DeferredMessageUpdate: 6,
78
+ MessageUpdate: 7,
79
+ Autocomplete: 8,
80
+ Modal: 9
81
+ };
82
+ var StickerFormatEnum = {
83
+ PNG: 1,
84
+ APNG: 2,
85
+ Lottie: 3,
86
+ GIF: 4
87
+ };
88
+
2
89
  // packages/structures/src/base.ts
3
90
  class BaseStructure {
4
91
  id;
@@ -10,8 +97,11 @@ class BaseStructure {
10
97
  toString() {
11
98
  return this.id;
12
99
  }
100
+ get createdTimestamp() {
101
+ return Number((BigInt(this.id) >> 22n) + 1420070400000n);
102
+ }
13
103
  get createdAt() {
14
- return new Date(Number((BigInt(this.id) >> 22n) + 1420070400000n));
104
+ return new Date(this.createdTimestamp);
15
105
  }
16
106
  }
17
107
  var CDN_BASE = "https://cdn.discordapp.com";
@@ -19,7 +109,7 @@ function cdnURL(path, hash, options = {}) {
19
109
  const isAnimated = hash.startsWith("a_") && !options.forceStatic;
20
110
  const ext = options.extension ?? (isAnimated ? "gif" : "png");
21
111
  const size = options.size ? `?size=${options.size}` : "";
22
- return `${CDN_BASE}${path}/${hash}.${ext}${size}`;
112
+ return `${CDN_BASE}${path}/${encodeURIComponent(hash)}.${ext}${size}`;
23
113
  }
24
114
 
25
115
  class User extends BaseStructure {
@@ -93,9 +183,6 @@ class Channel extends BaseStructure {
93
183
  throw new Error("This channel is not attached to a client.");
94
184
  return this.#context.sendMessage(this.id, options);
95
185
  }
96
- sendMessage(options) {
97
- return this.send(options);
98
- }
99
186
  edit(options) {
100
187
  if (!this.#context?.editChannel)
101
188
  throw new Error("This channel is not attached to a client.");
@@ -125,6 +212,17 @@ class Channel extends BaseStructure {
125
212
  update(options) {
126
213
  return this.edit(options);
127
214
  }
215
+ get kind() {
216
+ return channelKindOf(this.type);
217
+ }
218
+ is(...kinds) {
219
+ return kinds.includes(this.kind);
220
+ }
221
+ as(...kinds) {
222
+ if (!this.is(...kinds))
223
+ throw new TypeError(`Channel ${this.id} is a ${this.kind} channel, not ${kinds.join(" or ")}.`);
224
+ return this;
225
+ }
128
226
  isThread() {
129
227
  return this.type === 10 || this.type === 11 || this.type === 12;
130
228
  }
@@ -176,6 +274,7 @@ class Guild extends BaseStructure {
176
274
  safetyAlertsChannelId;
177
275
  maxPresences;
178
276
  maxVideoChannelUsers;
277
+ premiumProgressBarEnabled;
179
278
  constructor(data) {
180
279
  super(data.id);
181
280
  if (!data.name)
@@ -213,6 +312,7 @@ class Guild extends BaseStructure {
213
312
  this.safetyAlertsChannelId = data.safety_alerts_channel_id ?? null;
214
313
  this.maxPresences = data.max_presences ?? null;
215
314
  this.maxVideoChannelUsers = data.max_video_channel_users;
315
+ this.premiumProgressBarEnabled = data.premium_progress_bar_enabled ?? false;
216
316
  }
217
317
  iconURL(options = {}) {
218
318
  if (!this.icon)
@@ -375,60 +475,7 @@ var Permissions = {
375
475
  PinMessages: 1n << 51n,
376
476
  BypassSlowmode: 1n << 52n
377
477
  };
378
- var PermissionFlagsBits = {
379
- CreateInstantInvite: 1n << 0n,
380
- KickMembers: 1n << 1n,
381
- BanMembers: 1n << 2n,
382
- Administrator: 1n << 3n,
383
- ManageChannels: 1n << 4n,
384
- ManageGuild: 1n << 5n,
385
- AddReactions: 1n << 6n,
386
- ViewAuditLog: 1n << 7n,
387
- PrioritySpeaker: 1n << 8n,
388
- Stream: 1n << 9n,
389
- ViewChannel: 1n << 10n,
390
- SendMessages: 1n << 11n,
391
- SendTTSMessages: 1n << 12n,
392
- ManageMessages: 1n << 13n,
393
- EmbedLinks: 1n << 14n,
394
- AttachFiles: 1n << 15n,
395
- ReadMessageHistory: 1n << 16n,
396
- MentionEveryone: 1n << 17n,
397
- UseExternalEmojis: 1n << 18n,
398
- ViewGuildInsights: 1n << 19n,
399
- Connect: 1n << 20n,
400
- Speak: 1n << 21n,
401
- MuteMembers: 1n << 22n,
402
- DeafenMembers: 1n << 23n,
403
- MoveMembers: 1n << 24n,
404
- UseVAD: 1n << 25n,
405
- ChangeNickname: 1n << 26n,
406
- ManageNicknames: 1n << 27n,
407
- ManageRoles: 1n << 28n,
408
- ManageWebhooks: 1n << 29n,
409
- ManageGuildExpressions: 1n << 30n,
410
- UseApplicationCommands: 1n << 31n,
411
- RequestToSpeak: 1n << 32n,
412
- ManageEvents: 1n << 33n,
413
- ManageThreads: 1n << 34n,
414
- CreatePublicThreads: 1n << 35n,
415
- CreatePrivateThreads: 1n << 36n,
416
- UseExternalStickers: 1n << 37n,
417
- SendMessagesInThreads: 1n << 38n,
418
- UseEmbeddedActivities: 1n << 39n,
419
- ModerateMembers: 1n << 40n,
420
- ViewCreatorMonetizationAnalytics: 1n << 41n,
421
- UseSoundboard: 1n << 42n,
422
- CreateGuildExpressions: 1n << 43n,
423
- CreateEvents: 1n << 44n,
424
- UseExternalSounds: 1n << 45n,
425
- SendVoiceMessages: 1n << 46n,
426
- SetVoiceChannelStatus: 1n << 48n,
427
- SendPolls: 1n << 49n,
428
- UseExternalApps: 1n << 50n,
429
- PinMessages: 1n << 51n,
430
- BypassSlowmode: 1n << 52n
431
- };
478
+ var PermissionFlagsBits = Permissions;
432
479
 
433
480
  class PermissionSet {
434
481
  bitfield;
@@ -703,73 +750,36 @@ class PermissionsBitField extends PermissionSet {
703
750
  }
704
751
  }
705
752
  var ALL_PERMISSIONS = Object.values(Permission).reduce((bits, bit) => bits | bit, 0n);
706
- // packages/types/src/gateway.ts
707
- var GatewayIntentBits = {
708
- Guilds: 1 << 0,
709
- GuildMembers: 1 << 1,
710
- GuildModeration: 1 << 2,
711
- GuildExpressions: 1 << 3,
712
- GuildIntegrations: 1 << 4,
713
- GuildWebhooks: 1 << 5,
714
- GuildInvites: 1 << 6,
715
- GuildVoiceStates: 1 << 7,
716
- GuildPresences: 1 << 8,
717
- GuildMessages: 1 << 9,
718
- GuildMessageReactions: 1 << 10,
719
- GuildMessageTyping: 1 << 11,
720
- DirectMessages: 1 << 12,
721
- DirectMessageReactions: 1 << 13,
722
- DirectMessageTyping: 1 << 14,
723
- MessageContent: 1 << 15,
724
- GuildScheduledEvents: 1 << 16,
725
- AutoModerationConfiguration: 1 << 20,
726
- AutoModerationExecution: 1 << 21,
727
- GuildMessagePolls: 1 << 24,
728
- DirectMessagePolls: 1 << 25
729
- };
730
- var IntentBits = {
731
- guild: 1 << 0,
732
- guilds: 1 << 0,
733
- guildMembers: 1 << 1,
734
- guildModeration: 1 << 2,
735
- guildBans: 1 << 2,
736
- guildExpressions: 1 << 3,
737
- guildEmojis: 1 << 3,
738
- guildEmojisAndStickers: 1 << 3,
739
- guildIntegrations: 1 << 4,
740
- guildWebhooks: 1 << 5,
741
- guildInvites: 1 << 6,
742
- guildVoiceStates: 1 << 7,
743
- guildPresences: 1 << 8,
744
- guildMessages: 1 << 9,
745
- guildMessage: 1 << 9,
746
- guildMessageReactions: 1 << 10,
747
- guildMessageTyping: 1 << 11,
748
- directMessages: 1 << 12,
749
- directMessageReactions: 1 << 13,
750
- directMessageTyping: 1 << 14,
751
- messageContent: 1 << 15,
752
- guildScheduledEvents: 1 << 16,
753
- autoModerationConfiguration: 1 << 20,
754
- autoModerationExecution: 1 << 21,
755
- guildMessagePolls: 1 << 24,
756
- directMessagePolls: 1 << 25
757
- };
758
- // packages/types/src/index.ts
759
- var InteractionResponseEnum = {
760
- Pong: 1,
761
- ChannelMessage: 4,
762
- DeferredChannelMessage: 5,
763
- DeferredMessageUpdate: 6,
764
- MessageUpdate: 7,
765
- Autocomplete: 8,
766
- Modal: 9
767
- };
768
- var InteractionResponseType = InteractionResponseEnum;
753
+ // packages/builders/src/components.ts
754
+ var IS_COMPONENTS_V2 = 1 << 15;
755
+ // packages/builders/src/commands.ts
756
+ var MAX_SAFE = Number.MAX_SAFE_INTEGER;
757
+ // packages/utils/src/args.ts
758
+ var TRUE_WORDS = new Set([
759
+ "true",
760
+ "yes",
761
+ "y",
762
+ "on",
763
+ "1",
764
+ "enable",
765
+ "enabled"
766
+ ]);
767
+ var FALSE_WORDS = new Set([
768
+ "false",
769
+ "no",
770
+ "n",
771
+ "off",
772
+ "0",
773
+ "disable",
774
+ "disabled"
775
+ ]);
776
+ // packages/collection/src/index.ts
777
+ var mapGet = Map.prototype.get;
778
+ var mapHas = Map.prototype.has;
769
779
  // packages/rest/package.json
770
780
  var package_default = {
771
781
  name: "@lunibee/rest",
772
- version: "0.2.3",
782
+ version: "0.3.0",
773
783
  type: "module",
774
784
  module: "./src/index.ts",
775
785
  types: "./src/index.ts",
@@ -871,10 +881,10 @@ class GuildMember {
871
881
  get permissions() {
872
882
  if (this.#suppliedPermissions)
873
883
  return this.#suppliedPermissions;
874
- return new PermissionsBitField(this.#context?.memberPermissions?.(this.guildId, this.user.id, this.roleIds) ?? 0n);
884
+ return new PermissionsBitField(this.#context?.memberPermissions?.(this.guildId, this.user.id, this.roleIds, undefined, this.timedOutUntil) ?? 0n);
875
885
  }
876
886
  permissionsIn(channelId) {
877
- const computed = this.#context?.memberPermissions?.(this.guildId, this.user.id, this.roleIds, channelId);
887
+ const computed = this.#context?.memberPermissions?.(this.guildId, this.user.id, this.roleIds, channelId, this.timedOutUntil);
878
888
  return computed ? new PermissionsBitField(computed) : null;
879
889
  }
880
890
  #action(name) {
@@ -937,6 +947,7 @@ class Role extends BaseStructure {
937
947
  position;
938
948
  unicodeEmoji;
939
949
  iconHash;
950
+ colors;
940
951
  tags;
941
952
  constructor(data) {
942
953
  super(data.id);
@@ -950,6 +961,11 @@ class Role extends BaseStructure {
950
961
  this.mentionable = data.mentionable ?? false;
951
962
  this.position = data.position ?? 0;
952
963
  this.unicodeEmoji = data.unicode_emoji ?? null;
964
+ this.colors = data.colors ? {
965
+ primary: data.colors.primary_color,
966
+ secondary: data.colors.secondary_color,
967
+ tertiary: data.colors.tertiary_color
968
+ } : null;
953
969
  this.iconHash = data.icon ?? null;
954
970
  this.tags = data.tags ?? null;
955
971
  }
@@ -1191,7 +1207,6 @@ class GuildOnboarding extends BaseStructure {
1191
1207
  this.mode = data.mode;
1192
1208
  }
1193
1209
  }
1194
- var WebhookType = WebhookEnum;
1195
1210
  // packages/structures/src/channels.ts
1196
1211
  class NewsChannel extends TextChannel {
1197
1212
  }
@@ -1554,6 +1569,14 @@ class Interaction {
1554
1569
  this.type = data.type;
1555
1570
  this.data = data;
1556
1571
  }
1572
+ get entitlements() {
1573
+ const entitlements = this.data.entitlements;
1574
+ return Array.isArray(entitlements) ? entitlements : [];
1575
+ }
1576
+ hasEntitlement(skuId) {
1577
+ const now = Date.now();
1578
+ return this.entitlements.some((entitlement) => entitlement.sku_id === skuId && !entitlement.deleted && (!entitlement.ends_at || Date.parse(entitlement.ends_at) > now));
1579
+ }
1557
1580
  #commandType() {
1558
1581
  if (this.type !== InteractionEnum.ApplicationCommand)
1559
1582
  return 0;
@@ -1866,7 +1889,6 @@ function createInteraction(client, data) {
1866
1889
  return new Interaction(client, data);
1867
1890
  }
1868
1891
  }
1869
- var InteractionType = InteractionEnum;
1870
1892
  // packages/structures/src/embed.ts
1871
1893
  class Embed {
1872
1894
  #data;
@@ -2006,22 +2028,85 @@ class Embed {
2006
2028
  }
2007
2029
  }
2008
2030
  // packages/structures/src/audit-log.ts
2031
+ function int(value) {
2032
+ return Number(value ?? 0);
2033
+ }
2034
+ function parseInfo(type, options) {
2035
+ if (!options)
2036
+ return;
2037
+ switch (type) {
2038
+ case 13:
2039
+ case 14:
2040
+ case 15:
2041
+ return {
2042
+ id: options.id ?? "",
2043
+ type: int(options.type),
2044
+ roleName: options.role_name
2045
+ };
2046
+ case 21:
2047
+ return {
2048
+ deleteMemberDays: int(options.delete_member_days),
2049
+ membersRemoved: int(options.members_removed)
2050
+ };
2051
+ case 26:
2052
+ case 72:
2053
+ return {
2054
+ channelId: options.channel_id ?? "",
2055
+ count: int(options.count)
2056
+ };
2057
+ case 27:
2058
+ case 73:
2059
+ return { count: int(options.count) };
2060
+ case 74:
2061
+ case 75:
2062
+ return {
2063
+ channelId: options.channel_id ?? "",
2064
+ messageId: options.message_id ?? ""
2065
+ };
2066
+ case 83:
2067
+ case 84:
2068
+ case 85:
2069
+ return { channelId: options.channel_id ?? "" };
2070
+ case 121:
2071
+ return { applicationId: options.app_id ?? "" };
2072
+ case 143:
2073
+ case 144:
2074
+ case 145:
2075
+ return {
2076
+ ruleName: options.auto_moderation_rule_name ?? "",
2077
+ ruleTriggerType: int(options.auto_moderation_rule_trigger_type),
2078
+ channelId: options.channel_id
2079
+ };
2080
+ default:
2081
+ return;
2082
+ }
2083
+ }
2084
+
2009
2085
  class AuditLogEntry extends BaseStructure {
2010
2086
  targetId;
2011
2087
  userId;
2012
2088
  actionType;
2013
2089
  changes;
2014
2090
  options;
2091
+ info;
2015
2092
  reason;
2016
2093
  constructor(data) {
2017
2094
  super(data.id);
2018
2095
  this.targetId = data.target_id;
2019
2096
  this.userId = data.user_id;
2020
2097
  this.actionType = data.action_type;
2098
+ this.info = parseInfo(data.action_type, data.options);
2021
2099
  this.changes = data.changes ?? [];
2022
2100
  this.options = data.options ?? null;
2023
2101
  this.reason = data.reason ?? null;
2024
2102
  }
2103
+ is(type) {
2104
+ return this.actionType === type;
2105
+ }
2106
+ change(key) {
2107
+ const found = this.changes.find((change) => change.key === key);
2108
+ return found && { old: found.old_value, new: found.new_value };
2109
+ }
2025
2110
  }
2026
2111
 
2027
2112
  class AuditLog {
@@ -2032,6 +2117,70 @@ class AuditLog {
2032
2117
  this.entries.set(entryData.id, new AuditLogEntry(entryData));
2033
2118
  }
2034
2119
  }
2120
+ filter(query) {
2121
+ const types = query.type === undefined ? undefined : Array.isArray(query.type) ? query.type : [query.type];
2122
+ const since = query.since === undefined ? undefined : new Date(query.since).getTime();
2123
+ const matches = [];
2124
+ for (const entry of this.entries.values()) {
2125
+ if (types && !types.includes(entry.actionType))
2126
+ continue;
2127
+ if (query.targetId !== undefined && entry.targetId !== query.targetId)
2128
+ continue;
2129
+ if (query.userId !== undefined && entry.userId !== query.userId)
2130
+ continue;
2131
+ if (since !== undefined && entry.createdAt.getTime() < since)
2132
+ continue;
2133
+ matches.push(entry);
2134
+ }
2135
+ return matches;
2136
+ }
2137
+ find(query) {
2138
+ return this.filter(query)[0];
2139
+ }
2140
+ }
2141
+ // packages/structures/src/sticker.ts
2142
+ function stickerURL(id, format, options = {}) {
2143
+ const size = options.size === undefined ? "" : `?size=${options.size}`;
2144
+ if (format === StickerFormatEnum.Lottie)
2145
+ return `https://cdn.discordapp.com/stickers/${id}.json`;
2146
+ if (format === StickerFormatEnum.GIF)
2147
+ return `https://media.discordapp.net/stickers/${id}.gif${size}`;
2148
+ return `https://cdn.discordapp.com/stickers/${id}.png${size}`;
2149
+ }
2150
+
2151
+ class Sticker extends BaseStructure {
2152
+ name;
2153
+ description;
2154
+ tags;
2155
+ type;
2156
+ formatType;
2157
+ available;
2158
+ guildId;
2159
+ packId;
2160
+ sortValue;
2161
+ user;
2162
+ constructor(data) {
2163
+ super(data.id);
2164
+ this.name = data.name;
2165
+ this.description = data.description ?? null;
2166
+ this.tags = data.tags ?? "";
2167
+ this.type = data.type ?? 2;
2168
+ this.formatType = data.format_type;
2169
+ this.available = data.available ?? true;
2170
+ this.guildId = data.guild_id ?? null;
2171
+ this.packId = data.pack_id ?? null;
2172
+ this.sortValue = data.sort_value ?? null;
2173
+ this.user = data.user ?? null;
2174
+ }
2175
+ get animated() {
2176
+ return this.formatType !== StickerFormatEnum.PNG;
2177
+ }
2178
+ url(options = {}) {
2179
+ return stickerURL(this.id, this.formatType, options);
2180
+ }
2181
+ toItem() {
2182
+ return { id: this.id, name: this.name, format_type: this.formatType };
2183
+ }
2035
2184
  }
2036
2185
 
2037
2186
  // packages/structures/src/index.ts
@@ -2244,8 +2393,6 @@ export {
2244
2393
  InteractionEnum,
2245
2394
  InteractionResponse,
2246
2395
  InteractionResponseEnum,
2247
- InteractionResponseType,
2248
- InteractionType,
2249
2396
  Invite,
2250
2397
  MediaChannel,
2251
2398
  Message,
@@ -2256,17 +2403,18 @@ export {
2256
2403
  PermissionsBitField,
2257
2404
  Role,
2258
2405
  StageChannel,
2406
+ Sticker,
2259
2407
  TextChannel,
2260
2408
  ThreadChannel,
2261
2409
  User,
2262
2410
  VoiceChannel,
2263
2411
  Webhook,
2264
2412
  WebhookEnum,
2265
- WebhookType,
2266
2413
  WelcomeScreenChannel,
2267
2414
  cdnURL,
2268
2415
  createChannel,
2269
- createInteraction
2416
+ createInteraction,
2417
+ stickerURL
2270
2418
  };
2271
2419
 
2272
- //# debugId=07D330C2B35D9E3E64756E2164756E21
2420
+ //# debugId=CCB1FE6D82188C4D64756E2164756E21