revbot.js 0.2.4 → 0.2.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.js CHANGED
@@ -468,6 +468,9 @@ var Events = /* @__PURE__ */ ((Events2) => {
468
468
  Events2["TYPING_START"] = "typingStart";
469
469
  Events2["TYPING_STOP"] = "typingStop";
470
470
  Events2["USER_UPDATE"] = "userUpdate";
471
+ Events2["WEBHOOKS_CREATE"] = "webhookCreate";
472
+ Events2["WEBHOOKS_DELETE"] = "webhookDelete";
473
+ Events2["WEBHOOKS_UPDATE"] = "webhookUpdate";
471
474
  return Events2;
472
475
  })(Events || {});
473
476
  var WSEvents = /* @__PURE__ */ ((WSEvents2) => {
@@ -501,6 +504,9 @@ var WSEvents = /* @__PURE__ */ ((WSEvents2) => {
501
504
  WSEvents2["SERVER_UPDATE"] = "ServerUpdate";
502
505
  WSEvents2["USER_RELATIONSHIP"] = "UserRelationship";
503
506
  WSEvents2["USER_UPDATE"] = "UserUpdate";
507
+ WSEvents2["WEBHOOKS_CREATE"] = "WebhooksCreate";
508
+ WSEvents2["WEBHOOKS_DELETE"] = "WebhooksDelete";
509
+ WSEvents2["WEBHOOKS_UPDATE"] = "WebhooksUpdate";
504
510
  return WSEvents2;
505
511
  })(WSEvents || {});
506
512
  var ChannelTypes = /* @__PURE__ */ ((ChannelTypes2) => {
@@ -1472,6 +1478,237 @@ var Channel = class extends Base {
1472
1478
  fetch(force = true) {
1473
1479
  return this.client.channels.fetch(this, { force });
1474
1480
  }
1481
+ edit(data) {
1482
+ return __async(this, null, function* () {
1483
+ const id = this.id;
1484
+ if (!id) {
1485
+ throw new TypeError("INVALID_ID");
1486
+ }
1487
+ const response = yield this.client.api.patch(`/channels/${id}`, {
1488
+ body: data
1489
+ });
1490
+ return response;
1491
+ });
1492
+ }
1493
+ // Implementation
1494
+ setRolePermissions(roleId, allowOrOptions, deny) {
1495
+ return __async(this, null, function* () {
1496
+ const id = this.id;
1497
+ if (!id) {
1498
+ throw new TypeError("INVALID_ID");
1499
+ }
1500
+ let allow;
1501
+ let denyPermissions;
1502
+ if (Array.isArray(allowOrOptions)) {
1503
+ allow = allowOrOptions;
1504
+ denyPermissions = deny;
1505
+ } else if (allowOrOptions && typeof allowOrOptions === "object") {
1506
+ allow = allowOrOptions.allow;
1507
+ denyPermissions = allowOrOptions.deny;
1508
+ if (allow === void 0 && denyPermissions === void 0) {
1509
+ throw new TypeError(
1510
+ "At least one of 'allow' or 'deny' must be provided in options"
1511
+ );
1512
+ }
1513
+ } else {
1514
+ throw new TypeError("Invalid arguments provided");
1515
+ }
1516
+ const requestBody = {
1517
+ allow: 0,
1518
+ deny: 0
1519
+ };
1520
+ if (allow !== void 0) {
1521
+ requestBody.allow = new FullPermissions(allow).bitfield;
1522
+ }
1523
+ if (denyPermissions !== void 0) {
1524
+ requestBody.deny = new FullPermissions(denyPermissions).bitfield;
1525
+ }
1526
+ yield this.client.api.put(`/channels/${id}/permissions/${roleId}`, {
1527
+ body: { permissions: requestBody }
1528
+ });
1529
+ });
1530
+ }
1531
+ // Implementation
1532
+ setDefaultPermissions(allowOrOptionsOrPermissions) {
1533
+ return __async(this, null, function* () {
1534
+ const id = this.id;
1535
+ if (!id) {
1536
+ throw new TypeError("INVALID_ID");
1537
+ }
1538
+ let allow;
1539
+ let deny;
1540
+ if (Array.isArray(allowOrOptionsOrPermissions)) {
1541
+ allow = allowOrOptionsOrPermissions;
1542
+ } else if (allowOrOptionsOrPermissions && typeof allowOrOptionsOrPermissions === "object") {
1543
+ if ("a" in allowOrOptionsOrPermissions || "d" in allowOrOptionsOrPermissions) {
1544
+ const legacyPerms = allowOrOptionsOrPermissions;
1545
+ allow = legacyPerms.a;
1546
+ deny = legacyPerms.d;
1547
+ } else {
1548
+ const options = allowOrOptionsOrPermissions;
1549
+ allow = options.allow;
1550
+ deny = options.deny;
1551
+ if (allow === void 0 && deny === void 0) {
1552
+ throw new TypeError(
1553
+ "At least one of 'allow' or 'deny' must be provided in options"
1554
+ );
1555
+ }
1556
+ }
1557
+ } else {
1558
+ throw new TypeError("Invalid arguments provided");
1559
+ }
1560
+ const requestBody = {};
1561
+ if (allow !== void 0) {
1562
+ requestBody.allow = new FullPermissions(allow).bitfield;
1563
+ }
1564
+ if (deny !== void 0) {
1565
+ requestBody.deny = new FullPermissions(deny).bitfield;
1566
+ }
1567
+ if (requestBody.allow === void 0) {
1568
+ requestBody.allow = 0;
1569
+ }
1570
+ if (requestBody.deny === void 0) {
1571
+ requestBody.deny = 0;
1572
+ }
1573
+ yield this.client.api.put(`/channels/${id}/permissions/default`, {
1574
+ body: { permissions: requestBody }
1575
+ });
1576
+ });
1577
+ }
1578
+ /**
1579
+ * Creates a new webhook in this channel.
1580
+ *
1581
+ * @param name - The name of the webhook
1582
+ * @param avatar - Optional avatar for the webhook. Can be a URL string, Readable stream, or File object
1583
+ * @returns Promise resolving to the created webhook response
1584
+ *
1585
+ * @example
1586
+ * ```typescript
1587
+ * const webhook = await channel.createWebhook("My Webhook", "https://example.com/avatar.png");
1588
+ * ```
1589
+ */
1590
+ createWebhook(name, avatar) {
1591
+ return __async(this, null, function* () {
1592
+ return this.client.webhooks.create(this.id, name, avatar);
1593
+ });
1594
+ }
1595
+ /**
1596
+ * Retrieves all webhooks for this channel.
1597
+ *
1598
+ * @returns Promise resolving to an array of webhook responses
1599
+ *
1600
+ * @example
1601
+ * ```typescript
1602
+ * const webhooks = await channel.getWebhooks();
1603
+ * console.log(`Found ${webhooks.length} webhooks`);
1604
+ * ```
1605
+ */
1606
+ getWebhooks() {
1607
+ return __async(this, null, function* () {
1608
+ return this.client.webhooks.getAll(this.id);
1609
+ });
1610
+ }
1611
+ /**
1612
+ * Retrieves a specific webhook by ID and token.
1613
+ *
1614
+ * @param webhookId - The ID of the webhook to retrieve
1615
+ * @param token - The token of the webhook
1616
+ * @returns Promise resolving to the webhook response
1617
+ *
1618
+ * @example
1619
+ * ```typescript
1620
+ * const webhook = await channel.getWebhook("webhookId", "webhookToken");
1621
+ * console.log(`Webhook name: ${webhook.name}`);
1622
+ * ```
1623
+ */
1624
+ getWebhook(webhookId, token) {
1625
+ return __async(this, null, function* () {
1626
+ return this.client.webhooks.get(webhookId, token);
1627
+ });
1628
+ }
1629
+ /**
1630
+ * Sends a message through a webhook in this channel.
1631
+ *
1632
+ * @param webhookId - The ID of the webhook to send the message through
1633
+ * @param token - The token of the webhook
1634
+ * @param content - The message content. Can be a string or MessageOptions object with attachments and embeds
1635
+ * @returns Promise resolving to the sent message
1636
+ *
1637
+ * @example
1638
+ * ```typescript
1639
+ * // Send a simple text message
1640
+ * await channel.sendWebhookMessage("webhookId", "token", "Hello, world!");
1641
+ *
1642
+ * // Send a message with embeds and attachments
1643
+ * await channel.sendWebhookMessage("webhookId", "token", {
1644
+ * content: "Check out this image!",
1645
+ * attachments: ["https://example.com/image.png"],
1646
+ * embeds: [myEmbed]
1647
+ * });
1648
+ * ```
1649
+ */
1650
+ sendWebhookMessage(webhookId, token, content) {
1651
+ return __async(this, null, function* () {
1652
+ return this.client.webhooks.send(webhookId, token, content);
1653
+ });
1654
+ }
1655
+ /**
1656
+ * Deletes a webhook.
1657
+ *
1658
+ * @param webhookId - The ID of the webhook to delete
1659
+ * @param token - The token of the webhook
1660
+ * @returns Promise that resolves when the webhook is deleted
1661
+ *
1662
+ * @example
1663
+ * ```typescript
1664
+ * await channel.deleteWebhook("webhookId", "webhookToken");
1665
+ * console.log("Webhook deleted successfully");
1666
+ * ```
1667
+ */
1668
+ deleteWebhook(webhookId, token) {
1669
+ return __async(this, null, function* () {
1670
+ return this.client.webhooks.delete(webhookId, token);
1671
+ });
1672
+ }
1673
+ /**
1674
+ * Edits a webhook's properties.
1675
+ *
1676
+ * @param webhookId - The ID of the webhook to edit
1677
+ * @param token - The token of the webhook
1678
+ * @param options - The options to edit on the webhook
1679
+ * @returns Promise resolving to the updated webhook response
1680
+ *
1681
+ * @example
1682
+ * ```typescript
1683
+ * const updatedWebhook = await channel.editWebhook("webhookId", "token", {
1684
+ * name: "New Webhook Name",
1685
+ * avatar: "https://example.com/new-avatar.png"
1686
+ * });
1687
+ * ```
1688
+ */
1689
+ editWebhook(webhookId, token, options) {
1690
+ return __async(this, null, function* () {
1691
+ return this.client.webhooks.edit(webhookId, token, options);
1692
+ });
1693
+ }
1694
+ /**
1695
+ * Retrieves partial information about a webhook using only its ID.
1696
+ * This method provides limited webhook information without requiring a token.
1697
+ *
1698
+ * @param webhookId - The ID of the webhook to retrieve partial information for
1699
+ * @returns Promise resolving to the webhook response with partial information
1700
+ *
1701
+ * @example
1702
+ * ```typescript
1703
+ * const partialWebhook = await channel.getPartialWebhook("webhookId");
1704
+ * console.log(`Webhook name: ${partialWebhook.name}`);
1705
+ * ```
1706
+ */
1707
+ getPartialWebhook(webhookId) {
1708
+ return __async(this, null, function* () {
1709
+ return this.client.webhooks.getPartial(webhookId);
1710
+ });
1711
+ }
1475
1712
  };
1476
1713
 
1477
1714
  // src/struct/dmChannel.ts
@@ -3027,9 +3264,14 @@ var MessageManager = class extends BaseManager {
3027
3264
  }
3028
3265
  if (typeof query === "number") query = { limit: query };
3029
3266
  else if (typeof query === "undefined") query = { limit: 100 };
3267
+ const queryObj = Object.fromEntries(
3268
+ Object.entries(query).filter(
3269
+ ([, v]) => v !== void 0
3270
+ )
3271
+ );
3030
3272
  const messages = yield this.client.api.get(
3031
3273
  `/channels/${this.channel.id}/messages`,
3032
- { query: JSON.stringify(query) }
3274
+ queryObj
3033
3275
  );
3034
3276
  return messages.reduce((coll, cur) => {
3035
3277
  const msg = this._add(cur);
@@ -3369,17 +3611,283 @@ var ServerMemberManager = class extends BaseManager {
3369
3611
  }
3370
3612
  };
3371
3613
 
3614
+ // src/managers/webhookManager.ts
3615
+ var import_stream3 = require("stream");
3616
+ var import_axios3 = __toESM(require("axios"));
3617
+ var import_form_data3 = __toESM(require("form-data"));
3618
+ var WebhookManager = class {
3619
+ /**
3620
+ * Creates a new WebhookManager instance.
3621
+ *
3622
+ * @param client - The client instance this manager belongs to
3623
+ */
3624
+ constructor(client3) {
3625
+ this.client = client3;
3626
+ }
3627
+ /**
3628
+ * Creates a new webhook in the specified channel.
3629
+ *
3630
+ * @param channelId - The ID of the channel where the webhook will be created
3631
+ * @param name - The name of the webhook
3632
+ * @param avatar - Optional avatar for the webhook. Can be a URL string, Readable stream, or File object
3633
+ * @returns Promise resolving to the created webhook response
3634
+ *
3635
+ * @example
3636
+ * ```typescript
3637
+ * const webhook = await client.webhooks.create("channelId", "My Webhook", "https://example.com/avatar.png");
3638
+ * ```
3639
+ */
3640
+ create(channelId, name, avatar) {
3641
+ return __async(this, null, function* () {
3642
+ const data = new import_form_data3.default();
3643
+ let avatarID = void 0;
3644
+ if (typeof avatar === "string") {
3645
+ const readableStream = yield import_axios3.default.get(avatar, {
3646
+ responseType: "stream"
3647
+ });
3648
+ data.append("file", readableStream.data, {
3649
+ filename: avatar.split("/").pop()
3650
+ });
3651
+ }
3652
+ if (avatar instanceof import_stream3.Readable) {
3653
+ data.append("file", avatar, { filename: "avatar.png" });
3654
+ }
3655
+ if (avatar instanceof File) {
3656
+ const buffer = Buffer.from(yield avatar.arrayBuffer());
3657
+ data.append("file", buffer, { filename: avatar.name });
3658
+ }
3659
+ if (avatar) {
3660
+ yield this.client.cdn.post("/avatars", data).then((attachment) => {
3661
+ const { id } = attachment;
3662
+ avatarID = id;
3663
+ });
3664
+ }
3665
+ const response = yield this.client.api.post(
3666
+ `/channels/${channelId}/webhooks`,
3667
+ {
3668
+ body: {
3669
+ name,
3670
+ avatar: avatarID
3671
+ }
3672
+ }
3673
+ );
3674
+ return response;
3675
+ });
3676
+ }
3677
+ /**
3678
+ * Retrieves all webhooks for the specified channel.
3679
+ *
3680
+ * @param channelId - The ID of the channel to get webhooks from
3681
+ * @returns Promise resolving to an array of webhook responses
3682
+ *
3683
+ * @example
3684
+ * ```typescript
3685
+ * const webhooks = await client.webhooks.getAll("channelId");
3686
+ * console.log(`Found ${webhooks.length} webhooks`);
3687
+ * ```
3688
+ */
3689
+ getAll(channelId) {
3690
+ return __async(this, null, function* () {
3691
+ const response = yield this.client.api.get(
3692
+ `/channels/${channelId}/webhooks`
3693
+ );
3694
+ return response;
3695
+ });
3696
+ }
3697
+ /**
3698
+ * Retrieves a specific webhook by ID and token.
3699
+ *
3700
+ * @param webhookId - The ID of the webhook to retrieve
3701
+ * @param token - The token of the webhook
3702
+ * @returns Promise resolving to the webhook response
3703
+ *
3704
+ * @example
3705
+ * ```typescript
3706
+ * const webhook = await client.webhooks.get("webhookId", "webhookToken");
3707
+ * console.log(`Webhook name: ${webhook.name}`);
3708
+ * ```
3709
+ */
3710
+ get(webhookId, token) {
3711
+ return __async(this, null, function* () {
3712
+ const response = yield this.client.api.get(
3713
+ `/webhooks/${webhookId}/${token}`
3714
+ );
3715
+ return response;
3716
+ });
3717
+ }
3718
+ /**
3719
+ * Sends a message through a webhook.
3720
+ *
3721
+ * @param webhookId - The ID of the webhook to send the message through
3722
+ * @param token - The token of the webhook
3723
+ * @param content - The message content. Can be a string or MessageOptions object with attachments and embeds
3724
+ * @returns Promise resolving to the sent message
3725
+ *
3726
+ * @example
3727
+ * ```typescript
3728
+ * // Send a simple text message
3729
+ * await client.webhooks.send("webhookId", "token", "Hello, world!");
3730
+ *
3731
+ * // Send a message with embeds and attachments
3732
+ * await client.webhooks.send("webhookId", "token", {
3733
+ * content: "Check out this image!",
3734
+ * attachments: ["https://example.com/image.png"],
3735
+ * embeds: [myEmbed]
3736
+ * });
3737
+ * ```
3738
+ */
3739
+ send(webhookId, token, content) {
3740
+ return __async(this, null, function* () {
3741
+ if (typeof content === "string") content = { content };
3742
+ let attachments = [];
3743
+ let embeds = [];
3744
+ if (Array.isArray(content.attachments)) {
3745
+ const promises = content.attachments.map((att) => __async(this, null, function* () {
3746
+ const data = new import_form_data3.default();
3747
+ if (typeof att === "string") {
3748
+ const readableStream = yield import_axios3.default.get(att, {
3749
+ responseType: "stream"
3750
+ });
3751
+ data.append("file", readableStream.data, {
3752
+ filename: att.split("/").pop()
3753
+ });
3754
+ }
3755
+ if (att instanceof import_stream3.Readable) {
3756
+ data.append("file", att);
3757
+ }
3758
+ if (att instanceof File) {
3759
+ const buffer = Buffer.from(yield att.arrayBuffer());
3760
+ data.append("file", buffer, { filename: att.name });
3761
+ }
3762
+ yield this.client.cdn.post("/attachments", data).then((attachment) => {
3763
+ const { id } = attachment;
3764
+ attachments.push(id);
3765
+ });
3766
+ }));
3767
+ yield Promise.all(promises);
3768
+ }
3769
+ if (Array.isArray(content.embeds)) {
3770
+ const promises = content.embeds.map((embed) => __async(this, null, function* () {
3771
+ const json = yield embed.toJSONWithMedia(this.client);
3772
+ embeds.push(json);
3773
+ }));
3774
+ yield Promise.all(promises);
3775
+ }
3776
+ const resp = yield this.client.api.post(
3777
+ `/webhooks/${webhookId}/${token}`,
3778
+ {
3779
+ body: __spreadProps(__spreadValues({}, content), { attachments, embeds, nonce: UUID.generate() })
3780
+ }
3781
+ );
3782
+ return resp;
3783
+ });
3784
+ }
3785
+ /**
3786
+ * Deletes a webhook.
3787
+ *
3788
+ * @param webhookId - The ID of the webhook to delete
3789
+ * @param token - The token of the webhook
3790
+ * @returns Promise that resolves when the webhook is deleted
3791
+ *
3792
+ * @example
3793
+ * ```typescript
3794
+ * await client.webhooks.delete("webhookId", "webhookToken");
3795
+ * console.log("Webhook deleted successfully");
3796
+ * ```
3797
+ */
3798
+ delete(webhookId, token) {
3799
+ return __async(this, null, function* () {
3800
+ yield this.client.api.delete(`/webhooks/${webhookId}/${token}`);
3801
+ });
3802
+ }
3803
+ /**
3804
+ * Edits a webhook's properties.
3805
+ *
3806
+ * @param webhookId - The ID of the webhook to edit
3807
+ * @param token - The token of the webhook
3808
+ * @param options - The options to edit on the webhook
3809
+ * @returns Promise resolving to the updated webhook response
3810
+ *
3811
+ * @example
3812
+ * ```typescript
3813
+ * const updatedWebhook = await client.webhooks.edit("webhookId", "token", {
3814
+ * name: "New Webhook Name",
3815
+ * avatar: "https://example.com/new-avatar.png"
3816
+ * });
3817
+ * ```
3818
+ */
3819
+ edit(webhookId, token, options) {
3820
+ return __async(this, null, function* () {
3821
+ var _a;
3822
+ const data = new import_form_data3.default();
3823
+ let avatarID = void 0;
3824
+ if (typeof options.avatar === "string") {
3825
+ const readableStream = yield import_axios3.default.get(options.avatar, {
3826
+ responseType: "stream"
3827
+ });
3828
+ data.append("file", readableStream.data, {
3829
+ filename: options.avatar.split("/").pop()
3830
+ });
3831
+ }
3832
+ if (options.avatar instanceof import_stream3.Readable) {
3833
+ data.append("file", options.avatar, { filename: "avatar.png" });
3834
+ }
3835
+ if (options.avatar instanceof File) {
3836
+ const buffer = Buffer.from(yield options.avatar.arrayBuffer());
3837
+ data.append("file", buffer, { filename: options.avatar.name });
3838
+ }
3839
+ if (options.avatar) {
3840
+ yield this.client.cdn.post("/avatars", data).then((attachment) => {
3841
+ const { id } = attachment;
3842
+ avatarID = id;
3843
+ });
3844
+ }
3845
+ const response = yield this.client.api.patch(
3846
+ `/webhooks/${webhookId}/${token}`,
3847
+ {
3848
+ body: __spreadProps(__spreadValues({}, options), {
3849
+ avatar: avatarID,
3850
+ remove: (_a = options.remove) != null ? _a : []
3851
+ })
3852
+ }
3853
+ );
3854
+ return response;
3855
+ });
3856
+ }
3857
+ /**
3858
+ * Retrieves partial information about a webhook using only its ID.
3859
+ * This method provides limited webhook information without requiring a token.
3860
+ *
3861
+ * @param webhookId - The ID of the webhook to retrieve partial information for
3862
+ * @returns Promise resolving to the webhook response with partial information
3863
+ *
3864
+ * @example
3865
+ * ```typescript
3866
+ * const partialWebhook = await client.webhooks.getPartial("webhookId");
3867
+ * console.log(`Webhook name: ${partialWebhook.name}`);
3868
+ * ```
3869
+ */
3870
+ getPartial(webhookId) {
3871
+ return __async(this, null, function* () {
3872
+ const response = yield this.client.api.get(
3873
+ `/webhooks/${webhookId}`
3874
+ );
3875
+ return response;
3876
+ });
3877
+ }
3878
+ };
3879
+
3372
3880
  // src/client/baseClient.ts
3373
3881
  var import_node_events = require("events");
3374
3882
 
3375
3883
  // src/rest/restClient.ts
3376
- var import_axios4 = __toESM(require("axios"));
3884
+ var import_axios5 = __toESM(require("axios"));
3377
3885
 
3378
3886
  // package.json
3379
- var version = "0.2.4";
3887
+ var version = "0.2.6";
3380
3888
 
3381
3889
  // src/rest/restUtils/rateLimitQueue.ts
3382
- var import_axios3 = __toESM(require("axios"));
3890
+ var import_axios4 = __toESM(require("axios"));
3383
3891
  var RateLimitQueue = class {
3384
3892
  constructor() {
3385
3893
  this.bucketMap = /* @__PURE__ */ new Map();
@@ -3408,7 +3916,7 @@ var RateLimitQueue = class {
3408
3916
  }
3409
3917
  _doRequest(config, path) {
3410
3918
  return __async(this, null, function* () {
3411
- const response = yield (0, import_axios3.default)(config);
3919
+ const response = yield (0, import_axios4.default)(config);
3412
3920
  this._updateRateLimit(path, response);
3413
3921
  return response;
3414
3922
  });
@@ -3474,7 +3982,7 @@ var RestClient = class {
3474
3982
  */
3475
3983
  request(method, url, body, query, retry) {
3476
3984
  return __async(this, null, function* () {
3477
- var _a, _b, _c, _d, _e;
3985
+ var _a, _b, _c, _d, _e, _f;
3478
3986
  try {
3479
3987
  if (!this.client.token) throw new Error("Token is required");
3480
3988
  const authHeader = this.client.bot ? "X-Bot-Token" : "X-Session-Token";
@@ -3494,13 +4002,20 @@ var RestClient = class {
3494
4002
  return response.data;
3495
4003
  } catch (error) {
3496
4004
  if (retry) throw typeof error;
3497
- if (error instanceof import_axios4.AxiosError) {
4005
+ if (error instanceof import_axios5.AxiosError) {
3498
4006
  if (error.status && (error.status === 429 || error.status >= 500)) {
3499
4007
  return this.retryRequest(0, method, url, body, query);
3500
4008
  }
3501
4009
  if (error.status) {
4010
+ if (process.env.NODE_ENV === "test") {
4011
+ console.error("Error details:", error);
4012
+ console.error("Error response data:", (_e = error.response) == null ? void 0 : _e.data);
4013
+ console.error("Error request config:", error.config);
4014
+ console.error("Error message:", error.message);
4015
+ console.error("Error URL:", url);
4016
+ }
3502
4017
  throw new Error(
3503
- `API call failed with status ${error.status}: ${(_e = error.response) == null ? void 0 : _e.statusText}`
4018
+ `API call failed with status ${error.status}: ${(_f = error.response) == null ? void 0 : _f.statusText}`
3504
4019
  );
3505
4020
  }
3506
4021
  }
@@ -3514,7 +4029,7 @@ var RestClient = class {
3514
4029
  return __async(this, null, function* () {
3515
4030
  var _a, _b;
3516
4031
  try {
3517
- const response = yield import_axios4.default.get(
4032
+ const response = yield import_axios5.default.get(
3518
4033
  `${((_a = this.client.options.rest) == null ? void 0 : _a.instanceURL) ? (_b = this.client.options.rest) == null ? void 0 : _b.instanceURL : apiUrl}/`
3519
4034
  );
3520
4035
  const config = response.data;
@@ -3614,7 +4129,7 @@ var RestClient = class {
3614
4129
  };
3615
4130
 
3616
4131
  // src/rest/CDNClient.ts
3617
- var import_axios5 = require("axios");
4132
+ var import_axios6 = require("axios");
3618
4133
  var CDNClient = class {
3619
4134
  constructor(client3) {
3620
4135
  this.client = client3;
@@ -3652,7 +4167,7 @@ var CDNClient = class {
3652
4167
  return response.data;
3653
4168
  } catch (error) {
3654
4169
  if (retry) throw typeof error;
3655
- if (error instanceof import_axios5.AxiosError) {
4170
+ if (error instanceof import_axios6.AxiosError) {
3656
4171
  if (error.status && (error.status === 429 || error.status >= 500)) {
3657
4172
  return this.retryRequest(0, method, url, data, query);
3658
4173
  }
@@ -4264,6 +4779,58 @@ var MessageUnreact = class extends Event {
4264
4779
  }
4265
4780
  };
4266
4781
 
4782
+ // src/client/events/webhookCreate.ts
4783
+ var WebhookCreate = class extends Event {
4784
+ /**
4785
+ * Handles the webhook create event.
4786
+ * @param {id: string, channel_id: string, server_id: string, name: string} data - The data for the event, containing the webhook ID, channel ID, server ID, and name.
4787
+ * @returns {void}
4788
+ */
4789
+ handle(data) {
4790
+ const webhookData = {
4791
+ webhookId: data.id,
4792
+ channelId: data.channel_id,
4793
+ name: data.name,
4794
+ creatorId: data.creator_id,
4795
+ token: data.token
4796
+ };
4797
+ this.client.emit("webhookCreate" /* WEBHOOKS_CREATE */, webhookData);
4798
+ }
4799
+ };
4800
+
4801
+ // src/client/events/webhookDelete.ts
4802
+ var WebhookDelete = class extends Event {
4803
+ /**
4804
+ * Handles the webhook delete event.
4805
+ * @param {id: string, channel_id: string, server_id: string} data - The data for the event, containing the webhook ID, channel ID, and server ID.
4806
+ * @returns {void}
4807
+ */
4808
+ handle(data) {
4809
+ const webhookData = {
4810
+ webhookId: data.id
4811
+ };
4812
+ this.client.emit("webhookDelete" /* WEBHOOKS_DELETE */, webhookData);
4813
+ }
4814
+ };
4815
+
4816
+ // src/client/events/webhookUpdate.ts
4817
+ var WebhookUpdate = class extends Event {
4818
+ /**
4819
+ * Handles the webhook update event.
4820
+ * @param {id: string, data: { name: string; avatar?: { _id: string; tag: string; filename: string; metadata: any; content_type: string; size: number; }; remove: string[]; }} data- The data for the event, containing the webhook ID and updated webhook data.
4821
+ * @returns {void}
4822
+ */
4823
+ handle(data) {
4824
+ const webhookData = {
4825
+ webhookId: data.id,
4826
+ name: data.data.name,
4827
+ avatar: data.data.avatar,
4828
+ remove: data.data.remove
4829
+ };
4830
+ this.client.emit("webhookUpdate" /* WEBHOOKS_UPDATE */, webhookData);
4831
+ }
4832
+ };
4833
+
4267
4834
  // src/client/events/index.ts
4268
4835
  var EventMap = {
4269
4836
  bulkMessageDelete: BulkMessageDelete,
@@ -4287,7 +4854,10 @@ var EventMap = {
4287
4854
  serverUpdate: ServerUpdate,
4288
4855
  userUpdate: UserUpdate,
4289
4856
  messageReact: MessageReact,
4290
- messageUnreact: MessageUnreact
4857
+ messageUnreact: MessageUnreact,
4858
+ webhookCreate: WebhookCreate,
4859
+ webhookDelete: WebhookDelete,
4860
+ webhookUpdate: WebhookUpdate
4291
4861
  };
4292
4862
 
4293
4863
  // src/client/events/eventManager.ts
@@ -4679,6 +5249,8 @@ var client2 = class extends BaseClient {
4679
5249
  this.users = new UserManager(this);
4680
5250
  /** Manages the events in the client. */
4681
5251
  this.events = new EventManager(this);
5252
+ /** Manages the webhooks in the client. */
5253
+ this.webhooks = new WebhookManager(this);
4682
5254
  /** The authenticated user, or `null` if not logged in. */
4683
5255
  this.user = null;
4684
5256
  /** The timestamp when the client became ready, or `null` if not ready. */