lunibee 0.2.1 → 0.2.2

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.
package/dist/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  // @bun
2
2
  // packages/core/src/permissions.ts
3
- var PermissionOverwriteType;
4
- ((PermissionOverwriteType) => {
5
- PermissionOverwriteType[PermissionOverwriteType["Role"] = 0] = "Role";
6
- PermissionOverwriteType[PermissionOverwriteType["Member"] = 1] = "Member";
7
- })(PermissionOverwriteType ||= {});
3
+ var PermissionOverwriteEnum;
4
+ ((PermissionOverwriteEnum) => {
5
+ PermissionOverwriteEnum[PermissionOverwriteEnum["Role"] = 0] = "Role";
6
+ PermissionOverwriteEnum[PermissionOverwriteEnum["Member"] = 1] = "Member";
7
+ })(PermissionOverwriteEnum ||= {});
8
+ var PermissionOverwriteType = PermissionOverwriteEnum;
8
9
  var Permission = {
9
10
  createInstantInvite: 1n << 0n,
10
11
  kickMembers: 1n << 1n,
@@ -814,7 +815,7 @@ var MessageFlags = {
814
815
  Loading: 128,
815
816
  IsComponentsV2: 32768
816
817
  };
817
- var ChannelType = {
818
+ var ChannelEnum = {
818
819
  GuildText: 0,
819
820
  DM: 1,
820
821
  GuildVoice: 2,
@@ -829,7 +830,7 @@ var ChannelType = {
829
830
  GuildForum: 15,
830
831
  GuildMedia: 16
831
832
  };
832
- var ButtonStyle = {
833
+ var ButtonType = {
833
834
  Primary: 1,
834
835
  Secondary: 2,
835
836
  Success: 3,
@@ -837,7 +838,7 @@ var ButtonStyle = {
837
838
  Link: 5,
838
839
  Premium: 6
839
840
  };
840
- var InteractionResponseType = {
841
+ var InteractionResponseEnum = {
841
842
  Pong: 1,
842
843
  ChannelMessage: 4,
843
844
  DeferredChannelMessage: 5,
@@ -846,13 +847,13 @@ var InteractionResponseType = {
846
847
  Autocomplete: 8,
847
848
  Modal: 9
848
849
  };
849
- var StickerFormatType = {
850
+ var StickerFormatEnum = {
850
851
  PNG: 1,
851
852
  APNG: 2,
852
853
  Lottie: 3,
853
854
  GIF: 4
854
855
  };
855
- var StickerType = {
856
+ var StickerEnum = {
856
857
  Standard: 1,
857
858
  Guild: 2
858
859
  };
@@ -869,7 +870,15 @@ var PremiumTier = {
869
870
  Tier2: 2,
870
871
  Tier3: 3
871
872
  };
872
- var ApplicationCommandOptionType = {
873
+ var ActivityEnum = {
874
+ Playing: 0,
875
+ Streaming: 1,
876
+ Listening: 2,
877
+ Watching: 3,
878
+ Custom: 4,
879
+ Competing: 5
880
+ };
881
+ var ApplicationCommandOptionEnum = {
873
882
  SubCommand: 1,
874
883
  SubCommandGroup: 2,
875
884
  String: 3,
@@ -882,11 +891,17 @@ var ApplicationCommandOptionType = {
882
891
  Number: 10,
883
892
  Attachment: 11
884
893
  };
885
- var ApplicationCommandType = {
894
+ var ApplicationCommandEnum = {
886
895
  ChatInput: 1,
887
896
  User: 2,
888
897
  Message: 3
889
898
  };
899
+ var ChannelType = ChannelEnum;
900
+ var InteractionResponseType = InteractionResponseEnum;
901
+ var ApplicationCommandType = ApplicationCommandEnum;
902
+ var ApplicationCommandOptionType = ApplicationCommandOptionEnum;
903
+ var StickerType = StickerEnum;
904
+ var StickerFormatType = StickerFormatEnum;
890
905
  // packages/collection/src/cache.ts
891
906
  class Cache {
892
907
  #entries = new Collection;
@@ -1635,7 +1650,7 @@ class ResourceManager extends Manager {
1635
1650
  // packages/rest/package.json
1636
1651
  var package_default = {
1637
1652
  name: "@lunibee/rest",
1638
- version: "0.2.1",
1653
+ version: "0.2.2",
1639
1654
  type: "module",
1640
1655
  module: "./src/index.ts",
1641
1656
  types: "./src/index.ts",
@@ -2942,7 +2957,7 @@ class Invite {
2942
2957
  return this.url;
2943
2958
  }
2944
2959
  }
2945
- var WebhookType = {
2960
+ var WebhookEnum = {
2946
2961
  Incoming: 1,
2947
2962
  ChannelFollower: 2,
2948
2963
  Application: 3
@@ -2958,7 +2973,7 @@ class Webhook extends BaseStructure {
2958
2973
  token;
2959
2974
  constructor(data) {
2960
2975
  super(data.id);
2961
- this.type = data.type ?? WebhookType.Incoming;
2976
+ this.type = data.type ?? WebhookEnum.Incoming;
2962
2977
  this.name = data.name ?? null;
2963
2978
  this.avatarHash = data.avatar ?? null;
2964
2979
  this.channelId = data.channel_id ?? null;
@@ -3123,6 +3138,7 @@ class GuildOnboarding extends BaseStructure {
3123
3138
  this.mode = data.mode;
3124
3139
  }
3125
3140
  }
3141
+ var WebhookType = WebhookEnum;
3126
3142
  // packages/structures/src/channels.ts
3127
3143
  class NewsChannel extends TextChannel {
3128
3144
  }
@@ -3402,7 +3418,7 @@ class CommandOptions {
3402
3418
  }
3403
3419
  }
3404
3420
  // packages/structures/src/interactions.ts
3405
- var InteractionType = {
3421
+ var InteractionEnum = {
3406
3422
  Ping: 1,
3407
3423
  ApplicationCommand: 2,
3408
3424
  MessageComponent: 3,
@@ -3410,8 +3426,17 @@ var InteractionType = {
3410
3426
  ModalSubmit: 5
3411
3427
  };
3412
3428
  var EPHEMERAL = 64;
3429
+ var COMMAND_CHAT_INPUT = 1;
3430
+ var COMMAND_USER = 2;
3431
+ var COMMAND_MESSAGE = 3;
3413
3432
  var TOKEN_LIFETIME_MS = 15 * 60000;
3414
3433
  var DISCORD_EPOCH = 1420070400000n;
3434
+ function splitWithResponse(options) {
3435
+ if (typeof options === "string")
3436
+ return { withResponse: false, rest: options };
3437
+ const { withResponse, ...rest } = options;
3438
+ return { withResponse: withResponse === true, rest };
3439
+ }
3415
3440
  function toMessageData(options) {
3416
3441
  if (typeof options === "string")
3417
3442
  return { content: options };
@@ -3424,6 +3449,7 @@ function toMessageData(options) {
3424
3449
  class InteractionResponse {
3425
3450
  type;
3426
3451
  data;
3452
+ withResponse = false;
3427
3453
  constructor(type, data) {
3428
3454
  if (!Number.isFinite(type))
3429
3455
  throw new TypeError("Interaction response type must be finite.");
@@ -3434,13 +3460,13 @@ class InteractionResponse {
3434
3460
  return this.data === undefined ? { type: this.type } : { type: this.type, data: this.data };
3435
3461
  }
3436
3462
  static message(options) {
3437
- return new InteractionResponse(InteractionResponseType.ChannelMessage, toMessageData(options));
3463
+ return new InteractionResponse(InteractionResponseEnum.ChannelMessage, toMessageData(options));
3438
3464
  }
3439
3465
  static defer(ephemeral = false) {
3440
- return new InteractionResponse(InteractionResponseType.DeferredChannelMessage, ephemeral ? { flags: EPHEMERAL } : undefined);
3466
+ return new InteractionResponse(InteractionResponseEnum.DeferredChannelMessage, ephemeral ? { flags: EPHEMERAL } : undefined);
3441
3467
  }
3442
3468
  static pong() {
3443
- return new InteractionResponse(InteractionResponseType.Pong);
3469
+ return new InteractionResponse(InteractionResponseEnum.Pong);
3444
3470
  }
3445
3471
  }
3446
3472
 
@@ -3468,8 +3494,30 @@ class Interaction {
3468
3494
  this.type = data.type;
3469
3495
  this.data = data;
3470
3496
  }
3497
+ #commandType() {
3498
+ if (this.type !== InteractionEnum.ApplicationCommand)
3499
+ return 0;
3500
+ const type = this.data.data?.type;
3501
+ return typeof type === "number" ? type : COMMAND_CHAT_INPUT;
3502
+ }
3503
+ isCommand() {
3504
+ return this.type === InteractionEnum.ApplicationCommand;
3505
+ }
3471
3506
  isChatInputCommand() {
3472
- return this.type === InteractionType.ApplicationCommand;
3507
+ return this.#commandType() === COMMAND_CHAT_INPUT;
3508
+ }
3509
+ isContextMenuCommand() {
3510
+ const type = this.#commandType();
3511
+ return type === COMMAND_USER || type === COMMAND_MESSAGE;
3512
+ }
3513
+ isUserContextMenuCommand() {
3514
+ return this.#commandType() === COMMAND_USER;
3515
+ }
3516
+ isMessageContextMenuCommand() {
3517
+ return this.#commandType() === COMMAND_MESSAGE;
3518
+ }
3519
+ get resourceContext() {
3520
+ return this.#client.resourceContext;
3473
3521
  }
3474
3522
  awaitModalSubmit(options) {
3475
3523
  const collect = this.#client.resourceContext?.collectInteractions;
@@ -3486,13 +3534,13 @@ class Interaction {
3486
3534
  return collector.next();
3487
3535
  }
3488
3536
  isMessageComponent() {
3489
- return this.type === InteractionType.MessageComponent;
3537
+ return this.type === InteractionEnum.MessageComponent;
3490
3538
  }
3491
3539
  isModalSubmit() {
3492
- return this.type === InteractionType.ModalSubmit;
3540
+ return this.type === InteractionEnum.ModalSubmit;
3493
3541
  }
3494
3542
  isAutocomplete() {
3495
- return this.type === InteractionType.ApplicationCommandAutocomplete;
3543
+ return this.type === InteractionEnum.ApplicationCommandAutocomplete;
3496
3544
  }
3497
3545
  #componentType() {
3498
3546
  return this.isMessageComponent() ? this.data.data?.component_type ?? 0 : 0;
@@ -3577,12 +3625,24 @@ class Interaction {
3577
3625
  postResponse(response) {
3578
3626
  return this.#client.postInteractionResponse(this.id, this.token, response);
3579
3627
  }
3628
+ async acknowledgeWith(response, state, withResponse) {
3629
+ response.withResponse = withResponse;
3630
+ const result = await this.acknowledge(response, state);
3631
+ if (!withResponse)
3632
+ return result;
3633
+ const message = result?.resource?.message;
3634
+ return message ? new Message(message, this.#client.resourceContext) : null;
3635
+ }
3580
3636
  async reply(options) {
3581
- return this.acknowledge(InteractionResponse.message(toMessageData(options)), "replied");
3637
+ const { withResponse, rest } = splitWithResponse(options);
3638
+ return this.acknowledgeWith(InteractionResponse.message(toMessageData(rest)), "replied", withResponse);
3582
3639
  }
3583
3640
  async deferReply(options = false) {
3584
3641
  const ephemeral = typeof options === "boolean" ? options : options.ephemeral === true;
3585
- await this.acknowledge(InteractionResponse.defer(ephemeral), "deferred");
3642
+ const withResponse = typeof options === "object" && options.withResponse === true;
3643
+ const result = await this.acknowledgeWith(InteractionResponse.defer(ephemeral), "deferred", withResponse);
3644
+ if (withResponse)
3645
+ return result;
3586
3646
  }
3587
3647
  editReply(options) {
3588
3648
  this.assertAcknowledged();
@@ -3596,11 +3656,12 @@ class Interaction {
3596
3656
  return this.#client.followUpInteraction(this.token, toMessageData(options));
3597
3657
  }
3598
3658
  async update(options) {
3599
- return this.acknowledge(new InteractionResponse(InteractionResponseType.MessageUpdate, toMessageData(options)), "replied");
3659
+ const { withResponse, rest } = splitWithResponse(options);
3660
+ return this.acknowledgeWith(new InteractionResponse(InteractionResponseEnum.MessageUpdate, toMessageData(rest)), "replied", withResponse);
3600
3661
  }
3601
3662
  async showModal(modal) {
3602
3663
  const data = "toJSON" in modal && typeof modal.toJSON === "function" ? modal.toJSON() : modal;
3603
- return this.acknowledge(new InteractionResponse(InteractionResponseType.Modal, data), "replied");
3664
+ return this.acknowledge(new InteractionResponse(InteractionResponseEnum.Modal, data), "replied");
3604
3665
  }
3605
3666
  }
3606
3667
 
@@ -3617,6 +3678,38 @@ class CommandInteraction extends Interaction {
3617
3678
  }
3618
3679
  }
3619
3680
 
3681
+ class ContextMenuCommandInteraction extends CommandInteraction {
3682
+ #resolved() {
3683
+ return this.data.data?.resolved ?? {};
3684
+ }
3685
+ get targetId() {
3686
+ const id = this.data.data?.target_id;
3687
+ return typeof id === "string" ? id : null;
3688
+ }
3689
+ get targetUser() {
3690
+ const id = this.targetId;
3691
+ const raw = id ? this.#resolved().users?.[id] : undefined;
3692
+ return raw ? new User(raw) : null;
3693
+ }
3694
+ get targetMember() {
3695
+ const id = this.targetId;
3696
+ const raw = id ? this.#resolved().members?.[id] : undefined;
3697
+ const user = id ? this.#resolved().users?.[id] : undefined;
3698
+ if (!raw || !user || !this.guildId)
3699
+ return null;
3700
+ return new GuildMember({
3701
+ ...raw,
3702
+ user,
3703
+ guild_id: this.guildId
3704
+ }, this.resourceContext);
3705
+ }
3706
+ get targetMessage() {
3707
+ const id = this.targetId;
3708
+ const raw = id ? this.#resolved().messages?.[id] : undefined;
3709
+ return raw ? new Message(raw, this.resourceContext) : null;
3710
+ }
3711
+ }
3712
+
3620
3713
  class ComponentInteraction extends Interaction {
3621
3714
  get customId() {
3622
3715
  return this.data?.data?.custom_id ?? "";
@@ -3630,11 +3723,11 @@ class ComponentInteraction extends Interaction {
3630
3723
  get values() {
3631
3724
  return this.data?.data?.values ?? [];
3632
3725
  }
3633
- async deferUpdate() {
3634
- await this.acknowledge(new InteractionResponse(InteractionResponseType.DeferredMessageUpdate), "deferred");
3635
- }
3636
- async update(options) {
3637
- return this.acknowledge(new InteractionResponse(InteractionResponseType.MessageUpdate, toMessageData(options)), "replied");
3726
+ async deferUpdate(options = {}) {
3727
+ const withResponse = options.withResponse === true;
3728
+ const result = await this.acknowledgeWith(new InteractionResponse(InteractionResponseEnum.DeferredMessageUpdate), "deferred", withResponse);
3729
+ if (withResponse)
3730
+ return result;
3638
3731
  }
3639
3732
  }
3640
3733
 
@@ -3676,7 +3769,7 @@ class AutocompleteInteraction extends Interaction {
3676
3769
  async respond(choices) {
3677
3770
  if (!Array.isArray(choices))
3678
3771
  throw new TypeError("Autocomplete choices must be an array.");
3679
- const response = new InteractionResponse(InteractionResponseType.Autocomplete, { choices });
3772
+ const response = new InteractionResponse(InteractionResponseEnum.Autocomplete, { choices });
3680
3773
  await this.acknowledge(response, "replied");
3681
3774
  }
3682
3775
  }
@@ -3694,18 +3787,21 @@ function findFocused(options) {
3694
3787
  }
3695
3788
  function createInteraction(client, data) {
3696
3789
  switch (data.type) {
3697
- case InteractionType.ApplicationCommand:
3698
- return new CommandInteraction(client, data);
3699
- case InteractionType.ApplicationCommandAutocomplete:
3790
+ case InteractionEnum.ApplicationCommand: {
3791
+ const commandType = data.data?.type;
3792
+ return commandType === COMMAND_USER || commandType === COMMAND_MESSAGE ? new ContextMenuCommandInteraction(client, data) : new CommandInteraction(client, data);
3793
+ }
3794
+ case InteractionEnum.ApplicationCommandAutocomplete:
3700
3795
  return new AutocompleteInteraction(client, data);
3701
- case InteractionType.MessageComponent:
3796
+ case InteractionEnum.MessageComponent:
3702
3797
  return new ComponentInteraction(client, data);
3703
- case InteractionType.ModalSubmit:
3798
+ case InteractionEnum.ModalSubmit:
3704
3799
  return new ModalSubmitInteraction(client, data);
3705
3800
  default:
3706
3801
  return new Interaction(client, data);
3707
3802
  }
3708
3803
  }
3804
+ var InteractionType = InteractionEnum;
3709
3805
  // packages/structures/src/embed.ts
3710
3806
  class Embed {
3711
3807
  #data;
@@ -3895,6 +3991,9 @@ class Message extends BaseStructure {
3895
3991
  reference;
3896
3992
  components;
3897
3993
  referencedMessage;
3994
+ stickers;
3995
+ poll;
3996
+ messageSnapshots;
3898
3997
  member;
3899
3998
  #context;
3900
3999
  constructor(data, context) {
@@ -3916,6 +4015,13 @@ class Message extends BaseStructure {
3916
4015
  this.mentionEveryone = data.mention_everyone ?? false;
3917
4016
  this.type = data.type ?? 0;
3918
4017
  this.reference = data.message_reference;
4018
+ this.stickers = data.sticker_items ?? (data.stickers ?? []).map(({ id, name, format_type }) => ({
4019
+ id,
4020
+ name,
4021
+ format_type
4022
+ }));
4023
+ this.poll = data.poll ?? null;
4024
+ this.messageSnapshots = data.message_snapshots ?? [];
3919
4025
  this.referencedMessage = data.referenced_message ? new Message(data.referenced_message, context) : data.referenced_message === null ? null : undefined;
3920
4026
  this.#context = context;
3921
4027
  this.member = data.member && data.guild_id ? new GuildMember({
@@ -4050,8 +4156,10 @@ class Message extends BaseStructure {
4050
4156
  }
4051
4157
 
4052
4158
  // packages/managers/src/message.ts
4053
- function toRequest(options) {
4159
+ function toRequest(options, allowedMentions) {
4054
4160
  const { files, ...body } = options;
4161
+ if (allowedMentions !== undefined && body.allowed_mentions === undefined)
4162
+ body.allowed_mentions = allowedMentions;
4055
4163
  if (!files?.length)
4056
4164
  return body;
4057
4165
  return {
@@ -4070,9 +4178,11 @@ class MessageManager {
4070
4178
  #rest;
4071
4179
  #context;
4072
4180
  #channelId;
4073
- constructor(rest, context, channelId, cache) {
4181
+ #allowedMentions;
4182
+ constructor(rest, context, channelId, cache, allowedMentions) {
4074
4183
  if (!channelId)
4075
4184
  throw new TypeError("Channel ID is required.");
4185
+ this.#allowedMentions = allowedMentions;
4076
4186
  this.#rest = rest;
4077
4187
  this.#context = context;
4078
4188
  this.#channelId = channelId;
@@ -4086,7 +4196,7 @@ class MessageManager {
4086
4196
  return this.cache.get(messageId) ?? this.fetch(messageId);
4087
4197
  }
4088
4198
  async send(options) {
4089
- const data = await this.#rest.post(Routes.channelMessages(this.#channelId), toRequest(options));
4199
+ const data = await this.#rest.post(Routes.channelMessages(this.#channelId), toRequest(options, this.#allowedMentions));
4090
4200
  return this.upsert(data);
4091
4201
  }
4092
4202
  async fetch(messageId) {
@@ -4882,10 +4992,12 @@ class ChannelManager extends Manager {
4882
4992
  #context;
4883
4993
  #messageManagers = new Map;
4884
4994
  #messageCache;
4995
+ #allowedMentions;
4885
4996
  constructor(rest, options = {}) {
4886
4997
  super();
4887
4998
  this.#rest = rest;
4888
4999
  this.#messageCache = options.messageCache;
5000
+ this.#allowedMentions = options.allowedMentions;
4889
5001
  this.#context = {
4890
5002
  sendMessage: (channelId, options) => this.send(channelId, options),
4891
5003
  editMessage: (channelId, messageId, options) => this.editMessage(channelId, messageId, options),
@@ -4904,7 +5016,7 @@ class ChannelManager extends Manager {
4904
5016
  messages(channelId) {
4905
5017
  let manager = this.#messageManagers.get(channelId);
4906
5018
  if (!manager) {
4907
- manager = new MessageManager(this.#rest, this.#context, channelId, this.#messageCache);
5019
+ manager = new MessageManager(this.#rest, this.#context, channelId, this.#messageCache, this.#allowedMentions);
4908
5020
  this.#messageManagers.set(channelId, manager);
4909
5021
  }
4910
5022
  return manager;
@@ -5010,7 +5122,7 @@ class ChannelManager extends Manager {
5010
5122
  return this.messages(data.channel_id).upsert(data);
5011
5123
  }
5012
5124
  async editMessage(channelId, messageId, options) {
5013
- return this.messages(channelId).upsert(await this.#rest.patch(Routes.message(channelId, messageId), toRequest(options)));
5125
+ return this.messages(channelId).upsert(await this.#rest.patch(Routes.message(channelId, messageId), toRequest(options, this.#allowedMentions)));
5014
5126
  }
5015
5127
  async deleteMessage(channelId, messageId) {
5016
5128
  await this.#rest.delete(Routes.message(channelId, messageId));
@@ -6059,6 +6171,7 @@ class Gateway {
6059
6171
  #message(raw, token) {
6060
6172
  if (!this.#session.owns(token))
6061
6173
  return;
6174
+ this.#heartbeat.receivedMessage();
6062
6175
  const { sequence, action } = classifyFrame(raw);
6063
6176
  if (sequence !== null)
6064
6177
  this.#session.recordSequence(sequence, token);
@@ -6327,7 +6440,8 @@ class Client extends EventEmitter2 {
6327
6440
  this.users = new UserManager(this.rest);
6328
6441
  this.guilds = new GuildManager(this.rest);
6329
6442
  this.channels = new ChannelManager(this.rest, {
6330
- messageCache: options.messageCache
6443
+ messageCache: options.messageCache,
6444
+ allowedMentions: options.allowedMentions
6331
6445
  });
6332
6446
  this.stageInstances = new StageInstanceManager(this.rest);
6333
6447
  const placeholderAppCommands = new ApplicationCommandManager(this.rest, "0");
@@ -6474,8 +6588,11 @@ class Client extends EventEmitter2 {
6474
6588
  this.emit(wasCached ? "guildAvailable" /* GuildAvailable */ : "guildCreate" /* GuildCreate */, payload);
6475
6589
  });
6476
6590
  this.#gateway.on("GUILD_UPDATE", (data) => {
6477
- this.guilds.patch(data);
6478
- this.emit("guildUpdate" /* GuildUpdate */, data);
6591
+ const payload = data;
6592
+ const cached = this.guilds.get(payload.id);
6593
+ const previous = cached ? this.#snapshot(cached) : null;
6594
+ this.guilds.patch(payload);
6595
+ this.emit("guildUpdate" /* GuildUpdate */, payload, previous);
6479
6596
  });
6480
6597
  this.#gateway.on("GUILD_DELETE", (data) => {
6481
6598
  const payload = data;
@@ -6494,8 +6611,10 @@ class Client extends EventEmitter2 {
6494
6611
  });
6495
6612
  this.#gateway.on("GUILD_MEMBER_UPDATE", (data) => {
6496
6613
  const member = data;
6614
+ const cached = this.#cache.members ? this.guilds.members(member.guild_id).get(member.user.id) : undefined;
6615
+ const previous = cached ? this.#snapshot(cached, new GuildMember({ user: member.user, guild_id: member.guild_id }, this.#resourceContext)) : null;
6497
6616
  this.#upsertMember(member.guild_id, member);
6498
- this.emit("guildMemberUpdate" /* GuildMemberUpdate */, member);
6617
+ this.emit("guildMemberUpdate" /* GuildMemberUpdate */, member, previous);
6499
6618
  });
6500
6619
  this.#gateway.on("GUILD_MEMBER_REMOVE", (data) => {
6501
6620
  const member = data;
@@ -6530,18 +6649,24 @@ class Client extends EventEmitter2 {
6530
6649
  });
6531
6650
  this.#gateway.on("GUILD_ROLE_UPDATE", (data) => {
6532
6651
  const event = data;
6652
+ const cached = this.#cache.roles ? this.guilds.roles(event.guild_id).get(event.role.id) : undefined;
6653
+ const previous = cached ? this.#snapshot(cached) : null;
6533
6654
  this.#upsertRole(event.guild_id, event.role);
6534
- this.emit("guildRoleUpdate" /* GuildRoleUpdate */, event);
6655
+ this.emit("guildRoleUpdate" /* GuildRoleUpdate */, event, previous);
6535
6656
  });
6536
6657
  this.#gateway.on("GUILD_ROLE_DELETE", (data) => {
6537
6658
  const event = data;
6538
- this.guilds.roles(event.guild_id).delete(event.role_id);
6539
- this.emit("guildRoleDelete" /* GuildRoleDelete */, event);
6659
+ const roles = this.guilds.roles(event.guild_id);
6660
+ const removed = roles.get(event.role_id) ?? null;
6661
+ roles.delete(event.role_id);
6662
+ this.emit("guildRoleDelete" /* GuildRoleDelete */, event, removed);
6540
6663
  });
6541
6664
  this.#gateway.on("GUILD_EMOJIS_UPDATE", (data) => {
6542
6665
  const event = data;
6666
+ let previous = null;
6543
6667
  if (this.#cache.emojis) {
6544
6668
  const emojis = this.guilds.emojis(event.guild_id);
6669
+ previous = [...emojis.cache.values()].map((emoji) => this.#snapshot(emoji));
6545
6670
  const current = new Set(event.emojis.map((emoji) => emoji.id));
6546
6671
  for (const id of [...emojis.cache.keys()])
6547
6672
  if (!current.has(id))
@@ -6549,12 +6674,14 @@ class Client extends EventEmitter2 {
6549
6674
  for (const emoji of event.emojis)
6550
6675
  emojis.upsert(emoji);
6551
6676
  }
6552
- this.emit("guildEmojisUpdate" /* GuildEmojisUpdate */, event);
6677
+ this.emit("guildEmojisUpdate" /* GuildEmojisUpdate */, event, previous);
6553
6678
  });
6554
6679
  this.#gateway.on("GUILD_STICKERS_UPDATE", (data) => {
6555
6680
  const event = data;
6556
- this.guilds.stickers(event.guild_id).sync(event.stickers);
6557
- this.emit("guildStickersUpdate" /* GuildStickersUpdate */, event);
6681
+ const stickers = this.guilds.stickers(event.guild_id);
6682
+ const previous = [...stickers.cache.values()];
6683
+ stickers.sync(event.stickers);
6684
+ this.emit("guildStickersUpdate" /* GuildStickersUpdate */, event, previous);
6558
6685
  });
6559
6686
  this.#gateway.on("GUILD_SOUNDBOARD_SOUND_CREATE", (data) => {
6560
6687
  const sound = data;
@@ -6635,13 +6762,15 @@ class Client extends EventEmitter2 {
6635
6762
  this.emit("channelCreate" /* ChannelCreate */, channel);
6636
6763
  });
6637
6764
  this.#gateway.on("CHANNEL_UPDATE", (data) => {
6765
+ const previous = this.#previousChannel(data);
6638
6766
  const channel = this.channels.upsert(data);
6639
- this.emit("channelUpdate" /* ChannelUpdate */, channel);
6767
+ this.emit("channelUpdate" /* ChannelUpdate */, channel, previous);
6640
6768
  });
6641
6769
  this.#gateway.on("CHANNEL_DELETE", (data) => {
6642
6770
  const payload = data;
6771
+ const removed = this.channels.get(payload.id) ?? null;
6643
6772
  this.channels.delete(payload.id);
6644
- this.emit("channelDelete" /* ChannelDelete */, payload);
6773
+ this.emit("channelDelete" /* ChannelDelete */, payload, removed);
6645
6774
  });
6646
6775
  this.#gateway.on("CHANNEL_PINS_UPDATE", (data) => this.emit("channelPinsUpdate" /* ChannelPinsUpdate */, data));
6647
6776
  this.#gateway.on("THREAD_CREATE", (data) => {
@@ -6649,13 +6778,15 @@ class Client extends EventEmitter2 {
6649
6778
  this.emit("threadCreate" /* ThreadCreate */, channel);
6650
6779
  });
6651
6780
  this.#gateway.on("THREAD_UPDATE", (data) => {
6781
+ const previous = this.#previousChannel(data);
6652
6782
  const channel = this.channels.upsert(data);
6653
- this.emit("threadUpdate" /* ThreadUpdate */, channel);
6783
+ this.emit("threadUpdate" /* ThreadUpdate */, channel, previous);
6654
6784
  });
6655
6785
  this.#gateway.on("THREAD_DELETE", (data) => {
6656
6786
  const payload = data;
6787
+ const removed = this.channels.get(payload.id) ?? null;
6657
6788
  this.channels.delete(payload.id);
6658
- this.emit("threadDelete" /* ThreadDelete */, payload);
6789
+ this.emit("threadDelete" /* ThreadDelete */, payload, removed);
6659
6790
  });
6660
6791
  this.#gateway.on("THREAD_LIST_SYNC", (data) => {
6661
6792
  const sync = data;
@@ -6732,6 +6863,15 @@ class Client extends EventEmitter2 {
6732
6863
  return new Role(data);
6733
6864
  return this.#merge(this.guilds.roles(guildId), data.id, new Role(data));
6734
6865
  }
6866
+ #snapshot(cached, blank = Object.create(Object.getPrototypeOf(cached))) {
6867
+ return Object.assign(blank, cached);
6868
+ }
6869
+ #previousChannel(data) {
6870
+ const cached = this.channels.get(data.id);
6871
+ if (!cached)
6872
+ return null;
6873
+ return this.#snapshot(cached, createChannel({ id: cached.id, type: cached.type, guild_id: cached.guildId }, this.#resourceContext));
6874
+ }
6735
6875
  #merge(manager, id, next) {
6736
6876
  const existing = manager.get(id);
6737
6877
  if (!existing) {
@@ -6823,20 +6963,22 @@ class Client extends EventEmitter2 {
6823
6963
  }
6824
6964
  postInteractionResponse(id, token, response) {
6825
6965
  const json = response.toJSON();
6826
- const upload = json.data ? toRequest(json.data) : undefined;
6966
+ const callback = response.withResponse ? `${Routes.interactionCallback(id, token)}?with_response=true` : Routes.interactionCallback(id, token);
6967
+ const carriesMessage = json.type === 4 || json.type === 7;
6968
+ const upload = json.data ? toRequest(json.data, carriesMessage ? this.options.allowedMentions : undefined) : undefined;
6827
6969
  if (upload && typeof upload === "object" && "files" in upload) {
6828
6970
  const { body, files } = upload;
6829
- return this.rest.post(Routes.interactionCallback(id, token), {
6971
+ return this.rest.post(callback, {
6830
6972
  body: { ...json, data: body },
6831
6973
  files
6832
6974
  });
6833
6975
  }
6834
- return this.rest.post(Routes.interactionCallback(id, token), json);
6976
+ return this.rest.post(callback, upload === undefined ? json : { ...json, data: upload });
6835
6977
  }
6836
6978
  editInteractionReply(token, data) {
6837
6979
  if (!this.user)
6838
6980
  return Promise.reject(new Error("Client is unauthenticated."));
6839
- return this.rest.patch(Routes.interactionOriginalResponse(this.user.id, token), toRequest(data));
6981
+ return this.rest.patch(Routes.interactionOriginalResponse(this.user.id, token), toRequest(data, this.options.allowedMentions));
6840
6982
  }
6841
6983
  deleteInteractionReply(token) {
6842
6984
  if (!this.user)
@@ -6846,14 +6988,14 @@ class Client extends EventEmitter2 {
6846
6988
  followUpInteraction(token, data) {
6847
6989
  if (!this.user)
6848
6990
  return Promise.reject(new Error("Client is unauthenticated."));
6849
- return this.rest.post(`/webhooks/${this.user.id}/${token}`, toRequest(data));
6991
+ return this.rest.post(`/webhooks/${this.user.id}/${token}`, toRequest(data, this.options.allowedMentions));
6850
6992
  }
6851
6993
  interactionWebhookMessage(method, applicationId, token, messageId, data) {
6852
6994
  const path = messageId === "@original" ? Routes.interactionOriginalResponse(applicationId, token) : Routes.webhookMessage(applicationId, token, messageId);
6853
6995
  if (method === "GET")
6854
6996
  return this.rest.get(path);
6855
6997
  if (method === "PATCH")
6856
- return this.rest.patch(path, data);
6998
+ return this.rest.patch(path, data ? toRequest(data, this.options.allowedMentions) : data);
6857
6999
  return this.rest.delete(path);
6858
7000
  }
6859
7001
  fetchWebhook(id, token) {
@@ -7014,7 +7156,7 @@ class HandlerRegistry {
7014
7156
  // packages/sharding/package.json
7015
7157
  var package_default2 = {
7016
7158
  name: "@lunibee/sharding",
7017
- version: "0.2.1",
7159
+ version: "0.2.2",
7018
7160
  type: "module",
7019
7161
  module: "./src/index.ts",
7020
7162
  types: "./src/index.ts",
@@ -8148,7 +8290,7 @@ function entersState(target, status, timeoutMs) {
8148
8290
  });
8149
8291
  }
8150
8292
  // packages/builders/src/embed.ts
8151
- class EmbedBuilder {
8293
+ class CreateEmbed {
8152
8294
  #data = {};
8153
8295
  setTitle(value) {
8154
8296
  if (value === null)
@@ -8279,8 +8421,9 @@ function url(value, field) {
8279
8421
  throw new TypeError(`${field} must be a valid URL.`, { cause: error });
8280
8422
  }
8281
8423
  }
8424
+ var EmbedBuilder = CreateEmbed;
8282
8425
  // packages/builders/src/components.ts
8283
- var ComponentType = {
8426
+ var ComponentEnum = {
8284
8427
  ActionRow: 1,
8285
8428
  Button: 2,
8286
8429
  StringSelect: 3,
@@ -8298,9 +8441,9 @@ var ComponentType = {
8298
8441
  ContentInventoryEntry: 16,
8299
8442
  Container: 17
8300
8443
  };
8301
- var TextInputStyle = { Short: 1, Paragraph: 2 };
8444
+ var TextInputType = { Short: 1, Paragraph: 2 };
8302
8445
 
8303
- class ActionRowBuilder {
8446
+ class CreateActionRow {
8304
8447
  #components = [];
8305
8448
  addComponents(...components) {
8306
8449
  if (!components.length)
@@ -8319,15 +8462,15 @@ class ActionRowBuilder {
8319
8462
  if (components.length === 0)
8320
8463
  throw new RangeError("An action row needs at least one component.");
8321
8464
  const types = components.map((component) => component.type);
8322
- if (types.some((type) => type !== ComponentType.Button) && components.length > 1)
8465
+ if (types.some((type) => type !== ComponentEnum.Button) && components.length > 1)
8323
8466
  throw new RangeError("A select menu or text input must be alone in its action row.");
8324
- return { type: ComponentType.ActionRow, components };
8467
+ return { type: ComponentEnum.ActionRow, components };
8325
8468
  }
8326
8469
  }
8327
8470
 
8328
- class StringSelectBuilder {
8471
+ class CreateStringSelect {
8329
8472
  #data = {
8330
- type: ComponentType.StringSelect
8473
+ type: ComponentEnum.StringSelect
8331
8474
  };
8332
8475
  setCustomId(value) {
8333
8476
  validateText(value, 100, "Component custom ID");
@@ -8386,18 +8529,18 @@ class StringSelectBuilder {
8386
8529
  }
8387
8530
  }
8388
8531
 
8389
- class ButtonBuilder {
8532
+ class CreateButton {
8390
8533
  #data = {
8391
- type: ComponentType.Button,
8392
- style: ButtonStyle.Secondary
8534
+ type: ComponentEnum.Button,
8535
+ style: ButtonType.Secondary
8393
8536
  };
8394
8537
  setStyle(style) {
8395
8538
  const data = this.#data;
8396
8539
  data.style = style;
8397
- if (style === ButtonStyle.Link) {
8540
+ if (style === ButtonType.Link) {
8398
8541
  delete data.custom_id;
8399
8542
  delete data.sku_id;
8400
- } else if (style === ButtonStyle.Premium) {
8543
+ } else if (style === ButtonType.Premium) {
8401
8544
  delete data.custom_id;
8402
8545
  delete data.url;
8403
8546
  delete data.label;
@@ -8410,7 +8553,7 @@ class ButtonBuilder {
8410
8553
  }
8411
8554
  setCustomId(value) {
8412
8555
  validateText(value, 100, "Button custom ID");
8413
- if (this.#data.style === ButtonStyle.Link)
8556
+ if (this.#data.style === ButtonType.Link)
8414
8557
  throw new TypeError("Link buttons cannot use custom IDs.");
8415
8558
  this.#data.custom_id = value;
8416
8559
  return this;
@@ -8430,13 +8573,13 @@ class ButtonBuilder {
8430
8573
  cause: error
8431
8574
  });
8432
8575
  }
8433
- this.setStyle(ButtonStyle.Link);
8576
+ this.setStyle(ButtonType.Link);
8434
8577
  this.#data.url = url.toString();
8435
8578
  return this;
8436
8579
  }
8437
8580
  setSKUId(skuId) {
8438
8581
  validateText(skuId, 20, "Button SKU ID");
8439
- this.setStyle(ButtonStyle.Premium);
8582
+ this.setStyle(ButtonType.Premium);
8440
8583
  this.#data.sku_id = skuId;
8441
8584
  return this;
8442
8585
  }
@@ -8450,12 +8593,12 @@ class ButtonBuilder {
8450
8593
  }
8451
8594
  toJSON() {
8452
8595
  const data = this.#data;
8453
- if (data.style === ButtonStyle.Link) {
8596
+ if (data.style === ButtonType.Link) {
8454
8597
  if (!data.url)
8455
8598
  throw new TypeError("Link buttons require a URL.");
8456
8599
  if (data.custom_id || data.sku_id)
8457
8600
  throw new TypeError("Link buttons cannot have a custom ID or SKU ID.");
8458
- } else if (data.style === ButtonStyle.Premium) {
8601
+ } else if (data.style === ButtonType.Premium) {
8459
8602
  if (!data.sku_id)
8460
8603
  throw new TypeError("Premium buttons require a SKU ID.");
8461
8604
  if (data.custom_id || data.url || data.label || data.emoji)
@@ -8466,16 +8609,16 @@ class ButtonBuilder {
8466
8609
  if (data.url || data.sku_id)
8467
8610
  throw new TypeError("Only link buttons have a URL and only premium buttons have a SKU ID.");
8468
8611
  }
8469
- if (data.style !== ButtonStyle.Premium && !data.label && !data.emoji)
8612
+ if (data.style !== ButtonType.Premium && !data.label && !data.emoji)
8470
8613
  throw new TypeError("Buttons require a label or an emoji.");
8471
8614
  return structuredClone(data);
8472
8615
  }
8473
8616
  }
8474
8617
 
8475
- class EntitySelectBuilder {
8618
+ class CreateEntitySelect {
8476
8619
  #data;
8477
8620
  constructor(type) {
8478
- if (type !== ComponentType.UserSelect && type !== ComponentType.RoleSelect && type !== ComponentType.MentionableSelect && type !== ComponentType.ChannelSelect)
8621
+ if (type !== ComponentEnum.UserSelect && type !== ComponentEnum.RoleSelect && type !== ComponentEnum.MentionableSelect && type !== ComponentEnum.ChannelSelect)
8479
8622
  throw new TypeError("Invalid select component type.");
8480
8623
  this.#data = { type };
8481
8624
  }
@@ -8517,7 +8660,7 @@ class EntitySelectBuilder {
8517
8660
  }
8518
8661
  }
8519
8662
 
8520
- class ModalBuilder {
8663
+ class CreateModal {
8521
8664
  #components = [];
8522
8665
  #custom_id;
8523
8666
  #title;
@@ -8540,7 +8683,7 @@ class ModalBuilder {
8540
8683
  return this;
8541
8684
  }
8542
8685
  addTextInputs(...inputs) {
8543
- return this.addComponents(...inputs.map((input) => new ActionRowBuilder().addComponents(input)));
8686
+ return this.addComponents(...inputs.map((input) => new CreateActionRow().addComponents(input)));
8544
8687
  }
8545
8688
  toJSON() {
8546
8689
  if (!this.#custom_id || !this.#title)
@@ -8556,10 +8699,10 @@ class ModalBuilder {
8556
8699
  }
8557
8700
  }
8558
8701
 
8559
- class TextInputBuilder {
8702
+ class CreateTextInput {
8560
8703
  #data = {
8561
- type: ComponentType.TextInput,
8562
- style: TextInputStyle.Short
8704
+ type: ComponentEnum.TextInput,
8705
+ style: TextInputType.Short
8563
8706
  };
8564
8707
  setStyle(style) {
8565
8708
  this.#data.style = style;
@@ -8609,7 +8752,7 @@ class TextInputBuilder {
8609
8752
  }
8610
8753
  }
8611
8754
 
8612
- class ContainerBuilder {
8755
+ class CreateContainer {
8613
8756
  #components = [];
8614
8757
  #accentColor;
8615
8758
  #spoiler;
@@ -8632,7 +8775,7 @@ class ContainerBuilder {
8632
8775
  }
8633
8776
  toJSON() {
8634
8777
  const data = {
8635
- type: ComponentType.Container,
8778
+ type: ComponentEnum.Container,
8636
8779
  components: this.#components.map((c) => c.toJSON())
8637
8780
  };
8638
8781
  if (this.#accentColor !== undefined)
@@ -8643,7 +8786,7 @@ class ContainerBuilder {
8643
8786
  }
8644
8787
  }
8645
8788
 
8646
- class SectionBuilder {
8789
+ class CreateSection {
8647
8790
  #components = [];
8648
8791
  #accessory;
8649
8792
  addComponents(...components) {
@@ -8658,14 +8801,14 @@ class SectionBuilder {
8658
8801
  }
8659
8802
  toJSON() {
8660
8803
  return {
8661
- type: ComponentType.Section,
8804
+ type: ComponentEnum.Section,
8662
8805
  components: this.#components.length ? this.#components.map((c) => c.toJSON()) : undefined,
8663
8806
  accessory: this.#accessory?.toJSON()
8664
8807
  };
8665
8808
  }
8666
8809
  }
8667
8810
 
8668
- class TextDisplayBuilder {
8811
+ class CreateTextDisplay {
8669
8812
  #content = "";
8670
8813
  setContent(content) {
8671
8814
  validateText(content, 4000, "Text display content");
@@ -8674,13 +8817,13 @@ class TextDisplayBuilder {
8674
8817
  }
8675
8818
  toJSON() {
8676
8819
  return {
8677
- type: ComponentType.TextDisplay,
8820
+ type: ComponentEnum.TextDisplay,
8678
8821
  content: this.#content
8679
8822
  };
8680
8823
  }
8681
8824
  }
8682
8825
 
8683
- class MediaGalleryBuilder {
8826
+ class CreateMediaGallery {
8684
8827
  #items = [];
8685
8828
  addItems(...items) {
8686
8829
  if (!items.length) {
@@ -8694,13 +8837,13 @@ class MediaGalleryBuilder {
8694
8837
  }
8695
8838
  toJSON() {
8696
8839
  return {
8697
- type: ComponentType.MediaGallery,
8840
+ type: ComponentEnum.MediaGallery,
8698
8841
  items: structuredClone(this.#items)
8699
8842
  };
8700
8843
  }
8701
8844
  }
8702
8845
 
8703
- class FileComponentBuilder {
8846
+ class CreateFileComponent {
8704
8847
  #url = "";
8705
8848
  #spoiler;
8706
8849
  setUrl(url) {
@@ -8716,7 +8859,7 @@ class FileComponentBuilder {
8716
8859
  if (!this.#url)
8717
8860
  throw new Error("File component must have a URL.");
8718
8861
  const data = {
8719
- type: ComponentType.File,
8862
+ type: ComponentEnum.File,
8720
8863
  file: { url: this.#url }
8721
8864
  };
8722
8865
  if (this.#spoiler !== undefined)
@@ -8725,7 +8868,7 @@ class FileComponentBuilder {
8725
8868
  }
8726
8869
  }
8727
8870
 
8728
- class SeparatorBuilder {
8871
+ class CreateSeparator {
8729
8872
  #spacing;
8730
8873
  #divider;
8731
8874
  setSpacing(spacing) {
@@ -8738,7 +8881,7 @@ class SeparatorBuilder {
8738
8881
  }
8739
8882
  toJSON() {
8740
8883
  const data = {
8741
- type: ComponentType.Separator
8884
+ type: ComponentEnum.Separator
8742
8885
  };
8743
8886
  if (this.#spacing !== undefined)
8744
8887
  data.spacing = this.#spacing;
@@ -8748,7 +8891,7 @@ class SeparatorBuilder {
8748
8891
  }
8749
8892
  }
8750
8893
 
8751
- class ThumbnailBuilder {
8894
+ class CreateThumbnail {
8752
8895
  #url = "";
8753
8896
  #description;
8754
8897
  #spoiler;
@@ -8768,7 +8911,7 @@ class ThumbnailBuilder {
8768
8911
  }
8769
8912
  toJSON() {
8770
8913
  const data = {
8771
- type: ComponentType.Thumbnail,
8914
+ type: ComponentEnum.Thumbnail,
8772
8915
  url: this.#url
8773
8916
  };
8774
8917
  if (this.#description !== undefined)
@@ -8779,7 +8922,7 @@ class ThumbnailBuilder {
8779
8922
  }
8780
8923
  }
8781
8924
 
8782
- class ContentInventoryEntryBuilder {
8925
+ class CreateContentInventoryEntry {
8783
8926
  #id = "";
8784
8927
  setId(id) {
8785
8928
  validateText(id, 100, "Content inventory entry ID");
@@ -8788,7 +8931,7 @@ class ContentInventoryEntryBuilder {
8788
8931
  }
8789
8932
  toJSON() {
8790
8933
  return {
8791
- type: ComponentType.ContentInventoryEntry,
8934
+ type: ComponentEnum.ContentInventoryEntry,
8792
8935
  id: this.#id
8793
8936
  };
8794
8937
  }
@@ -8809,27 +8952,27 @@ function validateLength(value, field, max = 4000) {
8809
8952
  if (!Number.isInteger(value) || value < 0 || value > max)
8810
8953
  throw new RangeError(`${field} must be an integer between 0 and ${max}.`);
8811
8954
  }
8812
- class UserSelectMenuBuilder extends EntitySelectBuilder {
8955
+ class CreateUserSelectMenu extends CreateEntitySelect {
8813
8956
  constructor() {
8814
- super(ComponentType.UserSelect);
8957
+ super(ComponentEnum.UserSelect);
8815
8958
  }
8816
8959
  }
8817
8960
 
8818
- class RoleSelectMenuBuilder extends EntitySelectBuilder {
8961
+ class CreateRoleSelectMenu extends CreateEntitySelect {
8819
8962
  constructor() {
8820
- super(ComponentType.RoleSelect);
8963
+ super(ComponentEnum.RoleSelect);
8821
8964
  }
8822
8965
  }
8823
8966
 
8824
- class MentionableSelectMenuBuilder extends EntitySelectBuilder {
8967
+ class CreateMentionableSelectMenu extends CreateEntitySelect {
8825
8968
  constructor() {
8826
- super(ComponentType.MentionableSelect);
8969
+ super(ComponentEnum.MentionableSelect);
8827
8970
  }
8828
8971
  }
8829
8972
 
8830
- class ChannelSelectMenuBuilder extends EntitySelectBuilder {
8973
+ class CreateChannelSelectMenu extends CreateEntitySelect {
8831
8974
  constructor() {
8832
- super(ComponentType.ChannelSelect);
8975
+ super(ComponentEnum.ChannelSelect);
8833
8976
  }
8834
8977
  }
8835
8978
  function assertSelect(data) {
@@ -8849,8 +8992,30 @@ function componentsV2Message(components, options) {
8849
8992
  flags: (options?.flags ?? 0) | IS_COMPONENTS_V2
8850
8993
  };
8851
8994
  }
8995
+ var ButtonBuilder = CreateButton;
8996
+ var ChannelSelectMenuBuilder = CreateChannelSelectMenu;
8997
+ var ContainerBuilder = CreateContainer;
8998
+ var ContentInventoryEntryBuilder = CreateContentInventoryEntry;
8999
+ var EntitySelectBuilder = CreateEntitySelect;
9000
+ var FileComponentBuilder = CreateFileComponent;
9001
+ var MediaGalleryBuilder = CreateMediaGallery;
9002
+ var MentionableSelectMenuBuilder = CreateMentionableSelectMenu;
9003
+ var ModalBuilder = CreateModal;
9004
+ var RoleSelectMenuBuilder = CreateRoleSelectMenu;
9005
+ var SectionBuilder = CreateSection;
9006
+ var SeparatorBuilder = CreateSeparator;
9007
+ var StringSelectBuilder = CreateStringSelect;
9008
+ var StringSelectMenuBuilder = CreateStringSelect;
9009
+ var TextDisplayBuilder = CreateTextDisplay;
9010
+ var TextInputBuilder = CreateTextInput;
9011
+ var ThumbnailBuilder = CreateThumbnail;
9012
+ var UserSelectMenuBuilder = CreateUserSelectMenu;
9013
+ var ActionRowBuilder = CreateActionRow;
9014
+ var ButtonStyle = ButtonType;
9015
+ var TextInputStyle = TextInputType;
9016
+ var ComponentType = ComponentEnum;
8852
9017
  // packages/builders/src/commands.ts
8853
- var ApplicationCommandOptionType2 = {
9018
+ var ApplicationCommandOptionEnum2 = {
8854
9019
  Subcommand: 1,
8855
9020
  SubcommandGroup: 2,
8856
9021
  String: 3,
@@ -8864,7 +9029,7 @@ var ApplicationCommandOptionType2 = {
8864
9029
  Attachment: 11
8865
9030
  };
8866
9031
 
8867
- class SlashCommandBuilder {
9032
+ class CreateSlashCommand {
8868
9033
  #data = { type: 1 };
8869
9034
  setName(name) {
8870
9035
  validateName(name, "Command name");
@@ -8896,37 +9061,37 @@ class SlashCommandBuilder {
8896
9061
  return this;
8897
9062
  }
8898
9063
  addStringOption(configure) {
8899
- return this.addOption(configure(new StringOptionBuilder));
9064
+ return this.addOption(configure(new CreateStringOption));
8900
9065
  }
8901
9066
  addIntegerOption(configure) {
8902
- return this.addOption(configure(new IntegerOptionBuilder));
9067
+ return this.addOption(configure(new CreateIntegerOption));
8903
9068
  }
8904
9069
  addNumberOption(configure) {
8905
- return this.addOption(configure(new NumberOptionBuilder));
9070
+ return this.addOption(configure(new CreateNumberOption));
8906
9071
  }
8907
9072
  addBooleanOption(configure) {
8908
- return this.addOption(configure(new BooleanOptionBuilder));
9073
+ return this.addOption(configure(new CreateBooleanOption));
8909
9074
  }
8910
9075
  addUserOption(configure) {
8911
- return this.addOption(configure(new UserOptionBuilder));
9076
+ return this.addOption(configure(new CreateUserOption));
8912
9077
  }
8913
9078
  addChannelOption(configure) {
8914
- return this.addOption(configure(new ChannelOptionBuilder));
9079
+ return this.addOption(configure(new CreateChannelOption));
8915
9080
  }
8916
9081
  addRoleOption(configure) {
8917
- return this.addOption(configure(new RoleOptionBuilder));
9082
+ return this.addOption(configure(new CreateRoleOption));
8918
9083
  }
8919
9084
  addMentionableOption(configure) {
8920
- return this.addOption(configure(new MentionableOptionBuilder));
9085
+ return this.addOption(configure(new CreateMentionableOption));
8921
9086
  }
8922
9087
  addAttachmentOption(configure) {
8923
- return this.addOption(configure(new AttachmentOptionBuilder));
9088
+ return this.addOption(configure(new CreateAttachmentOption));
8924
9089
  }
8925
9090
  addSubcommand(configure) {
8926
- return this.addOption(configure(new SubcommandBuilder));
9091
+ return this.addOption(configure(new CreateSubcommand));
8927
9092
  }
8928
9093
  addSubcommandGroup(configure) {
8929
- return this.addOption(configure(new SubcommandGroupBuilder));
9094
+ return this.addOption(configure(new CreateSubcommandGroup));
8930
9095
  }
8931
9096
  toJSON() {
8932
9097
  return structuredClone(this.#data);
@@ -8946,7 +9111,7 @@ class SlashCommandBuilder {
8946
9111
  }
8947
9112
  }
8948
9113
 
8949
- class CommandOptionBuilder {
9114
+ class CreateCommandOption {
8950
9115
  data;
8951
9116
  constructor(type) {
8952
9117
  this.data = { type };
@@ -8974,9 +9139,9 @@ class CommandOptionBuilder {
8974
9139
  }
8975
9140
  }
8976
9141
 
8977
- class StringOptionBuilder extends CommandOptionBuilder {
9142
+ class CreateStringOption extends CreateCommandOption {
8978
9143
  constructor() {
8979
- super(ApplicationCommandOptionType2.String);
9144
+ super(ApplicationCommandOptionEnum2.String);
8980
9145
  }
8981
9146
  addChoices(...choices) {
8982
9147
  const current = this.data.choices ?? [];
@@ -9010,9 +9175,9 @@ class StringOptionBuilder extends CommandOptionBuilder {
9010
9175
  }
9011
9176
  }
9012
9177
 
9013
- class IntegerOptionBuilder extends CommandOptionBuilder {
9178
+ class CreateIntegerOption extends CreateCommandOption {
9014
9179
  constructor() {
9015
- super(ApplicationCommandOptionType2.Integer);
9180
+ super(ApplicationCommandOptionEnum2.Integer);
9016
9181
  }
9017
9182
  setMinValue(value) {
9018
9183
  validateNumberRange(value, -9007199254740991, 9007199254740991, "min_value", true);
@@ -9045,9 +9210,9 @@ class IntegerOptionBuilder extends CommandOptionBuilder {
9045
9210
  }
9046
9211
  }
9047
9212
 
9048
- class NumberOptionBuilder extends CommandOptionBuilder {
9213
+ class CreateNumberOption extends CreateCommandOption {
9049
9214
  constructor() {
9050
- super(ApplicationCommandOptionType2.Number);
9215
+ super(ApplicationCommandOptionEnum2.Number);
9051
9216
  }
9052
9217
  setMinValue(value) {
9053
9218
  validateNumberRange(value, -9007199254740991, 9007199254740991, "min_value", false);
@@ -9080,39 +9245,39 @@ class NumberOptionBuilder extends CommandOptionBuilder {
9080
9245
  }
9081
9246
  }
9082
9247
 
9083
- class BooleanOptionBuilder extends CommandOptionBuilder {
9248
+ class CreateBooleanOption extends CreateCommandOption {
9084
9249
  constructor() {
9085
- super(ApplicationCommandOptionType2.Boolean);
9250
+ super(ApplicationCommandOptionEnum2.Boolean);
9086
9251
  }
9087
9252
  }
9088
9253
 
9089
- class UserOptionBuilder extends CommandOptionBuilder {
9254
+ class CreateUserOption extends CreateCommandOption {
9090
9255
  constructor() {
9091
- super(ApplicationCommandOptionType2.User);
9256
+ super(ApplicationCommandOptionEnum2.User);
9092
9257
  }
9093
9258
  }
9094
9259
 
9095
- class RoleOptionBuilder extends CommandOptionBuilder {
9260
+ class CreateRoleOption extends CreateCommandOption {
9096
9261
  constructor() {
9097
- super(ApplicationCommandOptionType2.Role);
9262
+ super(ApplicationCommandOptionEnum2.Role);
9098
9263
  }
9099
9264
  }
9100
9265
 
9101
- class MentionableOptionBuilder extends CommandOptionBuilder {
9266
+ class CreateMentionableOption extends CreateCommandOption {
9102
9267
  constructor() {
9103
- super(ApplicationCommandOptionType2.Mentionable);
9268
+ super(ApplicationCommandOptionEnum2.Mentionable);
9104
9269
  }
9105
9270
  }
9106
9271
 
9107
- class AttachmentOptionBuilder extends CommandOptionBuilder {
9272
+ class CreateAttachmentOption extends CreateCommandOption {
9108
9273
  constructor() {
9109
- super(ApplicationCommandOptionType2.Attachment);
9274
+ super(ApplicationCommandOptionEnum2.Attachment);
9110
9275
  }
9111
9276
  }
9112
9277
 
9113
- class ChannelOptionBuilder extends CommandOptionBuilder {
9278
+ class CreateChannelOption extends CreateCommandOption {
9114
9279
  constructor() {
9115
- super(ApplicationCommandOptionType2.Channel);
9280
+ super(ApplicationCommandOptionEnum2.Channel);
9116
9281
  }
9117
9282
  addChannelTypes(...types) {
9118
9283
  if (types.some((type) => !Number.isInteger(type) || type < 0))
@@ -9122,36 +9287,36 @@ class ChannelOptionBuilder extends CommandOptionBuilder {
9122
9287
  }
9123
9288
  }
9124
9289
 
9125
- class SubcommandBuilder extends CommandOptionBuilder {
9290
+ class CreateSubcommand extends CreateCommandOption {
9126
9291
  constructor() {
9127
- super(ApplicationCommandOptionType2.Subcommand);
9292
+ super(ApplicationCommandOptionEnum2.Subcommand);
9128
9293
  }
9129
9294
  addStringOption(configure) {
9130
- return this.addChildOption(configure(new StringOptionBuilder));
9295
+ return this.addChildOption(configure(new CreateStringOption));
9131
9296
  }
9132
9297
  addIntegerOption(configure) {
9133
- return this.addChildOption(configure(new IntegerOptionBuilder));
9298
+ return this.addChildOption(configure(new CreateIntegerOption));
9134
9299
  }
9135
9300
  addNumberOption(configure) {
9136
- return this.addChildOption(configure(new NumberOptionBuilder));
9301
+ return this.addChildOption(configure(new CreateNumberOption));
9137
9302
  }
9138
9303
  addBooleanOption(configure) {
9139
- return this.addChildOption(configure(new BooleanOptionBuilder));
9304
+ return this.addChildOption(configure(new CreateBooleanOption));
9140
9305
  }
9141
9306
  addUserOption(configure) {
9142
- return this.addChildOption(configure(new UserOptionBuilder));
9307
+ return this.addChildOption(configure(new CreateUserOption));
9143
9308
  }
9144
9309
  addChannelOption(configure) {
9145
- return this.addChildOption(configure(new ChannelOptionBuilder));
9310
+ return this.addChildOption(configure(new CreateChannelOption));
9146
9311
  }
9147
9312
  addRoleOption(configure) {
9148
- return this.addChildOption(configure(new RoleOptionBuilder));
9313
+ return this.addChildOption(configure(new CreateRoleOption));
9149
9314
  }
9150
9315
  addMentionableOption(configure) {
9151
- return this.addChildOption(configure(new MentionableOptionBuilder));
9316
+ return this.addChildOption(configure(new CreateMentionableOption));
9152
9317
  }
9153
9318
  addAttachmentOption(configure) {
9154
- return this.addChildOption(configure(new AttachmentOptionBuilder));
9319
+ return this.addChildOption(configure(new CreateAttachmentOption));
9155
9320
  }
9156
9321
  addChildOption(option) {
9157
9322
  const options = this.data.options ?? [];
@@ -9162,7 +9327,7 @@ class SubcommandBuilder extends CommandOptionBuilder {
9162
9327
  throw new RangeError(`Duplicate option name: ${String(payload.name)}.`);
9163
9328
  if (payload.required === true && options.some((existing) => existing.required !== true))
9164
9329
  throw new RangeError("Required subcommand options must be placed before optional options.");
9165
- if (options.some((existing) => existing.type === ApplicationCommandOptionType2.Subcommand))
9330
+ if (options.some((existing) => existing.type === ApplicationCommandOptionEnum2.Subcommand))
9166
9331
  throw new RangeError("Subcommands cannot contain nested subcommands.");
9167
9332
  options.push(payload);
9168
9333
  this.data.options = options;
@@ -9170,18 +9335,18 @@ class SubcommandBuilder extends CommandOptionBuilder {
9170
9335
  }
9171
9336
  }
9172
9337
 
9173
- class SubcommandGroupBuilder extends CommandOptionBuilder {
9338
+ class CreateSubcommandGroup extends CreateCommandOption {
9174
9339
  constructor() {
9175
- super(ApplicationCommandOptionType2.SubcommandGroup);
9340
+ super(ApplicationCommandOptionEnum2.SubcommandGroup);
9176
9341
  }
9177
9342
  addSubcommand(configure) {
9178
9343
  const options = this.data.options ?? [];
9179
9344
  if (options.length >= 25)
9180
9345
  throw new RangeError("A subcommand group cannot contain more than 25 subcommands.");
9181
- const payload = configure(new SubcommandBuilder).toJSON();
9346
+ const payload = configure(new CreateSubcommand).toJSON();
9182
9347
  if (options.some((existing) => existing.name === payload.name))
9183
9348
  throw new RangeError(`Duplicate subcommand name: ${String(payload.name)}.`);
9184
- if (payload.type !== ApplicationCommandOptionType2.Subcommand)
9349
+ if (payload.type !== ApplicationCommandOptionEnum2.Subcommand)
9185
9350
  throw new TypeError("Subcommand group children must be subcommands.");
9186
9351
  options.push(payload);
9187
9352
  this.data.options = options;
@@ -9205,7 +9370,7 @@ function validateNumberRange(value, minimum, maximum, field, integerOnly = true)
9205
9370
  throw new RangeError(`${field} must be ${integerOnly ? "an integer" : "a number"} between ${minimum} and ${maximum}.`);
9206
9371
  }
9207
9372
 
9208
- class ContextMenuCommandBuilder {
9373
+ class CreateContextMenuCommand {
9209
9374
  data;
9210
9375
  constructor(type = 2) {
9211
9376
  this.data = { type };
@@ -9234,27 +9399,53 @@ class ContextMenuCommandBuilder {
9234
9399
  this.data.integration_types = [...types];
9235
9400
  return this;
9236
9401
  }
9402
+ setContexts(...contexts) {
9403
+ if (contexts.some((context) => context !== 0 && context !== 1 && context !== 2))
9404
+ throw new RangeError("Command contexts must be 0, 1 or 2.");
9405
+ this.data.contexts = [...contexts];
9406
+ return this;
9407
+ }
9408
+ setNameLocalizations(localizations) {
9409
+ this.data.name_localizations = localizations === null ? null : { ...localizations };
9410
+ return this;
9411
+ }
9237
9412
  toJSON() {
9238
9413
  return structuredClone(this.data);
9239
9414
  }
9240
9415
  }
9241
9416
 
9242
- class UserCommandBuilder extends ContextMenuCommandBuilder {
9417
+ class CreateUserCommand extends CreateContextMenuCommand {
9243
9418
  constructor() {
9244
9419
  super(2);
9245
9420
  }
9246
9421
  }
9247
9422
 
9248
- class MessageCommandBuilder extends ContextMenuCommandBuilder {
9423
+ class CreateMessageCommand extends CreateContextMenuCommand {
9249
9424
  constructor() {
9250
9425
  super(3);
9251
9426
  }
9252
9427
  }
9428
+ var AttachmentOptionBuilder = CreateAttachmentOption;
9429
+ var BooleanOptionBuilder = CreateBooleanOption;
9430
+ var ChannelOptionBuilder = CreateChannelOption;
9431
+ var CommandOptionBuilder = CreateCommandOption;
9432
+ var ContextMenuCommandBuilder = CreateContextMenuCommand;
9433
+ var IntegerOptionBuilder = CreateIntegerOption;
9434
+ var MentionableOptionBuilder = CreateMentionableOption;
9435
+ var MessageCommandBuilder = CreateMessageCommand;
9436
+ var NumberOptionBuilder = CreateNumberOption;
9437
+ var RoleOptionBuilder = CreateRoleOption;
9438
+ var SlashCommandBuilder = CreateSlashCommand;
9439
+ var StringOptionBuilder = CreateStringOption;
9440
+ var SubcommandBuilder = CreateSubcommand;
9441
+ var SubcommandGroupBuilder = CreateSubcommandGroup;
9442
+ var UserCommandBuilder = CreateUserCommand;
9443
+ var UserOptionBuilder = CreateUserOption;
9253
9444
  // packages/builders/src/attachment.ts
9254
9445
  import { readFile } from "fs/promises";
9255
9446
  import { basename } from "path";
9256
9447
 
9257
- class AttachmentBuilder {
9448
+ class CreateAttachment {
9258
9449
  name;
9259
9450
  description;
9260
9451
  file;
@@ -9298,9 +9489,13 @@ class AttachmentBuilder {
9298
9489
  throw new TypeError("Attachment file must be a supported binary value or file path.");
9299
9490
  }
9300
9491
  }
9492
+ var AttachmentBuilder = CreateAttachment;
9301
9493
  export {
9302
9494
  ActionRowBuilder,
9495
+ ActivityEnum,
9496
+ ApplicationCommandEnum,
9303
9497
  ApplicationCommandManager,
9498
+ ApplicationCommandOptionEnum,
9304
9499
  ApplicationCommandOptionType,
9305
9500
  ApplicationCommandType,
9306
9501
  AttachmentBuilder,
@@ -9316,10 +9511,13 @@ export {
9316
9511
  BooleanOptionBuilder,
9317
9512
  ButtonBuilder,
9318
9513
  ButtonStyle,
9514
+ ButtonType,
9515
+ CDN_BASE,
9319
9516
  Cache,
9320
9517
  ResourceManager as CachedManager,
9321
9518
  CategoryChannel,
9322
9519
  Channel,
9520
+ ChannelEnum,
9323
9521
  ChannelManager,
9324
9522
  ChannelOptionBuilder,
9325
9523
  ChannelSelectMenuBuilder,
@@ -9330,12 +9528,51 @@ export {
9330
9528
  Collection,
9331
9529
  Collector,
9332
9530
  CommandInteraction,
9531
+ CommandOptionBuilder,
9333
9532
  CommandOptions,
9533
+ ComponentEnum,
9334
9534
  ComponentInteraction,
9335
9535
  ComponentType,
9336
9536
  ContainerBuilder,
9337
9537
  ContentInventoryEntryBuilder,
9338
9538
  ContextMenuCommandBuilder,
9539
+ ContextMenuCommandInteraction,
9540
+ CreateActionRow,
9541
+ CreateAttachment,
9542
+ CreateAttachmentOption,
9543
+ CreateBooleanOption,
9544
+ CreateButton,
9545
+ CreateChannelOption,
9546
+ CreateChannelSelectMenu,
9547
+ CreateContainer,
9548
+ CreateContentInventoryEntry,
9549
+ CreateContextMenuCommand,
9550
+ CreateEmbed,
9551
+ CreateEntitySelect,
9552
+ CreateFileComponent,
9553
+ CreateIntegerOption,
9554
+ CreateMediaGallery,
9555
+ CreateMentionableOption,
9556
+ CreateMentionableSelectMenu,
9557
+ CreateMessageCommand,
9558
+ CreateModal,
9559
+ CreateNumberOption,
9560
+ CreateRoleOption,
9561
+ CreateRoleSelectMenu,
9562
+ CreateSection,
9563
+ CreateSeparator,
9564
+ CreateSlashCommand,
9565
+ CreateStringOption,
9566
+ CreateStringSelect,
9567
+ CreateStringSelect as CreateStringSelectMenu,
9568
+ CreateSubcommand,
9569
+ CreateSubcommandGroup,
9570
+ CreateTextDisplay,
9571
+ CreateTextInput,
9572
+ CreateThumbnail,
9573
+ CreateUserCommand,
9574
+ CreateUserOption,
9575
+ CreateUserSelectMenu,
9339
9576
  DMChannel,
9340
9577
  RESTError as DiscordAPIError,
9341
9578
  Embed,
@@ -9374,7 +9611,9 @@ export {
9374
9611
  Intents,
9375
9612
  IntentsBitField,
9376
9613
  Interaction,
9614
+ InteractionEnum,
9377
9615
  InteractionResponse,
9616
+ InteractionResponseEnum,
9378
9617
  InteractionResponseType,
9379
9618
  InteractionType,
9380
9619
  Invite,
@@ -9397,6 +9636,7 @@ export {
9397
9636
  OnboardingPromptOption,
9398
9637
  Permission,
9399
9638
  PermissionFlagsBits,
9639
+ PermissionOverwriteEnum,
9400
9640
  PermissionOverwriteManager,
9401
9641
  PermissionOverwriteType,
9402
9642
  PermissionSet,
@@ -9426,17 +9666,20 @@ export {
9426
9666
  StageChannel,
9427
9667
  StageInstanceManager,
9428
9668
  GatewayState as Status,
9669
+ StickerEnum,
9670
+ StickerFormatEnum,
9429
9671
  StickerFormatType,
9430
9672
  StickerType,
9431
9673
  StringOptionBuilder,
9432
9674
  StringSelectBuilder,
9433
- StringSelectBuilder as StringSelectMenuBuilder,
9675
+ StringSelectMenuBuilder,
9434
9676
  SubcommandBuilder,
9435
9677
  SubcommandGroupBuilder,
9436
9678
  TextChannel,
9437
9679
  TextDisplayBuilder,
9438
9680
  TextInputBuilder,
9439
9681
  TextInputStyle,
9682
+ TextInputType,
9440
9683
  ThreadChannel,
9441
9684
  ThreadManager,
9442
9685
  ThumbnailBuilder,
@@ -9456,6 +9699,7 @@ export {
9456
9699
  WebSocketTransport,
9457
9700
  Webhook,
9458
9701
  WebhookClient,
9702
+ WebhookEnum,
9459
9703
  WebhookType,
9460
9704
  WelcomeScreenChannel,
9461
9705
  ZlibStreamDecoder,
@@ -9464,6 +9708,7 @@ export {
9464
9708
  blockQuote,
9465
9709
  bold,
9466
9710
  bulletList,
9711
+ cdnURL,
9467
9712
  channelMention,
9468
9713
  classifyCloseCode,
9469
9714
  classifyFrame,
@@ -9516,4 +9761,4 @@ export {
9516
9761
  userMention
9517
9762
  };
9518
9763
 
9519
- //# debugId=9E598E337B852A0164756E2164756E21
9764
+ //# debugId=FC58C0F70BD3B2A964756E2164756E21