@ovencord/rest 2.5.2 → 2.5.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/package.json +1 -2
- package/src/lib/REST.ts +8 -3
- package/src/lib/utils/utils.ts +3 -5
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.4",
|
|
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';
|
|
@@ -372,7 +372,10 @@ export class REST extends AsyncEventEmitter<RestEvents> {
|
|
|
372
372
|
formData.append(key, value as string | Blob);
|
|
373
373
|
}
|
|
374
374
|
} else {
|
|
375
|
-
formData.append(
|
|
375
|
+
formData.append(
|
|
376
|
+
'payload_json',
|
|
377
|
+
JSON.stringify(request.body, (_, value) => (typeof value === 'bigint' ? value.toString() : value)),
|
|
378
|
+
);
|
|
376
379
|
}
|
|
377
380
|
}
|
|
378
381
|
|
|
@@ -385,7 +388,9 @@ export class REST extends AsyncEventEmitter<RestEvents> {
|
|
|
385
388
|
finalBody = request.body as BodyInit;
|
|
386
389
|
} else {
|
|
387
390
|
// Stringify the JSON data
|
|
388
|
-
finalBody = JSON.stringify(request.body)
|
|
391
|
+
finalBody = JSON.stringify(request.body, (_, value) =>
|
|
392
|
+
typeof value === 'bigint' ? value.toString() : value,
|
|
393
|
+
);
|
|
389
394
|
// Set the additional headers to specify the content-type
|
|
390
395
|
additionalHeaders = { 'Content-Type': 'application/json' };
|
|
391
396
|
}
|
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)
|