lunibee 0.1.4 → 0.1.6

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 (42) hide show
  1. package/README.md +12 -23
  2. package/dist/builders/components.d.ts +108 -0
  3. package/dist/builders/index.d.ts +1 -1
  4. package/dist/builders/index.js +178 -2
  5. package/dist/builders/index.js.map +3 -3
  6. package/dist/collection/index.d.ts +6 -0
  7. package/dist/collection/index.js +33 -2
  8. package/dist/collection/index.js.map +4 -4
  9. package/dist/core/events.d.ts +67 -3
  10. package/dist/core/index.d.ts +120 -90
  11. package/dist/core/index.js +816 -1021
  12. package/dist/core/index.js.map +20 -21
  13. package/dist/formatters/index.js.map +1 -1
  14. package/dist/index.d.ts +5 -4
  15. package/dist/index.js +2215 -1392
  16. package/dist/index.js.map +29 -26
  17. package/dist/managers/guild.d.ts +30 -0
  18. package/dist/managers/index.d.ts +56 -75
  19. package/dist/managers/index.js +339 -48
  20. package/dist/managers/index.js.map +16 -12
  21. package/dist/managers/message.d.ts +7 -12
  22. package/dist/managers/user.d.ts +20 -0
  23. package/dist/rest/index.d.ts +83 -1
  24. package/dist/rest/index.js +48 -8
  25. package/dist/rest/index.js.map +4 -4
  26. package/dist/rest/routes.d.ts +4 -1
  27. package/dist/sharding/index.js +4 -1
  28. package/dist/sharding/index.js.map +4 -4
  29. package/dist/structures/base.d.ts +99 -48
  30. package/dist/structures/embed.d.ts +65 -0
  31. package/dist/structures/index.d.ts +45 -25
  32. package/dist/structures/index.js +569 -36
  33. package/dist/structures/index.js.map +10 -8
  34. package/dist/structures/interactions.d.ts +72 -17
  35. package/dist/structures/resources.d.ts +9 -5
  36. package/dist/types/index.d.ts +530 -85
  37. package/dist/types/index.js +71 -1
  38. package/dist/types/index.js.map +3 -3
  39. package/dist/voice/index.js.map +1 -1
  40. package/dist/ws/index.js +4 -1
  41. package/dist/ws/index.js.map +4 -4
  42. package/package.json +15 -15
@@ -123,6 +123,28 @@ class Collection extends Map {
123
123
  entry = [item[0], item[1]];
124
124
  return entry;
125
125
  }
126
+ union(other) {
127
+ const result = this.clone();
128
+ for (const [key, value] of other)
129
+ result.set(key, value);
130
+ return result;
131
+ }
132
+ intersection(other) {
133
+ const result = new Collection;
134
+ for (const [key, value] of this) {
135
+ if (other.has(key))
136
+ result.set(key, value);
137
+ }
138
+ return result;
139
+ }
140
+ difference(other) {
141
+ const result = new Collection;
142
+ for (const [key, value] of this) {
143
+ if (!other.has(key))
144
+ result.set(key, value);
145
+ }
146
+ return result;
147
+ }
126
148
  }
127
149
 
128
150
  // packages/managers/src/base.ts
@@ -191,11 +213,27 @@ class ResourceManager extends Manager {
191
213
  return this.upsert(resource);
192
214
  }
193
215
  }
216
+ // packages/rest/package.json
217
+ var package_default = {
218
+ name: "@lunibee/rest",
219
+ version: "0.1.6",
220
+ type: "module",
221
+ module: "./src/index.ts",
222
+ types: "./src/index.ts",
223
+ exports: {
224
+ ".": "./src/index.ts"
225
+ }
226
+ };
227
+
194
228
  // packages/rest/src/routes.ts
195
229
  var Routes = {
196
230
  user: () => "/users/@me",
197
231
  userById: (userId) => `/users/${snowflake(userId, "User ID")}`,
198
232
  guild: (guildId) => `/guilds/${snowflake(guildId, "Guild ID")}`,
233
+ guildPreview: (guildId) => `/guilds/${snowflake(guildId, "Guild ID")}/preview`,
234
+ guildActiveThreads: (guildId) => `/guilds/${snowflake(guildId, "Guild ID")}/threads/active`,
235
+ guildWebhooks: (guildId) => `/guilds/${snowflake(guildId, "Guild ID")}/webhooks`,
236
+ guildInvites: (guildId) => `/guilds/${snowflake(guildId, "Guild ID")}/invites`,
199
237
  guildChannels: (guildId) => `/guilds/${snowflake(guildId, "Guild ID")}/channels`,
200
238
  guildMember: (guildId, userId) => `/guilds/${snowflake(guildId, "Guild ID")}/members/${snowflake(userId, "User ID")}`,
201
239
  guildRoles: (guildId) => `/guilds/${snowflake(guildId, "Guild ID")}/roles`,
@@ -223,7 +261,6 @@ var Routes = {
223
261
  guildApplicationCommand: (applicationId, guildId, commandId) => `/applications/${snowflake(applicationId, "Application ID")}/guilds/${snowflake(guildId, "Guild ID")}/commands/${snowflake(commandId, "Command ID")}`,
224
262
  interactionCallback: (interactionId, token) => `/interactions/${snowflake(interactionId, "Interaction ID")}/${encodeURIComponent(token)}/callback`,
225
263
  interactionOriginalResponse: (applicationId, token) => `/webhooks/${snowflake(applicationId, "Application ID")}/${encodeURIComponent(token)}/messages/@original`,
226
- guildActiveThreads: (guildId) => `/guilds/${snowflake(guildId, "Guild ID")}/threads/active`,
227
264
  channelPublicArchivedThreads: (channelId) => `/channels/${snowflake(channelId, "Channel ID")}/threads/archived/public`,
228
265
  channelPrivateArchivedThreads: (channelId) => `/channels/${snowflake(channelId, "Channel ID")}/threads/archived/private`,
229
266
  threadMembers: (threadId) => `/channels/${snowflake(threadId, "Thread ID")}/thread-members`,
@@ -240,6 +277,11 @@ function snowflake(value, field) {
240
277
  throw new TypeError(`${field} must be a valid Discord snowflake.`);
241
278
  return value;
242
279
  }
280
+ // packages/rest/src/index.ts
281
+ var LIBRARY_VERSION = package_default.version;
282
+ var LIBRARY_URL = "https://github.com/Ekretos/lunibee";
283
+ var USER_AGENT = `DiscordBot (${LIBRARY_URL}, ${package_default.version})`;
284
+
243
285
  // packages/structures/src/base.ts
244
286
  class BaseStructure {
245
287
  id;
@@ -251,6 +293,16 @@ class BaseStructure {
251
293
  toString() {
252
294
  return this.id;
253
295
  }
296
+ get createdAt() {
297
+ return new Date(Number((BigInt(this.id) >> 22n) + 1420070400000n));
298
+ }
299
+ }
300
+ var CDN_BASE = "https://cdn.discordapp.com";
301
+ function cdnURL(path, hash, options = {}) {
302
+ const isAnimated = hash.startsWith("a_") && !options.forceStatic;
303
+ const ext = options.extension ?? (isAnimated ? "gif" : "png");
304
+ const size = options.size ? `?size=${options.size}` : "";
305
+ return `${CDN_BASE}${path}/${hash}.${ext}${size}`;
254
306
  }
255
307
 
256
308
  class User extends BaseStructure {
@@ -260,6 +312,7 @@ class User extends BaseStructure {
260
312
  bot;
261
313
  system;
262
314
  flags;
315
+ discriminator;
263
316
  constructor(data) {
264
317
  super(data.id);
265
318
  if (!data.username)
@@ -270,6 +323,7 @@ class User extends BaseStructure {
270
323
  this.bot = data.bot ?? false;
271
324
  this.system = data.system ?? false;
272
325
  this.flags = data.public_flags ?? 0;
326
+ this.discriminator = data.discriminator && data.discriminator !== "0" ? data.discriminator : null;
273
327
  }
274
328
  get displayName() {
275
329
  return this.globalName ?? this.username;
@@ -277,21 +331,29 @@ class User extends BaseStructure {
277
331
  avatarURL(options = {}) {
278
332
  if (!this.avatar)
279
333
  return null;
280
- const extension = options.extension ?? (this.avatar.startsWith("a_") ? "gif" : "png");
281
- return `https://cdn.discordapp.com/avatars/${this.id}/${this.avatar}.${extension}${options.size ? `?size=${options.size}` : ""}`;
334
+ return cdnURL(`/avatars/${this.id}`, this.avatar, options);
282
335
  }
283
336
  defaultAvatarURL() {
284
- return `https://cdn.discordapp.com/embed/avatars/${Number(BigInt(this.id) % 5n)}.png`;
337
+ const index = this.discriminator ? Number(this.discriminator) % 5 : Number((BigInt(this.id) >> 22n) % 6n);
338
+ return `${CDN_BASE}/embed/avatars/${index}.png`;
285
339
  }
286
340
  displayAvatarURL(options = {}) {
287
341
  return this.avatarURL(options) ?? this.defaultAvatarURL();
288
342
  }
343
+ toString() {
344
+ return `<@${this.id}>`;
345
+ }
289
346
  }
290
347
 
291
348
  class Channel extends BaseStructure {
292
349
  type;
293
350
  name;
294
351
  guildId;
352
+ topic;
353
+ parentId;
354
+ nsfw;
355
+ rateLimitPerUser;
356
+ position;
295
357
  #context;
296
358
  constructor(data, context) {
297
359
  super(data.id);
@@ -300,6 +362,11 @@ class Channel extends BaseStructure {
300
362
  this.type = data.type;
301
363
  this.name = data.name;
302
364
  this.guildId = data.guild_id;
365
+ this.topic = data.topic;
366
+ this.parentId = data.parent_id;
367
+ this.nsfw = data.nsfw;
368
+ this.rateLimitPerUser = data.rate_limit_per_user;
369
+ this.position = data.position;
303
370
  this.#context = context;
304
371
  }
305
372
  sendMessage(options) {
@@ -307,19 +374,112 @@ class Channel extends BaseStructure {
307
374
  throw new Error("This channel is not attached to a client.");
308
375
  return this.#context.sendMessage(this.id, options);
309
376
  }
377
+ send(options) {
378
+ return this.sendMessage(options);
379
+ }
380
+ edit(options) {
381
+ if (!this.#context?.editChannel)
382
+ throw new Error("This channel is not attached to a client.");
383
+ return this.#context.editChannel(this.id, options);
384
+ }
385
+ editName(name) {
386
+ if (!name.trim())
387
+ throw new TypeError("Channel name cannot be empty.");
388
+ return this.edit({ name });
389
+ }
390
+ editTopic(topic) {
391
+ return this.edit({ topic });
392
+ }
393
+ editParent(parentId) {
394
+ return this.edit({ parent_id: parentId });
395
+ }
396
+ delete() {
397
+ if (!this.#context?.deleteChannel)
398
+ throw new Error("This channel is not attached to a client.");
399
+ return this.#context.deleteChannel(this.id);
400
+ }
401
+ update(options) {
402
+ return this.edit(options);
403
+ }
404
+ toString() {
405
+ return `<#${this.id}>`;
406
+ }
310
407
  }
311
408
 
312
409
  class Guild extends BaseStructure {
313
410
  name;
411
+ icon;
412
+ splash;
413
+ banner;
414
+ description;
314
415
  preferredLocale;
315
416
  ownerId;
417
+ features;
418
+ verificationLevel;
419
+ premiumTier;
420
+ premiumSubscriptionCount;
421
+ memberCount;
422
+ approximateMemberCount;
423
+ approximatePresenceCount;
424
+ vanityUrlCode;
425
+ nsfwLevel;
426
+ discoverySplash;
316
427
  constructor(data) {
317
428
  super(data.id);
318
429
  if (!data.name)
319
430
  throw new TypeError("A Discord guild requires a name.");
320
431
  this.name = data.name;
321
- this.preferredLocale = data.preferred_locale;
432
+ this.icon = data.icon ?? null;
433
+ this.splash = data.splash ?? null;
434
+ this.banner = data.banner ?? null;
435
+ this.description = data.description ?? null;
436
+ this.preferredLocale = data.preferred_locale ?? "en-US";
322
437
  this.ownerId = data.owner_id;
438
+ this.features = data.features ?? [];
439
+ this.verificationLevel = data.verification_level ?? 0;
440
+ this.premiumTier = data.premium_tier ?? 0;
441
+ this.premiumSubscriptionCount = data.premium_subscription_count ?? 0;
442
+ this.memberCount = data.member_count ?? data.approximate_member_count;
443
+ this.approximateMemberCount = data.approximate_member_count;
444
+ this.approximatePresenceCount = data.approximate_presence_count;
445
+ this.vanityUrlCode = data.vanity_url_code ?? null;
446
+ this.nsfwLevel = data.nsfw_level ?? 0;
447
+ this.discoverySplash = data.discovery_splash ?? null;
448
+ }
449
+ iconURL(options = {}) {
450
+ if (!this.icon)
451
+ return null;
452
+ return cdnURL(`/icons/${this.id}`, this.icon, options);
453
+ }
454
+ splashURL(options = {}) {
455
+ if (!this.splash)
456
+ return null;
457
+ return cdnURL(`/splashes/${this.id}`, this.splash, options);
458
+ }
459
+ bannerURL(options = {}) {
460
+ if (!this.banner)
461
+ return null;
462
+ return cdnURL(`/banners/${this.id}`, this.banner, options);
463
+ }
464
+ discoverySplashURL(options = {}) {
465
+ if (!this.discoverySplash)
466
+ return null;
467
+ return cdnURL(`/discovery-splashes/${this.id}`, this.discoverySplash, options);
468
+ }
469
+ hasFeature(feature) {
470
+ return this.features.includes(feature);
471
+ }
472
+ get isCommunity() {
473
+ return this.hasFeature("COMMUNITY");
474
+ }
475
+ get hasVanityUrl() {
476
+ return this.vanityUrlCode !== null;
477
+ }
478
+ get vanityURL() {
479
+ return this.vanityUrlCode ? `https://discord.gg/${this.vanityUrlCode}` : null;
480
+ }
481
+ toString() {
482
+ return this.name;
323
483
  }
324
484
  }
325
485
  // packages/structures/src/permissions.ts
@@ -481,6 +641,9 @@ class GuildMember {
481
641
  get displayName() {
482
642
  return this.nickname ?? this.user.displayName;
483
643
  }
644
+ toString() {
645
+ return this.user.toString();
646
+ }
484
647
  }
485
648
 
486
649
  class Role extends BaseStructure {
@@ -505,7 +668,58 @@ class Role extends BaseStructure {
505
668
  return `<@&${this.id}>`;
506
669
  }
507
670
  }
508
-
671
+ // packages/types/src/index.ts
672
+ var GatewayIntentBits = {
673
+ Guilds: 1 << 0,
674
+ GuildMembers: 1 << 1,
675
+ GuildModeration: 1 << 2,
676
+ GuildExpressions: 1 << 3,
677
+ GuildIntegrations: 1 << 4,
678
+ GuildWebhooks: 1 << 5,
679
+ GuildInvites: 1 << 6,
680
+ GuildVoiceStates: 1 << 7,
681
+ GuildPresences: 1 << 8,
682
+ GuildMessages: 1 << 9,
683
+ GuildMessageReactions: 1 << 10,
684
+ GuildMessageTyping: 1 << 11,
685
+ DirectMessages: 1 << 12,
686
+ DirectMessageReactions: 1 << 13,
687
+ DirectMessageTyping: 1 << 14,
688
+ MessageContent: 1 << 15,
689
+ GuildScheduledEvents: 1 << 16,
690
+ AutoModerationConfiguration: 1 << 20,
691
+ AutoModerationExecution: 1 << 21,
692
+ GuildMessagePolls: 1 << 24,
693
+ DirectMessagePolls: 1 << 25
694
+ };
695
+ var IntentBits = {
696
+ guild: 1 << 0,
697
+ guilds: 1 << 0,
698
+ guildMembers: 1 << 1,
699
+ guildModeration: 1 << 2,
700
+ guildBans: 1 << 2,
701
+ guildExpressions: 1 << 3,
702
+ guildEmojis: 1 << 3,
703
+ guildEmojisAndStickers: 1 << 3,
704
+ guildIntegrations: 1 << 4,
705
+ guildWebhooks: 1 << 5,
706
+ guildInvites: 1 << 6,
707
+ guildVoiceStates: 1 << 7,
708
+ guildPresences: 1 << 8,
709
+ guildMessages: 1 << 9,
710
+ guildMessage: 1 << 9,
711
+ guildMessageReactions: 1 << 10,
712
+ guildMessageTyping: 1 << 11,
713
+ directMessages: 1 << 12,
714
+ directMessageReactions: 1 << 13,
715
+ directMessageTyping: 1 << 14,
716
+ messageContent: 1 << 15,
717
+ guildScheduledEvents: 1 << 16,
718
+ autoModerationConfiguration: 1 << 20,
719
+ autoModerationExecution: 1 << 21,
720
+ guildMessagePolls: 1 << 24,
721
+ directMessagePolls: 1 << 25
722
+ };
509
723
  // packages/structures/src/index.ts
510
724
  class Message extends BaseStructure {
511
725
  content;
@@ -514,7 +728,7 @@ class Message extends BaseStructure {
514
728
  channel;
515
729
  guildId;
516
730
  flags;
517
- createdAt;
731
+ timestamp;
518
732
  attachments;
519
733
  embeds;
520
734
  mentions;
@@ -523,6 +737,7 @@ class Message extends BaseStructure {
523
737
  mentionEveryone;
524
738
  type;
525
739
  reference;
740
+ components;
526
741
  referencedMessage;
527
742
  #context;
528
743
  constructor(data, context) {
@@ -534,9 +749,10 @@ class Message extends BaseStructure {
534
749
  this.channelId = data.channel_id;
535
750
  this.guildId = data.guild_id;
536
751
  this.flags = data.flags ?? 0;
537
- this.createdAt = new Date(data.timestamp ?? Number((BigInt(this.id) >> 22n) + 1420070400000n));
752
+ this.timestamp = new Date(data.timestamp ?? Number((BigInt(this.id) >> 22n) + 1420070400000n));
538
753
  this.attachments = data.attachments ?? [];
539
754
  this.embeds = data.embeds ?? [];
755
+ this.components = data.components ?? [];
540
756
  this.mentions = (data.mentions ?? []).map((user) => new User(user));
541
757
  this.mentionRoles = data.mention_roles ?? [];
542
758
  this.pinned = data.pinned ?? false;
@@ -555,16 +771,14 @@ class Message extends BaseStructure {
555
771
  throw new Error("This message is not attached to a client.");
556
772
  return this.#context.editMessage(this.channelId, this.id, options);
557
773
  }
774
+ update(options) {
775
+ return this.edit(options);
776
+ }
558
777
  delete() {
559
778
  if (!this.#context)
560
779
  throw new Error("This message is not attached to a client.");
561
780
  return this.#context.deleteMessage(this.channelId, this.id);
562
781
  }
563
- crosspost() {
564
- if (!this.#context)
565
- throw new Error("This message is not attached to a client.");
566
- return this.#context.crosspostMessage(this.channelId, this.id);
567
- }
568
782
  reply(options) {
569
783
  if (!this.#context)
570
784
  throw new Error("This message is not attached to a client.");
@@ -576,6 +790,36 @@ class Message extends BaseStructure {
576
790
  };
577
791
  return this.#context.sendMessage(this.channelId, payload);
578
792
  }
793
+ crosspost() {
794
+ if (!this.#context)
795
+ throw new Error("This message is not attached to a client.");
796
+ return this.#context.crosspostMessage(this.channelId, this.id);
797
+ }
798
+ react(emoji) {
799
+ if (!this.#context?.addReaction)
800
+ throw new Error("This message is not attached to a client.");
801
+ return this.#context.addReaction(this.channelId, this.id, emoji);
802
+ }
803
+ removeReaction(emoji, userId) {
804
+ if (!this.#context)
805
+ throw new Error("This message is not attached to a client.");
806
+ return userId ? this.#context.removeReaction?.(this.channelId, this.id, emoji, userId) ?? Promise.reject(new Error("Reaction operations are unavailable.")) : this.#context.removeOwnReaction?.(this.channelId, this.id, emoji) ?? Promise.reject(new Error("Reaction operations are unavailable."));
807
+ }
808
+ removeAllReactions() {
809
+ if (!this.#context?.removeAllReactions)
810
+ throw new Error("This message is not attached to a client.");
811
+ return this.#context.removeAllReactions(this.channelId, this.id);
812
+ }
813
+ pin() {
814
+ if (!this.#context?.pinMessage)
815
+ throw new Error("This message is not attached to a client.");
816
+ return this.#context.pinMessage(this.channelId, this.id);
817
+ }
818
+ unpin() {
819
+ if (!this.#context?.unpinMessage)
820
+ throw new Error("This message is not attached to a client.");
821
+ return this.#context.unpinMessage(this.channelId, this.id);
822
+ }
579
823
  }
580
824
 
581
825
  // packages/managers/src/message.ts
@@ -600,10 +844,7 @@ class MessageManager {
600
844
  }
601
845
  async fetch(messageId) {
602
846
  const data = await this.#rest.get(Routes.message(this.#channelId, messageId));
603
- const message = Array.isArray(data) ? data[0] : data;
604
- if (!message)
605
- throw new Error("Discord returned no message payload.");
606
- return this.upsert(message);
847
+ return this.upsert(data);
607
848
  }
608
849
  fetchMany(messageIds) {
609
850
  return Promise.all(Array.from(messageIds, (messageId) => this.fetch(messageId)));
@@ -644,6 +885,62 @@ class ThreadManager {
644
885
  return new Channel(data, this.#context);
645
886
  }
646
887
  }
888
+
889
+ // packages/managers/src/user.ts
890
+ class UserManager extends ResourceManager {
891
+ #rest;
892
+ constructor(rest) {
893
+ super(async (id) => new User(await rest.get(Routes.userById(id))), (user) => user.id);
894
+ this.#rest = rest;
895
+ }
896
+ async fetchMe() {
897
+ const data = await this.#rest.get("/users/@me");
898
+ return this.upsert(new User(data));
899
+ }
900
+ async editMe(options) {
901
+ const data = await this.#rest.patch("/users/@me", options);
902
+ return this.upsert(new User(data));
903
+ }
904
+ async leaveGuild(guildId) {
905
+ await this.#rest.delete(`/users/@me/guilds/${guildId}`);
906
+ }
907
+ async createDM(userId) {
908
+ return this.#rest.post("/users/@me/channels", {
909
+ recipient_id: userId
910
+ });
911
+ }
912
+ }
913
+ // packages/managers/src/guild.ts
914
+ class GuildManager extends ResourceManager {
915
+ #rest;
916
+ constructor(rest) {
917
+ super(async (id) => new Guild(await rest.get(Routes.guild(id))), (guild) => guild.id);
918
+ this.#rest = rest;
919
+ }
920
+ async create(options) {
921
+ const data = await this.#rest.post("/guilds", options);
922
+ return this.upsert(new Guild(data));
923
+ }
924
+ async edit(id, options) {
925
+ const data = await this.#rest.patch(Routes.guild(id), options);
926
+ return this.upsert(new Guild(data));
927
+ }
928
+ async deleteGuild(id) {
929
+ await this.#rest.delete(Routes.guild(id));
930
+ }
931
+ async fetchPreview(id) {
932
+ return this.#rest.get(Routes.guildPreview(id));
933
+ }
934
+ async fetchActiveThreads(id) {
935
+ return this.#rest.get(Routes.guildActiveThreads(id));
936
+ }
937
+ async fetchWebhooks(id) {
938
+ return this.#rest.get(Routes.guildWebhooks(id));
939
+ }
940
+ async fetchInvites(id) {
941
+ return this.#rest.get(Routes.guildInvites(id));
942
+ }
943
+ }
647
944
  // packages/managers/src/role.ts
648
945
  class RoleManager extends ResourceManager {
649
946
  #rest;
@@ -766,23 +1063,6 @@ class ApplicationCommandManager {
766
1063
  }
767
1064
 
768
1065
  // packages/managers/src/index.ts
769
- class UserManager extends ResourceManager {
770
- constructor(rest) {
771
- super(async (id) => new User(await rest.get(Routes.userById(id))), (user) => user.id);
772
- }
773
- }
774
-
775
- class GuildManager extends ResourceManager {
776
- constructor(rest) {
777
- super(async (id) => new Guild(await rest.get(Routes.guild(id))), (guild) => guild.id);
778
- }
779
- }
780
- var MessageCreateOptions = undefined;
781
- var MessageEditOptions = undefined;
782
- var MessageFetchOptions = undefined;
783
- var MessageThreadOptions = undefined;
784
- var ReactionFetchOptions = undefined;
785
-
786
1066
  class ChannelManager extends Manager {
787
1067
  #rest;
788
1068
  #context;
@@ -794,7 +1074,15 @@ class ChannelManager extends Manager {
794
1074
  sendMessage: (channelId, options) => this.send(channelId, options),
795
1075
  editMessage: (channelId, messageId, options) => this.editMessage(channelId, messageId, options),
796
1076
  deleteMessage: (channelId, messageId) => this.deleteMessage(channelId, messageId),
797
- crosspostMessage: (channelId, messageId) => this.crosspostMessage(channelId, messageId)
1077
+ crosspostMessage: (channelId, messageId) => this.crosspostMessage(channelId, messageId),
1078
+ editChannel: (channelId, options) => this.edit(channelId, options),
1079
+ deleteChannel: (channelId) => this.deleteChannel(channelId),
1080
+ addReaction: (channelId, messageId, emoji) => this.addReaction(channelId, messageId, emoji),
1081
+ removeOwnReaction: (channelId, messageId, emoji) => this.removeOwnReaction(channelId, messageId, emoji),
1082
+ removeReaction: (channelId, messageId, emoji, userId) => this.removeReaction(channelId, messageId, emoji, userId),
1083
+ removeAllReactions: (channelId, messageId) => this.removeAllReactions(channelId, messageId),
1084
+ pinMessage: (channelId, messageId) => this.pinMessage(channelId, messageId),
1085
+ unpinMessage: (channelId, messageId) => this.unpinMessage(channelId, messageId)
798
1086
  };
799
1087
  }
800
1088
  messages(channelId) {
@@ -809,8 +1097,7 @@ class ChannelManager extends Manager {
809
1097
  return new ThreadManager(this.#rest, this.#context, channelId);
810
1098
  }
811
1099
  async fetch(channelId) {
812
- const data = await this.#rest.get(Routes.channel(channelId));
813
- return this.upsert(data);
1100
+ return this.upsert(await this.#rest.get(Routes.channel(channelId)));
814
1101
  }
815
1102
  async resolve(channelId) {
816
1103
  return this.get(channelId) ?? this.fetch(channelId);
@@ -828,6 +1115,17 @@ class ChannelManager extends Manager {
828
1115
  update(channel) {
829
1116
  return this.set(channel.id, channel);
830
1117
  }
1118
+ async create(guildId, options) {
1119
+ return this.upsert(await this.#rest.post(Routes.guildChannels(guildId), options));
1120
+ }
1121
+ async edit(channelId, options) {
1122
+ return this.upsert(await this.#rest.patch(Routes.channel(channelId), options));
1123
+ }
1124
+ async deleteChannel(channelId) {
1125
+ await this.#rest.delete(Routes.channel(channelId));
1126
+ this.#messageManagers.delete(channelId);
1127
+ super.delete(channelId);
1128
+ }
831
1129
  send(channelId, options) {
832
1130
  return this.messages(channelId).send(options);
833
1131
  }
@@ -857,8 +1155,7 @@ class ChannelManager extends Manager {
857
1155
  return this.messages(data.channel_id).upsert(data);
858
1156
  }
859
1157
  async editMessage(channelId, messageId, options) {
860
- const data = await this.#rest.patch(Routes.message(channelId, messageId), options);
861
- return this.messages(channelId).upsert(data);
1158
+ return this.messages(channelId).upsert(await this.#rest.patch(Routes.message(channelId, messageId), options));
862
1159
  }
863
1160
  async deleteMessage(channelId, messageId) {
864
1161
  await this.#rest.delete(Routes.message(channelId, messageId));
@@ -868,8 +1165,7 @@ class ChannelManager extends Manager {
868
1165
  return this.messages(channelId).delete(messageId);
869
1166
  }
870
1167
  async crosspostMessage(channelId, messageId) {
871
- const data = await this.#rest.post(Routes.crosspostMessage(channelId, messageId));
872
- return this.messages(channelId).upsert(data);
1168
+ return this.messages(channelId).upsert(await this.#rest.post(Routes.crosspostMessage(channelId, messageId)));
873
1169
  }
874
1170
  async bulkDeleteMessages(channelId, messageIds) {
875
1171
  const ids = [...messageIds];
@@ -893,7 +1189,7 @@ class ChannelManager extends Manager {
893
1189
  return data.map((user) => new User(user));
894
1190
  }
895
1191
  async removeOwnReaction(channelId, messageId, emoji) {
896
- await this.#rest.delete(Routes.messageReactions(channelId, messageId, emoji) + "/@me");
1192
+ await this.#rest.delete(`${Routes.messageReactions(channelId, messageId, emoji)}/@me`);
897
1193
  }
898
1194
  async removeReaction(channelId, messageId, emoji, userId) {
899
1195
  await this.#rest.delete(`${Routes.messageReactions(channelId, messageId, emoji)}/${userId}`);
@@ -932,16 +1228,11 @@ export {
932
1228
  GuildManager,
933
1229
  GuildMemberManager,
934
1230
  Manager,
935
- MessageCreateOptions,
936
- MessageEditOptions,
937
- MessageFetchOptions,
938
1231
  MessageManager,
939
- MessageThreadOptions,
940
- ReactionFetchOptions,
941
1232
  ResourceManager,
942
1233
  RoleManager,
943
1234
  ThreadManager,
944
1235
  UserManager
945
1236
  };
946
1237
 
947
- //# debugId=B1F523C9C7EE890964756E2164756E21
1238
+ //# debugId=53F2FF9551439B3964756E2164756E21