@ovencord/rest 2.5.3 → 2.5.5
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@ovencord/rest",
|
|
4
|
-
"version": "2.5.
|
|
4
|
+
"version": "2.5.5",
|
|
5
5
|
"description": "The REST API for discord.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "bun test",
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@ovencord/collection": "^2.1.1",
|
|
38
38
|
"@ovencord/util": "^1.1.1",
|
|
39
|
-
"@sapphire/snowflake": "^3.5.5",
|
|
40
39
|
"discord-api-types": "^0.38.36"
|
|
41
40
|
},
|
|
42
41
|
"devDependencies": {
|
package/src/lib/REST.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Collection } from '@ovencord/collection';
|
|
2
|
-
import { DiscordSnowflake } from '@
|
|
2
|
+
import { DiscordSnowflake } from '@ovencord/util';
|
|
3
3
|
import { AsyncEventEmitter } from './utils/AsyncEventEmitter.js';
|
|
4
4
|
import { uuidv5 as uuidV5 } from './utils/utils.js';
|
|
5
5
|
import { CDN } from './CDN.js';
|
|
@@ -385,7 +385,7 @@ export class REST extends AsyncEventEmitter<RestEvents> {
|
|
|
385
385
|
// eslint-disable-next-line no-eq-null, eqeqeq
|
|
386
386
|
} else if (request.body != null) {
|
|
387
387
|
if (request.passThroughBody) {
|
|
388
|
-
finalBody = request.body as
|
|
388
|
+
finalBody = request.body as any;
|
|
389
389
|
} else {
|
|
390
390
|
// Stringify the JSON data
|
|
391
391
|
finalBody = JSON.stringify(request.body, (_, value) =>
|
|
@@ -15,6 +15,7 @@ export const DefaultUserAgent =
|
|
|
15
15
|
export const DefaultUserAgentAppendix = getUserAgentAppendix();
|
|
16
16
|
|
|
17
17
|
export const DefaultRestOptions = {
|
|
18
|
+
// @ts-ignore
|
|
18
19
|
agent: null,
|
|
19
20
|
api: 'https://discord.com/api',
|
|
20
21
|
authPrefix: 'Bot',
|
|
@@ -23,6 +24,7 @@ export const DefaultRestOptions = {
|
|
|
23
24
|
invalidRequestWarningInterval: 0,
|
|
24
25
|
globalRequestsPerSecond: 50,
|
|
25
26
|
offset: 50,
|
|
27
|
+
// @ts-ignore
|
|
26
28
|
rejectOnRateLimit: null,
|
|
27
29
|
retries: 3,
|
|
28
30
|
retryBackoff: 0,
|
package/src/lib/utils/types.ts
CHANGED
|
@@ -313,7 +313,7 @@ export interface RequestData {
|
|
|
313
313
|
* The body to send to this request.
|
|
314
314
|
* If providing as BodyInit, set `passThroughBody: true`
|
|
315
315
|
*/
|
|
316
|
-
body?:
|
|
316
|
+
body?: unknown;
|
|
317
317
|
/**
|
|
318
318
|
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} to use for the request.
|
|
319
319
|
*
|
package/src/lib/utils/utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import type { RESTPatchAPIChannelJSONBody, Snowflake } from 'discord-api-types/v10';
|
|
3
3
|
import type { REST } from '../REST.js';
|
|
4
4
|
import { RateLimitError } from '../errors/RateLimitError.js';
|
|
@@ -134,9 +134,7 @@ export function calculateUserDefaultAvatarIndex(userId: Snowflake) {
|
|
|
134
134
|
* @param ms - The amount of time (in milliseconds) to sleep for
|
|
135
135
|
*/
|
|
136
136
|
export async function sleep(ms: number): Promise<void> {
|
|
137
|
-
return
|
|
138
|
-
setTimeout(() => resolve(), ms);
|
|
139
|
-
});
|
|
137
|
+
return Bun.sleep(ms);
|
|
140
138
|
}
|
|
141
139
|
|
|
142
140
|
/**
|
|
@@ -226,7 +224,7 @@ export function uuidv5(value: string | Uint8Array, namespace: string): string {
|
|
|
226
224
|
data.set(valueBytes, namespaceBytes.length);
|
|
227
225
|
|
|
228
226
|
// 5. Hash with SHA-1
|
|
229
|
-
const buffer =
|
|
227
|
+
const buffer = new Bun.CryptoHasher('sha1').update(data).digest();
|
|
230
228
|
const hash = new Uint8Array(buffer);
|
|
231
229
|
|
|
232
230
|
// 6. Set version to 5 (0101)
|