revbot.js 0.0.4 → 0.0.6
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.mts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +72 -18
- package/dist/index.mjs +72 -18
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1437,10 +1437,17 @@ declare class MessageEmbed {
|
|
|
1437
1437
|
/**
|
|
1438
1438
|
* Sets the media (e.g., image or video) of the embed.
|
|
1439
1439
|
*
|
|
1440
|
-
* @param {string} media - The media URL to set.
|
|
1440
|
+
* @param {Readable | string | File} media - The media URL, File or Stream to set.
|
|
1441
1441
|
* @returns {this} The updated `MessageEmbed` instance.
|
|
1442
1442
|
*/
|
|
1443
|
-
setMedia(media: string): this;
|
|
1443
|
+
setMedia(media: Readable | string | File$1): this;
|
|
1444
|
+
/**
|
|
1445
|
+
*
|
|
1446
|
+
* @param client The client instance used to send the embed.
|
|
1447
|
+
* @returns SendableEmbed
|
|
1448
|
+
* Converts the embed to a JSON object that can be sent to the API, including media handling.
|
|
1449
|
+
*/
|
|
1450
|
+
toJSONWithMedia(client: client): Promise<SendableEmbed>;
|
|
1444
1451
|
/**
|
|
1445
1452
|
* Converts the embed to a JSON object that can be sent to the API.
|
|
1446
1453
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1437,10 +1437,17 @@ declare class MessageEmbed {
|
|
|
1437
1437
|
/**
|
|
1438
1438
|
* Sets the media (e.g., image or video) of the embed.
|
|
1439
1439
|
*
|
|
1440
|
-
* @param {string} media - The media URL to set.
|
|
1440
|
+
* @param {Readable | string | File} media - The media URL, File or Stream to set.
|
|
1441
1441
|
* @returns {this} The updated `MessageEmbed` instance.
|
|
1442
1442
|
*/
|
|
1443
|
-
setMedia(media: string): this;
|
|
1443
|
+
setMedia(media: Readable | string | File$1): this;
|
|
1444
|
+
/**
|
|
1445
|
+
*
|
|
1446
|
+
* @param client The client instance used to send the embed.
|
|
1447
|
+
* @returns SendableEmbed
|
|
1448
|
+
* Converts the embed to a JSON object that can be sent to the API, including media handling.
|
|
1449
|
+
*/
|
|
1450
|
+
toJSONWithMedia(client: client): Promise<SendableEmbed>;
|
|
1444
1451
|
/**
|
|
1445
1452
|
* Converts the embed to a JSON object that can be sent to the API.
|
|
1446
1453
|
*
|
package/dist/index.js
CHANGED
|
@@ -1715,6 +1715,10 @@ var Mentions = class {
|
|
|
1715
1715
|
};
|
|
1716
1716
|
|
|
1717
1717
|
// src/struct/messageEmbed.ts
|
|
1718
|
+
var import_stream = require("stream");
|
|
1719
|
+
var import_axios = __toESM(require("axios"));
|
|
1720
|
+
var import_form_data = __toESM(require("form-data"));
|
|
1721
|
+
var import_node_buffer = require("buffer");
|
|
1718
1722
|
var _url, _title, _description, _icon_url, _color, _media;
|
|
1719
1723
|
var MessageEmbed = class {
|
|
1720
1724
|
constructor() {
|
|
@@ -1778,26 +1782,68 @@ var MessageEmbed = class {
|
|
|
1778
1782
|
/**
|
|
1779
1783
|
* Sets the media (e.g., image or video) of the embed.
|
|
1780
1784
|
*
|
|
1781
|
-
* @param {string} media - The media URL to set.
|
|
1785
|
+
* @param {Readable | string | File} media - The media URL, File or Stream to set.
|
|
1782
1786
|
* @returns {this} The updated `MessageEmbed` instance.
|
|
1783
1787
|
*/
|
|
1784
1788
|
setMedia(media) {
|
|
1785
1789
|
__privateSet(this, _media, media);
|
|
1786
1790
|
return this;
|
|
1787
1791
|
}
|
|
1792
|
+
/**
|
|
1793
|
+
*
|
|
1794
|
+
* @param client The client instance used to send the embed.
|
|
1795
|
+
* @returns SendableEmbed
|
|
1796
|
+
* Converts the embed to a JSON object that can be sent to the API, including media handling.
|
|
1797
|
+
*/
|
|
1798
|
+
toJSONWithMedia(client3) {
|
|
1799
|
+
return __async(this, null, function* () {
|
|
1800
|
+
const embed = {
|
|
1801
|
+
title: __privateGet(this, _title),
|
|
1802
|
+
icon_url: __privateGet(this, _icon_url),
|
|
1803
|
+
colour: __privateGet(this, _color),
|
|
1804
|
+
description: __privateGet(this, _description),
|
|
1805
|
+
url: __privateGet(this, _url)
|
|
1806
|
+
};
|
|
1807
|
+
if (__privateGet(this, _media)) {
|
|
1808
|
+
let att = __privateGet(this, _media);
|
|
1809
|
+
const data = new import_form_data.default();
|
|
1810
|
+
if (typeof att === "string") {
|
|
1811
|
+
const readableStream = yield import_axios.default.get(att, {
|
|
1812
|
+
responseType: "stream"
|
|
1813
|
+
});
|
|
1814
|
+
data.append("file", readableStream.data, {
|
|
1815
|
+
filename: att.split("/").pop()
|
|
1816
|
+
});
|
|
1817
|
+
}
|
|
1818
|
+
if (att instanceof import_stream.Readable) {
|
|
1819
|
+
data.append("file", att);
|
|
1820
|
+
}
|
|
1821
|
+
if (att instanceof import_node_buffer.File) {
|
|
1822
|
+
const buffer = Buffer.from(yield att.arrayBuffer());
|
|
1823
|
+
data.append("file", buffer, { filename: att.name });
|
|
1824
|
+
}
|
|
1825
|
+
yield client3.cdn.post("/attachments", data).then((attachment) => {
|
|
1826
|
+
const { id } = attachment;
|
|
1827
|
+
embed.media = id;
|
|
1828
|
+
});
|
|
1829
|
+
}
|
|
1830
|
+
return embed;
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1788
1833
|
/**
|
|
1789
1834
|
* Converts the embed to a JSON object that can be sent to the API.
|
|
1790
1835
|
*
|
|
1791
1836
|
* @returns {SendableEmbed} The JSON representation of the embed.
|
|
1792
1837
|
*/
|
|
1793
1838
|
toJSON() {
|
|
1839
|
+
var _a;
|
|
1794
1840
|
return {
|
|
1795
1841
|
title: __privateGet(this, _title),
|
|
1796
|
-
description: __privateGet(this, _description),
|
|
1797
|
-
url: __privateGet(this, _url),
|
|
1798
1842
|
icon_url: __privateGet(this, _icon_url),
|
|
1799
1843
|
colour: __privateGet(this, _color),
|
|
1800
|
-
|
|
1844
|
+
description: __privateGet(this, _description),
|
|
1845
|
+
url: __privateGet(this, _url),
|
|
1846
|
+
media: (_a = __privateGet(this, _media)) == null ? void 0 : _a.toString()
|
|
1801
1847
|
};
|
|
1802
1848
|
}
|
|
1803
1849
|
};
|
|
@@ -2566,10 +2612,10 @@ var UserManager = class extends BaseManager {
|
|
|
2566
2612
|
};
|
|
2567
2613
|
|
|
2568
2614
|
// src/managers/messageManager.ts
|
|
2569
|
-
var
|
|
2570
|
-
var
|
|
2571
|
-
var
|
|
2572
|
-
var
|
|
2615
|
+
var import_node_buffer2 = require("buffer");
|
|
2616
|
+
var import_stream2 = require("stream");
|
|
2617
|
+
var import_form_data2 = __toESM(require("form-data"));
|
|
2618
|
+
var import_axios2 = __toESM(require("axios"));
|
|
2573
2619
|
var MessageManager = class extends BaseManager {
|
|
2574
2620
|
constructor(channel) {
|
|
2575
2621
|
super(channel.client);
|
|
@@ -2589,21 +2635,22 @@ var MessageManager = class extends BaseManager {
|
|
|
2589
2635
|
return __async(this, null, function* () {
|
|
2590
2636
|
if (typeof content === "string") content = { content };
|
|
2591
2637
|
let attachments = [];
|
|
2638
|
+
let embeds = [];
|
|
2592
2639
|
if (Array.isArray(content.attachments)) {
|
|
2593
2640
|
const promises = content.attachments.map((att) => __async(this, null, function* () {
|
|
2594
|
-
const data = new
|
|
2641
|
+
const data = new import_form_data2.default();
|
|
2595
2642
|
if (typeof att === "string") {
|
|
2596
|
-
const readableStream = yield
|
|
2643
|
+
const readableStream = yield import_axios2.default.get(att, {
|
|
2597
2644
|
responseType: "stream"
|
|
2598
2645
|
});
|
|
2599
2646
|
data.append("file", readableStream.data, {
|
|
2600
2647
|
filename: att.split("/").pop()
|
|
2601
2648
|
});
|
|
2602
2649
|
}
|
|
2603
|
-
if (att instanceof
|
|
2650
|
+
if (att instanceof import_stream2.Readable) {
|
|
2604
2651
|
data.append("file", att);
|
|
2605
2652
|
}
|
|
2606
|
-
if (att instanceof
|
|
2653
|
+
if (att instanceof import_node_buffer2.File) {
|
|
2607
2654
|
const buffer = Buffer.from(yield att.arrayBuffer());
|
|
2608
2655
|
data.append("file", buffer, { filename: att.name });
|
|
2609
2656
|
}
|
|
@@ -2614,10 +2661,17 @@ var MessageManager = class extends BaseManager {
|
|
|
2614
2661
|
}));
|
|
2615
2662
|
yield Promise.all(promises);
|
|
2616
2663
|
}
|
|
2664
|
+
if (Array.isArray(content.embeds)) {
|
|
2665
|
+
const promises = content.embeds.map((embed) => __async(this, null, function* () {
|
|
2666
|
+
const json = yield embed.toJSONWithMedia(this.client);
|
|
2667
|
+
embeds.push(json);
|
|
2668
|
+
}));
|
|
2669
|
+
yield Promise.all(promises);
|
|
2670
|
+
}
|
|
2617
2671
|
const resp = yield this.client.api.post(
|
|
2618
2672
|
`/channels/${this.channel.id}/messages`,
|
|
2619
2673
|
{
|
|
2620
|
-
body: __spreadProps(__spreadValues({}, content), { attachments, nonce: UUID.generate() })
|
|
2674
|
+
body: __spreadProps(__spreadValues({}, content), { attachments, embeds, nonce: UUID.generate() })
|
|
2621
2675
|
}
|
|
2622
2676
|
);
|
|
2623
2677
|
return this._add(resp);
|
|
@@ -3034,10 +3088,10 @@ var ServerMemberManager = class extends BaseManager {
|
|
|
3034
3088
|
var import_node_events = require("events");
|
|
3035
3089
|
|
|
3036
3090
|
// src/rest/restClient.ts
|
|
3037
|
-
var
|
|
3091
|
+
var import_axios3 = __toESM(require("axios"));
|
|
3038
3092
|
|
|
3039
3093
|
// package.json
|
|
3040
|
-
var version = "0.0.
|
|
3094
|
+
var version = "0.0.6";
|
|
3041
3095
|
|
|
3042
3096
|
// src/rest/restClient.ts
|
|
3043
3097
|
var RestClient = class {
|
|
@@ -3066,7 +3120,7 @@ var RestClient = class {
|
|
|
3066
3120
|
"User-Agent": `RevBot.js/${version}`
|
|
3067
3121
|
}
|
|
3068
3122
|
};
|
|
3069
|
-
const response = yield (0,
|
|
3123
|
+
const response = yield (0, import_axios3.default)(config);
|
|
3070
3124
|
return response.data;
|
|
3071
3125
|
} catch (error) {
|
|
3072
3126
|
console.error("API call failed:", error);
|
|
@@ -3135,7 +3189,7 @@ var RestClient = class {
|
|
|
3135
3189
|
};
|
|
3136
3190
|
|
|
3137
3191
|
// src/rest/CDNClient.ts
|
|
3138
|
-
var
|
|
3192
|
+
var import_axios4 = __toESM(require("axios"));
|
|
3139
3193
|
var CDNClient = class {
|
|
3140
3194
|
constructor(client3) {
|
|
3141
3195
|
this.client = client3;
|
|
@@ -3164,7 +3218,7 @@ var CDNClient = class {
|
|
|
3164
3218
|
"User-Agent": `RevBot.js/${version}`
|
|
3165
3219
|
}, data.getHeaders())
|
|
3166
3220
|
};
|
|
3167
|
-
const response = yield (0,
|
|
3221
|
+
const response = yield (0, import_axios4.default)(config);
|
|
3168
3222
|
return response.data;
|
|
3169
3223
|
} catch (error) {
|
|
3170
3224
|
console.error("API call failed:", error);
|
package/dist/index.mjs
CHANGED
|
@@ -1642,6 +1642,10 @@ var Mentions = class {
|
|
|
1642
1642
|
};
|
|
1643
1643
|
|
|
1644
1644
|
// src/struct/messageEmbed.ts
|
|
1645
|
+
import { Readable } from "stream";
|
|
1646
|
+
import axios from "axios";
|
|
1647
|
+
import FormData from "form-data";
|
|
1648
|
+
import { File } from "node:buffer";
|
|
1645
1649
|
var _url, _title, _description, _icon_url, _color, _media;
|
|
1646
1650
|
var MessageEmbed = class {
|
|
1647
1651
|
constructor() {
|
|
@@ -1705,26 +1709,68 @@ var MessageEmbed = class {
|
|
|
1705
1709
|
/**
|
|
1706
1710
|
* Sets the media (e.g., image or video) of the embed.
|
|
1707
1711
|
*
|
|
1708
|
-
* @param {string} media - The media URL to set.
|
|
1712
|
+
* @param {Readable | string | File} media - The media URL, File or Stream to set.
|
|
1709
1713
|
* @returns {this} The updated `MessageEmbed` instance.
|
|
1710
1714
|
*/
|
|
1711
1715
|
setMedia(media) {
|
|
1712
1716
|
__privateSet(this, _media, media);
|
|
1713
1717
|
return this;
|
|
1714
1718
|
}
|
|
1719
|
+
/**
|
|
1720
|
+
*
|
|
1721
|
+
* @param client The client instance used to send the embed.
|
|
1722
|
+
* @returns SendableEmbed
|
|
1723
|
+
* Converts the embed to a JSON object that can be sent to the API, including media handling.
|
|
1724
|
+
*/
|
|
1725
|
+
toJSONWithMedia(client3) {
|
|
1726
|
+
return __async(this, null, function* () {
|
|
1727
|
+
const embed = {
|
|
1728
|
+
title: __privateGet(this, _title),
|
|
1729
|
+
icon_url: __privateGet(this, _icon_url),
|
|
1730
|
+
colour: __privateGet(this, _color),
|
|
1731
|
+
description: __privateGet(this, _description),
|
|
1732
|
+
url: __privateGet(this, _url)
|
|
1733
|
+
};
|
|
1734
|
+
if (__privateGet(this, _media)) {
|
|
1735
|
+
let att = __privateGet(this, _media);
|
|
1736
|
+
const data = new FormData();
|
|
1737
|
+
if (typeof att === "string") {
|
|
1738
|
+
const readableStream = yield axios.get(att, {
|
|
1739
|
+
responseType: "stream"
|
|
1740
|
+
});
|
|
1741
|
+
data.append("file", readableStream.data, {
|
|
1742
|
+
filename: att.split("/").pop()
|
|
1743
|
+
});
|
|
1744
|
+
}
|
|
1745
|
+
if (att instanceof Readable) {
|
|
1746
|
+
data.append("file", att);
|
|
1747
|
+
}
|
|
1748
|
+
if (att instanceof File) {
|
|
1749
|
+
const buffer = Buffer.from(yield att.arrayBuffer());
|
|
1750
|
+
data.append("file", buffer, { filename: att.name });
|
|
1751
|
+
}
|
|
1752
|
+
yield client3.cdn.post("/attachments", data).then((attachment) => {
|
|
1753
|
+
const { id } = attachment;
|
|
1754
|
+
embed.media = id;
|
|
1755
|
+
});
|
|
1756
|
+
}
|
|
1757
|
+
return embed;
|
|
1758
|
+
});
|
|
1759
|
+
}
|
|
1715
1760
|
/**
|
|
1716
1761
|
* Converts the embed to a JSON object that can be sent to the API.
|
|
1717
1762
|
*
|
|
1718
1763
|
* @returns {SendableEmbed} The JSON representation of the embed.
|
|
1719
1764
|
*/
|
|
1720
1765
|
toJSON() {
|
|
1766
|
+
var _a;
|
|
1721
1767
|
return {
|
|
1722
1768
|
title: __privateGet(this, _title),
|
|
1723
|
-
description: __privateGet(this, _description),
|
|
1724
|
-
url: __privateGet(this, _url),
|
|
1725
1769
|
icon_url: __privateGet(this, _icon_url),
|
|
1726
1770
|
colour: __privateGet(this, _color),
|
|
1727
|
-
|
|
1771
|
+
description: __privateGet(this, _description),
|
|
1772
|
+
url: __privateGet(this, _url),
|
|
1773
|
+
media: (_a = __privateGet(this, _media)) == null ? void 0 : _a.toString()
|
|
1728
1774
|
};
|
|
1729
1775
|
}
|
|
1730
1776
|
};
|
|
@@ -2493,10 +2539,10 @@ var UserManager = class extends BaseManager {
|
|
|
2493
2539
|
};
|
|
2494
2540
|
|
|
2495
2541
|
// src/managers/messageManager.ts
|
|
2496
|
-
import { File } from "node:buffer";
|
|
2497
|
-
import { Readable } from "stream";
|
|
2498
|
-
import
|
|
2499
|
-
import
|
|
2542
|
+
import { File as File2 } from "node:buffer";
|
|
2543
|
+
import { Readable as Readable2 } from "stream";
|
|
2544
|
+
import FormData2 from "form-data";
|
|
2545
|
+
import axios2 from "axios";
|
|
2500
2546
|
var MessageManager = class extends BaseManager {
|
|
2501
2547
|
constructor(channel) {
|
|
2502
2548
|
super(channel.client);
|
|
@@ -2516,21 +2562,22 @@ var MessageManager = class extends BaseManager {
|
|
|
2516
2562
|
return __async(this, null, function* () {
|
|
2517
2563
|
if (typeof content === "string") content = { content };
|
|
2518
2564
|
let attachments = [];
|
|
2565
|
+
let embeds = [];
|
|
2519
2566
|
if (Array.isArray(content.attachments)) {
|
|
2520
2567
|
const promises = content.attachments.map((att) => __async(this, null, function* () {
|
|
2521
|
-
const data = new
|
|
2568
|
+
const data = new FormData2();
|
|
2522
2569
|
if (typeof att === "string") {
|
|
2523
|
-
const readableStream = yield
|
|
2570
|
+
const readableStream = yield axios2.get(att, {
|
|
2524
2571
|
responseType: "stream"
|
|
2525
2572
|
});
|
|
2526
2573
|
data.append("file", readableStream.data, {
|
|
2527
2574
|
filename: att.split("/").pop()
|
|
2528
2575
|
});
|
|
2529
2576
|
}
|
|
2530
|
-
if (att instanceof
|
|
2577
|
+
if (att instanceof Readable2) {
|
|
2531
2578
|
data.append("file", att);
|
|
2532
2579
|
}
|
|
2533
|
-
if (att instanceof
|
|
2580
|
+
if (att instanceof File2) {
|
|
2534
2581
|
const buffer = Buffer.from(yield att.arrayBuffer());
|
|
2535
2582
|
data.append("file", buffer, { filename: att.name });
|
|
2536
2583
|
}
|
|
@@ -2541,10 +2588,17 @@ var MessageManager = class extends BaseManager {
|
|
|
2541
2588
|
}));
|
|
2542
2589
|
yield Promise.all(promises);
|
|
2543
2590
|
}
|
|
2591
|
+
if (Array.isArray(content.embeds)) {
|
|
2592
|
+
const promises = content.embeds.map((embed) => __async(this, null, function* () {
|
|
2593
|
+
const json = yield embed.toJSONWithMedia(this.client);
|
|
2594
|
+
embeds.push(json);
|
|
2595
|
+
}));
|
|
2596
|
+
yield Promise.all(promises);
|
|
2597
|
+
}
|
|
2544
2598
|
const resp = yield this.client.api.post(
|
|
2545
2599
|
`/channels/${this.channel.id}/messages`,
|
|
2546
2600
|
{
|
|
2547
|
-
body: __spreadProps(__spreadValues({}, content), { attachments, nonce: UUID.generate() })
|
|
2601
|
+
body: __spreadProps(__spreadValues({}, content), { attachments, embeds, nonce: UUID.generate() })
|
|
2548
2602
|
}
|
|
2549
2603
|
);
|
|
2550
2604
|
return this._add(resp);
|
|
@@ -2961,10 +3015,10 @@ var ServerMemberManager = class extends BaseManager {
|
|
|
2961
3015
|
import { EventEmitter } from "node:events";
|
|
2962
3016
|
|
|
2963
3017
|
// src/rest/restClient.ts
|
|
2964
|
-
import
|
|
3018
|
+
import axios3 from "axios";
|
|
2965
3019
|
|
|
2966
3020
|
// package.json
|
|
2967
|
-
var version = "0.0.
|
|
3021
|
+
var version = "0.0.6";
|
|
2968
3022
|
|
|
2969
3023
|
// src/rest/restClient.ts
|
|
2970
3024
|
var RestClient = class {
|
|
@@ -2993,7 +3047,7 @@ var RestClient = class {
|
|
|
2993
3047
|
"User-Agent": `RevBot.js/${version}`
|
|
2994
3048
|
}
|
|
2995
3049
|
};
|
|
2996
|
-
const response = yield
|
|
3050
|
+
const response = yield axios3(config);
|
|
2997
3051
|
return response.data;
|
|
2998
3052
|
} catch (error) {
|
|
2999
3053
|
console.error("API call failed:", error);
|
|
@@ -3062,7 +3116,7 @@ var RestClient = class {
|
|
|
3062
3116
|
};
|
|
3063
3117
|
|
|
3064
3118
|
// src/rest/CDNClient.ts
|
|
3065
|
-
import
|
|
3119
|
+
import axios4 from "axios";
|
|
3066
3120
|
var CDNClient = class {
|
|
3067
3121
|
constructor(client3) {
|
|
3068
3122
|
this.client = client3;
|
|
@@ -3091,7 +3145,7 @@ var CDNClient = class {
|
|
|
3091
3145
|
"User-Agent": `RevBot.js/${version}`
|
|
3092
3146
|
}, data.getHeaders())
|
|
3093
3147
|
};
|
|
3094
|
-
const response = yield
|
|
3148
|
+
const response = yield axios4(config);
|
|
3095
3149
|
return response.data;
|
|
3096
3150
|
} catch (error) {
|
|
3097
3151
|
console.error("API call failed:", error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "revbot.js",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "A Revolt bot client used to interact with the revolt api for Node.js, written in TypeScript.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
],
|
|
20
20
|
"homepage": "https://jade3375.github.io/revbot.js/",
|
|
21
21
|
"author": "Jade3375",
|
|
22
|
-
"license": "MIT
|
|
22
|
+
"license": "MIT",
|
|
23
23
|
"packageManager": "yarn@4.9.1",
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@mxssfd/typedoc-theme": "^1.1.7",
|