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
## 2.0.0
## 2.0.1
### Major Changes
- publish
- publish

View File

@ -25,7 +25,7 @@ import type { DiscordUser } from '@biscuitland/api-types';
## Example for [Deno](https://deno.land/)
```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

View File

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

View File

@ -5,7 +5,7 @@ export const BASE_URL = 'https://discord.com/api';
export const API_VERSION = 10;
/** 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 */
export const USER_AGENT = `DiscordBot (https://github.com/oasisjs/biscuit, v${BISCUIT_VERSION})`;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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