lunibee 0.3.3 → 0.4.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 (125) hide show
  1. package/README.md +1 -1
  2. package/dist/builders/commands.d.ts +1 -1
  3. package/dist/builders/components.d.ts +9 -11
  4. package/dist/builders/embed.d.ts +1 -1
  5. package/dist/builders/index.d.ts +1 -1
  6. package/dist/builders/index.js +87 -1298
  7. package/dist/builders/index.js.map +3 -11
  8. package/dist/chunks/index-0wn81eng.js +2492 -0
  9. package/dist/chunks/index-0wn81eng.js.map +17 -0
  10. package/dist/chunks/index-2en489j6.js +40 -0
  11. package/dist/chunks/index-2en489j6.js.map +10 -0
  12. package/dist/chunks/index-3hyps48a.js +203 -0
  13. package/dist/chunks/index-3hyps48a.js.map +11 -0
  14. package/dist/chunks/index-57c5n3ms.js +2274 -0
  15. package/dist/chunks/index-57c5n3ms.js.map +19 -0
  16. package/dist/chunks/index-5yx92e36.js +1170 -0
  17. package/dist/chunks/index-5yx92e36.js.map +14 -0
  18. package/dist/chunks/index-690bp093.js +95 -0
  19. package/dist/chunks/index-690bp093.js.map +10 -0
  20. package/dist/chunks/index-7fp2hvmg.js +2155 -0
  21. package/dist/chunks/index-7fp2hvmg.js.map +24 -0
  22. package/dist/chunks/index-cnmsajvk.js +1119 -0
  23. package/dist/chunks/index-cnmsajvk.js.map +12 -0
  24. package/dist/chunks/index-fdvgk2sw.js +1310 -0
  25. package/dist/chunks/index-fdvgk2sw.js.map +21 -0
  26. package/dist/chunks/index-gyvps8b9.js +214 -0
  27. package/dist/chunks/index-gyvps8b9.js.map +12 -0
  28. package/dist/chunks/index-jzg4bh99.js +1533 -0
  29. package/dist/chunks/index-jzg4bh99.js.map +21 -0
  30. package/dist/chunks/index-mgw2yvrm.js +3547 -0
  31. package/dist/chunks/index-mgw2yvrm.js.map +25 -0
  32. package/dist/chunks/index-yh76b55h.js +3449 -0
  33. package/dist/chunks/index-yh76b55h.js.map +29 -0
  34. package/dist/collection/index.js +9 -1118
  35. package/dist/collection/index.js.map +3 -6
  36. package/dist/core/api.d.ts +3 -3
  37. package/dist/core/channel-create.d.ts +2 -2
  38. package/dist/core/commands.d.ts +3 -3
  39. package/dist/core/events.d.ts +4 -4
  40. package/dist/core/handles.d.ts +4 -4
  41. package/dist/core/index.d.ts +25 -20
  42. package/dist/core/index.js +68 -10130
  43. package/dist/core/index.js.map +3 -65
  44. package/dist/core/permissions.d.ts +1 -1
  45. package/dist/core/redis-cache.d.ts +1 -1
  46. package/dist/formatters/index.js +41 -110
  47. package/dist/formatters/index.js.map +3 -4
  48. package/dist/handlers/index.js +5 -37
  49. package/dist/handlers/index.js.map +3 -4
  50. package/dist/index.d.ts +21 -21
  51. package/dist/index.js +641 -16325
  52. package/dist/index.js.map +3 -92
  53. package/dist/managers/advanced.d.ts +3 -3
  54. package/dist/managers/application.d.ts +2 -2
  55. package/dist/managers/base.d.ts +1 -1
  56. package/dist/managers/emoji.d.ts +2 -2
  57. package/dist/managers/guild-resources.d.ts +6 -6
  58. package/dist/managers/guild.d.ts +3 -3
  59. package/dist/managers/index.d.ts +4 -8
  60. package/dist/managers/index.js +51 -4060
  61. package/dist/managers/index.js.map +3 -29
  62. package/dist/managers/member.d.ts +2 -2
  63. package/dist/managers/message.d.ts +14 -6
  64. package/dist/managers/role.d.ts +2 -2
  65. package/dist/managers/thread.d.ts +3 -3
  66. package/dist/managers/user.d.ts +7 -4
  67. package/dist/rest/index.d.ts +10 -35
  68. package/dist/rest/index.js +57 -2184
  69. package/dist/rest/index.js.map +3 -18
  70. package/dist/rest/limiter.d.ts +9 -1
  71. package/dist/rest/webhook.d.ts +2 -8
  72. package/dist/sharding/bus.d.ts +2 -2
  73. package/dist/sharding/cluster.d.ts +45 -5
  74. package/dist/sharding/context.d.ts +45 -3
  75. package/dist/sharding/gateway-bot.d.ts +2 -1
  76. package/dist/sharding/health.d.ts +1 -1
  77. package/dist/sharding/identify.d.ts +12 -0
  78. package/dist/sharding/index.d.ts +44 -11
  79. package/dist/sharding/index.js +60 -4620
  80. package/dist/sharding/index.js.map +3 -33
  81. package/dist/sharding/supervisor.d.ts +4 -2
  82. package/dist/structures/audit-log.d.ts +1 -1
  83. package/dist/structures/base.d.ts +6 -6
  84. package/dist/structures/channels.d.ts +1 -1
  85. package/dist/structures/embed.d.ts +1 -1
  86. package/dist/structures/index.d.ts +14 -14
  87. package/dist/structures/index.js +109 -2382
  88. package/dist/structures/index.js.map +3 -16
  89. package/dist/structures/interactions.d.ts +13 -9
  90. package/dist/structures/options.d.ts +1 -1
  91. package/dist/structures/permissions.d.ts +2 -2
  92. package/dist/structures/resources.d.ts +10 -10
  93. package/dist/structures/sticker.d.ts +1 -1
  94. package/dist/types/gateway.d.ts +2 -79
  95. package/dist/types/index.d.ts +0 -6
  96. package/dist/types/index.js +41 -272
  97. package/dist/types/index.js.map +3 -6
  98. package/dist/utils/index.js +23 -209
  99. package/dist/utils/index.js.map +3 -5
  100. package/dist/voice/connection.d.ts +200 -0
  101. package/dist/voice/crypto.d.ts +50 -0
  102. package/dist/voice/dave.d.ts +85 -0
  103. package/dist/voice/effects.d.ts +31 -0
  104. package/dist/voice/emitter.d.ts +14 -0
  105. package/dist/voice/gateway.d.ts +59 -0
  106. package/dist/voice/index.d.ts +25 -228
  107. package/dist/voice/index.js +111 -442
  108. package/dist/voice/index.js.map +3 -4
  109. package/dist/voice/libopus.d.ts +88 -0
  110. package/dist/voice/networking.d.ts +80 -0
  111. package/dist/voice/ogg.d.ts +24 -0
  112. package/dist/voice/opus.d.ts +18 -0
  113. package/dist/voice/player.d.ts +79 -0
  114. package/dist/voice/protocol.d.ts +76 -0
  115. package/dist/voice/receiver.d.ts +59 -0
  116. package/dist/voice/resource.d.ts +102 -0
  117. package/dist/voice/udp.d.ts +40 -0
  118. package/dist/ws/close-codes.d.ts +1 -1
  119. package/dist/ws/index.d.ts +25 -4
  120. package/dist/ws/index.js +47 -1336
  121. package/dist/ws/index.js.map +3 -17
  122. package/dist/ws/protocol.d.ts +1 -1
  123. package/dist/ws/send-budget.d.ts +0 -2
  124. package/dist/ws/state.d.ts +0 -10
  125. package/package.json +19 -16
@@ -0,0 +1,1533 @@
1
+ // @bun
2
+ import {
3
+ Collection2
4
+ } from "./index-cnmsajvk.js";
5
+ import {
6
+ Routes2
7
+ } from "./index-7fp2hvmg.js";
8
+ import {
9
+ User2,
10
+ Guild2,
11
+ GuildMember2,
12
+ Role2,
13
+ Emoji2,
14
+ AutoModerationRule2,
15
+ createChannel2,
16
+ AuditLog2,
17
+ Message2
18
+ } from "./index-57c5n3ms.js";
19
+
20
+ // packages/managers/src/base.ts
21
+ function assignFields(into, from) {
22
+ const target = into;
23
+ const source = from;
24
+ for (const key of Object.keys(source))
25
+ target[key] = source[key];
26
+ return into;
27
+ }
28
+ function splitReason(options) {
29
+ const { reason, ...payload } = options;
30
+ return [payload, reason];
31
+ }
32
+
33
+ class Manager2 {
34
+ cache;
35
+ #bounded;
36
+ constructor(maxSize) {
37
+ this.#bounded = maxSize !== undefined;
38
+ this.cache = new Collection2(null, { maxSize });
39
+ }
40
+ get(id) {
41
+ return this.cache.get(id);
42
+ }
43
+ has(id) {
44
+ return this.cache.has(id);
45
+ }
46
+ #inflight = new Map;
47
+ fetchOnce(id, load, store = (value) => {
48
+ this.set(id, value);
49
+ return value;
50
+ }) {
51
+ const pending = this.#inflight.get(id);
52
+ if (pending)
53
+ return pending.promise;
54
+ const entry = {
55
+ promise: new Promise((resolve) => resolve(load())),
56
+ dirty: false
57
+ };
58
+ this.#inflight.set(id, entry);
59
+ entry.promise = entry.promise.then((value) => {
60
+ this.#inflight.delete(id);
61
+ return entry.dirty ? this.get(id) ?? value : store(value);
62
+ }, (error) => {
63
+ this.#inflight.delete(id);
64
+ throw error;
65
+ });
66
+ return entry.promise;
67
+ }
68
+ #markDirty(id) {
69
+ const pending = this.#inflight.get(id);
70
+ if (pending)
71
+ pending.dirty = true;
72
+ }
73
+ set(id, value) {
74
+ this.#markDirty(id);
75
+ if (this.#bounded)
76
+ this.cache.set(id, value);
77
+ else
78
+ this.cache.setWithoutTTL(id, value);
79
+ return this;
80
+ }
81
+ delete(id) {
82
+ this.#markDirty(id);
83
+ return this.cache.delete(id);
84
+ }
85
+ clear() {
86
+ this.cache.clear();
87
+ }
88
+ get size() {
89
+ return this.cache.size;
90
+ }
91
+ first() {
92
+ return this.cache.first();
93
+ }
94
+ values() {
95
+ return this.cache.array();
96
+ }
97
+ find(predicate) {
98
+ return this.cache.find(predicate);
99
+ }
100
+ [Symbol.iterator]() {
101
+ return this.cache[Symbol.iterator]();
102
+ }
103
+ }
104
+
105
+ class ResourceManager2 extends Manager2 {
106
+ #fetcher;
107
+ #key;
108
+ constructor(fetcher, key, maxSize) {
109
+ super(maxSize);
110
+ if (typeof fetcher !== "function" || typeof key !== "function")
111
+ throw new TypeError("ResourceManager requires fetcher and key functions.");
112
+ this.#fetcher = fetcher;
113
+ this.#key = key;
114
+ }
115
+ async resolve(id) {
116
+ return this.get(id) ?? this.fetch(id);
117
+ }
118
+ fetch(id) {
119
+ return this.fetchOnce(id, () => this.#fetcher(id), (value) => this.upsert(value));
120
+ }
121
+ async fetchMany(ids) {
122
+ return Promise.all([...ids].map((id) => this.resolve(id)));
123
+ }
124
+ upsert(resource) {
125
+ const key = this.#key(resource);
126
+ const existing = this.get(key);
127
+ if (existing !== undefined && existing !== resource && typeof existing === "object" && existing !== null) {
128
+ assignFields(existing, resource);
129
+ this.set(key, existing);
130
+ return existing;
131
+ }
132
+ this.set(key, resource);
133
+ return resource;
134
+ }
135
+ update(resource) {
136
+ return this.upsert(resource);
137
+ }
138
+ }
139
+ // packages/managers/src/message.ts
140
+ function toAttachments(files) {
141
+ return files.map((file) => ("toBuffer" in file) ? { name: file.name, data: file.toBuffer() } : {
142
+ name: file.name,
143
+ data: typeof file.data === "string" ? new TextEncoder().encode(file.data) : file.data,
144
+ contentType: file.contentType
145
+ });
146
+ }
147
+ function assertAllowedMentions(mentions) {
148
+ const parse = mentions.parse ?? [];
149
+ for (const kind of parse)
150
+ if (!["roles", "users", "everyone"].includes(kind))
151
+ throw new TypeError(`allowed_mentions.parse has unknown value "${String(kind)}".`);
152
+ for (const [kind, list] of [
153
+ ["users", mentions.users],
154
+ ["roles", mentions.roles]
155
+ ]) {
156
+ if (list === undefined)
157
+ continue;
158
+ if (!Array.isArray(list) || list.some((id) => typeof id !== "string"))
159
+ throw new TypeError(`allowed_mentions.${kind} must be an array of ID strings.`);
160
+ if (list.length > 100)
161
+ throw new RangeError(`allowed_mentions.${kind} holds at most 100 IDs.`);
162
+ if (list.length > 0 && parse.includes(kind))
163
+ throw new TypeError(`allowed_mentions cannot list ${kind} by ID and also parse "${kind}".`);
164
+ }
165
+ }
166
+ function toRequest2(options, allowedMentions) {
167
+ const { files, ...body } = options;
168
+ if (allowedMentions !== undefined && body.allowed_mentions === undefined)
169
+ body.allowed_mentions = allowedMentions;
170
+ if (body.allowed_mentions)
171
+ assertAllowedMentions(body.allowed_mentions);
172
+ if (!files?.length)
173
+ return { body };
174
+ if (body.attachments === undefined && files.some((f) => f.description))
175
+ body.attachments = files.map((file, id) => file.description ? { id, description: file.description } : { id });
176
+ return {
177
+ body,
178
+ files: toAttachments(files)
179
+ };
180
+ }
181
+
182
+ class MessageManager2 {
183
+ cache;
184
+ #caching;
185
+ #rest;
186
+ #context;
187
+ #channelId;
188
+ #allowedMentions;
189
+ constructor(rest, context, channelId, cache, allowedMentions) {
190
+ if (!channelId)
191
+ throw new TypeError("Channel ID is required.");
192
+ this.#allowedMentions = allowedMentions;
193
+ this.#rest = rest;
194
+ this.#context = context;
195
+ this.#channelId = channelId;
196
+ this.#caching = cache !== undefined;
197
+ this.cache = new Collection2(null, {
198
+ ttl: cache?.ttl,
199
+ maxSize: cache ? cache.maxSize ?? 100 : undefined
200
+ });
201
+ }
202
+ async resolve(messageId) {
203
+ return this.cache.get(messageId) ?? this.fetch(messageId);
204
+ }
205
+ async send(options) {
206
+ const { body, files } = toRequest2(options, this.#allowedMentions);
207
+ const data = await this.#rest.post(Routes2.channelMessages(this.#channelId), body, { files });
208
+ return this.upsert(data);
209
+ }
210
+ #inflight = new Map;
211
+ fetch(messageId) {
212
+ const pending = this.#inflight.get(messageId);
213
+ if (pending)
214
+ return pending.promise;
215
+ const entry = {
216
+ promise: Promise.resolve(null),
217
+ dirty: false
218
+ };
219
+ this.#inflight.set(messageId, entry);
220
+ entry.promise = this.#rest.get(Routes2.message(this.#channelId, messageId)).then((data) => {
221
+ this.#inflight.delete(messageId);
222
+ return entry.dirty ? this.cache.peek(messageId) ?? new Message2(data, this.#context) : this.upsert(data);
223
+ }, (error) => {
224
+ this.#inflight.delete(messageId);
225
+ throw error;
226
+ });
227
+ return entry.promise;
228
+ }
229
+ #markDirty(messageId) {
230
+ const pending = this.#inflight.get(messageId);
231
+ if (pending)
232
+ pending.dirty = true;
233
+ }
234
+ set(messageId, message) {
235
+ this.#markDirty(messageId);
236
+ if (this.#caching)
237
+ this.cache.set(messageId, message);
238
+ return this;
239
+ }
240
+ fetchMany(messageIds) {
241
+ return Promise.all(Array.from(messageIds, (messageId) => this.fetch(messageId)));
242
+ }
243
+ upsert(data) {
244
+ this.#markDirty(data.id);
245
+ const existing = this.cache.peek(data.id);
246
+ const message = new Message2(data, this.#context);
247
+ if (existing) {
248
+ assignFields(existing, message);
249
+ return existing;
250
+ }
251
+ if (this.#caching)
252
+ this.cache.set(message.id, message);
253
+ return message;
254
+ }
255
+ delete(messageId) {
256
+ this.#markDirty(messageId);
257
+ return this.cache.delete(messageId);
258
+ }
259
+ }
260
+
261
+ // packages/managers/src/thread.ts
262
+ class ThreadManager2 {
263
+ #rest;
264
+ #context;
265
+ #channelId;
266
+ #allowedMentions;
267
+ constructor(rest, context, channelId, allowedMentions) {
268
+ if (!channelId)
269
+ throw new TypeError("Channel ID is required.");
270
+ this.#rest = rest;
271
+ this.#context = context;
272
+ this.#channelId = channelId;
273
+ this.#allowedMentions = allowedMentions;
274
+ }
275
+ async createFromMessage(messageId, options) {
276
+ const data = await this.#rest.post(Routes2.messageThread(this.#channelId, messageId), {
277
+ name: options.name,
278
+ auto_archive_duration: options.autoArchiveDuration,
279
+ rate_limit_per_user: options.rateLimitPerUser
280
+ });
281
+ return createChannel2(data, this.#context);
282
+ }
283
+ async create(options) {
284
+ const data = await this.#rest.post(Routes2.channelThreads(this.#channelId), {
285
+ name: options.name,
286
+ type: options.type ?? 12,
287
+ auto_archive_duration: options.autoArchiveDuration,
288
+ rate_limit_per_user: options.rateLimitPerUser,
289
+ invitable: options.invitable
290
+ }, { reason: options.reason });
291
+ return createChannel2(data, this.#context);
292
+ }
293
+ async createForumPost(options) {
294
+ const { message, appliedTags, reason, ...thread } = options;
295
+ const { body: content, files } = toRequest2(message, this.#allowedMentions);
296
+ const data = await this.#rest.post(Routes2.channelThreads(this.#channelId), {
297
+ name: thread.name,
298
+ auto_archive_duration: thread.autoArchiveDuration,
299
+ rate_limit_per_user: thread.rateLimitPerUser,
300
+ applied_tags: appliedTags,
301
+ message: content
302
+ }, { files, reason });
303
+ return createChannel2(data, this.#context);
304
+ }
305
+ async fetchArchived(scope, options = {}) {
306
+ const route = scope === "public" ? Routes2.channelPublicArchivedThreads(this.#channelId) : scope === "private" ? Routes2.channelPrivateArchivedThreads(this.#channelId) : Routes2.channelJoinedPrivateArchivedThreads(this.#channelId);
307
+ const params = new URLSearchParams;
308
+ if (options.before)
309
+ params.set("before", options.before);
310
+ if (options.limit !== undefined)
311
+ params.set("limit", String(Math.min(100, Math.max(1, options.limit))));
312
+ const query = params.toString();
313
+ const page = await this.#rest.get(`${route}${query ? `?${query}` : ""}`);
314
+ return {
315
+ threads: page.threads.map((thread) => createChannel2(thread, this.#context)),
316
+ members: page.members,
317
+ hasMore: page.has_more
318
+ };
319
+ }
320
+ async join(threadId) {
321
+ await this.#rest.put(Routes2.threadMember(threadId, "@me"));
322
+ }
323
+ async leave(threadId) {
324
+ await this.#rest.delete(Routes2.threadMember(threadId, "@me"));
325
+ }
326
+ async addMember(threadId, userId) {
327
+ await this.#rest.put(Routes2.threadMember(threadId, userId));
328
+ }
329
+ async removeMember(threadId, userId) {
330
+ await this.#rest.delete(Routes2.threadMember(threadId, userId));
331
+ }
332
+ async fetchMember(threadId, userId, query = {}) {
333
+ const suffix = query.withMember ? "?with_member=true" : "";
334
+ return this.#rest.get(`${Routes2.threadMember(threadId, userId)}${suffix}`);
335
+ }
336
+ async fetchMembers(threadId, options = {}) {
337
+ const params = new URLSearchParams;
338
+ if (options.withMember)
339
+ params.set("with_member", "true");
340
+ if (options.after)
341
+ params.set("after", options.after);
342
+ if (options.limit !== undefined)
343
+ params.set("limit", String(Math.min(100, Math.max(1, options.limit))));
344
+ const query = params.toString();
345
+ return this.#rest.get(`${Routes2.threadMembers(threadId)}${query ? `?${query}` : ""}`);
346
+ }
347
+ }
348
+
349
+ // packages/managers/src/user.ts
350
+ class UserManager2 extends ResourceManager2 {
351
+ #rest;
352
+ constructor(rest, options = {}) {
353
+ super(async (id) => new User2(await rest.get(Routes2.userById(id))), (user) => user.id, options.maxSize);
354
+ this.#rest = rest;
355
+ }
356
+ async fetchMe() {
357
+ const data = await this.#rest.get("/users/@me");
358
+ return this.upsert(new User2(data));
359
+ }
360
+ async editMe(options) {
361
+ const data = await this.#rest.patch("/users/@me", options);
362
+ return this.upsert(new User2(data));
363
+ }
364
+ async fetchGuilds(options = {}) {
365
+ const params = new URLSearchParams;
366
+ if (options.limit !== undefined)
367
+ params.set("limit", String(Math.min(200, Math.max(1, options.limit))));
368
+ if (options.before)
369
+ params.set("before", options.before);
370
+ if (options.after)
371
+ params.set("after", options.after);
372
+ if (options.withCounts)
373
+ params.set("with_counts", "true");
374
+ const query = params.toString();
375
+ return this.#rest.get(`${Routes2.userGuilds()}${query ? `?${query}` : ""}`);
376
+ }
377
+ async leaveGuild(guildId) {
378
+ await this.#rest.delete(Routes2.currentUserGuild(guildId));
379
+ }
380
+ async createDM(userId) {
381
+ return this.#rest.post("/users/@me/channels", {
382
+ recipient_id: userId
383
+ });
384
+ }
385
+ }
386
+ // packages/managers/src/emoji.ts
387
+ class EmojiManager2 extends Manager2 {
388
+ #rest;
389
+ #guildId;
390
+ constructor(rest, guildId) {
391
+ super();
392
+ this.#rest = rest;
393
+ this.#guildId = guildId;
394
+ }
395
+ fetch(emojiId) {
396
+ return this.fetchOnce(emojiId, async () => new Emoji2(await this.#rest.get(Routes2.guildEmoji(this.#guildId, emojiId))), (emoji) => this.#merge(emojiId, emoji));
397
+ }
398
+ async fetchAll() {
399
+ const data = await this.#rest.get(Routes2.guildEmoji(this.#guildId));
400
+ return data.map((item) => this.upsert(item));
401
+ }
402
+ async create(options) {
403
+ const [payload, reason] = splitReason(options);
404
+ return this.upsert(await this.#rest.post(Routes2.guildEmoji(this.#guildId), payload, { reason }));
405
+ }
406
+ async edit(emojiId, options) {
407
+ const [payload, reason] = splitReason(options);
408
+ return this.upsert(await this.#rest.patch(Routes2.guildEmoji(this.#guildId, emojiId), payload, { reason }));
409
+ }
410
+ async remove(emojiId, reason) {
411
+ await this.#rest.delete(Routes2.guildEmoji(this.#guildId, emojiId), {
412
+ reason
413
+ });
414
+ this.delete(emojiId);
415
+ }
416
+ upsert(data) {
417
+ const key = data.id != null ? data.id : `unicode:${data.name ?? ""}`;
418
+ return this.#merge(key, new Emoji2(data));
419
+ }
420
+ #merge(key, emoji) {
421
+ const existing = this.get(key);
422
+ if (existing) {
423
+ assignFields(existing, emoji);
424
+ return existing;
425
+ }
426
+ this.set(key, emoji);
427
+ return emoji;
428
+ }
429
+ }
430
+
431
+ // packages/managers/src/advanced.ts
432
+ function withQuery(path, query) {
433
+ const params = new URLSearchParams;
434
+ for (const [key, value] of Object.entries(query))
435
+ if (value !== undefined)
436
+ params.set(key, String(value));
437
+ const suffix = params.toString();
438
+ return suffix ? `${path}?${suffix}` : path;
439
+ }
440
+
441
+ class GuildStickerManager2 extends Manager2 {
442
+ #rest;
443
+ guildId;
444
+ constructor(rest, guildId) {
445
+ super();
446
+ this.#rest = rest;
447
+ this.guildId = guildId;
448
+ }
449
+ #store(sticker) {
450
+ this.set(sticker.id, sticker);
451
+ return sticker;
452
+ }
453
+ async fetchAll() {
454
+ const stickers = await this.#rest.get(Routes2.guildSticker(this.guildId));
455
+ this.clear();
456
+ return stickers.map((sticker) => this.#store(sticker));
457
+ }
458
+ async fetch(stickerId) {
459
+ return this.#store(await this.#rest.get(Routes2.guildSticker(this.guildId, stickerId)));
460
+ }
461
+ async create(options) {
462
+ const form = new FormData;
463
+ form.set("name", options.name);
464
+ form.set("description", options.description);
465
+ form.set("tags", options.tags);
466
+ form.set("file", options.file);
467
+ return this.#store(await this.#rest.post(Routes2.guildSticker(this.guildId), form, { reason: options.reason }));
468
+ }
469
+ async edit(stickerId, options) {
470
+ const { reason, ...body } = options;
471
+ return this.#store(await this.#rest.patch(Routes2.guildSticker(this.guildId, stickerId), body, { reason }));
472
+ }
473
+ async remove(stickerId, reason) {
474
+ await this.#rest.delete(Routes2.guildSticker(this.guildId, stickerId), {
475
+ reason
476
+ });
477
+ this.delete(stickerId);
478
+ }
479
+ sync(stickers) {
480
+ this.clear();
481
+ for (const sticker of stickers)
482
+ this.#store(sticker);
483
+ }
484
+ }
485
+
486
+ class GuildSoundboardManager2 extends Manager2 {
487
+ #rest;
488
+ guildId;
489
+ constructor(rest, guildId) {
490
+ super();
491
+ this.#rest = rest;
492
+ this.guildId = guildId;
493
+ }
494
+ #store(sound) {
495
+ this.set(sound.sound_id, sound);
496
+ return sound;
497
+ }
498
+ async fetchAll() {
499
+ const { items } = await this.#rest.get(Routes2.guildSoundboardSound(this.guildId));
500
+ this.clear();
501
+ return items.map((sound) => this.#store(sound));
502
+ }
503
+ async fetch(soundId) {
504
+ return this.#store(await this.#rest.get(Routes2.guildSoundboardSound(this.guildId, soundId)));
505
+ }
506
+ async create(options) {
507
+ if (options.volume !== undefined && (options.volume < 0 || options.volume > 1))
508
+ throw new RangeError("Soundboard volume must be between 0 and 1.");
509
+ return this.#store(await this.#rest.post(Routes2.guildSoundboardSound(this.guildId), {
510
+ name: options.name,
511
+ sound: options.sound,
512
+ volume: options.volume,
513
+ emoji_id: options.emojiId,
514
+ emoji_name: options.emojiName
515
+ }, { reason: options.reason }));
516
+ }
517
+ async edit(soundId, options) {
518
+ return this.#store(await this.#rest.patch(Routes2.guildSoundboardSound(this.guildId, soundId), {
519
+ name: options.name,
520
+ volume: options.volume,
521
+ emoji_id: options.emojiId,
522
+ emoji_name: options.emojiName
523
+ }, { reason: options.reason }));
524
+ }
525
+ async remove(soundId, reason) {
526
+ await this.#rest.delete(Routes2.guildSoundboardSound(this.guildId, soundId), { reason });
527
+ this.delete(soundId);
528
+ }
529
+ }
530
+
531
+ class MonetizationManager2 extends Manager2 {
532
+ #rest;
533
+ applicationId;
534
+ constructor(rest, applicationId) {
535
+ super();
536
+ this.#rest = rest;
537
+ this.applicationId = applicationId;
538
+ }
539
+ fetchSkus() {
540
+ return this.#rest.get(Routes2.applicationSkus(this.applicationId));
541
+ }
542
+ async fetchEntitlements(query = {}) {
543
+ if (query.limit !== undefined && (!Number.isInteger(query.limit) || query.limit < 1 || query.limit > 100))
544
+ throw new RangeError("Entitlement limit must be 1-100.");
545
+ const entitlements = await this.#rest.get(withQuery(Routes2.applicationEntitlement(this.applicationId), {
546
+ user_id: query.userId,
547
+ sku_ids: query.skuIds?.join(","),
548
+ guild_id: query.guildId,
549
+ before: query.before,
550
+ after: query.after,
551
+ limit: query.limit,
552
+ exclude_ended: query.excludeEnded,
553
+ exclude_deleted: query.excludeDeleted
554
+ }));
555
+ for (const entitlement of entitlements)
556
+ this.set(entitlement.id, entitlement);
557
+ return entitlements;
558
+ }
559
+ async fetch(entitlementId) {
560
+ const entitlement = await this.#rest.get(Routes2.applicationEntitlement(this.applicationId, entitlementId));
561
+ this.set(entitlement.id, entitlement);
562
+ return entitlement;
563
+ }
564
+ async consume(entitlementId) {
565
+ await this.#rest.post(Routes2.consumeEntitlement(this.applicationId, entitlementId));
566
+ const cached = this.get(entitlementId);
567
+ if (cached)
568
+ cached.consumed = true;
569
+ }
570
+ async createTestEntitlement(options) {
571
+ const entitlement = await this.#rest.post(Routes2.applicationEntitlement(this.applicationId), {
572
+ sku_id: options.skuId,
573
+ owner_id: options.ownerId,
574
+ owner_type: options.ownerType
575
+ });
576
+ this.set(entitlement.id, entitlement);
577
+ return entitlement;
578
+ }
579
+ async deleteTestEntitlement(entitlementId) {
580
+ await this.#rest.delete(Routes2.applicationEntitlement(this.applicationId, entitlementId));
581
+ this.delete(entitlementId);
582
+ }
583
+ fetchSubscriptions(skuId, query = {}) {
584
+ return this.#rest.get(withQuery(Routes2.skuSubscription(skuId), {
585
+ user_id: query.userId,
586
+ before: query.before,
587
+ after: query.after,
588
+ limit: query.limit
589
+ }));
590
+ }
591
+ fetchSubscription(skuId, subscriptionId) {
592
+ return this.#rest.get(Routes2.skuSubscription(skuId, subscriptionId));
593
+ }
594
+ }
595
+
596
+ class ApplicationEmojiManager2 extends Manager2 {
597
+ #rest;
598
+ applicationId;
599
+ constructor(rest, applicationId) {
600
+ super();
601
+ this.#rest = rest;
602
+ this.applicationId = applicationId;
603
+ }
604
+ #store(emoji) {
605
+ if (emoji.id)
606
+ this.set(emoji.id, emoji);
607
+ return emoji;
608
+ }
609
+ async fetchAll() {
610
+ const { items } = await this.#rest.get(Routes2.applicationEmoji(this.applicationId));
611
+ this.clear();
612
+ return items.map((emoji) => this.#store(emoji));
613
+ }
614
+ async fetch(emojiId) {
615
+ return this.#store(await this.#rest.get(Routes2.applicationEmoji(this.applicationId, emojiId)));
616
+ }
617
+ async create(options) {
618
+ return this.#store(await this.#rest.post(Routes2.applicationEmoji(this.applicationId), options));
619
+ }
620
+ async edit(emojiId, options) {
621
+ return this.#store(await this.#rest.patch(Routes2.applicationEmoji(this.applicationId, emojiId), options));
622
+ }
623
+ async remove(emojiId) {
624
+ await this.#rest.delete(Routes2.applicationEmoji(this.applicationId, emojiId));
625
+ this.delete(emojiId);
626
+ }
627
+ }
628
+
629
+ // packages/managers/src/member.ts
630
+ class GuildMemberManager2 extends ResourceManager2 {
631
+ #rest;
632
+ #context;
633
+ guildId;
634
+ constructor(guildId, rest, context = () => {
635
+ return;
636
+ }, maxSize) {
637
+ super((id) => rest.get(Routes2.guildMember(guildId, id)).then((data) => new GuildMember2({ ...data, guild_id: guildId }, context())), (member) => member.user.id, maxSize);
638
+ this.guildId = guildId;
639
+ this.#rest = rest;
640
+ this.#context = context;
641
+ }
642
+ async search(query, limit = 1) {
643
+ if (!query.trim())
644
+ throw new TypeError("A search query is required.");
645
+ const params = new URLSearchParams({
646
+ query,
647
+ limit: String(Math.min(1000, Math.max(1, limit)))
648
+ });
649
+ const found = await this.#rest.get(`${Routes2.guildMembersSearch(this.guildId)}?${params}`);
650
+ return found.map((data) => {
651
+ return this.upsert(new GuildMember2({ ...data, guild_id: this.guildId }, this.#context()));
652
+ });
653
+ }
654
+ async editMe(options) {
655
+ const [payload, reason] = splitReason(options);
656
+ const data = await this.#rest.patch(Routes2.guildMemberMe(this.guildId), payload, { reason });
657
+ return this.upsert(new GuildMember2({ ...data, guild_id: this.guildId }, this.#context()));
658
+ }
659
+ async kick(userId, reason) {
660
+ await this.#rest.delete(Routes2.guildMember(this.guildId, userId), {
661
+ reason
662
+ });
663
+ this.delete(userId);
664
+ }
665
+ async ban(userId, options = {}) {
666
+ await this.#rest.put(Routes2.guildBan(this.guildId, userId), { delete_message_seconds: options.deleteMessageSeconds }, { reason: options.reason });
667
+ this.delete(userId);
668
+ }
669
+ async unban(userId, reason) {
670
+ await this.#rest.delete(Routes2.guildBan(this.guildId, userId), {
671
+ reason
672
+ });
673
+ }
674
+ async edit(userId, options) {
675
+ const [payload, optionsReason] = splitReason(options);
676
+ const data = await this.#rest.patch(Routes2.guildMember(this.guildId, userId), payload, {
677
+ reason: optionsReason
678
+ });
679
+ return this.upsert(new GuildMember2({ ...data, guild_id: this.guildId }, this.#context()));
680
+ }
681
+ async addRole(userId, roleId, reason) {
682
+ await this.#rest.put(Routes2.guildMemberRole(this.guildId, userId, roleId), undefined, { reason });
683
+ }
684
+ async removeRole(userId, roleId, reason) {
685
+ await this.#rest.delete(Routes2.guildMemberRole(this.guildId, userId, roleId), { reason });
686
+ }
687
+ async timeout(userId, milliseconds, reason) {
688
+ const timeoutDate = milliseconds === null ? null : new Date(Date.now() + milliseconds).toISOString();
689
+ return this.edit(userId, {
690
+ communication_disabled_until: timeoutDate,
691
+ reason
692
+ });
693
+ }
694
+ }
695
+
696
+ // packages/managers/src/role.ts
697
+ class RoleManager2 extends ResourceManager2 {
698
+ #rest;
699
+ guildId;
700
+ constructor(guildId, rest) {
701
+ super((id) => rest.get(Routes2.guildRole(guildId, id)).then((data) => new Role2(data)), (role) => role.id);
702
+ this.guildId = guildId;
703
+ this.#rest = rest;
704
+ }
705
+ async fetchAll() {
706
+ const data = await this.#rest.get(Routes2.guildRoles(this.guildId));
707
+ return data.map((item) => this.upsert(new Role2(item)));
708
+ }
709
+ async create(options) {
710
+ const { reason, ...payload } = options;
711
+ const data = await this.#rest.post(Routes2.guildRoles(this.guildId), rolePayload(payload), { reason });
712
+ return this.#store(data);
713
+ }
714
+ async edit(roleId, options) {
715
+ const { reason, ...payload } = options;
716
+ const data = await this.#rest.patch(Routes2.guildRole(this.guildId, roleId), rolePayload(payload), { reason });
717
+ return this.#store(data);
718
+ }
719
+ #store(data) {
720
+ return this.upsert(new Role2(data));
721
+ }
722
+ async remove(roleId, reason) {
723
+ await this.#rest.delete(Routes2.guildRole(this.guildId, roleId), {
724
+ reason
725
+ });
726
+ this.delete(roleId);
727
+ }
728
+ async setPositions(positions, reason) {
729
+ const data = await this.#rest.patch(Routes2.guildRoles(this.guildId), positions.map(({ id, position }) => ({ id, position })), { reason });
730
+ return data.map((item) => this.upsert(new Role2(item)));
731
+ }
732
+ }
733
+ function rolePayload(options) {
734
+ const { permissions, colors, unicodeEmoji, ...rest } = options;
735
+ return {
736
+ ...rest,
737
+ permissions: permissions !== undefined ? String(permissions) : undefined,
738
+ colors: colors && {
739
+ primary_color: colors.primary,
740
+ secondary_color: colors.secondary ?? null,
741
+ tertiary_color: colors.tertiary ?? null
742
+ },
743
+ unicode_emoji: unicodeEmoji
744
+ };
745
+ }
746
+
747
+ // packages/managers/src/guild-resources.ts
748
+ function withQuery2(path, params) {
749
+ const query = new URLSearchParams;
750
+ for (const [key, value] of Object.entries(params))
751
+ if (value !== undefined)
752
+ query.set(key, String(value));
753
+ const suffix = query.toString();
754
+ return suffix ? `${path}?${suffix}` : path;
755
+ }
756
+
757
+ class GuildBanManager2 extends Manager2 {
758
+ #rest;
759
+ guildId;
760
+ constructor(rest, guildId) {
761
+ super();
762
+ this.#rest = rest;
763
+ this.guildId = guildId;
764
+ }
765
+ async fetch(userId) {
766
+ const ban = await this.#rest.get(Routes2.guildBan(this.guildId, userId));
767
+ this.set(ban.user.id, ban);
768
+ return ban;
769
+ }
770
+ async fetchAll(options = {}) {
771
+ const limit = options.limit === undefined ? undefined : Math.min(1000, Math.max(1, options.limit));
772
+ const bans = await this.#rest.get(withQuery2(Routes2.guildBans(this.guildId), {
773
+ limit,
774
+ before: options.before,
775
+ after: options.after
776
+ }));
777
+ for (const ban of bans)
778
+ this.set(ban.user.id, ban);
779
+ return bans;
780
+ }
781
+ async create(userId, options = {}) {
782
+ await this.#rest.put(Routes2.guildBan(this.guildId, userId), { delete_message_seconds: options.deleteMessageSeconds }, { reason: options.reason });
783
+ }
784
+ async bulk(userIds, options = {}) {
785
+ if (userIds.length < 1 || userIds.length > 200)
786
+ throw new RangeError("Bulk ban takes 1 to 200 user IDs.");
787
+ const result = await this.#rest.post(Routes2.guildBulkBan(this.guildId), {
788
+ user_ids: userIds,
789
+ delete_message_seconds: options.deleteMessageSeconds
790
+ }, { reason: options.reason });
791
+ return {
792
+ banned: result.banned_users ?? [],
793
+ failed: result.failed_users ?? []
794
+ };
795
+ }
796
+ async remove(userId, reason) {
797
+ await this.#rest.delete(Routes2.guildBan(this.guildId, userId), {
798
+ reason
799
+ });
800
+ this.delete(userId);
801
+ }
802
+ }
803
+
804
+ class GuildScheduledEventManager2 extends Manager2 {
805
+ #rest;
806
+ guildId;
807
+ constructor(rest, guildId) {
808
+ super();
809
+ this.#rest = rest;
810
+ this.guildId = guildId;
811
+ }
812
+ #store(event) {
813
+ this.set(event.id, event);
814
+ return event;
815
+ }
816
+ async fetch(eventId, options = {}) {
817
+ return this.#store(await this.#rest.get(withQuery2(Routes2.guildScheduledEvent(this.guildId, eventId), {
818
+ with_user_count: options.withUserCount
819
+ })));
820
+ }
821
+ async fetchAll(options = {}) {
822
+ const events = await this.#rest.get(withQuery2(Routes2.guildScheduledEvents(this.guildId), {
823
+ with_user_count: options.withUserCount
824
+ }));
825
+ return events.map((event) => this.#store(event));
826
+ }
827
+ async create(options) {
828
+ const [payload, optionsReason] = splitReason(options);
829
+ return this.#store(await this.#rest.post(Routes2.guildScheduledEvents(this.guildId), payload, { reason: optionsReason }));
830
+ }
831
+ async edit(eventId, options) {
832
+ const [payload, optionsReason] = splitReason(options);
833
+ return this.#store(await this.#rest.patch(Routes2.guildScheduledEvent(this.guildId, eventId), payload, { reason: optionsReason }));
834
+ }
835
+ async remove(eventId, reason) {
836
+ await this.#rest.delete(Routes2.guildScheduledEvent(this.guildId, eventId), { reason });
837
+ this.delete(eventId);
838
+ }
839
+ async fetchSubscribers(eventId, options = {}) {
840
+ const limit = options.limit === undefined ? undefined : Math.min(100, Math.max(1, options.limit));
841
+ return this.#rest.get(withQuery2(Routes2.guildScheduledEventUsers(this.guildId, eventId), {
842
+ limit,
843
+ with_member: options.withMember,
844
+ before: options.before,
845
+ after: options.after
846
+ }));
847
+ }
848
+ }
849
+
850
+ class StageInstanceManager2 extends Manager2 {
851
+ #rest;
852
+ constructor(rest) {
853
+ super();
854
+ this.#rest = rest;
855
+ }
856
+ #store(stage) {
857
+ this.set(stage.channel_id, stage);
858
+ return stage;
859
+ }
860
+ async create(channelId, options) {
861
+ return this.#store(await this.#rest.post(Routes2.stageInstances(), {
862
+ channel_id: channelId,
863
+ topic: options.topic,
864
+ privacy_level: options.privacyLevel,
865
+ send_start_notification: options.sendStartNotification,
866
+ guild_scheduled_event_id: options.guildScheduledEventId
867
+ }, { reason: options.reason }));
868
+ }
869
+ async fetch(channelId) {
870
+ return this.#store(await this.#rest.get(Routes2.stageInstanceByChannel(channelId)));
871
+ }
872
+ async edit(channelId, options) {
873
+ return this.#store(await this.#rest.patch(Routes2.stageInstanceByChannel(channelId), { topic: options.topic, privacy_level: options.privacyLevel }, { reason: options.reason }));
874
+ }
875
+ async remove(channelId, reason) {
876
+ await this.#rest.delete(Routes2.stageInstanceByChannel(channelId), {
877
+ reason
878
+ });
879
+ this.delete(channelId);
880
+ }
881
+ }
882
+
883
+ class PermissionOverwriteManager2 {
884
+ #rest;
885
+ #current;
886
+ channelId;
887
+ constructor(rest, channelId, current = () => {
888
+ return;
889
+ }) {
890
+ this.#rest = rest;
891
+ this.channelId = channelId;
892
+ this.#current = current;
893
+ }
894
+ async update(overwriteId, changes, options = {}) {
895
+ const overwrites = this.#current() ?? (await this.#rest.get(Routes2.channel(this.channelId))).permission_overwrites ?? [];
896
+ const existing = overwrites.find((entry) => entry.id === overwriteId);
897
+ const type = existing?.type ?? options.type;
898
+ if (type !== 0 && type !== 1)
899
+ throw new TypeError("A new permission overwrite needs a type: 0 for a role, 1 for a member.");
900
+ const touched = (changes.allow ?? 0n) | (changes.deny ?? 0n) | (changes.inherit ?? 0n);
901
+ const allow = BigInt(existing?.allow ?? 0) & ~touched | (changes.allow ?? 0n);
902
+ const deny = BigInt(existing?.deny ?? 0) & ~touched | (changes.deny ?? 0n);
903
+ await this.edit(overwriteId, {
904
+ type,
905
+ allow,
906
+ deny,
907
+ reason: options.reason
908
+ });
909
+ }
910
+ async edit(overwriteId, options) {
911
+ await this.#rest.put(Routes2.channelPermission(this.channelId, overwriteId), {
912
+ type: options.type,
913
+ allow: BigInt(options.allow ?? 0).toString(),
914
+ deny: BigInt(options.deny ?? 0).toString()
915
+ }, { reason: options.reason });
916
+ }
917
+ async remove(overwriteId, reason) {
918
+ await this.#rest.delete(Routes2.channelPermission(this.channelId, overwriteId), { reason });
919
+ }
920
+ }
921
+
922
+ // packages/managers/src/guild.ts
923
+ function withQuery3(path, params) {
924
+ const suffix = params.toString();
925
+ return suffix ? `${path}?${suffix}` : path;
926
+ }
927
+
928
+ class GuildManager2 extends ResourceManager2 {
929
+ #rest;
930
+ #bans = new Map;
931
+ #scheduledEvents = new Map;
932
+ #members = new Map;
933
+ #roles = new Map;
934
+ #emojis = new Map;
935
+ #stickers = new Map;
936
+ #soundboard = new Map;
937
+ #voiceStates = new Map;
938
+ #autoModerationRules = new Map;
939
+ #presences = new Map;
940
+ #invites = new Map;
941
+ #context;
942
+ attachContext(context) {
943
+ this.#context = context;
944
+ }
945
+ #perGuild(map, guildId, create) {
946
+ let manager = map.get(guildId);
947
+ if (!manager)
948
+ map.set(guildId, manager = create());
949
+ return manager;
950
+ }
951
+ #maxMembers;
952
+ constructor(rest, options = {}) {
953
+ super(async (id) => new Guild2(await rest.get(Routes2.guild(id))), (guild) => guild.id);
954
+ this.#rest = rest;
955
+ this.#maxMembers = options.maxMembers;
956
+ }
957
+ bans(guildId) {
958
+ let manager = this.#bans.get(guildId);
959
+ if (!manager)
960
+ this.#bans.set(guildId, manager = new GuildBanManager2(this.#rest, guildId));
961
+ return manager;
962
+ }
963
+ scheduledEvents(guildId) {
964
+ let manager = this.#scheduledEvents.get(guildId);
965
+ if (!manager)
966
+ this.#scheduledEvents.set(guildId, manager = new GuildScheduledEventManager2(this.#rest, guildId));
967
+ return manager;
968
+ }
969
+ members(guildId) {
970
+ let manager = this.#members.get(guildId);
971
+ if (!manager)
972
+ this.#members.set(guildId, manager = new GuildMemberManager2(guildId, this.#rest, () => this.#context, this.#maxMembers));
973
+ return manager;
974
+ }
975
+ roles(guildId) {
976
+ let manager = this.#roles.get(guildId);
977
+ if (!manager)
978
+ this.#roles.set(guildId, manager = new RoleManager2(guildId, this.#rest));
979
+ return manager;
980
+ }
981
+ emojis(guildId) {
982
+ let manager = this.#emojis.get(guildId);
983
+ if (!manager)
984
+ this.#emojis.set(guildId, manager = new EmojiManager2(this.#rest, guildId));
985
+ return manager;
986
+ }
987
+ stickers(guildId) {
988
+ let manager = this.#stickers.get(guildId);
989
+ if (!manager)
990
+ this.#stickers.set(guildId, manager = new GuildStickerManager2(this.#rest, guildId));
991
+ return manager;
992
+ }
993
+ soundboard(guildId) {
994
+ let manager = this.#soundboard.get(guildId);
995
+ if (!manager)
996
+ this.#soundboard.set(guildId, manager = new GuildSoundboardManager2(this.#rest, guildId));
997
+ return manager;
998
+ }
999
+ voiceStates(guildId) {
1000
+ return this.#perGuild(this.#voiceStates, guildId, () => new Manager2);
1001
+ }
1002
+ presences(guildId) {
1003
+ return this.#perGuild(this.#presences, guildId, () => new Manager2);
1004
+ }
1005
+ autoModerationRules(guildId) {
1006
+ return this.#perGuild(this.#autoModerationRules, guildId, () => new Manager2);
1007
+ }
1008
+ invites(guildId) {
1009
+ return this.#perGuild(this.#invites, guildId, () => new Manager2);
1010
+ }
1011
+ patch(data) {
1012
+ const guild = new Guild2(data);
1013
+ const existing = this.get(guild.id);
1014
+ if (!existing)
1015
+ return this.upsert(guild);
1016
+ const from = guild;
1017
+ const into = existing;
1018
+ for (const key of Object.keys(from)) {
1019
+ const value = from[key];
1020
+ if (value !== undefined)
1021
+ into[key] = value;
1022
+ }
1023
+ this.set(existing.id, existing);
1024
+ return existing;
1025
+ }
1026
+ delete(id) {
1027
+ this.#bans.delete(id);
1028
+ this.#scheduledEvents.delete(id);
1029
+ this.#members.delete(id);
1030
+ this.#roles.delete(id);
1031
+ this.#emojis.delete(id);
1032
+ this.#stickers.delete(id);
1033
+ this.#soundboard.delete(id);
1034
+ this.#voiceStates.delete(id);
1035
+ this.#presences.delete(id);
1036
+ this.#autoModerationRules.delete(id);
1037
+ this.#invites.delete(id);
1038
+ return super.delete(id);
1039
+ }
1040
+ async create(options) {
1041
+ const data = await this.#rest.post("/guilds", options);
1042
+ return this.upsert(new Guild2(data));
1043
+ }
1044
+ async edit(id, options) {
1045
+ const [payload, reason] = splitReason(options);
1046
+ const data = await this.#rest.patch(Routes2.guild(id), payload, { reason });
1047
+ return this.upsert(new Guild2(data));
1048
+ }
1049
+ async remove(id) {
1050
+ await this.#rest.delete(Routes2.guild(id));
1051
+ }
1052
+ async fetchPreview(id) {
1053
+ return this.#rest.get(Routes2.guildPreview(id));
1054
+ }
1055
+ async fetchWelcomeScreen(id) {
1056
+ return this.#rest.get(Routes2.guildWelcomeScreen(id));
1057
+ }
1058
+ async editWelcomeScreen(id, options) {
1059
+ const { reason, welcomeChannels, ...rest } = options;
1060
+ return this.#rest.patch(Routes2.guildWelcomeScreen(id), { ...rest, welcome_channels: welcomeChannels }, { reason });
1061
+ }
1062
+ async fetchOnboarding(id) {
1063
+ return this.#rest.get(Routes2.guildOnboarding(id));
1064
+ }
1065
+ async editOnboarding(id, options) {
1066
+ const { reason, defaultChannelIds, ...rest } = options;
1067
+ return this.#rest.put(Routes2.guildOnboarding(id), { ...rest, default_channel_ids: defaultChannelIds }, { reason });
1068
+ }
1069
+ async editVoiceState(id, userId, options) {
1070
+ await this.#rest.patch(Routes2.guildVoiceState(id, userId), {
1071
+ channel_id: options.channelId,
1072
+ suppress: options.suppress,
1073
+ request_to_speak_timestamp: options.requestToSpeakTimestamp
1074
+ });
1075
+ }
1076
+ async removeIntegration(id, integrationId, reason) {
1077
+ await this.#rest.delete(Routes2.guildIntegration(id, integrationId), {
1078
+ reason
1079
+ });
1080
+ }
1081
+ async fetchActiveThreads(id) {
1082
+ return this.#rest.get(Routes2.guildActiveThreads(id));
1083
+ }
1084
+ async fetchWebhooks(id) {
1085
+ return this.#rest.get(Routes2.guildWebhooks(id));
1086
+ }
1087
+ async fetchInvites(id) {
1088
+ return this.#rest.get(Routes2.guildInvites(id));
1089
+ }
1090
+ async fetchAuditLog(guildId, options = {}) {
1091
+ const params = new URLSearchParams;
1092
+ if (options.userId)
1093
+ params.set("user_id", options.userId);
1094
+ if (options.actionType !== undefined)
1095
+ params.set("action_type", String(options.actionType));
1096
+ if (options.before)
1097
+ params.set("before", options.before);
1098
+ if (options.after)
1099
+ params.set("after", options.after);
1100
+ if (options.limit !== undefined)
1101
+ params.set("limit", String(Math.min(100, Math.max(1, options.limit))));
1102
+ return this.#rest.get(withQuery3(Routes2.guildAuditLog(guildId), params));
1103
+ }
1104
+ async fetchAuditLogEntries(guildId, options = {}) {
1105
+ return new AuditLog2(await this.fetchAuditLog(guildId, options));
1106
+ }
1107
+ async fetchMembers(guildId, options = {}) {
1108
+ const params = new URLSearchParams;
1109
+ if (options.limit !== undefined)
1110
+ params.set("limit", String(Math.min(1000, Math.max(1, options.limit))));
1111
+ if (options.after)
1112
+ params.set("after", options.after);
1113
+ return this.#rest.get(withQuery3(Routes2.guildMembers(guildId), params));
1114
+ }
1115
+ async fetchAutoModerationRules(guildId) {
1116
+ const rules = await this.#rest.get(Routes2.guildAutoModerationRules(guildId));
1117
+ return rules.map((r) => new AutoModerationRule2(r));
1118
+ }
1119
+ async fetchAutoModerationRule(guildId, ruleId) {
1120
+ const rule = await this.#rest.get(Routes2.guildAutoModerationRule(guildId, ruleId));
1121
+ return new AutoModerationRule2(rule);
1122
+ }
1123
+ async createAutoModerationRule(guildId, options) {
1124
+ const [payload, reason] = splitReason(options);
1125
+ const rule = await this.#rest.post(Routes2.guildAutoModerationRules(guildId), payload, { reason });
1126
+ return new AutoModerationRule2(rule);
1127
+ }
1128
+ async editAutoModerationRule(guildId, ruleId, options) {
1129
+ const [payload, reason] = splitReason(options);
1130
+ const rule = await this.#rest.patch(Routes2.guildAutoModerationRule(guildId, ruleId), payload, { reason });
1131
+ return new AutoModerationRule2(rule);
1132
+ }
1133
+ async deleteAutoModerationRule(guildId, ruleId, reason) {
1134
+ await this.#rest.delete(Routes2.guildAutoModerationRule(guildId, ruleId), { reason });
1135
+ }
1136
+ }
1137
+ var AuditLogEvent2 = {
1138
+ GuildUpdate: 1,
1139
+ ChannelCreate: 10,
1140
+ ChannelUpdate: 11,
1141
+ ChannelDelete: 12,
1142
+ ChannelOverwriteCreate: 13,
1143
+ ChannelOverwriteUpdate: 14,
1144
+ ChannelOverwriteDelete: 15,
1145
+ MemberKick: 20,
1146
+ MemberPrune: 21,
1147
+ MemberBanAdd: 22,
1148
+ MemberBanRemove: 23,
1149
+ MemberUpdate: 24,
1150
+ MemberRoleUpdate: 25,
1151
+ MemberMove: 26,
1152
+ MemberDisconnect: 27,
1153
+ BotAdd: 28,
1154
+ RoleCreate: 30,
1155
+ RoleUpdate: 31,
1156
+ RoleDelete: 32,
1157
+ InviteCreate: 40,
1158
+ InviteUpdate: 41,
1159
+ InviteDelete: 42,
1160
+ WebhookCreate: 50,
1161
+ WebhookUpdate: 51,
1162
+ WebhookDelete: 52,
1163
+ EmojiCreate: 60,
1164
+ EmojiUpdate: 61,
1165
+ EmojiDelete: 62,
1166
+ MessageDelete: 72,
1167
+ MessageBulkDelete: 73,
1168
+ MessagePin: 74,
1169
+ MessageUnpin: 75,
1170
+ IntegrationCreate: 80,
1171
+ IntegrationUpdate: 81,
1172
+ IntegrationDelete: 82,
1173
+ StageInstanceCreate: 83,
1174
+ StageInstanceUpdate: 84,
1175
+ StageInstanceDelete: 85,
1176
+ StickerCreate: 90,
1177
+ StickerUpdate: 91,
1178
+ StickerDelete: 92,
1179
+ ScheduledEventCreate: 100,
1180
+ ScheduledEventUpdate: 101,
1181
+ ScheduledEventDelete: 102,
1182
+ ThreadCreate: 110,
1183
+ ThreadUpdate: 111,
1184
+ ThreadDelete: 112,
1185
+ AutoModerationRuleCreate: 140,
1186
+ AutoModerationRuleUpdate: 141,
1187
+ AutoModerationRuleDelete: 142,
1188
+ AutoModerationBlockMessage: 143
1189
+ };
1190
+ // packages/managers/src/application.ts
1191
+ function commandPayload(command) {
1192
+ return "toJSON" in command && typeof command.toJSON === "function" ? command.toJSON() : command;
1193
+ }
1194
+
1195
+ class ApplicationCommandManager2 {
1196
+ #rest;
1197
+ #applicationId;
1198
+ constructor(rest, applicationId) {
1199
+ this.#rest = rest;
1200
+ this.#applicationId = applicationId;
1201
+ }
1202
+ fetch() {
1203
+ return this.#rest.get(Routes2.applicationCommands(this.#applicationId));
1204
+ }
1205
+ create(data) {
1206
+ return this.#rest.post(Routes2.applicationCommands(this.#applicationId), commandPayload(data));
1207
+ }
1208
+ set(commands) {
1209
+ return this.#rest.put(Routes2.applicationCommands(this.#applicationId), commands.map(commandPayload));
1210
+ }
1211
+ edit(commandId, data) {
1212
+ return this.#rest.patch(Routes2.applicationCommand(this.#applicationId, commandId), commandPayload(data));
1213
+ }
1214
+ async delete(commandId) {
1215
+ await this.#rest.delete(Routes2.applicationCommand(this.#applicationId, commandId));
1216
+ }
1217
+ fetchGuild(guildId) {
1218
+ return this.#rest.get(Routes2.guildApplicationCommands(this.#applicationId, guildId));
1219
+ }
1220
+ createGuild(guildId, data) {
1221
+ return this.#rest.post(Routes2.guildApplicationCommands(this.#applicationId, guildId), commandPayload(data));
1222
+ }
1223
+ setGuild(guildId, commands) {
1224
+ return this.#rest.put(Routes2.guildApplicationCommands(this.#applicationId, guildId), commands.map(commandPayload));
1225
+ }
1226
+ editGuild(guildId, commandId, data) {
1227
+ return this.#rest.patch(Routes2.guildApplicationCommand(this.#applicationId, guildId, commandId), commandPayload(data));
1228
+ }
1229
+ async deleteGuild(guildId, commandId) {
1230
+ await this.#rest.delete(Routes2.guildApplicationCommand(this.#applicationId, guildId, commandId));
1231
+ }
1232
+ }
1233
+
1234
+ // packages/managers/src/index.ts
1235
+ var BULK_DELETE_MAX_AGE_MS = 14 * 24 * 60 * 60000;
1236
+ function snowflakeTime(id) {
1237
+ return Number((BigInt(id) >> 22n) + 1420070400000n);
1238
+ }
1239
+
1240
+ class ChannelManager2 extends Manager2 {
1241
+ #rest;
1242
+ #context;
1243
+ #messageManagers = new Map;
1244
+ #messageCache;
1245
+ #allowedMentions;
1246
+ constructor(rest, options = {}) {
1247
+ super();
1248
+ this.#rest = rest;
1249
+ this.#messageCache = options.messageCache;
1250
+ this.#allowedMentions = options.allowedMentions;
1251
+ this.#context = {
1252
+ sendMessage: (channelId, options) => this.send(channelId, options),
1253
+ editMessage: (channelId, messageId, options) => this.editMessage(channelId, messageId, options),
1254
+ deleteMessage: (channelId, messageId, reason) => this.deleteMessage(channelId, messageId, reason),
1255
+ crosspostMessage: (channelId, messageId) => this.crosspostMessage(channelId, messageId),
1256
+ editChannel: (channelId, options) => this.edit(channelId, options),
1257
+ deleteChannel: (channelId, reason) => this.remove(channelId, reason),
1258
+ addReaction: (channelId, messageId, emoji) => this.addReaction(channelId, messageId, emoji),
1259
+ removeOwnReaction: (channelId, messageId, emoji) => this.removeOwnReaction(channelId, messageId, emoji),
1260
+ removeReaction: (channelId, messageId, emoji, userId) => this.removeReaction(channelId, messageId, emoji, userId),
1261
+ removeAllReactions: (channelId, messageId) => this.removeAllReactions(channelId, messageId),
1262
+ pinMessage: (channelId, messageId, reason) => this.pinMessage(channelId, messageId, reason),
1263
+ unpinMessage: (channelId, messageId, reason) => this.unpinMessage(channelId, messageId, reason)
1264
+ };
1265
+ }
1266
+ messages(channelId) {
1267
+ let manager = this.#messageManagers.get(channelId);
1268
+ if (!manager) {
1269
+ manager = new MessageManager2(this.#rest, this.#context, channelId, this.#messageCache, this.#allowedMentions);
1270
+ this.#messageManagers.set(channelId, manager);
1271
+ }
1272
+ return manager;
1273
+ }
1274
+ permissionOverwrites(channelId) {
1275
+ return new PermissionOverwriteManager2(this.#rest, channelId, () => {
1276
+ const channel = this.get(channelId);
1277
+ return channel && !channel.partial ? channel.permissionOverwrites : undefined;
1278
+ });
1279
+ }
1280
+ threads(channelId) {
1281
+ return new ThreadManager2(this.#rest, this.#context, channelId, this.#allowedMentions);
1282
+ }
1283
+ fetch(channelId) {
1284
+ return this.fetchOnce(channelId, async () => createChannel2(await this.#rest.get(Routes2.channel(channelId)), this.#context), (channel) => this.#merge(channel));
1285
+ }
1286
+ async resolve(channelId) {
1287
+ return this.get(channelId) ?? this.fetch(channelId);
1288
+ }
1289
+ upsert(data) {
1290
+ return this.#merge(createChannel2(data, this.#context));
1291
+ }
1292
+ #merge(channel) {
1293
+ const existing = this.get(channel.id);
1294
+ if (existing && existing.type === channel.type) {
1295
+ assignFields(existing, channel);
1296
+ this.set(existing.id, existing);
1297
+ return existing;
1298
+ }
1299
+ this.set(channel.id, channel);
1300
+ return channel;
1301
+ }
1302
+ update(channel) {
1303
+ return this.set(channel.id, channel);
1304
+ }
1305
+ deleteGuildChannels(guildId) {
1306
+ const ids = [];
1307
+ this.cache.forEach((channel, id) => {
1308
+ if (channel.guildId === guildId)
1309
+ ids.push(id);
1310
+ });
1311
+ let removed = 0;
1312
+ for (const id of ids)
1313
+ if (this.delete(id))
1314
+ removed++;
1315
+ return removed;
1316
+ }
1317
+ async endPoll(channelId, messageId) {
1318
+ return this.messages(channelId).upsert(await this.#rest.post(Routes2.pollExpire(channelId, messageId)));
1319
+ }
1320
+ async fetchPollVoters(channelId, messageId, answerId, options = {}) {
1321
+ if (options.limit !== undefined && (!Number.isInteger(options.limit) || options.limit < 1 || options.limit > 100))
1322
+ throw new RangeError("Poll voter limit must be 1-100.");
1323
+ const params = new URLSearchParams;
1324
+ if (options.after)
1325
+ params.set("after", options.after);
1326
+ if (options.limit !== undefined)
1327
+ params.set("limit", String(options.limit));
1328
+ const suffix = params.toString();
1329
+ const { users } = await this.#rest.get(`${Routes2.pollAnswerVoters(channelId, messageId, answerId)}${suffix ? `?${suffix}` : ""}`);
1330
+ return users.map((user) => new User2(user));
1331
+ }
1332
+ async sendSoundboardSound(channelId, options) {
1333
+ await this.#rest.post(Routes2.sendSoundboardSound(channelId), {
1334
+ sound_id: options.soundId,
1335
+ source_guild_id: options.sourceGuildId
1336
+ });
1337
+ }
1338
+ cachedMessages(channelId) {
1339
+ return this.#messageManagers.get(channelId);
1340
+ }
1341
+ async create(guildId, options) {
1342
+ const [payload, reason] = splitReason(options);
1343
+ return this.upsert(await this.#rest.post(Routes2.guildChannels(guildId), payload, { reason }));
1344
+ }
1345
+ async edit(channelId, options) {
1346
+ const [payload, reason] = splitReason(options);
1347
+ return this.upsert(await this.#rest.patch(Routes2.channel(channelId), payload, { reason }));
1348
+ }
1349
+ async remove(channelId, reason) {
1350
+ await this.#rest.delete(Routes2.channel(channelId), { reason });
1351
+ this.delete(channelId);
1352
+ }
1353
+ delete(channelId) {
1354
+ this.#messageManagers.delete(channelId);
1355
+ return super.delete(channelId);
1356
+ }
1357
+ send(channelId, options) {
1358
+ return this.messages(channelId).send(options);
1359
+ }
1360
+ async fetchMessage(channelId, messageId, options = {}) {
1361
+ return this.messages(channelId).fetch(messageId);
1362
+ }
1363
+ fetchMessages(channelId, query) {
1364
+ if (isMessageQuery(query)) {
1365
+ const params = new URLSearchParams;
1366
+ if (query.before)
1367
+ params.set("before", query.before);
1368
+ if (query.after)
1369
+ params.set("after", query.after);
1370
+ if (query.around)
1371
+ params.set("around", query.around);
1372
+ if (query.limit !== undefined)
1373
+ params.set("limit", String(query.limit));
1374
+ const suffix = params.toString();
1375
+ return this.#rest.get(`${Routes2.channelMessages(channelId)}${suffix ? `?${suffix}` : ""}`).then((data) => data.map((item) => this.messages(channelId).upsert(item)));
1376
+ }
1377
+ return this.messages(channelId).fetchMany(query);
1378
+ }
1379
+ upsertMessage(data) {
1380
+ return this.messages(data.channel_id).upsert(data);
1381
+ }
1382
+ async editMessage(channelId, messageId, options) {
1383
+ const { body, files } = toRequest2(options, this.#allowedMentions);
1384
+ return this.messages(channelId).upsert(await this.#rest.patch(Routes2.message(channelId, messageId), body, { files }));
1385
+ }
1386
+ async deleteMessage(channelId, messageId, reason) {
1387
+ await this.#rest.delete(Routes2.message(channelId, messageId), {
1388
+ reason
1389
+ });
1390
+ this.messages(channelId).delete(messageId);
1391
+ }
1392
+ deleteCachedMessage(channelId, messageId) {
1393
+ return this.messages(channelId).delete(messageId);
1394
+ }
1395
+ async crosspostMessage(channelId, messageId) {
1396
+ return this.messages(channelId).upsert(await this.#rest.post(Routes2.crosspostMessage(channelId, messageId)));
1397
+ }
1398
+ async bulkDeleteMessages(channelId, messageIds, reason) {
1399
+ const ids = [...new Set(messageIds)];
1400
+ if (ids.length < 1 || ids.length > 100)
1401
+ throw new RangeError("bulkDelete requires between 1 and 100 message IDs.");
1402
+ if (ids.length === 1)
1403
+ return this.deleteMessage(channelId, ids[0], reason);
1404
+ const cutoff = Date.now() - BULK_DELETE_MAX_AGE_MS;
1405
+ const tooOld = ids.filter((id) => snowflakeTime(id) < cutoff);
1406
+ if (tooOld.length)
1407
+ throw new RangeError(`bulkDelete cannot delete messages older than 14 days: ${tooOld.join(", ")}`);
1408
+ await this.#rest.post(Routes2.channelBulkDelete(channelId), { messages: ids }, { reason });
1409
+ for (const id of ids)
1410
+ this.messages(channelId).delete(id);
1411
+ }
1412
+ async* iterateMessages(channelId, options = {}) {
1413
+ let before = options.before;
1414
+ let remaining = options.limit ?? Infinity;
1415
+ while (remaining > 0) {
1416
+ const page = await this.fetchMessages(channelId, {
1417
+ before,
1418
+ limit: Math.min(100, remaining)
1419
+ });
1420
+ for (const message of page)
1421
+ yield message;
1422
+ remaining -= page.length;
1423
+ if (page.length < 100)
1424
+ return;
1425
+ before = page.at(-1).id;
1426
+ }
1427
+ }
1428
+ async addReaction(channelId, messageId, emoji) {
1429
+ await this.#rest.put(Routes2.messageReactionMe(channelId, messageId, emoji));
1430
+ }
1431
+ async fetchReactions(channelId, messageId, emoji, options = {}) {
1432
+ const params = new URLSearchParams;
1433
+ if (options.limit !== undefined)
1434
+ params.set("limit", String(options.limit));
1435
+ if (options.after)
1436
+ params.set("after", options.after);
1437
+ const suffix = params.toString();
1438
+ const data = await this.#rest.get(`${Routes2.messageReactions(channelId, messageId, emoji)}${suffix ? `?${suffix}` : ""}`);
1439
+ return data.map((user) => new User2(user));
1440
+ }
1441
+ async removeOwnReaction(channelId, messageId, emoji) {
1442
+ await this.#rest.delete(Routes2.messageReactionMe(channelId, messageId, emoji));
1443
+ }
1444
+ async removeReaction(channelId, messageId, emoji, userId) {
1445
+ await this.#rest.delete(Routes2.messageReactionUser(channelId, messageId, emoji, userId));
1446
+ }
1447
+ async removeAllReactions(channelId, messageId) {
1448
+ await this.#rest.delete(Routes2.messageReactionsAll(channelId, messageId));
1449
+ }
1450
+ async fetchPinnedMessages(channelId) {
1451
+ const data = await this.#rest.get(Routes2.channelMessagesPins(channelId));
1452
+ return data.items.map((item) => this.messages(channelId).upsert(item.message));
1453
+ }
1454
+ async fetchPins(channelId, options = {}) {
1455
+ const params = new URLSearchParams;
1456
+ if (options.before)
1457
+ params.set("before", options.before);
1458
+ if (options.limit !== undefined)
1459
+ params.set("limit", String(Math.min(50, Math.max(1, options.limit))));
1460
+ const query = params.toString();
1461
+ const data = await this.#rest.get(`${Routes2.channelMessagesPins(channelId)}${query ? `?${query}` : ""}`);
1462
+ return {
1463
+ messages: data.items.map((item) => this.messages(channelId).upsert(item.message)),
1464
+ hasMore: data.has_more
1465
+ };
1466
+ }
1467
+ async triggerTyping(channelId) {
1468
+ await this.#rest.post(Routes2.channelTyping(channelId));
1469
+ }
1470
+ async createForumTag(channelId, tag, reason) {
1471
+ const tags = await this.#forumTags(channelId);
1472
+ return this.#saveForumTags(channelId, [...tags, tag], reason);
1473
+ }
1474
+ async editForumTag(channelId, tagId, changes, reason) {
1475
+ const tags = await this.#forumTags(channelId);
1476
+ if (!tags.some((tag) => tag.id === tagId))
1477
+ throw new Error(`Channel ${channelId} has no tag ${tagId}.`);
1478
+ return this.#saveForumTags(channelId, tags.map((tag) => tag.id === tagId ? { ...tag, ...changes } : tag), reason);
1479
+ }
1480
+ async removeForumTag(channelId, tagId, reason) {
1481
+ const tags = await this.#forumTags(channelId);
1482
+ if (!tags.some((tag) => tag.id === tagId))
1483
+ throw new Error(`Channel ${channelId} has no tag ${tagId}.`);
1484
+ return this.#saveForumTags(channelId, tags.filter((tag) => tag.id !== tagId), reason);
1485
+ }
1486
+ async#forumTags(channelId) {
1487
+ const channel = await this.#rest.get(Routes2.channel(channelId));
1488
+ return channel.available_tags ?? [];
1489
+ }
1490
+ async#saveForumTags(channelId, tags, reason) {
1491
+ const updated = await this.#rest.patch(Routes2.channel(channelId), { available_tags: tags }, { reason });
1492
+ return updated.available_tags ?? [];
1493
+ }
1494
+ async pinMessage(channelId, messageId, reason) {
1495
+ await this.#rest.put(Routes2.channelMessagesPin(channelId, messageId), undefined, { reason });
1496
+ }
1497
+ async unpinMessage(channelId, messageId, reason) {
1498
+ await this.#rest.delete(Routes2.channelMessagesPin(channelId, messageId), { reason });
1499
+ }
1500
+ async createWebhook(channelId, options) {
1501
+ const [payload, reason] = splitReason(options);
1502
+ return this.#rest.post(Routes2.channelWebhooks(channelId), payload, {
1503
+ reason
1504
+ });
1505
+ }
1506
+ createThreadFromMessage(channelId, messageId, options) {
1507
+ return this.threads(channelId).createFromMessage(messageId, options);
1508
+ }
1509
+ async fetchPage(channelId, options = {}) {
1510
+ const limit = Math.min(100, Math.max(1, options.limit ?? 50));
1511
+ const messages = await this.fetchMessages(channelId, {
1512
+ ...options,
1513
+ limit
1514
+ });
1515
+ return {
1516
+ messages,
1517
+ before: messages[0]?.id,
1518
+ after: messages[messages.length - 1]?.id,
1519
+ hasMore: messages.length === limit
1520
+ };
1521
+ }
1522
+ clear() {
1523
+ this.#messageManagers.clear();
1524
+ super.clear();
1525
+ }
1526
+ }
1527
+ function isMessageQuery(value) {
1528
+ return typeof value === "object" && value !== null && !(Symbol.iterator in value);
1529
+ }
1530
+
1531
+ export { Manager2, ResourceManager2, toRequest2, MessageManager2, ThreadManager2, UserManager2, EmojiManager2, GuildStickerManager2, GuildSoundboardManager2, MonetizationManager2, ApplicationEmojiManager2, GuildMemberManager2, RoleManager2, GuildBanManager2, GuildScheduledEventManager2, StageInstanceManager2, PermissionOverwriteManager2, GuildManager2, AuditLogEvent2, ApplicationCommandManager2, ChannelManager2 };
1532
+
1533
+ //# debugId=594E37102F1B43CE64756E2164756E21