This commit is contained in:
Dragurimu 2022-08-20 05:59:52 -05:00
parent 9bff9a9883
commit 313483eb80
15 changed files with 49 additions and 43 deletions

View File

@ -1,7 +1,7 @@
# @biscuitland/api-types # @biscuitland/api-types
## 2.0.0 ## 2.0.1
### Major Changes ### Major Changes
- publish - publish

View File

@ -25,7 +25,7 @@ import type { DiscordUser } from '@biscuitland/api-types';
## Example for [Deno](https://deno.land/) ## Example for [Deno](https://deno.land/)
```ts ```ts
import type { DiscordUser } from "https://unpkg.com/@biscuitland/api-types@1.3.2/dist/index.d.ts"; import type { DiscordUser } from "https://unpkg.com/@biscuitland/api-types@2.0.1/dist/index.d.ts";
``` ```
We deliver this package through [unpkg](https://unpkg.com/) and it does contain constants and routes too We deliver this package through [unpkg](https://unpkg.com/) and it does contain constants and routes too

View File

@ -1,6 +1,6 @@
{ {
"name": "@biscuitland/api-types", "name": "@biscuitland/api-types",
"version": "2.0.0", "version": "2.0.1",
"main": "./dist/index.js", "main": "./dist/index.js",
"module": "./dist/index.mjs", "module": "./dist/index.mjs",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",

View File

@ -5,7 +5,7 @@ export const BASE_URL = 'https://discord.com/api';
export const API_VERSION = 10; export const API_VERSION = 10;
/** https://github.com/oasisjs/biscuit/releases */ /** https://github.com/oasisjs/biscuit/releases */
export const BISCUIT_VERSION = '1.3.2'; export const BISCUIT_VERSION = '2.0.1';
/** https://discord.com/developers/docs/reference#user-agent */ /** https://discord.com/developers/docs/reference#user-agent */
export const USER_AGENT = `DiscordBot (https://github.com/oasisjs/biscuit, v${BISCUIT_VERSION})`; export const USER_AGENT = `DiscordBot (https://github.com/oasisjs/biscuit, v${BISCUIT_VERSION})`;

View File

@ -1,12 +1,12 @@
# @biscuitland/cache # @biscuitland/cache
## 2.0.0 ## 2.0.1
### Major Changes ### Major Changes
- publish - publish
### Patch Changes ### Patch Changes
- Updated dependencies - Updated dependencies
- @biscuitland/api-types@2.0.0 - @biscuitland/api-types@2.0.1

View File

@ -1,6 +1,6 @@
{ {
"name": "@biscuitland/cache", "name": "@biscuitland/cache",
"version": "2.0.0", "version": "2.0.1",
"main": "./dist/index.js", "main": "./dist/index.js",
"module": "./dist/index.mjs", "module": "./dist/index.mjs",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
@ -23,7 +23,7 @@
} }
}, },
"dependencies": { "dependencies": {
"@biscuitland/api-types": "^2.0.0", "@biscuitland/api-types": "^2.0.1",
"ioredis": "^5.2.2" "ioredis": "^5.2.2"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,14 +1,14 @@
# @biscuitland/core # @biscuitland/core
## 2.0.0 ## 2.0.1
### Major Changes ### Major Changes
- publish - publish
### Patch Changes ### Patch Changes
- Updated dependencies - Updated dependencies
- @biscuitland/api-types@2.0.0 - @biscuitland/api-types@2.0.1
- @biscuitland/rest@2.0.0 - @biscuitland/rest@2.0.1
- @biscuitland/ws@2.0.0 - @biscuitland/ws@2.0.1

View File

@ -1,6 +1,6 @@
{ {
"name": "@biscuitland/core", "name": "@biscuitland/core",
"version": "2.0.0", "version": "2.0.1",
"main": "./dist/index.js", "main": "./dist/index.js",
"module": "./dist/index.mjs", "module": "./dist/index.mjs",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
@ -23,9 +23,9 @@
} }
}, },
"dependencies": { "dependencies": {
"@biscuitland/api-types": "^2.0.0", "@biscuitland/api-types": "^2.0.1",
"@biscuitland/rest": "^2.0.0", "@biscuitland/rest": "^2.0.1",
"@biscuitland/ws": "^2.0.0" "@biscuitland/ws": "^2.0.1"
}, },
"devDependencies": { "devDependencies": {
"tsup": "^6.1.3" "tsup": "^6.1.3"

View File

@ -1,9 +1,9 @@
# @biscuitland/helpers # @biscuitland/helpers
## 1.3.3 ## 2.0.1
### Patch Changes ### Patch Changes
- Updated dependencies - Updated dependencies
- @biscuitland/api-types@2.0.0 - @biscuitland/api-types@2.0.1
- @biscuitland/core@2.0.0 - @biscuitland/core@2.0.1

View File

@ -1,6 +1,6 @@
{ {
"name": "@biscuitland/helpers", "name": "@biscuitland/helpers",
"version": "1.3.3", "version": "2.0.1",
"main": "./dist/index.js", "main": "./dist/index.js",
"module": "./dist/index.mjs", "module": "./dist/index.mjs",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
@ -23,8 +23,8 @@
} }
}, },
"dependencies": { "dependencies": {
"@biscuitland/api-types": "^2.0.0", "@biscuitland/api-types": "^2.0.1",
"@biscuitland/core": "^2.0.0" "@biscuitland/core": "^2.0.1"
}, },
"devDependencies": { "devDependencies": {
"tsup": "^6.1.3" "tsup": "^6.1.3"

View File

@ -1,12 +1,12 @@
# @biscuitland/rest # @biscuitland/rest
## 2.0.0 ## 2.0.1
### Major Changes ### Major Changes
- publish - publish
### Patch Changes ### Patch Changes
- Updated dependencies - Updated dependencies
- @biscuitland/api-types@2.0.0 - @biscuitland/api-types@2.0.1

View File

@ -1,6 +1,6 @@
{ {
"name": "@biscuitland/rest", "name": "@biscuitland/rest",
"version": "2.0.0", "version": "2.0.1",
"main": "./dist/index.js", "main": "./dist/index.js",
"module": "./dist/index.mjs", "module": "./dist/index.mjs",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
@ -23,7 +23,7 @@
} }
}, },
"dependencies": { "dependencies": {
"@biscuitland/api-types": "^2.0.0" "@biscuitland/api-types": "^2.0.1"
}, },
"devDependencies": { "devDependencies": {
"tsup": "^6.1.3" "tsup": "^6.1.3"

View File

@ -1,12 +1,12 @@
# @biscuitland/ws # @biscuitland/ws
## 2.0.0 ## 2.0.1
### Major Changes ### Major Changes
- publish - publish
### Patch Changes ### Patch Changes
- Updated dependencies - Updated dependencies
- @biscuitland/api-types@2.0.0 - @biscuitland/api-types@2.0.1

View File

@ -1,6 +1,6 @@
{ {
"name": "@biscuitland/ws", "name": "@biscuitland/ws",
"version": "2.0.0", "version": "2.0.1",
"main": "./dist/index.js", "main": "./dist/index.js",
"module": "./dist/index.mjs", "module": "./dist/index.mjs",
"types": "./dist/index.d.ts", "types": "./dist/index.d.ts",
@ -23,7 +23,7 @@
} }
}, },
"dependencies": { "dependencies": {
"@biscuitland/api-types": "^2.0.0", "@biscuitland/api-types": "^2.0.1",
"ws": "^8.8.1" "ws": "^8.8.1"
}, },
"devDependencies": { "devDependencies": {

View File

@ -40,6 +40,14 @@ export interface LeakyBucket {
waiting: ((_?: unknown) => void)[]; waiting: ((_?: unknown) => void)[];
} }
export function delay(ms: number): Promise<void> {
return new Promise(result =>
setTimeout(() => {
result();
}, ms)
);
}
/** Update the tokens of that bucket. /** Update the tokens of that bucket.
* @returns {number} The amount of current available tokens. * @returns {number} The amount of current available tokens.
*/ */
@ -100,9 +108,7 @@ async function acquire(
const refillsNeeded = Math.ceil(tokensNeeded / bucket.refillAmount); const refillsNeeded = Math.ceil(tokensNeeded / bucket.refillAmount);
const waitTime = bucket.refillInterval * refillsNeeded; const waitTime = bucket.refillInterval * refillsNeeded;
// await delay(waitTime); await delay(waitTime);
await new Promise(() => setTimeout((): null => null, waitTime));
// Update the tokens again to ensure nothing has been missed. // Update the tokens again to ensure nothing has been missed.
updateTokens(bucket); updateTokens(bucket);