@impulsedev/chameleon 1.7.0 → 2.0.0

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,3 +1,37 @@
1
+ import {
2
+ ActionRowBuilder,
3
+ ButtonBuilder,
4
+ ButtonStyle,
5
+ Colors,
6
+ ComponentType,
7
+ EmbedBuilder,
8
+ ModalBuilder,
9
+ SelectMenuBuilder,
10
+ TextInputBuilder,
11
+ buildAutoModRule,
12
+ buildChannel,
13
+ buildEmoji,
14
+ buildEntitlement,
15
+ buildGuild,
16
+ buildIntegration,
17
+ buildInteraction,
18
+ buildMember,
19
+ buildMessage,
20
+ buildRole,
21
+ buildScheduledEvent,
22
+ buildStageInstance,
23
+ buildSticker,
24
+ buildStickerItem,
25
+ buildUser,
26
+ buildVoiceState,
27
+ resolveChannel,
28
+ resolveGuild,
29
+ resolveRole,
30
+ resolveUser,
31
+ serializeComponent,
32
+ toSnakeCase
33
+ } from "./chunk-F2RRJ7OJ.js";
34
+
1
35
  // src/types/user/index.ts
2
36
  var UserFlag = {
3
37
  STAFF: 1 << 0,
@@ -462,26 +496,6 @@ var AutoModerationActionType = {
462
496
  BLOCK_MEMBER_INTERACTION: 4
463
497
  };
464
498
 
465
- // src/types/components/index.ts
466
- var ComponentType = {
467
- ACTION_ROW: 1,
468
- BUTTON: 2,
469
- STRING_SELECT: 3,
470
- TEXT_INPUT: 4,
471
- USER_SELECT: 5,
472
- ROLE_SELECT: 6,
473
- MENTIONABLE_SELECT: 7,
474
- CHANNEL_SELECT: 8
475
- };
476
- var ButtonStyle = {
477
- PRIMARY: 1,
478
- SECONDARY: 2,
479
- SUCCESS: 3,
480
- DANGER: 4,
481
- LINK: 5,
482
- PREMIUM: 6
483
- };
484
-
485
499
  // src/types/entitlement/index.ts
486
500
  var EntitlementType = {
487
501
  PURCHASE: 1,
@@ -1215,7 +1229,7 @@ var ChameleonGateway = class {
1215
1229
  // package.json
1216
1230
  var package_default = {
1217
1231
  name: "@impulsedev/chameleon",
1218
- version: "1.7.0",
1232
+ version: "2.0.0",
1219
1233
  description: "highly optimized, memory-efficient, and fully type-safe Discord API library",
1220
1234
  main: "dist/index.js",
1221
1235
  types: "dist/index.d.ts",
@@ -1290,547 +1304,6 @@ var MESSAGE_FLAGS = {
1290
1304
  var CHAMELEON_VERSION = package_default.version;
1291
1305
  var CHAMELEON = package_default.name;
1292
1306
 
1293
- // src/builders/embed.ts
1294
- var Colors = {
1295
- Blue: 2003199,
1296
- Purple: 10181046,
1297
- Orange: 16744272,
1298
- Pink: 16739201,
1299
- White: 16777215,
1300
- Blurple: 5793266,
1301
- Green: 5763719,
1302
- Yellow: 16705372,
1303
- Fuchsia: 15418782,
1304
- Red: 15548997,
1305
- Black: 2303786,
1306
- Transparent: 3092790
1307
- };
1308
- var EmbedBuilder = class {
1309
- data = {};
1310
- constructor(data) {
1311
- if (data) Object.assign(this.data, data);
1312
- }
1313
- setTitle(title) {
1314
- this.data.title = title;
1315
- return this;
1316
- }
1317
- setDescription(description) {
1318
- this.data.description = description;
1319
- return this;
1320
- }
1321
- setColor(color) {
1322
- this.data.color = color;
1323
- return this;
1324
- }
1325
- setURL(url) {
1326
- this.data.url = url;
1327
- return this;
1328
- }
1329
- setTimestamp(ts = Date.now()) {
1330
- this.data.timestamp = ts instanceof Date ? ts.getTime() : ts;
1331
- return this;
1332
- }
1333
- setFooter(text, iconUrl) {
1334
- this.data.footer = {
1335
- text,
1336
- ...iconUrl ? { iconUrl } : {}
1337
- };
1338
- return this;
1339
- }
1340
- setAuthor(name, iconUrl, url) {
1341
- this.data.author = {
1342
- name,
1343
- ...iconUrl ? { iconUrl } : {},
1344
- ...url ? { url } : {}
1345
- };
1346
- return this;
1347
- }
1348
- setImage(url) {
1349
- this.data.image = { url };
1350
- return this;
1351
- }
1352
- setThumbnail(url) {
1353
- this.data.thumbnail = { url };
1354
- return this;
1355
- }
1356
- addField(name, value, inline = false) {
1357
- if (!this.data.fields) this.data.fields = [];
1358
- this.data.fields.push({ name, value, inline });
1359
- return this;
1360
- }
1361
- addFields(...fields) {
1362
- if (!this.data.fields) this.data.fields = [];
1363
- this.data.fields.push(...fields);
1364
- return this;
1365
- }
1366
- build() {
1367
- return this.data;
1368
- }
1369
- toJSON() {
1370
- const e = this.data;
1371
- const payload = {};
1372
- if (typeof e.title === "string") payload.title = e.title;
1373
- if (typeof e.description === "string") payload.description = e.description;
1374
- if (typeof e.color === "number") payload.color = e.color;
1375
- if (typeof e.url === "string") payload.url = e.url;
1376
- if (typeof e.timestamp === "number" && !Number.isNaN(e.timestamp)) {
1377
- payload.timestamp = new Date(e.timestamp).toISOString();
1378
- }
1379
- if (e.author) {
1380
- const author = {
1381
- name: e.author.name
1382
- };
1383
- if (typeof e.author.url === "string") {
1384
- author.url = e.author.url;
1385
- }
1386
- if (typeof e.author.iconUrl === "string") {
1387
- author.icon_url = e.author.iconUrl;
1388
- }
1389
- if (typeof e.author.proxyIconUrl === "string") {
1390
- author.proxy_icon_url = e.author.proxyIconUrl;
1391
- }
1392
- payload.author = author;
1393
- }
1394
- if (e.footer) {
1395
- const footer = {
1396
- text: e.footer.text
1397
- };
1398
- if (typeof e.footer.iconUrl === "string") {
1399
- footer.icon_url = e.footer.iconUrl;
1400
- }
1401
- if (typeof e.footer.proxyIconUrl === "string") {
1402
- footer.proxy_icon_url = e.footer.proxyIconUrl;
1403
- }
1404
- payload.footer = footer;
1405
- }
1406
- if (e.image?.url) {
1407
- payload.image = {
1408
- url: e.image.url
1409
- };
1410
- }
1411
- if (e.thumbnail?.url) {
1412
- payload.thumbnail = {
1413
- url: e.thumbnail.url
1414
- };
1415
- }
1416
- if (Array.isArray(e.fields) && e.fields.length > 0) {
1417
- payload.fields = e.fields.map((f) => ({
1418
- name: f.name,
1419
- value: f.value,
1420
- inline: !!f.inline
1421
- }));
1422
- }
1423
- return payload;
1424
- }
1425
- };
1426
-
1427
- // src/builders/components.ts
1428
- function serializeEmoji(emoji) {
1429
- if (!emoji) return void 0;
1430
- return {
1431
- id: emoji.id,
1432
- name: emoji.name,
1433
- animated: emoji.animated
1434
- };
1435
- }
1436
- var ButtonBuilder = class {
1437
- data = {
1438
- type: ComponentType.BUTTON
1439
- };
1440
- setCustomId(id) {
1441
- this.data.customId = id;
1442
- return this;
1443
- }
1444
- setLabel(label) {
1445
- this.data.label = label;
1446
- return this;
1447
- }
1448
- setStyle(style) {
1449
- this.data.style = style;
1450
- return this;
1451
- }
1452
- setEmoji(emoji) {
1453
- this.data.emoji = emoji;
1454
- return this;
1455
- }
1456
- setDisabled(disabled = true) {
1457
- this.data.disabled = disabled;
1458
- return this;
1459
- }
1460
- setURL(url) {
1461
- this.data.url = url;
1462
- this.data.style = ButtonStyle.LINK;
1463
- return this;
1464
- }
1465
- build() {
1466
- return {
1467
- ...this.data
1468
- };
1469
- }
1470
- toJSON() {
1471
- return {
1472
- type: ComponentType.BUTTON,
1473
- custom_id: this.data.customId,
1474
- label: this.data.label,
1475
- style: this.data.style,
1476
- disabled: this.data.disabled,
1477
- url: this.data.url,
1478
- emoji: serializeEmoji(this.data.emoji)
1479
- };
1480
- }
1481
- };
1482
- var SelectMenuBuilder = class {
1483
- data = {
1484
- type: ComponentType.STRING_SELECT
1485
- };
1486
- setCustomId(id) {
1487
- this.data.customId = id;
1488
- return this;
1489
- }
1490
- setPlaceholder(placeholder) {
1491
- this.data.placeholder = placeholder;
1492
- return this;
1493
- }
1494
- setMinValues(min) {
1495
- this.data.minValues = min;
1496
- return this;
1497
- }
1498
- setMaxValues(max) {
1499
- this.data.maxValues = max;
1500
- return this;
1501
- }
1502
- setDisabled(disabled = true) {
1503
- this.data.disabled = disabled;
1504
- return this;
1505
- }
1506
- setType(type) {
1507
- this.data.type = type;
1508
- return this;
1509
- }
1510
- addOption(option) {
1511
- if (!this.data.options) {
1512
- this.data.options = [];
1513
- }
1514
- this.data.options.push(option);
1515
- return this;
1516
- }
1517
- addOptions(...options) {
1518
- if (!this.data.options) {
1519
- this.data.options = [];
1520
- }
1521
- this.data.options.push(...options);
1522
- return this;
1523
- }
1524
- build() {
1525
- return {
1526
- ...this.data
1527
- };
1528
- }
1529
- toJSON() {
1530
- return {
1531
- type: this.data.type ?? ComponentType.STRING_SELECT,
1532
- custom_id: this.data.customId,
1533
- placeholder: this.data.placeholder,
1534
- min_values: this.data.minValues,
1535
- max_values: this.data.maxValues,
1536
- disabled: this.data.disabled,
1537
- options: this.data.options?.map((option) => ({
1538
- label: option.label,
1539
- value: option.value,
1540
- description: option.description,
1541
- emoji: serializeEmoji(option.emoji),
1542
- default: option.default
1543
- }))
1544
- };
1545
- }
1546
- };
1547
- var TextInputBuilder = class {
1548
- data = {
1549
- type: ComponentType.TEXT_INPUT
1550
- };
1551
- _minLength;
1552
- _maxLength;
1553
- _required;
1554
- _value;
1555
- setCustomId(id) {
1556
- this.data.customId = id;
1557
- return this;
1558
- }
1559
- setLabel(label) {
1560
- this.data.label = label;
1561
- return this;
1562
- }
1563
- setStyle(style) {
1564
- this.data.style = style;
1565
- return this;
1566
- }
1567
- setPlaceholder(placeholder) {
1568
- this.data.placeholder = placeholder;
1569
- return this;
1570
- }
1571
- setMinLength(length) {
1572
- this._minLength = length;
1573
- return this;
1574
- }
1575
- setMaxLength(length) {
1576
- this._maxLength = length;
1577
- return this;
1578
- }
1579
- setRequired(required = true) {
1580
- this._required = required;
1581
- return this;
1582
- }
1583
- setValue(value) {
1584
- this._value = value;
1585
- return this;
1586
- }
1587
- build() {
1588
- return {
1589
- ...this.data,
1590
- minLength: this._minLength,
1591
- maxLength: this._maxLength,
1592
- required: this._required,
1593
- value: this._value
1594
- };
1595
- }
1596
- toJSON() {
1597
- return {
1598
- type: ComponentType.TEXT_INPUT,
1599
- custom_id: this.data.customId,
1600
- style: this.data.style,
1601
- label: this.data.label,
1602
- placeholder: this.data.placeholder,
1603
- min_length: this._minLength,
1604
- max_length: this._maxLength,
1605
- required: this._required,
1606
- value: this._value
1607
- };
1608
- }
1609
- };
1610
- var ActionRowBuilder = class {
1611
- data = {
1612
- type: ComponentType.ACTION_ROW,
1613
- components: []
1614
- };
1615
- addComponent(component) {
1616
- this.data.components.push(component);
1617
- return this;
1618
- }
1619
- addComponents(...components) {
1620
- for (const component of components) {
1621
- this.addComponent(component);
1622
- }
1623
- return this;
1624
- }
1625
- build() {
1626
- return {
1627
- ...this.data,
1628
- components: [...this.data.components]
1629
- };
1630
- }
1631
- toJSON() {
1632
- return {
1633
- type: ComponentType.ACTION_ROW,
1634
- components: this.data.components?.map((component) => {
1635
- if (component && typeof component.toJSON === "function") {
1636
- return component.toJSON();
1637
- }
1638
- return component;
1639
- })
1640
- };
1641
- }
1642
- };
1643
- var ModalBuilder = class {
1644
- _title = "";
1645
- _customId = "";
1646
- _components = [];
1647
- setTitle(title) {
1648
- this._title = title;
1649
- return this;
1650
- }
1651
- setCustomId(id) {
1652
- this._customId = id;
1653
- return this;
1654
- }
1655
- addComponent(component) {
1656
- this._components.push(component);
1657
- return this;
1658
- }
1659
- addComponents(...components) {
1660
- for (const component of components) {
1661
- this.addComponent(component);
1662
- }
1663
- return this;
1664
- }
1665
- build() {
1666
- return {
1667
- title: this._title,
1668
- custom_id: this._customId,
1669
- components: [...this._components]
1670
- };
1671
- }
1672
- toJSON() {
1673
- return {
1674
- title: this._title,
1675
- custom_id: this._customId,
1676
- components: this._components.map((component) => {
1677
- if (component && typeof component.toJSON === "function") {
1678
- return component.toJSON();
1679
- }
1680
- return component;
1681
- })
1682
- };
1683
- }
1684
- };
1685
-
1686
- // src/builders/index.ts
1687
- function buildUser(raw) {
1688
- return {
1689
- id: raw.id,
1690
- username: raw.username,
1691
- discriminator: raw.discriminator,
1692
- globalName: raw.global_name ?? null,
1693
- avatar: raw.avatar ?? null,
1694
- bot: raw.bot ?? false,
1695
- system: raw.system ?? false,
1696
- mfaEnabled: raw.mfa_enabled ?? false,
1697
- banner: raw.banner ?? null,
1698
- accentColor: raw.accent_color ?? null,
1699
- locale: raw.locale ?? void 0,
1700
- flags: raw.flags ?? 0,
1701
- premiumType: raw.premium_type ?? 0,
1702
- publicFlags: raw.public_flags ?? 0
1703
- };
1704
- }
1705
- function buildChannel(raw, guildId) {
1706
- return {
1707
- id: raw.id,
1708
- type: raw.type,
1709
- guildId: raw.guild_id ?? guildId ?? void 0,
1710
- name: raw.name ?? null,
1711
- position: raw.position ?? 0,
1712
- parentId: raw.parent_id ?? null,
1713
- topic: raw.topic ?? null,
1714
- nsfw: raw.nsfw ?? false,
1715
- lastMessageId: raw.last_message_id ?? null,
1716
- bitrate: raw.bitrate ?? void 0,
1717
- userLimit: raw.user_limit ?? void 0,
1718
- rateLimitPerUser: raw.rate_limit_per_user ?? 0,
1719
- permissionOverwrites: raw.permission_overwrites ?? []
1720
- };
1721
- }
1722
- function buildGuild(raw) {
1723
- return {
1724
- id: raw.id,
1725
- name: raw.name,
1726
- icon: raw.icon ?? null,
1727
- splash: raw.splash ?? null,
1728
- discoverySplash: raw.discovery_splash ?? null,
1729
- ownerId: raw.owner_id,
1730
- afkChannelId: raw.afk_channel_id ?? null,
1731
- afkTimeout: raw.afk_timeout ?? 0,
1732
- verificationLevel: raw.verification_level ?? 0,
1733
- defaultMessageNotifications: raw.default_message_notifications ?? 0,
1734
- explicitContentFilter: raw.explicit_content_filter ?? 0,
1735
- features: raw.features ?? [],
1736
- mfaLevel: raw.mfa_level ?? 0,
1737
- systemChannelId: raw.system_channel_id ?? null,
1738
- systemChannelFlags: raw.system_channel_flags ?? 0,
1739
- rulesChannelId: raw.rules_channel_id ?? null,
1740
- memberCount: raw.member_count ?? 0,
1741
- vanityUrlCode: raw.vanity_url_code ?? null,
1742
- description: raw.description ?? null,
1743
- banner: raw.banner ?? null,
1744
- premiumTier: raw.premium_tier ?? 0,
1745
- premiumSubscriptionCount: raw.premium_subscription_count ?? 0,
1746
- preferredLocale: raw.preferred_locale ?? "en-US",
1747
- publicUpdatesChannelId: raw.public_updates_channel_id ?? null,
1748
- nsfwLevel: raw.nsfw_level ?? 0,
1749
- premiumProgressBarEnabled: raw.premium_progress_bar_enabled ?? false,
1750
- roles: Array.isArray(raw.roles) ? raw.roles.map((r) => buildRole(r)) : [],
1751
- emojis: raw.emojis ?? [],
1752
- applicationId: raw.application_id ?? null,
1753
- large: raw.large ?? false
1754
- };
1755
- }
1756
- function buildRole(raw) {
1757
- return {
1758
- id: raw.id,
1759
- name: raw.name,
1760
- color: raw.color ?? 0,
1761
- hoist: raw.hoist ?? false,
1762
- position: raw.position ?? 0,
1763
- permissions: raw.permissions,
1764
- managed: raw.managed ?? false,
1765
- mentionable: raw.mentionable ?? false,
1766
- icon: raw.icon ?? null,
1767
- unicodeEmoji: raw.unicode_emoji ?? null,
1768
- flags: raw.flags ?? 0
1769
- };
1770
- }
1771
- function buildMember(raw, guildId, cache) {
1772
- let userObj;
1773
- if (raw.user) {
1774
- const user = buildUser(raw.user);
1775
- cache.users.set(user.id, user);
1776
- userObj = user;
1777
- }
1778
- return {
1779
- ...userObj ? { user: userObj } : {},
1780
- nick: raw.nick ?? null,
1781
- avatar: raw.avatar ?? null,
1782
- roles: raw.roles ?? [],
1783
- joinedAt: raw.joined_at ? Date.parse(raw.joined_at) : 0,
1784
- premiumSince: raw.premium_since ? Date.parse(raw.premium_since) : null,
1785
- deaf: raw.deaf ?? false,
1786
- mute: raw.mute ?? false,
1787
- pending: raw.pending ?? false,
1788
- flags: raw.flags ?? 0,
1789
- communicationDisabledUntil: raw.communication_disabled_until ? Date.parse(raw.communication_disabled_until) : null
1790
- };
1791
- }
1792
- function buildMessage(raw, cache, oldMessage) {
1793
- const authorRaw = raw.author;
1794
- const author = authorRaw ? buildUser(authorRaw) : oldMessage?.author ?? {};
1795
- if (authorRaw && author.id) {
1796
- cache.users.set(author.id, author);
1797
- }
1798
- const msgId = raw.id ?? oldMessage?.id;
1799
- const channelId = raw.channel_id ?? oldMessage?.channelId;
1800
- const guildId = raw.guild_id ? raw.guild_id : oldMessage?.guildId;
1801
- const msg = {
1802
- id: msgId,
1803
- channelId,
1804
- author,
1805
- ...guildId ? { guildId } : {},
1806
- url: `https://discord.com/channels/${guildId ?? "@me"}/${channelId}/${msgId}`,
1807
- content: raw.content ?? oldMessage?.content ?? "",
1808
- timestamp: raw.timestamp ? Date.parse(raw.timestamp) : oldMessage?.timestamp ?? Date.now(),
1809
- editedTimestamp: raw.edited_timestamp ? Date.parse(raw.edited_timestamp) : oldMessage?.editedTimestamp ?? null,
1810
- tts: raw.tts ?? oldMessage?.tts ?? false,
1811
- mentionEveryone: raw.mention_everyone ?? oldMessage?.mentionEveryone ?? false,
1812
- mentions: raw.mentions ? raw.mentions.map((m) => buildUser(m)) : oldMessage?.mentions ?? [],
1813
- mentionRoles: raw.mention_roles ?? oldMessage?.mentionRoles ?? [],
1814
- attachments: raw.attachments ?? oldMessage?.attachments ?? [],
1815
- embeds: raw.embeds ?? oldMessage?.embeds ?? [],
1816
- pinned: raw.pinned ?? oldMessage?.pinned ?? false,
1817
- type: raw.type ?? oldMessage?.type ?? 0
1818
- };
1819
- return msg;
1820
- }
1821
- function resolveChannel(channelId, cache) {
1822
- return cache.channels.get(channelId) ?? { id: channelId };
1823
- }
1824
- function resolveGuild(guildId, cache) {
1825
- return cache.guilds.get(guildId) ?? { id: guildId };
1826
- }
1827
- function resolveUser(userId, cache) {
1828
- return cache.users.get(userId) ?? { id: userId };
1829
- }
1830
- function resolveRole(roleId, cache) {
1831
- return cache.roles.get(roleId) ?? { id: roleId };
1832
- }
1833
-
1834
1307
  // src/commands/options.ts
1835
1308
  var opt = {
1836
1309
  string: (description, options) => ({
@@ -1874,8 +1347,7 @@ var opt = {
1874
1347
  };
1875
1348
 
1876
1349
  // src/commands/context.ts
1877
- var CommandContext = class {
1878
- options;
1350
+ var BaseInteractionContext = class {
1879
1351
  user;
1880
1352
  guild;
1881
1353
  channel;
@@ -1884,11 +1356,10 @@ var CommandContext = class {
1884
1356
  _client;
1885
1357
  _deferred = false;
1886
1358
  _replied = false;
1887
- constructor(client, rawInteraction, parsedOptions, user, guild, channel) {
1359
+ constructor(client, raw, user, guild, channel) {
1888
1360
  this._client = client;
1889
- this.interactionId = rawInteraction.id;
1890
- this.interactionToken = rawInteraction.token;
1891
- this.options = parsedOptions;
1361
+ this.interactionId = raw.id;
1362
+ this.interactionToken = raw.token;
1892
1363
  this.user = user;
1893
1364
  this.guild = guild;
1894
1365
  this.channel = channel;
@@ -1899,10 +1370,27 @@ var CommandContext = class {
1899
1370
  get deferred() {
1900
1371
  return this._deferred;
1901
1372
  }
1373
+ _resolvePayload(payload) {
1374
+ const data = typeof payload === "string" ? { content: payload } : { ...payload };
1375
+ if (typeof payload === "object") {
1376
+ if (payload.ephemeral) data.flags = MESSAGE_FLAGS.EPHEMERAL;
1377
+ if (payload.embeds) {
1378
+ data.embeds = payload.embeds.map((e) => {
1379
+ if (e && typeof e.toJSON === "function") {
1380
+ return e.toJSON();
1381
+ }
1382
+ return e;
1383
+ });
1384
+ }
1385
+ if (payload.components) {
1386
+ data.components = payload.components.map((c) => serializeComponent(c));
1387
+ }
1388
+ }
1389
+ return data;
1390
+ }
1902
1391
  async reply(payload) {
1903
1392
  if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
1904
- const data = typeof payload === "string" ? { content: payload } : { ...payload };
1905
- if (typeof payload === "object" && payload.ephemeral) data.flags = 64;
1393
+ const data = this._resolvePayload(payload);
1906
1394
  await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
1907
1395
  type: 4 /* CHANNEL_MESSAGE_WITH_SOURCE */,
1908
1396
  data
@@ -1913,16 +1401,13 @@ var CommandContext = class {
1913
1401
  if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
1914
1402
  await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
1915
1403
  type: 5 /* DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE */,
1916
- data: {
1917
- flags: options?.ephemeral ? 64 : 0
1918
- }
1404
+ data: { flags: options?.ephemeral ? MESSAGE_FLAGS.EPHEMERAL : 0 }
1919
1405
  });
1920
1406
  this._deferred = true;
1921
1407
  }
1922
1408
  async followUp(payload) {
1923
- if (!this._deferred && !this._replied) throw new Error("Interaction not acknowledged. Use reply or defer first.");
1924
- const data = typeof payload === "string" ? { content: payload } : { ...payload };
1925
- if (typeof payload === "object" && payload.ephemeral) data.flags = 64;
1409
+ if (!this._deferred && !this._replied) throw new Error("Interaction not acknowledged.");
1410
+ const data = this._resolvePayload(payload);
1926
1411
  await this._client.rest.post(`/webhooks/${this._client.user?.id}/${this.interactionToken}`, data);
1927
1412
  }
1928
1413
  async showModal(modal) {
@@ -1930,13 +1415,12 @@ var CommandContext = class {
1930
1415
  const payload = modal.type === "modal" ? {
1931
1416
  custom_id: modal.customId,
1932
1417
  title: modal.title,
1933
- components: modal.fields.map((f) => ({
1418
+ components: Array.isArray(modal.fields) ? modal.fields.map((f) => ({
1934
1419
  type: 1 /* ACTION_ROW */,
1935
1420
  components: [{
1936
1421
  type: 4 /* TEXT_INPUT */,
1937
1422
  custom_id: f.id,
1938
1423
  style: f.type,
1939
- // 1 short, 2 paragraph
1940
1424
  label: f.label,
1941
1425
  required: f.required,
1942
1426
  min_length: f.minLength,
@@ -1944,7 +1428,7 @@ var CommandContext = class {
1944
1428
  placeholder: f.placeholder,
1945
1429
  value: f.value
1946
1430
  }]
1947
- }))
1431
+ })) : []
1948
1432
  } : modal;
1949
1433
  await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
1950
1434
  type: 9 /* MODAL */,
@@ -1953,6 +1437,13 @@ var CommandContext = class {
1953
1437
  this._replied = true;
1954
1438
  }
1955
1439
  };
1440
+ var CommandContext = class extends BaseInteractionContext {
1441
+ options;
1442
+ constructor(client, rawInteraction, parsedOptions, user, guild, channel) {
1443
+ super(client, rawInteraction, user, guild, channel);
1444
+ this.options = parsedOptions;
1445
+ }
1446
+ };
1956
1447
 
1957
1448
  // src/commands/command.ts
1958
1449
  function defineSubcommand(def) {
@@ -1966,48 +1457,57 @@ function defineCommand(def) {
1966
1457
  }
1967
1458
 
1968
1459
  // src/commands/interactions.ts
1969
- var ComponentContext = class {
1460
+ var ModalContext = class extends BaseInteractionContext {
1970
1461
  customId;
1971
- user;
1972
- guild;
1973
- channel;
1974
- message;
1975
- interactionId;
1976
- interactionToken;
1977
- _client;
1978
- _deferred = false;
1979
- _replied = false;
1462
+ _fields = /* @__PURE__ */ new Map();
1980
1463
  constructor(client, raw, user, guild, channel) {
1981
- this._client = client;
1982
- this.interactionId = raw.id;
1983
- this.interactionToken = raw.token;
1464
+ super(client, raw, user, guild, channel);
1984
1465
  this.customId = raw.data?.custom_id ?? "";
1985
- this.message = raw.message;
1986
- this.user = user;
1987
- this.guild = guild;
1988
- this.channel = channel;
1989
- }
1990
- get replied() {
1991
- return this._replied;
1992
- }
1993
- get deferred() {
1994
- return this._deferred;
1466
+ const rows = raw.data?.components ?? [];
1467
+ for (const row of rows) {
1468
+ for (const comp of row.components ?? []) {
1469
+ if (comp.custom_id && comp.value !== void 0) {
1470
+ this._fields.set(comp.custom_id, comp.value);
1471
+ }
1472
+ }
1473
+ }
1995
1474
  }
1996
- /** Values from a select menu interaction */
1475
+ // Get a text input value by its customId
1476
+ // values from a select menu interaction
1997
1477
  get values() {
1998
1478
  return this._values ?? [];
1999
1479
  }
2000
- async reply(payload) {
2001
- if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
2002
- const data = typeof payload === "string" ? { content: payload } : { ...payload };
2003
- if (typeof payload === "object" && payload.ephemeral) data.flags = 64;
2004
- await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
2005
- type: 4 /* CHANNEL_MESSAGE_WITH_SOURCE */,
2006
- data
2007
- });
2008
- this._replied = true;
2009
- }
2010
- async deferUpdate() {
1480
+ // Get all field values as a plain object
1481
+ get fields() {
1482
+ return Object.fromEntries(this._fields);
1483
+ }
1484
+ };
1485
+
1486
+ // src/components/context.ts
1487
+ var ComponentContext = class extends BaseInteractionContext {
1488
+ customId;
1489
+ message;
1490
+ values;
1491
+ fields;
1492
+ constructor(client, raw, user, guild, channel) {
1493
+ super(client, raw, user, guild, channel);
1494
+ const data = raw.data;
1495
+ this.customId = data?.custom_id ?? "";
1496
+ if (raw.message) {
1497
+ this.message = raw.message;
1498
+ }
1499
+ this.values = data?.values ?? [];
1500
+ const fields = {};
1501
+ if (data?.components) {
1502
+ for (const row of data.components) {
1503
+ for (const comp of row.components) {
1504
+ fields[comp.custom_id] = comp.value;
1505
+ }
1506
+ }
1507
+ }
1508
+ this.fields = fields;
1509
+ }
1510
+ async deferUpdate() {
2011
1511
  if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
2012
1512
  await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
2013
1513
  type: 6 /* DEFERRED_UPDATE_MESSAGE */
@@ -2016,87 +1516,13 @@ var ComponentContext = class {
2016
1516
  }
2017
1517
  async update(payload) {
2018
1518
  if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
2019
- const data = typeof payload === "string" ? { content: payload } : { ...payload };
2020
- if (typeof payload === "object" && payload.ephemeral) data.flags = 64;
1519
+ const data = this._resolvePayload(payload);
2021
1520
  await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
2022
1521
  type: 7 /* UPDATE_MESSAGE */,
2023
1522
  data
2024
1523
  });
2025
1524
  this._replied = true;
2026
1525
  }
2027
- async followUp(payload) {
2028
- if (!this._deferred && !this._replied) throw new Error("Interaction not acknowledged.");
2029
- const data = typeof payload === "string" ? { content: payload } : { ...payload };
2030
- if (typeof payload === "object" && payload.ephemeral) data.flags = 64;
2031
- await this._client.rest.post(`/webhooks/${this._client.user?.id}/${this.interactionToken}`, data);
2032
- }
2033
- };
2034
- var ModalContext = class {
2035
- customId;
2036
- user;
2037
- guild;
2038
- channel;
2039
- interactionId;
2040
- interactionToken;
2041
- _fields = /* @__PURE__ */ new Map();
2042
- _client;
2043
- _replied = false;
2044
- _deferred = false;
2045
- constructor(client, raw, user, guild, channel) {
2046
- this._client = client;
2047
- this.interactionId = raw.id;
2048
- this.interactionToken = raw.token;
2049
- this.customId = raw.data?.custom_id ?? "";
2050
- this.user = user;
2051
- this.guild = guild;
2052
- this.channel = channel;
2053
- const rows = raw.data?.components ?? [];
2054
- for (const row of rows) {
2055
- for (const comp of row.components ?? []) {
2056
- if (comp.custom_id && comp.value !== void 0) {
2057
- this._fields.set(comp.custom_id, comp.value);
2058
- }
2059
- }
2060
- }
2061
- }
2062
- get replied() {
2063
- return this._replied;
2064
- }
2065
- get deferred() {
2066
- return this._deferred;
2067
- }
2068
- /** Get a text input value by its customId */
2069
- getField(customId) {
2070
- return this._fields.get(customId);
2071
- }
2072
- /** Get all field values as a plain object */
2073
- get fields() {
2074
- return Object.fromEntries(this._fields);
2075
- }
2076
- async reply(payload) {
2077
- if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
2078
- const data = typeof payload === "string" ? { content: payload } : { ...payload };
2079
- if (typeof payload === "object" && payload.ephemeral) data.flags = 64;
2080
- await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
2081
- type: 4 /* CHANNEL_MESSAGE_WITH_SOURCE */,
2082
- data
2083
- });
2084
- this._replied = true;
2085
- }
2086
- async defer(options) {
2087
- if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
2088
- await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
2089
- type: 5 /* DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE */,
2090
- data: { flags: options?.ephemeral ? 64 : 0 }
2091
- });
2092
- this._deferred = true;
2093
- }
2094
- async followUp(payload) {
2095
- if (!this._deferred && !this._replied) throw new Error("Interaction not acknowledged.");
2096
- const data = typeof payload === "string" ? { content: payload } : { ...payload };
2097
- if (typeof payload === "object" && payload.ephemeral) data.flags = 64;
2098
- await this._client.rest.post(`/webhooks/${this._client.user?.id}/${this.interactionToken}`, data);
2099
- }
2100
1526
  };
2101
1527
 
2102
1528
  // src/commands/manager.ts
@@ -2179,11 +1605,11 @@ var CommandManager = class {
2179
1605
  };
2180
1606
  const options = [];
2181
1607
  if (cmd.subcommands) {
2182
- for (const [subName, subDefRaw] of Object.entries(cmd.subcommands)) {
2183
- const subDef = subDefRaw;
1608
+ for (const [subName, subDef] of Object.entries(cmd.subcommands)) {
2184
1609
  const subOpts = [];
2185
1610
  if (subDef.options) {
2186
- for (const [optName, optDef] of Object.entries(subDef.options)) {
1611
+ for (const [optName, optDefRaw] of Object.entries(subDef.options)) {
1612
+ const optDef = optDefRaw;
2187
1613
  subOpts.push({
2188
1614
  type: mapType(optDef.type),
2189
1615
  name: optName,
@@ -2203,7 +1629,8 @@ var CommandManager = class {
2203
1629
  });
2204
1630
  }
2205
1631
  } else if (cmd.options) {
2206
- for (const [optName, optDef] of Object.entries(cmd.options)) {
1632
+ for (const [optName, optDefRaw] of Object.entries(cmd.options)) {
1633
+ const optDef = optDefRaw;
2207
1634
  options.push({
2208
1635
  type: mapType(optDef.type),
2209
1636
  name: optName,
@@ -2222,15 +1649,18 @@ var CommandManager = class {
2222
1649
  };
2223
1650
  }
2224
1651
  async handleInteraction(raw) {
2225
- if (raw.type === 3 /* MESSAGE_COMPONENT */) return this._handleComponentInteraction(raw);
2226
- if (raw.type === 5 /* MODAL_SUBMIT */) return this._handleModalInteraction(raw);
1652
+ const data = raw.data;
1653
+ if (!data) return;
1654
+ if (raw.type === 3 /* MESSAGE_COMPONENT */) return this._handleComponentInteraction(raw, data);
1655
+ if (raw.type === 5 /* MODAL_SUBMIT */) return this._handleModalInteraction(raw, data);
2227
1656
  if (raw.type !== 2 /* APPLICATION_COMMAND */) return;
2228
- const name = raw.data.name;
1657
+ const name = data.name;
1658
+ if (!name) return;
2229
1659
  const command = this._commands.get(name);
2230
1660
  if (!command) return;
2231
1661
  const parsedOptions = {};
2232
1662
  let targetExecute = command.execute;
2233
- const rawOptions = raw.data.options || [];
1663
+ const rawOptions = data.options || [];
2234
1664
  let actualOptions = rawOptions;
2235
1665
  if (rawOptions.length > 0 && rawOptions[0].type === 1 /* SUB_COMMAND */) {
2236
1666
  const subcommandName = rawOptions[0].name;
@@ -2240,26 +1670,26 @@ var CommandManager = class {
2240
1670
  }
2241
1671
  }
2242
1672
  for (const opt2 of actualOptions) {
2243
- if (opt2.type === 6 /* USER */ && raw.data.resolved?.users?.[opt2.value]) {
2244
- parsedOptions[opt2.name] = resolveUser(opt2.value, this._client.cache);
2245
- } else if (opt2.type === 7 /* CHANNEL */ && raw.data.resolved?.channels?.[opt2.value]) {
2246
- parsedOptions[opt2.name] = resolveChannel(opt2.value, this._client.cache);
2247
- } else if (opt2.type === 8 /* ROLE */ && raw.data.resolved?.roles?.[opt2.value]) {
2248
- parsedOptions[opt2.name] = resolveRole(opt2.value, this._client.cache);
1673
+ if (opt2.type === 6 /* USER */ && data.resolved?.users?.[opt2.value]) {
1674
+ parsedOptions[opt2.name] = resolveUser(opt2.value, this._client);
1675
+ } else if (opt2.type === 7 /* CHANNEL */ && data.resolved?.channels?.[opt2.value]) {
1676
+ parsedOptions[opt2.name] = resolveChannel(opt2.value, this._client);
1677
+ } else if (opt2.type === 8 /* ROLE */ && data.resolved?.roles?.[opt2.value]) {
1678
+ parsedOptions[opt2.name] = resolveRole(opt2.value, this._client, raw.guild_id);
2249
1679
  } else {
2250
1680
  parsedOptions[opt2.name] = opt2.value;
2251
1681
  }
2252
1682
  }
2253
- const member = raw.member || {};
2254
- const userRaw = member.user || raw.user;
1683
+ const member = raw.member;
1684
+ const userRaw = member?.user ?? raw.user;
2255
1685
  const user = buildUser(userRaw);
2256
1686
  const ctx = new CommandContext(
2257
1687
  this._client,
2258
1688
  raw,
2259
1689
  parsedOptions,
2260
1690
  user,
2261
- raw.guild_id ? resolveGuild(raw.guild_id, this._client.cache) : void 0,
2262
- raw.channel_id ? resolveChannel(raw.channel_id, this._client.cache) : void 0
1691
+ raw.guild_id ? resolveGuild(raw.guild_id, this._client) : void 0,
1692
+ raw.channel_id ? resolveChannel(raw.channel_id, this._client) : void 0
2263
1693
  );
2264
1694
  if (targetExecute) {
2265
1695
  try {
@@ -2269,164 +1699,53 @@ var CommandManager = class {
2269
1699
  }
2270
1700
  }
2271
1701
  }
2272
- async _handleComponentInteraction(raw) {
2273
- const customId = raw.data.custom_id;
2274
- const handler = this._components.find(
2275
- (h) => typeof h.customId === "string" ? h.customId === customId : h.customId.test(customId)
2276
- );
1702
+ async _handleComponentInteraction(raw, data) {
1703
+ const customId = data.custom_id;
1704
+ const handler = this._components.find((h) => {
1705
+ if (!h.customId) return false;
1706
+ return typeof h.customId === "string" ? h.customId === customId : h.customId.test(customId);
1707
+ });
2277
1708
  if (!handler) return;
2278
- const userRaw = raw.member?.user || raw.user;
1709
+ const member = raw.member;
1710
+ const userRaw = member?.user ?? raw.user;
2279
1711
  const user = buildUser(userRaw);
2280
1712
  const ctx = new ComponentContext(
2281
1713
  this._client,
2282
1714
  raw,
2283
1715
  user,
2284
- raw.guild_id ? resolveGuild(raw.guild_id, this._client.cache) : void 0,
2285
- raw.channel_id ? resolveChannel(raw.channel_id, this._client.cache) : void 0
1716
+ raw.guild_id ? resolveGuild(raw.guild_id, this._client) : void 0,
1717
+ raw.channel_id ? resolveChannel(raw.channel_id, this._client) : void 0
2286
1718
  );
2287
- if (raw.data.component_type === 3 /* STRING_SELECT */ || raw.data.component_type === 5 /* USER_SELECT */ || raw.data.component_type === 6 /* ROLE_SELECT */ || raw.data.component_type === 7 /* MENTIONABLE_SELECT */ || raw.data.component_type === 8 /* CHANNEL_SELECT */) {
2288
- ctx._values = raw.data.values || [];
2289
- }
2290
1719
  try {
2291
- await handler.execute(ctx);
1720
+ await handler.execute?.(ctx);
2292
1721
  } catch (err) {
2293
1722
  console.error(`[Chameleon] Error executing component ${customId}:`, err);
2294
1723
  }
2295
1724
  }
2296
- async _handleModalInteraction(raw) {
2297
- const customId = raw.data.custom_id;
1725
+ async _handleModalInteraction(raw, data) {
1726
+ const customId = data.custom_id;
2298
1727
  const handler = this._modals.find(
2299
1728
  (h) => typeof h.customId === "string" ? h.customId === customId : h.customId.test(customId)
2300
1729
  );
2301
1730
  if (!handler) return;
2302
- const userRaw = raw.member?.user || raw.user;
1731
+ const member = raw.member;
1732
+ const userRaw = member?.user ?? raw.user;
2303
1733
  const user = buildUser(userRaw);
2304
1734
  const ctx = new ModalContext(
2305
1735
  this._client,
2306
1736
  raw,
2307
1737
  user,
2308
- raw.guild_id ? resolveGuild(raw.guild_id, this._client.cache) : void 0,
2309
- raw.channel_id ? resolveChannel(raw.channel_id, this._client.cache) : void 0
1738
+ raw.guild_id ? resolveGuild(raw.guild_id, this._client) : void 0,
1739
+ raw.channel_id ? resolveChannel(raw.channel_id, this._client) : void 0
2310
1740
  );
2311
1741
  try {
2312
- await handler.execute(ctx);
1742
+ await handler.execute?.(ctx);
2313
1743
  } catch (err) {
2314
1744
  console.error(`[Chameleon] Error executing modal ${customId}:`, err);
2315
1745
  }
2316
1746
  }
2317
1747
  };
2318
1748
 
2319
- // src/components/context.ts
2320
- var ComponentContext2 = class {
2321
- user;
2322
- guild;
2323
- channel;
2324
- interactionId;
2325
- interactionToken;
2326
- customId;
2327
- values;
2328
- fields;
2329
- _client;
2330
- _deferred = false;
2331
- _replied = false;
2332
- constructor(client, rawInteraction, user, guild, channel) {
2333
- this._client = client;
2334
- this.interactionId = rawInteraction.id;
2335
- this.interactionToken = rawInteraction.token;
2336
- this.customId = rawInteraction.data?.custom_id;
2337
- this.user = user;
2338
- this.guild = guild;
2339
- this.channel = channel;
2340
- this.values = rawInteraction.data?.values ?? [];
2341
- const fields = {};
2342
- if (rawInteraction.data?.components) {
2343
- for (const row of rawInteraction.data.components) {
2344
- for (const comp of row.components) {
2345
- fields[comp.custom_id] = comp.value;
2346
- }
2347
- }
2348
- }
2349
- this.fields = fields;
2350
- }
2351
- get replied() {
2352
- return this._replied;
2353
- }
2354
- get deferred() {
2355
- return this._deferred;
2356
- }
2357
- async reply(payload) {
2358
- if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
2359
- const data = typeof payload === "string" ? { content: payload } : { ...payload };
2360
- if (typeof payload === "object" && payload.ephemeral) data.flags = 64;
2361
- await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
2362
- type: 4 /* CHANNEL_MESSAGE_WITH_SOURCE */,
2363
- data
2364
- });
2365
- this._replied = true;
2366
- }
2367
- async defer(options) {
2368
- if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
2369
- await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
2370
- type: 5 /* DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE */,
2371
- data: {
2372
- flags: options?.ephemeral ? 64 : 0
2373
- }
2374
- });
2375
- this._deferred = true;
2376
- }
2377
- async update(payload) {
2378
- if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
2379
- const data = typeof payload === "string" ? { content: payload } : { ...payload };
2380
- await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
2381
- type: 7 /* UPDATE_MESSAGE */,
2382
- data
2383
- });
2384
- this._replied = true;
2385
- }
2386
- async deferUpdate() {
2387
- if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
2388
- await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
2389
- type: 6 /* DEFERRED_UPDATE_MESSAGE */
2390
- });
2391
- this._deferred = true;
2392
- }
2393
- async followUp(payload) {
2394
- if (!this._deferred && !this._replied) throw new Error("Interaction not acknowledged. Use reply or defer first.");
2395
- const data = typeof payload === "string" ? { content: payload } : { ...payload };
2396
- if (typeof payload === "object" && payload.ephemeral) data.flags = 64;
2397
- await this._client.rest.post(`/webhooks/${this._client.user?.id}/${this.interactionToken}`, data);
2398
- }
2399
- async showModal(modal) {
2400
- if (this._replied || this._deferred) throw new Error("Interaction already acknowledged.");
2401
- await this._client.rest.post(`/interactions/${this.interactionId}/${this.interactionToken}/callback`, {
2402
- type: 9 /* MODAL */,
2403
- data: modal.type === "modal" ? buildModalPayload(modal) : modal
2404
- });
2405
- this._replied = true;
2406
- }
2407
- };
2408
- function buildModalPayload(def) {
2409
- return {
2410
- custom_id: def.customId,
2411
- title: def.title,
2412
- components: def.fields.map((f) => ({
2413
- type: 1 /* ACTION_ROW */,
2414
- components: [{
2415
- type: 4 /* TEXT_INPUT */,
2416
- custom_id: f.id,
2417
- style: f.type,
2418
- // 1 short, 2 paragraph
2419
- label: f.label,
2420
- required: f.required,
2421
- min_length: f.minLength,
2422
- max_length: f.maxLength,
2423
- placeholder: f.placeholder,
2424
- value: f.value
2425
- }]
2426
- }))
2427
- };
2428
- }
2429
-
2430
1749
  // src/components/define.ts
2431
1750
  function resolveButtonStyle(style) {
2432
1751
  if (typeof style === "number") return style;
@@ -2477,52 +1796,59 @@ var ActionRow = {
2477
1796
  return {
2478
1797
  type: 1 /* ACTION_ROW */,
2479
1798
  components: components.map((c) => {
2480
- if (c.type === "button") {
1799
+ if ("type" in c && c.type === "button") {
1800
+ const btn = c;
2481
1801
  return {
2482
1802
  type: 2 /* BUTTON */,
2483
- custom_id: c.customId,
2484
- url: c.url,
2485
- label: c.label,
2486
- style: resolveButtonStyle(c.style),
2487
- disabled: c.disabled,
2488
- emoji: c.emoji,
2489
- sku_id: c.skuId
1803
+ custom_id: btn.customId,
1804
+ url: btn.url,
1805
+ label: btn.label,
1806
+ style: resolveButtonStyle(btn.style),
1807
+ disabled: btn.disabled,
1808
+ emoji: btn.emoji,
1809
+ sku_id: btn.skuId
2490
1810
  };
2491
1811
  }
2492
- if (c.type === "string_select") {
1812
+ if ("type" in c && c.type === "string_select") {
1813
+ const sel = c;
2493
1814
  return {
2494
1815
  type: 3 /* STRING_SELECT */,
2495
- custom_id: c.customId,
2496
- options: c.options,
2497
- placeholder: c.placeholder,
2498
- min_values: c.minValues,
2499
- max_values: c.maxValues,
2500
- disabled: c.disabled
1816
+ custom_id: sel.customId,
1817
+ options: sel.options,
1818
+ placeholder: sel.placeholder,
1819
+ min_values: sel.minValues,
1820
+ max_values: sel.maxValues,
1821
+ disabled: sel.disabled
2501
1822
  };
2502
1823
  }
2503
- if (c.type === "user_select") {
2504
- return { type: 5 /* USER_SELECT */, custom_id: c.customId, placeholder: c.placeholder, min_values: c.minValues, max_values: c.maxValues, disabled: c.disabled };
1824
+ if ("type" in c && c.type === "user_select") {
1825
+ const sel = c;
1826
+ return { type: 5 /* USER_SELECT */, custom_id: sel.customId, placeholder: sel.placeholder, min_values: sel.minValues, max_values: sel.maxValues, disabled: sel.disabled };
2505
1827
  }
2506
- if (c.type === "role_select") {
2507
- return { type: 6 /* ROLE_SELECT */, custom_id: c.customId, placeholder: c.placeholder, min_values: c.minValues, max_values: c.maxValues, disabled: c.disabled };
1828
+ if ("type" in c && c.type === "role_select") {
1829
+ const sel = c;
1830
+ return { type: 6 /* ROLE_SELECT */, custom_id: sel.customId, placeholder: sel.placeholder, min_values: sel.minValues, max_values: sel.maxValues, disabled: sel.disabled };
2508
1831
  }
2509
- if (c.type === "mentionable_select") {
2510
- return { type: 7 /* MENTIONABLE_SELECT */, custom_id: c.customId, placeholder: c.placeholder, min_values: c.minValues, max_values: c.maxValues, disabled: c.disabled };
1832
+ if ("type" in c && c.type === "mentionable_select") {
1833
+ const sel = c;
1834
+ return { type: 7 /* MENTIONABLE_SELECT */, custom_id: sel.customId, placeholder: sel.placeholder, min_values: sel.minValues, max_values: sel.maxValues, disabled: sel.disabled };
2511
1835
  }
2512
- if (c.type === "channel_select") {
2513
- return { type: 8 /* CHANNEL_SELECT */, custom_id: c.customId, channel_types: c.channelTypes, placeholder: c.placeholder, min_values: c.minValues, max_values: c.maxValues, disabled: c.disabled };
1836
+ if ("type" in c && c.type === "channel_select") {
1837
+ const sel = c;
1838
+ return { type: 8 /* CHANNEL_SELECT */, custom_id: sel.customId, channel_types: sel.channelTypes, placeholder: sel.placeholder, min_values: sel.minValues, max_values: sel.maxValues, disabled: sel.disabled };
2514
1839
  }
2515
- if (c.type === 1 /* SHORT */ || c.type === 2 /* PARAGRAPH */) {
1840
+ if ("type" in c && (c.type === 1 /* SHORT */ || c.type === 2 /* PARAGRAPH */)) {
1841
+ const field2 = c;
2516
1842
  return {
2517
1843
  type: 4 /* TEXT_INPUT */,
2518
- custom_id: c.id,
2519
- style: c.type,
2520
- label: c.label,
2521
- required: c.required,
2522
- min_length: c.minLength,
2523
- max_length: c.maxLength,
2524
- placeholder: c.placeholder,
2525
- value: c.value
1844
+ custom_id: field2.id,
1845
+ style: field2.type,
1846
+ label: field2.label,
1847
+ required: field2.required,
1848
+ min_length: field2.minLength,
1849
+ max_length: field2.maxLength,
1850
+ placeholder: field2.placeholder,
1851
+ value: field2.value
2526
1852
  };
2527
1853
  }
2528
1854
  return c;
@@ -2546,45 +1872,47 @@ var ComponentManager = class {
2546
1872
  handlers = /* @__PURE__ */ new Map();
2547
1873
  register(...components) {
2548
1874
  for (const comp of components) {
2549
- if (comp.customId) {
1875
+ if (comp.customId && typeof comp.customId === "string") {
2550
1876
  this.handlers.set(comp.customId, comp);
2551
1877
  }
2552
1878
  }
2553
1879
  }
2554
1880
  async handleInteraction(raw) {
2555
1881
  const data = raw.data;
1882
+ if (!data) return;
2556
1883
  const customId = data.custom_id;
2557
1884
  if (!customId) return;
2558
1885
  const handler = this.handlers.get(customId);
2559
1886
  if (!handler || !handler.execute) return;
2560
- const user = buildUser(raw.user ?? raw.member?.user);
1887
+ const userRaw = raw.member?.user ?? raw.user;
1888
+ const user = buildUser(userRaw);
2561
1889
  let guild;
2562
1890
  if (raw.guild_id) {
2563
1891
  guild = this.client.cache.guilds.get(raw.guild_id) ?? { id: raw.guild_id };
2564
1892
  }
2565
1893
  let channel;
2566
1894
  if (raw.channel_id) {
2567
- channel = resolveChannel(raw.channel_id, this.client.cache) ?? { id: raw.channel_id };
1895
+ channel = resolveChannel(raw.channel_id, this.client) ?? { id: raw.channel_id };
2568
1896
  }
2569
- if (data.resolved?.members && data.resolved?.users && raw.guild_id) {
2570
- for (const [id, memberData] of Object.entries(data.resolved.members)) {
2571
- const userData = data.resolved.users[id];
1897
+ const resolved = data.resolved;
1898
+ if (resolved?.members && resolved?.users && raw.guild_id) {
1899
+ for (const [id] of Object.entries(resolved.members)) {
1900
+ const userData = resolved.users[id];
2572
1901
  if (userData) {
2573
- const mergedMember = { ...memberData, user: userData };
2574
1902
  const u = buildUser(userData);
2575
1903
  this.client.cache.users.set(u.id, u);
2576
1904
  }
2577
1905
  }
2578
1906
  }
2579
- const ctx = new ComponentContext2(this.client, raw, user, guild, channel);
2580
- if (handler.type === "user_select" && data.resolved?.users) {
1907
+ const ctx = new ComponentContext(this.client, raw, user, guild, channel);
1908
+ if (handler.type === "user_select" && resolved?.users) {
2581
1909
  ctx.values = ctx.values.map((id) => {
2582
- const uData = data.resolved.users[id];
1910
+ const uData = resolved.users[id];
2583
1911
  return uData ? buildUser(uData) : { id };
2584
1912
  });
2585
- } else if (handler.type === "channel_select" && data.resolved?.channels) {
1913
+ } else if (handler.type === "channel_select" && resolved?.channels) {
2586
1914
  ctx.values = ctx.values.map((id) => {
2587
- const cData = data.resolved.channels[id];
1915
+ const cData = resolved.channels[id];
2588
1916
  return cData ? buildChannel(cData, raw.guild_id) : { id };
2589
1917
  });
2590
1918
  }
@@ -2626,6 +1954,106 @@ var UserManager = class extends BaseManager {
2626
1954
  return `/users/${id}`;
2627
1955
  }
2628
1956
  build = buildUser;
1957
+ async createDM(userId) {
1958
+ const result = await this.rest.post("/users/@me/channels", { recipient_id: userId });
1959
+ if (!result.ok) return result;
1960
+ return { ok: true, data: (await import("./builders-CCZQJXF6.js")).buildChannel(result.data) };
1961
+ }
1962
+ };
1963
+
1964
+ // src/managers/role.ts
1965
+ var RoleManager = class {
1966
+ constructor(rest, store, guildId) {
1967
+ this.rest = rest;
1968
+ this.store = store;
1969
+ this.guildId = guildId;
1970
+ }
1971
+ rest;
1972
+ store;
1973
+ guildId;
1974
+ async fetch(roleId, force = false) {
1975
+ if (!force) {
1976
+ const cached = this.store.roles.get(roleId);
1977
+ if (cached) return { ok: true, data: cached };
1978
+ }
1979
+ const result = await this.rest.get(`/guilds/${this.guildId}/roles`);
1980
+ if (!result.ok) return result;
1981
+ const roles = result.data.map((raw) => buildRole(raw));
1982
+ for (const r of roles) {
1983
+ this.store.roles.set(r.id, r);
1984
+ }
1985
+ const target = roles.find((r) => r.id === roleId);
1986
+ if (target) return { ok: true, data: target };
1987
+ return { ok: false, status: 404, message: "Role not found" };
1988
+ }
1989
+ async list() {
1990
+ const result = await this.rest.get(`/guilds/${this.guildId}/roles`);
1991
+ if (!result.ok) return result;
1992
+ const roles = result.data.map((raw) => buildRole(raw));
1993
+ for (const r of roles) {
1994
+ this.store.roles.set(r.id, r);
1995
+ }
1996
+ return { ok: true, data: roles };
1997
+ }
1998
+ async create(payload, reason) {
1999
+ const headers = {};
2000
+ if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
2001
+ const result = await this.rest.post(`/guilds/${this.guildId}/roles`, toSnakeCase(payload), headers);
2002
+ if (!result.ok) return result;
2003
+ const role = buildRole(result.data);
2004
+ this.store.roles.set(role.id, role);
2005
+ return { ok: true, data: role };
2006
+ }
2007
+ async edit(roleId, payload, reason) {
2008
+ const headers = {};
2009
+ if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
2010
+ const result = await this.rest.patch(`/guilds/${this.guildId}/roles/${roleId}`, toSnakeCase(payload), headers);
2011
+ if (!result.ok) return result;
2012
+ const role = buildRole(result.data);
2013
+ this.store.roles.set(role.id, role);
2014
+ return { ok: true, data: role };
2015
+ }
2016
+ async delete(roleId, reason) {
2017
+ const headers = {};
2018
+ if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
2019
+ const result = await this.rest.delete(`/guilds/${this.guildId}/roles/${roleId}`, headers);
2020
+ if (result.ok) this.store.roles.delete(roleId);
2021
+ return result;
2022
+ }
2023
+ };
2024
+
2025
+ // src/managers/member.ts
2026
+ var MemberManager = class {
2027
+ constructor(rest, store, guildId) {
2028
+ this.rest = rest;
2029
+ this.store = store;
2030
+ this.guildId = guildId;
2031
+ }
2032
+ rest;
2033
+ store;
2034
+ guildId;
2035
+ async fetch(userId, force = false) {
2036
+ const cacheKey = TongueStore.memberKey(this.guildId, userId);
2037
+ if (!force) {
2038
+ const cached = this.store.members.get(cacheKey);
2039
+ if (cached) return { ok: true, data: cached };
2040
+ }
2041
+ const result = await this.rest.get(`/guilds/${this.guildId}/members/${userId}`);
2042
+ if (!result.ok) return result;
2043
+ const member = buildMember(result.data, this.guildId, this.store);
2044
+ this.store.members.set(cacheKey, member);
2045
+ return { ok: true, data: member };
2046
+ }
2047
+ async edit(userId, payload, reason) {
2048
+ const headers = {};
2049
+ if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
2050
+ const result = await this.rest.patch(`/guilds/${this.guildId}/members/${userId}`, toSnakeCase(payload), headers);
2051
+ if (!result.ok) return result;
2052
+ const cacheKey = TongueStore.memberKey(this.guildId, userId);
2053
+ const member = buildMember(result.data, this.guildId, this.store);
2054
+ this.store.members.set(cacheKey, member);
2055
+ return { ok: true, data: member };
2056
+ }
2629
2057
  };
2630
2058
 
2631
2059
  // src/managers/guild.ts
@@ -2635,6 +2063,12 @@ var GuildManager = class extends BaseManager {
2635
2063
  return `/guilds/${id}`;
2636
2064
  }
2637
2065
  build = buildGuild;
2066
+ roles(guildId) {
2067
+ return new RoleManager(this.rest, this.store, guildId);
2068
+ }
2069
+ members(guildId) {
2070
+ return new MemberManager(this.rest, this.store, guildId);
2071
+ }
2638
2072
  async fetchChannels(guildId) {
2639
2073
  const result = await this.rest.get(`/guilds/${guildId}/channels`);
2640
2074
  if (!result.ok) return result;
@@ -2667,6 +2101,20 @@ var GuildManager = class extends BaseManager {
2667
2101
  }
2668
2102
  return result;
2669
2103
  }
2104
+ async edit(guildId, payload, reason) {
2105
+ const headers = {};
2106
+ if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
2107
+ const result = await this.rest.patch(this.endpoint(guildId), toSnakeCase(payload), headers);
2108
+ if (!result.ok) return result;
2109
+ const entity = this.build(result.data);
2110
+ this.store.guilds.set(entity.id, entity);
2111
+ return { ok: true, data: entity };
2112
+ }
2113
+ async delete(guildId) {
2114
+ const result = await this.rest.delete(this.endpoint(guildId));
2115
+ if (result.ok) this.store.guilds.delete(guildId);
2116
+ return result;
2117
+ }
2670
2118
  };
2671
2119
 
2672
2120
  // src/managers/channel.ts
@@ -2676,29 +2124,40 @@ var ChannelManager = class extends BaseManager {
2676
2124
  return `/channels/${id}`;
2677
2125
  }
2678
2126
  build = buildChannel;
2679
- };
2680
-
2681
- // src/managers/member.ts
2682
- var MemberManager = class {
2683
- constructor(rest, store, guildId) {
2684
- this.rest = rest;
2685
- this.store = store;
2686
- this.guildId = guildId;
2127
+ async create(guildId, payload, reason) {
2128
+ const headers = {};
2129
+ if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
2130
+ const result = await this.rest.post(`/guilds/${guildId}/channels`, toSnakeCase(payload), headers);
2131
+ if (!result.ok) return result;
2132
+ const entity = this.build(result.data, guildId);
2133
+ this.store.channels.set(entity.id, entity);
2134
+ return { ok: true, data: entity };
2687
2135
  }
2688
- rest;
2689
- store;
2690
- guildId;
2691
- async fetch(userId, force = false) {
2692
- const cacheKey = TongueStore.memberKey(this.guildId, userId);
2693
- if (!force) {
2694
- const cached = this.store.members.get(cacheKey);
2695
- if (cached) return { ok: true, data: cached };
2696
- }
2697
- const result = await this.rest.get(`/guilds/${this.guildId}/members/${userId}`);
2136
+ async edit(channelId, payload, reason) {
2137
+ const headers = {};
2138
+ if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
2139
+ const result = await this.rest.patch(this.endpoint(channelId), toSnakeCase(payload), headers);
2698
2140
  if (!result.ok) return result;
2699
- const member = buildMember(result.data, this.guildId, this.store);
2700
- this.store.members.set(cacheKey, member);
2701
- return { ok: true, data: member };
2141
+ const entity = this.build(result.data);
2142
+ this.store.channels.set(entity.id, entity);
2143
+ return { ok: true, data: entity };
2144
+ }
2145
+ async delete(channelId, reason) {
2146
+ const headers = {};
2147
+ if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
2148
+ const result = await this.rest.delete(this.endpoint(channelId), headers);
2149
+ if (result.ok) this.store.channels.delete(channelId);
2150
+ return result;
2151
+ }
2152
+ async updatePermissions(channelId, overwriteId, payload, reason) {
2153
+ const headers = {};
2154
+ if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
2155
+ return await this.rest.put(`/channels/${channelId}/permissions/${overwriteId}`, toSnakeCase(payload), headers);
2156
+ }
2157
+ async deletePermission(channelId, overwriteId, reason) {
2158
+ const headers = {};
2159
+ if (reason) headers["X-Audit-Log-Reason"] = encodeURIComponent(reason);
2160
+ return await this.rest.delete(`/channels/${channelId}/permissions/${overwriteId}`, headers);
2702
2161
  }
2703
2162
  };
2704
2163
 
@@ -2722,7 +2181,19 @@ var MessageManager = class {
2722
2181
  return { ok: true, data: message };
2723
2182
  }
2724
2183
  async send(channelId, payload) {
2725
- const data = typeof payload === "string" ? { content: payload } : payload;
2184
+ const data = typeof payload === "string" ? { content: payload } : { ...payload };
2185
+ if (typeof payload === "object") {
2186
+ if (payload.embeds) {
2187
+ data.embeds = payload.embeds.map((e) => e && typeof e.toJSON === "function" ? e.toJSON() : e);
2188
+ }
2189
+ if (payload.components) {
2190
+ data.components = payload.components.map((c) => serializeComponent(c));
2191
+ }
2192
+ if (payload.reply) {
2193
+ data.message_reference = { message_id: payload.reply.messageId, fail_if_not_exists: payload.reply.failIfNotExists ?? true };
2194
+ delete data.reply;
2195
+ }
2196
+ }
2726
2197
  const result = await this.rest.post(`/channels/${channelId}/messages`, data);
2727
2198
  if (!result.ok) return result;
2728
2199
  const message = buildMessage(result.data, this.store);
@@ -2730,7 +2201,15 @@ var MessageManager = class {
2730
2201
  return { ok: true, data: message };
2731
2202
  }
2732
2203
  async edit(channelId, messageId, payload) {
2733
- const data = typeof payload === "string" ? { content: payload } : payload;
2204
+ const data = typeof payload === "string" ? { content: payload } : { ...payload };
2205
+ if (typeof payload === "object") {
2206
+ if (payload.embeds) {
2207
+ data.embeds = payload.embeds.map((e) => e && typeof e.toJSON === "function" ? e.toJSON() : e);
2208
+ }
2209
+ if (payload.components) {
2210
+ data.components = payload.components.map((c) => serializeComponent(c));
2211
+ }
2212
+ }
2734
2213
  const result = await this.rest.patch(`/channels/${channelId}/messages/${messageId}`, data);
2735
2214
  if (!result.ok) return result;
2736
2215
  const oldMsg = this.store.messages.get(messageId);
@@ -2745,6 +2224,26 @@ var MessageManager = class {
2745
2224
  }
2746
2225
  return result;
2747
2226
  }
2227
+ async list(channelId, options) {
2228
+ let url = `/channels/${channelId}/messages`;
2229
+ if (options) {
2230
+ const params = new URLSearchParams();
2231
+ if (options.limit) params.append("limit", options.limit.toString());
2232
+ if (options.before) params.append("before", options.before);
2233
+ if (options.after) params.append("after", options.after);
2234
+ if (options.around) params.append("around", options.around);
2235
+ const qs = params.toString();
2236
+ if (qs) url += `?${qs}`;
2237
+ }
2238
+ const result = await this.rest.get(url);
2239
+ if (!result.ok) return result;
2240
+ const messages = result.data.map((msgData) => {
2241
+ const msg = buildMessage(msgData, this.store);
2242
+ this.store.messages.set(msg.id, msg);
2243
+ return msg;
2244
+ });
2245
+ return { ok: true, data: messages };
2246
+ }
2748
2247
  };
2749
2248
 
2750
2249
  // src/managers/collector.ts
@@ -2794,21 +2293,20 @@ var CollectorManager = class {
2794
2293
  return new Promise((resolve2) => {
2795
2294
  let timeoutId = null;
2796
2295
  const handler = (data) => {
2797
- const raw = data.interaction;
2798
- if (raw.type !== 3 /* MESSAGE_COMPONENT */) return;
2799
- if (raw.message?.id !== messageId) return;
2800
- const userRaw = raw.member?.user || raw.user;
2296
+ if (data.type !== "INTERACTION_CREATE") return;
2297
+ const interaction = data.interaction;
2298
+ const raw = interaction;
2299
+ if (interaction.type !== 3 /* MESSAGE_COMPONENT */) return;
2300
+ if (interaction.message?.id !== messageId) return;
2301
+ const userRaw = interaction.member?.user || interaction.user;
2801
2302
  const user = buildUser(userRaw);
2802
2303
  const ctx = new ComponentContext(
2803
2304
  this.client,
2804
2305
  raw,
2805
2306
  user,
2806
- raw.guild_id ? resolveGuild(raw.guild_id, this.client.cache) : void 0,
2807
- raw.channel_id ? resolveChannel(raw.channel_id, this.client.cache) : void 0
2307
+ interaction.guildId ? resolveGuild(interaction.guildId, this.client) : void 0,
2308
+ interaction.channelId ? resolveChannel(interaction.channelId, this.client) : void 0
2808
2309
  );
2809
- if (raw.data.component_type === 3 /* STRING_SELECT */ || raw.data.component_type === 5 /* USER_SELECT */ || raw.data.component_type === 6 /* ROLE_SELECT */ || raw.data.component_type === 7 /* MENTIONABLE_SELECT */ || raw.data.component_type === 8 /* CHANNEL_SELECT */) {
2810
- ctx._values = raw.data.values || [];
2811
- }
2812
2310
  if (filter && !filter(ctx)) return;
2813
2311
  cleanup();
2814
2312
  resolve2(ctx);
@@ -3079,22 +2577,26 @@ var Client = class {
3079
2577
  }
3080
2578
  if (Array.isArray(d.emojis)) {
3081
2579
  for (const raw of d.emojis) {
3082
- this.cache.emojis.set(raw.id, raw);
2580
+ const emoji = buildEmoji(raw);
2581
+ if (emoji.id) this.cache.emojis.set(emoji.id, emoji);
3083
2582
  }
3084
2583
  }
3085
2584
  if (Array.isArray(d.stickers)) {
3086
2585
  for (const raw of d.stickers) {
3087
- this.cache.stickers.set(raw.id, raw);
2586
+ const sticker = buildSticker(raw);
2587
+ this.cache.stickers.set(sticker.id, sticker);
3088
2588
  }
3089
2589
  }
3090
2590
  if (Array.isArray(d.stage_instances)) {
3091
2591
  for (const raw of d.stage_instances) {
3092
- this.cache.stageInstances.set(raw.id, raw);
2592
+ const stage = buildStageInstance(raw);
2593
+ this.cache.stageInstances.set(stage.id, stage);
3093
2594
  }
3094
2595
  }
3095
2596
  if (Array.isArray(d.guild_scheduled_events)) {
3096
2597
  for (const raw of d.guild_scheduled_events) {
3097
- this.cache.scheduledEvents.set(raw.id, raw);
2598
+ const event = buildScheduledEvent(raw);
2599
+ this.cache.scheduledEvents.set(event.id, event);
3098
2600
  }
3099
2601
  }
3100
2602
  if (guild.large) {
@@ -3279,7 +2781,7 @@ var Client = class {
3279
2781
  this.dispatch("MESSAGE_CREATE", {
3280
2782
  type: "MESSAGE_CREATE",
3281
2783
  message,
3282
- channel: resolveChannel(message.channelId, this.cache)
2784
+ channel: resolveChannel(message.channelId, this)
3283
2785
  });
3284
2786
  break;
3285
2787
  }
@@ -3290,7 +2792,7 @@ var Client = class {
3290
2792
  this.dispatch("MESSAGE_UPDATE", {
3291
2793
  type: "MESSAGE_UPDATE",
3292
2794
  message,
3293
- channel: resolveChannel(message.channelId, this.cache),
2795
+ channel: resolveChannel(message.channelId, this),
3294
2796
  ...oldMessage ? { oldMessage } : {}
3295
2797
  });
3296
2798
  break;
@@ -3383,14 +2885,14 @@ var Client = class {
3383
2885
  }
3384
2886
  this.dispatch("INTERACTION_CREATE", {
3385
2887
  type: "INTERACTION_CREATE",
3386
- interaction: d
2888
+ interaction: buildInteraction(d, this.cache)
3387
2889
  });
3388
2890
  break;
3389
2891
  }
3390
2892
  case "VOICE_STATE_UPDATE": {
3391
2893
  this.dispatch("VOICE_STATE_UPDATE", {
3392
2894
  type: "VOICE_STATE_UPDATE",
3393
- voiceState: d
2895
+ voiceState: buildVoiceState(d, this.cache)
3394
2896
  });
3395
2897
  break;
3396
2898
  }
@@ -3438,15 +2940,15 @@ var Client = class {
3438
2940
  break;
3439
2941
  }
3440
2942
  case "ENTITLEMENT_CREATE": {
3441
- this.dispatch("ENTITLEMENT_CREATE", { type: "ENTITLEMENT_CREATE", entitlement: d });
2943
+ this.dispatch("ENTITLEMENT_CREATE", { type: "ENTITLEMENT_CREATE", entitlement: buildEntitlement(d) });
3442
2944
  break;
3443
2945
  }
3444
2946
  case "ENTITLEMENT_UPDATE": {
3445
- this.dispatch("ENTITLEMENT_UPDATE", { type: "ENTITLEMENT_UPDATE", entitlement: d });
2947
+ this.dispatch("ENTITLEMENT_UPDATE", { type: "ENTITLEMENT_UPDATE", entitlement: buildEntitlement(d) });
3446
2948
  break;
3447
2949
  }
3448
2950
  case "ENTITLEMENT_DELETE": {
3449
- this.dispatch("ENTITLEMENT_DELETE", { type: "ENTITLEMENT_DELETE", entitlement: d });
2951
+ this.dispatch("ENTITLEMENT_DELETE", { type: "ENTITLEMENT_DELETE", entitlement: buildEntitlement(d) });
3450
2952
  break;
3451
2953
  }
3452
2954
  case "PRESENCE_UPDATE": {
@@ -3578,7 +3080,7 @@ var Client = class {
3578
3080
  break;
3579
3081
  }
3580
3082
  case "GUILD_EMOJIS_UPDATE": {
3581
- const emojis = d.emojis;
3083
+ const emojis = d.emojis.map((raw) => buildEmoji(raw));
3582
3084
  for (const emoji of emojis) {
3583
3085
  if (emoji.id) this.cache.emojis.set(emoji.id, emoji);
3584
3086
  }
@@ -3590,7 +3092,7 @@ var Client = class {
3590
3092
  break;
3591
3093
  }
3592
3094
  case "GUILD_STICKERS_UPDATE": {
3593
- const stickers = d.stickers;
3095
+ const stickers = d.stickers.map((raw) => buildSticker(raw));
3594
3096
  for (const sticker of stickers) {
3595
3097
  this.cache.stickers.set(sticker.id, sticker);
3596
3098
  }
@@ -3602,37 +3104,37 @@ var Client = class {
3602
3104
  break;
3603
3105
  }
3604
3106
  case "STAGE_INSTANCE_CREATE": {
3605
- const stageInstance = d;
3107
+ const stageInstance = buildStageInstance(d);
3606
3108
  this.cache.stageInstances.set(stageInstance.id, stageInstance);
3607
3109
  this.dispatch("STAGE_INSTANCE_CREATE", { type: "STAGE_INSTANCE_CREATE", stageInstance });
3608
3110
  break;
3609
3111
  }
3610
3112
  case "STAGE_INSTANCE_UPDATE": {
3611
- const stageInstance = d;
3113
+ const stageInstance = buildStageInstance(d);
3612
3114
  this.cache.stageInstances.set(stageInstance.id, stageInstance);
3613
3115
  this.dispatch("STAGE_INSTANCE_UPDATE", { type: "STAGE_INSTANCE_UPDATE", stageInstance });
3614
3116
  break;
3615
3117
  }
3616
3118
  case "STAGE_INSTANCE_DELETE": {
3617
- const stageInstance = d;
3119
+ const stageInstance = buildStageInstance(d);
3618
3120
  this.cache.stageInstances.delete(stageInstance.id);
3619
3121
  this.dispatch("STAGE_INSTANCE_DELETE", { type: "STAGE_INSTANCE_DELETE", stageInstance });
3620
3122
  break;
3621
3123
  }
3622
3124
  case "GUILD_SCHEDULED_EVENT_CREATE": {
3623
- const scheduledEvent = d;
3125
+ const scheduledEvent = buildScheduledEvent(d);
3624
3126
  this.cache.scheduledEvents.set(scheduledEvent.id, scheduledEvent);
3625
3127
  this.dispatch("GUILD_SCHEDULED_EVENT_CREATE", { type: "GUILD_SCHEDULED_EVENT_CREATE", scheduledEvent });
3626
3128
  break;
3627
3129
  }
3628
3130
  case "GUILD_SCHEDULED_EVENT_UPDATE": {
3629
- const scheduledEvent = d;
3131
+ const scheduledEvent = buildScheduledEvent(d);
3630
3132
  this.cache.scheduledEvents.set(scheduledEvent.id, scheduledEvent);
3631
3133
  this.dispatch("GUILD_SCHEDULED_EVENT_UPDATE", { type: "GUILD_SCHEDULED_EVENT_UPDATE", scheduledEvent });
3632
3134
  break;
3633
3135
  }
3634
3136
  case "GUILD_SCHEDULED_EVENT_DELETE": {
3635
- const scheduledEvent = d;
3137
+ const scheduledEvent = buildScheduledEvent(d);
3636
3138
  this.cache.scheduledEvents.delete(scheduledEvent.id);
3637
3139
  this.dispatch("GUILD_SCHEDULED_EVENT_DELETE", { type: "GUILD_SCHEDULED_EVENT_DELETE", scheduledEvent });
3638
3140
  break;
@@ -3646,19 +3148,19 @@ var Client = class {
3646
3148
  break;
3647
3149
  }
3648
3150
  case "AUTO_MODERATION_RULE_CREATE": {
3649
- const rule = d;
3151
+ const rule = buildAutoModRule(d);
3650
3152
  this.cache.autoModRules.set(rule.id, rule);
3651
3153
  this.dispatch("AUTO_MODERATION_RULE_CREATE", { type: "AUTO_MODERATION_RULE_CREATE", rule });
3652
3154
  break;
3653
3155
  }
3654
3156
  case "AUTO_MODERATION_RULE_UPDATE": {
3655
- const rule = d;
3157
+ const rule = buildAutoModRule(d);
3656
3158
  this.cache.autoModRules.set(rule.id, rule);
3657
3159
  this.dispatch("AUTO_MODERATION_RULE_UPDATE", { type: "AUTO_MODERATION_RULE_UPDATE", rule });
3658
3160
  break;
3659
3161
  }
3660
3162
  case "AUTO_MODERATION_RULE_DELETE": {
3661
- const rule = d;
3163
+ const rule = buildAutoModRule(d);
3662
3164
  this.cache.autoModRules.delete(rule.id);
3663
3165
  this.dispatch("AUTO_MODERATION_RULE_DELETE", { type: "AUTO_MODERATION_RULE_DELETE", rule });
3664
3166
  break;
@@ -3680,13 +3182,13 @@ var Client = class {
3680
3182
  break;
3681
3183
  }
3682
3184
  case "INTEGRATION_CREATE": {
3683
- const integration = d;
3185
+ const integration = buildIntegration(d);
3684
3186
  this.cache.integrations.set(integration.id, integration);
3685
3187
  this.dispatch("INTEGRATION_CREATE", { type: "INTEGRATION_CREATE", guildId: d.guild_id, integration });
3686
3188
  break;
3687
3189
  }
3688
3190
  case "INTEGRATION_UPDATE": {
3689
- const integration = d;
3191
+ const integration = buildIntegration(d);
3690
3192
  this.cache.integrations.set(integration.id, integration);
3691
3193
  this.dispatch("INTEGRATION_UPDATE", { type: "INTEGRATION_UPDATE", guildId: d.guild_id, integration });
3692
3194
  break;
@@ -3769,6 +3271,7 @@ export {
3769
3271
  AutoModerationEventType,
3770
3272
  AutoModerationKeywordPresetType,
3771
3273
  AutoModerationTriggerType,
3274
+ BaseInteractionContext,
3772
3275
  BaseManager,
3773
3276
  ButtonBuilder,
3774
3277
  ButtonStyle,
@@ -3784,7 +3287,7 @@ export {
3784
3287
  Colors,
3785
3288
  CommandContext,
3786
3289
  CommandManager,
3787
- ComponentContext2 as ComponentContext,
3290
+ ComponentContext,
3788
3291
  ComponentManager,
3789
3292
  ComponentType,
3790
3293
  DISCORD_GATEWAY_OPCODES,
@@ -3818,6 +3321,7 @@ export {
3818
3321
  ModalBuilder,
3819
3322
  PremiumTier,
3820
3323
  PremiumType,
3324
+ RoleManager,
3821
3325
  SelectMenuBuilder,
3822
3326
  SkuFlag,
3823
3327
  SkuType,
@@ -3836,13 +3340,22 @@ export {
3836
3340
  VideoQualityMode,
3837
3341
  VisibilityType,
3838
3342
  WebhookType,
3343
+ buildAutoModRule,
3839
3344
  buildChannel,
3345
+ buildEmoji,
3346
+ buildEntitlement,
3840
3347
  buildGuild,
3348
+ buildIntegration,
3349
+ buildInteraction,
3841
3350
  buildMember,
3842
3351
  buildMessage,
3843
- buildModalPayload,
3844
3352
  buildRole,
3353
+ buildScheduledEvent,
3354
+ buildStageInstance,
3355
+ buildSticker,
3356
+ buildStickerItem,
3845
3357
  buildUser,
3358
+ buildVoiceState,
3846
3359
  combinePermissions,
3847
3360
  defineButton,
3848
3361
  defineChannelSelect,
@@ -3863,5 +3376,6 @@ export {
3863
3376
  resolveChannel,
3864
3377
  resolveGuild,
3865
3378
  resolveRole,
3866
- resolveUser
3379
+ resolveUser,
3380
+ serializeComponent
3867
3381
  };