@impulsedev/chameleon 1.2.0 → 1.4.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.d.ts CHANGED
@@ -2511,7 +2511,7 @@ declare class ButtonBuilder {
2511
2511
  setDisabled(disabled?: boolean): this;
2512
2512
  setURL(url: string): this;
2513
2513
  build(): MessageComponent;
2514
- toJSON(): MessageComponent;
2514
+ toJSON(): any;
2515
2515
  }
2516
2516
  declare class SelectMenuBuilder {
2517
2517
  private data;
@@ -2520,22 +2520,22 @@ declare class SelectMenuBuilder {
2520
2520
  setMinValues(min: number): this;
2521
2521
  setMaxValues(max: number): this;
2522
2522
  setDisabled(disabled?: boolean): this;
2523
+ setType(type: number): this;
2523
2524
  addOption(option: SelectOption): this;
2524
2525
  addOptions(...options: SelectOption[]): this;
2525
- setType(type: number): this;
2526
2526
  build(): MessageComponent;
2527
- toJSON(): MessageComponent;
2527
+ toJSON(): any;
2528
2528
  }
2529
2529
  declare class TextInputBuilder {
2530
2530
  private data;
2531
- setCustomId(id: string): this;
2532
- setLabel(label: string): this;
2533
- setStyle(style: number): this;
2534
- setPlaceholder(placeholder: string): this;
2535
2531
  private _minLength?;
2536
2532
  private _maxLength?;
2537
2533
  private _required?;
2538
2534
  private _value?;
2535
+ setCustomId(id: string): this;
2536
+ setLabel(label: string): this;
2537
+ setStyle(style: number): this;
2538
+ setPlaceholder(placeholder: string): this;
2539
2539
  setMinLength(length: number): this;
2540
2540
  setMaxLength(length: number): this;
2541
2541
  setRequired(required?: boolean): this;
@@ -2547,12 +2547,16 @@ declare class ActionRowBuilder {
2547
2547
  private data;
2548
2548
  addComponent(component: MessageComponent | {
2549
2549
  build(): MessageComponent;
2550
+ } | {
2551
+ toJSON(): any;
2550
2552
  }): this;
2551
2553
  addComponents(...components: (MessageComponent | {
2552
2554
  build(): MessageComponent;
2555
+ } | {
2556
+ toJSON(): any;
2553
2557
  })[]): this;
2554
2558
  build(): MessageComponent;
2555
- toJSON(): MessageComponent;
2559
+ toJSON(): any;
2556
2560
  }
2557
2561
  declare class ModalBuilder {
2558
2562
  private _title;
@@ -2560,21 +2564,25 @@ declare class ModalBuilder {
2560
2564
  private _components;
2561
2565
  setTitle(title: string): this;
2562
2566
  setCustomId(id: string): this;
2563
- addComponent(row: MessageComponent | {
2567
+ addComponent(component: MessageComponent | {
2564
2568
  build(): MessageComponent;
2569
+ } | {
2570
+ toJSON(): any;
2565
2571
  }): this;
2566
- addComponents(...rows: (MessageComponent | {
2572
+ addComponents(...components: (MessageComponent | {
2567
2573
  build(): MessageComponent;
2574
+ } | {
2575
+ toJSON(): any;
2568
2576
  })[]): this;
2569
2577
  build(): {
2570
2578
  title: string;
2571
2579
  custom_id: string;
2572
- components: MessageComponent[];
2580
+ components: any[];
2573
2581
  };
2574
2582
  toJSON(): {
2575
2583
  title: string;
2576
2584
  custom_id: string;
2577
- components: MessageComponent[];
2585
+ components: any[];
2578
2586
  };
2579
2587
  }
2580
2588
 
@@ -2683,7 +2691,7 @@ type EventMap = {
2683
2691
  };
2684
2692
  type MiddlewareFn = (event: ChameleonEvent, next: () => void) => void | Promise<void>;
2685
2693
  declare class Client<TIntents extends readonly IntentResolvable[] = readonly IntentResolvable[]> {
2686
- token: string;
2694
+ token: string | undefined;
2687
2695
  intents: number;
2688
2696
  cache: TongueStore;
2689
2697
  rest: ChameleonREST;
package/dist/index.js CHANGED
@@ -1215,7 +1215,7 @@ var ChameleonGateway = class {
1215
1215
  // package.json
1216
1216
  var package_default = {
1217
1217
  name: "@impulsedev/chameleon",
1218
- version: "1.2.0",
1218
+ version: "1.4.0",
1219
1219
  description: "highly optimized, memory-efficient, and fully type-safe Discord API library",
1220
1220
  main: "dist/index.js",
1221
1221
  types: "dist/index.d.ts",
@@ -1450,8 +1450,18 @@ var EmbedBuilder = class {
1450
1450
  };
1451
1451
 
1452
1452
  // src/builders/components.ts
1453
+ function serializeEmoji(emoji) {
1454
+ if (!emoji) return void 0;
1455
+ return {
1456
+ id: emoji.id,
1457
+ name: emoji.name,
1458
+ animated: emoji.animated
1459
+ };
1460
+ }
1453
1461
  var ButtonBuilder = class {
1454
- data = { type: ComponentType.BUTTON };
1462
+ data = {
1463
+ type: ComponentType.BUTTON
1464
+ };
1455
1465
  setCustomId(id) {
1456
1466
  this.data.customId = id;
1457
1467
  return this;
@@ -1478,14 +1488,26 @@ var ButtonBuilder = class {
1478
1488
  return this;
1479
1489
  }
1480
1490
  build() {
1481
- return { ...this.data };
1491
+ return {
1492
+ ...this.data
1493
+ };
1482
1494
  }
1483
1495
  toJSON() {
1484
- return this.build();
1496
+ return {
1497
+ type: ComponentType.BUTTON,
1498
+ custom_id: this.data.customId,
1499
+ label: this.data.label,
1500
+ style: this.data.style,
1501
+ disabled: this.data.disabled,
1502
+ url: this.data.url,
1503
+ emoji: serializeEmoji(this.data.emoji)
1504
+ };
1485
1505
  }
1486
1506
  };
1487
1507
  var SelectMenuBuilder = class {
1488
- data = { type: ComponentType.STRING_SELECT };
1508
+ data = {
1509
+ type: ComponentType.STRING_SELECT
1510
+ };
1489
1511
  setCustomId(id) {
1490
1512
  this.data.customId = id;
1491
1513
  return this;
@@ -1506,29 +1528,55 @@ var SelectMenuBuilder = class {
1506
1528
  this.data.disabled = disabled;
1507
1529
  return this;
1508
1530
  }
1531
+ setType(type) {
1532
+ this.data.type = type;
1533
+ return this;
1534
+ }
1509
1535
  addOption(option) {
1510
- if (!this.data.options) this.data.options = [];
1536
+ if (!this.data.options) {
1537
+ this.data.options = [];
1538
+ }
1511
1539
  this.data.options.push(option);
1512
1540
  return this;
1513
1541
  }
1514
1542
  addOptions(...options) {
1515
- if (!this.data.options) this.data.options = [];
1543
+ if (!this.data.options) {
1544
+ this.data.options = [];
1545
+ }
1516
1546
  this.data.options.push(...options);
1517
1547
  return this;
1518
1548
  }
1519
- setType(type) {
1520
- this.data.type = type;
1521
- return this;
1522
- }
1523
1549
  build() {
1524
- return { ...this.data };
1550
+ return {
1551
+ ...this.data
1552
+ };
1525
1553
  }
1526
1554
  toJSON() {
1527
- return this.build();
1555
+ return {
1556
+ type: this.data.type ?? ComponentType.STRING_SELECT,
1557
+ custom_id: this.data.customId,
1558
+ placeholder: this.data.placeholder,
1559
+ min_values: this.data.minValues,
1560
+ max_values: this.data.maxValues,
1561
+ disabled: this.data.disabled,
1562
+ options: this.data.options?.map((option) => ({
1563
+ label: option.label,
1564
+ value: option.value,
1565
+ description: option.description,
1566
+ emoji: serializeEmoji(option.emoji),
1567
+ default: option.default
1568
+ }))
1569
+ };
1528
1570
  }
1529
1571
  };
1530
1572
  var TextInputBuilder = class {
1531
- data = { type: ComponentType.TEXT_INPUT };
1573
+ data = {
1574
+ type: ComponentType.TEXT_INPUT
1575
+ };
1576
+ _minLength;
1577
+ _maxLength;
1578
+ _required;
1579
+ _value;
1532
1580
  setCustomId(id) {
1533
1581
  this.data.customId = id;
1534
1582
  return this;
@@ -1545,10 +1593,6 @@ var TextInputBuilder = class {
1545
1593
  this.data.placeholder = placeholder;
1546
1594
  return this;
1547
1595
  }
1548
- _minLength;
1549
- _maxLength;
1550
- _required;
1551
- _value;
1552
1596
  setMinLength(length) {
1553
1597
  this._minLength = length;
1554
1598
  return this;
@@ -1589,21 +1633,36 @@ var TextInputBuilder = class {
1589
1633
  }
1590
1634
  };
1591
1635
  var ActionRowBuilder = class {
1592
- data = { type: ComponentType.ACTION_ROW, components: [] };
1636
+ data = {
1637
+ type: ComponentType.ACTION_ROW,
1638
+ components: []
1639
+ };
1593
1640
  addComponent(component) {
1594
- const built = "build" in component && typeof component.build === "function" ? component.build() : component;
1595
- this.data.components.push(built);
1641
+ this.data.components.push(component);
1596
1642
  return this;
1597
1643
  }
1598
1644
  addComponents(...components) {
1599
- for (const c of components) this.addComponent(c);
1645
+ for (const component of components) {
1646
+ this.addComponent(component);
1647
+ }
1600
1648
  return this;
1601
1649
  }
1602
1650
  build() {
1603
- return { ...this.data, components: [...this.data.components] };
1651
+ return {
1652
+ ...this.data,
1653
+ components: [...this.data.components]
1654
+ };
1604
1655
  }
1605
1656
  toJSON() {
1606
- return this.build();
1657
+ return {
1658
+ type: ComponentType.ACTION_ROW,
1659
+ components: this.data.components?.map((component) => {
1660
+ if (component && typeof component.toJSON === "function") {
1661
+ return component.toJSON();
1662
+ }
1663
+ return component;
1664
+ })
1665
+ };
1607
1666
  }
1608
1667
  };
1609
1668
  var ModalBuilder = class {
@@ -1618,13 +1677,14 @@ var ModalBuilder = class {
1618
1677
  this._customId = id;
1619
1678
  return this;
1620
1679
  }
1621
- addComponent(row) {
1622
- const built = "build" in row && typeof row.build === "function" ? row.build() : row;
1623
- this._components.push(built);
1680
+ addComponent(component) {
1681
+ this._components.push(component);
1624
1682
  return this;
1625
1683
  }
1626
- addComponents(...rows) {
1627
- for (const r of rows) this.addComponent(r);
1684
+ addComponents(...components) {
1685
+ for (const component of components) {
1686
+ this.addComponent(component);
1687
+ }
1628
1688
  return this;
1629
1689
  }
1630
1690
  build() {
@@ -1635,7 +1695,16 @@ var ModalBuilder = class {
1635
1695
  };
1636
1696
  }
1637
1697
  toJSON() {
1638
- return this.build();
1698
+ return {
1699
+ title: this._title,
1700
+ custom_id: this._customId,
1701
+ components: this._components.map((component) => {
1702
+ if (component && typeof component.toJSON === "function") {
1703
+ return component.toJSON();
1704
+ }
1705
+ return component;
1706
+ })
1707
+ };
1639
1708
  }
1640
1709
  };
1641
1710
 
@@ -2808,6 +2877,7 @@ var Client = class {
2808
2877
  listeners = /* @__PURE__ */ new Map();
2809
2878
  middlewares = [];
2810
2879
  constructor(options) {
2880
+ if (!options.token) throw new Error("[Chameleon] Token is required");
2811
2881
  this.token = options.token;
2812
2882
  this.intents = this.resolveIntents(options.intents);
2813
2883
  this.debug = options.debug ?? false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@impulsedev/chameleon",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "highly optimized, memory-efficient, and fully type-safe Discord API library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",