lunibee 0.2.1 → 0.2.3

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 (49) hide show
  1. package/README.md +6 -6
  2. package/dist/builders/attachment.d.ts +5 -1
  3. package/dist/builders/commands.d.ts +136 -47
  4. package/dist/builders/components.d.ts +164 -45
  5. package/dist/builders/embed.d.ts +5 -1
  6. package/dist/builders/index.d.ts +9 -4
  7. package/dist/builders/index.js +206 -105
  8. package/dist/builders/index.js.map +8 -8
  9. package/dist/core/events.d.ts +28 -12
  10. package/dist/core/index.d.ts +2 -1
  11. package/dist/core/index.js +377 -150
  12. package/dist/core/index.js.map +25 -25
  13. package/dist/core/permissions.d.ts +6 -2
  14. package/dist/index.d.ts +5 -4
  15. package/dist/index.js +662 -268
  16. package/dist/index.js.map +33 -32
  17. package/dist/managers/base.d.ts +4 -0
  18. package/dist/managers/emoji.d.ts +7 -1
  19. package/dist/managers/guild-resources.d.ts +11 -3
  20. package/dist/managers/guild.d.ts +13 -5
  21. package/dist/managers/index.d.ts +31 -14
  22. package/dist/managers/index.js +167 -80
  23. package/dist/managers/index.js.map +18 -18
  24. package/dist/managers/member.d.ts +5 -3
  25. package/dist/managers/message.d.ts +7 -3
  26. package/dist/managers/role.d.ts +13 -1
  27. package/dist/rest/error-codes.d.ts +48 -0
  28. package/dist/rest/errors.d.ts +1 -0
  29. package/dist/rest/index.d.ts +1 -0
  30. package/dist/rest/index.js +53 -3
  31. package/dist/rest/index.js.map +7 -6
  32. package/dist/rest/routes.d.ts +4 -2
  33. package/dist/sharding/index.js +7 -6
  34. package/dist/sharding/index.js.map +6 -6
  35. package/dist/structures/base.d.ts +18 -9
  36. package/dist/structures/index.d.ts +15 -9
  37. package/dist/structures/index.js +198 -68
  38. package/dist/structures/index.js.map +12 -12
  39. package/dist/structures/interactions.d.ts +85 -11
  40. package/dist/structures/resources.d.ts +11 -1
  41. package/dist/types/gateway.d.ts +14 -0
  42. package/dist/types/index.d.ts +204 -16
  43. package/dist/types/index.js +37 -10
  44. package/dist/types/index.js.map +4 -4
  45. package/dist/voice/index.js +4 -3
  46. package/dist/voice/index.js.map +3 -3
  47. package/dist/ws/index.js +2 -1
  48. package/dist/ws/index.js.map +5 -5
  49. package/package.json +15 -15
@@ -550,6 +550,11 @@ class Collection extends Map {
550
550
  }
551
551
 
552
552
  // packages/managers/src/base.ts
553
+ function splitReason(options) {
554
+ const { reason, ...payload } = options;
555
+ return [payload, reason];
556
+ }
557
+
553
558
  class Manager {
554
559
  cache = new Collection;
555
560
  get(id) {
@@ -651,12 +656,15 @@ class ResourceManager extends Manager {
651
656
  // packages/rest/package.json
652
657
  var package_default = {
653
658
  name: "@lunibee/rest",
654
- version: "0.2.1",
659
+ version: "0.2.3",
655
660
  type: "module",
656
661
  module: "./src/index.ts",
657
662
  types: "./src/index.ts",
658
663
  exports: {
659
664
  ".": "./src/index.ts"
665
+ },
666
+ dependencies: {
667
+ "@lunibee/types": "workspace:*"
660
668
  }
661
669
  };
662
670
 
@@ -682,6 +690,8 @@ var Routes = {
682
690
  crosspostMessage: (channelId, messageId) => `${Routes.message(channelId, messageId)}/crosspost`,
683
691
  messageReactions: (channelId, messageId, emoji) => `${Routes.message(channelId, messageId)}/reactions/${encodeURIComponent(emoji)}`,
684
692
  messageReactionsAll: (channelId, messageId) => `${Routes.message(channelId, messageId)}/reactions`,
693
+ channelMessagesPins: (channelId) => `/channels/${snowflake(channelId, "Channel ID")}/messages/pins`,
694
+ channelMessagesPin: (channelId, messageId) => `/channels/${snowflake(channelId, "Channel ID")}/messages/pins/${snowflake(messageId, "Message ID")}`,
685
695
  channelPins: (channelId) => `/channels/${snowflake(channelId, "Channel ID")}/pins`,
686
696
  channelPin: (channelId, messageId) => `/channels/${snowflake(channelId, "Channel ID")}/pins/${snowflake(messageId, "Message ID")}`,
687
697
  messageThread: (channelId, messageId) => `${Routes.message(channelId, messageId)}/threads`,
@@ -744,7 +754,7 @@ function snowflake(value, field) {
744
754
  // packages/rest/src/index.ts
745
755
  var LIBRARY_VERSION = package_default.version;
746
756
  var LIBRARY_URL = "https://github.com/Ekretos/lunibee";
747
- var USER_AGENT = `DiscordBot (${LIBRARY_URL}, ${package_default.version})`;
757
+ var USER_AGENT = `DiscordBot (${LIBRARY_URL}, ${LIBRARY_VERSION})`;
748
758
  var REQUEST_DATA_KEYS = new Set([
749
759
  "body",
750
760
  "files",
@@ -844,13 +854,13 @@ class Channel extends BaseStructure {
844
854
  this.permissionOverwrites = (data.permission_overwrites ?? []).map((overwrite) => ({ ...overwrite }));
845
855
  this.#context = context;
846
856
  }
847
- sendMessage(options) {
857
+ send(options) {
848
858
  if (!this.#context)
849
859
  throw new Error("This channel is not attached to a client.");
850
860
  return this.#context.sendMessage(this.id, options);
851
861
  }
852
- send(options) {
853
- return this.sendMessage(options);
862
+ sendMessage(options) {
863
+ return this.send(options);
854
864
  }
855
865
  edit(options) {
856
866
  if (!this.#context?.editChannel)
@@ -873,10 +883,10 @@ class Channel extends BaseStructure {
873
883
  editParent(parentId) {
874
884
  return this.edit({ parent_id: parentId });
875
885
  }
876
- delete() {
886
+ delete(reason) {
877
887
  if (!this.#context?.deleteChannel)
878
888
  throw new Error("This channel is not attached to a client.");
879
- return this.#context.deleteChannel(this.id);
889
+ return this.#context.deleteChannel(this.id, reason);
880
890
  }
881
891
  update(options) {
882
892
  return this.edit(options);
@@ -923,6 +933,15 @@ class Guild extends BaseStructure {
923
933
  mfaLevel;
924
934
  explicitContentFilter;
925
935
  defaultMessageNotifications;
936
+ afkChannelId;
937
+ afkTimeout;
938
+ widgetEnabled;
939
+ widgetChannelId;
940
+ applicationId;
941
+ publicUpdatesChannelId;
942
+ safetyAlertsChannelId;
943
+ maxPresences;
944
+ maxVideoChannelUsers;
926
945
  constructor(data) {
927
946
  super(data.id);
928
947
  if (!data.name)
@@ -944,14 +963,22 @@ class Guild extends BaseStructure {
944
963
  this.vanityUrlCode = data.vanity_url_code ?? null;
945
964
  this.nsfwLevel = data.nsfw_level ?? 0;
946
965
  this.discoverySplash = data.discovery_splash ?? null;
947
- const d = data;
948
- this.rulesChannelId = d.rules_channel_id ?? null;
949
- this.systemChannelId = d.system_channel_id ?? null;
950
- this.systemChannelFlags = d.system_channel_flags ?? 0;
951
- this.maxMembers = d.max_members ?? 0;
952
- this.mfaLevel = d.mfa_level ?? 0;
953
- this.explicitContentFilter = d.explicit_content_filter ?? 0;
954
- this.defaultMessageNotifications = d.default_message_notifications ?? 0;
966
+ this.rulesChannelId = data.rules_channel_id ?? null;
967
+ this.systemChannelId = data.system_channel_id ?? null;
968
+ this.systemChannelFlags = data.system_channel_flags ?? 0;
969
+ this.maxMembers = data.max_members ?? 0;
970
+ this.mfaLevel = data.mfa_level ?? 0;
971
+ this.explicitContentFilter = data.explicit_content_filter ?? 0;
972
+ this.defaultMessageNotifications = data.default_message_notifications ?? 0;
973
+ this.afkChannelId = data.afk_channel_id ?? null;
974
+ this.afkTimeout = data.afk_timeout;
975
+ this.widgetEnabled = data.widget_enabled ?? false;
976
+ this.widgetChannelId = data.widget_channel_id ?? null;
977
+ this.applicationId = data.application_id ?? null;
978
+ this.publicUpdatesChannelId = data.public_updates_channel_id ?? null;
979
+ this.safetyAlertsChannelId = data.safety_alerts_channel_id ?? null;
980
+ this.maxPresences = data.max_presences ?? null;
981
+ this.maxVideoChannelUsers = data.max_video_channel_users;
955
982
  }
956
983
  iconURL(options = {}) {
957
984
  if (!this.icon)
@@ -1674,7 +1701,7 @@ class TextChannel extends Channel {
1674
1701
  return `<#${this.id}>`;
1675
1702
  }
1676
1703
  }
1677
- class Emoji extends BaseStructure {
1704
+ class Emoji2 extends BaseStructure {
1678
1705
  name;
1679
1706
  roleIds;
1680
1707
  user;
@@ -1821,7 +1848,7 @@ class ForumChannel extends Channel {
1821
1848
 
1822
1849
  class MediaChannel extends ForumChannel {
1823
1850
  }
1824
- function createChannel2(data, context) {
1851
+ function createChannel(data, context) {
1825
1852
  switch (data.type) {
1826
1853
  case 0:
1827
1854
  return new TextChannel(data, context);
@@ -1873,6 +1900,9 @@ class Message extends BaseStructure {
1873
1900
  reference;
1874
1901
  components;
1875
1902
  referencedMessage;
1903
+ stickers;
1904
+ poll;
1905
+ messageSnapshots;
1876
1906
  member;
1877
1907
  #context;
1878
1908
  constructor(data, context) {
@@ -1894,6 +1924,13 @@ class Message extends BaseStructure {
1894
1924
  this.mentionEveryone = data.mention_everyone ?? false;
1895
1925
  this.type = data.type ?? 0;
1896
1926
  this.reference = data.message_reference;
1927
+ this.stickers = data.sticker_items ?? (data.stickers ?? []).map(({ id, name, format_type }) => ({
1928
+ id,
1929
+ name,
1930
+ format_type
1931
+ }));
1932
+ this.poll = data.poll ?? null;
1933
+ this.messageSnapshots = data.message_snapshots ?? [];
1897
1934
  this.referencedMessage = data.referenced_message ? new Message(data.referenced_message, context) : data.referenced_message === null ? null : undefined;
1898
1935
  this.#context = context;
1899
1936
  this.member = data.member && data.guild_id ? new GuildMember({
@@ -1920,10 +1957,10 @@ class Message extends BaseStructure {
1920
1957
  update(options) {
1921
1958
  return this.edit(options);
1922
1959
  }
1923
- delete() {
1960
+ delete(reason) {
1924
1961
  if (!this.#context)
1925
1962
  throw new Error("This message is not attached to a client.");
1926
- return this.#context.deleteMessage(this.channelId, this.id);
1963
+ return this.#context.deleteMessage(this.channelId, this.id, reason);
1927
1964
  }
1928
1965
  reply(options) {
1929
1966
  if (!this.#context)
@@ -1970,15 +2007,15 @@ class Message extends BaseStructure {
1970
2007
  throw new Error("This message is not attached to a client.");
1971
2008
  return this.#context.removeAllReactions(this.channelId, this.id);
1972
2009
  }
1973
- pin() {
2010
+ pin(reason) {
1974
2011
  if (!this.#context?.pinMessage)
1975
2012
  throw new Error("This message is not attached to a client.");
1976
- return this.#context.pinMessage(this.channelId, this.id);
2013
+ return this.#context.pinMessage(this.channelId, this.id, reason);
1977
2014
  }
1978
- unpin() {
2015
+ unpin(reason) {
1979
2016
  if (!this.#context?.unpinMessage)
1980
2017
  throw new Error("This message is not attached to a client.");
1981
- return this.#context.unpinMessage(this.channelId, this.id);
2018
+ return this.#context.unpinMessage(this.channelId, this.id, reason);
1982
2019
  }
1983
2020
  get isEphemeral() {
1984
2021
  return (this.flags & 64) !== 0;
@@ -2028,8 +2065,10 @@ class Message extends BaseStructure {
2028
2065
  }
2029
2066
 
2030
2067
  // packages/managers/src/message.ts
2031
- function toRequest(options) {
2068
+ function toRequest(options, allowedMentions) {
2032
2069
  const { files, ...body } = options;
2070
+ if (allowedMentions !== undefined && body.allowed_mentions === undefined)
2071
+ body.allowed_mentions = allowedMentions;
2033
2072
  if (!files?.length)
2034
2073
  return body;
2035
2074
  return {
@@ -2048,9 +2087,11 @@ class MessageManager {
2048
2087
  #rest;
2049
2088
  #context;
2050
2089
  #channelId;
2051
- constructor(rest, context, channelId, cache) {
2090
+ #allowedMentions;
2091
+ constructor(rest, context, channelId, cache, allowedMentions) {
2052
2092
  if (!channelId)
2053
2093
  throw new TypeError("Channel ID is required.");
2094
+ this.#allowedMentions = allowedMentions;
2054
2095
  this.#rest = rest;
2055
2096
  this.#context = context;
2056
2097
  this.#channelId = channelId;
@@ -2064,7 +2105,7 @@ class MessageManager {
2064
2105
  return this.cache.get(messageId) ?? this.fetch(messageId);
2065
2106
  }
2066
2107
  async send(options) {
2067
- const data = await this.#rest.post(Routes.channelMessages(this.#channelId), toRequest(options));
2108
+ const data = await this.#rest.post(Routes.channelMessages(this.#channelId), toRequest(options, this.#allowedMentions));
2068
2109
  return this.upsert(data);
2069
2110
  }
2070
2111
  async fetch(messageId) {
@@ -2108,7 +2149,7 @@ class ThreadManager {
2108
2149
  auto_archive_duration: options.autoArchiveDuration,
2109
2150
  rate_limit_per_user: options.rateLimitPerUser
2110
2151
  });
2111
- return createChannel2(data, this.#context);
2152
+ return createChannel(data, this.#context);
2112
2153
  }
2113
2154
  }
2114
2155
 
@@ -2146,25 +2187,32 @@ class EmojiManager extends Manager {
2146
2187
  this.#guildId = guildId;
2147
2188
  }
2148
2189
  fetch(emojiId) {
2149
- return this.fetchOnce(emojiId, async () => new Emoji(await this.#rest.get(Routes.guildEmoji(this.#guildId, emojiId))), (emoji) => this.#merge(emojiId, emoji));
2190
+ return this.fetchOnce(emojiId, async () => new Emoji2(await this.#rest.get(Routes.guildEmoji(this.#guildId, emojiId))), (emoji) => this.#merge(emojiId, emoji));
2150
2191
  }
2151
2192
  async fetchAll() {
2152
2193
  const data = await this.#rest.get(Routes.guildEmoji(this.#guildId));
2153
2194
  return data.map((item) => this.upsert(item));
2154
2195
  }
2155
2196
  async create(options) {
2156
- return this.upsert(await this.#rest.post(Routes.guildEmoji(this.#guildId), options));
2197
+ const [payload, reason] = splitReason(options);
2198
+ return this.upsert(await this.#rest.post(Routes.guildEmoji(this.#guildId), payload, { reason }));
2157
2199
  }
2158
2200
  async edit(emojiId, options) {
2159
- return this.upsert(await this.#rest.patch(Routes.guildEmoji(this.#guildId, emojiId), options));
2201
+ const [payload, reason] = splitReason(options);
2202
+ return this.upsert(await this.#rest.patch(Routes.guildEmoji(this.#guildId, emojiId), payload, { reason }));
2160
2203
  }
2161
- async deleteEmoji(emojiId) {
2162
- await this.#rest.delete(Routes.guildEmoji(this.#guildId, emojiId));
2204
+ async remove(emojiId, reason) {
2205
+ await this.#rest.delete(Routes.guildEmoji(this.#guildId, emojiId), {
2206
+ reason
2207
+ });
2163
2208
  this.delete(emojiId);
2164
2209
  }
2210
+ deleteEmoji(emojiId) {
2211
+ return this.remove(emojiId);
2212
+ }
2165
2213
  upsert(data) {
2166
2214
  const key = data.id != null ? data.id : `unicode:${data.name ?? ""}`;
2167
- return this.#merge(key, new Emoji(data));
2215
+ return this.#merge(key, new Emoji2(data));
2168
2216
  }
2169
2217
  #merge(key, emoji) {
2170
2218
  const existing = this.get(key);
@@ -2365,11 +2413,16 @@ class GuildMemberManager extends ResourceManager {
2365
2413
  await this.#rest.put(Routes.guildBan(this.guildId, userId), { delete_message_seconds: options.deleteMessageSeconds }, { reason: options.reason });
2366
2414
  this.delete(userId);
2367
2415
  }
2368
- async unban(userId) {
2369
- await this.#rest.delete(Routes.guildBan(this.guildId, userId));
2416
+ async unban(userId, reason) {
2417
+ await this.#rest.delete(Routes.guildBan(this.guildId, userId), {
2418
+ reason
2419
+ });
2370
2420
  }
2371
2421
  async edit(userId, options, reason) {
2372
- const data = await this.#rest.patch(Routes.guildMember(this.guildId, userId), options, { reason });
2422
+ const [payload, optionsReason] = splitReason(options);
2423
+ const data = await this.#rest.patch(Routes.guildMember(this.guildId, userId), payload, {
2424
+ reason: optionsReason ?? reason
2425
+ });
2373
2426
  const member = new GuildMember({ ...data, guild_id: this.guildId }, this.#context());
2374
2427
  this.set(member.user.id, member);
2375
2428
  return member;
@@ -2408,7 +2461,7 @@ class RoleManager extends ResourceManager {
2408
2461
  const data = await this.#rest.post(Routes.guildRoles(this.guildId), {
2409
2462
  ...payload,
2410
2463
  permissions: payload.permissions !== undefined ? String(payload.permissions) : undefined
2411
- });
2464
+ }, { reason });
2412
2465
  const role = new Role(data);
2413
2466
  this.set(role.id, role);
2414
2467
  return role;
@@ -2418,15 +2471,28 @@ class RoleManager extends ResourceManager {
2418
2471
  const data = await this.#rest.patch(Routes.guildRole(this.guildId, roleId), {
2419
2472
  ...payload,
2420
2473
  permissions: payload.permissions !== undefined ? String(payload.permissions) : undefined
2421
- });
2474
+ }, { reason });
2422
2475
  const role = new Role(data);
2423
2476
  this.set(role.id, role);
2424
2477
  return role;
2425
2478
  }
2426
- async deleteRole(roleId) {
2427
- await this.#rest.delete(Routes.guildRole(this.guildId, roleId));
2479
+ async remove(roleId, reason) {
2480
+ await this.#rest.delete(Routes.guildRole(this.guildId, roleId), {
2481
+ reason
2482
+ });
2428
2483
  this.delete(roleId);
2429
2484
  }
2485
+ async setPositions(positions, reason) {
2486
+ const data = await this.#rest.patch(Routes.guildRoles(this.guildId), positions.map(({ id, position }) => ({ id, position })), { reason });
2487
+ return data.map((item) => {
2488
+ const role = new Role(item);
2489
+ this.set(role.id, role);
2490
+ return role;
2491
+ });
2492
+ }
2493
+ deleteRole(roleId) {
2494
+ return this.remove(roleId);
2495
+ }
2430
2496
  }
2431
2497
 
2432
2498
  // packages/managers/src/guild-resources.ts
@@ -2498,13 +2564,15 @@ class GuildScheduledEventManager extends Manager {
2498
2564
  return events.map((event) => this.#store(event));
2499
2565
  }
2500
2566
  async create(options, reason) {
2501
- return this.#store(await this.#rest.post(Routes.guildScheduledEvents(this.guildId), options, { reason }));
2567
+ const [payload, optionsReason] = splitReason(options);
2568
+ return this.#store(await this.#rest.post(Routes.guildScheduledEvents(this.guildId), payload, { reason: optionsReason ?? reason }));
2502
2569
  }
2503
2570
  async edit(eventId, options, reason) {
2504
- return this.#store(await this.#rest.patch(Routes.guildScheduledEvent(this.guildId, eventId), options, { reason }));
2571
+ const [payload, optionsReason] = splitReason(options);
2572
+ return this.#store(await this.#rest.patch(Routes.guildScheduledEvent(this.guildId, eventId), payload, { reason: optionsReason ?? reason }));
2505
2573
  }
2506
- async remove(eventId) {
2507
- await this.#rest.delete(Routes.guildScheduledEvent(this.guildId, eventId));
2574
+ async remove(eventId, reason) {
2575
+ await this.#rest.delete(Routes.guildScheduledEvent(this.guildId, eventId), { reason });
2508
2576
  this.delete(eventId);
2509
2577
  }
2510
2578
  async fetchSubscribers(eventId, options = {}) {
@@ -2535,13 +2603,13 @@ class StageInstanceManager extends Manager {
2535
2603
  privacy_level: options.privacyLevel,
2536
2604
  send_start_notification: options.sendStartNotification,
2537
2605
  guild_scheduled_event_id: options.guildScheduledEventId
2538
- }, { reason }));
2606
+ }, { reason: options.reason ?? reason }));
2539
2607
  }
2540
2608
  async fetch(channelId) {
2541
2609
  return this.#store(await this.#rest.get(Routes.stageInstanceByChannel(channelId)));
2542
2610
  }
2543
2611
  async edit(channelId, options, reason) {
2544
- return this.#store(await this.#rest.patch(Routes.stageInstanceByChannel(channelId), { topic: options.topic, privacy_level: options.privacyLevel }, { reason }));
2612
+ return this.#store(await this.#rest.patch(Routes.stageInstanceByChannel(channelId), { topic: options.topic, privacy_level: options.privacyLevel }, { reason: options.reason ?? reason }));
2545
2613
  }
2546
2614
  async remove(channelId, reason) {
2547
2615
  await this.#rest.delete(Routes.stageInstanceByChannel(channelId), {
@@ -2578,7 +2646,7 @@ class PermissionOverwriteManager {
2578
2646
  type: options.type,
2579
2647
  allow: BigInt(options.allow ?? 0).toString(),
2580
2648
  deny: BigInt(options.deny ?? 0).toString()
2581
- }, { reason });
2649
+ }, { reason: options.reason ?? reason });
2582
2650
  }
2583
2651
  async remove(overwriteId, reason) {
2584
2652
  await this.#rest.delete(Routes.channelPermission(this.channelId, overwriteId), { reason });
@@ -2696,12 +2764,16 @@ class GuildManager extends ResourceManager {
2696
2764
  return this.upsert(new Guild(data));
2697
2765
  }
2698
2766
  async edit(id, options) {
2699
- const data = await this.#rest.patch(Routes.guild(id), options);
2767
+ const [payload, reason] = splitReason(options);
2768
+ const data = await this.#rest.patch(Routes.guild(id), payload, { reason });
2700
2769
  return this.upsert(new Guild(data));
2701
2770
  }
2702
- async deleteGuild(id) {
2771
+ async remove(id) {
2703
2772
  await this.#rest.delete(Routes.guild(id));
2704
2773
  }
2774
+ deleteGuild(id) {
2775
+ return this.remove(id);
2776
+ }
2705
2777
  async fetchPreview(id) {
2706
2778
  return this.#rest.get(Routes.guildPreview(id));
2707
2779
  }
@@ -2745,15 +2817,17 @@ class GuildManager extends ResourceManager {
2745
2817
  return new AutoModerationRule(rule);
2746
2818
  }
2747
2819
  async createAutoModerationRule(guildId, options) {
2748
- const rule = await this.#rest.post(Routes.guildAutoModerationRules(guildId), options);
2820
+ const [payload, reason] = splitReason(options);
2821
+ const rule = await this.#rest.post(Routes.guildAutoModerationRules(guildId), payload, { reason });
2749
2822
  return new AutoModerationRule(rule);
2750
2823
  }
2751
2824
  async editAutoModerationRule(guildId, ruleId, options) {
2752
- const rule = await this.#rest.patch(Routes.guildAutoModerationRule(guildId, ruleId), options);
2825
+ const [payload, reason] = splitReason(options);
2826
+ const rule = await this.#rest.patch(Routes.guildAutoModerationRule(guildId, ruleId), payload, { reason });
2753
2827
  return new AutoModerationRule(rule);
2754
2828
  }
2755
- async deleteAutoModerationRule(guildId, ruleId) {
2756
- await this.#rest.delete(Routes.guildAutoModerationRule(guildId, ruleId));
2829
+ async deleteAutoModerationRule(guildId, ruleId, reason) {
2830
+ await this.#rest.delete(Routes.guildAutoModerationRule(guildId, ruleId), { reason });
2757
2831
  }
2758
2832
  }
2759
2833
  var AuditLogEvent = {
@@ -2860,29 +2934,31 @@ class ChannelManager extends Manager {
2860
2934
  #context;
2861
2935
  #messageManagers = new Map;
2862
2936
  #messageCache;
2937
+ #allowedMentions;
2863
2938
  constructor(rest, options = {}) {
2864
2939
  super();
2865
2940
  this.#rest = rest;
2866
2941
  this.#messageCache = options.messageCache;
2942
+ this.#allowedMentions = options.allowedMentions;
2867
2943
  this.#context = {
2868
2944
  sendMessage: (channelId, options) => this.send(channelId, options),
2869
2945
  editMessage: (channelId, messageId, options) => this.editMessage(channelId, messageId, options),
2870
- deleteMessage: (channelId, messageId) => this.deleteMessage(channelId, messageId),
2946
+ deleteMessage: (channelId, messageId, reason) => this.deleteMessage(channelId, messageId, reason),
2871
2947
  crosspostMessage: (channelId, messageId) => this.crosspostMessage(channelId, messageId),
2872
2948
  editChannel: (channelId, options) => this.edit(channelId, options),
2873
- deleteChannel: (channelId) => this.deleteChannel(channelId),
2949
+ deleteChannel: (channelId, reason) => this.remove(channelId, reason),
2874
2950
  addReaction: (channelId, messageId, emoji) => this.addReaction(channelId, messageId, emoji),
2875
2951
  removeOwnReaction: (channelId, messageId, emoji) => this.removeOwnReaction(channelId, messageId, emoji),
2876
2952
  removeReaction: (channelId, messageId, emoji, userId) => this.removeReaction(channelId, messageId, emoji, userId),
2877
2953
  removeAllReactions: (channelId, messageId) => this.removeAllReactions(channelId, messageId),
2878
- pinMessage: (channelId, messageId) => this.pinMessage(channelId, messageId),
2879
- unpinMessage: (channelId, messageId) => this.unpinMessage(channelId, messageId)
2954
+ pinMessage: (channelId, messageId, reason) => this.pinMessage(channelId, messageId, reason),
2955
+ unpinMessage: (channelId, messageId, reason) => this.unpinMessage(channelId, messageId, reason)
2880
2956
  };
2881
2957
  }
2882
2958
  messages(channelId) {
2883
2959
  let manager = this.#messageManagers.get(channelId);
2884
2960
  if (!manager) {
2885
- manager = new MessageManager(this.#rest, this.#context, channelId, this.#messageCache);
2961
+ manager = new MessageManager(this.#rest, this.#context, channelId, this.#messageCache, this.#allowedMentions);
2886
2962
  this.#messageManagers.set(channelId, manager);
2887
2963
  }
2888
2964
  return manager;
@@ -2894,13 +2970,13 @@ class ChannelManager extends Manager {
2894
2970
  return new ThreadManager(this.#rest, this.#context, channelId);
2895
2971
  }
2896
2972
  fetch(channelId) {
2897
- return this.fetchOnce(channelId, async () => createChannel2(await this.#rest.get(Routes.channel(channelId)), this.#context), (channel) => this.#merge(channel));
2973
+ return this.fetchOnce(channelId, async () => createChannel(await this.#rest.get(Routes.channel(channelId)), this.#context), (channel) => this.#merge(channel));
2898
2974
  }
2899
2975
  async resolve(channelId) {
2900
2976
  return this.get(channelId) ?? this.fetch(channelId);
2901
2977
  }
2902
2978
  upsert(data) {
2903
- return this.#merge(createChannel2(data, this.#context));
2979
+ return this.#merge(createChannel(data, this.#context));
2904
2980
  }
2905
2981
  #merge(channel) {
2906
2982
  const existing = this.get(channel.id);
@@ -2946,15 +3022,20 @@ class ChannelManager extends Manager {
2946
3022
  return this.#messageManagers.get(channelId);
2947
3023
  }
2948
3024
  async create(guildId, options) {
2949
- return this.upsert(await this.#rest.post(Routes.guildChannels(guildId), options));
3025
+ const [payload, reason] = splitReason(options);
3026
+ return this.upsert(await this.#rest.post(Routes.guildChannels(guildId), payload, { reason }));
2950
3027
  }
2951
3028
  async edit(channelId, options) {
2952
- return this.upsert(await this.#rest.patch(Routes.channel(channelId), options));
3029
+ const [payload, reason] = splitReason(options);
3030
+ return this.upsert(await this.#rest.patch(Routes.channel(channelId), payload, { reason }));
2953
3031
  }
2954
- async deleteChannel(channelId) {
2955
- await this.#rest.delete(Routes.channel(channelId));
3032
+ async remove(channelId, reason) {
3033
+ await this.#rest.delete(Routes.channel(channelId), { reason });
2956
3034
  this.delete(channelId);
2957
3035
  }
3036
+ deleteChannel(channelId) {
3037
+ return this.remove(channelId);
3038
+ }
2958
3039
  delete(channelId) {
2959
3040
  this.#messageManagers.delete(channelId);
2960
3041
  return super.delete(channelId);
@@ -2988,10 +3069,12 @@ class ChannelManager extends Manager {
2988
3069
  return this.messages(data.channel_id).upsert(data);
2989
3070
  }
2990
3071
  async editMessage(channelId, messageId, options) {
2991
- return this.messages(channelId).upsert(await this.#rest.patch(Routes.message(channelId, messageId), toRequest(options)));
3072
+ return this.messages(channelId).upsert(await this.#rest.patch(Routes.message(channelId, messageId), toRequest(options, this.#allowedMentions)));
2992
3073
  }
2993
- async deleteMessage(channelId, messageId) {
2994
- await this.#rest.delete(Routes.message(channelId, messageId));
3074
+ async deleteMessage(channelId, messageId, reason) {
3075
+ await this.#rest.delete(Routes.message(channelId, messageId), {
3076
+ reason
3077
+ });
2995
3078
  this.messages(channelId).delete(messageId);
2996
3079
  }
2997
3080
  deleteCachedMessage(channelId, messageId) {
@@ -3000,19 +3083,17 @@ class ChannelManager extends Manager {
3000
3083
  async crosspostMessage(channelId, messageId) {
3001
3084
  return this.messages(channelId).upsert(await this.#rest.post(Routes.crosspostMessage(channelId, messageId)));
3002
3085
  }
3003
- async bulkDeleteMessages(channelId, messageIds) {
3086
+ async bulkDeleteMessages(channelId, messageIds, reason) {
3004
3087
  const ids = [...new Set(messageIds)];
3005
3088
  if (ids.length < 1 || ids.length > 100)
3006
3089
  throw new RangeError("bulkDelete requires between 1 and 100 message IDs.");
3007
3090
  if (ids.length === 1)
3008
- return this.deleteMessage(channelId, ids[0]);
3091
+ return this.deleteMessage(channelId, ids[0], reason);
3009
3092
  const cutoff = Date.now() - BULK_DELETE_MAX_AGE_MS;
3010
3093
  const tooOld = ids.filter((id) => snowflakeTime(id) < cutoff);
3011
3094
  if (tooOld.length)
3012
3095
  throw new RangeError(`bulkDelete cannot delete messages older than 14 days: ${tooOld.join(", ")}`);
3013
- await this.#rest.post(Routes.channelBulkDelete(channelId), {
3014
- messages: ids
3015
- });
3096
+ await this.#rest.post(Routes.channelBulkDelete(channelId), { messages: ids }, { reason });
3016
3097
  for (const id of ids)
3017
3098
  this.messages(channelId).delete(id);
3018
3099
  }
@@ -3055,14 +3136,20 @@ class ChannelManager extends Manager {
3055
3136
  await this.#rest.delete(Routes.messageReactionsAll(channelId, messageId));
3056
3137
  }
3057
3138
  async fetchPinnedMessages(channelId) {
3058
- const data = await this.#rest.get(Routes.channelPins(channelId));
3059
- return data.map((item) => this.messages(channelId).upsert(item));
3139
+ const data = await this.#rest.get(Routes.channelMessagesPins(channelId));
3140
+ return data.items.map((item) => this.messages(channelId).upsert(item.message));
3141
+ }
3142
+ async pinMessage(channelId, messageId, reason) {
3143
+ await this.#rest.put(Routes.channelMessagesPin(channelId, messageId), undefined, { reason });
3060
3144
  }
3061
- async pinMessage(channelId, messageId) {
3062
- await this.#rest.put(Routes.channelPin(channelId, messageId));
3145
+ async unpinMessage(channelId, messageId, reason) {
3146
+ await this.#rest.delete(Routes.channelMessagesPin(channelId, messageId), { reason });
3063
3147
  }
3064
- async unpinMessage(channelId, messageId) {
3065
- await this.#rest.delete(Routes.channelPin(channelId, messageId));
3148
+ async createWebhook(channelId, options) {
3149
+ const [payload, reason] = splitReason(options);
3150
+ return this.#rest.post(Routes.channelWebhooks(channelId), payload, {
3151
+ reason
3152
+ });
3066
3153
  }
3067
3154
  createThreadFromMessage(channelId, messageId, options) {
3068
3155
  return this.threads(channelId).createFromMessage(messageId, options);
@@ -3080,7 +3167,7 @@ class ChannelManager extends Manager {
3080
3167
  hasMore: messages.length === limit
3081
3168
  };
3082
3169
  }
3083
- async bulkDelete(channelId, messageIds) {
3170
+ bulkDelete(channelId, messageIds) {
3084
3171
  return this.bulkDeleteMessages(channelId, messageIds);
3085
3172
  }
3086
3173
  clear() {
@@ -3115,4 +3202,4 @@ export {
3115
3202
  toRequest
3116
3203
  };
3117
3204
 
3118
- //# debugId=6C6CF1CF95B4E3CA64756E2164756E21
3205
+ //# debugId=1B8C9372B2A05B6E64756E2164756E21