@stoatx/client 0.6.2 → 0.6.4

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.cts CHANGED
@@ -1933,7 +1933,10 @@ interface MessageOptions {
1933
1933
  content?: string;
1934
1934
  embeds?: (TextEmbedData | EmbedBuilder)[];
1935
1935
  attachments?: string[] | AttachmentBuilder[];
1936
- interactions?: any[];
1936
+ interactions?: {
1937
+ reactions?: string[] | null;
1938
+ restrict_reactions?: boolean;
1939
+ };
1937
1940
  flags?: number;
1938
1941
  masquerade?: Masquerade;
1939
1942
  replies?: ReplyIntent[];
package/dist/index.d.ts CHANGED
@@ -1933,7 +1933,10 @@ interface MessageOptions {
1933
1933
  content?: string;
1934
1934
  embeds?: (TextEmbedData | EmbedBuilder)[];
1935
1935
  attachments?: string[] | AttachmentBuilder[];
1936
- interactions?: any[];
1936
+ interactions?: {
1937
+ reactions?: string[] | null;
1938
+ restrict_reactions?: boolean;
1939
+ };
1937
1940
  flags?: number;
1938
1941
  masquerade?: Masquerade;
1939
1942
  replies?: ReplyIntent[];
package/dist/index.js CHANGED
@@ -1131,9 +1131,6 @@ var GatewayManager = class {
1131
1131
  }
1132
1132
  };
1133
1133
 
1134
- // src/rest/RESTManager.ts
1135
- import { request } from "undici";
1136
-
1137
1134
  // src/utils/schema.ts
1138
1135
  var queryParams = {
1139
1136
  "/": { get: [] },
@@ -1347,29 +1344,28 @@ var RESTManager = class {
1347
1344
  this.client.emit("debug", `Bucket [${method}:${endpoint}] exhausted. Waiting ${waitTime}ms proactively...`);
1348
1345
  await sleep(waitTime);
1349
1346
  }
1350
- const options = {
1347
+ const response = await fetch(url, {
1351
1348
  method: method.toUpperCase(),
1352
1349
  headers: {
1353
1350
  "X-Bot-Token": this.token,
1354
1351
  "Content-Type": "application/json"
1355
1352
  },
1356
- ...body ? { body: JSON.stringify(body) } : {}
1357
- };
1358
- const response = await request(url, options);
1359
- const remainingHeader = response.headers["x-ratelimit-remaining"];
1360
- const resetAfterHeader = response.headers["x-ratelimit-reset-after"];
1353
+ ...body !== void 0 ? { body: JSON.stringify(body) } : {}
1354
+ });
1355
+ const remainingHeader = response.headers.get("x-ratelimit-remaining");
1356
+ const resetAfterHeader = response.headers.get("x-ratelimit-reset-after");
1361
1357
  if (remainingHeader !== void 0 && resetAfterHeader !== void 0) {
1362
1358
  bucket.remaining = Number(remainingHeader);
1363
1359
  bucket.resetAt = Date.now() + Number(resetAfterHeader);
1364
1360
  }
1365
- const textBody = await response.body.text();
1361
+ const textBody = await response.text();
1366
1362
  let data;
1367
1363
  try {
1368
1364
  data = JSON.parse(textBody);
1369
1365
  } catch {
1370
1366
  data = textBody;
1371
1367
  }
1372
- if (response.statusCode === 429) {
1368
+ if (response.status === 429) {
1373
1369
  const retryMs = typeof data === "object" && data?.retry_after ? data.retry_after : Number(resetAfterHeader) || 5e3;
1374
1370
  this.client.emit("debug", `Hit 429 on [${method}:${endpoint}]. Retrying in ${retryMs}ms.`);
1375
1371
  bucket.remaining = 0;
@@ -1377,8 +1373,8 @@ var RESTManager = class {
1377
1373
  await sleep(retryMs);
1378
1374
  return this.execute(method, endpoint, body, bucket);
1379
1375
  }
1380
- if (response.statusCode >= 400) {
1381
- throw new StoatAPIError(response.statusCode, data, method, endpoint);
1376
+ if (response.status >= 400) {
1377
+ throw new StoatAPIError(response.status, data, method, endpoint);
1382
1378
  }
1383
1379
  return data;
1384
1380
  }
@@ -1573,8 +1569,8 @@ var MessageManager = class extends BaseManager {
1573
1569
  async send(contentOrOptions) {
1574
1570
  const opts = typeof contentOrOptions === "string" ? { content: contentOrOptions } : contentOrOptions;
1575
1571
  const payload = {};
1576
- if (opts.embeds && opts.embeds.length) {
1577
- payload.embeds = opts.embeds.map((embed) => typeof embed.toJSON === "function" ? embed.toJSON() : embed);
1572
+ if (opts.content) {
1573
+ payload.content = opts.content;
1578
1574
  }
1579
1575
  if (opts.attachments && opts.attachments.length > 0) {
1580
1576
  const resolved = await Promise.all(
@@ -1585,6 +1581,21 @@ var MessageManager = class extends BaseManager {
1585
1581
  payload.attachments = validAttachments;
1586
1582
  }
1587
1583
  }
1584
+ if (opts.replies) {
1585
+ payload.replies = opts.replies;
1586
+ }
1587
+ if (opts.embeds && opts.embeds.length) {
1588
+ payload.embeds = opts.embeds.map((embed) => typeof embed.toJSON === "function" ? embed.toJSON() : embed);
1589
+ }
1590
+ if (opts.masquerade) {
1591
+ payload.masquerade = opts.masquerade;
1592
+ }
1593
+ if (opts.interactions) {
1594
+ payload.interactions = opts.interactions;
1595
+ }
1596
+ if (opts.flags) {
1597
+ payload.flags = opts.flags;
1598
+ }
1588
1599
  const data = await this.client.rest.post(`/channels/${this.channel.id}/messages`, payload);
1589
1600
  return new Message(this.client, data);
1590
1601
  }