@impulsedev/chameleon 1.4.0 → 1.7.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 +1 -1
- package/dist/index.js +58 -83
- 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;
|
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.7.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,44 +1364,62 @@ 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 (
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
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
|
|
1423
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;
|
|
1424
1393
|
}
|
|
1425
|
-
if (
|
|
1426
|
-
|
|
1427
|
-
text:
|
|
1428
|
-
icon_url: this.data.footer.iconUrl,
|
|
1429
|
-
proxy_icon_url: this.data.footer.proxyIconUrl
|
|
1394
|
+
if (e.footer) {
|
|
1395
|
+
const footer = {
|
|
1396
|
+
text: e.footer.text
|
|
1430
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;
|
|
1431
1405
|
}
|
|
1432
|
-
if (
|
|
1406
|
+
if (e.image?.url) {
|
|
1433
1407
|
payload.image = {
|
|
1434
|
-
url:
|
|
1435
|
-
proxy_url: this.data.image.proxyUrl,
|
|
1436
|
-
height: this.data.image.height,
|
|
1437
|
-
width: this.data.image.width
|
|
1408
|
+
url: e.image.url
|
|
1438
1409
|
};
|
|
1439
1410
|
}
|
|
1440
|
-
if (
|
|
1411
|
+
if (e.thumbnail?.url) {
|
|
1441
1412
|
payload.thumbnail = {
|
|
1442
|
-
url:
|
|
1443
|
-
proxy_url: this.data.thumbnail.proxyUrl,
|
|
1444
|
-
height: this.data.thumbnail.height,
|
|
1445
|
-
width: this.data.thumbnail.width
|
|
1413
|
+
url: e.thumbnail.url
|
|
1446
1414
|
};
|
|
1447
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
|
+
}
|
|
1448
1423
|
return payload;
|
|
1449
1424
|
}
|
|
1450
1425
|
};
|