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
@@ -88,13 +88,13 @@ class Channel extends BaseStructure {
88
88
  this.permissionOverwrites = (data.permission_overwrites ?? []).map((overwrite) => ({ ...overwrite }));
89
89
  this.#context = context;
90
90
  }
91
- sendMessage(options) {
91
+ send(options) {
92
92
  if (!this.#context)
93
93
  throw new Error("This channel is not attached to a client.");
94
94
  return this.#context.sendMessage(this.id, options);
95
95
  }
96
- send(options) {
97
- return this.sendMessage(options);
96
+ sendMessage(options) {
97
+ return this.send(options);
98
98
  }
99
99
  edit(options) {
100
100
  if (!this.#context?.editChannel)
@@ -117,10 +117,10 @@ class Channel extends BaseStructure {
117
117
  editParent(parentId) {
118
118
  return this.edit({ parent_id: parentId });
119
119
  }
120
- delete() {
120
+ delete(reason) {
121
121
  if (!this.#context?.deleteChannel)
122
122
  throw new Error("This channel is not attached to a client.");
123
- return this.#context.deleteChannel(this.id);
123
+ return this.#context.deleteChannel(this.id, reason);
124
124
  }
125
125
  update(options) {
126
126
  return this.edit(options);
@@ -167,6 +167,15 @@ class Guild extends BaseStructure {
167
167
  mfaLevel;
168
168
  explicitContentFilter;
169
169
  defaultMessageNotifications;
170
+ afkChannelId;
171
+ afkTimeout;
172
+ widgetEnabled;
173
+ widgetChannelId;
174
+ applicationId;
175
+ publicUpdatesChannelId;
176
+ safetyAlertsChannelId;
177
+ maxPresences;
178
+ maxVideoChannelUsers;
170
179
  constructor(data) {
171
180
  super(data.id);
172
181
  if (!data.name)
@@ -188,14 +197,22 @@ class Guild extends BaseStructure {
188
197
  this.vanityUrlCode = data.vanity_url_code ?? null;
189
198
  this.nsfwLevel = data.nsfw_level ?? 0;
190
199
  this.discoverySplash = data.discovery_splash ?? null;
191
- const d = data;
192
- this.rulesChannelId = d.rules_channel_id ?? null;
193
- this.systemChannelId = d.system_channel_id ?? null;
194
- this.systemChannelFlags = d.system_channel_flags ?? 0;
195
- this.maxMembers = d.max_members ?? 0;
196
- this.mfaLevel = d.mfa_level ?? 0;
197
- this.explicitContentFilter = d.explicit_content_filter ?? 0;
198
- this.defaultMessageNotifications = d.default_message_notifications ?? 0;
200
+ this.rulesChannelId = data.rules_channel_id ?? null;
201
+ this.systemChannelId = data.system_channel_id ?? null;
202
+ this.systemChannelFlags = data.system_channel_flags ?? 0;
203
+ this.maxMembers = data.max_members ?? 0;
204
+ this.mfaLevel = data.mfa_level ?? 0;
205
+ this.explicitContentFilter = data.explicit_content_filter ?? 0;
206
+ this.defaultMessageNotifications = data.default_message_notifications ?? 0;
207
+ this.afkChannelId = data.afk_channel_id ?? null;
208
+ this.afkTimeout = data.afk_timeout;
209
+ this.widgetEnabled = data.widget_enabled ?? false;
210
+ this.widgetChannelId = data.widget_channel_id ?? null;
211
+ this.applicationId = data.application_id ?? null;
212
+ this.publicUpdatesChannelId = data.public_updates_channel_id ?? null;
213
+ this.safetyAlertsChannelId = data.safety_alerts_channel_id ?? null;
214
+ this.maxPresences = data.max_presences ?? null;
215
+ this.maxVideoChannelUsers = data.max_video_channel_users;
199
216
  }
200
217
  iconURL(options = {}) {
201
218
  if (!this.icon)
@@ -739,7 +756,7 @@ var IntentBits = {
739
756
  directMessagePolls: 1 << 25
740
757
  };
741
758
  // packages/types/src/index.ts
742
- var InteractionResponseType = {
759
+ var InteractionResponseEnum = {
743
760
  Pong: 1,
744
761
  ChannelMessage: 4,
745
762
  DeferredChannelMessage: 5,
@@ -748,22 +765,26 @@ var InteractionResponseType = {
748
765
  Autocomplete: 8,
749
766
  Modal: 9
750
767
  };
768
+ var InteractionResponseType = InteractionResponseEnum;
751
769
  // packages/rest/package.json
752
770
  var package_default = {
753
771
  name: "@lunibee/rest",
754
- version: "0.2.1",
772
+ version: "0.2.3",
755
773
  type: "module",
756
774
  module: "./src/index.ts",
757
775
  types: "./src/index.ts",
758
776
  exports: {
759
777
  ".": "./src/index.ts"
778
+ },
779
+ dependencies: {
780
+ "@lunibee/types": "workspace:*"
760
781
  }
761
782
  };
762
783
 
763
784
  // packages/rest/src/index.ts
764
785
  var LIBRARY_VERSION = package_default.version;
765
786
  var LIBRARY_URL = "https://github.com/Ekretos/lunibee";
766
- var USER_AGENT = `DiscordBot (${LIBRARY_URL}, ${package_default.version})`;
787
+ var USER_AGENT = `DiscordBot (${LIBRARY_URL}, ${LIBRARY_VERSION})`;
767
788
  var REQUEST_DATA_KEYS = new Set([
768
789
  "body",
769
790
  "files",
@@ -989,7 +1010,7 @@ class Invite {
989
1010
  return this.url;
990
1011
  }
991
1012
  }
992
- var WebhookType = {
1013
+ var WebhookEnum = {
993
1014
  Incoming: 1,
994
1015
  ChannelFollower: 2,
995
1016
  Application: 3
@@ -1005,7 +1026,7 @@ class Webhook extends BaseStructure {
1005
1026
  token;
1006
1027
  constructor(data) {
1007
1028
  super(data.id);
1008
- this.type = data.type ?? WebhookType.Incoming;
1029
+ this.type = data.type ?? WebhookEnum.Incoming;
1009
1030
  this.name = data.name ?? null;
1010
1031
  this.avatarHash = data.avatar ?? null;
1011
1032
  this.channelId = data.channel_id ?? null;
@@ -1114,7 +1135,7 @@ class WelcomeScreenChannel {
1114
1135
  }
1115
1136
  }
1116
1137
 
1117
- class GuildWelcomeScreen2 {
1138
+ class GuildWelcomeScreen {
1118
1139
  description;
1119
1140
  channels;
1120
1141
  constructor(data) {
@@ -1157,7 +1178,7 @@ class OnboardingPrompt extends BaseStructure {
1157
1178
  }
1158
1179
  }
1159
1180
 
1160
- class GuildOnboarding2 extends BaseStructure {
1181
+ class GuildOnboarding extends BaseStructure {
1161
1182
  prompts;
1162
1183
  defaultChannelIds;
1163
1184
  enabled;
@@ -1170,6 +1191,7 @@ class GuildOnboarding2 extends BaseStructure {
1170
1191
  this.mode = data.mode;
1171
1192
  }
1172
1193
  }
1194
+ var WebhookType = WebhookEnum;
1173
1195
  // packages/structures/src/channels.ts
1174
1196
  class NewsChannel extends TextChannel {
1175
1197
  }
@@ -1288,6 +1310,13 @@ var OptionType = {
1288
1310
  class CommandOptions {
1289
1311
  #options;
1290
1312
  #resolved;
1313
+ #lookup(kind, id) {
1314
+ const group = this.#resolved?.[kind];
1315
+ if (typeof group !== "object" || group === null)
1316
+ return;
1317
+ const entry = group[id];
1318
+ return typeof entry === "object" && entry !== null ? entry : undefined;
1319
+ }
1291
1320
  constructor(options, resolved = {}) {
1292
1321
  let currentOptions = options;
1293
1322
  let group = null;
@@ -1376,7 +1405,7 @@ class CommandOptions {
1376
1405
  return null;
1377
1406
  }
1378
1407
  const userId = String(opt.value);
1379
- const resolved = this.#resolved?.users?.[userId] ?? null;
1408
+ const resolved = this.#lookup("users", userId) ?? null;
1380
1409
  if (!resolved && required)
1381
1410
  throw new TypeError(`Resolved user for option "${name}" is missing.`);
1382
1411
  return resolved;
@@ -1389,7 +1418,7 @@ class CommandOptions {
1389
1418
  return null;
1390
1419
  }
1391
1420
  const channelId = String(opt.value);
1392
- const resolved = this.#resolved?.channels?.[channelId] ?? null;
1421
+ const resolved = this.#lookup("channels", channelId) ?? null;
1393
1422
  if (!resolved && required)
1394
1423
  throw new TypeError(`Resolved channel for option "${name}" is missing.`);
1395
1424
  return resolved;
@@ -1402,7 +1431,7 @@ class CommandOptions {
1402
1431
  return null;
1403
1432
  }
1404
1433
  const roleId = String(opt.value);
1405
- const resolved = this.#resolved?.roles?.[roleId] ?? null;
1434
+ const resolved = this.#lookup("roles", roleId) ?? null;
1406
1435
  if (!resolved && required)
1407
1436
  throw new TypeError(`Resolved role for option "${name}" is missing.`);
1408
1437
  return resolved;
@@ -1415,7 +1444,7 @@ class CommandOptions {
1415
1444
  return null;
1416
1445
  }
1417
1446
  const id = String(opt.value);
1418
- const resolved = this.#resolved?.users?.[id] ?? this.#resolved?.roles?.[id] ?? null;
1447
+ const resolved = this.#lookup("users", id) ?? this.#lookup("roles", id) ?? null;
1419
1448
  if (!resolved && required)
1420
1449
  throw new TypeError(`Resolved mentionable for option "${name}" is missing.`);
1421
1450
  return resolved;
@@ -1425,9 +1454,9 @@ class CommandOptions {
1425
1454
  if (!opt || opt.type !== OptionType.Mentionable)
1426
1455
  return null;
1427
1456
  const id = String(opt.value);
1428
- if (this.#resolved?.users?.[id])
1457
+ if (this.#lookup("users", id))
1429
1458
  return "user";
1430
- if (this.#resolved?.roles?.[id])
1459
+ if (this.#lookup("roles", id))
1431
1460
  return "role";
1432
1461
  return null;
1433
1462
  }
@@ -1439,7 +1468,7 @@ class CommandOptions {
1439
1468
  return null;
1440
1469
  }
1441
1470
  const attachmentId = String(opt.value);
1442
- const resolved = this.#resolved?.attachments?.[attachmentId] ?? null;
1471
+ const resolved = this.#lookup("attachments", attachmentId) ?? null;
1443
1472
  if (!resolved && required)
1444
1473
  throw new TypeError(`Resolved attachment for option "${name}" is missing.`);
1445
1474
  return resolved;
@@ -1449,7 +1478,7 @@ class CommandOptions {
1449
1478
  }
1450
1479
  }
1451
1480
  // packages/structures/src/interactions.ts
1452
- var InteractionType = {
1481
+ var InteractionEnum = {
1453
1482
  Ping: 1,
1454
1483
  ApplicationCommand: 2,
1455
1484
  MessageComponent: 3,
@@ -1457,8 +1486,17 @@ var InteractionType = {
1457
1486
  ModalSubmit: 5
1458
1487
  };
1459
1488
  var EPHEMERAL = 64;
1489
+ var COMMAND_CHAT_INPUT = 1;
1490
+ var COMMAND_USER = 2;
1491
+ var COMMAND_MESSAGE = 3;
1460
1492
  var TOKEN_LIFETIME_MS = 15 * 60000;
1461
1493
  var DISCORD_EPOCH = 1420070400000n;
1494
+ function splitWithResponse(options) {
1495
+ if (typeof options === "string")
1496
+ return { withResponse: false, rest: options };
1497
+ const { withResponse, ...rest } = options;
1498
+ return { withResponse: withResponse === true, rest };
1499
+ }
1462
1500
  function toMessageData(options) {
1463
1501
  if (typeof options === "string")
1464
1502
  return { content: options };
@@ -1471,6 +1509,7 @@ function toMessageData(options) {
1471
1509
  class InteractionResponse {
1472
1510
  type;
1473
1511
  data;
1512
+ withResponse = false;
1474
1513
  constructor(type, data) {
1475
1514
  if (!Number.isFinite(type))
1476
1515
  throw new TypeError("Interaction response type must be finite.");
@@ -1481,13 +1520,13 @@ class InteractionResponse {
1481
1520
  return this.data === undefined ? { type: this.type } : { type: this.type, data: this.data };
1482
1521
  }
1483
1522
  static message(options) {
1484
- return new InteractionResponse(InteractionResponseType.ChannelMessage, toMessageData(options));
1523
+ return new InteractionResponse(InteractionResponseEnum.ChannelMessage, toMessageData(options));
1485
1524
  }
1486
1525
  static defer(ephemeral = false) {
1487
- return new InteractionResponse(InteractionResponseType.DeferredChannelMessage, ephemeral ? { flags: EPHEMERAL } : undefined);
1526
+ return new InteractionResponse(InteractionResponseEnum.DeferredChannelMessage, ephemeral ? { flags: EPHEMERAL } : undefined);
1488
1527
  }
1489
1528
  static pong() {
1490
- return new InteractionResponse(InteractionResponseType.Pong);
1529
+ return new InteractionResponse(InteractionResponseEnum.Pong);
1491
1530
  }
1492
1531
  }
1493
1532
 
@@ -1515,8 +1554,30 @@ class Interaction {
1515
1554
  this.type = data.type;
1516
1555
  this.data = data;
1517
1556
  }
1557
+ #commandType() {
1558
+ if (this.type !== InteractionEnum.ApplicationCommand)
1559
+ return 0;
1560
+ const type = this.data.data?.type;
1561
+ return typeof type === "number" ? type : COMMAND_CHAT_INPUT;
1562
+ }
1563
+ isCommand() {
1564
+ return this.type === InteractionEnum.ApplicationCommand;
1565
+ }
1518
1566
  isChatInputCommand() {
1519
- return this.type === InteractionType.ApplicationCommand;
1567
+ return this.#commandType() === COMMAND_CHAT_INPUT;
1568
+ }
1569
+ isContextMenuCommand() {
1570
+ const type = this.#commandType();
1571
+ return type === COMMAND_USER || type === COMMAND_MESSAGE;
1572
+ }
1573
+ isUserContextMenuCommand() {
1574
+ return this.#commandType() === COMMAND_USER;
1575
+ }
1576
+ isMessageContextMenuCommand() {
1577
+ return this.#commandType() === COMMAND_MESSAGE;
1578
+ }
1579
+ get resourceContext() {
1580
+ return this.#client.resourceContext;
1520
1581
  }
1521
1582
  awaitModalSubmit(options) {
1522
1583
  const collect = this.#client.resourceContext?.collectInteractions;
@@ -1533,13 +1594,13 @@ class Interaction {
1533
1594
  return collector.next();
1534
1595
  }
1535
1596
  isMessageComponent() {
1536
- return this.type === InteractionType.MessageComponent;
1597
+ return this.type === InteractionEnum.MessageComponent;
1537
1598
  }
1538
1599
  isModalSubmit() {
1539
- return this.type === InteractionType.ModalSubmit;
1600
+ return this.type === InteractionEnum.ModalSubmit;
1540
1601
  }
1541
1602
  isAutocomplete() {
1542
- return this.type === InteractionType.ApplicationCommandAutocomplete;
1603
+ return this.type === InteractionEnum.ApplicationCommandAutocomplete;
1543
1604
  }
1544
1605
  #componentType() {
1545
1606
  return this.isMessageComponent() ? this.data.data?.component_type ?? 0 : 0;
@@ -1624,12 +1685,24 @@ class Interaction {
1624
1685
  postResponse(response) {
1625
1686
  return this.#client.postInteractionResponse(this.id, this.token, response);
1626
1687
  }
1688
+ async acknowledgeWith(response, state, withResponse) {
1689
+ response.withResponse = withResponse;
1690
+ const result = await this.acknowledge(response, state);
1691
+ if (!withResponse)
1692
+ return result;
1693
+ const message = result?.resource?.message;
1694
+ return message ? new Message(message, this.#client.resourceContext) : null;
1695
+ }
1627
1696
  async reply(options) {
1628
- return this.acknowledge(InteractionResponse.message(toMessageData(options)), "replied");
1697
+ const { withResponse, rest } = splitWithResponse(options);
1698
+ return this.acknowledgeWith(InteractionResponse.message(toMessageData(rest)), "replied", withResponse);
1629
1699
  }
1630
1700
  async deferReply(options = false) {
1631
1701
  const ephemeral = typeof options === "boolean" ? options : options.ephemeral === true;
1632
- await this.acknowledge(InteractionResponse.defer(ephemeral), "deferred");
1702
+ const withResponse = typeof options === "object" && options.withResponse === true;
1703
+ const result = await this.acknowledgeWith(InteractionResponse.defer(ephemeral), "deferred", withResponse);
1704
+ if (withResponse)
1705
+ return result;
1633
1706
  }
1634
1707
  editReply(options) {
1635
1708
  this.assertAcknowledged();
@@ -1643,11 +1716,12 @@ class Interaction {
1643
1716
  return this.#client.followUpInteraction(this.token, toMessageData(options));
1644
1717
  }
1645
1718
  async update(options) {
1646
- return this.acknowledge(new InteractionResponse(InteractionResponseType.MessageUpdate, toMessageData(options)), "replied");
1719
+ const { withResponse, rest } = splitWithResponse(options);
1720
+ return this.acknowledgeWith(new InteractionResponse(InteractionResponseEnum.MessageUpdate, toMessageData(rest)), "replied", withResponse);
1647
1721
  }
1648
1722
  async showModal(modal) {
1649
1723
  const data = "toJSON" in modal && typeof modal.toJSON === "function" ? modal.toJSON() : modal;
1650
- return this.acknowledge(new InteractionResponse(InteractionResponseType.Modal, data), "replied");
1724
+ return this.acknowledge(new InteractionResponse(InteractionResponseEnum.Modal, data), "replied");
1651
1725
  }
1652
1726
  }
1653
1727
 
@@ -1664,33 +1738,69 @@ class CommandInteraction extends Interaction {
1664
1738
  }
1665
1739
  }
1666
1740
 
1741
+ class ContextMenuCommandInteraction extends CommandInteraction {
1742
+ #resolved() {
1743
+ return this.data.data?.resolved ?? {};
1744
+ }
1745
+ get targetId() {
1746
+ const id = this.data.data?.target_id;
1747
+ return typeof id === "string" ? id : null;
1748
+ }
1749
+ get targetUser() {
1750
+ const id = this.targetId;
1751
+ const raw = id ? this.#resolved().users?.[id] : undefined;
1752
+ return raw ? new User(raw) : null;
1753
+ }
1754
+ get targetMember() {
1755
+ const id = this.targetId;
1756
+ const raw = id ? this.#resolved().members?.[id] : undefined;
1757
+ const user = id ? this.#resolved().users?.[id] : undefined;
1758
+ if (!raw || !user || !this.guildId)
1759
+ return null;
1760
+ return new GuildMember({
1761
+ ...raw,
1762
+ user,
1763
+ guild_id: this.guildId
1764
+ }, this.resourceContext);
1765
+ }
1766
+ get targetMessage() {
1767
+ const id = this.targetId;
1768
+ const raw = id ? this.#resolved().messages?.[id] : undefined;
1769
+ return raw ? new Message(raw, this.resourceContext) : null;
1770
+ }
1771
+ }
1772
+
1667
1773
  class ComponentInteraction extends Interaction {
1668
1774
  get customId() {
1669
- return this.data?.data?.custom_id ?? "";
1775
+ const id = this.data.data?.custom_id;
1776
+ return typeof id === "string" ? id : "";
1670
1777
  }
1671
1778
  get messageId() {
1672
- return this.data?.message?.id;
1779
+ return this.data.message?.id;
1673
1780
  }
1674
1781
  get componentType() {
1675
- return this.data?.data?.component_type ?? 0;
1782
+ const type = this.data.data?.component_type;
1783
+ return typeof type === "number" ? type : 0;
1676
1784
  }
1677
1785
  get values() {
1678
- return this.data?.data?.values ?? [];
1679
- }
1680
- async deferUpdate() {
1681
- await this.acknowledge(new InteractionResponse(InteractionResponseType.DeferredMessageUpdate), "deferred");
1786
+ const values = this.data.data?.values;
1787
+ return Array.isArray(values) ? values : [];
1682
1788
  }
1683
- async update(options) {
1684
- return this.acknowledge(new InteractionResponse(InteractionResponseType.MessageUpdate, toMessageData(options)), "replied");
1789
+ async deferUpdate(options = {}) {
1790
+ const withResponse = options.withResponse === true;
1791
+ const result = await this.acknowledgeWith(new InteractionResponse(InteractionResponseEnum.DeferredMessageUpdate), "deferred", withResponse);
1792
+ if (withResponse)
1793
+ return result;
1685
1794
  }
1686
1795
  }
1687
1796
 
1688
1797
  class ModalSubmitInteraction extends Interaction {
1689
1798
  get customId() {
1690
- return this.data?.data?.custom_id ?? "";
1799
+ const id = this.data.data?.custom_id;
1800
+ return typeof id === "string" ? id : "";
1691
1801
  }
1692
1802
  getInputValue(customId) {
1693
- const rows = this.data?.data?.components ?? [];
1803
+ const rows = this.data.data?.components ?? [];
1694
1804
  for (const row of rows) {
1695
1805
  for (const comp of row.components ?? []) {
1696
1806
  if (comp.custom_id === customId)
@@ -1714,16 +1824,17 @@ class AutocompleteInteraction extends Interaction {
1714
1824
  this.options = new CommandOptions(data.data?.options ?? []);
1715
1825
  }
1716
1826
  get commandName() {
1717
- return this.data?.data?.name ?? "";
1827
+ const name = this.data.data?.name;
1828
+ return typeof name === "string" ? name : "";
1718
1829
  }
1719
1830
  get focusedOption() {
1720
- const options = this.data?.data?.options ?? [];
1721
- return findFocused(options);
1831
+ const options = this.data.data?.options;
1832
+ return findFocused(Array.isArray(options) ? options : []);
1722
1833
  }
1723
1834
  async respond(choices) {
1724
1835
  if (!Array.isArray(choices))
1725
1836
  throw new TypeError("Autocomplete choices must be an array.");
1726
- const response = new InteractionResponse(InteractionResponseType.Autocomplete, { choices });
1837
+ const response = new InteractionResponse(InteractionResponseEnum.Autocomplete, { choices });
1727
1838
  await this.acknowledge(response, "replied");
1728
1839
  }
1729
1840
  }
@@ -1741,18 +1852,21 @@ function findFocused(options) {
1741
1852
  }
1742
1853
  function createInteraction(client, data) {
1743
1854
  switch (data.type) {
1744
- case InteractionType.ApplicationCommand:
1745
- return new CommandInteraction(client, data);
1746
- case InteractionType.ApplicationCommandAutocomplete:
1855
+ case InteractionEnum.ApplicationCommand: {
1856
+ const commandType = data.data?.type;
1857
+ return commandType === COMMAND_USER || commandType === COMMAND_MESSAGE ? new ContextMenuCommandInteraction(client, data) : new CommandInteraction(client, data);
1858
+ }
1859
+ case InteractionEnum.ApplicationCommandAutocomplete:
1747
1860
  return new AutocompleteInteraction(client, data);
1748
- case InteractionType.MessageComponent:
1861
+ case InteractionEnum.MessageComponent:
1749
1862
  return new ComponentInteraction(client, data);
1750
- case InteractionType.ModalSubmit:
1863
+ case InteractionEnum.ModalSubmit:
1751
1864
  return new ModalSubmitInteraction(client, data);
1752
1865
  default:
1753
1866
  return new Interaction(client, data);
1754
1867
  }
1755
1868
  }
1869
+ var InteractionType = InteractionEnum;
1756
1870
  // packages/structures/src/embed.ts
1757
1871
  class Embed {
1758
1872
  #data;
@@ -1942,6 +2056,9 @@ class Message extends BaseStructure {
1942
2056
  reference;
1943
2057
  components;
1944
2058
  referencedMessage;
2059
+ stickers;
2060
+ poll;
2061
+ messageSnapshots;
1945
2062
  member;
1946
2063
  #context;
1947
2064
  constructor(data, context) {
@@ -1963,6 +2080,13 @@ class Message extends BaseStructure {
1963
2080
  this.mentionEveryone = data.mention_everyone ?? false;
1964
2081
  this.type = data.type ?? 0;
1965
2082
  this.reference = data.message_reference;
2083
+ this.stickers = data.sticker_items ?? (data.stickers ?? []).map(({ id, name, format_type }) => ({
2084
+ id,
2085
+ name,
2086
+ format_type
2087
+ }));
2088
+ this.poll = data.poll ?? null;
2089
+ this.messageSnapshots = data.message_snapshots ?? [];
1966
2090
  this.referencedMessage = data.referenced_message ? new Message(data.referenced_message, context) : data.referenced_message === null ? null : undefined;
1967
2091
  this.#context = context;
1968
2092
  this.member = data.member && data.guild_id ? new GuildMember({
@@ -1989,10 +2113,10 @@ class Message extends BaseStructure {
1989
2113
  update(options) {
1990
2114
  return this.edit(options);
1991
2115
  }
1992
- delete() {
2116
+ delete(reason) {
1993
2117
  if (!this.#context)
1994
2118
  throw new Error("This message is not attached to a client.");
1995
- return this.#context.deleteMessage(this.channelId, this.id);
2119
+ return this.#context.deleteMessage(this.channelId, this.id, reason);
1996
2120
  }
1997
2121
  reply(options) {
1998
2122
  if (!this.#context)
@@ -2039,15 +2163,15 @@ class Message extends BaseStructure {
2039
2163
  throw new Error("This message is not attached to a client.");
2040
2164
  return this.#context.removeAllReactions(this.channelId, this.id);
2041
2165
  }
2042
- pin() {
2166
+ pin(reason) {
2043
2167
  if (!this.#context?.pinMessage)
2044
2168
  throw new Error("This message is not attached to a client.");
2045
- return this.#context.pinMessage(this.channelId, this.id);
2169
+ return this.#context.pinMessage(this.channelId, this.id, reason);
2046
2170
  }
2047
- unpin() {
2171
+ unpin(reason) {
2048
2172
  if (!this.#context?.unpinMessage)
2049
2173
  throw new Error("This message is not attached to a client.");
2050
- return this.#context.unpinMessage(this.channelId, this.id);
2174
+ return this.#context.unpinMessage(this.channelId, this.id, reason);
2051
2175
  }
2052
2176
  get isEphemeral() {
2053
2177
  return (this.flags & 64) !== 0;
@@ -2101,21 +2225,25 @@ export {
2101
2225
  AutoModerationRule,
2102
2226
  AutocompleteInteraction,
2103
2227
  BaseStructure,
2228
+ CDN_BASE,
2104
2229
  CategoryChannel,
2105
2230
  Channel,
2106
2231
  CommandInteraction,
2107
2232
  CommandOptions,
2108
2233
  ComponentInteraction,
2234
+ ContextMenuCommandInteraction,
2109
2235
  DMChannel,
2110
2236
  Embed,
2111
2237
  Emoji,
2112
2238
  ForumChannel,
2113
2239
  Guild,
2114
2240
  GuildMember,
2115
- GuildOnboarding2 as GuildOnboarding,
2116
- GuildWelcomeScreen2 as GuildWelcomeScreen,
2241
+ GuildOnboarding,
2242
+ GuildWelcomeScreen,
2117
2243
  Interaction,
2244
+ InteractionEnum,
2118
2245
  InteractionResponse,
2246
+ InteractionResponseEnum,
2119
2247
  InteractionResponseType,
2120
2248
  InteractionType,
2121
2249
  Invite,
@@ -2133,10 +2261,12 @@ export {
2133
2261
  User,
2134
2262
  VoiceChannel,
2135
2263
  Webhook,
2264
+ WebhookEnum,
2136
2265
  WebhookType,
2137
2266
  WelcomeScreenChannel,
2267
+ cdnURL,
2138
2268
  createChannel,
2139
2269
  createInteraction
2140
2270
  };
2141
2271
 
2142
- //# debugId=56391DD25556C30C64756E2164756E21
2272
+ //# debugId=07D330C2B35D9E3E64756E2164756E21