@discordjs/rest 3.0.0-pr-11006.1765450794-e636950b2 → 3.0.0-pr-11005.1765454364-f3f6d34e7

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.
@@ -25,20 +25,15 @@ __export(undiciRequest_exports, {
25
25
  resolveBody: () => resolveBody
26
26
  });
27
27
  module.exports = __toCommonJS(undiciRequest_exports);
28
- var import_node_buffer = require("buffer");
29
28
  var import_node_http = require("http");
29
+ var import_node_url = require("url");
30
30
  var import_node_util = require("util");
31
31
  var import_undici = require("undici");
32
- var localAgent = null;
33
32
  async function makeRequest(url, init) {
34
33
  const options = {
35
34
  ...init,
36
35
  body: await resolveBody(init.body)
37
36
  };
38
- if (!options.dispatcher) {
39
- localAgent ??= new import_undici.Agent();
40
- options.dispatcher = localAgent;
41
- }
42
37
  const res = await (0, import_undici.request)(url, options);
43
38
  return {
44
39
  body: res.body,
@@ -70,7 +65,7 @@ async function resolveBody(body) {
70
65
  return body;
71
66
  } else if (import_node_util.types.isArrayBuffer(body)) {
72
67
  return new Uint8Array(body);
73
- } else if (body instanceof URLSearchParams) {
68
+ } else if (body instanceof import_node_url.URLSearchParams) {
74
69
  return body.toString();
75
70
  } else if (body instanceof DataView) {
76
71
  return new Uint8Array(body.buffer);
@@ -82,13 +77,13 @@ async function resolveBody(body) {
82
77
  return globalToUndiciFormData(body);
83
78
  } else if (body[Symbol.iterator]) {
84
79
  const chunks = [...body];
85
- return import_node_buffer.Buffer.concat(chunks);
80
+ return Buffer.concat(chunks);
86
81
  } else if (body[Symbol.asyncIterator]) {
87
82
  const chunks = [];
88
83
  for await (const chunk of body) {
89
84
  chunks.push(chunk);
90
85
  }
91
- return import_node_buffer.Buffer.concat(chunks);
86
+ return Buffer.concat(chunks);
92
87
  }
93
88
  throw new TypeError(`Unable to resolve body.`);
94
89
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/strategies/undiciRequest.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport { STATUS_CODES } from 'node:http';\nimport { types } from 'node:util';\nimport { type RequestInit, request, Headers, FormData as UndiciFormData, Agent } from 'undici';\nimport type { HeaderRecord } from 'undici/types/header.js';\nimport type { ResponseLike } from '../shared.js';\n\nexport type RequestOptions = Exclude<Parameters<typeof request>[1], undefined>;\n\nlet localAgent: Agent | null = null;\n\nexport async function makeRequest(url: string, init: RequestInit): Promise<ResponseLike> {\n\t// The cast is necessary because `headers` and `method` are narrower types in `undici.request`\n\t// our request path guarantees they are of acceptable type for `undici.request`\n\tconst options = {\n\t\t...init,\n\t\tbody: await resolveBody(init.body),\n\t} as RequestOptions;\n\n\t// Mismatched dispatchers from the Node.js-bundled undici and package-installed undici breaks file uploads.\n\t// So we ensure that we always pass an Agent to request()\n\t// https://github.com/nodejs/node/issues/59012\n\tif (!options.dispatcher) {\n\t\tlocalAgent ??= new Agent();\n\t\toptions.dispatcher = localAgent;\n\t}\n\n\tconst res = await request(url, options);\n\treturn {\n\t\tbody: res.body,\n\t\tasync arrayBuffer() {\n\t\t\treturn res.body.arrayBuffer();\n\t\t},\n\t\tasync json() {\n\t\t\treturn res.body.json();\n\t\t},\n\t\tasync text() {\n\t\t\treturn res.body.text();\n\t\t},\n\t\tget bodyUsed() {\n\t\t\treturn res.body.bodyUsed;\n\t\t},\n\t\theaders: new Headers(res.headers as HeaderRecord),\n\t\tstatus: res.statusCode,\n\t\tstatusText: STATUS_CODES[res.statusCode]!,\n\t\tok: res.statusCode >= 200 && res.statusCode < 300,\n\t};\n}\n\nexport async function resolveBody(body: RequestInit['body']): Promise<Exclude<RequestOptions['body'], undefined>> {\n\t// eslint-disable-next-line no-eq-null, eqeqeq\n\tif (body == null) {\n\t\treturn null;\n\t} else if (typeof body === 'string') {\n\t\treturn body;\n\t} else if (types.isUint8Array(body)) {\n\t\treturn body;\n\t} else if (types.isArrayBuffer(body)) {\n\t\treturn new Uint8Array(body);\n\t} else if (body instanceof URLSearchParams) {\n\t\treturn body.toString();\n\t} else if (body instanceof DataView) {\n\t\treturn new Uint8Array(body.buffer);\n\t} else if (body instanceof Blob) {\n\t\treturn new Uint8Array(await body.arrayBuffer());\n\t} else if (body instanceof UndiciFormData) {\n\t\treturn body;\n\t} else if (body instanceof FormData) {\n\t\treturn globalToUndiciFormData(body);\n\t} else if ((body as Iterable<Uint8Array>)[Symbol.iterator]) {\n\t\tconst chunks = [...(body as Iterable<Uint8Array>)];\n\n\t\treturn Buffer.concat(chunks);\n\t} else if ((body as AsyncIterable<Uint8Array>)[Symbol.asyncIterator]) {\n\t\tconst chunks: Uint8Array[] = [];\n\n\t\tfor await (const chunk of body as AsyncIterable<Uint8Array>) {\n\t\t\tchunks.push(chunk);\n\t\t}\n\n\t\treturn Buffer.concat(chunks);\n\t}\n\n\tthrow new TypeError(`Unable to resolve body.`);\n}\n\nfunction globalToUndiciFormData(fd: globalThis.FormData): UndiciFormData {\n\tconst clone = new UndiciFormData();\n\n\tfor (const [name, value] of fd.entries()) {\n\t\tif (typeof value === 'string') {\n\t\t\tclone.append(name, value);\n\t\t} else {\n\t\t\tclone.append(name, value, value.name);\n\t\t}\n\t}\n\n\treturn clone;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAuB;AACvB,uBAA6B;AAC7B,uBAAsB;AACtB,oBAAsF;AAMtF,IAAI,aAA2B;AAE/B,eAAsB,YAAY,KAAa,MAA0C;AAGxF,QAAM,UAAU;AAAA,IACf,GAAG;AAAA,IACH,MAAM,MAAM,YAAY,KAAK,IAAI;AAAA,EAClC;AAKA,MAAI,CAAC,QAAQ,YAAY;AACxB,mBAAe,IAAI,oBAAM;AACzB,YAAQ,aAAa;AAAA,EACtB;AAEA,QAAM,MAAM,UAAM,uBAAQ,KAAK,OAAO;AACtC,SAAO;AAAA,IACN,MAAM,IAAI;AAAA,IACV,MAAM,cAAc;AACnB,aAAO,IAAI,KAAK,YAAY;AAAA,IAC7B;AA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QAAM,IAAI,UAAU,yBAAyB;AAC9C;AAnCsB;AAqCtB,SAAS,uBAAuB,IAAyC;AACxE,QAAM,QAAQ,IAAI,cAAAA,SAAe;AAEjC,aAAW,CAAC,MAAM,KAAK,KAAK,GAAG,QAAQ,GAAG;AACzC,QAAI,OAAO,UAAU,UAAU;AAC9B,YAAM,OAAO,MAAM,KAAK;AAAA,IACzB,OAAO;AACN,YAAM,OAAO,MAAM,OAAO,MAAM,IAAI;AAAA,IACrC;AAAA,EACD;AAEA,SAAO;AACR;AAZS;","names":["UndiciFormData"]}
1
+ {"version":3,"sources":["../../src/strategies/undiciRequest.ts"],"sourcesContent":["import { STATUS_CODES } from 'node:http';\nimport { URLSearchParams } from 'node:url';\nimport { types } from 'node:util';\nimport { type RequestInit, request, Headers, FormData as UndiciFormData } from 'undici';\nimport type { HeaderRecord } from 'undici/types/header.js';\nimport type { ResponseLike } from '../shared.js';\n\nexport type RequestOptions = Exclude<Parameters<typeof request>[1], undefined>;\n\nexport async function makeRequest(url: string, init: RequestInit): Promise<ResponseLike> {\n\t// The cast is necessary because `headers` and `method` are narrower types in `undici.request`\n\t// our request path guarantees they are of acceptable type for `undici.request`\n\tconst options = {\n\t\t...init,\n\t\tbody: await resolveBody(init.body),\n\t} as RequestOptions;\n\tconst res = await request(url, options);\n\treturn {\n\t\tbody: res.body,\n\t\tasync arrayBuffer() {\n\t\t\treturn res.body.arrayBuffer();\n\t\t},\n\t\tasync json() {\n\t\t\treturn res.body.json();\n\t\t},\n\t\tasync text() {\n\t\t\treturn res.body.text();\n\t\t},\n\t\tget bodyUsed() {\n\t\t\treturn res.body.bodyUsed;\n\t\t},\n\t\theaders: new Headers(res.headers as HeaderRecord),\n\t\tstatus: res.statusCode,\n\t\tstatusText: STATUS_CODES[res.statusCode]!,\n\t\tok: res.statusCode >= 200 && res.statusCode < 300,\n\t};\n}\n\nexport async function resolveBody(body: RequestInit['body']): Promise<Exclude<RequestOptions['body'], undefined>> {\n\t// eslint-disable-next-line no-eq-null, eqeqeq\n\tif (body == null) {\n\t\treturn null;\n\t} else if (typeof body === 'string') {\n\t\treturn body;\n\t} else if (types.isUint8Array(body)) {\n\t\treturn body;\n\t} else if (types.isArrayBuffer(body)) {\n\t\treturn new Uint8Array(body);\n\t} else if (body instanceof URLSearchParams) {\n\t\treturn body.toString();\n\t} else if (body instanceof DataView) {\n\t\treturn new Uint8Array(body.buffer);\n\t} else if (body instanceof Blob) {\n\t\treturn new Uint8Array(await body.arrayBuffer());\n\t} else if (body instanceof UndiciFormData) {\n\t\treturn body;\n\t} else if (body instanceof FormData) {\n\t\treturn globalToUndiciFormData(body);\n\t} else if ((body as Iterable<Uint8Array>)[Symbol.iterator]) {\n\t\tconst chunks = [...(body as Iterable<Uint8Array>)];\n\n\t\treturn Buffer.concat(chunks);\n\t} else if ((body as AsyncIterable<Uint8Array>)[Symbol.asyncIterator]) {\n\t\tconst chunks: Uint8Array[] = [];\n\n\t\tfor await (const chunk of body as AsyncIterable<Uint8Array>) {\n\t\t\tchunks.push(chunk);\n\t\t}\n\n\t\treturn Buffer.concat(chunks);\n\t}\n\n\tthrow new TypeError(`Unable to resolve body.`);\n}\n\nfunction globalToUndiciFormData(fd: globalThis.FormData): UndiciFormData {\n\tconst clone = new UndiciFormData();\n\n\tfor (const [name, value] of fd.entries()) {\n\t\tif (typeof value === 'string') {\n\t\t\tclone.append(name, value);\n\t\t} else {\n\t\t\tclone.append(name, value, value.name);\n\t\t}\n\t}\n\n\treturn clone;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA6B;AAC7B,sBAAgC;AAChC,uBAAsB;AACtB,oBAA+E;AAM/E,eAAsB,YAAY,KAAa,MAA0C;AAGxF,QAAM,UAAU;AAAA,IACf,GAAG;AAAA,IACH,MAAM,MAAM,YAAY,KAAK,IAAI;AAAA,EAClC;AACA,QAAM,MAAM,UAAM,uBAAQ,KAAK,OAAO;AACtC,SAAO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AmC;AAC5D,aAAO,KAAK,KAAK;AAAA,IAClB;AAEA,WAAO,OAAO,OAAO,MAAM;AAAA,EAC5B;AAEA,QAAM,IAAI,UAAU,yBAAyB;AAC9C;AAnCsB;AAqCtB,SAAS,uBAAuB,IAAyC;AACxE,QAAM,QAAQ,IAAI,cAAAA,SAAe;AAEjC,aAAW,CAAC,MAAM,KAAK,KAAK,GAAG,QAAQ,GAAG;AACzC,QAAI,OAAO,UAAU,UAAU;AAC9B,YAAM,OAAO,MAAM,KAAK;AAAA,IACzB,OAAO;AACN,YAAM,OAAO,MAAM,OAAO,MAAM,IAAI;AAAA,IACrC;AAAA,EACD;AAEA,SAAO;AACR;AAZS;","names":["UndiciFormData"]}
@@ -2,20 +2,15 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
4
  // src/strategies/undiciRequest.ts
5
- import { Buffer as Buffer2 } from "buffer";
6
5
  import { STATUS_CODES } from "http";
6
+ import { URLSearchParams } from "url";
7
7
  import { types } from "util";
8
- import { request, Headers, FormData as UndiciFormData, Agent } from "undici";
9
- var localAgent = null;
8
+ import { request, Headers, FormData as UndiciFormData } from "undici";
10
9
  async function makeRequest(url, init) {
11
10
  const options = {
12
11
  ...init,
13
12
  body: await resolveBody(init.body)
14
13
  };
15
- if (!options.dispatcher) {
16
- localAgent ??= new Agent();
17
- options.dispatcher = localAgent;
18
- }
19
14
  const res = await request(url, options);
20
15
  return {
21
16
  body: res.body,
@@ -59,13 +54,13 @@ async function resolveBody(body) {
59
54
  return globalToUndiciFormData(body);
60
55
  } else if (body[Symbol.iterator]) {
61
56
  const chunks = [...body];
62
- return Buffer2.concat(chunks);
57
+ return Buffer.concat(chunks);
63
58
  } else if (body[Symbol.asyncIterator]) {
64
59
  const chunks = [];
65
60
  for await (const chunk of body) {
66
61
  chunks.push(chunk);
67
62
  }
68
- return Buffer2.concat(chunks);
63
+ return Buffer.concat(chunks);
69
64
  }
70
65
  throw new TypeError(`Unable to resolve body.`);
71
66
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/strategies/undiciRequest.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport { STATUS_CODES } from 'node:http';\nimport { types } from 'node:util';\nimport { type RequestInit, request, Headers, FormData as UndiciFormData, Agent } from 'undici';\nimport type { HeaderRecord } from 'undici/types/header.js';\nimport type { ResponseLike } from '../shared.js';\n\nexport type RequestOptions = Exclude<Parameters<typeof request>[1], undefined>;\n\nlet localAgent: Agent | null = null;\n\nexport async function makeRequest(url: string, init: RequestInit): Promise<ResponseLike> {\n\t// The cast is necessary because `headers` and `method` are narrower types in `undici.request`\n\t// our request path guarantees they are of acceptable type for `undici.request`\n\tconst options = {\n\t\t...init,\n\t\tbody: await resolveBody(init.body),\n\t} as RequestOptions;\n\n\t// Mismatched dispatchers from the Node.js-bundled undici and package-installed undici breaks file uploads.\n\t// So we ensure that we always pass an Agent to request()\n\t// https://github.com/nodejs/node/issues/59012\n\tif (!options.dispatcher) {\n\t\tlocalAgent ??= new Agent();\n\t\toptions.dispatcher = localAgent;\n\t}\n\n\tconst res = await request(url, options);\n\treturn {\n\t\tbody: res.body,\n\t\tasync arrayBuffer() {\n\t\t\treturn res.body.arrayBuffer();\n\t\t},\n\t\tasync json() {\n\t\t\treturn res.body.json();\n\t\t},\n\t\tasync text() {\n\t\t\treturn res.body.text();\n\t\t},\n\t\tget bodyUsed() {\n\t\t\treturn res.body.bodyUsed;\n\t\t},\n\t\theaders: new Headers(res.headers as HeaderRecord),\n\t\tstatus: res.statusCode,\n\t\tstatusText: STATUS_CODES[res.statusCode]!,\n\t\tok: res.statusCode >= 200 && res.statusCode < 300,\n\t};\n}\n\nexport async function resolveBody(body: RequestInit['body']): Promise<Exclude<RequestOptions['body'], undefined>> {\n\t// eslint-disable-next-line no-eq-null, eqeqeq\n\tif (body == null) {\n\t\treturn null;\n\t} else if (typeof body === 'string') {\n\t\treturn body;\n\t} else if (types.isUint8Array(body)) {\n\t\treturn body;\n\t} else if (types.isArrayBuffer(body)) {\n\t\treturn new Uint8Array(body);\n\t} else if (body instanceof URLSearchParams) {\n\t\treturn body.toString();\n\t} else if (body instanceof DataView) {\n\t\treturn new Uint8Array(body.buffer);\n\t} else if (body instanceof Blob) {\n\t\treturn new Uint8Array(await body.arrayBuffer());\n\t} else if (body instanceof UndiciFormData) {\n\t\treturn body;\n\t} else if (body instanceof FormData) {\n\t\treturn globalToUndiciFormData(body);\n\t} else if ((body as Iterable<Uint8Array>)[Symbol.iterator]) {\n\t\tconst chunks = [...(body as Iterable<Uint8Array>)];\n\n\t\treturn Buffer.concat(chunks);\n\t} else if ((body as AsyncIterable<Uint8Array>)[Symbol.asyncIterator]) {\n\t\tconst chunks: Uint8Array[] = [];\n\n\t\tfor await (const chunk of body as AsyncIterable<Uint8Array>) {\n\t\t\tchunks.push(chunk);\n\t\t}\n\n\t\treturn Buffer.concat(chunks);\n\t}\n\n\tthrow new TypeError(`Unable to resolve body.`);\n}\n\nfunction globalToUndiciFormData(fd: globalThis.FormData): UndiciFormData {\n\tconst clone = new UndiciFormData();\n\n\tfor (const [name, value] of fd.entries()) {\n\t\tif (typeof value === 'string') {\n\t\t\tclone.append(name, value);\n\t\t} else {\n\t\t\tclone.append(name, value, value.name);\n\t\t}\n\t}\n\n\treturn clone;\n}\n"],"mappings":";;;;AAAA,SAAS,UAAAA,eAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,aAAa;AACtB,SAA2B,SAAS,SAAS,YAAY,gBAAgB,aAAa;AAMtF,IAAI,aAA2B;AAE/B,eAAsB,YAAY,KAAa,MAA0C;AAGxF,QAAM,UAAU;AAAA,IACf,GAAG;AAAA,IACH,MAAM,MAAM,YAAY,KAAK,IAAI;AAAA,EAClC;AAKA,MAAI,CAAC,QAAQ,YAAY;AACxB,mBAAe,IAAI,MAAM;AACzB,YAAQ,aAAa;AAAA,EACtB;AAEA,QAAM,MAAM,MAAM,QAAQ,KAAK,OAAO;AACtC,S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C5D,aAAO,KAAK,KAAK;AAAA,IAClB;AAEA,WAAOA,QAAO,OAAO,MAAM;AAAA,EAC5B;AAEA,QAAM,IAAI,UAAU,yBAAyB;AAC9C;AAnCsB;AAqCtB,SAAS,uBAAuB,IAAyC;AACxE,QAAM,QAAQ,IAAI,eAAe;AAEjC,aAAW,CAAC,MAAM,KAAK,KAAK,GAAG,QAAQ,GAAG;AACzC,QAAI,OAAO,UAAU,UAAU;AAC9B,YAAM,OAAO,MAAM,KAAK;AAAA,IACzB,OAAO;AACN,YAAM,OAAO,MAAM,OAAO,MAAM,IAAI;AAAA,IACrC;AAAA,EACD;AAEA,SAAO;AACR;AAZS;","names":["Buffer","Buffer"]}
1
+ {"version":3,"sources":["../../src/strategies/undiciRequest.ts"],"sourcesContent":["import { STATUS_CODES } from 'node:http';\nimport { URLSearchParams } from 'node:url';\nimport { types } from 'node:util';\nimport { type RequestInit, request, Headers, FormData as UndiciFormData } from 'undici';\nimport type { HeaderRecord } from 'undici/types/header.js';\nimport type { ResponseLike } from '../shared.js';\n\nexport type RequestOptions = Exclude<Parameters<typeof request>[1], undefined>;\n\nexport async function makeRequest(url: string, init: RequestInit): Promise<ResponseLike> {\n\t// The cast is necessary because `headers` and `method` are narrower types in `undici.request`\n\t// our request path guarantees they are of acceptable type for `undici.request`\n\tconst options = {\n\t\t...init,\n\t\tbody: await resolveBody(init.body),\n\t} as RequestOptions;\n\tconst res = await request(url, options);\n\treturn {\n\t\tbody: res.body,\n\t\tasync arrayBuffer() {\n\t\t\treturn res.body.arrayBuffer();\n\t\t},\n\t\tasync json() {\n\t\t\treturn res.body.json();\n\t\t},\n\t\tasync text() {\n\t\t\treturn res.body.text();\n\t\t},\n\t\tget bodyUsed() {\n\t\t\treturn res.body.bodyUsed;\n\t\t},\n\t\theaders: new Headers(res.headers as HeaderRecord),\n\t\tstatus: res.statusCode,\n\t\tstatusText: STATUS_CODES[res.statusCode]!,\n\t\tok: res.statusCode >= 200 && res.statusCode < 300,\n\t};\n}\n\nexport async function resolveBody(body: RequestInit['body']): Promise<Exclude<RequestOptions['body'], undefined>> {\n\t// eslint-disable-next-line no-eq-null, eqeqeq\n\tif (body == null) {\n\t\treturn null;\n\t} else if (typeof body === 'string') {\n\t\treturn body;\n\t} else if (types.isUint8Array(body)) {\n\t\treturn body;\n\t} else if (types.isArrayBuffer(body)) {\n\t\treturn new Uint8Array(body);\n\t} else if (body instanceof URLSearchParams) {\n\t\treturn body.toString();\n\t} else if (body instanceof DataView) {\n\t\treturn new Uint8Array(body.buffer);\n\t} else if (body instanceof Blob) {\n\t\treturn new Uint8Array(await body.arrayBuffer());\n\t} else if (body instanceof UndiciFormData) {\n\t\treturn body;\n\t} else if (body instanceof FormData) {\n\t\treturn globalToUndiciFormData(body);\n\t} else if ((body as Iterable<Uint8Array>)[Symbol.iterator]) {\n\t\tconst chunks = [...(body as Iterable<Uint8Array>)];\n\n\t\treturn Buffer.concat(chunks);\n\t} else if ((body as AsyncIterable<Uint8Array>)[Symbol.asyncIterator]) {\n\t\tconst chunks: Uint8Array[] = [];\n\n\t\tfor await (const chunk of body as AsyncIterable<Uint8Array>) {\n\t\t\tchunks.push(chunk);\n\t\t}\n\n\t\treturn Buffer.concat(chunks);\n\t}\n\n\tthrow new TypeError(`Unable to resolve body.`);\n}\n\nfunction globalToUndiciFormData(fd: globalThis.FormData): UndiciFormData {\n\tconst clone = new UndiciFormData();\n\n\tfor (const [name, value] of fd.entries()) {\n\t\tif (typeof value === 'string') {\n\t\t\tclone.append(name, value);\n\t\t} else {\n\t\t\tclone.append(name, value, value.name);\n\t\t}\n\t}\n\n\treturn clone;\n}\n"],"mappings":";;;;AAAA,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,aAAa;AACtB,SAA2B,SAAS,SAAS,YAAY,sBAAsB;AAM/E,eAAsB,YAAY,KAAa,MAA0C;AAGxF,QAAM,UAAU;AAAA,IACf,GAAG;AAAA,IACH,MAAM,MAAM,YAAY,KAAK,IAAI;A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AG;AACrE,UAAM,SAAuB,CAAC;AAE9B,qBAAiB,SAAS,MAAmC;AAC5D,aAAO,KAAK,KAAK;AAAA,IAClB;AAEA,WAAO,OAAO,OAAO,MAAM;AAAA,EAC5B;AAEA,QAAM,IAAI,UAAU,yBAAyB;AAC9C;AAnCsB;AAqCtB,SAAS,uBAAuB,IAAyC;AACxE,QAAM,QAAQ,IAAI,eAAe;AAEjC,aAAW,CAAC,MAAM,KAAK,KAAK,GAAG,QAAQ,GAAG;AACzC,QAAI,OAAO,UAAU,UAAU;AAC9B,YAAM,OAAO,MAAM,KAAK;AAAA,IACzB,OAAO;AACN,YAAM,OAAO,MAAM,OAAO,MAAM,IAAI;AAAA,IACrC;AAAA,EACD;AAEA,SAAO;AACR;AAZS;","names":[]}
package/dist/web.d.mts CHANGED
@@ -4,8 +4,7 @@ export { ImageSize } from 'discord-api-types/v10';
4
4
  import { Readable } from 'node:stream';
5
5
  import { ReadableStream } from 'node:stream/web';
6
6
  import { Collection } from '@discordjs/collection';
7
- import { RawFile, Awaitable } from '@discordjs/util';
8
- export { RawFile } from '@discordjs/util';
7
+ import { Awaitable } from '@discordjs/util';
9
8
  import * as undici from 'undici';
10
9
  import { RequestInit, Response, BodyInit, Agent, Dispatcher } from 'undici';
11
10
  import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
@@ -284,7 +283,29 @@ interface InvalidRequestWarningData {
284
283
  */
285
284
  remainingTime: number;
286
285
  }
287
-
286
+ /**
287
+ * Represents a file to be added to the request
288
+ */
289
+ interface RawFile {
290
+ /**
291
+ * Content-Type of the file
292
+ */
293
+ contentType?: string;
294
+ /**
295
+ * The actual data for the file
296
+ */
297
+ data: Buffer | Uint8Array | boolean | number | string;
298
+ /**
299
+ * An explicit key to use for key of the formdata field for this file.
300
+ * When not provided, the index of the file in the files array is used in the form `files[${index}]`.
301
+ * If you wish to alter the placeholder snowflake, you must provide this property in the same form (`files[${placeholder}]`)
302
+ */
303
+ key?: string;
304
+ /**
305
+ * The name of the file
306
+ */
307
+ name: string;
308
+ }
288
309
  interface AuthData {
289
310
  /**
290
311
  * The authorization prefix to use for this request, useful if you use this with bearer tokens
@@ -928,4 +949,4 @@ declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
928
949
  */
929
950
  declare const version: string;
930
951
 
931
- export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, AUTH_UUID_NAMESPACE, type AuthData, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, type CDNOptions, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordError, type DiscordErrorData, type DiscordErrorFieldInformation, type DiscordErrorGroupWrapper, type EmojiURLOptions, type EmojiURLOptionsNotWebp, type EmojiURLOptionsWebp, type GetRateLimitOffsetFunction, type GetRetryBackoffFunction, type GetTimeoutFunction, HTTPError, type HandlerRequestData, type HashData, type IHandler, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, type RESTOptions, type RateLimitData, RateLimitError, type RateLimitQueueFilter, type RequestBody, type RequestData, type RequestHeaders, RequestMethod, type ResponseLike, type RestEvents, type RestEventsMap, type RouteData, type RouteLike, type StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
952
+ export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, AUTH_UUID_NAMESPACE, type AuthData, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, type CDNOptions, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordError, type DiscordErrorData, type DiscordErrorFieldInformation, type DiscordErrorGroupWrapper, type EmojiURLOptions, type EmojiURLOptionsNotWebp, type EmojiURLOptionsWebp, type GetRateLimitOffsetFunction, type GetRetryBackoffFunction, type GetTimeoutFunction, HTTPError, type HandlerRequestData, type HashData, type IHandler, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, type RESTOptions, type RateLimitData, RateLimitError, type RateLimitQueueFilter, type RawFile, type RequestBody, type RequestData, type RequestHeaders, RequestMethod, type ResponseLike, type RestEvents, type RestEventsMap, type RouteData, type RouteLike, type StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
package/dist/web.d.ts CHANGED
@@ -4,8 +4,7 @@ export { ImageSize } from 'discord-api-types/v10';
4
4
  import { Readable } from 'node:stream';
5
5
  import { ReadableStream } from 'node:stream/web';
6
6
  import { Collection } from '@discordjs/collection';
7
- import { RawFile, Awaitable } from '@discordjs/util';
8
- export { RawFile } from '@discordjs/util';
7
+ import { Awaitable } from '@discordjs/util';
9
8
  import * as undici from 'undici';
10
9
  import { RequestInit, Response, BodyInit, Agent, Dispatcher } from 'undici';
11
10
  import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
@@ -284,7 +283,29 @@ interface InvalidRequestWarningData {
284
283
  */
285
284
  remainingTime: number;
286
285
  }
287
-
286
+ /**
287
+ * Represents a file to be added to the request
288
+ */
289
+ interface RawFile {
290
+ /**
291
+ * Content-Type of the file
292
+ */
293
+ contentType?: string;
294
+ /**
295
+ * The actual data for the file
296
+ */
297
+ data: Buffer | Uint8Array | boolean | number | string;
298
+ /**
299
+ * An explicit key to use for key of the formdata field for this file.
300
+ * When not provided, the index of the file in the files array is used in the form `files[${index}]`.
301
+ * If you wish to alter the placeholder snowflake, you must provide this property in the same form (`files[${placeholder}]`)
302
+ */
303
+ key?: string;
304
+ /**
305
+ * The name of the file
306
+ */
307
+ name: string;
308
+ }
288
309
  interface AuthData {
289
310
  /**
290
311
  * The authorization prefix to use for this request, useful if you use this with bearer tokens
@@ -928,4 +949,4 @@ declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
928
949
  */
929
950
  declare const version: string;
930
951
 
931
- export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, AUTH_UUID_NAMESPACE, type AuthData, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, type CDNOptions, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordError, type DiscordErrorData, type DiscordErrorFieldInformation, type DiscordErrorGroupWrapper, type EmojiURLOptions, type EmojiURLOptionsNotWebp, type EmojiURLOptionsWebp, type GetRateLimitOffsetFunction, type GetRetryBackoffFunction, type GetTimeoutFunction, HTTPError, type HandlerRequestData, type HashData, type IHandler, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, type RESTOptions, type RateLimitData, RateLimitError, type RateLimitQueueFilter, type RequestBody, type RequestData, type RequestHeaders, RequestMethod, type ResponseLike, type RestEvents, type RestEventsMap, type RouteData, type RouteLike, type StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
952
+ export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, AUTH_UUID_NAMESPACE, type AuthData, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, type CDNOptions, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordError, type DiscordErrorData, type DiscordErrorFieldInformation, type DiscordErrorGroupWrapper, type EmojiURLOptions, type EmojiURLOptionsNotWebp, type EmojiURLOptionsWebp, type GetRateLimitOffsetFunction, type GetRetryBackoffFunction, type GetTimeoutFunction, HTTPError, type HandlerRequestData, type HashData, type IHandler, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, type RESTOptions, type RateLimitData, RateLimitError, type RateLimitQueueFilter, type RawFile, type RequestBody, type RequestData, type RequestHeaders, RequestMethod, type ResponseLike, type RestEvents, type RestEventsMap, type RouteData, type RouteLike, type StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
package/dist/web.js CHANGED
@@ -61,7 +61,7 @@ var import_v102 = require("discord-api-types/v10");
61
61
  // src/lib/utils/constants.ts
62
62
  var import_util = require("@discordjs/util");
63
63
  var import_v10 = require("discord-api-types/v10");
64
- var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-pr-11006.1765450794-e636950b2)`;
64
+ var DefaultUserAgent = `DiscordBot (https://discord.js.org, 3.0.0-pr-11005.1765454364-f3f6d34e7)`;
65
65
  var DefaultUserAgentAppendix = (0, import_util.getUserAgentAppendix)();
66
66
  var DefaultRestOptions = {
67
67
  agent: null,
@@ -1178,7 +1178,6 @@ var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
1178
1178
  handlerTimer;
1179
1179
  options;
1180
1180
  constructor(options = {}) {
1181
- console.log("even rest got something new \u203C\uFE0F \u{1F5E3}\uFE0F \u{1F525}");
1182
1181
  super();
1183
1182
  this.cdn = new CDN(options);
1184
1183
  this.options = { ...DefaultRestOptions, ...options };
@@ -1463,7 +1462,7 @@ var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
1463
1462
  };
1464
1463
 
1465
1464
  // src/shared.ts
1466
- var version = "3.0.0-pr-11006.1765450794-e636950b2";
1465
+ var version = "3.0.0-pr-11005.1765454364-f3f6d34e7";
1467
1466
 
1468
1467
  // src/web.ts
1469
1468
  setDefaultStrategy(fetch);