lunibee 0.2.2 → 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 (43) hide show
  1. package/dist/builders/attachment.d.ts +2 -2
  2. package/dist/builders/commands.d.ts +39 -36
  3. package/dist/builders/components.d.ts +44 -44
  4. package/dist/builders/embed.d.ts +2 -2
  5. package/dist/builders/index.d.ts +1 -1
  6. package/dist/builders/index.js +12 -3
  7. package/dist/builders/index.js.map +7 -7
  8. package/dist/core/index.d.ts +1 -0
  9. package/dist/core/index.js +196 -96
  10. package/dist/core/index.js.map +21 -21
  11. package/dist/core/permissions.d.ts +2 -2
  12. package/dist/index.js +254 -105
  13. package/dist/index.js.map +29 -28
  14. package/dist/managers/base.d.ts +4 -0
  15. package/dist/managers/emoji.d.ts +7 -1
  16. package/dist/managers/guild-resources.d.ts +11 -3
  17. package/dist/managers/guild.d.ts +13 -5
  18. package/dist/managers/index.d.ts +26 -13
  19. package/dist/managers/index.js +139 -68
  20. package/dist/managers/index.js.map +16 -16
  21. package/dist/managers/member.d.ts +5 -3
  22. package/dist/managers/role.d.ts +13 -1
  23. package/dist/rest/error-codes.d.ts +48 -0
  24. package/dist/rest/errors.d.ts +1 -0
  25. package/dist/rest/index.d.ts +1 -0
  26. package/dist/rest/index.js +53 -3
  27. package/dist/rest/index.js.map +7 -6
  28. package/dist/rest/routes.d.ts +4 -2
  29. package/dist/sharding/index.js +6 -6
  30. package/dist/sharding/index.js.map +4 -4
  31. package/dist/structures/base.d.ts +18 -9
  32. package/dist/structures/index.d.ts +6 -6
  33. package/dist/structures/index.js +74 -42
  34. package/dist/structures/index.js.map +11 -11
  35. package/dist/structures/interactions.d.ts +2 -2
  36. package/dist/structures/resources.d.ts +2 -2
  37. package/dist/types/index.d.ts +43 -18
  38. package/dist/types/index.js.map +2 -2
  39. package/dist/voice/index.js +4 -3
  40. package/dist/voice/index.js.map +3 -3
  41. package/dist/ws/index.js +1 -1
  42. package/dist/ws/index.js.map +3 -3
  43. 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.2",
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)
@@ -1930,10 +1957,10 @@ class Message extends BaseStructure {
1930
1957
  update(options) {
1931
1958
  return this.edit(options);
1932
1959
  }
1933
- delete() {
1960
+ delete(reason) {
1934
1961
  if (!this.#context)
1935
1962
  throw new Error("This message is not attached to a client.");
1936
- return this.#context.deleteMessage(this.channelId, this.id);
1963
+ return this.#context.deleteMessage(this.channelId, this.id, reason);
1937
1964
  }
1938
1965
  reply(options) {
1939
1966
  if (!this.#context)
@@ -1980,15 +2007,15 @@ class Message extends BaseStructure {
1980
2007
  throw new Error("This message is not attached to a client.");
1981
2008
  return this.#context.removeAllReactions(this.channelId, this.id);
1982
2009
  }
1983
- pin() {
2010
+ pin(reason) {
1984
2011
  if (!this.#context?.pinMessage)
1985
2012
  throw new Error("This message is not attached to a client.");
1986
- return this.#context.pinMessage(this.channelId, this.id);
2013
+ return this.#context.pinMessage(this.channelId, this.id, reason);
1987
2014
  }
1988
- unpin() {
2015
+ unpin(reason) {
1989
2016
  if (!this.#context?.unpinMessage)
1990
2017
  throw new Error("This message is not attached to a client.");
1991
- return this.#context.unpinMessage(this.channelId, this.id);
2018
+ return this.#context.unpinMessage(this.channelId, this.id, reason);
1992
2019
  }
1993
2020
  get isEphemeral() {
1994
2021
  return (this.flags & 64) !== 0;
@@ -2167,15 +2194,22 @@ class EmojiManager extends Manager {
2167
2194
  return data.map((item) => this.upsert(item));
2168
2195
  }
2169
2196
  async create(options) {
2170
- 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 }));
2171
2199
  }
2172
2200
  async edit(emojiId, options) {
2173
- 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 }));
2174
2203
  }
2175
- async deleteEmoji(emojiId) {
2176
- 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
+ });
2177
2208
  this.delete(emojiId);
2178
2209
  }
2210
+ deleteEmoji(emojiId) {
2211
+ return this.remove(emojiId);
2212
+ }
2179
2213
  upsert(data) {
2180
2214
  const key = data.id != null ? data.id : `unicode:${data.name ?? ""}`;
2181
2215
  return this.#merge(key, new Emoji2(data));
@@ -2379,11 +2413,16 @@ class GuildMemberManager extends ResourceManager {
2379
2413
  await this.#rest.put(Routes.guildBan(this.guildId, userId), { delete_message_seconds: options.deleteMessageSeconds }, { reason: options.reason });
2380
2414
  this.delete(userId);
2381
2415
  }
2382
- async unban(userId) {
2383
- 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
+ });
2384
2420
  }
2385
2421
  async edit(userId, options, reason) {
2386
- 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
+ });
2387
2426
  const member = new GuildMember({ ...data, guild_id: this.guildId }, this.#context());
2388
2427
  this.set(member.user.id, member);
2389
2428
  return member;
@@ -2422,7 +2461,7 @@ class RoleManager extends ResourceManager {
2422
2461
  const data = await this.#rest.post(Routes.guildRoles(this.guildId), {
2423
2462
  ...payload,
2424
2463
  permissions: payload.permissions !== undefined ? String(payload.permissions) : undefined
2425
- });
2464
+ }, { reason });
2426
2465
  const role = new Role(data);
2427
2466
  this.set(role.id, role);
2428
2467
  return role;
@@ -2432,15 +2471,28 @@ class RoleManager extends ResourceManager {
2432
2471
  const data = await this.#rest.patch(Routes.guildRole(this.guildId, roleId), {
2433
2472
  ...payload,
2434
2473
  permissions: payload.permissions !== undefined ? String(payload.permissions) : undefined
2435
- });
2474
+ }, { reason });
2436
2475
  const role = new Role(data);
2437
2476
  this.set(role.id, role);
2438
2477
  return role;
2439
2478
  }
2440
- async deleteRole(roleId) {
2441
- 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
+ });
2442
2483
  this.delete(roleId);
2443
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
+ }
2444
2496
  }
2445
2497
 
2446
2498
  // packages/managers/src/guild-resources.ts
@@ -2512,13 +2564,15 @@ class GuildScheduledEventManager extends Manager {
2512
2564
  return events.map((event) => this.#store(event));
2513
2565
  }
2514
2566
  async create(options, reason) {
2515
- 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 }));
2516
2569
  }
2517
2570
  async edit(eventId, options, reason) {
2518
- 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 }));
2519
2573
  }
2520
- async remove(eventId) {
2521
- 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 });
2522
2576
  this.delete(eventId);
2523
2577
  }
2524
2578
  async fetchSubscribers(eventId, options = {}) {
@@ -2549,13 +2603,13 @@ class StageInstanceManager extends Manager {
2549
2603
  privacy_level: options.privacyLevel,
2550
2604
  send_start_notification: options.sendStartNotification,
2551
2605
  guild_scheduled_event_id: options.guildScheduledEventId
2552
- }, { reason }));
2606
+ }, { reason: options.reason ?? reason }));
2553
2607
  }
2554
2608
  async fetch(channelId) {
2555
2609
  return this.#store(await this.#rest.get(Routes.stageInstanceByChannel(channelId)));
2556
2610
  }
2557
2611
  async edit(channelId, options, reason) {
2558
- 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 }));
2559
2613
  }
2560
2614
  async remove(channelId, reason) {
2561
2615
  await this.#rest.delete(Routes.stageInstanceByChannel(channelId), {
@@ -2592,7 +2646,7 @@ class PermissionOverwriteManager {
2592
2646
  type: options.type,
2593
2647
  allow: BigInt(options.allow ?? 0).toString(),
2594
2648
  deny: BigInt(options.deny ?? 0).toString()
2595
- }, { reason });
2649
+ }, { reason: options.reason ?? reason });
2596
2650
  }
2597
2651
  async remove(overwriteId, reason) {
2598
2652
  await this.#rest.delete(Routes.channelPermission(this.channelId, overwriteId), { reason });
@@ -2710,12 +2764,16 @@ class GuildManager extends ResourceManager {
2710
2764
  return this.upsert(new Guild(data));
2711
2765
  }
2712
2766
  async edit(id, options) {
2713
- 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 });
2714
2769
  return this.upsert(new Guild(data));
2715
2770
  }
2716
- async deleteGuild(id) {
2771
+ async remove(id) {
2717
2772
  await this.#rest.delete(Routes.guild(id));
2718
2773
  }
2774
+ deleteGuild(id) {
2775
+ return this.remove(id);
2776
+ }
2719
2777
  async fetchPreview(id) {
2720
2778
  return this.#rest.get(Routes.guildPreview(id));
2721
2779
  }
@@ -2759,15 +2817,17 @@ class GuildManager extends ResourceManager {
2759
2817
  return new AutoModerationRule(rule);
2760
2818
  }
2761
2819
  async createAutoModerationRule(guildId, options) {
2762
- 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 });
2763
2822
  return new AutoModerationRule(rule);
2764
2823
  }
2765
2824
  async editAutoModerationRule(guildId, ruleId, options) {
2766
- 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 });
2767
2827
  return new AutoModerationRule(rule);
2768
2828
  }
2769
- async deleteAutoModerationRule(guildId, ruleId) {
2770
- await this.#rest.delete(Routes.guildAutoModerationRule(guildId, ruleId));
2829
+ async deleteAutoModerationRule(guildId, ruleId, reason) {
2830
+ await this.#rest.delete(Routes.guildAutoModerationRule(guildId, ruleId), { reason });
2771
2831
  }
2772
2832
  }
2773
2833
  var AuditLogEvent = {
@@ -2883,16 +2943,16 @@ class ChannelManager extends Manager {
2883
2943
  this.#context = {
2884
2944
  sendMessage: (channelId, options) => this.send(channelId, options),
2885
2945
  editMessage: (channelId, messageId, options) => this.editMessage(channelId, messageId, options),
2886
- deleteMessage: (channelId, messageId) => this.deleteMessage(channelId, messageId),
2946
+ deleteMessage: (channelId, messageId, reason) => this.deleteMessage(channelId, messageId, reason),
2887
2947
  crosspostMessage: (channelId, messageId) => this.crosspostMessage(channelId, messageId),
2888
2948
  editChannel: (channelId, options) => this.edit(channelId, options),
2889
- deleteChannel: (channelId) => this.deleteChannel(channelId),
2949
+ deleteChannel: (channelId, reason) => this.remove(channelId, reason),
2890
2950
  addReaction: (channelId, messageId, emoji) => this.addReaction(channelId, messageId, emoji),
2891
2951
  removeOwnReaction: (channelId, messageId, emoji) => this.removeOwnReaction(channelId, messageId, emoji),
2892
2952
  removeReaction: (channelId, messageId, emoji, userId) => this.removeReaction(channelId, messageId, emoji, userId),
2893
2953
  removeAllReactions: (channelId, messageId) => this.removeAllReactions(channelId, messageId),
2894
- pinMessage: (channelId, messageId) => this.pinMessage(channelId, messageId),
2895
- 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)
2896
2956
  };
2897
2957
  }
2898
2958
  messages(channelId) {
@@ -2962,15 +3022,20 @@ class ChannelManager extends Manager {
2962
3022
  return this.#messageManagers.get(channelId);
2963
3023
  }
2964
3024
  async create(guildId, options) {
2965
- 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 }));
2966
3027
  }
2967
3028
  async edit(channelId, options) {
2968
- 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 }));
2969
3031
  }
2970
- async deleteChannel(channelId) {
2971
- await this.#rest.delete(Routes.channel(channelId));
3032
+ async remove(channelId, reason) {
3033
+ await this.#rest.delete(Routes.channel(channelId), { reason });
2972
3034
  this.delete(channelId);
2973
3035
  }
3036
+ deleteChannel(channelId) {
3037
+ return this.remove(channelId);
3038
+ }
2974
3039
  delete(channelId) {
2975
3040
  this.#messageManagers.delete(channelId);
2976
3041
  return super.delete(channelId);
@@ -3006,8 +3071,10 @@ class ChannelManager extends Manager {
3006
3071
  async editMessage(channelId, messageId, options) {
3007
3072
  return this.messages(channelId).upsert(await this.#rest.patch(Routes.message(channelId, messageId), toRequest(options, this.#allowedMentions)));
3008
3073
  }
3009
- async deleteMessage(channelId, messageId) {
3010
- 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
+ });
3011
3078
  this.messages(channelId).delete(messageId);
3012
3079
  }
3013
3080
  deleteCachedMessage(channelId, messageId) {
@@ -3016,19 +3083,17 @@ class ChannelManager extends Manager {
3016
3083
  async crosspostMessage(channelId, messageId) {
3017
3084
  return this.messages(channelId).upsert(await this.#rest.post(Routes.crosspostMessage(channelId, messageId)));
3018
3085
  }
3019
- async bulkDeleteMessages(channelId, messageIds) {
3086
+ async bulkDeleteMessages(channelId, messageIds, reason) {
3020
3087
  const ids = [...new Set(messageIds)];
3021
3088
  if (ids.length < 1 || ids.length > 100)
3022
3089
  throw new RangeError("bulkDelete requires between 1 and 100 message IDs.");
3023
3090
  if (ids.length === 1)
3024
- return this.deleteMessage(channelId, ids[0]);
3091
+ return this.deleteMessage(channelId, ids[0], reason);
3025
3092
  const cutoff = Date.now() - BULK_DELETE_MAX_AGE_MS;
3026
3093
  const tooOld = ids.filter((id) => snowflakeTime(id) < cutoff);
3027
3094
  if (tooOld.length)
3028
3095
  throw new RangeError(`bulkDelete cannot delete messages older than 14 days: ${tooOld.join(", ")}`);
3029
- await this.#rest.post(Routes.channelBulkDelete(channelId), {
3030
- messages: ids
3031
- });
3096
+ await this.#rest.post(Routes.channelBulkDelete(channelId), { messages: ids }, { reason });
3032
3097
  for (const id of ids)
3033
3098
  this.messages(channelId).delete(id);
3034
3099
  }
@@ -3071,14 +3136,20 @@ class ChannelManager extends Manager {
3071
3136
  await this.#rest.delete(Routes.messageReactionsAll(channelId, messageId));
3072
3137
  }
3073
3138
  async fetchPinnedMessages(channelId) {
3074
- const data = await this.#rest.get(Routes.channelPins(channelId));
3075
- 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 });
3076
3144
  }
3077
- async pinMessage(channelId, messageId) {
3078
- await this.#rest.put(Routes.channelPin(channelId, messageId));
3145
+ async unpinMessage(channelId, messageId, reason) {
3146
+ await this.#rest.delete(Routes.channelMessagesPin(channelId, messageId), { reason });
3079
3147
  }
3080
- async unpinMessage(channelId, messageId) {
3081
- 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
+ });
3082
3153
  }
3083
3154
  createThreadFromMessage(channelId, messageId, options) {
3084
3155
  return this.threads(channelId).createFromMessage(messageId, options);
@@ -3096,7 +3167,7 @@ class ChannelManager extends Manager {
3096
3167
  hasMore: messages.length === limit
3097
3168
  };
3098
3169
  }
3099
- async bulkDelete(channelId, messageIds) {
3170
+ bulkDelete(channelId, messageIds) {
3100
3171
  return this.bulkDeleteMessages(channelId, messageIds);
3101
3172
  }
3102
3173
  clear() {
@@ -3131,4 +3202,4 @@ export {
3131
3202
  toRequest
3132
3203
  };
3133
3204
 
3134
- //# debugId=EB58705923B2D19264756E2164756E21
3205
+ //# debugId=1B8C9372B2A05B6E64756E2164756E21