@impulsedev/chameleon 1.3.0 → 1.6.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 +21 -13
- package/dist/index.js +142 -110
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2486,7 +2486,7 @@ declare const Colors: {
|
|
|
2486
2486
|
};
|
|
2487
2487
|
declare class EmbedBuilder {
|
|
2488
2488
|
private data;
|
|
2489
|
-
constructor(data?: Partial<Embed>
|
|
2489
|
+
constructor(data?: Partial<Embed>);
|
|
2490
2490
|
setTitle(title: string): this;
|
|
2491
2491
|
setDescription(description: string): this;
|
|
2492
2492
|
setColor(color: number): this;
|
|
@@ -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():
|
|
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():
|
|
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():
|
|
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(
|
|
2567
|
+
addComponent(component: MessageComponent | {
|
|
2564
2568
|
build(): MessageComponent;
|
|
2569
|
+
} | {
|
|
2570
|
+
toJSON(): any;
|
|
2565
2571
|
}): this;
|
|
2566
|
-
addComponents(...
|
|
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:
|
|
2580
|
+
components: any[];
|
|
2573
2581
|
};
|
|
2574
2582
|
toJSON(): {
|
|
2575
2583
|
title: string;
|
|
2576
2584
|
custom_id: string;
|
|
2577
|
-
components:
|
|
2585
|
+
components: any[];
|
|
2578
2586
|
};
|
|
2579
2587
|
}
|
|
2580
2588
|
|
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.
|
|
1218
|
+
version: "1.6.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",
|
|
@@ -1306,59 +1306,9 @@ var Colors = {
|
|
|
1306
1306
|
Transparent: 3092790
|
|
1307
1307
|
};
|
|
1308
1308
|
var EmbedBuilder = class {
|
|
1309
|
-
data;
|
|
1309
|
+
data = {};
|
|
1310
1310
|
constructor(data) {
|
|
1311
|
-
this.data
|
|
1312
|
-
if (!data) return;
|
|
1313
|
-
if ("title" in data) this.data.title = data.title;
|
|
1314
|
-
if ("description" in data) this.data.description = data.description;
|
|
1315
|
-
if ("color" in data) this.data.color = data.color;
|
|
1316
|
-
if ("url" in data) this.data.url = data.url;
|
|
1317
|
-
if ("timestamp" in data && data.timestamp) {
|
|
1318
|
-
this.data.timestamp = new Date(data.timestamp).getTime();
|
|
1319
|
-
}
|
|
1320
|
-
if (data.author) {
|
|
1321
|
-
const author = data.author;
|
|
1322
|
-
this.data.author = {
|
|
1323
|
-
name: author.name,
|
|
1324
|
-
url: author.url,
|
|
1325
|
-
iconUrl: author.iconUrl ?? author.icon_url,
|
|
1326
|
-
proxyIconUrl: author.proxyIconUrl ?? author.proxy_icon_url
|
|
1327
|
-
};
|
|
1328
|
-
}
|
|
1329
|
-
if (data.footer) {
|
|
1330
|
-
const footer = data.footer;
|
|
1331
|
-
this.data.footer = {
|
|
1332
|
-
text: footer.text,
|
|
1333
|
-
iconUrl: footer.iconUrl ?? footer.icon_url,
|
|
1334
|
-
proxyIconUrl: footer.proxyIconUrl ?? footer.proxy_icon_url
|
|
1335
|
-
};
|
|
1336
|
-
}
|
|
1337
|
-
if (data.image) {
|
|
1338
|
-
const image = data.image;
|
|
1339
|
-
this.data.image = {
|
|
1340
|
-
url: image.url,
|
|
1341
|
-
proxyUrl: image.proxyUrl ?? image.proxy_url,
|
|
1342
|
-
height: image.height,
|
|
1343
|
-
width: image.width
|
|
1344
|
-
};
|
|
1345
|
-
}
|
|
1346
|
-
if (data.thumbnail) {
|
|
1347
|
-
const thumbnail = data.thumbnail;
|
|
1348
|
-
this.data.thumbnail = {
|
|
1349
|
-
url: thumbnail.url,
|
|
1350
|
-
proxyUrl: thumbnail.proxyUrl ?? thumbnail.proxy_url,
|
|
1351
|
-
height: thumbnail.height,
|
|
1352
|
-
width: thumbnail.width
|
|
1353
|
-
};
|
|
1354
|
-
}
|
|
1355
|
-
if (Array.isArray(data.fields)) {
|
|
1356
|
-
this.data.fields = data.fields.map((f) => ({
|
|
1357
|
-
name: f.name,
|
|
1358
|
-
value: f.value,
|
|
1359
|
-
inline: f.inline ?? false
|
|
1360
|
-
}));
|
|
1361
|
-
}
|
|
1311
|
+
if (data) Object.assign(this.data, data);
|
|
1362
1312
|
}
|
|
1363
1313
|
setTitle(title) {
|
|
1364
1314
|
this.data.title = title;
|
|
@@ -1376,16 +1326,23 @@ var EmbedBuilder = class {
|
|
|
1376
1326
|
this.data.url = url;
|
|
1377
1327
|
return this;
|
|
1378
1328
|
}
|
|
1379
|
-
setTimestamp(ts) {
|
|
1380
|
-
this.data.timestamp = ts instanceof Date ? ts.getTime() : ts
|
|
1329
|
+
setTimestamp(ts = Date.now()) {
|
|
1330
|
+
this.data.timestamp = ts instanceof Date ? ts.getTime() : ts;
|
|
1381
1331
|
return this;
|
|
1382
1332
|
}
|
|
1383
1333
|
setFooter(text, iconUrl) {
|
|
1384
|
-
this.data.footer = {
|
|
1334
|
+
this.data.footer = {
|
|
1335
|
+
text,
|
|
1336
|
+
...iconUrl ? { iconUrl } : {}
|
|
1337
|
+
};
|
|
1385
1338
|
return this;
|
|
1386
1339
|
}
|
|
1387
1340
|
setAuthor(name, iconUrl, url) {
|
|
1388
|
-
this.data.author = {
|
|
1341
|
+
this.data.author = {
|
|
1342
|
+
name,
|
|
1343
|
+
...iconUrl ? { iconUrl } : {},
|
|
1344
|
+
...url ? { url } : {}
|
|
1345
|
+
};
|
|
1389
1346
|
return this;
|
|
1390
1347
|
}
|
|
1391
1348
|
setImage(url) {
|
|
@@ -1407,51 +1364,67 @@ var EmbedBuilder = class {
|
|
|
1407
1364
|
return this;
|
|
1408
1365
|
}
|
|
1409
1366
|
build() {
|
|
1410
|
-
return
|
|
1367
|
+
return this.data;
|
|
1411
1368
|
}
|
|
1412
1369
|
toJSON() {
|
|
1413
|
-
const
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
if (
|
|
1370
|
+
const e = this.data;
|
|
1371
|
+
const payload = {};
|
|
1372
|
+
if (e.title) payload.title = e.title;
|
|
1373
|
+
if (e.description) payload.description = e.description;
|
|
1374
|
+
if (e.color) payload.color = e.color;
|
|
1375
|
+
if (e.url) payload.url = e.url;
|
|
1376
|
+
if (e.timestamp) {
|
|
1377
|
+
payload.timestamp = new Date(e.timestamp).toISOString();
|
|
1378
|
+
}
|
|
1379
|
+
if (e.author) {
|
|
1418
1380
|
payload.author = {
|
|
1419
|
-
name:
|
|
1420
|
-
url:
|
|
1421
|
-
icon_url:
|
|
1422
|
-
proxy_icon_url:
|
|
1381
|
+
name: e.author.name,
|
|
1382
|
+
...e.author.url ? { url: e.author.url } : {},
|
|
1383
|
+
...e.author.iconUrl ? { icon_url: e.author.iconUrl } : {},
|
|
1384
|
+
...e.author.proxyIconUrl ? { proxy_icon_url: e.author.proxyIconUrl } : {}
|
|
1423
1385
|
};
|
|
1424
1386
|
}
|
|
1425
|
-
if (
|
|
1387
|
+
if (e.footer) {
|
|
1426
1388
|
payload.footer = {
|
|
1427
|
-
text:
|
|
1428
|
-
icon_url:
|
|
1429
|
-
proxy_icon_url:
|
|
1389
|
+
text: e.footer.text,
|
|
1390
|
+
...e.footer.iconUrl ? { icon_url: e.footer.iconUrl } : {},
|
|
1391
|
+
...e.footer.proxyIconUrl ? { proxy_icon_url: e.footer.proxyIconUrl } : {}
|
|
1430
1392
|
};
|
|
1431
1393
|
}
|
|
1432
|
-
if (
|
|
1394
|
+
if (e.image?.url) {
|
|
1433
1395
|
payload.image = {
|
|
1434
|
-
url:
|
|
1435
|
-
proxy_url: this.data.image.proxyUrl,
|
|
1436
|
-
height: this.data.image.height,
|
|
1437
|
-
width: this.data.image.width
|
|
1396
|
+
url: e.image.url
|
|
1438
1397
|
};
|
|
1439
1398
|
}
|
|
1440
|
-
if (
|
|
1399
|
+
if (e.thumbnail?.url) {
|
|
1441
1400
|
payload.thumbnail = {
|
|
1442
|
-
url:
|
|
1443
|
-
proxy_url: this.data.thumbnail.proxyUrl,
|
|
1444
|
-
height: this.data.thumbnail.height,
|
|
1445
|
-
width: this.data.thumbnail.width
|
|
1401
|
+
url: e.thumbnail.url
|
|
1446
1402
|
};
|
|
1447
1403
|
}
|
|
1404
|
+
if (e.fields?.length) {
|
|
1405
|
+
payload.fields = e.fields.map((f) => ({
|
|
1406
|
+
name: f.name,
|
|
1407
|
+
value: f.value,
|
|
1408
|
+
inline: f.inline ?? false
|
|
1409
|
+
}));
|
|
1410
|
+
}
|
|
1448
1411
|
return payload;
|
|
1449
1412
|
}
|
|
1450
1413
|
};
|
|
1451
1414
|
|
|
1452
1415
|
// src/builders/components.ts
|
|
1416
|
+
function serializeEmoji(emoji) {
|
|
1417
|
+
if (!emoji) return void 0;
|
|
1418
|
+
return {
|
|
1419
|
+
id: emoji.id,
|
|
1420
|
+
name: emoji.name,
|
|
1421
|
+
animated: emoji.animated
|
|
1422
|
+
};
|
|
1423
|
+
}
|
|
1453
1424
|
var ButtonBuilder = class {
|
|
1454
|
-
data = {
|
|
1425
|
+
data = {
|
|
1426
|
+
type: ComponentType.BUTTON
|
|
1427
|
+
};
|
|
1455
1428
|
setCustomId(id) {
|
|
1456
1429
|
this.data.customId = id;
|
|
1457
1430
|
return this;
|
|
@@ -1478,14 +1451,26 @@ var ButtonBuilder = class {
|
|
|
1478
1451
|
return this;
|
|
1479
1452
|
}
|
|
1480
1453
|
build() {
|
|
1481
|
-
return {
|
|
1454
|
+
return {
|
|
1455
|
+
...this.data
|
|
1456
|
+
};
|
|
1482
1457
|
}
|
|
1483
1458
|
toJSON() {
|
|
1484
|
-
return
|
|
1459
|
+
return {
|
|
1460
|
+
type: ComponentType.BUTTON,
|
|
1461
|
+
custom_id: this.data.customId,
|
|
1462
|
+
label: this.data.label,
|
|
1463
|
+
style: this.data.style,
|
|
1464
|
+
disabled: this.data.disabled,
|
|
1465
|
+
url: this.data.url,
|
|
1466
|
+
emoji: serializeEmoji(this.data.emoji)
|
|
1467
|
+
};
|
|
1485
1468
|
}
|
|
1486
1469
|
};
|
|
1487
1470
|
var SelectMenuBuilder = class {
|
|
1488
|
-
data = {
|
|
1471
|
+
data = {
|
|
1472
|
+
type: ComponentType.STRING_SELECT
|
|
1473
|
+
};
|
|
1489
1474
|
setCustomId(id) {
|
|
1490
1475
|
this.data.customId = id;
|
|
1491
1476
|
return this;
|
|
@@ -1506,29 +1491,55 @@ var SelectMenuBuilder = class {
|
|
|
1506
1491
|
this.data.disabled = disabled;
|
|
1507
1492
|
return this;
|
|
1508
1493
|
}
|
|
1494
|
+
setType(type) {
|
|
1495
|
+
this.data.type = type;
|
|
1496
|
+
return this;
|
|
1497
|
+
}
|
|
1509
1498
|
addOption(option) {
|
|
1510
|
-
if (!this.data.options)
|
|
1499
|
+
if (!this.data.options) {
|
|
1500
|
+
this.data.options = [];
|
|
1501
|
+
}
|
|
1511
1502
|
this.data.options.push(option);
|
|
1512
1503
|
return this;
|
|
1513
1504
|
}
|
|
1514
1505
|
addOptions(...options) {
|
|
1515
|
-
if (!this.data.options)
|
|
1506
|
+
if (!this.data.options) {
|
|
1507
|
+
this.data.options = [];
|
|
1508
|
+
}
|
|
1516
1509
|
this.data.options.push(...options);
|
|
1517
1510
|
return this;
|
|
1518
1511
|
}
|
|
1519
|
-
setType(type) {
|
|
1520
|
-
this.data.type = type;
|
|
1521
|
-
return this;
|
|
1522
|
-
}
|
|
1523
1512
|
build() {
|
|
1524
|
-
return {
|
|
1513
|
+
return {
|
|
1514
|
+
...this.data
|
|
1515
|
+
};
|
|
1525
1516
|
}
|
|
1526
1517
|
toJSON() {
|
|
1527
|
-
return
|
|
1518
|
+
return {
|
|
1519
|
+
type: this.data.type ?? ComponentType.STRING_SELECT,
|
|
1520
|
+
custom_id: this.data.customId,
|
|
1521
|
+
placeholder: this.data.placeholder,
|
|
1522
|
+
min_values: this.data.minValues,
|
|
1523
|
+
max_values: this.data.maxValues,
|
|
1524
|
+
disabled: this.data.disabled,
|
|
1525
|
+
options: this.data.options?.map((option) => ({
|
|
1526
|
+
label: option.label,
|
|
1527
|
+
value: option.value,
|
|
1528
|
+
description: option.description,
|
|
1529
|
+
emoji: serializeEmoji(option.emoji),
|
|
1530
|
+
default: option.default
|
|
1531
|
+
}))
|
|
1532
|
+
};
|
|
1528
1533
|
}
|
|
1529
1534
|
};
|
|
1530
1535
|
var TextInputBuilder = class {
|
|
1531
|
-
data = {
|
|
1536
|
+
data = {
|
|
1537
|
+
type: ComponentType.TEXT_INPUT
|
|
1538
|
+
};
|
|
1539
|
+
_minLength;
|
|
1540
|
+
_maxLength;
|
|
1541
|
+
_required;
|
|
1542
|
+
_value;
|
|
1532
1543
|
setCustomId(id) {
|
|
1533
1544
|
this.data.customId = id;
|
|
1534
1545
|
return this;
|
|
@@ -1545,10 +1556,6 @@ var TextInputBuilder = class {
|
|
|
1545
1556
|
this.data.placeholder = placeholder;
|
|
1546
1557
|
return this;
|
|
1547
1558
|
}
|
|
1548
|
-
_minLength;
|
|
1549
|
-
_maxLength;
|
|
1550
|
-
_required;
|
|
1551
|
-
_value;
|
|
1552
1559
|
setMinLength(length) {
|
|
1553
1560
|
this._minLength = length;
|
|
1554
1561
|
return this;
|
|
@@ -1589,21 +1596,36 @@ var TextInputBuilder = class {
|
|
|
1589
1596
|
}
|
|
1590
1597
|
};
|
|
1591
1598
|
var ActionRowBuilder = class {
|
|
1592
|
-
data = {
|
|
1599
|
+
data = {
|
|
1600
|
+
type: ComponentType.ACTION_ROW,
|
|
1601
|
+
components: []
|
|
1602
|
+
};
|
|
1593
1603
|
addComponent(component) {
|
|
1594
|
-
|
|
1595
|
-
this.data.components.push(built);
|
|
1604
|
+
this.data.components.push(component);
|
|
1596
1605
|
return this;
|
|
1597
1606
|
}
|
|
1598
1607
|
addComponents(...components) {
|
|
1599
|
-
for (const
|
|
1608
|
+
for (const component of components) {
|
|
1609
|
+
this.addComponent(component);
|
|
1610
|
+
}
|
|
1600
1611
|
return this;
|
|
1601
1612
|
}
|
|
1602
1613
|
build() {
|
|
1603
|
-
return {
|
|
1614
|
+
return {
|
|
1615
|
+
...this.data,
|
|
1616
|
+
components: [...this.data.components]
|
|
1617
|
+
};
|
|
1604
1618
|
}
|
|
1605
1619
|
toJSON() {
|
|
1606
|
-
return
|
|
1620
|
+
return {
|
|
1621
|
+
type: ComponentType.ACTION_ROW,
|
|
1622
|
+
components: this.data.components?.map((component) => {
|
|
1623
|
+
if (component && typeof component.toJSON === "function") {
|
|
1624
|
+
return component.toJSON();
|
|
1625
|
+
}
|
|
1626
|
+
return component;
|
|
1627
|
+
})
|
|
1628
|
+
};
|
|
1607
1629
|
}
|
|
1608
1630
|
};
|
|
1609
1631
|
var ModalBuilder = class {
|
|
@@ -1618,13 +1640,14 @@ var ModalBuilder = class {
|
|
|
1618
1640
|
this._customId = id;
|
|
1619
1641
|
return this;
|
|
1620
1642
|
}
|
|
1621
|
-
addComponent(
|
|
1622
|
-
|
|
1623
|
-
this._components.push(built);
|
|
1643
|
+
addComponent(component) {
|
|
1644
|
+
this._components.push(component);
|
|
1624
1645
|
return this;
|
|
1625
1646
|
}
|
|
1626
|
-
addComponents(...
|
|
1627
|
-
for (const
|
|
1647
|
+
addComponents(...components) {
|
|
1648
|
+
for (const component of components) {
|
|
1649
|
+
this.addComponent(component);
|
|
1650
|
+
}
|
|
1628
1651
|
return this;
|
|
1629
1652
|
}
|
|
1630
1653
|
build() {
|
|
@@ -1635,7 +1658,16 @@ var ModalBuilder = class {
|
|
|
1635
1658
|
};
|
|
1636
1659
|
}
|
|
1637
1660
|
toJSON() {
|
|
1638
|
-
return
|
|
1661
|
+
return {
|
|
1662
|
+
title: this._title,
|
|
1663
|
+
custom_id: this._customId,
|
|
1664
|
+
components: this._components.map((component) => {
|
|
1665
|
+
if (component && typeof component.toJSON === "function") {
|
|
1666
|
+
return component.toJSON();
|
|
1667
|
+
}
|
|
1668
|
+
return component;
|
|
1669
|
+
})
|
|
1670
|
+
};
|
|
1639
1671
|
}
|
|
1640
1672
|
};
|
|
1641
1673
|
|