revbot.js 0.0.5 → 0.0.7
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 +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +74 -20
- package/dist/index.mjs +74 -20
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -233,6 +233,8 @@ interface ClientEvents {
|
|
|
233
233
|
interface clientOptions {
|
|
234
234
|
/** Whether to fetch all members of a server. */
|
|
235
235
|
fetchMembers?: boolean;
|
|
236
|
+
/** wether to use X-Session-Token or X-Bot-Token*/
|
|
237
|
+
isBot?: boolean;
|
|
236
238
|
/** Configuration for REST API requests. */
|
|
237
239
|
rest?: {
|
|
238
240
|
/** The timeout for REST requests in milliseconds. */
|
|
@@ -1437,10 +1439,17 @@ declare class MessageEmbed {
|
|
|
1437
1439
|
/**
|
|
1438
1440
|
* Sets the media (e.g., image or video) of the embed.
|
|
1439
1441
|
*
|
|
1440
|
-
* @param {string} media - The media URL to set.
|
|
1442
|
+
* @param {Readable | string | File} media - The media URL, File or Stream to set.
|
|
1441
1443
|
* @returns {this} The updated `MessageEmbed` instance.
|
|
1442
1444
|
*/
|
|
1443
|
-
setMedia(media: string): this;
|
|
1445
|
+
setMedia(media: Readable | string | File$1): this;
|
|
1446
|
+
/**
|
|
1447
|
+
*
|
|
1448
|
+
* @param client The client instance used to send the embed.
|
|
1449
|
+
* @returns SendableEmbed
|
|
1450
|
+
* Converts the embed to a JSON object that can be sent to the API, including media handling.
|
|
1451
|
+
*/
|
|
1452
|
+
toJSONWithMedia(client: client): Promise<SendableEmbed>;
|
|
1444
1453
|
/**
|
|
1445
1454
|
* Converts the embed to a JSON object that can be sent to the API.
|
|
1446
1455
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -233,6 +233,8 @@ interface ClientEvents {
|
|
|
233
233
|
interface clientOptions {
|
|
234
234
|
/** Whether to fetch all members of a server. */
|
|
235
235
|
fetchMembers?: boolean;
|
|
236
|
+
/** wether to use X-Session-Token or X-Bot-Token*/
|
|
237
|
+
isBot?: boolean;
|
|
236
238
|
/** Configuration for REST API requests. */
|
|
237
239
|
rest?: {
|
|
238
240
|
/** The timeout for REST requests in milliseconds. */
|
|
@@ -1437,10 +1439,17 @@ declare class MessageEmbed {
|
|
|
1437
1439
|
/**
|
|
1438
1440
|
* Sets the media (e.g., image or video) of the embed.
|
|
1439
1441
|
*
|
|
1440
|
-
* @param {string} media - The media URL to set.
|
|
1442
|
+
* @param {Readable | string | File} media - The media URL, File or Stream to set.
|
|
1441
1443
|
* @returns {this} The updated `MessageEmbed` instance.
|
|
1442
1444
|
*/
|
|
1443
|
-
setMedia(media: string): this;
|
|
1445
|
+
setMedia(media: Readable | string | File$1): this;
|
|
1446
|
+
/**
|
|
1447
|
+
*
|
|
1448
|
+
* @param client The client instance used to send the embed.
|
|
1449
|
+
* @returns SendableEmbed
|
|
1450
|
+
* Converts the embed to a JSON object that can be sent to the API, including media handling.
|
|
1451
|
+
*/
|
|
1452
|
+
toJSONWithMedia(client: client): Promise<SendableEmbed>;
|
|
1444
1453
|
/**
|
|
1445
1454
|
* Converts the embed to a JSON object that can be sent to the API.
|
|
1446
1455
|
*
|
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);
|
|
@@ -2592,19 +2638,19 @@ var MessageManager = class extends BaseManager {
|
|
|
2592
2638
|
let embeds = [];
|
|
2593
2639
|
if (Array.isArray(content.attachments)) {
|
|
2594
2640
|
const promises = content.attachments.map((att) => __async(this, null, function* () {
|
|
2595
|
-
const data = new
|
|
2641
|
+
const data = new import_form_data2.default();
|
|
2596
2642
|
if (typeof att === "string") {
|
|
2597
|
-
const readableStream = yield
|
|
2643
|
+
const readableStream = yield import_axios2.default.get(att, {
|
|
2598
2644
|
responseType: "stream"
|
|
2599
2645
|
});
|
|
2600
2646
|
data.append("file", readableStream.data, {
|
|
2601
2647
|
filename: att.split("/").pop()
|
|
2602
2648
|
});
|
|
2603
2649
|
}
|
|
2604
|
-
if (att instanceof
|
|
2650
|
+
if (att instanceof import_stream2.Readable) {
|
|
2605
2651
|
data.append("file", att);
|
|
2606
2652
|
}
|
|
2607
|
-
if (att instanceof
|
|
2653
|
+
if (att instanceof import_node_buffer2.File) {
|
|
2608
2654
|
const buffer = Buffer.from(yield att.arrayBuffer());
|
|
2609
2655
|
data.append("file", buffer, { filename: att.name });
|
|
2610
2656
|
}
|
|
@@ -2616,7 +2662,11 @@ var MessageManager = class extends BaseManager {
|
|
|
2616
2662
|
yield Promise.all(promises);
|
|
2617
2663
|
}
|
|
2618
2664
|
if (Array.isArray(content.embeds)) {
|
|
2619
|
-
content.embeds.map((embed) =>
|
|
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);
|
|
2620
2670
|
}
|
|
2621
2671
|
const resp = yield this.client.api.post(
|
|
2622
2672
|
`/channels/${this.channel.id}/messages`,
|
|
@@ -3038,10 +3088,10 @@ var ServerMemberManager = class extends BaseManager {
|
|
|
3038
3088
|
var import_node_events = require("events");
|
|
3039
3089
|
|
|
3040
3090
|
// src/rest/restClient.ts
|
|
3041
|
-
var
|
|
3091
|
+
var import_axios3 = __toESM(require("axios"));
|
|
3042
3092
|
|
|
3043
3093
|
// package.json
|
|
3044
|
-
var version = "0.0.
|
|
3094
|
+
var version = "0.0.7";
|
|
3045
3095
|
|
|
3046
3096
|
// src/rest/restClient.ts
|
|
3047
3097
|
var RestClient = class {
|
|
@@ -3060,17 +3110,18 @@ var RestClient = class {
|
|
|
3060
3110
|
return __async(this, null, function* () {
|
|
3061
3111
|
try {
|
|
3062
3112
|
if (!this.client.token) throw new Error("Token is required");
|
|
3113
|
+
const authHeader = this.client.bot ? "X-Bot-Token" : "X-Session-Token";
|
|
3063
3114
|
const config = {
|
|
3064
3115
|
method,
|
|
3065
3116
|
url: `${apiUrl}${url}`,
|
|
3066
3117
|
params: query,
|
|
3067
3118
|
data: body == null ? void 0 : body.body,
|
|
3068
3119
|
headers: {
|
|
3069
|
-
|
|
3120
|
+
[authHeader]: this.client.token,
|
|
3070
3121
|
"User-Agent": `RevBot.js/${version}`
|
|
3071
3122
|
}
|
|
3072
3123
|
};
|
|
3073
|
-
const response = yield (0,
|
|
3124
|
+
const response = yield (0, import_axios3.default)(config);
|
|
3074
3125
|
return response.data;
|
|
3075
3126
|
} catch (error) {
|
|
3076
3127
|
console.error("API call failed:", error);
|
|
@@ -3139,7 +3190,7 @@ var RestClient = class {
|
|
|
3139
3190
|
};
|
|
3140
3191
|
|
|
3141
3192
|
// src/rest/CDNClient.ts
|
|
3142
|
-
var
|
|
3193
|
+
var import_axios4 = __toESM(require("axios"));
|
|
3143
3194
|
var CDNClient = class {
|
|
3144
3195
|
constructor(client3) {
|
|
3145
3196
|
this.client = client3;
|
|
@@ -3156,6 +3207,7 @@ var CDNClient = class {
|
|
|
3156
3207
|
return __async(this, null, function* () {
|
|
3157
3208
|
try {
|
|
3158
3209
|
if (!this.client.token) throw new Error("Token is required");
|
|
3210
|
+
const authHeader = this.client.bot ? "X-Bot-Token" : "X-Session-Token";
|
|
3159
3211
|
const config = {
|
|
3160
3212
|
method,
|
|
3161
3213
|
url: `${cdnUrl}${url}`,
|
|
@@ -3163,12 +3215,12 @@ var CDNClient = class {
|
|
|
3163
3215
|
data,
|
|
3164
3216
|
maxBodyLength: Infinity,
|
|
3165
3217
|
headers: __spreadValues({
|
|
3166
|
-
|
|
3218
|
+
[authHeader]: this.client.token,
|
|
3167
3219
|
"Content-Type": "multipart/form-data",
|
|
3168
3220
|
"User-Agent": `RevBot.js/${version}`
|
|
3169
3221
|
}, data.getHeaders())
|
|
3170
3222
|
};
|
|
3171
|
-
const response = yield (0,
|
|
3223
|
+
const response = yield (0, import_axios4.default)(config);
|
|
3172
3224
|
return response.data;
|
|
3173
3225
|
} catch (error) {
|
|
3174
3226
|
console.error("API call failed:", error);
|
|
@@ -3199,12 +3251,14 @@ var BaseClient = class extends import_node_events.EventEmitter {
|
|
|
3199
3251
|
* @param {clientOptions} [options={}] - The options for configuring the client.
|
|
3200
3252
|
*/
|
|
3201
3253
|
constructor(options = {}) {
|
|
3254
|
+
var _a;
|
|
3202
3255
|
super();
|
|
3203
3256
|
/** The authentication token for the client. */
|
|
3204
3257
|
__privateAdd(this, _token, null);
|
|
3205
3258
|
/** Whether the client is a bot. */
|
|
3206
3259
|
this.bot = true;
|
|
3207
3260
|
this.options = __spreadValues({}, options);
|
|
3261
|
+
this.bot = (_a = this.options.isBot) != null ? _a : true;
|
|
3208
3262
|
this.api = new RestClient(this);
|
|
3209
3263
|
this.cdn = new CDNClient(this);
|
|
3210
3264
|
}
|
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);
|
|
@@ -2519,19 +2565,19 @@ var MessageManager = class extends BaseManager {
|
|
|
2519
2565
|
let embeds = [];
|
|
2520
2566
|
if (Array.isArray(content.attachments)) {
|
|
2521
2567
|
const promises = content.attachments.map((att) => __async(this, null, function* () {
|
|
2522
|
-
const data = new
|
|
2568
|
+
const data = new FormData2();
|
|
2523
2569
|
if (typeof att === "string") {
|
|
2524
|
-
const readableStream = yield
|
|
2570
|
+
const readableStream = yield axios2.get(att, {
|
|
2525
2571
|
responseType: "stream"
|
|
2526
2572
|
});
|
|
2527
2573
|
data.append("file", readableStream.data, {
|
|
2528
2574
|
filename: att.split("/").pop()
|
|
2529
2575
|
});
|
|
2530
2576
|
}
|
|
2531
|
-
if (att instanceof
|
|
2577
|
+
if (att instanceof Readable2) {
|
|
2532
2578
|
data.append("file", att);
|
|
2533
2579
|
}
|
|
2534
|
-
if (att instanceof
|
|
2580
|
+
if (att instanceof File2) {
|
|
2535
2581
|
const buffer = Buffer.from(yield att.arrayBuffer());
|
|
2536
2582
|
data.append("file", buffer, { filename: att.name });
|
|
2537
2583
|
}
|
|
@@ -2543,7 +2589,11 @@ var MessageManager = class extends BaseManager {
|
|
|
2543
2589
|
yield Promise.all(promises);
|
|
2544
2590
|
}
|
|
2545
2591
|
if (Array.isArray(content.embeds)) {
|
|
2546
|
-
content.embeds.map((embed) =>
|
|
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);
|
|
2547
2597
|
}
|
|
2548
2598
|
const resp = yield this.client.api.post(
|
|
2549
2599
|
`/channels/${this.channel.id}/messages`,
|
|
@@ -2965,10 +3015,10 @@ var ServerMemberManager = class extends BaseManager {
|
|
|
2965
3015
|
import { EventEmitter } from "node:events";
|
|
2966
3016
|
|
|
2967
3017
|
// src/rest/restClient.ts
|
|
2968
|
-
import
|
|
3018
|
+
import axios3 from "axios";
|
|
2969
3019
|
|
|
2970
3020
|
// package.json
|
|
2971
|
-
var version = "0.0.
|
|
3021
|
+
var version = "0.0.7";
|
|
2972
3022
|
|
|
2973
3023
|
// src/rest/restClient.ts
|
|
2974
3024
|
var RestClient = class {
|
|
@@ -2987,17 +3037,18 @@ var RestClient = class {
|
|
|
2987
3037
|
return __async(this, null, function* () {
|
|
2988
3038
|
try {
|
|
2989
3039
|
if (!this.client.token) throw new Error("Token is required");
|
|
3040
|
+
const authHeader = this.client.bot ? "X-Bot-Token" : "X-Session-Token";
|
|
2990
3041
|
const config = {
|
|
2991
3042
|
method,
|
|
2992
3043
|
url: `${apiUrl}${url}`,
|
|
2993
3044
|
params: query,
|
|
2994
3045
|
data: body == null ? void 0 : body.body,
|
|
2995
3046
|
headers: {
|
|
2996
|
-
|
|
3047
|
+
[authHeader]: this.client.token,
|
|
2997
3048
|
"User-Agent": `RevBot.js/${version}`
|
|
2998
3049
|
}
|
|
2999
3050
|
};
|
|
3000
|
-
const response = yield
|
|
3051
|
+
const response = yield axios3(config);
|
|
3001
3052
|
return response.data;
|
|
3002
3053
|
} catch (error) {
|
|
3003
3054
|
console.error("API call failed:", error);
|
|
@@ -3066,7 +3117,7 @@ var RestClient = class {
|
|
|
3066
3117
|
};
|
|
3067
3118
|
|
|
3068
3119
|
// src/rest/CDNClient.ts
|
|
3069
|
-
import
|
|
3120
|
+
import axios4 from "axios";
|
|
3070
3121
|
var CDNClient = class {
|
|
3071
3122
|
constructor(client3) {
|
|
3072
3123
|
this.client = client3;
|
|
@@ -3083,6 +3134,7 @@ var CDNClient = class {
|
|
|
3083
3134
|
return __async(this, null, function* () {
|
|
3084
3135
|
try {
|
|
3085
3136
|
if (!this.client.token) throw new Error("Token is required");
|
|
3137
|
+
const authHeader = this.client.bot ? "X-Bot-Token" : "X-Session-Token";
|
|
3086
3138
|
const config = {
|
|
3087
3139
|
method,
|
|
3088
3140
|
url: `${cdnUrl}${url}`,
|
|
@@ -3090,12 +3142,12 @@ var CDNClient = class {
|
|
|
3090
3142
|
data,
|
|
3091
3143
|
maxBodyLength: Infinity,
|
|
3092
3144
|
headers: __spreadValues({
|
|
3093
|
-
|
|
3145
|
+
[authHeader]: this.client.token,
|
|
3094
3146
|
"Content-Type": "multipart/form-data",
|
|
3095
3147
|
"User-Agent": `RevBot.js/${version}`
|
|
3096
3148
|
}, data.getHeaders())
|
|
3097
3149
|
};
|
|
3098
|
-
const response = yield
|
|
3150
|
+
const response = yield axios4(config);
|
|
3099
3151
|
return response.data;
|
|
3100
3152
|
} catch (error) {
|
|
3101
3153
|
console.error("API call failed:", error);
|
|
@@ -3126,12 +3178,14 @@ var BaseClient = class extends EventEmitter {
|
|
|
3126
3178
|
* @param {clientOptions} [options={}] - The options for configuring the client.
|
|
3127
3179
|
*/
|
|
3128
3180
|
constructor(options = {}) {
|
|
3181
|
+
var _a;
|
|
3129
3182
|
super();
|
|
3130
3183
|
/** The authentication token for the client. */
|
|
3131
3184
|
__privateAdd(this, _token, null);
|
|
3132
3185
|
/** Whether the client is a bot. */
|
|
3133
3186
|
this.bot = true;
|
|
3134
3187
|
this.options = __spreadValues({}, options);
|
|
3188
|
+
this.bot = (_a = this.options.isBot) != null ? _a : true;
|
|
3135
3189
|
this.api = new RestClient(this);
|
|
3136
3190
|
this.cdn = new CDNClient(this);
|
|
3137
3191
|
}
|
package/package.json
CHANGED