diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..a457722
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,13 @@
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+trim_trailing_whitespace = true
+insert_final_newline = true
+indent_style = tab
+indent_size = 4
+quote_type = single
+
+[Makefile]
+indent_style = tab
\ No newline at end of file
diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 0000000..f995260
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,4 @@
+node_modules/
+build
+dist
+examples/**
\ No newline at end of file
diff --git a/.eslintrc.js b/.eslintrc.js
new file mode 100644
index 0000000..bfaba0b
--- /dev/null
+++ b/.eslintrc.js
@@ -0,0 +1,175 @@
+module.exports = {
+ root: true,
+ env: {
+ browser: true,
+ es2020: true,
+ node: true,
+ },
+ extends: [
+ 'prettier',
+ 'eslint:recommended',
+ 'plugin:@typescript-eslint/eslint-recommended',
+ 'plugin:@typescript-eslint/recommended',
+ ],
+ ignorePatterns: [
+ 'node_modules',
+ 'dist',
+ 'coverage',
+ '**/*.js',
+ '**/*.d.ts',
+ ],
+ parser: '@typescript-eslint/parser',
+ parserOptions: {
+ project: 'tsconfig.json',
+ sourceType: 'module',
+ },
+ plugins: ['@typescript-eslint'],
+ global: {
+ NodeJS: true,
+ },
+ rules: {
+ '@typescript-eslint/consistent-type-imports': 'error',
+ '@typescript-eslint/no-duplicate-imports': 'error',
+ '@typescript-eslint/prefer-optional-chain': 'error',
+ '@typescript-eslint/no-explicit-any': 'off',
+ '@typescript-eslint/explicit-function-return-type': 'off',
+ '@typescript-eslint/no-non-null-assertion': 'off',
+ '@typescript-eslint/ban-ts-comment': 'off',
+ '@typescript-eslint/no-unused-vars': 'off',
+ '@typescript-eslint/naming-convention': [
+ 'error',
+ { selector: 'default', format: null },
+ {
+ selector: 'variable',
+ format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
+ },
+ { selector: 'typeLike', format: ['PascalCase'] },
+ ],
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
+ '@typescript-eslint/no-empty-interface': 'off',
+ '@typescript-eslint/adjacent-overload-signatures': 'error',
+ '@typescript-eslint/consistent-type-assertions': 'error',
+ '@typescript-eslint/no-array-constructor': 'error',
+ '@typescript-eslint/no-empty-function': 'error',
+ '@typescript-eslint/no-inferrable-types': 'error',
+ '@typescript-eslint/no-misused-new': 'error',
+ '@typescript-eslint/no-namespace': 'error',
+ '@typescript-eslint/no-this-alias': 'error',
+ '@typescript-eslint/no-use-before-define': 'error',
+ '@typescript-eslint/no-var-requires': 'error',
+ '@typescript-eslint/triple-slash-reference': 'error',
+ '@typescript-eslint/type-annotation-spacing': 'error',
+ '@typescript-eslint/array-type': 'error',
+ '@typescript-eslint/no-unnecessary-qualifier': 'error',
+ '@typescript-eslint/no-unnecessary-type-arguments': 'off', // disabled as it started to be buggy
+ '@typescript-eslint/quotes': [
+ 'error',
+ 'single',
+ { avoidEscape: true, allowTemplateLiterals: true },
+ ],
+ '@typescript-eslint/semi': ['error', 'always'],
+ '@typescript-eslint/no-useless-constructor': 'error',
+ '@typescript-eslint/no-redeclare': ['error'],
+ '@typescript-eslint/member-delimiter-style': [
+ 'error',
+ {
+ multiline: { delimiter: 'semi', requireLast: true },
+ singleline: { delimiter: 'semi', requireLast: false },
+ },
+ ],
+ '@typescript-eslint/space-before-function-paren': [
+ 'error',
+ {
+ anonymous: 'always',
+ named: 'never',
+ asyncArrow: 'always',
+ },
+ ],
+ 'arrow-parens': ['error', 'as-needed'],
+ 'no-var': 'error',
+ 'prefer-const': 'error',
+ 'prefer-rest-params': 'error',
+ 'prefer-spread': 'error',
+ 'constructor-super': 'error',
+ 'for-direction': 'error',
+ 'getter-return': 'error',
+ 'no-async-promise-executor': 'error',
+ 'no-case-declarations': 'error',
+ 'no-class-assign': 'error',
+ 'no-compare-neg-zero': 'error',
+ 'no-cond-assign': 'error',
+ 'no-const-assign': 'error',
+ 'no-constant-condition': 'error',
+ 'no-control-regex': 'error',
+ 'no-debugger': 'error',
+ 'no-delete-var': 'error',
+ 'no-dupe-args': 'error',
+ 'no-dupe-keys': 'error',
+ 'no-duplicate-case': 'error',
+ 'no-empty': 'error',
+ 'no-empty-character-class': 'error',
+ 'no-empty-pattern': 'error',
+ 'no-ex-assign': 'error',
+ 'no-extra-boolean-cast': 'error',
+ 'no-extra-semi': 'error',
+ 'no-fallthrough': 'error',
+ 'no-func-assign': 'error',
+ 'no-global-assign': 'error',
+ 'no-inner-declarations': 'error',
+ 'no-invalid-regexp': 'error',
+ 'no-irregular-whitespace': 'error',
+ 'no-misleading-character-class': 'error',
+ 'no-mixed-spaces-and-tabs': 'error',
+ 'no-new-symbol': 'error',
+ 'no-obj-calls': 'error',
+ 'no-octal': 'error',
+ 'no-prototype-builtins': 'error',
+ 'no-redeclare': 'off',
+ 'no-regex-spaces': 'error',
+ 'no-self-assign': 'error',
+ 'no-shadow-restricted-names': 'error',
+ 'no-sparse-arrays': 'error',
+ 'no-this-before-super': 'error',
+ 'no-undef': 'error',
+ 'no-unexpected-multiline': 'error',
+ 'no-unreachable': 'error',
+ 'no-unsafe-finally': 'error',
+ 'no-unsafe-negation': 'error',
+ 'no-unused-labels': 'error',
+ 'no-useless-catch': 'error',
+ 'no-useless-escape': 'error',
+ 'no-with': 'error',
+ 'require-yield': 'error',
+ 'use-isnan': 'error',
+ 'valid-typeof': 'error',
+ // 'comma-dangle': ['error', 'never'], // always-multiline
+ 'dot-notation': 'error',
+ 'eol-last': 'error',
+ eqeqeq: ['error', 'always', { null: 'ignore' }],
+ 'no-console': 'error',
+ 'no-duplicate-imports': 'off',
+ 'no-multiple-empty-lines': 'error',
+ 'no-throw-literal': 'error',
+ 'no-trailing-spaces': 'error',
+ 'no-undef-init': 'error',
+ 'object-shorthand': 'error',
+ 'quote-props': ['error', 'consistent-as-needed'],
+ 'spaced-comment': 'error',
+ yoda: 'error',
+ curly: 'error',
+ 'object-curly-spacing': ['error', 'always'],
+ 'lines-between-class-members': [
+ 'error',
+ 'always',
+ { exceptAfterSingleLine: true },
+ ],
+ 'padded-blocks': ['error', { classes: 'never' }], // always
+ 'no-else-return': 'error',
+ 'block-spacing': ['error', 'always'],
+ 'space-before-blocks': ['error', 'always'],
+ 'brace-style': ['error', '1tbs', { allowSingleLine: true }],
+ 'keyword-spacing': ['error', { before: true, after: true }],
+ 'space-in-parens': ['error', 'never'],
+ },
+ settings: {},
+};
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
deleted file mode 100644
index 5fcc662..0000000
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ /dev/null
@@ -1,23 +0,0 @@
----
-name: Bug report
-about: Bugs
-title: ''
-labels: Bug
-assignees: ''
-
----
-
-**Describe the bug** A clear and concise description of what the bug is.
-
-**Biscuit Version** eg: 0.1.0-rc7
-
-**To Reproduce** Steps to reproduce the behavior:
-
-1. Go to '...'
-2. Click on '....'
-3. Scroll down to '....'
-4. See error
-
-**Expected behavior** A clear and concise description of what you expected to happen.
-
-**etc** Whatever
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
deleted file mode 100644
index 68ca28b..0000000
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ /dev/null
@@ -1,18 +0,0 @@
----
-name: Feature request
-about: Suggestions
-title: ''
-labels: Feature
-assignees: ''
-
----
-
-**Is your feature request related to a problem? Please describe.** A clear and concise description of what the problem
-is. Ex. I'm always frustrated when [...]
-
-**Describe the solution you'd like** A clear and concise description of what you want to happen.
-
-**Describe alternatives you've considered** A clear and concise description of any alternative solutions or features
-you've considered.
-
-**Limitations** A set of limitations of the API or the library by itself
diff --git a/.gitignore b/.gitignore
index d018c72..0f1d343 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,18 +1,50 @@
-# editors
-.vim/
-.vscode/
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
-# build
-npm/
-
-# etc
+# Enviorment
.env
-# Examples
-node_modules/
-package-lock.json
-package.json
-bun.lockb
+# NPM
+npm/
-# Docs
-docs.json
\ No newline at end of file
+# DOCS
+docs.json
+packages/core/docs.json
+
+# dependencies
+node_modules
+.pnp
+.pnp.js
+
+# testing
+coverage
+
+# node
+out/
+dist/
+build
+package-lock.json
+
+# misc
+.DS_Store
+*.pem
+*.vs
+
+# debug
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+.pnpm-debug.log*
+
+# local env files
+.env.local
+.env.development.local
+.env.test.local
+.env.production.local
+.env
+
+# turbo
+.turbo
+
+# tests
+__tests__
+__test__
\ No newline at end of file
diff --git a/.prettierrc.js b/.prettierrc.js
new file mode 100644
index 0000000..1a9f151
--- /dev/null
+++ b/.prettierrc.js
@@ -0,0 +1,4 @@
+module.exports = {
+ arrowParens: 'avoid',
+ singleQuote: true,
+};
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..751ee7a
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,5 @@
+{
+ "editor.tabSize": 4,
+ "editor.insertSpaces": false,
+ "editor.detectIndentation": true
+}
\ No newline at end of file
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..e69de29
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..e69de29
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 261eeb9..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
diff --git a/README.md b/README.md
index 2dddcea..e69de29 100644
--- a/README.md
+++ b/README.md
@@ -1,92 +0,0 @@
-# biscuit
-
-## A brand new bleeding edge non bloated Discord library
-
-[](https://nest.land/package/biscuit)
-[](https://www.npmjs.com/package/@oasisjs/biscuit)
-[](https://www.npmjs.com/package/@oasisjs/biscuit)
-[](https://deno.land/x/biscuit)
-
-
-
-### Install (for [node18](https://nodejs.org/en/download/))
-
-```sh-session
-npm install @oasisjs/biscuit
-pnpm add @oasisjs/biscuit
-yarn add @oasisjs/biscuit
-```
-
-get a quick bot: `deno run --allow-net https://crux.land/2CENgN [token]`
-
-The biscuit Discord library is built ontop of Discordeno and webspec APIs, we aim to provide portability. Join our
-[Discord](https://discord.gg/zmuvzzEFz2)
-
-### Most importantly, biscuit is:
-
-- A modular [Discordeno](https://github.com/discordeno/discordeno) fork
-- A framework to build Discord bots
-- A bleeding edge API to contact Discord
-
-Biscuit is primarily inspired by Discord.js and Discordeno but it does not include a cache layer by default, we believe
-that you should not make software that does things it is not supposed to do.
-
-### Why biscuit?:
-
-- [Minimal](https://en.wikipedia.org/wiki/Unix_philosophy), non feature-rich!
-- Crossplatform
-- Consistent
-- Performant
-- Small bundles
-
-### Example bot (TS/JS)
-
-```js
-import Biscuit, { GatewayIntents } from '@oasisjs/biscuit';
-
-const intents = GatewayIntents.MessageContent | GatewayIntents.Guilds | GatewayIntents.GuildMessages;
-const session = new Biscuit({ token: 'your token', intents });
-
-session.on('ready', ({ user }) => {
- console.log('Logged in as:', user.username);
-});
-
-session.on('messageCreate', (message) => {
- if (message.content.startsWith('!ping')) {
- message.reply({ content: 'pong!' });
- }
-});
-
-session.start();
-```
-
-### Minimal style guide
-
-- 4 spaces, no tabs
-- Semi-colons are mandatory
-- Run `deno fmt`
-- Avoid circular dependencies
-
-### Contrib guide
-
-- Install Deno extension [here](https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno)
-- Run `deno check` to make sure the library works
-- Avoid sharing state between classes
-
-### Compatibility (bun)
-
-**⚠️ DISCLAIMER:** since bun is unstable I highly recommend running biscuit on node!
-
-- We got the library running on EndeavourOS but it spams the ready event multiple times
-- We got the library running on Arch/Artix Linux but breaks when sending fetch requests
-- We got the library running on WSL (Ubuntu) without any trouble
-
-> if you really want to use the library with bun remember to clone the repo instead of installing it via the registry
-
-### Known issues:
-
-- some properties may be not implemented yet
-- some structures are not implemented (see https://github.com/oasisjs/biscuit/issues)
-- cache (wip)
-- no optimal way to create embeds, should be fixed in builders tho
-- no optimal way to deliver a webspec bun version to the registry (#50)
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 0000000..e69de29
diff --git a/examples/.env.example b/examples/.env.example
new file mode 100644
index 0000000..e69de29
diff --git a/examples/package.json b/examples/package.json
new file mode 100644
index 0000000..368ef5e
--- /dev/null
+++ b/examples/package.json
@@ -0,0 +1,6 @@
+{
+ "name": "examples",
+ "dependencies": {
+ "dotenv": "^16.0.1"
+ }
+}
diff --git a/examples/src/index.ts b/examples/src/index.ts
new file mode 100644
index 0000000..90541b0
--- /dev/null
+++ b/examples/src/index.ts
@@ -0,0 +1,69 @@
+import './utils/experimental.util';
+import 'dotenv/config';
+
+import { colors } from './utils/colors.util';
+
+import { DefaultRestAdapter } from '@biscuitland/rest';
+import { DefaultWsAdapter } from '@biscuitland/ws';
+
+import { GatewayIntents } from '@biscuitland/api-types';
+import { Biscuit } from '@biscuitland/core';
+
+import { ReadyEvent } from './operations';
+import { MeRest } from './operations';
+
+import { AgentWs } from './operations';
+
+const argv = process.argv.slice(2);
+
+const boostrap = async () => {
+ const biscuit = new Biscuit({
+ intents: GatewayIntents.Guilds,
+ token: process.env.AUTH!,
+ });
+
+ await biscuit.start();
+ await operations(biscuit);
+};
+
+const operations = async (biscuit: Biscuit) => {
+ switch (argv[0]) {
+ case '--events':
+ console.log(colors.cyan('Starting examples of events'));
+
+ switch (argv[1]) {
+ case 'ready':
+ new ReadyEvent(biscuit.events);
+
+ break;
+ }
+
+ break;
+
+ case '--rest':
+ console.log(colors.cyan('Starting examples of rest'));
+
+ switch (argv[1]) {
+ case 'me':
+ new MeRest(biscuit.rest as DefaultRestAdapter);
+
+ break;
+ }
+
+ break;
+
+ case '--ws':
+ console.log(colors.cyan('Starting examples of ws'));
+
+ switch (argv[1]) {
+ case 'agent':
+ new AgentWs(biscuit.ws as DefaultWsAdapter);
+
+ break;
+ }
+
+ break;
+ }
+};
+
+boostrap();
diff --git a/examples/src/operations/events/ready.ws.ts b/examples/src/operations/events/ready.ws.ts
new file mode 100644
index 0000000..e9a21bb
--- /dev/null
+++ b/examples/src/operations/events/ready.ws.ts
@@ -0,0 +1,17 @@
+import { EventAdapter } from '@biscuitland/core';
+
+export class ReadyEvent {
+ events: EventAdapter;
+
+ constructor(events: EventAdapter) {
+ this.events = events;
+
+ if (events) {
+ this.execute();
+ }
+ }
+
+ async execute() {
+ this.events.on('ready', () => console.log('[1/1] successful'));
+ }
+}
diff --git a/examples/src/operations/index.ts b/examples/src/operations/index.ts
new file mode 100644
index 0000000..25ca8a0
--- /dev/null
+++ b/examples/src/operations/index.ts
@@ -0,0 +1,8 @@
+/** events */
+export { ReadyEvent } from './events/ready.ws';
+
+/** rest */
+export { MeRest } from './rest/me.rest';
+
+/** ws */
+export { AgentWs } from './ws/agent.ws';
diff --git a/examples/src/operations/rest/me.rest.ts b/examples/src/operations/rest/me.rest.ts
new file mode 100644
index 0000000..f6bc837
--- /dev/null
+++ b/examples/src/operations/rest/me.rest.ts
@@ -0,0 +1,22 @@
+import { DiscordUser } from '@biscuitland/api-types';
+import { DefaultRestAdapter } from '@biscuitland/rest';
+
+export class MeRest {
+ rest: DefaultRestAdapter;
+
+ constructor(rest: DefaultRestAdapter) {
+ this.rest = rest;
+
+ if (rest) {
+ this.execute();
+ }
+ }
+
+ async execute() {
+ const { username } = await this.rest.get('/users/@me');
+
+ if (username) {
+ console.log('[1/1] successful [%s]', username);
+ }
+ }
+}
diff --git a/examples/src/operations/ws/agent.ws.ts b/examples/src/operations/ws/agent.ws.ts
new file mode 100644
index 0000000..0cfdceb
--- /dev/null
+++ b/examples/src/operations/ws/agent.ws.ts
@@ -0,0 +1,23 @@
+import { DefaultWsAdapter } from '@biscuitland/ws';
+
+export class AgentWs {
+ ws: DefaultWsAdapter;
+
+ constructor(ws: DefaultWsAdapter) {
+ this.ws = ws;
+
+ if (ws) {
+ this.execute();
+ }
+ }
+
+ async execute() {
+ const shard = this.ws.agent.shards.get(0);
+
+ if (shard && shard.socket) {
+ shard.socket.onmessage = (_message: any) => {
+ // operations
+ };
+ }
+ }
+}
diff --git a/examples/src/utils/colors.util.ts b/examples/src/utils/colors.util.ts
new file mode 100644
index 0000000..1ed6509
--- /dev/null
+++ b/examples/src/utils/colors.util.ts
@@ -0,0 +1,7 @@
+const wrap = (fn: (text: string) => string) => (text: string) => fn(text);
+
+export const colors = {
+ yellow: wrap((text: string) => `\x1b[33m${text}\x1B[39m`),
+ white: wrap((text: string) => `\x1b[37m${text}\x1B[39m`),
+ cyan: wrap((text: string) => `\x1b[36m${text}\x1B[39m`),
+};
diff --git a/examples/src/utils/experimental.util.ts b/examples/src/utils/experimental.util.ts
new file mode 100644
index 0000000..b882320
--- /dev/null
+++ b/examples/src/utils/experimental.util.ts
@@ -0,0 +1,15 @@
+const originalEmit = process.emit;
+
+// @ts-ignore
+process.emit = function (name, data: any, ..._args: any[]) {
+ if (
+ name === `warning` &&
+ typeof data === `object` &&
+ data.name === `ExperimentalWarning`
+ ) {
+ return false;
+ }
+
+ // @ts-ignore
+ return originalEmit.apply(process, arguments);
+};
diff --git a/examples/tsconfig.json b/examples/tsconfig.json
new file mode 100644
index 0000000..dc5a799
--- /dev/null
+++ b/examples/tsconfig.json
@@ -0,0 +1,31 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "target": "esnext",
+ "lib": ["es2020"],
+ "moduleResolution": "node",
+ "declaration": true,
+ "sourceMap": false,
+ "strict": true,
+ "suppressImplicitAnyIndexErrors": true,
+ "esModuleInterop": true,
+ "experimentalDecorators": true,
+ "emitDecoratorMetadata": true,
+ "preserveConstEnums": true,
+
+ "outDir": "dist",
+
+ /* Type Checking */
+ "noImplicitAny": true,
+ "strictNullChecks": true,
+ "strictFunctionTypes": true,
+ "noImplicitThis": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noImplicitReturns": true,
+ "noFallthroughCasesInSwitch": true,
+ "skipLibCheck": true
+ },
+ "exclude": ["**/node_modules", "**/dist"],
+ "include": ["src/**/*"]
+}
diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 0000000..1e43019
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,3906 @@
+{
+ "name": "biscuit",
+ "lockfileVersion": 2,
+ "requires": true,
+ "packages": {
+ "": {
+ "name": "biscuit",
+ "workspaces": [
+ "packages/*"
+ ],
+ "devDependencies": {
+ "@types/node": "^18.0.6",
+ "@typescript-eslint/eslint-plugin": "^5.30.7",
+ "@typescript-eslint/parser": "^5.30.7",
+ "eslint": "^8.20.0",
+ "eslint-config-prettier": "^8.5.0",
+ "ts-node": "^10.9.1",
+ "turbo": "^1.3.4",
+ "typescript": "^4.7.4"
+ },
+ "engines": {
+ "node": ">=14.0.0",
+ "npm": ">=7.0.0"
+ }
+ },
+ "node_modules/@biscuitland/api-types": {
+ "resolved": "packages/api-types",
+ "link": true
+ },
+ "node_modules/@biscuitland/cache": {
+ "resolved": "packages/cache",
+ "link": true
+ },
+ "node_modules/@biscuitland/core": {
+ "resolved": "packages/core",
+ "link": true
+ },
+ "node_modules/@biscuitland/logger": {
+ "resolved": "packages/logger",
+ "link": true
+ },
+ "node_modules/@biscuitland/rest": {
+ "resolved": "packages/rest",
+ "link": true
+ },
+ "node_modules/@biscuitland/ws": {
+ "resolved": "packages/ws",
+ "link": true
+ },
+ "node_modules/@cspotcode/source-map-support": {
+ "version": "0.8.1",
+ "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
+ "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
+ "dev": true,
+ "dependencies": {
+ "@jridgewell/trace-mapping": "0.3.9"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/@humanwhocodes/object-schema": {
+ "version": "1.2.1",
+ "dev": true,
+ "license": "BSD-3-Clause"
+ },
+ "node_modules/@ioredis/commands": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz",
+ "integrity": "sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg=="
+ },
+ "node_modules/@jridgewell/resolve-uri": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz",
+ "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==",
+ "dev": true,
+ "engines": {
+ "node": ">=6.0.0"
+ }
+ },
+ "node_modules/@jridgewell/sourcemap-codec": {
+ "version": "1.4.14",
+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz",
+ "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==",
+ "dev": true
+ },
+ "node_modules/@jridgewell/trace-mapping": {
+ "version": "0.3.9",
+ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
+ "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
+ "dev": true,
+ "dependencies": {
+ "@jridgewell/resolve-uri": "^3.0.3",
+ "@jridgewell/sourcemap-codec": "^1.4.10"
+ }
+ },
+ "node_modules/@nodelib/fs.scandir": {
+ "version": "2.1.5",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@nodelib/fs.stat": "2.0.5",
+ "run-parallel": "^1.1.9"
+ },
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/@nodelib/fs.stat": {
+ "version": "2.0.5",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/@nodelib/fs.walk": {
+ "version": "1.2.8",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@nodelib/fs.scandir": "2.1.5",
+ "fastq": "^1.6.0"
+ },
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/@tsconfig/node10": {
+ "version": "1.0.9",
+ "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz",
+ "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==",
+ "dev": true
+ },
+ "node_modules/@tsconfig/node12": {
+ "version": "1.0.11",
+ "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz",
+ "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==",
+ "dev": true
+ },
+ "node_modules/@tsconfig/node14": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz",
+ "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==",
+ "dev": true
+ },
+ "node_modules/@tsconfig/node16": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz",
+ "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==",
+ "dev": true
+ },
+ "node_modules/@types/json-schema": {
+ "version": "7.0.11",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/@types/node": {
+ "version": "18.0.6",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.0.6.tgz",
+ "integrity": "sha512-/xUq6H2aQm261exT6iZTMifUySEt4GR5KX8eYyY+C4MSNPqSh9oNIP7tz2GLKTlFaiBbgZNxffoR3CVRG+cljw==",
+ "dev": true
+ },
+ "node_modules/@types/ws": {
+ "version": "8.5.3",
+ "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.3.tgz",
+ "integrity": "sha512-6YOoWjruKj1uLf3INHH7D3qTXwFfEsg1kf3c0uDdSBJwfa/llkwIjrAGV7j7mVgGNbzTQ3HiHKKDXl6bJPD97w==",
+ "dev": true,
+ "dependencies": {
+ "@types/node": "*"
+ }
+ },
+ "node_modules/@typescript-eslint/eslint-plugin": {
+ "version": "5.30.7",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@typescript-eslint/scope-manager": "5.30.7",
+ "@typescript-eslint/type-utils": "5.30.7",
+ "@typescript-eslint/utils": "5.30.7",
+ "debug": "^4.3.4",
+ "functional-red-black-tree": "^1.0.1",
+ "ignore": "^5.2.0",
+ "regexpp": "^3.2.0",
+ "semver": "^7.3.7",
+ "tsutils": "^3.21.0"
+ },
+ "engines": {
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ },
+ "peerDependencies": {
+ "@typescript-eslint/parser": "^5.0.0",
+ "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
+ },
+ "peerDependenciesMeta": {
+ "typescript": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@typescript-eslint/parser": {
+ "version": "5.30.7",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "dependencies": {
+ "@typescript-eslint/scope-manager": "5.30.7",
+ "@typescript-eslint/types": "5.30.7",
+ "@typescript-eslint/typescript-estree": "5.30.7",
+ "debug": "^4.3.4"
+ },
+ "engines": {
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ },
+ "peerDependencies": {
+ "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
+ },
+ "peerDependenciesMeta": {
+ "typescript": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@typescript-eslint/scope-manager": {
+ "version": "5.30.7",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@typescript-eslint/types": "5.30.7",
+ "@typescript-eslint/visitor-keys": "5.30.7"
+ },
+ "engines": {
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ }
+ },
+ "node_modules/@typescript-eslint/type-utils": {
+ "version": "5.30.7",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@typescript-eslint/utils": "5.30.7",
+ "debug": "^4.3.4",
+ "tsutils": "^3.21.0"
+ },
+ "engines": {
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ },
+ "peerDependencies": {
+ "eslint": "*"
+ },
+ "peerDependenciesMeta": {
+ "typescript": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@typescript-eslint/types": {
+ "version": "5.30.7",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ }
+ },
+ "node_modules/@typescript-eslint/typescript-estree": {
+ "version": "5.30.7",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "dependencies": {
+ "@typescript-eslint/types": "5.30.7",
+ "@typescript-eslint/visitor-keys": "5.30.7",
+ "debug": "^4.3.4",
+ "globby": "^11.1.0",
+ "is-glob": "^4.0.3",
+ "semver": "^7.3.7",
+ "tsutils": "^3.21.0"
+ },
+ "engines": {
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ },
+ "peerDependenciesMeta": {
+ "typescript": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@typescript-eslint/utils": {
+ "version": "5.30.7",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/json-schema": "^7.0.9",
+ "@typescript-eslint/scope-manager": "5.30.7",
+ "@typescript-eslint/types": "5.30.7",
+ "@typescript-eslint/typescript-estree": "5.30.7",
+ "eslint-scope": "^5.1.1",
+ "eslint-utils": "^3.0.0"
+ },
+ "engines": {
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ },
+ "peerDependencies": {
+ "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
+ }
+ },
+ "node_modules/@typescript-eslint/visitor-keys": {
+ "version": "5.30.7",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@typescript-eslint/types": "5.30.7",
+ "eslint-visitor-keys": "^3.3.0"
+ },
+ "engines": {
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ }
+ },
+ "node_modules/acorn": {
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz",
+ "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==",
+ "dev": true,
+ "bin": {
+ "acorn": "bin/acorn"
+ },
+ "engines": {
+ "node": ">=0.4.0"
+ }
+ },
+ "node_modules/acorn-jsx": {
+ "version": "5.3.2",
+ "dev": true,
+ "license": "MIT",
+ "peerDependencies": {
+ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
+ }
+ },
+ "node_modules/acorn-walk": {
+ "version": "8.2.0",
+ "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
+ "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==",
+ "dev": true,
+ "engines": {
+ "node": ">=0.4.0"
+ }
+ },
+ "node_modules/ajv": {
+ "version": "6.12.6",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "fast-deep-equal": "^3.1.1",
+ "fast-json-stable-stringify": "^2.0.0",
+ "json-schema-traverse": "^0.4.1",
+ "uri-js": "^4.2.2"
+ },
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/epoberezkin"
+ }
+ },
+ "node_modules/ansi-regex": {
+ "version": "5.0.1",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/ansi-styles": {
+ "version": "4.3.0",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "color-convert": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/ansi-styles?sponsor=1"
+ }
+ },
+ "node_modules/any-promise": {
+ "version": "1.3.0",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/anymatch": {
+ "version": "3.1.2",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "normalize-path": "^3.0.0",
+ "picomatch": "^2.0.4"
+ },
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/arg": {
+ "version": "4.1.3",
+ "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
+ "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==",
+ "dev": true
+ },
+ "node_modules/array-union": {
+ "version": "2.1.0",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/balanced-match": {
+ "version": "1.0.2",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/binary-extensions": {
+ "version": "2.2.0",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/brace-expansion": {
+ "version": "1.1.11",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "balanced-match": "^1.0.0",
+ "concat-map": "0.0.1"
+ }
+ },
+ "node_modules/braces": {
+ "version": "3.0.2",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "fill-range": "^7.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/bundle-require": {
+ "version": "3.0.4",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "load-tsconfig": "^0.2.0"
+ },
+ "engines": {
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
+ },
+ "peerDependencies": {
+ "esbuild": ">=0.13"
+ }
+ },
+ "node_modules/cac": {
+ "version": "6.7.12",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/callsites": {
+ "version": "3.1.0",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
+ "node_modules/chalk": {
+ "version": "4.1.2",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "ansi-styles": "^4.1.0",
+ "supports-color": "^7.1.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/chalk?sponsor=1"
+ }
+ },
+ "node_modules/chokidar": {
+ "version": "3.5.3",
+ "dev": true,
+ "funding": [
+ {
+ "type": "individual",
+ "url": "https://paulmillr.com/funding/"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "anymatch": "~3.1.2",
+ "braces": "~3.0.2",
+ "glob-parent": "~5.1.2",
+ "is-binary-path": "~2.1.0",
+ "is-glob": "~4.0.1",
+ "normalize-path": "~3.0.0",
+ "readdirp": "~3.6.0"
+ },
+ "engines": {
+ "node": ">= 8.10.0"
+ },
+ "optionalDependencies": {
+ "fsevents": "~2.3.2"
+ }
+ },
+ "node_modules/cluster-key-slot": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.0.tgz",
+ "integrity": "sha512-2Nii8p3RwAPiFwsnZvukotvow2rIHM+yQ6ZcBXGHdniadkYGZYiGmkHJIbZPIV9nfv7m/U1IPMVVcAhoWFeklw==",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/color-convert": {
+ "version": "2.0.1",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "color-name": "~1.1.4"
+ },
+ "engines": {
+ "node": ">=7.0.0"
+ }
+ },
+ "node_modules/color-name": {
+ "version": "1.1.4",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/commander": {
+ "version": "4.1.1",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 6"
+ }
+ },
+ "node_modules/concat-map": {
+ "version": "0.0.1",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/create-require": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
+ "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
+ "dev": true
+ },
+ "node_modules/cross-spawn": {
+ "version": "7.0.3",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "path-key": "^3.1.0",
+ "shebang-command": "^2.0.0",
+ "which": "^2.0.1"
+ },
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/debug": {
+ "version": "4.3.4",
+ "license": "MIT",
+ "dependencies": {
+ "ms": "2.1.2"
+ },
+ "engines": {
+ "node": ">=6.0"
+ },
+ "peerDependenciesMeta": {
+ "supports-color": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/deep-is": {
+ "version": "0.1.4",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/denque": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz",
+ "integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==",
+ "engines": {
+ "node": ">=0.10"
+ }
+ },
+ "node_modules/diff": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
+ "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
+ "dev": true,
+ "engines": {
+ "node": ">=0.3.1"
+ }
+ },
+ "node_modules/dir-glob": {
+ "version": "3.0.1",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "path-type": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/doctrine": {
+ "version": "3.0.0",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "esutils": "^2.0.2"
+ },
+ "engines": {
+ "node": ">=6.0.0"
+ }
+ },
+ "node_modules/esbuild": {
+ "version": "0.14.49",
+ "dev": true,
+ "hasInstallScript": true,
+ "license": "MIT",
+ "bin": {
+ "esbuild": "bin/esbuild"
+ },
+ "engines": {
+ "node": ">=12"
+ },
+ "optionalDependencies": {
+ "esbuild-android-64": "0.14.49",
+ "esbuild-android-arm64": "0.14.49",
+ "esbuild-darwin-64": "0.14.49",
+ "esbuild-darwin-arm64": "0.14.49",
+ "esbuild-freebsd-64": "0.14.49",
+ "esbuild-freebsd-arm64": "0.14.49",
+ "esbuild-linux-32": "0.14.49",
+ "esbuild-linux-64": "0.14.49",
+ "esbuild-linux-arm": "0.14.49",
+ "esbuild-linux-arm64": "0.14.49",
+ "esbuild-linux-mips64le": "0.14.49",
+ "esbuild-linux-ppc64le": "0.14.49",
+ "esbuild-linux-riscv64": "0.14.49",
+ "esbuild-linux-s390x": "0.14.49",
+ "esbuild-netbsd-64": "0.14.49",
+ "esbuild-openbsd-64": "0.14.49",
+ "esbuild-sunos-64": "0.14.49",
+ "esbuild-windows-32": "0.14.49",
+ "esbuild-windows-64": "0.14.49",
+ "esbuild-windows-arm64": "0.14.49"
+ }
+ },
+ "node_modules/esbuild-windows-64": {
+ "version": "0.14.49",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/escape-string-regexp": {
+ "version": "4.0.0",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/eslint": {
+ "version": "8.20.0",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@eslint/eslintrc": "^1.3.0",
+ "@humanwhocodes/config-array": "^0.9.2",
+ "ajv": "^6.10.0",
+ "chalk": "^4.0.0",
+ "cross-spawn": "^7.0.2",
+ "debug": "^4.3.2",
+ "doctrine": "^3.0.0",
+ "escape-string-regexp": "^4.0.0",
+ "eslint-scope": "^7.1.1",
+ "eslint-utils": "^3.0.0",
+ "eslint-visitor-keys": "^3.3.0",
+ "espree": "^9.3.2",
+ "esquery": "^1.4.0",
+ "esutils": "^2.0.2",
+ "fast-deep-equal": "^3.1.3",
+ "file-entry-cache": "^6.0.1",
+ "functional-red-black-tree": "^1.0.1",
+ "glob-parent": "^6.0.1",
+ "globals": "^13.15.0",
+ "ignore": "^5.2.0",
+ "import-fresh": "^3.0.0",
+ "imurmurhash": "^0.1.4",
+ "is-glob": "^4.0.0",
+ "js-yaml": "^4.1.0",
+ "json-stable-stringify-without-jsonify": "^1.0.1",
+ "levn": "^0.4.1",
+ "lodash.merge": "^4.6.2",
+ "minimatch": "^3.1.2",
+ "natural-compare": "^1.4.0",
+ "optionator": "^0.9.1",
+ "regexpp": "^3.2.0",
+ "strip-ansi": "^6.0.1",
+ "strip-json-comments": "^3.1.0",
+ "text-table": "^0.2.0",
+ "v8-compile-cache": "^2.0.3"
+ },
+ "bin": {
+ "eslint": "bin/eslint.js"
+ },
+ "engines": {
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/eslint"
+ }
+ },
+ "node_modules/eslint-config-prettier": {
+ "version": "8.5.0",
+ "dev": true,
+ "license": "MIT",
+ "bin": {
+ "eslint-config-prettier": "bin/cli.js"
+ },
+ "peerDependencies": {
+ "eslint": ">=7.0.0"
+ }
+ },
+ "node_modules/eslint-scope": {
+ "version": "5.1.1",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "dependencies": {
+ "esrecurse": "^4.3.0",
+ "estraverse": "^4.1.1"
+ },
+ "engines": {
+ "node": ">=8.0.0"
+ }
+ },
+ "node_modules/eslint-scope/node_modules/estraverse": {
+ "version": "4.3.0",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "engines": {
+ "node": ">=4.0"
+ }
+ },
+ "node_modules/eslint-utils": {
+ "version": "3.0.0",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "eslint-visitor-keys": "^2.0.0"
+ },
+ "engines": {
+ "node": "^10.0.0 || ^12.0.0 || >= 14.0.0"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/mysticatea"
+ },
+ "peerDependencies": {
+ "eslint": ">=5"
+ }
+ },
+ "node_modules/eslint-utils/node_modules/eslint-visitor-keys": {
+ "version": "2.1.0",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/eslint-visitor-keys": {
+ "version": "3.3.0",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
+ }
+ },
+ "node_modules/eslint/node_modules/@eslint/eslintrc": {
+ "version": "1.3.0",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "ajv": "^6.12.4",
+ "debug": "^4.3.2",
+ "espree": "^9.3.2",
+ "globals": "^13.15.0",
+ "ignore": "^5.2.0",
+ "import-fresh": "^3.2.1",
+ "js-yaml": "^4.1.0",
+ "minimatch": "^3.1.2",
+ "strip-json-comments": "^3.1.1"
+ },
+ "engines": {
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
+ }
+ },
+ "node_modules/eslint/node_modules/@humanwhocodes/config-array": {
+ "version": "0.9.5",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "@humanwhocodes/object-schema": "^1.2.1",
+ "debug": "^4.1.1",
+ "minimatch": "^3.0.4"
+ },
+ "engines": {
+ "node": ">=10.10.0"
+ }
+ },
+ "node_modules/eslint/node_modules/argparse": {
+ "version": "2.0.1",
+ "dev": true,
+ "license": "Python-2.0"
+ },
+ "node_modules/eslint/node_modules/eslint-scope": {
+ "version": "7.1.1",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "dependencies": {
+ "esrecurse": "^4.3.0",
+ "estraverse": "^5.2.0"
+ },
+ "engines": {
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
+ }
+ },
+ "node_modules/eslint/node_modules/espree": {
+ "version": "9.3.2",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "dependencies": {
+ "acorn": "^8.7.1",
+ "acorn-jsx": "^5.3.2",
+ "eslint-visitor-keys": "^3.3.0"
+ },
+ "engines": {
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
+ }
+ },
+ "node_modules/eslint/node_modules/glob-parent": {
+ "version": "6.0.2",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "is-glob": "^4.0.3"
+ },
+ "engines": {
+ "node": ">=10.13.0"
+ }
+ },
+ "node_modules/eslint/node_modules/js-yaml": {
+ "version": "4.1.0",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "argparse": "^2.0.1"
+ },
+ "bin": {
+ "js-yaml": "bin/js-yaml.js"
+ }
+ },
+ "node_modules/esquery": {
+ "version": "1.4.0",
+ "dev": true,
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "estraverse": "^5.1.0"
+ },
+ "engines": {
+ "node": ">=0.10"
+ }
+ },
+ "node_modules/esrecurse": {
+ "version": "4.3.0",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "dependencies": {
+ "estraverse": "^5.2.0"
+ },
+ "engines": {
+ "node": ">=4.0"
+ }
+ },
+ "node_modules/estraverse": {
+ "version": "5.3.0",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "engines": {
+ "node": ">=4.0"
+ }
+ },
+ "node_modules/esutils": {
+ "version": "2.0.3",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/execa": {
+ "version": "5.1.1",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "cross-spawn": "^7.0.3",
+ "get-stream": "^6.0.0",
+ "human-signals": "^2.1.0",
+ "is-stream": "^2.0.0",
+ "merge-stream": "^2.0.0",
+ "npm-run-path": "^4.0.1",
+ "onetime": "^5.1.2",
+ "signal-exit": "^3.0.3",
+ "strip-final-newline": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sindresorhus/execa?sponsor=1"
+ }
+ },
+ "node_modules/fast-deep-equal": {
+ "version": "3.1.3",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/fast-glob": {
+ "version": "3.2.11",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@nodelib/fs.stat": "^2.0.2",
+ "@nodelib/fs.walk": "^1.2.3",
+ "glob-parent": "^5.1.2",
+ "merge2": "^1.3.0",
+ "micromatch": "^4.0.4"
+ },
+ "engines": {
+ "node": ">=8.6.0"
+ }
+ },
+ "node_modules/fast-json-stable-stringify": {
+ "version": "2.1.0",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/fast-levenshtein": {
+ "version": "2.0.6",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/fastq": {
+ "version": "1.13.0",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "reusify": "^1.0.4"
+ }
+ },
+ "node_modules/file-entry-cache": {
+ "version": "6.0.1",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "flat-cache": "^3.0.4"
+ },
+ "engines": {
+ "node": "^10.12.0 || >=12.0.0"
+ }
+ },
+ "node_modules/fill-range": {
+ "version": "7.0.1",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "to-regex-range": "^5.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/flat-cache": {
+ "version": "3.0.4",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "flatted": "^3.1.0",
+ "rimraf": "^3.0.2"
+ },
+ "engines": {
+ "node": "^10.12.0 || >=12.0.0"
+ }
+ },
+ "node_modules/flatted": {
+ "version": "3.2.6",
+ "dev": true,
+ "license": "ISC"
+ },
+ "node_modules/fs.realpath": {
+ "version": "1.0.0",
+ "dev": true,
+ "license": "ISC"
+ },
+ "node_modules/functional-red-black-tree": {
+ "version": "1.0.1",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/get-stream": {
+ "version": "6.0.1",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/glob": {
+ "version": "7.1.7",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "fs.realpath": "^1.0.0",
+ "inflight": "^1.0.4",
+ "inherits": "2",
+ "minimatch": "^3.0.4",
+ "once": "^1.3.0",
+ "path-is-absolute": "^1.0.0"
+ },
+ "engines": {
+ "node": "*"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
+ "node_modules/glob-parent": {
+ "version": "5.1.2",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "is-glob": "^4.0.1"
+ },
+ "engines": {
+ "node": ">= 6"
+ }
+ },
+ "node_modules/globals": {
+ "version": "13.16.0",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "type-fest": "^0.20.2"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/globby": {
+ "version": "11.1.0",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "array-union": "^2.1.0",
+ "dir-glob": "^3.0.1",
+ "fast-glob": "^3.2.9",
+ "ignore": "^5.2.0",
+ "merge2": "^1.4.1",
+ "slash": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/has-flag": {
+ "version": "4.0.0",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/human-signals": {
+ "version": "2.1.0",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=10.17.0"
+ }
+ },
+ "node_modules/ignore": {
+ "version": "5.2.0",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 4"
+ }
+ },
+ "node_modules/import-fresh": {
+ "version": "3.3.0",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "parent-module": "^1.0.0",
+ "resolve-from": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/imurmurhash": {
+ "version": "0.1.4",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.8.19"
+ }
+ },
+ "node_modules/inflight": {
+ "version": "1.0.6",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "once": "^1.3.0",
+ "wrappy": "1"
+ }
+ },
+ "node_modules/inherits": {
+ "version": "2.0.4",
+ "dev": true,
+ "license": "ISC"
+ },
+ "node_modules/ioredis": {
+ "version": "5.2.2",
+ "resolved": "https://registry.npmjs.org/ioredis/-/ioredis-5.2.2.tgz",
+ "integrity": "sha512-wryKc1ur8PcCmNwfcGkw5evouzpbDXxxkMkzPK8wl4xQfQf7lHe11Jotell5ikMVAtikXJEu/OJVaoV51BggRQ==",
+ "dependencies": {
+ "@ioredis/commands": "^1.1.1",
+ "cluster-key-slot": "^1.1.0",
+ "debug": "^4.3.4",
+ "denque": "^2.0.1",
+ "lodash.defaults": "^4.2.0",
+ "lodash.isarguments": "^3.1.0",
+ "redis-errors": "^1.2.0",
+ "redis-parser": "^3.0.0",
+ "standard-as-callback": "^2.1.0"
+ },
+ "engines": {
+ "node": ">=12.22.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/ioredis"
+ }
+ },
+ "node_modules/is-binary-path": {
+ "version": "2.1.0",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "binary-extensions": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/is-extglob": {
+ "version": "2.1.1",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/is-glob": {
+ "version": "4.0.3",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "is-extglob": "^2.1.1"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/is-number": {
+ "version": "7.0.0",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.12.0"
+ }
+ },
+ "node_modules/is-stream": {
+ "version": "2.0.1",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/isexe": {
+ "version": "2.0.0",
+ "dev": true,
+ "license": "ISC"
+ },
+ "node_modules/joycon": {
+ "version": "3.1.1",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/json-schema-traverse": {
+ "version": "0.4.1",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/json-stable-stringify-without-jsonify": {
+ "version": "1.0.1",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/levn": {
+ "version": "0.4.1",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "prelude-ls": "^1.2.1",
+ "type-check": "~0.4.0"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/lilconfig": {
+ "version": "2.0.6",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/lines-and-columns": {
+ "version": "1.2.4",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/load-tsconfig": {
+ "version": "0.2.3",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
+ }
+ },
+ "node_modules/lodash.defaults": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz",
+ "integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ=="
+ },
+ "node_modules/lodash.isarguments": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz",
+ "integrity": "sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg=="
+ },
+ "node_modules/lodash.merge": {
+ "version": "4.6.2",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/lodash.sortby": {
+ "version": "4.7.0",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/lru-cache": {
+ "version": "6.0.0",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "yallist": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/make-error": {
+ "version": "1.3.6",
+ "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
+ "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
+ "dev": true
+ },
+ "node_modules/merge-stream": {
+ "version": "2.0.0",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/merge2": {
+ "version": "1.4.1",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/micromatch": {
+ "version": "4.0.5",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "braces": "^3.0.2",
+ "picomatch": "^2.3.1"
+ },
+ "engines": {
+ "node": ">=8.6"
+ }
+ },
+ "node_modules/mimic-fn": {
+ "version": "2.1.0",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
+ "node_modules/minimatch": {
+ "version": "3.1.2",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "brace-expansion": "^1.1.7"
+ },
+ "engines": {
+ "node": "*"
+ }
+ },
+ "node_modules/ms": {
+ "version": "2.1.2",
+ "license": "MIT"
+ },
+ "node_modules/mz": {
+ "version": "2.7.0",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "any-promise": "^1.0.0",
+ "object-assign": "^4.0.1",
+ "thenify-all": "^1.0.0"
+ }
+ },
+ "node_modules/natural-compare": {
+ "version": "1.4.0",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/normalize-path": {
+ "version": "3.0.0",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/npm-run-path": {
+ "version": "4.0.1",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "path-key": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/object-assign": {
+ "version": "4.1.1",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/once": {
+ "version": "1.4.0",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "wrappy": "1"
+ }
+ },
+ "node_modules/onetime": {
+ "version": "5.1.2",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "mimic-fn": "^2.1.0"
+ },
+ "engines": {
+ "node": ">=6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/optionator": {
+ "version": "0.9.1",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "deep-is": "^0.1.3",
+ "fast-levenshtein": "^2.0.6",
+ "levn": "^0.4.1",
+ "prelude-ls": "^1.2.1",
+ "type-check": "^0.4.0",
+ "word-wrap": "^1.2.3"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/parent-module": {
+ "version": "1.0.1",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "callsites": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=6"
+ }
+ },
+ "node_modules/path-is-absolute": {
+ "version": "1.0.1",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/path-key": {
+ "version": "3.1.1",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/path-type": {
+ "version": "4.0.0",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/picomatch": {
+ "version": "2.3.1",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8.6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/jonschlinkert"
+ }
+ },
+ "node_modules/pirates": {
+ "version": "4.0.5",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 6"
+ }
+ },
+ "node_modules/postcss-load-config": {
+ "version": "3.1.4",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "lilconfig": "^2.0.5",
+ "yaml": "^1.10.2"
+ },
+ "engines": {
+ "node": ">= 10"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/postcss/"
+ },
+ "peerDependencies": {
+ "postcss": ">=8.0.9",
+ "ts-node": ">=9.0.0"
+ },
+ "peerDependenciesMeta": {
+ "postcss": {
+ "optional": true
+ },
+ "ts-node": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/prelude-ls": {
+ "version": "1.2.1",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/punycode": {
+ "version": "2.1.1",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
+ "node_modules/queue-microtask": {
+ "version": "1.2.3",
+ "dev": true,
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/feross"
+ },
+ {
+ "type": "patreon",
+ "url": "https://www.patreon.com/feross"
+ },
+ {
+ "type": "consulting",
+ "url": "https://feross.org/support"
+ }
+ ],
+ "license": "MIT"
+ },
+ "node_modules/readdirp": {
+ "version": "3.6.0",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "picomatch": "^2.2.1"
+ },
+ "engines": {
+ "node": ">=8.10.0"
+ }
+ },
+ "node_modules/redis-errors": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz",
+ "integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==",
+ "engines": {
+ "node": ">=4"
+ }
+ },
+ "node_modules/redis-parser": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz",
+ "integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==",
+ "dependencies": {
+ "redis-errors": "^1.0.0"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+ },
+ "node_modules/regexpp": {
+ "version": "3.2.0",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/mysticatea"
+ }
+ },
+ "node_modules/resolve-from": {
+ "version": "4.0.0",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=4"
+ }
+ },
+ "node_modules/reusify": {
+ "version": "1.0.4",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "iojs": ">=1.0.0",
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/rimraf": {
+ "version": "3.0.2",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "glob": "^7.1.3"
+ },
+ "bin": {
+ "rimraf": "bin.js"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
+ "node_modules/rollup": {
+ "version": "2.77.0",
+ "dev": true,
+ "license": "MIT",
+ "bin": {
+ "rollup": "dist/bin/rollup"
+ },
+ "engines": {
+ "node": ">=10.0.0"
+ },
+ "optionalDependencies": {
+ "fsevents": "~2.3.2"
+ }
+ },
+ "node_modules/run-parallel": {
+ "version": "1.2.0",
+ "dev": true,
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/feross"
+ },
+ {
+ "type": "patreon",
+ "url": "https://www.patreon.com/feross"
+ },
+ {
+ "type": "consulting",
+ "url": "https://feross.org/support"
+ }
+ ],
+ "license": "MIT",
+ "dependencies": {
+ "queue-microtask": "^1.2.2"
+ }
+ },
+ "node_modules/semver": {
+ "version": "7.3.7",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "lru-cache": "^6.0.0"
+ },
+ "bin": {
+ "semver": "bin/semver.js"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/shebang-command": {
+ "version": "2.0.0",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "shebang-regex": "^3.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/shebang-regex": {
+ "version": "3.0.0",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/signal-exit": {
+ "version": "3.0.7",
+ "dev": true,
+ "license": "ISC"
+ },
+ "node_modules/slash": {
+ "version": "3.0.0",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/source-map": {
+ "version": "0.8.0-beta.0",
+ "dev": true,
+ "license": "BSD-3-Clause",
+ "dependencies": {
+ "whatwg-url": "^7.0.0"
+ },
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/standard-as-callback": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz",
+ "integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A=="
+ },
+ "node_modules/strip-ansi": {
+ "version": "6.0.1",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "ansi-regex": "^5.0.1"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/strip-final-newline": {
+ "version": "2.0.0",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
+ "node_modules/strip-json-comments": {
+ "version": "3.1.1",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/sucrase": {
+ "version": "3.24.0",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "commander": "^4.0.0",
+ "glob": "7.1.6",
+ "lines-and-columns": "^1.1.6",
+ "mz": "^2.7.0",
+ "pirates": "^4.0.1",
+ "ts-interface-checker": "^0.1.9"
+ },
+ "bin": {
+ "sucrase": "bin/sucrase",
+ "sucrase-node": "bin/sucrase-node"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/sucrase/node_modules/glob": {
+ "version": "7.1.6",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "fs.realpath": "^1.0.0",
+ "inflight": "^1.0.4",
+ "inherits": "2",
+ "minimatch": "^3.0.4",
+ "once": "^1.3.0",
+ "path-is-absolute": "^1.0.0"
+ },
+ "engines": {
+ "node": "*"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
+ "node_modules/supports-color": {
+ "version": "7.2.0",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "has-flag": "^4.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/text-table": {
+ "version": "0.2.0",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/thenify": {
+ "version": "3.3.1",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "any-promise": "^1.0.0"
+ }
+ },
+ "node_modules/thenify-all": {
+ "version": "1.6.0",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "thenify": ">= 3.1.0 < 4"
+ },
+ "engines": {
+ "node": ">=0.8"
+ }
+ },
+ "node_modules/to-regex-range": {
+ "version": "5.0.1",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "is-number": "^7.0.0"
+ },
+ "engines": {
+ "node": ">=8.0"
+ }
+ },
+ "node_modules/tr46": {
+ "version": "1.0.1",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "punycode": "^2.1.0"
+ }
+ },
+ "node_modules/tree-kill": {
+ "version": "1.2.2",
+ "dev": true,
+ "license": "MIT",
+ "bin": {
+ "tree-kill": "cli.js"
+ }
+ },
+ "node_modules/ts-interface-checker": {
+ "version": "0.1.13",
+ "dev": true,
+ "license": "Apache-2.0"
+ },
+ "node_modules/ts-node": {
+ "version": "10.9.1",
+ "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz",
+ "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==",
+ "dev": true,
+ "dependencies": {
+ "@cspotcode/source-map-support": "^0.8.0",
+ "@tsconfig/node10": "^1.0.7",
+ "@tsconfig/node12": "^1.0.7",
+ "@tsconfig/node14": "^1.0.0",
+ "@tsconfig/node16": "^1.0.2",
+ "acorn": "^8.4.1",
+ "acorn-walk": "^8.1.1",
+ "arg": "^4.1.0",
+ "create-require": "^1.1.0",
+ "diff": "^4.0.1",
+ "make-error": "^1.1.1",
+ "v8-compile-cache-lib": "^3.0.1",
+ "yn": "3.1.1"
+ },
+ "bin": {
+ "ts-node": "dist/bin.js",
+ "ts-node-cwd": "dist/bin-cwd.js",
+ "ts-node-esm": "dist/bin-esm.js",
+ "ts-node-script": "dist/bin-script.js",
+ "ts-node-transpile-only": "dist/bin-transpile.js",
+ "ts-script": "dist/bin-script-deprecated.js"
+ },
+ "peerDependencies": {
+ "@swc/core": ">=1.2.50",
+ "@swc/wasm": ">=1.2.50",
+ "@types/node": "*",
+ "typescript": ">=2.7"
+ },
+ "peerDependenciesMeta": {
+ "@swc/core": {
+ "optional": true
+ },
+ "@swc/wasm": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/tslib": {
+ "version": "1.14.1",
+ "dev": true,
+ "license": "0BSD"
+ },
+ "node_modules/tsup": {
+ "version": "6.1.3",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "bundle-require": "^3.0.2",
+ "cac": "^6.7.12",
+ "chokidar": "^3.5.1",
+ "debug": "^4.3.1",
+ "esbuild": "^0.14.25",
+ "execa": "^5.0.0",
+ "globby": "^11.0.3",
+ "joycon": "^3.0.1",
+ "postcss-load-config": "^3.0.1",
+ "resolve-from": "^5.0.0",
+ "rollup": "^2.74.1",
+ "source-map": "0.8.0-beta.0",
+ "sucrase": "^3.20.3",
+ "tree-kill": "^1.2.2"
+ },
+ "bin": {
+ "tsup": "dist/cli-default.js",
+ "tsup-node": "dist/cli-node.js"
+ },
+ "engines": {
+ "node": ">=14"
+ },
+ "peerDependencies": {
+ "@swc/core": "^1",
+ "postcss": "^8.4.12",
+ "typescript": "^4.1.0"
+ },
+ "peerDependenciesMeta": {
+ "@swc/core": {
+ "optional": true
+ },
+ "postcss": {
+ "optional": true
+ },
+ "typescript": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/tsup/node_modules/resolve-from": {
+ "version": "5.0.0",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/tsutils": {
+ "version": "3.21.0",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "tslib": "^1.8.1"
+ },
+ "engines": {
+ "node": ">= 6"
+ },
+ "peerDependencies": {
+ "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
+ }
+ },
+ "node_modules/turbo": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo/-/turbo-1.3.4.tgz",
+ "integrity": "sha512-MsjlfAL29leQaIMdHGnIpK6IKZA4HwSAwDSIoBAs9EAKfAXIsnjLoF50dKDnBlaq5d4aVmiHsT6RYVcTKhSgBQ==",
+ "dev": true,
+ "hasInstallScript": true,
+ "bin": {
+ "turbo": "bin/turbo"
+ },
+ "optionalDependencies": {
+ "turbo-android-arm64": "1.3.4",
+ "turbo-darwin-64": "1.3.4",
+ "turbo-darwin-arm64": "1.3.4",
+ "turbo-freebsd-64": "1.3.4",
+ "turbo-freebsd-arm64": "1.3.4",
+ "turbo-linux-32": "1.3.4",
+ "turbo-linux-64": "1.3.4",
+ "turbo-linux-arm": "1.3.4",
+ "turbo-linux-arm64": "1.3.4",
+ "turbo-linux-mips64le": "1.3.4",
+ "turbo-linux-ppc64le": "1.3.4",
+ "turbo-windows-32": "1.3.4",
+ "turbo-windows-64": "1.3.4",
+ "turbo-windows-arm64": "1.3.4"
+ }
+ },
+ "node_modules/turbo-android-arm64": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-android-arm64/-/turbo-android-arm64-1.3.4.tgz",
+ "integrity": "sha512-rAbfiw5dT2rKV7L8XCL6nKwBxSz0TNknUT8F64pE+h3ESiT4y6Ow/hCdNxlb+hcee6lvZ8tB0cynXCVM5bthAA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "android"
+ ]
+ },
+ "node_modules/turbo-darwin-64": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-darwin-64/-/turbo-darwin-64-1.3.4.tgz",
+ "integrity": "sha512-DZbRwVHH3nKOzVtijKWzkiKLLY+pBjawK90po7VRKMwdN2Db+JkWdu9+6wIqaxQ4WEYnYpwnTm0Aiyua0U/dNg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "darwin"
+ ]
+ },
+ "node_modules/turbo-darwin-arm64": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-darwin-arm64/-/turbo-darwin-arm64-1.3.4.tgz",
+ "integrity": "sha512-Qfe7iBad/XM4G22G0XAnEQnHiSUO1WR4MgvyHV022WABIf7CgGDsW6DUu/4DOWFlfTO+xCC0Qgu93w6Kli/9uw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "darwin"
+ ]
+ },
+ "node_modules/turbo-freebsd-64": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-freebsd-64/-/turbo-freebsd-64-1.3.4.tgz",
+ "integrity": "sha512-lXFViR0fnoTRtnRtkeSA/10Q41h+fLgnYC62wzHNzPsq/kCYmiaXBg+gWRJom8Ka2nh+xWQdLG2Dh/uxK/+1Og==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "freebsd"
+ ]
+ },
+ "node_modules/turbo-freebsd-arm64": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-freebsd-arm64/-/turbo-freebsd-arm64-1.3.4.tgz",
+ "integrity": "sha512-VN9gPZcRaYhQOIo+NlIDIDNlJjhnyM7i+3WvWAK8y5p5GoZoDAahM36GDX05JNjVdPq95WJPnWcxoiQvwnctxg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "freebsd"
+ ]
+ },
+ "node_modules/turbo-linux-32": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-linux-32/-/turbo-linux-32-1.3.4.tgz",
+ "integrity": "sha512-h1oVx85jovYnAaP+KxSmFIPhlKFQmBwVkJBngALnHNU7HTN9+1t/VJ1WKjHEeLXrQ7ujeCMd/+TBm9XRd73RdA==",
+ "cpu": [
+ "ia32"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/turbo-linux-64": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-linux-64/-/turbo-linux-64-1.3.4.tgz",
+ "integrity": "sha512-QJJeksggK9/s3VzS+iMTQh8gO6JLDxKBSc3qnpP1Kaq8hF+M1upfP9KhDFNguz8UEFlOvTblplNdqZdk/wtkXQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/turbo-linux-arm": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-linux-arm/-/turbo-linux-arm-1.3.4.tgz",
+ "integrity": "sha512-vCVDcO4KNJak//UKsss/TnJw0ywYc8OyV88ZlSWyP3WtA+9D8DJNPOKodcR8IbKuV7Tqpr+f7cP+J9jGDkHjQw==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/turbo-linux-arm64": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-linux-arm64/-/turbo-linux-arm64-1.3.4.tgz",
+ "integrity": "sha512-SSyUvBxZmlS44LQ2hzX5gfDlQueH1Hx5/rFS9mJZKFdgMnAB2g7btxxEvnpm0lgpfP/c3LH0VRks3xYEoQvILg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/turbo-linux-mips64le": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-linux-mips64le/-/turbo-linux-mips64le-1.3.4.tgz",
+ "integrity": "sha512-w7Ib7i/GZhyJRdvQSLA1Be7AOIPgJpuLLjrtT2gUl3wXd4JuiHDvhOS7E0B9izaxeD/2iygU2kQjqD4o9tejlw==",
+ "cpu": [
+ "mips64el"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/turbo-linux-ppc64le": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-linux-ppc64le/-/turbo-linux-ppc64le-1.3.4.tgz",
+ "integrity": "sha512-xATyouJSGmfgQM6lLk4Da5HrsAw8qoPUArrBuDK1p3Rw1gcRnmlJL10mr6ZmZyRu+3o4M8UlThfus5q8eETmBw==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "node_modules/turbo-windows-32": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-windows-32/-/turbo-windows-32-1.3.4.tgz",
+ "integrity": "sha512-1oXgiGxkWuC/7rlBZTng7qC2zjAZ7lYLDDh3ePAycZzp6BprlxqT5+xA0kFJo+WqGRdAQVhanlET2bLGOdBQBQ==",
+ "cpu": [
+ "ia32"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "win32"
+ ]
+ },
+ "node_modules/turbo-windows-64": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-windows-64/-/turbo-windows-64-1.3.4.tgz",
+ "integrity": "sha512-k7K/oC+399Gtwol42ALvt0espWmZZR7qlRwfgFS3BF4pEetxjGFJMXKNWUMDkOqsHhMxvLIiDbWPmY3fTIWL7g==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "win32"
+ ]
+ },
+ "node_modules/turbo-windows-arm64": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-windows-arm64/-/turbo-windows-arm64-1.3.4.tgz",
+ "integrity": "sha512-jHBuTvQ3t/OElxn//kwHZR2mlPdmpcV7BZy+n18+wwx6ydGj5QDOrer7Dwk81YbA5KtOkp086Xpgr75T73wsSA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "win32"
+ ]
+ },
+ "node_modules/type-check": {
+ "version": "0.4.0",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "prelude-ls": "^1.2.1"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/type-fest": {
+ "version": "0.20.2",
+ "dev": true,
+ "license": "(MIT OR CC0-1.0)",
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/typescript": {
+ "version": "4.7.4",
+ "dev": true,
+ "license": "Apache-2.0",
+ "bin": {
+ "tsc": "bin/tsc",
+ "tsserver": "bin/tsserver"
+ },
+ "engines": {
+ "node": ">=4.2.0"
+ }
+ },
+ "node_modules/uri-js": {
+ "version": "4.4.1",
+ "dev": true,
+ "license": "BSD-2-Clause",
+ "dependencies": {
+ "punycode": "^2.1.0"
+ }
+ },
+ "node_modules/v8-compile-cache": {
+ "version": "2.3.0",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/v8-compile-cache-lib": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
+ "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==",
+ "dev": true
+ },
+ "node_modules/webidl-conversions": {
+ "version": "4.0.2",
+ "dev": true,
+ "license": "BSD-2-Clause"
+ },
+ "node_modules/whatwg-url": {
+ "version": "7.1.0",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "lodash.sortby": "^4.7.0",
+ "tr46": "^1.0.1",
+ "webidl-conversions": "^4.0.2"
+ }
+ },
+ "node_modules/which": {
+ "version": "2.0.2",
+ "dev": true,
+ "license": "ISC",
+ "dependencies": {
+ "isexe": "^2.0.0"
+ },
+ "bin": {
+ "node-which": "bin/node-which"
+ },
+ "engines": {
+ "node": ">= 8"
+ }
+ },
+ "node_modules/word-wrap": {
+ "version": "1.2.3",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/wrappy": {
+ "version": "1.0.2",
+ "dev": true,
+ "license": "ISC"
+ },
+ "node_modules/ws": {
+ "version": "8.8.1",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.8.1.tgz",
+ "integrity": "sha512-bGy2JzvzkPowEJV++hF07hAD6niYSr0JzBNo/J29WsB57A2r7Wlc1UFcTR9IzrPvuNVO4B8LGqF8qcpsVOhJCA==",
+ "engines": {
+ "node": ">=10.0.0"
+ },
+ "peerDependencies": {
+ "bufferutil": "^4.0.1",
+ "utf-8-validate": "^5.0.2"
+ },
+ "peerDependenciesMeta": {
+ "bufferutil": {
+ "optional": true
+ },
+ "utf-8-validate": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/yallist": {
+ "version": "4.0.0",
+ "dev": true,
+ "license": "ISC"
+ },
+ "node_modules/yaml": {
+ "version": "1.10.2",
+ "dev": true,
+ "license": "ISC",
+ "engines": {
+ "node": ">= 6"
+ }
+ },
+ "node_modules/yn": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz",
+ "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==",
+ "dev": true,
+ "engines": {
+ "node": ">=6"
+ }
+ },
+ "packages/api-types": {
+ "name": "@biscuitland/api-types",
+ "version": "1.0.0",
+ "devDependencies": {
+ "tsup": "^6.1.3"
+ }
+ },
+ "packages/cache": {
+ "name": "@biscuitland/cache",
+ "version": "1.0.0",
+ "dependencies": {
+ "@biscuitland/api-types": "^1.0.0",
+ "ioredis": "^5.2.2"
+ },
+ "devDependencies": {
+ "tsup": "^6.1.3"
+ }
+ },
+ "packages/core": {
+ "name": "@biscuitland/core",
+ "version": "1.0.0",
+ "dependencies": {
+ "@biscuitland/api-types": "^1.0.0",
+ "@biscuitland/rest": "^1.0.0",
+ "@biscuitland/ws": "^1.0.0"
+ },
+ "devDependencies": {
+ "tsup": "^6.1.3"
+ }
+ },
+ "packages/discordeno": {
+ "name": "@biscuit/discordeno",
+ "version": "1.0.0",
+ "extraneous": true,
+ "dependencies": {
+ "@biscuit/api-types": "^1.0.0",
+ "ws": "^8.8.1"
+ },
+ "devDependencies": {
+ "@types/ws": "^8.5.3",
+ "tsup": "^6.1.3"
+ }
+ },
+ "packages/logger": {
+ "name": "@biscuitland/logger",
+ "version": "1.0.0",
+ "devDependencies": {
+ "tsup": "^6.1.3"
+ }
+ },
+ "packages/rest": {
+ "name": "@biscuitland/rest",
+ "version": "1.0.0",
+ "dependencies": {
+ "@biscuitland/api-types": "^1.0.0"
+ },
+ "devDependencies": {
+ "tsup": "^6.1.3"
+ }
+ },
+ "packages/ws": {
+ "name": "@biscuitland/ws",
+ "version": "1.0.0",
+ "dependencies": {
+ "@biscuitland/api-types": "^1.0.0",
+ "ws": "^8.8.1"
+ },
+ "devDependencies": {
+ "@types/ws": "^8.5.3",
+ "tsup": "^6.1.3"
+ }
+ }
+ },
+ "dependencies": {
+ "@biscuitland/api-types": {
+ "version": "file:packages/api-types",
+ "requires": {
+ "tsup": "^6.1.3"
+ }
+ },
+ "@biscuitland/cache": {
+ "version": "file:packages/cache",
+ "requires": {
+ "@biscuitland/api-types": "^1.0.0",
+ "ioredis": "*",
+ "tsup": "^6.1.3"
+ }
+ },
+ "@biscuitland/core": {
+ "version": "file:packages/core",
+ "requires": {
+ "@biscuitland/api-types": "^1.0.0",
+ "@biscuitland/rest": "^1.0.0",
+ "@biscuitland/ws": "^1.0.0",
+ "tsup": "^6.1.3"
+ }
+ },
+ "@biscuitland/logger": {
+ "version": "file:packages/logger",
+ "requires": {
+ "tsup": "^6.1.3"
+ }
+ },
+ "@biscuitland/rest": {
+ "version": "file:packages/rest",
+ "requires": {
+ "@biscuitland/api-types": "^1.0.0",
+ "tsup": "^6.1.3"
+ }
+ },
+ "@biscuitland/ws": {
+ "version": "file:packages/ws",
+ "requires": {
+ "@biscuitland/api-types": "^1.0.0",
+ "@types/ws": "^8.5.3",
+ "tsup": "^6.1.3",
+ "ws": "^8.8.1"
+ }
+ },
+ "@cspotcode/source-map-support": {
+ "version": "0.8.1",
+ "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz",
+ "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==",
+ "dev": true,
+ "requires": {
+ "@jridgewell/trace-mapping": "0.3.9"
+ }
+ },
+ "@humanwhocodes/object-schema": {
+ "version": "1.2.1",
+ "dev": true
+ },
+ "@ioredis/commands": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz",
+ "integrity": "sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg=="
+ },
+ "@jridgewell/resolve-uri": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz",
+ "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==",
+ "dev": true
+ },
+ "@jridgewell/sourcemap-codec": {
+ "version": "1.4.14",
+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz",
+ "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==",
+ "dev": true
+ },
+ "@jridgewell/trace-mapping": {
+ "version": "0.3.9",
+ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz",
+ "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==",
+ "dev": true,
+ "requires": {
+ "@jridgewell/resolve-uri": "^3.0.3",
+ "@jridgewell/sourcemap-codec": "^1.4.10"
+ }
+ },
+ "@nodelib/fs.scandir": {
+ "version": "2.1.5",
+ "dev": true,
+ "requires": {
+ "@nodelib/fs.stat": "2.0.5",
+ "run-parallel": "^1.1.9"
+ }
+ },
+ "@nodelib/fs.stat": {
+ "version": "2.0.5",
+ "dev": true
+ },
+ "@nodelib/fs.walk": {
+ "version": "1.2.8",
+ "dev": true,
+ "requires": {
+ "@nodelib/fs.scandir": "2.1.5",
+ "fastq": "^1.6.0"
+ }
+ },
+ "@tsconfig/node10": {
+ "version": "1.0.9",
+ "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz",
+ "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==",
+ "dev": true
+ },
+ "@tsconfig/node12": {
+ "version": "1.0.11",
+ "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz",
+ "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==",
+ "dev": true
+ },
+ "@tsconfig/node14": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz",
+ "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==",
+ "dev": true
+ },
+ "@tsconfig/node16": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.3.tgz",
+ "integrity": "sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==",
+ "dev": true
+ },
+ "@types/json-schema": {
+ "version": "7.0.11",
+ "dev": true
+ },
+ "@types/node": {
+ "version": "18.0.6",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.0.6.tgz",
+ "integrity": "sha512-/xUq6H2aQm261exT6iZTMifUySEt4GR5KX8eYyY+C4MSNPqSh9oNIP7tz2GLKTlFaiBbgZNxffoR3CVRG+cljw==",
+ "dev": true
+ },
+ "@types/ws": {
+ "version": "8.5.3",
+ "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.3.tgz",
+ "integrity": "sha512-6YOoWjruKj1uLf3INHH7D3qTXwFfEsg1kf3c0uDdSBJwfa/llkwIjrAGV7j7mVgGNbzTQ3HiHKKDXl6bJPD97w==",
+ "dev": true,
+ "requires": {
+ "@types/node": "*"
+ }
+ },
+ "@typescript-eslint/eslint-plugin": {
+ "version": "5.30.7",
+ "dev": true,
+ "requires": {
+ "@typescript-eslint/scope-manager": "5.30.7",
+ "@typescript-eslint/type-utils": "5.30.7",
+ "@typescript-eslint/utils": "5.30.7",
+ "debug": "^4.3.4",
+ "functional-red-black-tree": "^1.0.1",
+ "ignore": "^5.2.0",
+ "regexpp": "^3.2.0",
+ "semver": "^7.3.7",
+ "tsutils": "^3.21.0"
+ }
+ },
+ "@typescript-eslint/parser": {
+ "version": "5.30.7",
+ "dev": true,
+ "requires": {
+ "@typescript-eslint/scope-manager": "5.30.7",
+ "@typescript-eslint/types": "5.30.7",
+ "@typescript-eslint/typescript-estree": "5.30.7",
+ "debug": "^4.3.4"
+ }
+ },
+ "@typescript-eslint/scope-manager": {
+ "version": "5.30.7",
+ "dev": true,
+ "requires": {
+ "@typescript-eslint/types": "5.30.7",
+ "@typescript-eslint/visitor-keys": "5.30.7"
+ }
+ },
+ "@typescript-eslint/type-utils": {
+ "version": "5.30.7",
+ "dev": true,
+ "requires": {
+ "@typescript-eslint/utils": "5.30.7",
+ "debug": "^4.3.4",
+ "tsutils": "^3.21.0"
+ }
+ },
+ "@typescript-eslint/types": {
+ "version": "5.30.7",
+ "dev": true
+ },
+ "@typescript-eslint/typescript-estree": {
+ "version": "5.30.7",
+ "dev": true,
+ "requires": {
+ "@typescript-eslint/types": "5.30.7",
+ "@typescript-eslint/visitor-keys": "5.30.7",
+ "debug": "^4.3.4",
+ "globby": "^11.1.0",
+ "is-glob": "^4.0.3",
+ "semver": "^7.3.7",
+ "tsutils": "^3.21.0"
+ }
+ },
+ "@typescript-eslint/utils": {
+ "version": "5.30.7",
+ "dev": true,
+ "requires": {
+ "@types/json-schema": "^7.0.9",
+ "@typescript-eslint/scope-manager": "5.30.7",
+ "@typescript-eslint/types": "5.30.7",
+ "@typescript-eslint/typescript-estree": "5.30.7",
+ "eslint-scope": "^5.1.1",
+ "eslint-utils": "^3.0.0"
+ }
+ },
+ "@typescript-eslint/visitor-keys": {
+ "version": "5.30.7",
+ "dev": true,
+ "requires": {
+ "@typescript-eslint/types": "5.30.7",
+ "eslint-visitor-keys": "^3.3.0"
+ }
+ },
+ "acorn": {
+ "version": "8.8.0",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz",
+ "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==",
+ "dev": true
+ },
+ "acorn-jsx": {
+ "version": "5.3.2",
+ "dev": true,
+ "requires": {}
+ },
+ "acorn-walk": {
+ "version": "8.2.0",
+ "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
+ "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==",
+ "dev": true
+ },
+ "ajv": {
+ "version": "6.12.6",
+ "dev": true,
+ "requires": {
+ "fast-deep-equal": "^3.1.1",
+ "fast-json-stable-stringify": "^2.0.0",
+ "json-schema-traverse": "^0.4.1",
+ "uri-js": "^4.2.2"
+ }
+ },
+ "ansi-regex": {
+ "version": "5.0.1",
+ "dev": true
+ },
+ "ansi-styles": {
+ "version": "4.3.0",
+ "dev": true,
+ "requires": {
+ "color-convert": "^2.0.1"
+ }
+ },
+ "any-promise": {
+ "version": "1.3.0",
+ "dev": true
+ },
+ "anymatch": {
+ "version": "3.1.2",
+ "dev": true,
+ "requires": {
+ "normalize-path": "^3.0.0",
+ "picomatch": "^2.0.4"
+ }
+ },
+ "arg": {
+ "version": "4.1.3",
+ "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
+ "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==",
+ "dev": true
+ },
+ "array-union": {
+ "version": "2.1.0",
+ "dev": true
+ },
+ "balanced-match": {
+ "version": "1.0.2",
+ "dev": true
+ },
+ "binary-extensions": {
+ "version": "2.2.0",
+ "dev": true
+ },
+ "brace-expansion": {
+ "version": "1.1.11",
+ "dev": true,
+ "requires": {
+ "balanced-match": "^1.0.0",
+ "concat-map": "0.0.1"
+ }
+ },
+ "braces": {
+ "version": "3.0.2",
+ "dev": true,
+ "requires": {
+ "fill-range": "^7.0.1"
+ }
+ },
+ "bundle-require": {
+ "version": "3.0.4",
+ "dev": true,
+ "requires": {
+ "load-tsconfig": "^0.2.0"
+ }
+ },
+ "cac": {
+ "version": "6.7.12",
+ "dev": true
+ },
+ "callsites": {
+ "version": "3.1.0",
+ "dev": true
+ },
+ "chalk": {
+ "version": "4.1.2",
+ "dev": true,
+ "requires": {
+ "ansi-styles": "^4.1.0",
+ "supports-color": "^7.1.0"
+ }
+ },
+ "chokidar": {
+ "version": "3.5.3",
+ "dev": true,
+ "requires": {
+ "anymatch": "~3.1.2",
+ "braces": "~3.0.2",
+ "fsevents": "~2.3.2",
+ "glob-parent": "~5.1.2",
+ "is-binary-path": "~2.1.0",
+ "is-glob": "~4.0.1",
+ "normalize-path": "~3.0.0",
+ "readdirp": "~3.6.0"
+ }
+ },
+ "cluster-key-slot": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.0.tgz",
+ "integrity": "sha512-2Nii8p3RwAPiFwsnZvukotvow2rIHM+yQ6ZcBXGHdniadkYGZYiGmkHJIbZPIV9nfv7m/U1IPMVVcAhoWFeklw=="
+ },
+ "color-convert": {
+ "version": "2.0.1",
+ "dev": true,
+ "requires": {
+ "color-name": "~1.1.4"
+ }
+ },
+ "color-name": {
+ "version": "1.1.4",
+ "dev": true
+ },
+ "commander": {
+ "version": "4.1.1",
+ "dev": true
+ },
+ "concat-map": {
+ "version": "0.0.1",
+ "dev": true
+ },
+ "create-require": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
+ "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
+ "dev": true
+ },
+ "cross-spawn": {
+ "version": "7.0.3",
+ "dev": true,
+ "requires": {
+ "path-key": "^3.1.0",
+ "shebang-command": "^2.0.0",
+ "which": "^2.0.1"
+ }
+ },
+ "debug": {
+ "version": "4.3.4",
+ "requires": {
+ "ms": "2.1.2"
+ }
+ },
+ "deep-is": {
+ "version": "0.1.4",
+ "dev": true
+ },
+ "denque": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz",
+ "integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw=="
+ },
+ "diff": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
+ "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
+ "dev": true
+ },
+ "dir-glob": {
+ "version": "3.0.1",
+ "dev": true,
+ "requires": {
+ "path-type": "^4.0.0"
+ }
+ },
+ "doctrine": {
+ "version": "3.0.0",
+ "dev": true,
+ "requires": {
+ "esutils": "^2.0.2"
+ }
+ },
+ "esbuild": {
+ "version": "0.14.49",
+ "dev": true,
+ "requires": {
+ "esbuild-android-64": "0.14.49",
+ "esbuild-android-arm64": "0.14.49",
+ "esbuild-darwin-64": "0.14.49",
+ "esbuild-darwin-arm64": "0.14.49",
+ "esbuild-freebsd-64": "0.14.49",
+ "esbuild-freebsd-arm64": "0.14.49",
+ "esbuild-linux-32": "0.14.49",
+ "esbuild-linux-64": "0.14.49",
+ "esbuild-linux-arm": "0.14.49",
+ "esbuild-linux-arm64": "0.14.49",
+ "esbuild-linux-mips64le": "0.14.49",
+ "esbuild-linux-ppc64le": "0.14.49",
+ "esbuild-linux-riscv64": "0.14.49",
+ "esbuild-linux-s390x": "0.14.49",
+ "esbuild-netbsd-64": "0.14.49",
+ "esbuild-openbsd-64": "0.14.49",
+ "esbuild-sunos-64": "0.14.49",
+ "esbuild-windows-32": "0.14.49",
+ "esbuild-windows-64": "0.14.49",
+ "esbuild-windows-arm64": "0.14.49"
+ }
+ },
+ "esbuild-windows-64": {
+ "version": "0.14.49",
+ "dev": true,
+ "optional": true
+ },
+ "escape-string-regexp": {
+ "version": "4.0.0",
+ "dev": true
+ },
+ "eslint": {
+ "version": "8.20.0",
+ "dev": true,
+ "requires": {
+ "@eslint/eslintrc": "^1.3.0",
+ "@humanwhocodes/config-array": "^0.9.2",
+ "ajv": "^6.10.0",
+ "chalk": "^4.0.0",
+ "cross-spawn": "^7.0.2",
+ "debug": "^4.3.2",
+ "doctrine": "^3.0.0",
+ "escape-string-regexp": "^4.0.0",
+ "eslint-scope": "^7.1.1",
+ "eslint-utils": "^3.0.0",
+ "eslint-visitor-keys": "^3.3.0",
+ "espree": "^9.3.2",
+ "esquery": "^1.4.0",
+ "esutils": "^2.0.2",
+ "fast-deep-equal": "^3.1.3",
+ "file-entry-cache": "^6.0.1",
+ "functional-red-black-tree": "^1.0.1",
+ "glob-parent": "^6.0.1",
+ "globals": "^13.15.0",
+ "ignore": "^5.2.0",
+ "import-fresh": "^3.0.0",
+ "imurmurhash": "^0.1.4",
+ "is-glob": "^4.0.0",
+ "js-yaml": "^4.1.0",
+ "json-stable-stringify-without-jsonify": "^1.0.1",
+ "levn": "^0.4.1",
+ "lodash.merge": "^4.6.2",
+ "minimatch": "^3.1.2",
+ "natural-compare": "^1.4.0",
+ "optionator": "^0.9.1",
+ "regexpp": "^3.2.0",
+ "strip-ansi": "^6.0.1",
+ "strip-json-comments": "^3.1.0",
+ "text-table": "^0.2.0",
+ "v8-compile-cache": "^2.0.3"
+ },
+ "dependencies": {
+ "@eslint/eslintrc": {
+ "version": "1.3.0",
+ "dev": true,
+ "requires": {
+ "ajv": "^6.12.4",
+ "debug": "^4.3.2",
+ "espree": "^9.3.2",
+ "globals": "^13.15.0",
+ "ignore": "^5.2.0",
+ "import-fresh": "^3.2.1",
+ "js-yaml": "^4.1.0",
+ "minimatch": "^3.1.2",
+ "strip-json-comments": "^3.1.1"
+ }
+ },
+ "@humanwhocodes/config-array": {
+ "version": "0.9.5",
+ "dev": true,
+ "requires": {
+ "@humanwhocodes/object-schema": "^1.2.1",
+ "debug": "^4.1.1",
+ "minimatch": "^3.0.4"
+ }
+ },
+ "argparse": {
+ "version": "2.0.1",
+ "dev": true
+ },
+ "eslint-scope": {
+ "version": "7.1.1",
+ "dev": true,
+ "requires": {
+ "esrecurse": "^4.3.0",
+ "estraverse": "^5.2.0"
+ }
+ },
+ "espree": {
+ "version": "9.3.2",
+ "dev": true,
+ "requires": {
+ "acorn": "^8.7.1",
+ "acorn-jsx": "^5.3.2",
+ "eslint-visitor-keys": "^3.3.0"
+ }
+ },
+ "glob-parent": {
+ "version": "6.0.2",
+ "dev": true,
+ "requires": {
+ "is-glob": "^4.0.3"
+ }
+ },
+ "js-yaml": {
+ "version": "4.1.0",
+ "dev": true,
+ "requires": {
+ "argparse": "^2.0.1"
+ }
+ }
+ }
+ },
+ "eslint-config-prettier": {
+ "version": "8.5.0",
+ "dev": true,
+ "requires": {}
+ },
+ "eslint-scope": {
+ "version": "5.1.1",
+ "dev": true,
+ "requires": {
+ "esrecurse": "^4.3.0",
+ "estraverse": "^4.1.1"
+ },
+ "dependencies": {
+ "estraverse": {
+ "version": "4.3.0",
+ "dev": true
+ }
+ }
+ },
+ "eslint-utils": {
+ "version": "3.0.0",
+ "dev": true,
+ "requires": {
+ "eslint-visitor-keys": "^2.0.0"
+ },
+ "dependencies": {
+ "eslint-visitor-keys": {
+ "version": "2.1.0",
+ "dev": true
+ }
+ }
+ },
+ "eslint-visitor-keys": {
+ "version": "3.3.0",
+ "dev": true
+ },
+ "esquery": {
+ "version": "1.4.0",
+ "dev": true,
+ "requires": {
+ "estraverse": "^5.1.0"
+ }
+ },
+ "esrecurse": {
+ "version": "4.3.0",
+ "dev": true,
+ "requires": {
+ "estraverse": "^5.2.0"
+ }
+ },
+ "estraverse": {
+ "version": "5.3.0",
+ "dev": true
+ },
+ "esutils": {
+ "version": "2.0.3",
+ "dev": true
+ },
+ "execa": {
+ "version": "5.1.1",
+ "dev": true,
+ "requires": {
+ "cross-spawn": "^7.0.3",
+ "get-stream": "^6.0.0",
+ "human-signals": "^2.1.0",
+ "is-stream": "^2.0.0",
+ "merge-stream": "^2.0.0",
+ "npm-run-path": "^4.0.1",
+ "onetime": "^5.1.2",
+ "signal-exit": "^3.0.3",
+ "strip-final-newline": "^2.0.0"
+ }
+ },
+ "fast-deep-equal": {
+ "version": "3.1.3",
+ "dev": true
+ },
+ "fast-glob": {
+ "version": "3.2.11",
+ "dev": true,
+ "requires": {
+ "@nodelib/fs.stat": "^2.0.2",
+ "@nodelib/fs.walk": "^1.2.3",
+ "glob-parent": "^5.1.2",
+ "merge2": "^1.3.0",
+ "micromatch": "^4.0.4"
+ }
+ },
+ "fast-json-stable-stringify": {
+ "version": "2.1.0",
+ "dev": true
+ },
+ "fast-levenshtein": {
+ "version": "2.0.6",
+ "dev": true
+ },
+ "fastq": {
+ "version": "1.13.0",
+ "dev": true,
+ "requires": {
+ "reusify": "^1.0.4"
+ }
+ },
+ "file-entry-cache": {
+ "version": "6.0.1",
+ "dev": true,
+ "requires": {
+ "flat-cache": "^3.0.4"
+ }
+ },
+ "fill-range": {
+ "version": "7.0.1",
+ "dev": true,
+ "requires": {
+ "to-regex-range": "^5.0.1"
+ }
+ },
+ "flat-cache": {
+ "version": "3.0.4",
+ "dev": true,
+ "requires": {
+ "flatted": "^3.1.0",
+ "rimraf": "^3.0.2"
+ }
+ },
+ "flatted": {
+ "version": "3.2.6",
+ "dev": true
+ },
+ "fs.realpath": {
+ "version": "1.0.0",
+ "dev": true
+ },
+ "functional-red-black-tree": {
+ "version": "1.0.1",
+ "dev": true
+ },
+ "get-stream": {
+ "version": "6.0.1",
+ "dev": true
+ },
+ "glob": {
+ "version": "7.1.7",
+ "dev": true,
+ "requires": {
+ "fs.realpath": "^1.0.0",
+ "inflight": "^1.0.4",
+ "inherits": "2",
+ "minimatch": "^3.0.4",
+ "once": "^1.3.0",
+ "path-is-absolute": "^1.0.0"
+ }
+ },
+ "glob-parent": {
+ "version": "5.1.2",
+ "dev": true,
+ "requires": {
+ "is-glob": "^4.0.1"
+ }
+ },
+ "globals": {
+ "version": "13.16.0",
+ "dev": true,
+ "requires": {
+ "type-fest": "^0.20.2"
+ }
+ },
+ "globby": {
+ "version": "11.1.0",
+ "dev": true,
+ "requires": {
+ "array-union": "^2.1.0",
+ "dir-glob": "^3.0.1",
+ "fast-glob": "^3.2.9",
+ "ignore": "^5.2.0",
+ "merge2": "^1.4.1",
+ "slash": "^3.0.0"
+ }
+ },
+ "has-flag": {
+ "version": "4.0.0",
+ "dev": true
+ },
+ "human-signals": {
+ "version": "2.1.0",
+ "dev": true
+ },
+ "ignore": {
+ "version": "5.2.0",
+ "dev": true
+ },
+ "import-fresh": {
+ "version": "3.3.0",
+ "dev": true,
+ "requires": {
+ "parent-module": "^1.0.0",
+ "resolve-from": "^4.0.0"
+ }
+ },
+ "imurmurhash": {
+ "version": "0.1.4",
+ "dev": true
+ },
+ "inflight": {
+ "version": "1.0.6",
+ "dev": true,
+ "requires": {
+ "once": "^1.3.0",
+ "wrappy": "1"
+ }
+ },
+ "inherits": {
+ "version": "2.0.4",
+ "dev": true
+ },
+ "ioredis": {
+ "version": "5.2.2",
+ "resolved": "https://registry.npmjs.org/ioredis/-/ioredis-5.2.2.tgz",
+ "integrity": "sha512-wryKc1ur8PcCmNwfcGkw5evouzpbDXxxkMkzPK8wl4xQfQf7lHe11Jotell5ikMVAtikXJEu/OJVaoV51BggRQ==",
+ "requires": {
+ "@ioredis/commands": "^1.1.1",
+ "cluster-key-slot": "^1.1.0",
+ "debug": "^4.3.4",
+ "denque": "^2.0.1",
+ "lodash.defaults": "^4.2.0",
+ "lodash.isarguments": "^3.1.0",
+ "redis-errors": "^1.2.0",
+ "redis-parser": "^3.0.0",
+ "standard-as-callback": "^2.1.0"
+ }
+ },
+ "is-binary-path": {
+ "version": "2.1.0",
+ "dev": true,
+ "requires": {
+ "binary-extensions": "^2.0.0"
+ }
+ },
+ "is-extglob": {
+ "version": "2.1.1",
+ "dev": true
+ },
+ "is-glob": {
+ "version": "4.0.3",
+ "dev": true,
+ "requires": {
+ "is-extglob": "^2.1.1"
+ }
+ },
+ "is-number": {
+ "version": "7.0.0",
+ "dev": true
+ },
+ "is-stream": {
+ "version": "2.0.1",
+ "dev": true
+ },
+ "isexe": {
+ "version": "2.0.0",
+ "dev": true
+ },
+ "joycon": {
+ "version": "3.1.1",
+ "dev": true
+ },
+ "json-schema-traverse": {
+ "version": "0.4.1",
+ "dev": true
+ },
+ "json-stable-stringify-without-jsonify": {
+ "version": "1.0.1",
+ "dev": true
+ },
+ "levn": {
+ "version": "0.4.1",
+ "dev": true,
+ "requires": {
+ "prelude-ls": "^1.2.1",
+ "type-check": "~0.4.0"
+ }
+ },
+ "lilconfig": {
+ "version": "2.0.6",
+ "dev": true
+ },
+ "lines-and-columns": {
+ "version": "1.2.4",
+ "dev": true
+ },
+ "load-tsconfig": {
+ "version": "0.2.3",
+ "dev": true
+ },
+ "lodash.defaults": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz",
+ "integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ=="
+ },
+ "lodash.isarguments": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz",
+ "integrity": "sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg=="
+ },
+ "lodash.merge": {
+ "version": "4.6.2",
+ "dev": true
+ },
+ "lodash.sortby": {
+ "version": "4.7.0",
+ "dev": true
+ },
+ "lru-cache": {
+ "version": "6.0.0",
+ "dev": true,
+ "requires": {
+ "yallist": "^4.0.0"
+ }
+ },
+ "make-error": {
+ "version": "1.3.6",
+ "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
+ "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
+ "dev": true
+ },
+ "merge-stream": {
+ "version": "2.0.0",
+ "dev": true
+ },
+ "merge2": {
+ "version": "1.4.1",
+ "dev": true
+ },
+ "micromatch": {
+ "version": "4.0.5",
+ "dev": true,
+ "requires": {
+ "braces": "^3.0.2",
+ "picomatch": "^2.3.1"
+ }
+ },
+ "mimic-fn": {
+ "version": "2.1.0",
+ "dev": true
+ },
+ "minimatch": {
+ "version": "3.1.2",
+ "dev": true,
+ "requires": {
+ "brace-expansion": "^1.1.7"
+ }
+ },
+ "ms": {
+ "version": "2.1.2"
+ },
+ "mz": {
+ "version": "2.7.0",
+ "dev": true,
+ "requires": {
+ "any-promise": "^1.0.0",
+ "object-assign": "^4.0.1",
+ "thenify-all": "^1.0.0"
+ }
+ },
+ "natural-compare": {
+ "version": "1.4.0",
+ "dev": true
+ },
+ "normalize-path": {
+ "version": "3.0.0",
+ "dev": true
+ },
+ "npm-run-path": {
+ "version": "4.0.1",
+ "dev": true,
+ "requires": {
+ "path-key": "^3.0.0"
+ }
+ },
+ "object-assign": {
+ "version": "4.1.1",
+ "dev": true
+ },
+ "once": {
+ "version": "1.4.0",
+ "dev": true,
+ "requires": {
+ "wrappy": "1"
+ }
+ },
+ "onetime": {
+ "version": "5.1.2",
+ "dev": true,
+ "requires": {
+ "mimic-fn": "^2.1.0"
+ }
+ },
+ "optionator": {
+ "version": "0.9.1",
+ "dev": true,
+ "requires": {
+ "deep-is": "^0.1.3",
+ "fast-levenshtein": "^2.0.6",
+ "levn": "^0.4.1",
+ "prelude-ls": "^1.2.1",
+ "type-check": "^0.4.0",
+ "word-wrap": "^1.2.3"
+ }
+ },
+ "parent-module": {
+ "version": "1.0.1",
+ "dev": true,
+ "requires": {
+ "callsites": "^3.0.0"
+ }
+ },
+ "path-is-absolute": {
+ "version": "1.0.1",
+ "dev": true
+ },
+ "path-key": {
+ "version": "3.1.1",
+ "dev": true
+ },
+ "path-type": {
+ "version": "4.0.0",
+ "dev": true
+ },
+ "picomatch": {
+ "version": "2.3.1",
+ "dev": true
+ },
+ "pirates": {
+ "version": "4.0.5",
+ "dev": true
+ },
+ "postcss-load-config": {
+ "version": "3.1.4",
+ "dev": true,
+ "requires": {
+ "lilconfig": "^2.0.5",
+ "yaml": "^1.10.2"
+ }
+ },
+ "prelude-ls": {
+ "version": "1.2.1",
+ "dev": true
+ },
+ "punycode": {
+ "version": "2.1.1",
+ "dev": true
+ },
+ "queue-microtask": {
+ "version": "1.2.3",
+ "dev": true
+ },
+ "readdirp": {
+ "version": "3.6.0",
+ "dev": true,
+ "requires": {
+ "picomatch": "^2.2.1"
+ }
+ },
+ "redis-errors": {
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz",
+ "integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w=="
+ },
+ "redis-parser": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz",
+ "integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==",
+ "requires": {
+ "redis-errors": "^1.0.0"
+ }
+ },
+ "regexpp": {
+ "version": "3.2.0",
+ "dev": true
+ },
+ "resolve-from": {
+ "version": "4.0.0",
+ "dev": true
+ },
+ "reusify": {
+ "version": "1.0.4",
+ "dev": true
+ },
+ "rimraf": {
+ "version": "3.0.2",
+ "dev": true,
+ "requires": {
+ "glob": "^7.1.3"
+ }
+ },
+ "rollup": {
+ "version": "2.77.0",
+ "dev": true,
+ "requires": {
+ "fsevents": "~2.3.2"
+ }
+ },
+ "run-parallel": {
+ "version": "1.2.0",
+ "dev": true,
+ "requires": {
+ "queue-microtask": "^1.2.2"
+ }
+ },
+ "semver": {
+ "version": "7.3.7",
+ "dev": true,
+ "requires": {
+ "lru-cache": "^6.0.0"
+ }
+ },
+ "shebang-command": {
+ "version": "2.0.0",
+ "dev": true,
+ "requires": {
+ "shebang-regex": "^3.0.0"
+ }
+ },
+ "shebang-regex": {
+ "version": "3.0.0",
+ "dev": true
+ },
+ "signal-exit": {
+ "version": "3.0.7",
+ "dev": true
+ },
+ "slash": {
+ "version": "3.0.0",
+ "dev": true
+ },
+ "source-map": {
+ "version": "0.8.0-beta.0",
+ "dev": true,
+ "requires": {
+ "whatwg-url": "^7.0.0"
+ }
+ },
+ "standard-as-callback": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz",
+ "integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A=="
+ },
+ "strip-ansi": {
+ "version": "6.0.1",
+ "dev": true,
+ "requires": {
+ "ansi-regex": "^5.0.1"
+ }
+ },
+ "strip-final-newline": {
+ "version": "2.0.0",
+ "dev": true
+ },
+ "strip-json-comments": {
+ "version": "3.1.1",
+ "dev": true
+ },
+ "sucrase": {
+ "version": "3.24.0",
+ "dev": true,
+ "requires": {
+ "commander": "^4.0.0",
+ "glob": "7.1.6",
+ "lines-and-columns": "^1.1.6",
+ "mz": "^2.7.0",
+ "pirates": "^4.0.1",
+ "ts-interface-checker": "^0.1.9"
+ },
+ "dependencies": {
+ "glob": {
+ "version": "7.1.6",
+ "dev": true,
+ "requires": {
+ "fs.realpath": "^1.0.0",
+ "inflight": "^1.0.4",
+ "inherits": "2",
+ "minimatch": "^3.0.4",
+ "once": "^1.3.0",
+ "path-is-absolute": "^1.0.0"
+ }
+ }
+ }
+ },
+ "supports-color": {
+ "version": "7.2.0",
+ "dev": true,
+ "requires": {
+ "has-flag": "^4.0.0"
+ }
+ },
+ "text-table": {
+ "version": "0.2.0",
+ "dev": true
+ },
+ "thenify": {
+ "version": "3.3.1",
+ "dev": true,
+ "requires": {
+ "any-promise": "^1.0.0"
+ }
+ },
+ "thenify-all": {
+ "version": "1.6.0",
+ "dev": true,
+ "requires": {
+ "thenify": ">= 3.1.0 < 4"
+ }
+ },
+ "to-regex-range": {
+ "version": "5.0.1",
+ "dev": true,
+ "requires": {
+ "is-number": "^7.0.0"
+ }
+ },
+ "tr46": {
+ "version": "1.0.1",
+ "dev": true,
+ "requires": {
+ "punycode": "^2.1.0"
+ }
+ },
+ "tree-kill": {
+ "version": "1.2.2",
+ "dev": true
+ },
+ "ts-interface-checker": {
+ "version": "0.1.13",
+ "dev": true
+ },
+ "ts-node": {
+ "version": "10.9.1",
+ "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz",
+ "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==",
+ "dev": true,
+ "requires": {
+ "@cspotcode/source-map-support": "^0.8.0",
+ "@tsconfig/node10": "^1.0.7",
+ "@tsconfig/node12": "^1.0.7",
+ "@tsconfig/node14": "^1.0.0",
+ "@tsconfig/node16": "^1.0.2",
+ "acorn": "^8.4.1",
+ "acorn-walk": "^8.1.1",
+ "arg": "^4.1.0",
+ "create-require": "^1.1.0",
+ "diff": "^4.0.1",
+ "make-error": "^1.1.1",
+ "v8-compile-cache-lib": "^3.0.1",
+ "yn": "3.1.1"
+ }
+ },
+ "tslib": {
+ "version": "1.14.1",
+ "dev": true
+ },
+ "tsup": {
+ "version": "6.1.3",
+ "dev": true,
+ "requires": {
+ "bundle-require": "^3.0.2",
+ "cac": "^6.7.12",
+ "chokidar": "^3.5.1",
+ "debug": "^4.3.1",
+ "esbuild": "^0.14.25",
+ "execa": "^5.0.0",
+ "globby": "^11.0.3",
+ "joycon": "^3.0.1",
+ "postcss-load-config": "^3.0.1",
+ "resolve-from": "^5.0.0",
+ "rollup": "^2.74.1",
+ "source-map": "0.8.0-beta.0",
+ "sucrase": "^3.20.3",
+ "tree-kill": "^1.2.2"
+ },
+ "dependencies": {
+ "resolve-from": {
+ "version": "5.0.0",
+ "dev": true
+ }
+ }
+ },
+ "tsutils": {
+ "version": "3.21.0",
+ "dev": true,
+ "requires": {
+ "tslib": "^1.8.1"
+ }
+ },
+ "turbo": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo/-/turbo-1.3.4.tgz",
+ "integrity": "sha512-MsjlfAL29leQaIMdHGnIpK6IKZA4HwSAwDSIoBAs9EAKfAXIsnjLoF50dKDnBlaq5d4aVmiHsT6RYVcTKhSgBQ==",
+ "dev": true,
+ "requires": {
+ "turbo-android-arm64": "1.3.4",
+ "turbo-darwin-64": "1.3.4",
+ "turbo-darwin-arm64": "1.3.4",
+ "turbo-freebsd-64": "1.3.4",
+ "turbo-freebsd-arm64": "1.3.4",
+ "turbo-linux-32": "1.3.4",
+ "turbo-linux-64": "1.3.4",
+ "turbo-linux-arm": "1.3.4",
+ "turbo-linux-arm64": "1.3.4",
+ "turbo-linux-mips64le": "1.3.4",
+ "turbo-linux-ppc64le": "1.3.4",
+ "turbo-windows-32": "1.3.4",
+ "turbo-windows-64": "1.3.4",
+ "turbo-windows-arm64": "1.3.4"
+ }
+ },
+ "turbo-android-arm64": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-android-arm64/-/turbo-android-arm64-1.3.4.tgz",
+ "integrity": "sha512-rAbfiw5dT2rKV7L8XCL6nKwBxSz0TNknUT8F64pE+h3ESiT4y6Ow/hCdNxlb+hcee6lvZ8tB0cynXCVM5bthAA==",
+ "dev": true,
+ "optional": true
+ },
+ "turbo-darwin-64": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-darwin-64/-/turbo-darwin-64-1.3.4.tgz",
+ "integrity": "sha512-DZbRwVHH3nKOzVtijKWzkiKLLY+pBjawK90po7VRKMwdN2Db+JkWdu9+6wIqaxQ4WEYnYpwnTm0Aiyua0U/dNg==",
+ "dev": true,
+ "optional": true
+ },
+ "turbo-darwin-arm64": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-darwin-arm64/-/turbo-darwin-arm64-1.3.4.tgz",
+ "integrity": "sha512-Qfe7iBad/XM4G22G0XAnEQnHiSUO1WR4MgvyHV022WABIf7CgGDsW6DUu/4DOWFlfTO+xCC0Qgu93w6Kli/9uw==",
+ "dev": true,
+ "optional": true
+ },
+ "turbo-freebsd-64": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-freebsd-64/-/turbo-freebsd-64-1.3.4.tgz",
+ "integrity": "sha512-lXFViR0fnoTRtnRtkeSA/10Q41h+fLgnYC62wzHNzPsq/kCYmiaXBg+gWRJom8Ka2nh+xWQdLG2Dh/uxK/+1Og==",
+ "dev": true,
+ "optional": true
+ },
+ "turbo-freebsd-arm64": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-freebsd-arm64/-/turbo-freebsd-arm64-1.3.4.tgz",
+ "integrity": "sha512-VN9gPZcRaYhQOIo+NlIDIDNlJjhnyM7i+3WvWAK8y5p5GoZoDAahM36GDX05JNjVdPq95WJPnWcxoiQvwnctxg==",
+ "dev": true,
+ "optional": true
+ },
+ "turbo-linux-32": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-linux-32/-/turbo-linux-32-1.3.4.tgz",
+ "integrity": "sha512-h1oVx85jovYnAaP+KxSmFIPhlKFQmBwVkJBngALnHNU7HTN9+1t/VJ1WKjHEeLXrQ7ujeCMd/+TBm9XRd73RdA==",
+ "dev": true,
+ "optional": true
+ },
+ "turbo-linux-64": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-linux-64/-/turbo-linux-64-1.3.4.tgz",
+ "integrity": "sha512-QJJeksggK9/s3VzS+iMTQh8gO6JLDxKBSc3qnpP1Kaq8hF+M1upfP9KhDFNguz8UEFlOvTblplNdqZdk/wtkXQ==",
+ "dev": true,
+ "optional": true
+ },
+ "turbo-linux-arm": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-linux-arm/-/turbo-linux-arm-1.3.4.tgz",
+ "integrity": "sha512-vCVDcO4KNJak//UKsss/TnJw0ywYc8OyV88ZlSWyP3WtA+9D8DJNPOKodcR8IbKuV7Tqpr+f7cP+J9jGDkHjQw==",
+ "dev": true,
+ "optional": true
+ },
+ "turbo-linux-arm64": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-linux-arm64/-/turbo-linux-arm64-1.3.4.tgz",
+ "integrity": "sha512-SSyUvBxZmlS44LQ2hzX5gfDlQueH1Hx5/rFS9mJZKFdgMnAB2g7btxxEvnpm0lgpfP/c3LH0VRks3xYEoQvILg==",
+ "dev": true,
+ "optional": true
+ },
+ "turbo-linux-mips64le": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-linux-mips64le/-/turbo-linux-mips64le-1.3.4.tgz",
+ "integrity": "sha512-w7Ib7i/GZhyJRdvQSLA1Be7AOIPgJpuLLjrtT2gUl3wXd4JuiHDvhOS7E0B9izaxeD/2iygU2kQjqD4o9tejlw==",
+ "dev": true,
+ "optional": true
+ },
+ "turbo-linux-ppc64le": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-linux-ppc64le/-/turbo-linux-ppc64le-1.3.4.tgz",
+ "integrity": "sha512-xATyouJSGmfgQM6lLk4Da5HrsAw8qoPUArrBuDK1p3Rw1gcRnmlJL10mr6ZmZyRu+3o4M8UlThfus5q8eETmBw==",
+ "dev": true,
+ "optional": true
+ },
+ "turbo-windows-32": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-windows-32/-/turbo-windows-32-1.3.4.tgz",
+ "integrity": "sha512-1oXgiGxkWuC/7rlBZTng7qC2zjAZ7lYLDDh3ePAycZzp6BprlxqT5+xA0kFJo+WqGRdAQVhanlET2bLGOdBQBQ==",
+ "dev": true,
+ "optional": true
+ },
+ "turbo-windows-64": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-windows-64/-/turbo-windows-64-1.3.4.tgz",
+ "integrity": "sha512-k7K/oC+399Gtwol42ALvt0espWmZZR7qlRwfgFS3BF4pEetxjGFJMXKNWUMDkOqsHhMxvLIiDbWPmY3fTIWL7g==",
+ "dev": true,
+ "optional": true
+ },
+ "turbo-windows-arm64": {
+ "version": "1.3.4",
+ "resolved": "https://registry.npmjs.org/turbo-windows-arm64/-/turbo-windows-arm64-1.3.4.tgz",
+ "integrity": "sha512-jHBuTvQ3t/OElxn//kwHZR2mlPdmpcV7BZy+n18+wwx6ydGj5QDOrer7Dwk81YbA5KtOkp086Xpgr75T73wsSA==",
+ "dev": true,
+ "optional": true
+ },
+ "type-check": {
+ "version": "0.4.0",
+ "dev": true,
+ "requires": {
+ "prelude-ls": "^1.2.1"
+ }
+ },
+ "type-fest": {
+ "version": "0.20.2",
+ "dev": true
+ },
+ "typescript": {
+ "version": "4.7.4",
+ "dev": true
+ },
+ "uri-js": {
+ "version": "4.4.1",
+ "dev": true,
+ "requires": {
+ "punycode": "^2.1.0"
+ }
+ },
+ "v8-compile-cache": {
+ "version": "2.3.0",
+ "dev": true
+ },
+ "v8-compile-cache-lib": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz",
+ "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==",
+ "dev": true
+ },
+ "webidl-conversions": {
+ "version": "4.0.2",
+ "dev": true
+ },
+ "whatwg-url": {
+ "version": "7.1.0",
+ "dev": true,
+ "requires": {
+ "lodash.sortby": "^4.7.0",
+ "tr46": "^1.0.1",
+ "webidl-conversions": "^4.0.2"
+ }
+ },
+ "which": {
+ "version": "2.0.2",
+ "dev": true,
+ "requires": {
+ "isexe": "^2.0.0"
+ }
+ },
+ "word-wrap": {
+ "version": "1.2.3",
+ "dev": true
+ },
+ "wrappy": {
+ "version": "1.0.2",
+ "dev": true
+ },
+ "ws": {
+ "version": "8.8.1",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.8.1.tgz",
+ "integrity": "sha512-bGy2JzvzkPowEJV++hF07hAD6niYSr0JzBNo/J29WsB57A2r7Wlc1UFcTR9IzrPvuNVO4B8LGqF8qcpsVOhJCA==",
+ "requires": {}
+ },
+ "yallist": {
+ "version": "4.0.0",
+ "dev": true
+ },
+ "yaml": {
+ "version": "1.10.2",
+ "dev": true
+ },
+ "yn": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz",
+ "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==",
+ "dev": true
+ }
+ }
+}
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..4751246
--- /dev/null
+++ b/package.json
@@ -0,0 +1,28 @@
+{
+ "name": "biscuit",
+ "private": true,
+ "workspaces": [
+ "packages/*"
+ ],
+ "scripts": {
+ "build": "turbo run build",
+ "clean": "turbo run clean",
+ "lint": "turbo run lint",
+ "dev": "turbo run dev --parallel"
+ },
+ "engines": {
+ "npm": ">=7.0.0",
+ "node": ">=14.0.0"
+ },
+ "devDependencies": {
+ "@types/node": "^18.0.6",
+ "@typescript-eslint/eslint-plugin": "^5.30.7",
+ "@typescript-eslint/parser": "^5.30.7",
+ "eslint": "^8.20.0",
+ "eslint-config-prettier": "^8.5.0",
+ "ts-node": "^10.9.1",
+ "turbo": "^1.3.4",
+ "typescript": "^4.7.4"
+ },
+ "packageManager": "npm@8.14.0"
+}
diff --git a/packages/api-types/package.json b/packages/api-types/package.json
new file mode 100644
index 0000000..4413e9a
--- /dev/null
+++ b/packages/api-types/package.json
@@ -0,0 +1,18 @@
+{
+ "name": "@biscuitland/api-types",
+ "version": "1.0.0",
+ "main": "./dist/index.js",
+ "module": "./dist/index.mjs",
+ "types": "./dist/index.d.ts",
+ "files": [
+ "dist/**"
+ ],
+ "scripts": {
+ "build": "tsup",
+ "clean": "rm -rf dist && rm -rf .turbo",
+ "dev": "tsup --watch"
+ },
+ "devDependencies": {
+ "tsup": "^6.1.3"
+ }
+}
diff --git a/packages/api-types/src/common.ts b/packages/api-types/src/common.ts
new file mode 100644
index 0000000..aa00dc5
--- /dev/null
+++ b/packages/api-types/src/common.ts
@@ -0,0 +1,1271 @@
+/* eslint-disable no-mixed-spaces-and-tabs */
+/** https://discord.com/developers/docs/resources/user#user-object-premium-types */
+export enum PremiumTypes {
+ None,
+ NitroClassic,
+ Nitro,
+}
+
+/** https://discord.com/developers/docs/resources/user#user-object-user-flags */
+export enum UserFlags {
+ DiscordEmployee = 1 << 0,
+ PartneredServerOwner = 1 << 1,
+ HypeSquadEventsMember = 1 << 2,
+ BugHunterLevel1 = 1 << 3,
+ HouseBravery = 1 << 6,
+ HouseBrilliance = 1 << 7,
+ HouseBalance = 1 << 8,
+ EarlySupporter = 1 << 9,
+ TeamUser = 1 << 10,
+ BugHunterLevel2 = 1 << 14,
+ VerifiedBot = 1 << 16,
+ EarlyVerifiedBotDeveloper = 1 << 17,
+ DiscordCertifiedModerator = 1 << 18,
+ BotHttpInteractions = 1 << 19,
+}
+
+/** https://discord.com/developers/docs/resources/channel#channels-resource */
+export enum ChannelFlags {
+ None,
+ Pinned = 1 << 1,
+}
+
+/** https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors */
+export enum IntegrationExpireBehaviors {
+ RemoveRole,
+ Kick,
+}
+
+/** https://discord.com/developers/docs/resources/user#connection-object-visibility-types */
+export enum VisibilityTypes {
+ /** Invisible to everyone except the user themselves */
+ None,
+ /** Visible to everyone */
+ Everyone,
+}
+
+/** https://discord.com/developers/docs/topics/teams#data-models-membership-state-enum */
+export enum TeamMembershipStates {
+ Invited = 1,
+ Accepted,
+}
+
+/** https://discord.com/developers/docs/topics/oauth2#application-application-flags */
+export enum ApplicationFlags {
+ /** Intent required for bots in **100 or more servers** to receive [`presence_update` events](#DOCS_TOPICS_GATEWAY/presence-update) */
+ GatewayPresence = 1 << 12,
+ /** Intent required for bots in under 100 servers to receive [`presence_update` events](#DOCS_TOPICS_GATEWAY/presence-update), found in Bot Settings */
+ GatewayPresenceLimited = 1 << 13,
+ /** Intent required for bots in **100 or more servers** to receive member-related events like `guild_member_add`. See list of member-related events [under `GUILD_MEMBERS`](#DOCS_TOPICS_GATEWAY/list-of-intents) */
+ GatewayGuildMembers = 1 << 14,
+ /** Intent required for bots in under 100 servers to receive member-related events like `guild_member_add`, found in Bot Settings. See list of member-related events [under `GUILD_MEMBERS`](#DOCS_TOPICS_GATEWAY/list-of-intents) */
+ GatewayGuildMembersLimited = 1 << 15,
+ /** Indicates unusual growth of an app that prevents verification */
+ VerificationPendingGuildLimit = 1 << 16,
+ /** Indicates if an app is embedded within the Discord client (currently unavailable publicly) */
+ Embedded = 1 << 17,
+ /** Intent required for bots in **100 or more servers** to receive [message content](https://support-dev.discord.com/hc/en-us/articles/4404772028055) */
+ GatewayMessageCount = 1 << 18,
+ /** Intent required for bots in under 100 servers to receive [message content](https://support-dev.discord.com/hc/en-us/articles/4404772028055), found in Bot Settings */
+ GatewayMessageContentLimited = 1 << 19,
+}
+
+/** https://discord.com/developers/docs/interactions/message-components#component-types */
+export enum MessageComponentTypes {
+ /** A container for other components */
+ ActionRow = 1,
+ /** A button object */
+ Button = 2,
+ /** A select menu for picking from choices */
+ SelectMenu = 3,
+ /** A text input object */
+ InputText = 4,
+}
+
+export enum TextStyles {
+ /** Intended for short single-line text */
+ Short = 1,
+ /** Intended for much longer inputs */
+ Paragraph = 2,
+}
+
+/** https://discord.com/developers/docs/interactions/message-components#buttons-button-styles */
+export enum ButtonStyles {
+ /** A blurple button */
+ Primary = 1,
+ /** A grey button */
+ Secondary,
+ /** A green button */
+ Success,
+ /** A red button */
+ Danger,
+ /** A button that navigates to a URL */
+ Link,
+}
+
+/** https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types */
+export enum AllowedMentionsTypes {
+ /** Controls role mentions */
+ RoleMentions = 'roles',
+ /** Controls user mentions */
+ UserMentions = 'users',
+ /** Controls @everyone and @here mentions */
+ EveryoneMentions = 'everyone',
+}
+
+/** https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-types */
+export enum WebhookTypes {
+ /** Incoming Webhooks can post messages to channels with a generated token */
+ Incoming = 1,
+ /** Channel Follower Webhooks are internal webhooks used with Channel Following to post new messages into channels */
+ ChannelFollower,
+ /** Application webhooks are webhooks used with Interactions */
+ Application,
+}
+
+/** https://discord.com/developers/docs/resources/channel#embed-object-embed-types */
+export type EmbedTypes =
+ | 'rich'
+ | 'image'
+ | 'video'
+ | 'gifv'
+ | 'article'
+ | 'link';
+
+/** https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level */
+export enum DefaultMessageNotificationLevels {
+ /** Members will receive notifications for all messages by default */
+ AllMessages,
+ /** Members will receive notifications only for messages that @mention them by default */
+ OnlyMentions,
+}
+
+/** https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level */
+export enum ExplicitContentFilterLevels {
+ /** Media content will not be scanned */
+ Disabled,
+ /** Media content sent by members without roles will be scanned */
+ MembersWithoutRoles,
+ /** Media content sent by all members will be scanned */
+ AllMembers,
+}
+
+/** https://discord.com/developers/docs/resources/guild#guild-object-verification-level */
+export enum VerificationLevels {
+ /** Unrestricted */
+ None,
+ /** Must have verified email on account */
+ Low,
+ /** Must be registered on Discord for longer than 5 minutes */
+ Medium,
+ /** Must be a member of the server for longer than 10 minutes */
+ High,
+ /** Must have a verified phone number */
+ VeryHigh,
+}
+
+/** https://discord.com/developers/docs/topics/permissions#role-object-role-structure */
+export interface BaseRole {
+ /** Role name */
+ name: string;
+ /** Integer representation of hexadecimal color code */
+ color: number;
+ /** Position of this role */
+ position: number;
+ /** role unicode emoji */
+ unicodeEmoji?: string;
+}
+
+/** https://discord.com/developers/docs/resources/guild#guild-object-guild-features */
+export enum GuildFeatures {
+ /** Guild has access to set an invite splash background */
+ InviteSplash = 'INVITE_SPLASH',
+ /** Guild has access to set 384 kbps bitrate in voice (previously VIP voice servers) */
+ VipRegions = 'VIP_REGIONS',
+ /** Guild has access to set a vanity URL */
+ VanityUrl = 'VANITY_URL',
+ /** Guild is verified */
+ Verified = 'VERIFIED',
+ /** Guild is partnered */
+ Partnered = 'PARTNERED',
+ /** Guild can enable welcome screen, Membership Screening, stage channels and discovery, and receives community updates */
+ Community = 'COMMUNITY',
+ /** Guild has access to use commerce features (i.e. create store channels) */
+ Commerce = 'COMMERCE',
+ /** Guild has access to create news channels */
+ News = 'NEWS',
+ /** Guild is able to be discovered in the directory */
+ Discoverable = 'DISCOVERABLE',
+ /** guild cannot be discoverable */
+ DiscoverableDisabled = 'DISCOVERABLE_DISABLED',
+ /** Guild is able to be featured in the directory */
+ Feature = 'FEATURABLE',
+ /** Guild has access to set an animated guild icon */
+ AnimatedIcon = 'ANIMATED_ICON',
+ /** Guild has access to set a guild banner image */
+ Banner = 'BANNER',
+ /** Guild has enabled the welcome screen */
+ WelcomeScreenEnabled = 'WELCOME_SCREEN_ENABLED',
+ /** Guild has enabled [Membership Screening](https://discord.com/developers/docs/resources/guild#membership-screening-object) */
+ MemberVerificationGateEnabled = 'MEMBER_VERIFICATION_GATE_ENABLED',
+ /** Guild can be previewed before joining via Membership Screening or the directory */
+ PreviewEnabled = 'PREVIEW_ENABLED',
+ /** Guild has enabled ticketed events */
+ TicketedEventsEnabled = 'TICKETED_EVENTS_ENABLED',
+ /** Guild has enabled monetization */
+ MonetizationEnabled = 'MONETIZATION_ENABLED',
+ /** Guild has increased custom sticker slots */
+ MoreStickers = 'MORE_STICKERS',
+ /** Guild has access to create private threads */
+ PrivateThreads = 'PRIVATE_THREADS',
+ /** Guild is able to set role icons */
+ RoleIcons = 'ROLE_ICONS',
+ /** Guild has set up auto moderation rules */
+ AutoModeration = 'AUTO_MODERATION',
+}
+
+/** https://discord.com/developers/docs/resources/guild#guild-object-mfa-level */
+export enum MfaLevels {
+ /** Guild has no MFA/2FA requirement for moderation actions */
+ None,
+ /** Guild has a 2FA requirement for moderation actions */
+ Elevated,
+}
+
+/** https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags */
+export enum SystemChannelFlags {
+ /** Suppress member join notifications */
+ SuppressJoinNotifications = 1 << 0,
+ /** Suppress server boost notifications */
+ SuppressPremiumSubscriptions = 1 << 1,
+ /** Suppress server setup tips */
+ SuppressGuildReminderNotifications = 1 << 2,
+ /** Hide member join sticker reply buttons */
+ SuppressJoinNotificationReplies = 1 << 3,
+}
+
+/** https://discord.com/developers/docs/resources/guild#guild-object-premium-tier */
+export enum PremiumTiers {
+ /** Guild has not unlocked any Server Boost perks */
+ None,
+ /** Guild has unlocked Server Boost level 1 perks */
+ Tier1,
+ /** Guild has unlocked Server Boost level 2 perks */
+ Tier2,
+ /** Guild has unlocked Server Boost level 3 perks */
+ Tier3,
+}
+
+/** https://discord.com/developers/docs/resources/guild#guild-object-guild-nsfw-level */
+export enum GuildNsfwLevel {
+ Default,
+ Explicit,
+ Safe,
+ AgeRestricted,
+}
+
+/** https://discord.com/developers/docs/resources/channel#channel-object-channel-types */
+export enum ChannelTypes {
+ /** A text channel within a server */
+ GuildText,
+ /** A direct message between users */
+ DM,
+ /** A voice channel within a server */
+ GuildVoice,
+ /** A direct message between multiple users */
+ GroupDm,
+ /** An organizational category that contains up to 50 channels */
+ GuildCategory,
+ /** A channel that users can follow and crosspost into their own server */
+ GuildNews,
+ /** A temporary sub-channel within a GUILD_NEWS channel */
+ GuildNewsThread = 10,
+ /** A temporary sub-channel within a GUILD_TEXT channel */
+ GuildPublicThread,
+ /** A temporary sub-channel within a GUILD_TEXT channel that is only viewable by those invited and those with the MANAGE_THREADS permission */
+ GuildPrivateThread,
+ /** A voice channel for hosting events with an audience */
+ GuildStageVoice,
+ /** A channel in a hub containing the listed servers */
+ GuildDirectory,
+ /** A channel which can only contains threads */
+ GuildForum,
+}
+
+export enum OverwriteTypes {
+ Role,
+ Member,
+}
+
+export enum VideoQualityModes {
+ /** Discord chooses the quality for optimal performance */
+ Auto = 1,
+ /** 720p */
+ Full,
+}
+
+/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-types */
+export enum ActivityTypes {
+ Game,
+ Streaming,
+ Listening,
+ Watching,
+ Custom = 4,
+ Competing,
+}
+
+/** https://discord.com/developers/docs/resources/channel#message-object-message-types */
+export enum MessageTypes {
+ Default,
+ RecipientAdd,
+ RecipientRemove,
+ Call,
+ ChannelNameChange,
+ ChannelIconChange,
+ ChannelPinnedMessage,
+ GuildMemberJoin,
+ UserPremiumGuildSubscription,
+ UserPremiumGuildSubscriptionTier1,
+ UserPremiumGuildSubscriptionTier2,
+ UserPremiumGuildSubscriptionTier3,
+ ChannelFollowAdd,
+ GuildDiscoveryDisqualified = 14,
+ GuildDiscoveryRequalified,
+ GuildDiscoveryGracePeriodInitialWarning,
+ GuildDiscoveryGracePeriodFinalWarning,
+ ThreadCreated,
+ Reply,
+ ChatInputCommand,
+ ThreadStarterMessage,
+ GuildInviteReminder,
+ ContextMenuCommand,
+ AutoModerationAction,
+}
+
+/** https://discord.com/developers/docs/resources/channel#message-object-message-activity-types */
+export enum MessageActivityTypes {
+ Join = 1,
+ Spectate,
+ Listen,
+ JoinRequest,
+}
+
+/** https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types */
+export enum StickerTypes {
+ /** an official sticker in a pack, part of Nitro or in a removed purchasable pack */
+ Standard = 1,
+ /** a sticker uploaded to a Boosted guild for the guild's members */
+ Guild,
+}
+
+/** https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types */
+export enum StickerFormatTypes {
+ Png = 1,
+ APng,
+ Lottie,
+}
+
+/** https://discord.com/developers/docs/interactions/slash-commands#interaction-interactiontype */
+export enum InteractionTypes {
+ Ping = 1,
+ ApplicationCommand = 2,
+ MessageComponent = 3,
+ ApplicationCommandAutocomplete = 4,
+ ModalSubmit = 5,
+}
+
+/** https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype */
+export enum ApplicationCommandOptionTypes {
+ SubCommand = 1,
+ SubCommandGroup,
+ String,
+ Integer,
+ Boolean,
+ User,
+ Channel,
+ Role,
+ Mentionable,
+ Number,
+ Attachment,
+}
+
+/** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events */
+export enum AuditLogEvents {
+ /** Server settings were updated */
+ GuildUpdate = 1,
+ /** Channel was created */
+ ChannelCreate = 10,
+ /** Channel settings were updated */
+ ChannelUpdate,
+ /** Channel was deleted */
+ ChannelDelete,
+ /** Permission overwrite was added to a channel */
+ ChannelOverwriteCreate,
+ /** Permission overwrite was updated for a channel */
+ ChannelOverwriteUpdate,
+ /** Permission overwrite was deleted from a channel */
+ ChannelOverwriteDelete,
+ /** Member was removed from server */
+ MemberKick = 20,
+ /** Members were pruned from server */
+ MemberPrune,
+ /** Member was banned from server */
+ MemberBanAdd,
+ /** Server ban was lifted for a member */
+ MemberBanRemove,
+ /** Member was updated in server */
+ MemberUpdate,
+ /** Member was added or removed from a role */
+ MemberRoleUpdate,
+ /** Member was moved to a different voice channel */
+ MemberMove,
+ /** Member was disconnected from a voice channel */
+ MemberDisconnect,
+ /** Bot user was added to server */
+ BotAdd,
+ /** Role was created */
+ RoleCreate = 30,
+ /** Role was edited */
+ RoleUpdate,
+ /** Role was deleted */
+ RoleDelete,
+ /** Server invite was created */
+ InviteCreate = 40,
+ /** Server invite was updated */
+ InviteUpdate,
+ /** Server invite was deleted */
+ InviteDelete,
+ /** Webhook was created */
+ WebhookCreate = 50,
+ /** Webhook properties or channel were updated */
+ WebhookUpdate,
+ /** Webhook was deleted */
+ WebhookDelete,
+ /** Emoji was created */
+ EmojiCreate = 60,
+ /** Emoji name was updated */
+ EmojiUpdate,
+ /** Emoji was deleted */
+ EmojiDelete,
+ /** Single message was deleted */
+ MessageDelete = 72,
+ /** Multiple messages were deleted */
+ MessageBulkDelete,
+ /** Messaged was pinned to a channel */
+ MessagePin,
+ /** Message was unpinned from a channel */
+ MessageUnpin,
+ /** App was added to server */
+ IntegrationCreate = 80,
+ /** App was updated (as an example, its scopes were updated) */
+ IntegrationUpdate,
+ /** App was removed from server */
+ IntegrationDelete,
+ /** Stage instance was created (stage channel becomes live) */
+ StageInstanceCreate,
+ /** Stage instace details were updated */
+ StageInstanceUpdate,
+ /** Stage instance was deleted (stage channel no longer live) */
+ StageInstanceDelete,
+ /** Sticker was created */
+ StickerCreate = 90,
+ /** Sticker details were updated */
+ StickerUpdate,
+ /** Sticker was deleted */
+ StickerDelete,
+ /** Event was created */
+ GuildScheduledEventCreate = 100,
+ /** Event was updated */
+ GuildScheduledEventUpdate,
+ /** Event was cancelled */
+ GuildScheduledEventDelete,
+ /** Thread was created in a channel */
+ ThreadCreate = 110,
+ /** Thread was updated */
+ ThreadUpdate,
+ /** Thread was deleted */
+ ThreadDelete,
+ /** Permissions were updated for a command */
+ ApplicationCommandPermissionUpdate = 121,
+ /** Auto moderation rule was created */
+ AutoModerationRuleCreate = 140,
+ /** Auto moderation rule was updated */
+ AutoModerationRuleUpdate,
+ /** Auto moderation rule was deleted */
+ AutoModerationRuleDelete,
+ /** Message was blocked by AutoMod according to a rule. */
+ AutoModerationBlockMessage,
+}
+
+export enum ScheduledEventPrivacyLevel {
+ /** the scheduled event is public and available in discovery. DISCORD DEVS DISABLED THIS! WILL ERROR IF USED! */
+ // Public = 1,
+ /** the scheduled event is only accessible to guild members */
+ GuildOnly = 2,
+}
+
+export enum ScheduledEventEntityType {
+ StageInstance = 1,
+ Voice,
+ External,
+}
+
+export enum ScheduledEventStatus {
+ Scheduled = 1,
+ Active,
+ Completed,
+ Canceled,
+}
+
+/** https://discord.com/developers/docs/resources/invite#invite-object-target-user-types */
+export enum TargetTypes {
+ Stream = 1,
+ EmbeddedApplication,
+}
+
+export enum ApplicationCommandTypes {
+ /** A text-based command that shows up when a user types `/` */
+ ChatInput = 1,
+ /** A UI-based command that shows up when you right click or tap on a user */
+ User,
+ /** A UI-based command that shows up when you right click or tap on a message */
+ Message,
+}
+
+export enum ApplicationCommandPermissionTypes {
+ Role = 1,
+ User,
+ Channel,
+}
+
+/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags */
+export enum ActivityFlags {
+ Instance = 1 << 0,
+ Join = 1 << 1,
+ Spectate = 1 << 2,
+ JoinRequest = 1 << 3,
+ Sync = 1 << 4,
+ Play = 1 << 5,
+ PartyPrivacyFriends = 1 << 6,
+ PartyPrivacyVoiceChannel = 1 << 7,
+ Embedded = 1 << 8,
+}
+
+/** https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags */
+export enum BitwisePermissionFlags {
+ /** Allows creation of instant invites */
+ CREATE_INSTANT_INVITE = 0x0000000000000001,
+ /** Allows kicking members */
+ KICK_MEMBERS = 0x0000000000000002,
+ /** Allows banning members */
+ BAN_MEMBERS = 0x0000000000000004,
+ /** Allows all permissions and bypasses channel permission overwrites */
+ ADMINISTRATOR = 0x0000000000000008,
+ /** Allows management and editing of channels */
+ MANAGE_CHANNELS = 0x0000000000000010,
+ /** Allows management and editing of the guild */
+ MANAGE_GUILD = 0x0000000000000020,
+ /** Allows for the addition of reactions to messages */
+ ADD_REACTIONS = 0x0000000000000040,
+ /** Allows for viewing of audit logs */
+ VIEW_AUDIT_LOG = 0x0000000000000080,
+ /** Allows for using priority speaker in a voice channel */
+ PRIORITY_SPEAKER = 0x0000000000000100,
+ /** Allows the user to go live */
+ STREAM = 0x0000000000000200,
+ /** Allows guild members to view a channel, which includes reading messages in text channels and joining voice channels */
+ VIEW_CHANNEL = 0x0000000000000400,
+ /** Allows for sending messages in a channel. (does not allow sending messages in threads) */
+ SEND_MESSAGES = 0x0000000000000800,
+ /** Allows for sending of /tts messages */
+ SEND_TTS_MESSAGES = 0x0000000000001000,
+ /** Allows for deletion of other users messages */
+ MANAGE_MESSAGES = 0x0000000000002000,
+ /** Links sent by users with this permission will be auto-embedded */
+ EMBED_LINKS = 0x0000000000004000,
+ /** Allows for uploading images and files */
+ ATTACH_FILES = 0x0000000000008000,
+ /** Allows for reading of message history */
+ READ_MESSAGE_HISTORY = 0x0000000000010000,
+ /** Allows for using the @everyone tag to notify all users in a channel, and the @here tag to notify all online users in a channel */
+ MENTION_EVERYONE = 0x0000000000020000,
+ /** Allows the usage of custom emojis from other servers */
+ USE_EXTERNAL_EMOJIS = 0x0000000000040000,
+ /** Allows for viewing guild insights */
+ VIEW_GUILD_INSIGHTS = 0x0000000000080000,
+ /** Allows for joining of a voice channel */
+ CONNECT = 0x0000000000100000,
+ /** Allows for speaking in a voice channel */
+ SPEAK = 0x0000000000200000,
+ /** Allows for muting members in a voice channel */
+ MUTE_MEMBERS = 0x0000000000400000,
+ /** Allows for deafening of members in a voice channel */
+ DEAFEN_MEMBERS = 0x0000000000800000,
+ /** Allows for moving of members between voice channels */
+ MOVE_MEMBERS = 0x0000000001000000,
+ /** Allows for using voice-activity-detection in a voice channel */
+ USE_VAD = 0x0000000002000000,
+ /** Allows for modification of own nickname */
+ CHANGE_NICKNAME = 0x0000000004000000,
+ /** Allows for modification of other users nicknames */
+ MANAGE_NICKNAMES = 0x0000000008000000,
+ /** Allows management and editing of roles */
+ MANAGE_ROLES = 0x0000000010000000,
+ /** Allows management and editing of webhooks */
+ MANAGE_WEBHOOKS = 0x0000000020000000,
+ /** Allows management and editing of emojis */
+ MANAGE_EMOJIS = 0x0000000040000000,
+ /** Allows members to use application commands in text channels */
+ USE_SLASH_COMMANDS = 0x0000000080000000,
+ /** Allows for requesting to speak in stage channels. */
+ REQUEST_TO_SPEAK = 0x0000000100000000,
+ /** Allows for creating, editing, and deleting scheduled events */
+ MANAGE_EVENTS = 0x0000000200000000,
+ /** Allows for deleting and archiving threads, and viewing all private threads */
+ MANAGE_THREADS = 0x0000000400000000,
+ /** Allows for creating public and announcement threads */
+ CREATE_PUBLIC_THREADS = 0x0000000800000000,
+ /** Allows for creating private threads */
+ CREATE_PRIVATE_THREADS = 0x0000001000000000,
+ /** Allows the usage of custom stickers from other servers */
+ USE_EXTERNAL_STICKERS = 0x0000002000000000,
+ /** Allows for sending messages in threads */
+ SEND_MESSAGES_IN_THREADS = 0x0000004000000000,
+ /** Allows for launching activities (applications with the `EMBEDDED` flag) in a voice channel. */
+ USE_EMBEDDED_ACTIVITIES = 0x0000008000000000,
+ /** Allows for timing out users to prevent them from sending or reacting to messages in chat and threads, and from speaking in voice and stage channels */
+ MODERATE_MEMBERS = 0x0000010000000000,
+}
+
+export type PermissionStrings = keyof typeof BitwisePermissionFlags;
+
+/** https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice */
+export enum VoiceOpcodes {
+ /** Begin a voice websocket connection. */
+ Identify,
+ /** Select the voice protocol. */
+ SelectProtocol,
+ /** Complete the websocket handshake. */
+ Ready,
+ /** Keep the websocket connection alive. */
+ Heartbeat,
+ /** Describe the session. */
+ SessionDescription,
+ /** Indicate which users are speaking. */
+ Speaking,
+ /** Sent to acknowledge a received client heartbeat. */
+ HeartbeatACK,
+ /** Resume a connection. */
+ Resume,
+ /** Time to wait between sending heartbeats in milliseconds. */
+ Hello,
+ /** Acknowledge a successful session resume. */
+ Resumed,
+ /** A client has disconnected from the voice channel */
+ ClientDisconnect = 13,
+}
+
+/** https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice */
+export enum VoiceCloseEventCodes {
+ /** You sent an invalid [opcode](https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-opcodes). */
+ UnknownOpcode = 4001,
+ /** You sent a invalid payload in your [identifying](https://discord.com/developers/docs/topics/gateway#identify) to the Gateway. */
+ FailedToDecodePayload,
+ /** You sent a payload before [identifying](https://discord.com/developers/docs/topics/gateway#identify) with the Gateway. */
+ NotAuthenticated,
+ /** The token you sent in your [identify](https://discord.com/developers/docs/topics/gateway#identify) payload is incorrect. */
+ AuthenticationFailed,
+ /** You sent more than one [identify](https://discord.com/developers/docs/topics/gateway#identify) payload. Stahp. */
+ AlreadyAuthenticated,
+ /** Your session is no longer valid. */
+ SessionNoLongerValid,
+ /** Your session has timed out. */
+ SessionTimedOut = 4009,
+ /** We can't find the server you're trying to connect to. */
+ ServerNotFound = 4011,
+ /** We didn't recognize the [protocol](https://discord.com/developers/docs/topics/voice-connections#establishing-a-voice-udp-connection-example-select-protocol-payload) you sent. */
+ UnknownProtocol,
+ /** Channel was deleted, you were kicked, voice server changed, or the main gateway session was dropped. Should not reconnect. */
+ Disconnect = 4014,
+ /** The server crashed. Our bad! Try [resuming](https://discord.com/developers/docs/topics/voice-connections#resuming-voice-connection). */
+ VoiceServerCrashed,
+ /** We didn't recognize your [encryption](https://discord.com/developers/docs/topics/voice-connections#encrypting-and-sending-voice). */
+ UnknownEncryptionMode,
+}
+
+/** https://discord.com/developers/docs/topics/opcodes-and-status-codes#rpc */
+export enum RpcErrorCodes {
+ /** An unknown error occurred. */
+ UnknownError = 1000,
+ /** You sent an invalid payload. */
+ InvalidPayload = 4000,
+ /** Invalid command name specified. */
+ InvalidCommand = 4002,
+ /** Invalid guild ID specified. */
+ InvalidGuild,
+ /** Invalid event name specified. */
+ InvalidEvent,
+ /** Invalid channel ID specified. */
+ InvalidChannel,
+ /** You lack permissions to access the given resource. */
+ InvalidPermissions,
+ /** An invalid OAuth2 application ID was used to authorize or authenticate with. */
+ InvalidClientId,
+ /** An invalid OAuth2 application origin was used to authorize or authenticate with. */
+ InvalidOrigin,
+ /** An invalid OAuth2 token was used to authorize or authenticate with. */
+ InvalidToken,
+ /** The specified user ID was invalid. */
+ InvalidUser,
+ /** A standard OAuth2 error occurred; check the data object for the OAuth2 error details. */
+ OAuth2Error = 5000,
+ /** An asynchronous `SELECT_TEXT_CHANNEL`/`SELECT_VOICE_CHANNEL` command timed out. */
+ SelectChannelTimedOut,
+ /** An asynchronous `GET_GUILD` command timed out. */
+ GetGuildTimedOut,
+ /** You tried to join a user to a voice channel but the user was already in one. */
+ SelectVoiceForceRequired,
+ /** You tried to capture more than one shortcut key at once. */
+ CaptureShortcutAlreadyListening,
+}
+
+/** https://discord.com/developers/docs/topics/opcodes-and-status-codes#rpc */
+export enum RpcCloseEventCodes {
+ /** You connected to the RPC server with an invalid client ID. */
+ InvalidClientId = 4000,
+ /** You connected to the RPC server with an invalid origin. */
+ InvalidOrigin,
+ /** You are being rate limited. */
+ RateLimited,
+ /** The OAuth2 token associated with a connection was revoked, get a new one! */
+ TokenRevoked,
+ /** The RPC Server version specified in the connection string was not valid. */
+ InvalidVersion,
+ /** The encoding specified in the connection string was not valid. */
+ InvalidEncoding,
+}
+
+/** https://discord.com/developers/docs/topics/opcodes-and-status-codes#http */
+export enum HTTPResponseCodes {
+ /** The request completed successfully. */
+ Ok = 200,
+ /** The entity was created successfully. */
+ Created,
+ /** The request completed successfully but returned no content. */
+ NoContent = 204,
+ /** The entity was not modified (no action was taken). */
+ NotModified = 304,
+ /** The request was improperly formatted, or the server couldn't understand it. */
+ BadRequest = 400,
+ /** The `Authorization` header was missing or invalid. */
+ Unauthorized,
+ /** The `Authorization` token you passed did not have permission to the resource. */
+ Forbidden = 403,
+ /** The resource at the location specified doesn't exist. */
+ NotFound,
+ /** The HTTP method used is not valid for the location specified. */
+ MethodNotAllowed,
+ /** You are being rate limited, see [Rate Limits](https://discord.com/developers/docs/topics/rate-limits). */
+ TooManyRequests = 429,
+ /** There was not a gateway available to process your request. Wait a bit and retry. */
+ GatewayUnavailable = 502,
+}
+
+/** https://discord.com/developers/docs/topics/opcodes-and-status-codes#opcodes-and-status-codes */
+export enum GatewayCloseEventCodes {
+ /** A normal closure of the gateway.
+ * You may attempt to reconnect.
+ */
+ NormalClosure = 1000,
+ /** We're not sure what went wrong. Try reconnecting? */
+ UnknownError = 4000,
+ /** You sent an invalid [Gateway opcode](https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes) or an invalid payload for an opcode. Don't do that! */
+ UnknownOpcode,
+ /** You sent an invalid [payload](https://discord.com/developers/docs/topics/gateway#sending-payloads) to us. Don't do that! */
+ DecodeError,
+ /** You sent us a payload prior to [identifying](https://discord.com/developers/docs/topics/gateway#identify). */
+ NotAuthenticated,
+ /** The account token sent with your [identify payload](https://discord.com/developers/docs/topics/gateway#identify) is incorrect. */
+ AuthenticationFailed,
+ /** You sent more than one identify payload. Don't do that! */
+ AlreadyAuthenticated,
+ /** The sequence sent when [resuming](https://discord.com/developers/docs/topics/gateway#resume) the session was invalid. Reconnect and start a new session. */
+ InvalidSeq = 4007,
+ /** Woah nelly! You're sending payloads to us too quickly. Slow it down! You will be disconnected on receiving this. */
+ RateLimited,
+ /** Your session timed out. Reconnect and start a new one. */
+ SessionTimedOut,
+ /** You sent us an invalid [shard when identifying](https://discord.com/developers/docs/topics/gateway#sharding). */
+ InvalidShard,
+ /** The session would have handled too many guilds - you are required to [shard](https://discord.com/developers/docs/topics/gateway#sharding) your connection in order to connect. */
+ ShardingRequired,
+ /** You sent an invalid version for the gateway. */
+ InvalidApiVersion,
+ /** You sent an invalid intent for a [Gateway Intent](https://discord.com/developers/docs/topics/gateway#gateway-intents). You may have incorrectly calculated the bitwise value. */
+ InvalidIntents,
+ /** You sent a disallowed intent for a [Gateway Intent](https://discord.com/developers/docs/topics/gateway#gateway-intents). You may have tried to specify an intent that you [have not enabled or are not approved for](https://discord.com/developers/docs/topics/gateway#privileged-intents). */
+ DisallowedIntents,
+}
+
+/** https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types */
+export enum InviteTargetTypes {
+ Stream = 1,
+ EmbeddedApplication,
+}
+
+/** https://discord.com/developers/docs/topics/opcodes-and-status-codes#gateway-gateway-opcodes */
+export enum GatewayOpcodes {
+ /** An event was dispatched. */
+ Dispatch,
+ /** Fired periodically by the client to keep the connection alive. */
+ Heartbeat,
+ /** Starts a new session during the initial handshake. */
+ Identify,
+ /** Update the client's presence. */
+ PresenceUpdate,
+ /** Used to join/leave or move between voice channels. */
+
+ VoiceStateUpdate,
+ /** Resume a previous session that was disconnected. */
+ Resume = 6,
+ /** You should attempt to reconnect and resume immediately. */
+ Reconnect,
+ /** Request information about offline guild members in a large guild. */
+ RequestGuildMembers,
+ /** The session has been invalidated. You should reconnect and identify/resume accordingly. */
+ InvalidSession,
+ /** Sent immediately after connecting, contains the `heartbeat_interval` to use. */
+ Hello,
+ /** Sent in response to receiving a heartbeat to acknowledge that it has been received. */
+ HeartbeatACK,
+}
+
+export type GatewayDispatchEventNames =
+ | 'READY'
+ | 'CHANNEL_CREATE'
+ | 'CHANNEL_DELETE'
+ | 'CHANNEL_PINS_UPDATE'
+ | 'CHANNEL_UPDATE'
+ | 'GUILD_BAN_ADD'
+ | 'GUILD_BAN_REMOVE'
+ | 'GUILD_CREATE'
+ | 'GUILD_DELETE'
+ | 'GUILD_EMOJIS_UPDATE'
+ | 'GUILD_INTEGRATIONS_UPDATE'
+ | 'GUILD_MEMBER_ADD'
+ | 'GUILD_MEMBER_REMOVE'
+ | 'GUILD_MEMBER_UPDATE'
+ | 'GUILD_MEMBERS_CHUNK'
+ | 'GUILD_ROLE_CREATE'
+ | 'GUILD_ROLE_DELETE'
+ | 'GUILD_ROLE_UPDATE'
+ | 'GUILD_UPDATE'
+ | 'GUILD_SCHEDULED_EVENT_CREATE'
+ | 'GUILD_SCHEDULED_EVENT_DELETE'
+ | 'GUILD_SCHEDULED_EVENT_UPDATE'
+ | 'GUILD_SCHEDULED_EVENT_USER_ADD'
+ | 'GUILD_SCHEDULED_EVENT_USER_REMOVE'
+ | 'INTERACTION_CREATE'
+ | 'INVITE_CREATE'
+ | 'INVITE_DELETE'
+ | 'MESSAGE_CREATE'
+ | 'MESSAGE_DELETE_BULK'
+ | 'MESSAGE_DELETE'
+ | 'MESSAGE_REACTION_ADD'
+ | 'MESSAGE_REACTION_REMOVE_ALL'
+ | 'MESSAGE_REACTION_REMOVE_EMOJI'
+ | 'MESSAGE_REACTION_REMOVE'
+ | 'MESSAGE_UPDATE'
+ | 'PRESENCE_UPDATE'
+ | 'TYPING_START'
+ | 'USER_UPDATE'
+ | 'VOICE_SERVER_UPDATE'
+ | 'VOICE_STATE_UPDATE'
+ | 'WEBHOOKS_UPDATE'
+ | 'INTEGRATION_CREATE'
+ | 'INTEGRATION_UPDATE'
+ | 'INTEGRATION_DELETE'
+ | 'STAGE_INSTANCE_CREATE'
+ | 'STAGE_INSTANCE_UPDATE'
+ | 'STAGE_INSTANCE_DELETE'
+ | 'THREAD_CREATE'
+ | 'THREAD_UPDATE'
+ | 'THREAD_DELETE'
+ | 'THREAD_LIST_SYNC'
+ | 'THREAD_MEMBERS_UPDATE';
+
+export type GatewayEventNames =
+ | GatewayDispatchEventNames
+ | 'READY'
+ | 'RESUMED'
+ // THIS IS A CUSTOM DD EVENT NOT A DISCORD EVENT
+ | 'GUILD_LOADED_DD';
+
+/** https://discord.com/developers/docs/topics/gateway#list-of-intents */
+export enum GatewayIntents {
+ /**
+ * - GUILD_CREATE
+ * - GUILD_DELETE
+ * - GUILD_ROLE_CREATE
+ * - GUILD_ROLE_UPDATE
+ * - GUILD_ROLE_DELETE
+ * - CHANNEL_CREATE
+ * - CHANNEL_UPDATE
+ * - CHANNEL_DELETE
+ * - CHANNEL_PINS_UPDATE
+ * - THREAD_CREATE
+ * - THREAD_UPDATE
+ * - THREAD_DELETE
+ * - THREAD_LIST_SYNC
+ * - THREAD_MEMBER_UPDATE
+ * - THREAD_MEMBERS_UPDATE
+ * - STAGE_INSTANCE_CREATE
+ * - STAGE_INSTANCE_UPDATE
+ * - STAGE_INSTANCE_DELETE
+ */
+ Guilds = 1 << 0,
+ /**
+ * - GUILD_MEMBER_ADD
+ * - GUILD_MEMBER_UPDATE
+ * - GUILD_MEMBER_REMOVE
+ */
+ GuildMembers = 1 << 1,
+ /**
+ * - GUILD_BAN_ADD
+ * - GUILD_BAN_REMOVE
+ */
+ GuildBans = 1 << 2,
+ /**
+ * - GUILD_EMOJIS_UPDATE
+ */
+ GuildEmojis = 1 << 3,
+ /**
+ * - GUILD_INTEGRATIONS_UPDATE
+ * - INTEGRATION_CREATE
+ * - INTEGRATION_UPDATE
+ * - INTEGRATION_DELETE
+ */
+ GuildIntegrations = 1 << 4,
+ /** Enables the following events:
+ * - WEBHOOKS_UPDATE
+ */
+ GuildWebhooks = 1 << 5,
+ /**
+ * - INVITE_CREATE
+ * - INVITE_DELETE
+ */
+ GuildInvites = 1 << 6,
+ /**
+ * - VOICE_STATE_UPDATE
+ */
+ GuildVoiceStates = 1 << 7,
+ /**
+ * - PRESENCE_UPDATE
+ */
+ GuildPresences = 1 << 8,
+ /**
+ * - MESSAGE_CREATE
+ * - MESSAGE_UPDATE
+ * - MESSAGE_DELETE
+ */
+ GuildMessages = 1 << 9,
+ /**
+ * - MESSAGE_REACTION_ADD
+ * - MESSAGE_REACTION_REMOVE
+ * - MESSAGE_REACTION_REMOVE_ALL
+ * - MESSAGE_REACTION_REMOVE_EMOJI
+ */
+ GuildMessageReactions = 1 << 10,
+ /**
+ * - TYPING_START
+ */
+ GuildMessageTyping = 1 << 11,
+ /**
+ * - CHANNEL_CREATE
+ * - MESSAGE_CREATE
+ * - MESSAGE_UPDATE
+ * - MESSAGE_DELETE
+ * - CHANNEL_PINS_UPDATE
+ */
+ DirectMessages = 1 << 12,
+ /**
+ * - MESSAGE_REACTION_ADD
+ * - MESSAGE_REACTION_REMOVE
+ * - MESSAGE_REACTION_REMOVE_ALL
+ * - MESSAGE_REACTION_REMOVE_EMOJI
+ */
+ DirectMessageReactions = 1 << 13,
+ /**
+ * - TYPING_START
+ */
+ DirectMessageTyping = 1 << 14,
+
+ /**
+ * This intent will add `content` values to all message objects.
+ */
+ MessageContent = 1 << 15,
+ /**
+ * - GUILD_SCHEDULED_EVENT_CREATE
+ * - GUILD_SCHEDULED_EVENT_UPDATE
+ * - GUILD_SCHEDULED_EVENT_DELETE
+ * - GUILD_SCHEDULED_EVENT_USER_ADD this is experimental and unstable.
+ * - GUILD_SCHEDULED_EVENT_USER_REMOVE this is experimental and unstable.
+ */
+ GuildScheduledEvents = 1 << 16,
+
+ /**
+ * - AUTO_MODERATION_RULE_CREATE
+ * - AUTO_MODERATION_RULE_UPDATE
+ * - AUTO_MODERATION_RULE_DELETE
+ */
+ AutoModerationConfiguration = 1 << 20,
+ /**
+ * - AUTO_MODERATION_ACTION_EXECUTION
+ */
+ AutoModerationExecution = 1 << 21,
+}
+
+// ALIASES JUST FOR BETTER UX IN THIS CASE
+
+/** https://discord.com/developers/docs/topics/gateway#list-of-intents */
+export const Intents = GatewayIntents;
+
+// eslint-disable-next-line @typescript-eslint/no-redeclare
+export type Intents = GatewayIntents;
+
+/** https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionresponsetype */
+export enum InteractionResponseTypes {
+ /** ACK a `Ping` */
+ Pong = 1,
+ /** Respond to an interaction with a message */
+ ChannelMessageWithSource = 4,
+ /** ACK an interaction and edit a response later, the user sees a loading state */
+ DeferredChannelMessageWithSource = 5,
+ /** For components, ACK an interaction and edit the original message later; the user does not see a loading state */
+ DeferredUpdateMessage = 6,
+ /** For components, edit the message the component was attached to */
+ UpdateMessage = 7,
+ /** For Application Command Options, send an autocomplete result */
+ ApplicationCommandAutocompleteResult = 8,
+ /** For Command or Component interactions, send a Modal response */
+ Modal = 9,
+}
+
+export enum Errors {
+ // Bot Role errors
+ BOTS_HIGHEST_ROLE_TOO_LOW = 'BOTS_HIGHEST_ROLE_TOO_LOW',
+ // Channel Errors
+ CHANNEL_NOT_FOUND = 'CHANNEL_NOT_FOUND',
+ CHANNEL_NOT_IN_GUILD = 'CHANNEL_NOT_IN_GUILD',
+ CHANNEL_NOT_TEXT_BASED = 'CHANNEL_NOT_TEXT_BASED',
+ CHANNEL_NOT_STAGE_VOICE = 'CHANNEL_NOT_STAGE_VOICE',
+ MESSAGE_MAX_LENGTH = 'MESSAGE_MAX_LENGTH',
+ RULES_CHANNEL_CANNOT_BE_DELETED = 'RULES_CHANNEL_CANNOT_BE_DELETED',
+ UPDATES_CHANNEL_CANNOT_BE_DELETED = 'UPDATES_CHANNEL_CANNOT_BE_DELETED',
+ INVALID_TOPIC_LENGTH = 'INVALID_TOPIC_LENGTH',
+ // Guild Errors
+ GUILD_NOT_DISCOVERABLE = 'GUILD_NOT_DISCOVERABLE',
+ GUILD_WIDGET_NOT_ENABLED = 'GUILD_WIDGET_NOT_ENABLED',
+ GUILD_NOT_FOUND = 'GUILD_NOT_FOUND',
+ MEMBER_NOT_FOUND = 'MEMBER_NOT_FOUND',
+ MEMBER_NOT_IN_VOICE_CHANNEL = 'MEMBER_NOT_IN_VOICE_CHANNEL',
+ MEMBER_SEARCH_LIMIT_TOO_HIGH = 'MEMBER_SEARCH_LIMIT_TOO_HIGH',
+ MEMBER_SEARCH_LIMIT_TOO_LOW = 'MEMBER_SEARCH_LIMIT_TOO_LOW',
+ PRUNE_MAX_DAYS = 'PRUNE_MAX_DAYS',
+ ROLE_NOT_FOUND = 'ROLE_NOT_FOUND',
+ // Thread errors
+ INVALID_THREAD_PARENT_CHANNEL_TYPE = 'INVALID_THREAD_PARENT_CHANNEL_TYPE',
+ GUILD_NEWS_CHANNEL_ONLY_SUPPORT_PUBLIC_THREADS = 'GUILD_NEWS_CHANNEL_ONLY_SUPPORT_PUBLIC_THREADS',
+ NOT_A_THREAD_CHANNEL = 'NOT_A_THREAD_CHANNEL',
+ MISSING_MANAGE_THREADS_AND_NOT_MEMBER = 'MISSING_MANAGE_THREADS_AND_NOT_MEMBER',
+ CANNOT_GET_MEMBERS_OF_AN_UNJOINED_PRIVATE_THREAD = 'CANNOT_GET_MEMBERS_OF_AN_UNJOINED_PRIVATE_THREAD',
+ HAVE_TO_BE_THE_CREATOR_OF_THE_THREAD_OR_HAVE_MANAGE_THREADS_TO_REMOVE_MEMBERS = 'HAVE_TO_BE_THE_CREATOR_OF_THE_THREAD_OR_HAVE_MANAGE_THREADS_TO_REMOVE_MEMBERS',
+ // Message Get Errors
+ INVALID_GET_MESSAGES_LIMIT = 'INVALID_GET_MESSAGES_LIMIT',
+ // Message Delete Errors
+ DELETE_MESSAGES_MIN = 'DELETE_MESSAGES_MIN',
+ PRUNE_MIN_DAYS = 'PRUNE_MIN_DAYS',
+ // Interaction Errors
+ INVALID_SLASH_DESCRIPTION = 'INVALID_SLASH_DESCRIPTION',
+ INVALID_SLASH_NAME = 'INVALID_SLASH_NAME',
+ INVALID_SLASH_OPTIONS = 'INVALID_SLASH_OPTIONS',
+ INVALID_SLASH_OPTIONS_CHOICES = 'INVALID_SLASH_OPTIONS_CHOICES',
+ TOO_MANY_SLASH_OPTIONS = 'TOO_MANY_SLASH_OPTIONS',
+ INVALID_SLASH_OPTION_CHOICE_NAME = 'INVALID_SLASH_OPTION_CHOICE_NAME',
+ INVALID_SLASH_OPTIONS_CHOICE_VALUE_TYPE = 'INVALID_SLASH_OPTIONS_CHOICE_VALUE_TYPE',
+ TOO_MANY_SLASH_OPTION_CHOICES = 'TOO_MANY_SLASH_OPTION_CHOICES',
+ ONLY_STRING_OR_INTEGER_OPTIONS_CAN_HAVE_CHOICES = 'ONLY_STRING_OR_INTEGER_OPTIONS_CAN_HAVE_CHOICES',
+ INVALID_SLASH_OPTION_NAME = 'INVALID_SLASH_OPTION_NAME',
+ INVALID_SLASH_OPTION_DESCRIPTION = 'INVALID_SLASH_OPTION_DESCRIPTION',
+ INVALID_CONTEXT_MENU_COMMAND_NAME = 'INVALID_CONTEXT_MENU_COMMAND_NAME',
+ INVALID_CONTEXT_MENU_COMMAND_DESCRIPTION = 'INVALID_CONTEXT_MENU_COMMAND_DESCRIPTION',
+ // Webhook Errors
+ INVALID_WEBHOOK_NAME = 'INVALID_WEBHOOK_NAME',
+ INVALID_WEBHOOK_OPTIONS = 'INVALID_WEBHOOK_OPTIONS',
+ // Permission Errors
+ MISSING_ADD_REACTIONS = 'MISSING_ADD_REACTIONS',
+ MISSING_ADMINISTRATOR = 'MISSING_ADMINISTRATOR',
+ MISSING_ATTACH_FILES = 'MISSING_ATTACH_FILES',
+ MISSING_BAN_MEMBERS = 'MISSING_BAN_MEMBERS',
+ MISSING_CHANGE_NICKNAME = 'MISSING_CHANGE_NICKNAME',
+ MISSING_CONNECT = 'MISSING_CONNECT',
+ MISSING_CREATE_INSTANT_INVITE = 'MISSING_CREATE_INSTANT_INVITE',
+ MISSING_DEAFEN_MEMBERS = 'MISSING_DEAFEN_MEMBERS',
+ MISSING_EMBED_LINKS = 'MISSING_EMBED_LINKS',
+ MISSING_INTENT_GUILD_MEMBERS = 'MISSING_INTENT_GUILD_MEMBERS',
+ MISSING_KICK_MEMBERS = 'MISSING_KICK_MEMBERS',
+ MISSING_MANAGE_CHANNELS = 'MISSING_MANAGE_CHANNELS',
+ MISSING_MANAGE_EMOJIS = 'MISSING_MANAGE_EMOJIS',
+ MISSING_MANAGE_GUILD = 'MISSING_MANAGE_GUILD',
+ MISSING_MANAGE_MESSAGES = 'MISSING_MANAGE_MESSAGES',
+ MISSING_MANAGE_NICKNAMES = 'MISSING_MANAGE_NICKNAMES',
+ MISSING_MANAGE_ROLES = 'MISSING_MANAGE_ROLES',
+ MISSING_MANAGE_WEBHOOKS = 'MISSING_MANAGE_WEBHOOKS',
+ MISSING_MENTION_EVERYONE = 'MISSING_MENTION_EVERYONE',
+ MISSING_MOVE_MEMBERS = 'MISSING_MOVE_MEMBERS',
+ MISSING_MUTE_MEMBERS = 'MISSING_MUTE_MEMBERS',
+ MISSING_PRIORITY_SPEAKER = 'MISSING_PRIORITY_SPEAKER',
+ MISSING_READ_MESSAGE_HISTORY = 'MISSING_READ_MESSAGE_HISTORY',
+ MISSING_SEND_MESSAGES = 'MISSING_SEND_MESSAGES',
+ MISSING_SEND_TTS_MESSAGES = 'MISSING_SEND_TTS_MESSAGES',
+ MISSING_SPEAK = 'MISSING_SPEAK',
+ MISSING_STREAM = 'MISSING_STREAM',
+ MISSING_USE_VAD = 'MISSING_USE_VAD',
+ MISSING_USE_EXTERNAL_EMOJIS = 'MISSING_USE_EXTERNAL_EMOJIS',
+ MISSING_VIEW_AUDIT_LOG = 'MISSING_VIEW_AUDIT_LOG',
+ MISSING_VIEW_CHANNEL = 'MISSING_VIEW_CHANNEL',
+ MISSING_VIEW_GUILD_INSIGHTS = 'MISSING_VIEW_GUILD_INSIGHTS',
+ // User Errors
+ NICKNAMES_MAX_LENGTH = 'NICKNAMES_MAX_LENGTH',
+ USERNAME_INVALID_CHARACTER = 'USERNAME_INVALID_CHARACTER',
+ USERNAME_INVALID_USERNAME = 'USERNAME_INVALID_USERNAME',
+ USERNAME_MAX_LENGTH = 'USERNAME_MAX_LENGTH',
+ USERNAME_MIN_LENGTH = 'USERNAME_MIN_LENGTH',
+ NONCE_TOO_LONG = 'NONCE_TOO_LONG',
+ INVITE_MAX_AGE_INVALID = 'INVITE_MAX_AGE_INVALID',
+ INVITE_MAX_USES_INVALID = 'INVITE_MAX_USES_INVALID',
+ // API Errors
+ RATE_LIMIT_RETRY_MAXED = 'RATE_LIMIT_RETRY_MAXED',
+ REQUEST_CLIENT_ERROR = 'REQUEST_CLIENT_ERROR',
+ REQUEST_SERVER_ERROR = 'REQUEST_SERVER_ERROR',
+ REQUEST_UNKNOWN_ERROR = 'REQUEST_UNKNOWN_ERROR',
+ // Component Errors
+ TOO_MANY_COMPONENTS = 'TOO_MANY_COMPONENTS',
+ TOO_MANY_ACTION_ROWS = 'TOO_MANY_ACTION_ROWS',
+ LINK_BUTTON_CANNOT_HAVE_CUSTOM_ID = 'LINK_BUTTON_CANNOT_HAVE_CUSTOM_ID',
+ COMPONENT_LABEL_TOO_BIG = 'COMPONENT_LABEL_TOO_BIG',
+ COMPONENT_CUSTOM_ID_TOO_BIG = 'COMPONENT_CUSTOM_ID_TOO_BIG',
+ BUTTON_REQUIRES_CUSTOM_ID = 'BUTTON_REQUIRES_CUSTOM_ID',
+ COMPONENT_SELECT_MUST_BE_ALONE = 'COMPONENT_SELECT_MUST_BE_ALONE',
+ COMPONENT_PLACEHOLDER_TOO_BIG = 'COMPONENT_PLACEHOLDER_TOO_BIG',
+ COMPONENT_SELECT_MIN_VALUE_TOO_LOW = 'COMPONENT_SELECT_MIN_VALUE_TOO_LOW',
+ COMPONENT_SELECT_MIN_VALUE_TOO_MANY = 'COMPONENT_SELECT_MIN_VALUE_TOO_MANY',
+ COMPONENT_SELECT_MAX_VALUE_TOO_LOW = 'COMPONENT_SELECT_MAX_VALUE_TOO_LOW',
+ COMPONENT_SELECT_MAX_VALUE_TOO_MANY = 'COMPONENT_SELECT_MAX_VALUE_TOO_MANY',
+ COMPONENT_SELECT_OPTIONS_TOO_LOW = 'COMPONENT_SELECT_OPTIONS_TOO_LOW',
+ COMPONENT_SELECT_OPTIONS_TOO_MANY = 'COMPONENT_SELECT_OPTIONS_TOO_MANY',
+ SELECT_OPTION_LABEL_TOO_BIG = 'SELECT_OPTION_LABEL_TOO_BIG',
+ SELECT_OPTION_VALUE_TOO_BIG = 'SELECT_OPTION_VALUE_TOO_BIG',
+ SELECT_OPTION_TOO_MANY_DEFAULTS = 'SELECT_OPTION_TOO_MANY_DEFAULTS',
+ COMPONENT_SELECT_MIN_HIGHER_THAN_MAX = 'COMPONENT_SELECT_MIN_HIGHER_THAN_MAX',
+ CANNOT_ADD_USER_TO_ARCHIVED_THREADS = 'CANNOT_ADD_USER_TO_ARCHIVED_THREADS',
+ CANNOT_LEAVE_ARCHIVED_THREAD = 'CANNOT_LEAVE_ARCHIVED_THREAD',
+ CANNOT_REMOVE_FROM_ARCHIVED_THREAD = 'CANNOT_REMOVE_FROM_ARCHIVED_THREAD',
+ YOU_CAN_NOT_DM_THE_BOT_ITSELF = 'YOU_CAN_NOT_DM_THE_BOT_ITSELF',
+}
+
+export enum Locales {
+ Danish = 'da',
+ German = 'de',
+ EnglishUk = 'en-GB',
+ EnglishUs = 'en-US',
+ Spanish = 'es-ES',
+ French = 'fr',
+ Croatian = 'hr',
+ Italian = 'it',
+ Lithuanian = 'lt',
+ Hungarian = 'hu',
+ Dutch = 'nl',
+ Norwegian = 'no',
+ Polish = 'pl',
+ PortugueseBrazilian = 'pt-BR',
+ RomanianRomania = 'ro',
+ Finnish = 'fi',
+ Swedish = 'sv-SE',
+ Vietnamese = 'vi',
+ Turkish = 'tr',
+ Czech = 'cs',
+ Greek = 'el',
+ Bulgarian = 'bg',
+ Russian = 'ru',
+ Ukrainian = 'uk',
+ Hindi = 'hi',
+ Thai = 'th',
+ ChineseChina = 'zh-CN',
+ Japanese = 'ja',
+ ChineseTaiwan = 'zh-TW',
+ Korean = 'ko',
+}
+
+export type Localization = Partial>;
+
+export interface FileContent {
+ /** The file blob */
+ blob: Blob;
+ /** The name of the file */
+ name: string;
+}
+
+export interface GatewayBot {
+ /** The WSS URL that can be used for connecting to the gateway */
+ url: string;
+ /** The recommended number of shards to use when connecting */
+ shards: number;
+ /** Information on the current session start limit */
+ sessionStartLimit: {
+ /** The total number of session starts the current user is allowed */
+ total: number;
+ /** The remaining number of session starts the current user is allowed */
+ remaining: number;
+ /** The number of milliseconds after which the limit resets */
+ resetAfter: number;
+ /** The number of identify requests allowed per 5 seconds */
+ maxConcurrency: number;
+ };
+}
+
+// UTILS
+
+export type AtLeastOne }> = Partial &
+ U[keyof U];
+export type MakeRequired = T & { [P in K]-?: T[P] };
+
+// THANK YOU YUI FOR SHARING THIS!
+export type CamelCase =
+ S extends `${infer P1}_${infer P2}${infer P3}`
+ ? `${Lowercase}${Uppercase}${CamelCase}`
+ : Lowercase;
+export type Camelize = {
+ // eslint-disable-next-line @typescript-eslint/array-type
+ [K in keyof T as CamelCase]: T[K] extends Array
+ ? // eslint-disable-next-line @typescript-eslint/ban-types
+ U extends {}
+ ? // eslint-disable-next-line @typescript-eslint/array-type
+ Array>
+ : T[K]
+ : // eslint-disable-next-line @typescript-eslint/ban-types
+ T[K] extends {}
+ ? Camelize
+ : never;
+};
+
+export type PickPartial = {
+ [P in keyof T]?: T[P] | undefined;
+} & { [P in K]: T[P] };
+
+// deno-lint-ignore no-explicit-any
+export type OmitFirstFnArg = F extends (x: any, ...args: infer P) => infer R
+ ? (...args: P) => R
+ : never;
+
+export type Snowflake = string;
diff --git a/packages/api-types/src/index.ts b/packages/api-types/src/index.ts
new file mode 100644
index 0000000..de7a384
--- /dev/null
+++ b/packages/api-types/src/index.ts
@@ -0,0 +1,5 @@
+export * as Constants from './utils/constants';
+export * from './utils/routes';
+
+export * from './v10/index';
+export * from './common';
diff --git a/packages/api-types/src/utils/cdn.ts b/packages/api-types/src/utils/cdn.ts
new file mode 100644
index 0000000..cdd4aad
--- /dev/null
+++ b/packages/api-types/src/utils/cdn.ts
@@ -0,0 +1,29 @@
+import type { Snowflake } from '../common';
+import { baseEndpoints as Endpoints } from './constants';
+
+export function USER_AVATAR(userId: Snowflake, icon: string): string {
+ return `${Endpoints.CDN_URL}/avatars/${userId}/${icon}`;
+}
+
+export function EMOJI_URL(id: Snowflake, animated = false): string {
+ return `https://cdn.discordapp.com/emojis/${id}.${animated ? 'gif' : 'png'}`;
+}
+
+export function USER_DEFAULT_AVATAR(
+ /** user discriminator */
+ altIcon: number,
+): string {
+ return `${Endpoints.CDN_URL}/embed/avatars/${altIcon}.png`;
+}
+
+export function GUILD_BANNER(guildId: Snowflake, icon: string): string {
+ return `${Endpoints.CDN_URL}/banners/${guildId}/${icon}`;
+}
+
+export function GUILD_SPLASH(guildId: Snowflake, icon: string): string {
+ return `${Endpoints.CDN_URL}/splashes/${guildId}/${icon}`;
+}
+
+export function GUILD_ICON(guildId: Snowflake, icon: string): string {
+ return `${Endpoints.CDN_URL}/icons/${guildId}/${icon}`;
+}
diff --git a/packages/api-types/src/utils/constants.ts b/packages/api-types/src/utils/constants.ts
new file mode 100644
index 0000000..b447fc9
--- /dev/null
+++ b/packages/api-types/src/utils/constants.ts
@@ -0,0 +1,26 @@
+/** https://discord.com/developers/docs/reference#api-reference-base-url */
+export const BASE_URL = 'https://discord.com/api';
+
+/** https://discord.com/developers/docs/reference#api-versioning-api-versions */
+export const API_VERSION = 10;
+
+/** https://github.com/discordeno/discordeno/releases */
+export const BISCUIT_VERSION = '0.2.2';
+
+/** https://discord.com/developers/docs/reference#user-agent */
+export const USER_AGENT = `DiscordBot (https://github.com/oasisjs/biscuit, v${BISCUIT_VERSION})`;
+
+/** https://discord.com/developers/docs/reference#image-formatting-image-base-url */
+export const IMAGE_BASE_URL = 'https://cdn.discordapp.com';
+
+// This can be modified by big brain bots and use a proxy
+export const baseEndpoints = {
+ BASE_URL: `${BASE_URL}/v${API_VERSION}`,
+ CDN_URL: IMAGE_BASE_URL,
+};
+
+export const SLASH_COMMANDS_NAME_REGEX =
+ /^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$/u;
+export const CONTEXT_MENU_COMMANDS_NAME_REGEX = /^[\w-\s]{1,32}$/;
+export const CHANNEL_MENTION_REGEX = /<#[0-9]+>/g;
+export const DISCORD_SNOWFLAKE_REGEX = /^(?\d{17,19})$/;
diff --git a/packages/api-types/src/utils/routes.ts b/packages/api-types/src/utils/routes.ts
new file mode 100644
index 0000000..9bdf659
--- /dev/null
+++ b/packages/api-types/src/utils/routes.ts
@@ -0,0 +1,471 @@
+import type { Snowflake } from '../common';
+export * from './cdn';
+
+export function USER(userId?: Snowflake): string {
+ if (!userId) { return '/users/@me'; }
+ return `/users/${userId}`;
+}
+
+export function GATEWAY_BOT(): string {
+ return '/gateway/bot';
+}
+
+export interface GetMessagesOptions {
+ limit?: number;
+}
+
+export interface GetMessagesOptions {
+ around?: Snowflake;
+ limit?: number;
+}
+
+export interface GetMessagesOptions {
+ before?: Snowflake;
+ limit?: number;
+}
+
+export interface GetMessagesOptions {
+ after?: Snowflake;
+ limit?: number;
+}
+
+export function CHANNEL(channelId: Snowflake): string {
+ return `/channels/${channelId}`;
+}
+
+export function CHANNEL_INVITES(channelId: Snowflake): string {
+ return `/channels/${channelId}/invites`;
+}
+
+export function CHANNEL_TYPING(channelId: Snowflake): string {
+ return `/channels/${channelId}/typing`;
+}
+
+export function CHANNEL_CREATE_THREAD(channelId: Snowflake): string {
+ return `/channels/${channelId}/threads`;
+}
+
+export function MESSAGE_CREATE_THREAD(channelId: Snowflake, messageId: Snowflake): string {
+ return `/channels/${channelId}/messages/${messageId}/threads`;
+}
+
+/** used to send messages */
+export function CHANNEL_MESSAGES(channelId: Snowflake, options?: GetMessagesOptions): string {
+ let url = `/channels/${channelId}/messages?`;
+
+ if (options) {
+ if (options.after) { url += `after=${options.after}`; }
+ if (options.before) { url += `&before=${options.before}`; }
+ if (options.around) { url += `&around=${options.around}`; }
+ if (options.limit) { url += `&limit=${options.limit}`; }
+ }
+
+ return url;
+}
+
+/** used to edit messages */
+export function CHANNEL_MESSAGE(channelId: Snowflake, messageId: Snowflake): string {
+ return `/channels/${channelId}/messages/${messageId}`;
+}
+
+/** used to kick members */
+export function GUILD_MEMBER(guildId: Snowflake, userId: Snowflake): string {
+ return `/guilds/${guildId}/members/${userId}`;
+}
+
+/** used to ban members */
+export function GUILD_BAN(guildId: Snowflake, userId: Snowflake): string {
+ return `/guilds/${guildId}/bans/${userId}`;
+}
+
+export interface GetBans {
+ limit?: number;
+ before?: Snowflake;
+ after?: Snowflake;
+}
+
+/** used to unban members */
+export function GUILD_BANS(guildId: Snowflake, options?: GetBans): string {
+ let url = `/guilds/${guildId}/bans?`;
+
+ if (options) {
+ if (options.limit) { url += `limit=${options.limit}`; }
+ if (options.after) { url += `&after=${options.after}`; }
+ if (options.before) { url += `&before=${options.before}`; }
+ }
+
+ return url;
+}
+
+export function GUILD_ROLE(guildId: Snowflake, roleId: Snowflake): string {
+ return `/guilds/${guildId}/roles/${roleId}`;
+}
+
+export function GUILD_ROLES(guildId: Snowflake): string {
+ return `/guilds/${guildId}/roles`;
+}
+
+export function USER_GUILDS(guildId?: Snowflake): string {
+ if (guildId) { return `/users/@me/guilds/${guildId}`; }
+ return `/users/@me/guilds/`;
+}
+
+export function USER_DM() {
+ return `/users/@me/channels`;
+}
+
+export function GUILD_EMOJIS(guildId: Snowflake): string {
+ return `/guilds/${guildId}/emojis`;
+}
+
+export function GUILD_EMOJI(guildId: Snowflake, emojiId: Snowflake): string {
+ return `/guilds/${guildId}/emojis/${emojiId}`;
+}
+
+export interface GetInvite {
+ withCounts?: boolean;
+ withExpiration?: boolean;
+ scheduledEventId?: Snowflake;
+}
+
+export function GUILDS(guildId?: Snowflake): string {
+ if (guildId) { return `/guilds/${guildId}`; }
+ return `/guilds`;
+}
+
+export function AUTO_MODERATION_RULES(guildId: Snowflake, ruleId?: Snowflake): string {
+ if (ruleId) {
+ return `/guilds/${guildId}/auto-moderation/rules/${ruleId}`;
+ }
+ return `/guilds/${guildId}/auto-moderation/rules`;
+}
+
+export function INVITE(inviteCode: string, options?: GetInvite): string {
+ let url = `/invites/${inviteCode}?`;
+
+ if (options) {
+ if (options.withCounts) { url += `with_counts=${options.withCounts}`; }
+ if (options.withExpiration) { url += `&with_expiration=${options.withExpiration}`; }
+ if (options.scheduledEventId) { url += `&guild_scheduled_event_id=${options.scheduledEventId}`; }
+ }
+
+ return url;
+}
+
+export function GUILD_INVITES(guildId: Snowflake): string {
+ return `/guilds/${guildId}/invites`;
+}
+
+export function INTERACTION_ID_TOKEN(interactionId: Snowflake, token: string): string {
+ return `/interactions/${interactionId}/${token}/callback`;
+}
+
+export function WEBHOOK_MESSAGE_ORIGINAL(webhookId: Snowflake, token: string, options?: { threadId?: bigint }): string {
+ let url = `/webhooks/${webhookId}/${token}/messages/@original?`;
+
+ if (options) {
+ if (options.threadId) { url += `thread_id=${options.threadId}`; }
+ }
+
+ return url;
+}
+
+export function WEBHOOK_MESSAGE(
+ webhookId: Snowflake,
+ token: string,
+ messageId: Snowflake,
+ options?: { threadId?: Snowflake },
+): string {
+ let url = `/webhooks/${webhookId}/${token}/messages/${messageId}?`;
+
+ if (options) {
+ if (options.threadId) { url += `thread_id=${options.threadId}`; }
+ }
+
+ return url;
+}
+
+export function WEBHOOK_TOKEN(webhookId: Snowflake, token?: string): string {
+ if (!token) { return `/webhooks/${webhookId}`; }
+ return `/webhooks/${webhookId}/${token}`;
+}
+
+export interface WebhookOptions {
+ wait?: boolean;
+ threadId?: Snowflake;
+}
+
+export function WEBHOOK(webhookId: Snowflake, token: string, options?: WebhookOptions): string {
+ let url = `/webhooks/${webhookId}/${token}`;
+
+ if (options?.wait) { url += `?wait=${options.wait}`; }
+ if (options?.threadId) { url += `?thread_id=${options.threadId}`; }
+ if (options?.wait && options.threadId) { url += `?wait=${options.wait}&thread_id=${options.threadId}`; }
+
+ return url;
+}
+
+export function USER_NICK(guildId: Snowflake): string {
+ return `/guilds/${guildId}/members/@me`;
+}
+
+/**
+ * @link https://discord.com/developers/docs/resources/guild#get-guild-prune-count
+ */
+export interface GetGuildPruneCountQuery {
+ days?: number;
+ includeRoles?: Snowflake | Snowflake[];
+}
+
+export function GUILD_PRUNE(guildId: Snowflake, options?: GetGuildPruneCountQuery): string {
+ let url = `/guilds/${guildId}/prune?`;
+
+ if (options?.days) { url += `days=${options.days}`; }
+ if (options?.includeRoles) { url += `&include_roles=${options.includeRoles}`; }
+
+ return url;
+}
+
+export function CHANNEL_PIN(channelId: Snowflake, messageId: Snowflake): string {
+ return `/channels/${channelId}/pins/${messageId}`;
+}
+
+export function CHANNEL_PINS(channelId: Snowflake): string {
+ return `/channels/${channelId}/pins`;
+}
+
+export function CHANNEL_MESSAGE_REACTION_ME(channelId: Snowflake, messageId: Snowflake, emoji: string): string {
+ return `/channels/${channelId}/messages/${messageId}/reactions/${encodeURIComponent(emoji)}/@me`;
+}
+
+export function CHANNEL_MESSAGE_REACTION_USER(
+ channelId: Snowflake,
+ messageId: Snowflake,
+ emoji: string,
+ userId: Snowflake,
+) {
+ return `/channels/${channelId}/messages/${messageId}/reactions/${encodeURIComponent(emoji)}/${userId}`;
+}
+
+export function CHANNEL_MESSAGE_REACTIONS(channelId: Snowflake, messageId: Snowflake) {
+ return `/channels/${channelId}/messages/${messageId}/reactions`;
+}
+
+/**
+ * @link https://discord.com/developers/docs/resources/channel#get-reactions-query-string-params
+ */
+export interface GetReactions {
+ after?: string;
+ limit?: number;
+}
+
+export function CHANNEL_MESSAGE_REACTION(
+ channelId: Snowflake,
+ messageId: Snowflake,
+ emoji: string,
+ options?: GetReactions,
+): string {
+ let url = `/channels/${channelId}/messages/${messageId}/reactions/${encodeURIComponent(emoji)}?`;
+
+ if (options?.after) { url += `after=${options.after}`; }
+ if (options?.limit) { url += `&limit=${options.limit}`; }
+
+ return url;
+}
+
+export function CHANNEL_MESSAGE_CROSSPOST(channelId: Snowflake, messageId: Snowflake): string {
+ return `/channels/${channelId}/messages/${messageId}/crosspost`;
+}
+
+export function GUILD_MEMBER_ROLE(guildId: Snowflake, memberId: Snowflake, roleId: Snowflake): string {
+ return `/guilds/${guildId}/members/${memberId}/roles/${roleId}`;
+}
+
+export function CHANNEL_WEBHOOKS(channelId: Snowflake): string {
+ return `/channels/${channelId}/webhooks`;
+}
+
+export function THREAD_START_PUBLIC(channelId: Snowflake, messageId: Snowflake): string {
+ return `/channels/${channelId}/messages/${messageId}/threads`;
+}
+
+export function THREAD_START_PRIVATE(channelId: Snowflake): string {
+ return `/channels/${channelId}/threads`;
+}
+
+export function THREAD_ACTIVE(guildId: Snowflake): string {
+ return `/guilds/${guildId}/threads/active`;
+}
+
+export interface ListArchivedThreads {
+ before?: number;
+ limit?: number;
+}
+
+export function THREAD_ME(channelId: Snowflake): string {
+ return `/channels/${channelId}/thread-members/@me`;
+}
+
+export function THREAD_MEMBERS(channelId: Snowflake): string {
+ return `/channels/${channelId}/thread-members`;
+}
+
+export function THREAD_USER(channelId: Snowflake, userId: Snowflake): string {
+ return `/channels/${channelId}/thread-members/${userId}`;
+}
+
+export function THREAD_ARCHIVED(channelId: Snowflake): string {
+ return `/channels/${channelId}/threads/archived`;
+}
+
+export function THREAD_ARCHIVED_PUBLIC(channelId: Snowflake, options?: ListArchivedThreads): string {
+ let url = `/channels/${channelId}/threads/archived/public?`;
+
+ if (options) {
+ if (options.before) { url += `before=${new Date(options.before).toISOString()}`; }
+ if (options.limit) { url += `&limit=${options.limit}`; }
+ }
+
+ return url;
+}
+
+export function THREAD_ARCHIVED_PRIVATE(channelId: Snowflake, options?: ListArchivedThreads): string {
+ let url = `/channels/${channelId}/threads/archived/private?`;
+
+ if (options) {
+ if (options.before) { url += `before=${new Date(options.before).toISOString()}`; }
+ if (options.limit) { url += `&limit=${options.limit}`; }
+ }
+
+ return url;
+}
+
+export function THREAD_ARCHIVED_PRIVATE_JOINED(channelId: Snowflake, options?: ListArchivedThreads): string {
+ let url = `/channels/${channelId}/users/@me/threads/archived/private?`;
+
+ if (options) {
+ if (options.before) { url += `before=${new Date(options.before).toISOString()}`; }
+ if (options.limit) { url += `&limit=${options.limit}`; }
+ }
+
+ return url;
+}
+
+export function FORUM_START(channelId: Snowflake): string {
+ return `/channels/${channelId}/threads?has_message=true`;
+}
+
+export function STAGE_INSTANCES(): string {
+ return `/stage-instances`;
+}
+
+export function STAGE_INSTANCE(channelId: Snowflake): string {
+ return `/stage-instances/${channelId}`;
+}
+
+export function APPLICATION_COMMANDS(appId: Snowflake, commandId?: Snowflake): string {
+ if (commandId) { return `/applications/${appId}/commands/${commandId}`; }
+ return `/applications/${appId}/commands`;
+}
+
+export function GUILD_APPLICATION_COMMANDS(appId: Snowflake, guildId: Snowflake, commandId?: Snowflake): string {
+ if (commandId) { return `/applications/${appId}/guilds/${guildId}/commands/${commandId}`; }
+ return `/applications/${appId}/guilds/${guildId}/commands`;
+}
+
+export function GUILD_APPLICATION_COMMANDS_PERMISSIONS(
+ appId: Snowflake,
+ guildId: Snowflake,
+ commandId?: Snowflake,
+): string {
+ if (commandId) { return `/applications/${appId}/guilds/${guildId}/commands/${commandId}/permissions`; }
+ return `/applications/${appId}/guilds/${guildId}/commands/permissions`;
+}
+
+export function APPLICATION_COMMANDS_LOCALIZATIONS(
+ appId: Snowflake,
+ commandId: Snowflake,
+ withLocalizations?: boolean,
+): string {
+ let url = `/applications/${appId}/commands/${commandId}?`;
+
+ if (withLocalizations !== undefined) {
+ url += `withLocalizations=${withLocalizations}`;
+ }
+
+ return url;
+}
+
+export function GUILD_APPLICATION_COMMANDS_LOCALIZATIONS(
+ appId: Snowflake,
+ guildId: Snowflake,
+ commandId: Snowflake,
+ withLocalizations?: boolean,
+): string {
+ let url = `/applications/${appId}/guilds/${guildId}/commands/${commandId}?`;
+
+ if (withLocalizations !== undefined) {
+ url += `with_localizations=${withLocalizations}`;
+ }
+
+ return url;
+}
+
+export function STICKER(id: Snowflake): string {
+ return `stickers/${id}`;
+}
+
+export function STICKER_PACKS(): string {
+ return `stickers-packs`;
+}
+
+export function GUILD_STICKERS(guildId: Snowflake, stickerId?: Snowflake): string {
+ if (stickerId) { return `/guilds/${guildId}/stickers/${stickerId}`; }
+ return `/guilds/${guildId}/stickers`;
+}
+
+/**
+ * Return the widget for the guild.
+ * @link https://discord.com/developers/docs/resources/guild#get-guild-widget-settings
+ */
+export interface GetWidget {
+ get: 'json' | 'image' | 'settings';
+}
+
+/**
+ * /guilds/{guildId}/widget
+ * @link https://discord.com/developers/docs/resources/guild#get-guild-widget-settings
+ */
+export function GUILD_WIDGET(guildId: Snowflake, options: GetWidget = { get: 'settings' }): string {
+ let url = `/guilds/${guildId}/widget`;
+ if (options.get === 'json') {
+ url += '.json';
+ } else if (options.get === 'image') {
+ url += '.png';
+ }
+
+ return url;
+}
+
+/** @link https://discord.com/developers/docs/resources/guild#get-guild-voice-regions */
+export function GUILD_VOICE_REGIONS(guildId: Snowflake): string {
+ return `/guilds/${guildId}/regions`;
+}
+
+/**
+ * @link https://discord.com/developers/docs/resources/guild#get-guild-vanity-url
+ * @param guildId The guild
+ * @returns Get vanity URL
+ */
+export function GUILD_VANITY(guildId: Snowflake): string {
+ return `/guilds/${guildId}/vanity-url`;
+}
+
+/**
+ * @link https://discord.com/developers/docs/resources/guild#get-guild-preview
+ * @param guildId The guild
+ * @returns Get guild preview url
+ */
+export function GUILD_PREVIEW(guildId: Snowflake): string {
+ return `/guilds/${guildId}/preview`;
+}
diff --git a/packages/api-types/src/v10/index.ts b/packages/api-types/src/v10/index.ts
new file mode 100644
index 0000000..57c3df3
--- /dev/null
+++ b/packages/api-types/src/v10/index.ts
@@ -0,0 +1,2476 @@
+/* eslint-disable no-mixed-spaces-and-tabs */
+import type {
+ ActivityTypes,
+ AllowedMentionsTypes,
+ ApplicationCommandOptionTypes,
+ ApplicationCommandPermissionTypes,
+ ApplicationCommandTypes,
+ ApplicationFlags,
+ AuditLogEvents,
+ ButtonStyles,
+ ChannelFlags,
+ ChannelTypes,
+ DefaultMessageNotificationLevels,
+ EmbedTypes,
+ ExplicitContentFilterLevels,
+ GatewayEventNames,
+ GuildFeatures,
+ GuildNsfwLevel,
+ IntegrationExpireBehaviors,
+ InteractionTypes,
+ // No used
+ // Locales,
+ Localization,
+ MessageActivityTypes,
+ MessageComponentTypes,
+ MessageTypes,
+ MfaLevels,
+ OverwriteTypes,
+ PickPartial,
+ PremiumTiers,
+ PremiumTypes,
+ ScheduledEventEntityType,
+ ScheduledEventPrivacyLevel,
+ ScheduledEventStatus,
+ StickerFormatTypes,
+ StickerTypes,
+ SystemChannelFlags,
+ TargetTypes,
+ TeamMembershipStates,
+ TextStyles,
+ UserFlags,
+ VerificationLevels,
+ VideoQualityModes,
+ VisibilityTypes,
+ WebhookTypes,
+} from '../common';
+
+/** https://discord.com/developers/docs/resources/user#user-object */
+export interface DiscordUser {
+ /** The user's username, not unique across the platform */
+ username: string;
+ /** The user's chosen language option */
+ locale?: string;
+ /** The flags on a user's account */
+ flags?: UserFlags;
+ /** The type of Nitro subscription on a user's account */
+ premium_type?: PremiumTypes;
+ /** The public flags on a user's account */
+ public_flags?: UserFlags;
+ /** the user's banner color encoded as an integer representation of hexadecimal color code */
+ accent_color?: number;
+
+ /** The user's id */
+ id: string;
+ /** The user's 4-digit discord-tag */
+ discriminator: string;
+ /** The user's avatar hash */
+ avatar: string | null;
+ /** Whether the user belongs to an OAuth2 application */
+ bot?: boolean;
+ /** Whether the user is an Official Discord System user (part of the urgent message system) */
+ system?: boolean;
+ /** Whether the user has two factor enabled on their account */
+ mfa_enabled?: boolean;
+ /** Whether the email on this account has been verified */
+ verified?: boolean;
+ /** The user's email */
+ email?: string | null;
+ /** the user's banner, or null if unset */
+ banner?: string;
+}
+
+/** https://discord.com/developers/docs/resources/user#connection-object */
+export interface DiscordConnection {
+ /** id of the connection account */
+ id: string;
+ /** The username of the connection account */
+ name: string;
+ /** The service of the connection (twitch, youtube) */
+ type: string;
+ /** Whether the connection is revoked */
+ revoked?: boolean;
+ /** Whether the connection is verified */
+ verified: boolean;
+ /** Whether friend sync is enabled for this connection */
+ friendSync: boolean;
+ /** Whether activities related to this connection will be shown in presence updates */
+ showActivity: boolean;
+ /** Visibility of this connection */
+ visibility: VisibilityTypes;
+
+ /** An array of partial server integrations */
+ integrations?: DiscordIntegration[];
+}
+
+/** https://discord.com/developers/docs/resources/guild#integration-object-integration-structure */
+export interface DiscordIntegration {
+ /** Integration Id */
+ id: string;
+ /** Integration name */
+ name: string;
+ /** Integration type (twitch, youtube or discord) */
+ type: 'twitch' | 'youtube' | 'discord';
+ /** Is this integration enabled */
+ enabled?: boolean;
+ /** Is this integration syncing */
+ syncing?: boolean;
+ /** Role Id that this integration uses for "subscribers" */
+ role_id?: string;
+ /** Whether emoticons should be synced for this integration (twitch only currently) */
+ enable_emoticons?: boolean;
+ /** The behavior of expiring subscribers */
+ expire_behavior?: IntegrationExpireBehaviors;
+ /** The grace period (in days) before expiring subscribers */
+ expire_grace_period?: number;
+ /** When this integration was last synced */
+ synced_at?: string;
+ /** How many subscribers this integration has */
+ subscriber_count?: number;
+ /** Has this integration been revoked */
+ revoked?: boolean;
+
+ /** User for this integration */
+ user?: DiscordUser;
+ /** Integration account information */
+ account: DiscordIntegrationAccount;
+ /** The bot/OAuth2 application for discord integrations */
+ application?: DiscordIntegrationApplication;
+}
+
+/** https://discord.com/developers/docs/resources/guild#integration-account-object-integration-account-structure */
+export interface DiscordIntegrationAccount {
+ /** Id of the account */
+ id: string;
+ /** Name of the account */
+ name: string;
+}
+
+/** https://discord.com/developers/docs/resources/guild#integration-application-object-integration-application-structure */
+export interface DiscordIntegrationApplication {
+ /** The id of the app */
+ id: string;
+ /** The name of the app */
+ name: string;
+ /** the icon hash of the app */
+ icon: string | null;
+ /** The description of the app */
+ description: string;
+
+ /** The bot associated with this application */
+ bot?: DiscordUser;
+}
+
+/** https://github.com/discord/discord-api-docs/blob/master/docs/topics/Gateway.md#integration-create-event-additional-fields */
+export interface DiscordIntegrationCreateUpdate extends DiscordIntegration {
+ /** Id of the guild */
+ guild_id: string;
+}
+
+/** https://github.com/discord/discord-api-docs/blob/master/docs/topics/Gateway.md#integration-delete-event-fields */
+export interface DiscordIntegrationDelete {
+ /** Integration id */
+ id: string;
+ /** Id of the guild */
+ guild_id: string;
+ /** Id of the bot/OAuth2 application for this discord integration */
+ application_id?: string;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#guild-integrations-update */
+export interface DiscordGuildIntegrationsUpdate {
+ /** id of the guild whose integrations were updated */
+ guild_id: string;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#typing-start */
+export interface DiscordTypingStart {
+ /** Unix time (in seconds) of when the user started typing */
+ timestamp: number;
+
+ /** id of the channel */
+ channel_id: string;
+ /** id of the guild */
+ guild_id?: string;
+ /** id of the user */
+ user_id: string;
+ /** The member who started typing if this happened in a guild */
+ member?: DiscordMember;
+}
+
+/** https://discord.com/developers/docs/resources/guild#guild-member-object */
+export interface DiscordMember {
+ /** Whether the user is deafened in voice channels */
+ deaf?: boolean;
+ /** Whether the user is muted in voice channels */
+ mute?: boolean;
+ /** Whether the user has not yet passed the guild's Membership Screening requirements */
+ pending?: boolean;
+
+ /** The user this guild member represents */
+ user?: DiscordUser;
+ /** This users guild nickname */
+ nick?: string | null;
+ /** The members custom avatar for this server. */
+ avatar?: string;
+ /** Array of role object ids */
+ roles: string[];
+ /** When the user joined the guild */
+ joined_at: string;
+ /** When the user started boosting the guild */
+ premium_since?: string | null;
+ /** The permissions this member has in the guild. Only present on interaction events. */
+ permissions?: string;
+ /** when the user's timeout will expire and the user will be able to communicate in the guild again, null or a time in the past if the user is not timed out */
+ communication_disabled_until?: string | null;
+}
+
+/** https://discord.com/developers/docs/topics/oauth2#application-object */
+export interface DiscordApplication {
+ /** The name of the app */
+ name: string;
+ /** The description of the app */
+ description: string;
+ /** An array of rpc origin urls, if rpc is enabled */
+ rpc_origins?: string[];
+ /** The url of the app's terms of service */
+ terms_of_service_url?: string;
+ /** The url of the app's privacy policy */
+ privacy_policy_url?: string;
+ /** The hex encoded key for verification in interactions and the GameSDK's GetTicket */
+ verify_key: string;
+ /** If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists */
+ primary_sku_id?: string;
+ /** If this application is a game sold on Discord, this field will be the URL slug that links to the store page */
+ slug?: string;
+ /** The application's public flags */
+ flags?: ApplicationFlags;
+
+ /** The id of the app */
+ id: string;
+ /** The icon hash of the app */
+ icon: string | null;
+ /** When false only app owner can join the app's bot to guilds */
+ bot_public: boolean;
+ /** When true the app's bot will only join upon completion of the full oauth2 code grant flow */
+ bot_require_code_grant: boolean;
+ /** Partial user object containing info on the owner of the application */
+ owner?: Partial;
+ /** If the application belongs to a team, this will be a list of the members of that team */
+ team: DiscordTeam | null;
+ /** If this application is a game sold on Discord, this field will be the guild to which it has been linked */
+ guild_id?: string;
+ /** If this application is a game sold on Discord, this field will be the hash of the image on store embeds */
+ cover_image?: string;
+ /** up to 5 tags describing the content and functionality of the application */
+ tags?: string[];
+ /** settings for the application's default in-app authorization link, if enabled */
+ install_params?: DiscordInstallParams;
+ /** the application's default custom authorization link, if enabled */
+ custom_install_url?: string;
+}
+
+/** https://discord.com/developers/docs/topics/teams#data-models-team-object */
+export interface DiscordTeam {
+ /** A hash of the image of the team's icon */
+ icon: string | null;
+ /** The unique id of the team */
+ id: string;
+ /** The members of the team */
+ members: DiscordTeamMember[];
+ /** The user id of the current team owner */
+ owner_user_id: string;
+ /** The name of the team */
+ name: string;
+}
+
+/** https://discord.com/developers/docs/topics/teams#data-models-team-members-object */
+export interface DiscordTeamMember {
+ /** The user's membership state on the team */
+ membership_state: TeamMembershipStates;
+ /** Will always be `["*"]` */
+ permissions: '*'[];
+
+ /** The id of the parent team of which they are a member */
+ team_id: string;
+ /** The avatar, discriminator, id, and username of the user */
+ user: Partial &
+ Pick;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#webhooks-update-webhook-update-event-fields */
+export interface DiscordWebhookUpdate {
+ /** id of the guild */
+ guild_id: string;
+ /** id of the channel */
+ channel_id: string;
+}
+
+/** https://discord.com/developers/docs/resources/channel#allowed-mentions-object */
+export interface DiscordAllowedMentions {
+ /** An array of allowed mention types to parse from the content. */
+ parse?: AllowedMentionsTypes[];
+ /** For replies, whether to mention the author of the message being replied to (default false) */
+ replied_user?: boolean;
+
+ /** Array of role_ids to mention (Max size of 100) */
+ roles?: string[];
+ /** Array of user_ids to mention (Max size of 100) */
+ users?: string[];
+}
+
+/** https://discord.com/developers/docs/resources/channel#embed-object */
+export interface DiscordEmbed {
+ /** Title of embed */
+ title?: string;
+ /** Type of embed (always "rich" for webhook embeds) */
+ type?: EmbedTypes;
+ /** Description of embed */
+ description?: string;
+ /** Url of embed */
+ url?: string;
+ /** Color code of the embed */
+ color?: number;
+
+ /** Timestamp of embed content */
+ timestamp?: string;
+ /** Footer information */
+ footer?: DiscordEmbedFooter;
+ /** Image information */
+ image?: DiscordEmbedImage;
+ /** Thumbnail information */
+ thumbnail?: DiscordEmbedThumbnail;
+ /** Video information */
+ video?: DiscordEmbedVideo;
+ /** Provider information */
+ provider?: DiscordEmbedProvider;
+ /** Author information */
+ author?: DiscordEmbedAuthor;
+ /** Fields information */
+ fields?: DiscordEmbedField[];
+}
+
+/** https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure */
+export interface DiscordEmbedAuthor {
+ /** Name of author */
+ name: string;
+ /** Url of author */
+ url?: string;
+ /** Url of author icon (only supports http(s) and attachments) */
+ icon_url?: string;
+ /** A proxied url of author icon */
+ proxy_icon_url?: string;
+}
+
+/** https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure */
+export interface DiscordEmbedField {
+ /** Name of the field */
+ name: string;
+ /** Value of the field */
+ value: string;
+ /** Whether or not this field should display inline */
+ inline?: boolean;
+}
+
+/** https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure */
+export interface DiscordEmbedFooter {
+ /** Footer text */
+ text: string;
+ /** Url of footer icon (only supports http(s) and attachments) */
+ icon_url?: string;
+ /** A proxied url of footer icon */
+ proxy_icon_url?: string;
+}
+
+/** https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure */
+export interface DiscordEmbedImage {
+ /** Source url of image (only supports http(s) and attachments) */
+ url: string;
+ /** A proxied url of the image */
+ proxy_url?: string;
+ /** Height of image */
+ height?: number;
+ /** Width of image */
+ width?: number;
+}
+
+export interface DiscordEmbedProvider {
+ /** Name of provider */
+ name?: string;
+ /** Url of provider */
+ url?: string;
+}
+
+/** https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure */
+export interface DiscordEmbedThumbnail {
+ /** Source url of thumbnail (only supports http(s) and attachments) */
+ url: string;
+ /** A proxied url of the thumbnail */
+ proxy_url?: string;
+ /** Height of thumbnail */
+ height?: number;
+ /** Width of thumbnail */
+ width?: number;
+}
+
+/** https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure */
+export interface DiscordEmbedVideo {
+ /** Source url of video */
+ url?: string;
+ /** A proxied url of the video */
+ proxy_url?: string;
+ /** Height of video */
+ height?: number;
+ /** Width of video */
+ width?: number;
+}
+
+/** https://discord.com/developers/docs/resources/channel#attachment-object */
+export interface DiscordAttachment {
+ /** Name of file attached */
+ filename: string;
+ /** The attachment's [media type](https://en.wikipedia.org/wiki/Media_type) */
+ content_type?: string;
+ /** Size of file in bytes */
+ size: number;
+ /** Source url of file */
+ url: string;
+ /** A proxied url of file */
+ proxy_url: string;
+
+ /** Attachment id */
+ id: string;
+ /** Height of file (if image) */
+ height?: number | null;
+ /** Width of file (if image) */
+ width?: number | null;
+ /** whether this attachment is ephemeral. Ephemeral attachments will automatically be removed after a set period of time. Ephemeral attachments on messages are guaranteed to be available as long as the message itself exists. */
+ ephemeral?: boolean;
+}
+
+/** https://discord.com/developers/docs/resources/webhook#webhook-object-webhook-structure */
+export type DiscordWebhook = DiscordIncomingWebhook | DiscordApplicationWebhook;
+
+export interface DiscordIncomingWebhook {
+ /** The type of the webhook */
+ type: WebhookTypes;
+ /** The secure token of the webhook (returned for Incoming Webhooks) */
+ token?: string;
+ /** The url used for executing the webhook (returned by the webhooks OAuth2 flow) */
+ url?: string;
+
+ /** The id of the webhook */
+ id: string;
+ /** The guild id this webhook is for */
+ guild_id?: string;
+ /** The channel id this webhook is for */
+ channel_id: string;
+ /** The user this webhook was created by (not returned when getting a webhook with its token) */
+ user?: DiscordUser;
+ /** The default name of the webhook */
+ name: string | null;
+ /** The default user avatar hash of the webhook */
+ avatar: string | null;
+ /** The bot/OAuth2 application that created this webhook */
+ application_id: string | null;
+ /** The guild of the channel that this webhook is following (returned for Channel Follower Webhooks) */
+ source_guild?: Partial;
+ /** The channel that this webhook is following (returned for Channel Follower Webhooks) */
+ source_channel?: Partial;
+}
+
+export interface DiscordApplicationWebhook {
+ /** The type of the webhook */
+ type: WebhookTypes.Application;
+ /** The secure token of the webhook (returned for Incoming Webhooks) */
+ token?: string;
+ /** The url used for executing the webhook (returned by the webhooks OAuth2 flow) */
+ url?: string;
+
+ /** The id of the webhook */
+ id: string;
+ /** The guild id this webhook is for */
+ guild_id?: string | null;
+ /** The channel id this webhook is for */
+ channel_id?: string | null;
+ /** The user this webhook was created by (not returned when getting a webhook with its token) */
+ user?: DiscordUser;
+ /** The default name of the webhook */
+ name: string | null;
+ /** The default user avatar hash of the webhook */
+ avatar: string | null;
+ /** The bot/OAuth2 application that created this webhook */
+ application_id: string | null;
+ /** The guild of the channel that this webhook is following (returned for Channel Follower Webhooks) */
+ source_guild?: Partial;
+ /** The channel that this webhook is following (returned for Channel Follower Webhooks) */
+ source_channel?: Partial;
+}
+
+/** https://discord.com/developers/docs/resources/guild#guild-object */
+export interface DiscordGuild {
+ /** Guild name (2-100 characters, excluding trailing and leading whitespace) */
+ name: string;
+ /** True if the user is the owner of the guild */
+ owner?: boolean;
+ /** Afk timeout in seconds */
+ afk_timeout: number;
+ /** True if the server widget is enabled */
+ widget_enabled?: boolean;
+ /** Verification level required for the guild */
+ verification_level: VerificationLevels;
+ /** Default message notifications level */
+ default_message_notifications: DefaultMessageNotificationLevels;
+ /** Explicit content filter level */
+ explicit_content_filter: ExplicitContentFilterLevels;
+ /** Enabled guild features */
+ features: GuildFeatures[];
+ /** Required MFA level for the guild */
+ mfa_level: MfaLevels;
+ /** System channel flags */
+ system_channel_flags: SystemChannelFlags;
+ /** True if this is considered a large guild */
+ large?: boolean;
+ /** True if this guild is unavailable due to an outage */
+ unavailable?: boolean;
+ /** Total number of members in this guild */
+ member_count?: number;
+ /** The maximum number of presences for the guild (the default value, currently 25000, is in effect when null is returned) */
+ max_presences?: number | null;
+ /** The maximum number of members for the guild */
+ max_members?: number;
+ /** The vanity url code for the guild */
+ vanity_url_code: string | null;
+ /** The description of a guild */
+ description: string | null;
+ /** Premium tier (Server Boost level) */
+ premium_tier: PremiumTiers;
+ /** The number of boosts this guild currently has */
+ premium_subscription_count?: number;
+ /** The maximum amount of users in a video channel */
+ max_video_channel_users?: number;
+ /** Approximate number of members in this guild, returned from the GET /guilds/ endpoint when with_counts is true */
+ approximate_member_count?: number;
+ /** Approximate number of non-offline members in this guild, returned from the GET /guilds/ endpoint when with_counts is true */
+ approximate_presence_count?: number;
+ /** Guild NSFW level */
+ nsfw_level: GuildNsfwLevel;
+ /** Whether the guild has the boost progress bar enabled */
+ premium_progress_bar_enabled: boolean;
+
+ /** Guild id */
+ id: string;
+ /** Icon hash */
+ icon: string | null;
+ /** Icon hash, returned when in the template object */
+ icon_hash?: string | null;
+ /** Splash hash */
+ splash: string | null;
+ /** Discovery splash hash; only present for guilds with the "DISCOVERABLE" feature */
+ discovery_splash: string | null;
+ /** Id of the owner */
+ owner_id: string;
+ /** Total permissions for the user in the guild (excludes overwrites) */
+ permissions?: string;
+ /** Id of afk channel */
+ afk_channel_id: string | null;
+ /** The channel id that the widget will generate an invite to, or null if set to no invite */
+ widget_channel_id?: string | null;
+ /** Roles in the guild */
+ roles: DiscordRole[];
+ /** Custom guild emojis */
+ emojis: DiscordEmoji[];
+ /** Application id of the guild creator if it is bot-created */
+ application_id: string | null;
+ /** The id of the channel where guild notices such as welcome messages and boost events are posted */
+ system_channel_id: string | null;
+ /** The id of the channel where community guilds can display rules and/or guidelines */
+ rules_channel_id: string | null;
+ /** When this guild was joined at */
+ joined_at?: string;
+ /** States of members currently in voice channels; lacks the guild_id key */
+ voice_states?: Omit[];
+ /** Users in the guild */
+ members?: DiscordMember[];
+ /** Channels in the guild */
+ channels?: DiscordChannel[];
+ // TODO: check if need to omit
+ /** All active threads in the guild that the current user has permission to view */
+ threads?: DiscordChannel[];
+ /** Presences of the members in the guild, will only include non-offline members if the size is greater than large threshold */
+ presences?: Partial[];
+ /** Banner hash */
+ banner: string | null;
+ // TODO: Can be optimized to a number but is it worth it?
+ /** The preferred locale of a Community guild; used in server discovery and notices from Discord; defaults to "en-US" */
+ preferred_locale: string;
+ /** The id of the channel where admins and moderators of Community guilds receive notices from Discord */
+ public_updates_channel_id: string | null;
+ /** The welcome screen of a Community guild, shown to new members, returned in an Invite's guild object */
+ welcome_screen?: DiscordWelcomeScreen;
+ /** Stage instances in the guild */
+ stage_instances?: DiscordStageInstance[];
+}
+
+/** https://discord.com/developers/docs/topics/permissions#role-object-role-structure */
+export interface DiscordRole {
+ /** Role id */
+ id: string;
+ /** If this role is showed separately in the user listing */
+ hoist: boolean;
+ /** Permission bit set */
+ permissions: string;
+ /** Whether this role is managed by an integration */
+ managed: boolean;
+ /** Whether this role is mentionable */
+ mentionable: boolean;
+ /** The tags this role has */
+ tags?: DiscordRoleTags;
+ /** the role emoji hash */
+ icon?: string;
+ /** Role name */
+ name: string;
+ /** Integer representation of hexadecimal color code */
+ color: number;
+ /** Position of this role */
+ position: number;
+ /** role unicode emoji */
+ unicode_emoji?: string;
+}
+
+/** https://discord.com/developers/docs/topics/permissions#role-object-role-tags-structure */
+export interface DiscordRoleTags {
+ /** The id of the bot this role belongs to */
+ bot_id?: string;
+ /** The id of the integration this role belongs to */
+ integration_id?: string;
+ /** Whether this is the guild's premium subscriber role */
+ premium_subscriber?: null;
+}
+
+/** https://discord.com/developers/docs/resources/emoji#emoji-object-emoji-structure */
+export interface DiscordEmoji {
+ /** Emoji name (can only be null in reaction emoji objects) */
+ name?: string;
+
+ /** Emoji id */
+ id?: string;
+ /** Roles allowed to use this emoji */
+ roles?: string[];
+ /** User that created this emoji */
+ user?: DiscordUser;
+ /** Whether this emoji must be wrapped in colons */
+ require_colons?: boolean;
+ /** Whether this emoji is managed */
+ managed?: boolean;
+ /** Whether this emoji is animated */
+ animated?: boolean;
+ /** Whether this emoji can be used, may be false due to loss of Server Boosts */
+ available?: boolean;
+}
+
+/** https://discord.com/developers/docs/resources/voice#voice-state-object-voice-state-structure */
+export interface DiscordVoiceState {
+ /** The session id for this voice state */
+ session_id: string;
+
+ /** The guild id this voice state is for */
+ guild_id?: string;
+ /** The channel id this user is connected to */
+ channel_id: string | null;
+ /** The user id this voice state is for */
+ user_id: string;
+ /** The guild member this voice state is for */
+ member?: DiscordMemberWithUser;
+ /** Whether this user is deafened by the server */
+ deaf: boolean;
+ /** Whether this user is muted by the server */
+ mute: boolean;
+ /** Whether this user is locally deafened */
+ self_deaf: boolean;
+ /** Whether this user is locally muted */
+ self_mute: boolean;
+ /** Whether this user is streaming using "Go Live" */
+ self_stream?: boolean;
+ /** Whether this user's camera is enabled */
+ self_video: boolean;
+ /** Whether this user is muted by the current user */
+ suppress: boolean;
+ /** The time at which the user requested to speak */
+ request_to_speak_timestamp: string | null;
+}
+
+/** https://discord.com/developers/docs/resources/channel#channel-object */
+export interface DiscordChannel {
+ /** The type of channel */
+ type: ChannelTypes;
+ /** The flags of the channel */
+ flags?: ChannelFlags;
+ /** Sorting position of the channel */
+ position?: number;
+ /** The name of the channel (1-100 characters) */
+ name?: string;
+ /** The channel topic (0-1024 characters) */
+ topic?: string | null;
+ /** The bitrate (in bits) of the voice channel */
+ bitrate?: number;
+ /** The user limit of the voice channel */
+ user_limit?: number;
+ /** Amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission `manage_messages` or `manage_channel`, are unaffected */
+ rate_limit_per_user?: number;
+ /** Voice region id for the voice channel, automatic when set to null */
+ rtc_region?: string | null;
+ /** The camera video quality mode of the voice channel, 1 when not present */
+ video_quality_mode?: VideoQualityModes;
+ /** An approximate count of messages in a thread, stops counting at 50 */
+ message_count?: number;
+ /** An approximate count of users in a thread, stops counting at 50 */
+ member_count?: number;
+ /** Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 */
+ default_auto_archive_duration?: number;
+
+ /** The id of the channel */
+ id: string;
+ /** The id of the guild */
+ guild_id?: string;
+ /** Explicit permission overwrites for members and roles */
+ permission_overwrites?: DiscordOverwrite[];
+ /** Whether the channel is nsfw */
+ nsfw?: boolean;
+ /** The id of the last message sent in this channel (may not point to an existing or valid message) */
+ last_message_id?: string | null;
+ /** Id of the creator of the thread */
+ owner_id?: string;
+ /** Application id of the group DM creator if it is bot-created */
+ application_id?: string;
+ /** For guild channels: Id of the parent category for a channel (each parent category can contain up to 50 channels), for threads: id of the text channel this thread was created */
+ parent_id?: string | null;
+ /** When the last pinned message was pinned. This may be null in events such as GUILD_CREATE when a message is not pinned. */
+ last_pin_timestamp?: string | null;
+ /** Thread-specific fields not needed by other channels */
+ thread_metadata?: DiscordThreadMetadata;
+ /** Thread member object for the current user, if they have joined the thread, only included on certain API endpoints */
+ member?: DiscordThreadMember;
+ /** computed permissions for the invoking user in the channel, including overwrites, only included when part of the resolved data received on a application command interaction */
+ permissions?: string;
+ /** When a thread is created this will be true on that channel payload for the thread. */
+ newly_created?: boolean;
+ /** The recipients of the DM*/
+ recipents?: DiscordUser[];
+}
+
+/** https://discord.com/developers/docs/topics/gateway#presence-update */
+export interface DiscordPresenceUpdate {
+ /** Either "idle", "dnd", "online", or "offline" */
+ status: 'idle' | 'dnd' | 'online' | 'offline';
+ /** The user presence is being updated for */
+ user: DiscordUser;
+ /** id of the guild */
+ guild_id: string;
+ /** User's current activities */
+ activities: DiscordActivity[];
+ /** User's platform-dependent status */
+ client_status: DiscordClientStatus;
+}
+
+export interface DiscordStatusUpdate {
+ /** User's current activities */
+ activities: DiscordActivity[];
+ /** Either "idle", "dnd", "online", or "offline" */
+ status: 'idle' | 'dnd' | 'online' | 'offline';
+}
+
+/** https://discord.com/developers/docs/resources/guild#welcome-screen-object-welcome-screen-structure */
+export interface DiscordWelcomeScreen {
+ /** The server description shown in the welcome screen */
+ description: string | null;
+ /** The channels shown in the welcome screen, up to 5 */
+ welcome_channels: DiscordWelcomeScreenChannel[];
+}
+
+/** https://discord.com/developers/docs/resources/guild#welcome-screen-object-welcome-screen-channel-structure */
+export interface DiscordWelcomeScreenChannel {
+ /** The description shown for the channel */
+ description: string;
+
+ /** The channel's id */
+ channel_id: string;
+ /** The emoji id, if the emoji is custom */
+ emoji_id: string | null;
+ /** The emoji name if custom, the unicode character if standard, or `null` if no emoji is set */
+ emoji_name: string | null;
+}
+
+/** https://discord.com/developers/docs/resources/stage-instance#auto-closing-stage-instance-structure */
+export interface DiscordStageInstance {
+ /** The topic of the Stage instance (1-120 characters) */
+ topic: string;
+ /** The id of this Stage instance */
+ id: string;
+ /** The guild id of the associated Stage channel */
+ guild_id: string;
+ /** The id of the associated Stage channel */
+ channel_id: string;
+ /** The id of the scheduled event for this Stage instance */
+ guild_scheduled_event_id?: string;
+}
+
+export interface DiscordThreadMetadata {
+ /** Whether the thread is archived */
+ archived: boolean;
+ /** Duration in minutes to automatically archive the thread after recent activity */
+ auto_archive_duration: 60 | 1440 | 4320 | 10080;
+ /** When a thread is locked, only users with `MANAGE_THREADS` can unarchive it */
+ locked: boolean;
+ /** whether non-moderators can add other non-moderators to a thread; only available on private threads */
+ invitable?: boolean;
+ /** Timestamp when the thread's archive status was last changed, used for calculating recent activity */
+ archive_timestamp: string;
+ /** Timestamp when the thread was created; only populated for threads created after 2022-01-09 */
+ create_timestamp?: string | null;
+}
+
+export interface DiscordThreadMemberBase {
+ /** Any user-thread settings, currently only used for notifications */
+ flags: number;
+}
+
+export interface DiscordThreadMember {
+ /** Any user-thread settings, currently only used for notifications */
+ flags: number;
+ /** The id of the thread */
+ id: string;
+ /** The id of the user */
+ user_id: string;
+ /** The time the current user last joined the thread */
+ join_timestamp: string;
+}
+
+export interface DiscordThreadMemberGuildCreate {
+ /** Any user-thread settings, currently only used for notifications */
+ flags: number;
+ /** The time the current user last joined the thread */
+ join_timestamp: string;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#activity-object */
+export interface DiscordActivity {
+ /** The activity's name */
+ name: string;
+ /** Activity type */
+ type: ActivityTypes;
+ /** Stream url, is validated when type is 1 */
+ url?: string | null;
+ /** Unix timestamp of when the activity was added to the user's session */
+ created_at: number;
+ /** What the player is currently doing */
+ details?: string | null;
+ /** The user's current party status */
+ state?: string | null;
+ /** Whether or not the activity is an instanced game session */
+ instance?: boolean;
+ /** Activity flags `OR`d together, describes what the payload includes */
+ flags?: number;
+ /** Unix timestamps for start and/or end of the game */
+ timestamps?: DiscordActivityTimestamps;
+ /** Application id for the game */
+ application_id?: string;
+ /** The emoji used for a custom status */
+ emoji?: DiscordActivityEmoji | null;
+ /** Information for the current party of the player */
+ party?: DiscordActivityParty;
+ /** Images for the presence and their hover texts */
+ assets?: DiscordActivityAssets;
+ /** Secrets for Rich Presence joining and spectating */
+ secrets?: DiscordActivitySecrets;
+ /** The custom buttons shown in the Rich Presence (max 2) */
+ buttons?: DiscordActivityButton[];
+}
+
+/** https://discord.com/developers/docs/topics/gateway#client-status-object */
+export interface DiscordClientStatus {
+ /** The user's status set for an active desktop (Windows, Linux, Mac) application session */
+ desktop?: string;
+ /** The user's status set for an active mobile (iOS, Android) application session */
+ mobile?: string;
+ /** The user's status set for an active web (browser, bot account) application session */
+ web?: string;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-timestamps */
+export interface DiscordActivityTimestamps {
+ /** Unix time (in milliseconds) of when the activity started */
+ start?: number;
+ /** Unix time (in milliseconds) of when the activity ends */
+ end?: number;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-emoji */
+export interface DiscordActivityEmoji {
+ /** The name of the emoji */
+ name: string;
+ /** Whether this emoji is animated */
+ animated?: boolean;
+ /** The id of the emoji */
+ id?: string;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-party */
+export interface DiscordActivityParty {
+ /** Used to show the party's current and maximum size */
+ size?: [currentSize: number, maxSize: number];
+ /** The id of the party */
+ id?: string;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-assets */
+export interface DiscordActivityAssets {
+ /** Text displayed when hovering over the large image of the activity */
+ large_text?: string;
+ /** Text displayed when hovering over the small image of the activity */
+ small_text?: string;
+ /** The id for a large asset of the activity, usually a snowflake */
+ large_image?: string;
+ /** The id for a small asset of the activity, usually a snowflake */
+ small_image?: string;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-secrets */
+export interface DiscordActivitySecrets {
+ /** The secret for joining a party */
+ join?: string;
+ /** The secret for spectating a game */
+ spectate?: string;
+ /** The secret for a specific instanced match */
+ match?: string;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#activity-object-activity-buttons */
+export interface DiscordActivityButton {
+ /** The text shown on the button (1-32 characters) */
+ label: string;
+ /** The url opened when clicking the button (1-512 characters) */
+ url: string;
+}
+
+export interface DiscordOverwrite {
+ /** Either 0 (role) or 1 (member) */
+ type: OverwriteTypes;
+ /** Role or user id */
+ id: string;
+ /** Permission bit set */
+ allow?: string;
+ /** Permission bit set */
+ deny?: string;
+}
+
+export interface DiscordMemberWithUser extends DiscordMember {
+ /** The user object for this member */
+ user: DiscordUser;
+}
+
+/** https://discord.com/developers/docs/resources/channel#message-object */
+export interface DiscordMessage {
+ /** id of the message */
+ id: string;
+ /** id of the channel the message was sent in */
+ channel_id: string;
+ /**
+ * id of the guild the message was sent in
+ * Note: For MESSAGE_CREATE and MESSAGE_UPDATE events, the message object may not contain a guild_id or member field since the events are sent directly to the receiving user and the bot who sent the message, rather than being sent through the guild like non-ephemeral messages.
+ */
+ guild_id?: string;
+ /**
+ * The author of this message (not guaranteed to be a valid user)
+ * Note: The author object follows the structure of the user object, but is only a valid user in the case where the message is generated by a user or bot user. If the message is generated by a webhook, the author object corresponds to the webhook's id, username, and avatar. You can tell if a message is generated by a webhook by checking for the webhook_id on the message object.
+ */
+ author: DiscordUser;
+ /**
+ * Member properties for this message's author
+ * Note: The member object exists in `MESSAGE_CREATE` and `MESSAGE_UPDATE` events from text-based guild channels. This allows bots to obtain real-time member data without requiring bots to store member state in memory.
+ */
+ member?: DiscordMember;
+ /** Contents of the message */
+ content?: string;
+ /** When this message was sent */
+ timestamp: string;
+ /** When this message was edited (or null if never) */
+ edited_timestamp: string | null;
+ /** Whether this was a TTS message */
+ tts: boolean;
+ /** Whether this message mentions everyone */
+ mention_everyone: boolean;
+ /**
+ * Users specifically mentioned in the message
+ * Note: The user objects in the mentions array will only have the partial member field present in `MESSAGE_CREATE` and `MESSAGE_UPDATE` events from text-based guild channels.
+ */
+ mentions?: (DiscordUser & { member?: Partial })[];
+ /** Roles specifically mentioned in this message */
+ mention_roles?: string[];
+ /**
+ * Channels specifically mentioned in this message
+ * Note: Not all channel mentions in a message will appear in `mention_channels`. Only textual channels that are visible to everyone in a lurkable guild will ever be included. Only crossposted messages (via Channel Following) currently include `mention_channels` at all. If no mentions in the message meet these requirements, this field will not be sent.
+ */
+ mention_channels?: DiscordChannelMention[];
+ /** Any attached files */
+ attachments: DiscordAttachment[];
+ /** Any embedded content */
+ embeds: DiscordEmbed[];
+ /** Reactions to the message */
+ reactions?: DiscordReaction[];
+ /** Used for validating a message was sent */
+ nonce?: number | string;
+ /** Whether this message is pinned */
+ pinned: boolean;
+ /** If the message is generated by a webhook, this is the webhook's id */
+ webhook_id?: string;
+ /** Type of message */
+ type: MessageTypes;
+ /** Sent with Rich Presence-related chat embeds */
+ activity?: DiscordMessageActivity;
+ /** Sent with Rich Presence-related chat embeds */
+ application?: Partial;
+ /** if the message is an Interaction or application-owned webhook, this is the id of the application */
+ application_id?: string;
+ /** Data showing the source of a crossposted channel follow add, pin or reply message */
+ message_reference?: Omit;
+ /** Message flags combined as a bitfield */
+ flags?: number;
+ /**
+ * The stickers sent with the message (bots currently can only receive messages with stickers, not send)
+ * @deprecated
+ */
+ stickers?: DiscordSticker[];
+ /**
+ * The message associated with the `message_reference`
+ * Note: This field is only returned for messages with a `type` of `19` (REPLY). If the message is a reply but the `referenced_message` field is not present, the backend did not attempt to fetch the message that was being replied to, so its state is unknown. If the field exists but is null, the referenced message was deleted.
+ */
+ referenced_message?: DiscordMessage;
+ /** Sent if the message is a response to an Interaction */
+ interaction?: DiscordMessageInteraction;
+ /** The thread that was started from this message, includes thread member object */
+ thread?: Omit & { member: DiscordThreadMember };
+ /** The components related to this message */
+ components?: DiscordMessageComponents;
+ /** Sent if the message contains stickers */
+ sticker_items?: DiscordStickerItem[];
+}
+
+/** https://discord.com/developers/docs/resources/channel#channel-mention-object */
+export interface DiscordChannelMention {
+ /** id of the channel */
+ id: string;
+ /** id of the guild containing the channel */
+ guild_id: string;
+ /** The type of channel */
+ type: number;
+ /** The name of the channel */
+ name: string;
+}
+
+/** https://discord.com/developers/docs/resources/channel#reaction-object */
+export interface DiscordReaction {
+ /** Times this emoji has been used to react */
+ count: number;
+ /** Whether the current user reacted using this emoji */
+ me: boolean;
+ /** Emoji information */
+ emoji: Partial;
+}
+
+/** https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure */
+export interface DiscordMessageActivity {
+ /** Type of message activity */
+ type: MessageActivityTypes;
+ /** `party_id` from a Rich Presence event */
+ party_id?: string;
+}
+
+/** https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure */
+export interface DiscordMessageReference {
+ /** id of the originating message */
+ message_id?: string;
+ /**
+ * id of the originating message's channel
+ * Note: `channel_id` is optional when creating a reply, but will always be present when receiving an event/response that includes this data model.
+ */
+ channel_id?: string;
+ /** id of the originating message's guild */
+ guild_id?: string;
+ /** When sending, whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message, default true */
+ fail_if_not_exists: boolean;
+}
+
+/** https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-structure */
+export interface DiscordSticker {
+ /** [Id of the sticker](https://discord.com/developers/docs/reference#image-formatting) */
+ id: string;
+ /** Id of the pack the sticker is from */
+ pack_id?: string;
+ /** Name of the sticker */
+ name: string;
+ /** Description of the sticker */
+ description: string;
+ /** a unicode emoji representing the sticker's expression */
+ tags: string;
+ /** [type of sticker](https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types) */
+ type: StickerTypes;
+ /** [Type of sticker format](https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types) */
+ format_type: StickerFormatTypes;
+ /** Whether or not the sticker is available */
+ available?: boolean;
+ /** Id of the guild that owns this sticker */
+ guild_id?: string;
+ /** The user that uploaded the sticker */
+ user?: DiscordUser;
+ /** A sticker's sort order within a pack */
+ sort_value?: number;
+}
+
+/** https://discord.com/developers/docs/interactions/receiving-and-responding#message-interaction-object-message-interaction-structure */
+export interface DiscordMessageInteraction {
+ /** Id of the interaction */
+ id: string;
+ /** The type of interaction */
+ type: InteractionTypes;
+ /** The name of the ApplicationCommand */
+ name: string;
+ /** The user who invoked the interaction */
+ user: DiscordUser;
+ /** The member who invoked the interaction in the guild */
+ member?: Partial;
+}
+
+export type DiscordMessageComponents = DiscordActionRow[];
+
+/** https://discord.com/developers/docs/interactions/message-components#actionrow */
+export interface DiscordActionRow {
+ /** Action rows are a group of buttons. */
+ type: 1;
+ /** The components in this row */
+ components:
+ | [
+ | DiscordSelectMenuComponent
+ | DiscordButtonComponent
+ | DiscordInputTextComponent
+ ]
+ | [DiscordButtonComponent, DiscordButtonComponent]
+ | [
+ DiscordButtonComponent,
+ DiscordButtonComponent,
+ DiscordButtonComponent
+ ]
+ | [
+ DiscordButtonComponent,
+ DiscordButtonComponent,
+ DiscordButtonComponent,
+ DiscordButtonComponent
+ ]
+ | [
+ DiscordButtonComponent,
+ DiscordButtonComponent,
+ DiscordButtonComponent,
+ DiscordButtonComponent,
+ DiscordButtonComponent
+ ];
+}
+
+export interface DiscordSelectMenuComponent {
+ type: MessageComponentTypes.SelectMenu;
+ /** A custom identifier for this component. Maximum 100 characters. */
+ custom_id: string;
+ /** A custom placeholder text if nothing is selected. Maximum 150 characters. */
+ placeholder?: string;
+ /** The minimum number of items that must be selected. Default 1. Between 1-25. */
+ min_values?: number;
+ /** The maximum number of items that can be selected. Default 1. Between 1-25. */
+ max_values?: number;
+ /** The choices! Maximum of 25 items. */
+ options: DiscordSelectOption[];
+ /** Whether or not this select menu is disabled */
+ disabled?: boolean;
+}
+
+export interface DiscordSelectOption {
+ /** The user-facing name of the option. Maximum 25 characters. */
+ label: string;
+ /** The dev-defined value of the option. Maximum 100 characters. */
+ value: string;
+ /** An additional description of the option. Maximum 50 characters. */
+ description?: string;
+ /** The id, name, and animated properties of an emoji. */
+ emoji?: {
+ /** Emoji id */
+ id?: string;
+ /** Emoji name */
+ name?: string;
+ /** Whether this emoji is animated */
+ animated?: boolean;
+ };
+ /** Will render this option as already-selected by default. */
+ default?: boolean;
+}
+
+/** https://discord.com/developers/docs/interactions/message-components#buttons-button-object */
+export interface DiscordButtonComponent {
+ /** All button components have type 2 */
+ type: MessageComponentTypes.Button;
+ /** for what the button says (max 80 characters) */
+ label: string;
+ /** a dev-defined unique string sent on click (max 100 characters). type 5 Link buttons can not have a custom_id */
+ custom_id?: string;
+ /** For different styles/colors of the buttons */
+ style: ButtonStyles;
+ /** Emoji object that includes fields of name, id, and animated supporting unicode and custom emojis. */
+ emoji?: {
+ /** Emoji id */
+ id?: string;
+ /** Emoji name */
+ name?: string;
+ /** Whether this emoji is animated */
+ animated?: boolean;
+ };
+ /** optional url for link-style buttons that can navigate a user to the web. Only type 5 Link buttons can have a url */
+ url?: string;
+ /** Whether or not this button is disabled */
+ disabled?: boolean;
+}
+
+/** https://discord.com/developers/docs/interactions/message-components#text-inputs-text-input-structure */
+export interface DiscordInputTextComponent {
+ /** InputText Component is of type 3 */
+ type: MessageComponentTypes.InputText;
+ /** The style of the InputText */
+ style: TextStyles;
+ /** The customId of the InputText */
+ custom_id: string;
+ /** The label of the InputText */
+ label: string;
+ /** The placeholder of the InputText */
+ placeholder?: string;
+ /** The minimum length of the text the user has to provide */
+ min_length?: number;
+ /** The maximum length of the text the user has to provide */
+ max_length?: number;
+ /** Whether or not this input is required. */
+ required?: boolean;
+ /** Pre-filled value for input text. */
+ value?: string;
+}
+
+/** https://discord.com/developers/docs/resources/sticker#sticker-item-object-sticker-item-structure */
+export interface DiscordStickerItem {
+ /** Id of the sticker */
+ id: string;
+ /** Name of the sticker */
+ name: string;
+ /** [Type of sticker format](https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types) */
+ format_type: StickerFormatTypes;
+}
+
+/** https://discord.com/developers/docs/resources/sticker#sticker-pack-object-sticker-pack-structure */
+export interface DiscordStickerPack {
+ /** id of the sticker pack */
+ id: string;
+ /** the stickers in the pack */
+ stickers: DiscordSticker[];
+ /** name of the sticker pack */
+ name: string;
+ /** id of the pack's SKU */
+ sku_id: string;
+ /** id of a sticker in the pack which is shown as the pack's icon */
+ cover_sticker_id?: string;
+ /** description of the sticker pack */
+ description: string;
+ /** id of the sticker pack's [banner image](https://discord.com/developers/docs/reference#image-formatting) */
+ banner_asset_id?: string;
+}
+
+export interface DiscordInteraction {
+ /** Id of the interaction */
+ id: string;
+ /** Id of the application this interaction is for */
+ application_id: string;
+ /** The type of interaction */
+ type: InteractionTypes;
+ /** The guild it was sent from */
+ guild_id?: string;
+ /** The channel it was sent from */
+ channel_id?: string;
+ /** Guild member data for the invoking user, including permissions */
+ member?: DiscordInteractionMember;
+ /** User object for the invoking user, if invoked in a DM */
+ user?: DiscordUser;
+ /** A continuation token for responding to the interaction */
+ token: string;
+ /** Read-only property, always `1` */
+ version: 1;
+ /** For the message the button was attached to */
+ message?: DiscordMessage;
+ /** the command data payload */
+ data?: DiscordInteractionData;
+ /** The selected language of the invoking user */
+ locale?: string;
+ /** The guild's preferred locale, if invoked in a guild */
+ guild_locale?: string;
+}
+
+/** https://discord.com/developers/docs/resources/guild#guild-member-object */
+export interface DiscordInteractionMember extends DiscordMemberWithUser {
+ /** Total permissions of the member in the channel, including overwrites, returned when in the interaction object */
+ permissions: string;
+}
+
+export interface DiscordInteractionData {
+ /** The type of component */
+ component_type?: MessageComponentTypes;
+ /** The custom id provided for this component. */
+ custom_id?: string;
+ /** The components if its a Modal Submit interaction. */
+ components?: DiscordMessageComponents;
+ /** The values chosen by the user. */
+ values?: string[];
+ /** The Id of the invoked command */
+ id: string;
+ /** The name of the invoked command */
+ name: string;
+ /** the type of the invoked command */
+ type: ApplicationCommandTypes;
+ /** Converted users + roles + channels + attachments */
+ resolved?: {
+ /** The Ids and Message objects */
+ messages?: Record;
+ /** The Ids and User objects */
+ users?: Record;
+ /** The Ids and partial Member objects */
+ members?: Record<
+ string,
+ Omit
+ >;
+ /** The Ids and Role objects */
+ roles?: Record;
+ /** The Ids and partial Channel objects */
+ channels?: Record<
+ string,
+ Pick
+ >;
+ /** The ids and attachment objects */
+ attachments: Record;
+ };
+ /** The params + values from the user */
+ options?: DiscordInteractionDataOption[];
+ /** The target id if this is a context menu command. */
+ target_id?: string;
+ /** the id of the guild the command is registered to */
+ guild_id?: string;
+}
+
+export type DiscordInteractionDataOption = {
+ /** Name of the parameter */
+ name: string;
+ /** Value of application command option type */
+ type: ApplicationCommandOptionTypes;
+ /** Value of the option resulting from user input */
+ value?:
+ | string
+ | boolean
+ | number
+ | DiscordMember
+ | DiscordChannel
+ | DiscordRole;
+ /** Present if this option is a group or subcommand */
+ options?: DiscordInteractionDataOption[];
+ /** `true` if this option is the currently focused option for autocomplete */
+ focused?: boolean;
+};
+
+export interface DiscordInteractionDataResolved {
+ /** The Ids and Message objects */
+ messages?: Record;
+ /** The Ids and User objects */
+ users?: Record;
+ /** The Ids and partial Member objects */
+ members?: Record<
+ string,
+ Omit
+ >;
+ /** The Ids and Role objects */
+ roles?: Record;
+ /** The Ids and partial Channel objects */
+ channels?: Record<
+ string,
+ Pick
+ >;
+ /** The Ids and attachments objects */
+ attachments?: Record;
+}
+
+export interface DiscordListActiveThreads {
+ /** The active threads */
+ threads: DiscordChannel[];
+ /** A thread member object for each returned thread the current user has joined */
+ members: DiscordThreadMember[];
+}
+
+export interface DiscordListArchivedThreads extends DiscordListActiveThreads {
+ /** Whether there are potentially additional threads that could be returned on a subsequent call */
+ has_more: boolean;
+}
+
+export interface DiscordThreadListSync {
+ /** The id of the guild */
+ guild_id: string;
+ /** The parent channel ids whose threads are being synced. If omitted, then threads were synced for the entire guild. This array may contain channelIds that have no active threads as well, so you know to clear that data */
+ channel_ids?: string[];
+ /** All active threads in the given channels that the current user can access */
+ threads: DiscordChannel[];
+ /** All thread member objects from the synced threads for the current user, indicating which threads the current user has been added to */
+ members: DiscordThreadMember[];
+}
+
+/** https://discord.com/developers/docs/resources/audit-log#audit-log-object */
+export interface DiscordAuditLog {
+ /** List of webhooks found in the audit log */
+ webhooks: DiscordWebhook[];
+ /** List of users found in the audit log */
+ users: DiscordUser[];
+ /** List of audit log entries, sorted from most to least recent */
+ audit_log_entries: DiscordAuditLogEntry[];
+ /** List of partial integration objects */
+ integrations: Partial[];
+ /**
+ * List of threads found in the audit log.
+ * Threads referenced in `THREAD_CREATE` and `THREAD_UPDATE` events are included in the threads map since archived threads might not be kept in memory by clients.
+ */
+ threads: DiscordChannel[];
+ /** List of guild scheduled events found in the audit log */
+ guild_scheduled_events?: DiscordScheduledEvent[];
+ /** List of auto moderation rules referenced in the audit log */
+ auto_moderation_rules?: DiscordAutoModerationRule[];
+}
+
+export interface DiscordAutoModerationRule {
+ /** The id of this rule */
+ id: string;
+ /** The guild id */
+ guild_id: string;
+ /** The name of the rule */
+ name: string;
+ /** The id of the user who created this rule. */
+ creator_id: string;
+ /** Indicates in what event context a rule should be checked. */
+ event_type: AutoModerationEventTypes;
+ /** The type of trigger for this rule */
+ trigger_type: AutoModerationTriggerTypes;
+ /** The metadata used to determine whether a rule should be triggered. */
+ trigger_metadata: DiscordAutoModerationRuleTriggerMetadata;
+ /** Actions which will execute whenever a rule is triggered. */
+ actions: DiscordAutoModerationAction[];
+ /** Whether the rule is enabled. */
+ enabled: boolean;
+ /** The role ids that are whitelisted. Max 20. */
+ exempt_roles: string[];
+ /** The channel ids that are whitelisted. Max 50. */
+ exempt_channels: string[];
+}
+
+export enum AutoModerationEventTypes {
+ /** When a user sends a message */
+ MessageSend = 1,
+}
+
+export enum AutoModerationTriggerTypes {
+ Keyword = 1,
+ HarmfulLink,
+ Spam,
+ KeywordPreset,
+}
+
+export interface DiscordAutoModerationRuleTriggerMetadata {
+ // TODO: discord is considering renaming this before release
+ /** The keywords needed to match. Only present when TriggerType.Keyword */
+ keyword_filter?: string[];
+ /** The pre-defined lists of words to match from. Only present when TriggerType.KeywordPreset */
+ presets?: DiscordAutoModerationRuleTriggerMetadataPresets[];
+}
+
+export enum DiscordAutoModerationRuleTriggerMetadataPresets {
+ /** Words that may be considered forms of swearing or cursing */
+ Profanity = 1,
+ /** Words that refer to sexually explicit behavior or activity */
+ SexualContent,
+ /** Personal insults or words that may be considered hate speech */
+ Slurs,
+}
+
+export interface DiscordAutoModerationAction {
+ /** The type of action to take when a rule is triggered */
+ type: AutoModerationActionType;
+ /** additional metadata needed during execution for this specific action type */
+ metadata: DiscordAutoModerationActionMetadata;
+}
+
+export enum AutoModerationActionType {
+ /** Blocks the content of a message according to the rule */
+ BlockMessage = 1,
+ /** Logs user content to a specified channel */
+ SendAlertMessage,
+ /** Times out user for specified duration */
+ Timeout,
+}
+
+export interface DiscordAutoModerationActionMetadata {
+ /** The id of channel to which user content should be logged. Only in ActionType.SendAlertMessage */
+ channel_id?: string;
+ /** Timeout duration in seconds maximum of 2419200 seconds (4 weeks). Only supported for TriggerType.Keyword && Only in ActionType.Timeout */
+ duration_seconds?: number;
+}
+
+export interface DiscordAutoModerationActionExecution {
+ /** The id of the guild */
+ guild_id: string;
+ /** The id of the rule that was executed */
+ rule_id: string;
+ /** The id of the user which generated the content which triggered the rule */
+ user_id: string;
+ /** The content from the user */
+ content: string;
+ /** Action which was executed */
+ action: DiscordAutoModerationAction;
+ /** The trigger type of the rule that was executed. */
+ rule_trigger_type: AutoModerationTriggerTypes;
+ /** The id of the channel in which user content was posted */
+ channel_id?: string | null;
+ /** The id of the message. Will not exist if message was blocked by automod or content was not part of any message */
+ message_id?: string | null;
+ /** The id of any system auto moderation messages posted as a result of this action */
+ alert_system_message_id?: string | null;
+ /** The word or phrase that triggerred the rule. */
+ matched_keyword: string | null;
+ /** The substring in content that triggered rule */
+ matched_content: string | null;
+}
+
+/** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-entry-structure */
+export interface DiscordAuditLogEntry {
+ /** ID of the affected entity (webhook, user, role, etc.) */
+ target_id: string | null;
+ /** Changes made to the `target_id` */
+ changes?: DiscordAuditLogChange[];
+ /** User or app that made the changes */
+ user_id: string | null;
+ /** ID of the entry */
+ id: string;
+ /** Type of action that occurred */
+ action_type: AuditLogEvents;
+ /** Additional info for certain event types */
+ options?: DiscordOptionalAuditEntryInfo;
+ /** Reason for the change (1-512 characters) */
+ reason?: string;
+}
+
+/** https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-structure */
+export type DiscordAuditLogChange =
+ | {
+ new_value: string;
+ old_value: string;
+ key:
+ | 'name'
+ | 'description'
+ | 'discovery_splash_hash'
+ | 'banner_hash'
+ | 'preferred_locale'
+ | 'rules_channel_id'
+ | 'public_updates_channel_id'
+ | 'icon_hash'
+ | 'image_hash'
+ | 'splash_hash'
+ | 'owner_id'
+ | 'region'
+ | 'afk_channel_id'
+ | 'vanity_url_code'
+ | 'widget_channel_id'
+ | 'system_channel_id'
+ | 'topic'
+ | 'application_id'
+ | 'permissions'
+ | 'allow'
+ | 'deny'
+ | 'code'
+ | 'channel_id'
+ | 'inviter_id'
+ | 'nick'
+ | 'avatar_hash'
+ | 'id'
+ | 'location'
+ | 'command_id';
+ }
+ | {
+ new_value: number;
+ old_value: number;
+ key:
+ | 'afk_timeout'
+ | 'mfa_level'
+ | 'verification_level'
+ | 'explicit_content_filter'
+ | 'default_message_notifications'
+ | 'prune_delete_days'
+ | 'position'
+ | 'bitrate'
+ | 'rate_limit_per_user'
+ | 'color'
+ | 'max_uses'
+ | 'uses'
+ | 'max_age'
+ | 'expire_behavior'
+ | 'expire_grace_period'
+ | 'user_limit'
+ | 'privacy_level'
+ | 'auto_archive_duration'
+ | 'default_auto_archive_duration'
+ | 'entity_type'
+ | 'status'
+ | 'communication_disabled_until';
+ }
+ | {
+ new_value: Partial[];
+ old_value?: Partial[];
+ key: '$add' | '$remove';
+ }
+ | {
+ new_value: boolean;
+ old_value: boolean;
+ key:
+ | 'widget_enabled'
+ | 'nsfw'
+ | 'hoist'
+ | 'mentionable'
+ | 'temporary'
+ | 'deaf'
+ | 'mute'
+ | 'enable_emoticons'
+ | 'archived'
+ | 'locked'
+ | 'invitable';
+ }
+ | {
+ new_value: DiscordOverwrite[];
+ old_value: DiscordOverwrite[];
+ key: 'permission_overwrites';
+ }
+ | {
+ new_value: string | number;
+ old_value: string | number;
+ key: 'type';
+ };
+
+/** https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info */
+export interface DiscordOptionalAuditEntryInfo {
+ /**
+ * Number of days after which inactive members were kicked.
+ *
+ * Event types: `MEMBER_PRUNE`
+ */
+ delete_member_days: string;
+ /**
+ * Number of members removed by the prune.
+ *
+ * Event types: `MEMBER_PRUNE`
+ */
+ members_removed: string;
+ /**
+ * Channel in which the entities were targeted.
+ *
+ * Event types: `MEMBER_MOVE`, `MESSAGE_PIN`, `MESSAGE_UNPIN`, `MESSAGE_DELETE`, `STAGE_INSTANCE_CREATE`, `STAGE_INSTANCE_UPDATE`, `STAGE_INSTANCE_DELETE`
+ */
+ channel_id: string;
+ /**
+ * ID of the message that was targeted.
+ *
+ * Event types: `MESSAGE_PIN`, `MESSAGE_UNPIN`, `STAGE_INSTANCE_CREATE`, `STAGE_INSTANCE_UPDATE`, `STAGE_INSTANCE_DELETE`
+ */
+ message_id: string;
+ /**
+ * Number of entities that were targeted.
+ *
+ * Event types: `MESSAGE_DELETE`, `MESSAGE_BULK_DELETE`, `MEMBER_DISCONNECT`, `MEMBER_MOVE`
+ */
+ count: string;
+ /**
+ * ID of the overwritten entity.
+ *
+ * Event types: `CHANNEL_OVERWRITE_CREATE`, `CHANNEL_OVERWRITE_UPDATE`, `CHANNEL_OVERWRITE_DELETE`
+ */
+ id: string;
+ /**
+ * Type of overwritten entity - "0", for "role", or "1" for "member".
+ *
+ * Event types: `CHANNEL_OVERWRITE_CREATE`, `CHANNEL_OVERWRITE_UPDATE`, `CHANNEL_OVERWRITE_DELETE`
+ */
+ type: string;
+ /**
+ * Name of the role if type is "0" (not present if type is "1").
+ *
+ * Event types: `CHANNEL_OVERWRITE_CREATE`, `CHANNEL_OVERWRITE_UPDATE`, `CHANNEL_OVERWRITE_DELETE`
+ */
+ role_name: string;
+ /**
+ * ID of the app whose permissions were targeted.
+ *
+ * Event types: `APPLICATION_COMMAND_PERMISSION_UPDATE`
+ */
+ application_id: string;
+}
+
+export interface DiscordScheduledEvent {
+ /** the id of the scheduled event */
+ id: string;
+ /** the guild id which the scheduled event belongs to */
+ guild_id: string;
+ /** the channel id in which the scheduled event will be hosted if specified */
+ channel_id: string | null;
+ /** the id of the user that created the scheduled event */
+ creator_id?: string | null;
+ /** the name of the scheduled event */
+ name: string;
+ /** the description of the scheduled event */
+ description?: string;
+ /** the time the scheduled event will start */
+ scheduled_start_time: string;
+ /** the time the scheduled event will end if it does end. */
+ scheduled_end_time: string | null;
+ /** the privacy level of the scheduled event */
+ privacy_level: ScheduledEventPrivacyLevel;
+ /** the status of the scheduled event */
+ status: ScheduledEventStatus;
+ /** the type of hosting entity associated with a scheduled event */
+ entity_type: ScheduledEventEntityType;
+ /** any additional id of the hosting entity associated with event */
+ entity_id: string | null;
+ /** the entity metadata for the scheduled event */
+ entity_metadata: DiscordScheduledEventEntityMetadata | null;
+ /** the user that created the scheduled event */
+ creator?: DiscordUser;
+ /** the number of users subscribed to the scheduled event */
+ user_count?: number;
+ /** the cover image hash of the scheduled event */
+ image?: string | null;
+}
+
+export interface DiscordScheduledEventEntityMetadata {
+ /** location of the event */
+ location?: string;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#get-gateway-bot */
+export interface DiscordGetGatewayBot {
+ /** The WSS URL that can be used for connecting to the gateway */
+ url: string;
+ /** The recommended number of shards to use when connecting */
+ shards: number;
+ /** Information on the current session start limit */
+ session_start_limit: DiscordSessionStartLimit;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#session-start-limit-object */
+export interface DiscordSessionStartLimit {
+ /** The total number of session starts the current user is allowed */
+ total: number;
+ /** The remaining number of session starts the current user is allowed */
+ remaining: number;
+ /** The number of milliseconds after which the limit resets */
+ reset_after: number;
+ /** The number of identify requests allowed per 5 seconds */
+ max_concurrency: number;
+}
+
+/** https://discord.com/developers/docs/resources/invite#invite-metadata-object */
+export interface DiscordInviteMetadata extends DiscordInvite {
+ /** Number of times this invite has been used */
+ uses: number;
+ /** Max number of times this invite can be used */
+ max_uses: number;
+ /** Duration (in seconds) after which the invite expires */
+ max_age: number;
+ /** Whether this invite only grants temporary membership */
+ temporary: boolean;
+ /** When this invite was created */
+ created_at: string;
+}
+
+/** https://discord.com/developers/docs/resources/invite#invite-object */
+export interface DiscordInvite {
+ /** The invite code (unique Id) */
+ code: string;
+ /** The guild this invite is for */
+ guild?: Partial;
+ /** The channel this invite is for */
+ channel: Partial | null;
+ /** The user who created the invite */
+ inviter?: DiscordUser;
+ /** The type of target for this voice channel invite */
+ target_type?: TargetTypes;
+ /** The target user for this invite */
+ target_user?: DiscordUser;
+ /** The embedded application to open for this voice channel embedded application invite */
+ target_application?: Partial;
+ /** Approximate count of online members (only present when target_user is set) */
+ approximate_presence_count?: number;
+ /** Approximate count of total members */
+ approximate_member_count?: number;
+ /** The expiration date of this invite, returned from the `GET /invites/` endpoint when `with_expiration` is `true` */
+ expires_at?: string | null;
+ /** Stage instance data if there is a public Stage instance in the Stage channel this invite is for */
+ stage_instance?: DiscordInviteStageInstance;
+ /** guild scheduled event data */
+ guild_scheduled_event?: DiscordScheduledEvent;
+}
+
+export interface DiscordInviteStageInstance {
+ /** The members speaking in the Stage */
+ members: Partial[];
+ /** The number of users in the Stage */
+ participant_count: number;
+ /** The number of users speaking in the Stage */
+ speaker_count: number;
+ /** The topic of the Stage instance (1-120 characters) */
+ topic: string;
+}
+
+/** https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure */
+export interface DiscordApplicationCommand {
+ /** Unique ID of command */
+ id: string;
+ /** Type of command, defaults to `ApplicationCommandTypes.ChatInput` */
+ type?: ApplicationCommandTypes;
+ /** ID of the parent application */
+ application_id: string;
+ /** Guild id of the command, if not global */
+ guild_id?: string;
+ /**
+ * Name of command, 1-32 characters.
+ * `ApplicationCommandTypes.ChatInput` command names must match the following regex `^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$` with the unicode flag set.
+ * If there is a lowercase variant of any letters used, you must use those.
+ * Characters with no lowercase variants and/or uncased letters are still allowed.
+ * ApplicationCommandTypes.User` and `ApplicationCommandTypes.Message` commands may be mixed case and can include spaces.
+ */
+ name: string;
+ /** Localization object for `name` field. Values follow the same restrictions as `name` */
+ name_localizations?: Localization | null;
+ /** Description for `ApplicationCommandTypes.ChatInput` commands, 1-100 characters. Empty string for `ApplicationCommandTypes.User` and `ApplicationCommandTypes.Message` commands */
+ description: string;
+ /** Localization object for `description` field. Values follow the same restrictions as `description` */
+ description_localizations?: Localization | null;
+ /** Parameters for the command, max of 25 */
+ options?: DiscordApplicationCommandOption[];
+ /** Set of permissions represented as a bit set */
+ default_member_permissions: string | null;
+ /** Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible. */
+ dm_permission?: boolean;
+ /** Auto incrementing version identifier updated during substantial record changes */
+ version: string;
+}
+
+/** https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure */
+export interface DiscordApplicationCommandOption {
+ /** Type of option */
+ type: ApplicationCommandOptionTypes;
+ /**
+ * Name of command, 1-32 characters.
+ * `ApplicationCommandTypes.ChatInput` command names must match the following regex `^[-_\p{L}\p{N}\p{sc=Deva}\p{sc=Thai}]{1,32}$` with the unicode flag set.
+ * If there is a lowercase variant of any letters used, you must use those.
+ * Characters with no lowercase variants and/or uncased letters are still allowed.
+ * ApplicationCommandTypes.User` and `ApplicationCommandTypes.Message` commands may be mixed case and can include spaces.
+ */
+ name: string;
+ /** Localization object for the `name` field. Values follow the same restrictions as `name` */
+ name_localizations?: Localization | null;
+ /** 1-100 character description */
+ description: string;
+ /** Localization object for the `description` field. Values follow the same restrictions as `description` */
+ description_localizations?: Localization | null;
+ /** If the parameter is required or optional--default `false` */
+ required?: boolean;
+ /** Choices for the option types `ApplicationCommandOptionTypes.String`, `ApplicationCommandOptionTypes.Integer`, and `ApplicationCommandOptionTypes.Number`, from which the user can choose, max 25 */
+ choices?: DiscordApplicationCommandOptionChoice[];
+ /** If the option is a subcommand or subcommand group type, these nested options will be the parameters */
+ options?: DiscordApplicationCommandOption[];
+ /**
+ * If autocomplete interactions are enabled for this option.
+ *
+ * Only available for `ApplicationCommandOptionTypes.String`, `ApplicationCommandOptionTypes.Integer` and `ApplicationCommandOptionTypes.Number` option types
+ */
+ autocomplete?: boolean;
+ /** If the option is a channel type, the channels shown will be restricted to these types */
+ channel_types?: ChannelTypes[];
+ /** If the option type is `ApplicationCommandOptionTypes.Integer` or `ApplicationCommandOptionTypes.Number`, the minimum permitted value */
+ min_value?: number;
+ /** If the option type is `ApplicationCommandOptionTypes.Integer` or `ApplicationCommandOptionTypes.Number`, the maximum permitted value */
+ max_value?: number;
+}
+
+/** https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-choice-structure */
+export interface DiscordApplicationCommandOptionChoice {
+ /** 1-100 character choice name */
+ name: string;
+ /** Localization object for the `name` field. Values follow the same restrictions as `name` */
+ name_localizations?: Localization | null;
+ /** Value for the choice, up to 100 characters if string */
+ value: string | number;
+}
+
+/** https://discord.com/developers/docs/interactions/slash-commands#guildapplicationcommandpermissions */
+export interface DiscordGuildApplicationCommandPermissions {
+ /** ID of the command or the application ID. When the `id` field is the application ID instead of a command ID, the permissions apply to all commands that do not contain explicit overwrites. */
+ id: string;
+ /** ID of the application the command belongs to */
+ application_id: string;
+ /** ID of the guild */
+ guild_id: string;
+ /** Permissions for the command in the guild, max of 100 */
+ permissions: DiscordApplicationCommandPermissions[];
+}
+
+/** https://discord.com/developers/docs/interactions/slash-commands#applicationcommandpermissions */
+export interface DiscordApplicationCommandPermissions {
+ /** ID of the role, user, or channel. It can also be a permission constant */
+ id: string;
+ /** ApplicationCommandPermissionTypes.Role, ApplicationCommandPermissionTypes.User, or ApplicationCommandPermissionTypes.Channel */
+ type: ApplicationCommandPermissionTypes;
+ /** `true` to allow, `false`, to disallow */
+ permission: boolean;
+}
+
+/** https://discord.com/developers/docs/resources/guild#get-guild-widget-example-get-guild-widget */
+export interface DiscordGuildWidget {
+ id: string;
+ name: string;
+ instant_invite: string;
+ channels: {
+ id: string;
+ name: string;
+ position: number;
+ }[];
+ members: {
+ id: string;
+ username: string;
+ discriminator: string;
+ avatar?: string | null;
+ status: string;
+ avatar_url: string;
+ }[];
+ presence_count: number;
+}
+
+/** https://discord.com/developers/docs/resources/guild#guild-preview-object */
+export interface DiscordGuildPreview {
+ /** Guild id */
+ id: string;
+ /** Guild name (2-100 characters) */
+ name: string;
+ /** Icon hash */
+ icon: string | null;
+ /** Splash hash */
+ splash: string | null;
+ /** Discovery splash hash */
+ discovery_splash: string | null;
+ /** Custom guild emojis */
+ emojis: DiscordEmoji[];
+ /** Enabled guild features */
+ features: GuildFeatures[];
+ /** Approximate number of members in this guild */
+ approximate_member_count: number;
+ /** Approximate number of online members in this guild */
+ approximate_presence_count: number;
+ /** The description for the guild, if the guild is discoverable */
+ description: string | null;
+ /** Custom guild stickers */
+ stickers: DiscordSticker[];
+}
+
+export interface DiscordDiscoveryCategory {
+ /** Numeric id of the category */
+ id: number;
+ /** The name of this category, in multiple languages */
+ name: DiscordDiscoveryName;
+ /** Whether this category can be set as a guild's primary category */
+ is_primary: boolean;
+}
+
+export interface DiscordDiscoveryName {
+ /** The name in English */
+ default: string;
+ /** The name in other languages */
+ localizations?: Record;
+}
+
+export interface DiscordDiscoveryMetadata {
+ /** The guild Id */
+ guild_id: string;
+ /** The id of the primary discovery category set for this guild */
+ primary_category_id: number;
+ /** Up to 10 discovery search keywords set for this guild */
+ keywords: string[] | null;
+ /** Whether guild info is shown when custom emojis from this guild are clicked */
+ emoji_discoverability_enabled: boolean;
+ /** When the server's partner application was accepted or denied, for applications via Server Settings */
+ partner_actioned_timestamp: string | null;
+ /** When the server applied for partnership, if it has a pending application */
+ partner_application_timestamp: string | null;
+ /** Ids of up to 5 discovery subcategories set for this guild */
+ category_ids: number[];
+}
+
+/** https://discord.com/developers/docs/resources/channel#followed-channel-object */
+export interface DiscordFollowedChannel {
+ /** Source message id */
+ channel_id: string;
+ /** Created target webhook id */
+ webhook_id: string;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#payloads-gateway-payload-structure */
+export interface DiscordGatewayPayload {
+ /** opcode for the payload */
+ op: number;
+ /** Event data */
+ d: unknown | null;
+ /** Sequence number, used for resuming sessions and heartbeats */
+ s: number | null;
+ /** The event name for this payload */
+ t: GatewayEventNames | null;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#guild-members-chunk */
+export interface DiscordGuildMembersChunk {
+ /** The id of the guild */
+ guild_id: string;
+ /** Set of guild members */
+ members: DiscordMemberWithUser[];
+ /** The chunk index in the expected chunks for this response (0 <= chunk_index < chunk_count) */
+ chunk_index: number;
+ /** The total number of expected chunks for this response */
+ chunk_count: number;
+ /** If passing an invalid id to `REQUEST_GUILD_MEMBERS`, it will be returned here */
+ not_found?: string[];
+ /** If passing true to `REQUEST_GUILD_MEMBERS`, presences of the returned members will be here */
+ presences?: DiscordPresenceUpdate[];
+ /** The nonce used in the Guild Members Request */
+ nonce?: string;
+}
+
+export interface DiscordComponent {
+ /** component type */
+ type: MessageComponentTypes;
+ /** a developer-defined identifier for the component, max 100 characters */
+ custom_id?: string;
+ /** whether the component is disabled, default false */
+ disabled?: boolean;
+ /** For different styles/colors of the buttons */
+ style?: ButtonStyles | TextStyles;
+ /** text that appears on the button (max 80 characters) */
+ label?: string;
+ /** the dev-define value of the option, max 100 characters for select or 4000 for input. */
+ value?: string;
+ /** Emoji object that includes fields of name, id, and animated supporting unicode and custom emojis. */
+ emoji?: {
+ /** Emoji id */
+ id?: string;
+ /** Emoji name */
+ name?: string;
+ /** Whether this emoji is animated */
+ animated?: boolean;
+ };
+ /** optional url for link-style buttons that can navigate a user to the web. Only type 5 Link buttons can have a url */
+ url?: string;
+ /** The choices! Maximum of 25 items. */
+ options?: DiscordSelectOption[];
+ /** A custom placeholder text if nothing is selected. Maximum 150 characters. */
+ placeholder?: string;
+ /** The minimum number of items that must be selected. Default 1. Between 1-25. */
+ min_values?: number;
+ /** The maximum number of items that can be selected. Default 1. Between 1-25. */
+ max_values?: number;
+ /** a list of child components */
+ components?: DiscordComponent[];
+}
+
+/** https://discord.com/developers/docs/topics/gateway#channel-pins-update */
+export interface DiscordChannelPinsUpdate {
+ /** The id of the guild */
+ guild_id?: string;
+ /** The id of the channel */
+ channel_id: string;
+ /** The time at which the most recent pinned message was pinned */
+ last_pin_timestamp?: string | null;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#guild-role-delete */
+export interface DiscordGuildRoleDelete {
+ /** id of the guild */
+ guild_id: string;
+ /** id of the role */
+ role_id: string;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#guild-ban-add */
+export interface DiscordGuildBanAddRemove {
+ /** id of the guild */
+ guild_id: string;
+ /** The banned user */
+ user: DiscordUser;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#message-reaction-remove */
+// deno-lint-ignore no-empty-interface
+export interface DiscordMessageReactionRemove
+ extends Omit {}
+
+/** https://discord.com/developers/docs/topics/gateway#message-reaction-add */
+export interface DiscordMessageReactionAdd {
+ /** The id of the user */
+ user_id: string;
+ /** The id of the channel */
+ channel_id: string;
+ /** The id of the message */
+ message_id: string;
+ /** The id of the guild */
+ guild_id?: string;
+ /** The member who reacted if this happened in a guild */
+ member?: DiscordMemberWithUser;
+ /** The emoji used to react */
+ emoji: Partial;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#voice-server-update */
+export interface DiscordVoiceServerUpdate {
+ /** Voice connection token */
+ token: string;
+ /** The guild this voice server update is for */
+ guild_id: string;
+ /** The voice server host */
+ endpoint: string | null;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#invite-create */
+export interface DiscordInviteCreate {
+ /** The channel the invite is for */
+ channel_id: string;
+ /** The unique invite code */
+ code: string;
+ /** The time at which the invite was created */
+ created_at: string;
+ /** The guild of the invite */
+ guild_id?: string;
+ /** The user that created the invite */
+ inviter?: DiscordUser;
+ /** How long the invite is valid for (in seconds) */
+ max_age: number;
+ /** The maximum number of times the invite can be used */
+ max_uses: number;
+ /** The type of target for this voice channel invite */
+ target_type: TargetTypes;
+ /** The target user for this invite */
+ target_user?: DiscordUser;
+ /** The embedded application to open for this voice channel embedded application invite */
+ target_application?: Partial;
+ /** Whether or not the invite is temporary (invited users will be kicked on disconnect unless they're assigned a role) */
+ temporary: boolean;
+ /** How many times the invite has been used (always will be 0) */
+ uses: number;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#hello */
+export interface DiscordHello {
+ /** The interval (in milliseconds) the client should heartbeat with */
+ heartbeat_interval: number;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#ready */
+export interface DiscordReady {
+ /** Gateway version */
+ v: number;
+ /** Information about the user including email */
+ user: DiscordUser;
+ /** The guilds the user is in */
+ guilds: DiscordUnavailableGuild[];
+ /** Used for resuming connections */
+ session_id: string;
+ /** The shard information associated with this session, if sent when identifying */
+ shard?: [number, number];
+ /** Contains id and flags */
+ application: Partial &
+ Pick;
+}
+
+/** https://discord.com/developers/docs/resources/guild#unavailable-guild-object */
+// deno-lint-ignore no-empty-interface
+export interface DiscordUnavailableGuild
+ extends Pick {}
+
+/** https://discord.com/developers/docs/topics/gateway#message-delete-bulk */
+export interface DiscordMessageDeleteBulk {
+ /** The ids of the messages */
+ ids: string[];
+ /** The id of the channel */
+ channel_id: string;
+ /** The id of the guild */
+ guild_id?: string;
+}
+
+/** https://discord.com/developers/docs/resources/template#template-object-template-structure */
+export interface DiscordTemplate {
+ /** The template code (unique Id) */
+ code: string;
+ /** Template name */
+ name: string;
+ /** The description for the template */
+ description: string | null;
+ /** Number of times this template has been used */
+ usage_count: number;
+ /** The Id of the user who created the template */
+ creator_id: string;
+ /** The user who created the template */
+ creator: DiscordUser;
+ /** When this template was created */
+ created_at: string;
+ /** When this template was last synced to the source guild */
+ updated_at: string;
+ /** The Id of the guild this template is based on */
+ source_guild_id: string;
+ /** The guild snapshot this template contains */
+ serialized_source_guild: Omit<
+ PickPartial<
+ DiscordGuild,
+ | 'name'
+ | 'description'
+ | 'verification_level'
+ | 'default_message_notifications'
+ | 'explicit_content_filter'
+ | 'preferred_locale'
+ | 'afk_timeout'
+ | 'channels'
+ | 'afk_channel_id'
+ | 'system_channel_id'
+ | 'system_channel_flags'
+ >,
+ 'roles'
+ > & {
+ roles: (Omit<
+ PickPartial<
+ DiscordRole,
+ | 'name'
+ | 'color'
+ | 'hoist'
+ | 'mentionable'
+ | 'permissions'
+ | 'icon'
+ | 'unicode_emoji'
+ >,
+ 'id'
+ > & { id: number })[];
+ };
+ /** Whether the template has un-synced changes */
+ is_dirty: boolean | null;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#guild-member-add */
+export interface DiscordGuildMemberAdd extends DiscordMemberWithUser {
+ /** id of the guild */
+ guild_id: string;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#message-delete */
+export interface DiscordMessageDelete {
+ /** The id of the message */
+ id: string;
+ /** The id of the channel */
+ channel_id: string;
+ /** The id of the guild */
+ guild_id?: string;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#thread-members-update-thread-members-update-event-fields */
+export interface DiscordThreadMembersUpdate {
+ /** The id of the thread */
+ id: string;
+ /** The id of the guild */
+ guild_id: string;
+ /** The users who were added to the thread */
+ added_members?: DiscordThreadMember[];
+ /** The id of the users who were removed from the thread */
+ removed_member_ids?: string[];
+ /** the approximate number of members in the thread, capped at 50 */
+ member_count: number;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#thread-member-update */
+export interface DiscordThreadMemberUpdate {
+ /** The id of the thread */
+ id: string;
+ /** The id of the user */
+ user_id: string;
+ /** The id of the guild */
+ guild_id: string;
+ /** The timestamp when the bot joined this thread. */
+ joined_at: string;
+ /** The flags this user has for this thread. Not useful for bots. */
+ flags: number;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#guild-role-create */
+export interface DiscordGuildRoleCreate {
+ /** The id of the guild */
+ guild_id: string;
+ /** The role created */
+ role: DiscordRole;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#guild-emojis-update */
+export interface DiscordGuildEmojisUpdate {
+ /** id of the guild */
+ guild_id: string;
+ /** Array of emojis */
+ emojis: DiscordEmoji[];
+}
+
+export interface DiscordAddGuildDiscoverySubcategory {
+ /** The guild Id of the subcategory was added to */
+ guild_id: string;
+ /** The Id of the subcategory added */
+ category_id: number;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#guild-ban-add */
+export interface DiscordGuildBanAddRemove {
+ /** id of the guild */
+ guild_id: string;
+ /** The banned user */
+ user: DiscordUser;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#guild-member-update */
+export interface DiscordGuildMemberUpdate {
+ /** The id of the guild */
+ guild_id: string;
+ /** User role ids */
+ roles: string[];
+ /** The user */
+ user: DiscordUser;
+ /** Nickname of the user in the guild */
+ nick?: string | null;
+ /** the member's [guild avatar hash](https://discord.com/developers/docs/reference#image-formatting) */
+ avatar: string;
+ /** When the user joined the guild */
+ joined_at: string;
+ /** When the user starting boosting the guild */
+ premium_since?: string | null;
+ /** whether the user is deafened in voice channels */
+ deaf?: boolean;
+ /** whether the user is muted in voice channels */
+ mute?: boolean;
+ /** Whether the user has not yet passed the guild's Membership Screening requirements */
+ pending?: boolean;
+ /** when the user's [timeout](https://support.discord.com/hc/en-us/articles/4413305239191-Time-Out-FAQ) will expire and the user will be able to communicate in the guild again, null or a time in the past if the user is not timed out. Will throw a 403 error if the user has the ADMINISTRATOR permission or is the owner of the guild */
+ communication_disabled_until?: string;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#message-reaction-remove-all */
+// deno-lint-ignore no-empty-interface
+export interface DiscordMessageReactionRemoveAll
+ extends Pick<
+ DiscordMessageReactionAdd,
+ 'channel_id' | 'message_id' | 'guild_id'
+ > {}
+
+// TODO: add docs link
+export interface DiscordValidateDiscoverySearchTerm {
+ /** Whether the provided term is valid */
+ valid: boolean;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#guild-role-update */
+export interface DiscordGuildRoleUpdate {
+ /** The id of the guild */
+ guild_id: string;
+ /** The role updated */
+ role: DiscordRole;
+}
+
+export interface DiscordScheduledEventUserAdd {
+ /** id of the guild scheduled event */
+ guild_scheduled_event_id: string;
+ /** id of the user */
+ user_id: string;
+ /** id of the guild */
+ guild_id: string;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#message-reaction-remove-emoji */
+export type DiscordMessageReactionRemoveEmoji = Pick<
+ DiscordMessageReactionAdd,
+ 'channel_id' | 'guild_id' | 'message_id' | 'emoji'
+>;
+
+/** https://discord.com/developers/docs/topics/gateway#guild-member-remove */
+export interface DiscordGuildMemberRemove {
+ /** The id of the guild */
+ guild_id: string;
+ /** The user who was removed */
+ user: DiscordUser;
+}
+
+/** https://discord.com/developers/docs/resources/guild#ban-object */
+export interface DiscordBan {
+ /** The reason for the ban */
+ reason: string | null;
+ /** The banned user */
+ user: DiscordUser;
+}
+
+export interface DiscordScheduledEventUserRemove {
+ /** id of the guild scheduled event */
+ guild_scheduled_event_id: string;
+ /** id of the user */
+ user_id: string;
+ /** id of the guild */
+ guild_id: string;
+}
+
+/** https://discord.com/developers/docs/topics/gateway#invite-delete */
+export interface DiscordInviteDelete {
+ /** The channel of the invite */
+ channel_id: string;
+ /** The guild of the invite */
+ guild_id?: string;
+ /** The unique invite code */
+ code: string;
+}
+
+/** https://discord.com/developers/docs/resources/voice#voice-region-object-voice-region-structure */
+export interface DiscordVoiceRegion {
+ /** Unique Id for the region */
+ id: string;
+ /** Name of the region */
+ name: string;
+ /** true for a single server that is closest to the current user's client */
+ optimal: boolean;
+ /** Whether this is a deprecated voice region (avoid switching to these) */
+ deprecated: boolean;
+ /** Whether this is a custom voice region (used for events/etc) */
+ custom: boolean;
+}
+
+export interface DiscordGuildWidgetSettings {
+ /** whether the widget is enabled */
+ enabled: boolean;
+ /** the widget channel id */
+ channel_id: string | null;
+}
+
+export interface DiscordInstallParams {
+ /** he scopes to add the application to the server with */
+ scopes: string[];
+ /** the permissions to request for the bot role */
+ permissions: string;
+}
diff --git a/packages/api-types/tsconfig.json b/packages/api-types/tsconfig.json
new file mode 100644
index 0000000..9b4f197
--- /dev/null
+++ b/packages/api-types/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "./dist"
+ },
+ "include": ["src/**/*"]
+}
diff --git a/packages/api-types/tsup.config.ts b/packages/api-types/tsup.config.ts
new file mode 100644
index 0000000..6eebbb4
--- /dev/null
+++ b/packages/api-types/tsup.config.ts
@@ -0,0 +1,12 @@
+import { defineConfig } from 'tsup';
+
+const isProduction = process.env.NODE_ENV === 'production';
+
+export default defineConfig({
+ clean: true,
+ dts: true,
+ entry: ['src/index.ts'],
+ format: ['cjs', 'esm'],
+ minify: isProduction,
+ sourcemap: true,
+});
diff --git a/packages/cache/README.md b/packages/cache/README.md
new file mode 100644
index 0000000..e69de29
diff --git a/packages/cache/package.json b/packages/cache/package.json
new file mode 100644
index 0000000..7970da8
--- /dev/null
+++ b/packages/cache/package.json
@@ -0,0 +1,22 @@
+{
+ "name": "@biscuitland/cache",
+ "version": "1.0.0",
+ "main": "./dist/index.js",
+ "module": "./dist/index.mjs",
+ "types": "./dist/index.d.ts",
+ "files": [
+ "dist/**"
+ ],
+ "scripts": {
+ "build": "tsup",
+ "clean": "rm -rf dist && rm -rf .turbo",
+ "dev": "tsup --watch"
+ },
+ "dependencies": {
+ "@biscuitland/api-types": "^1.0.0",
+ "ioredis": "^5.2.2"
+ },
+ "devDependencies": {
+ "tsup": "^6.1.3"
+ }
+}
diff --git a/packages/cache/src/adapters/cache-adapter.ts b/packages/cache/src/adapters/cache-adapter.ts
new file mode 100644
index 0000000..4d3ddb2
--- /dev/null
+++ b/packages/cache/src/adapters/cache-adapter.ts
@@ -0,0 +1,31 @@
+export interface CacheAdapter {
+ /**
+ * @inheritDoc
+ */
+
+ get(name: string): Promise;
+
+ /**
+ * @inheritDoc
+ */
+
+ set(name: string, data: unknown): Promise;
+
+ /**
+ * @inheritDoc
+ */
+
+ remove(name: string): Promise;
+
+ /**
+ * @inheritDoc
+ */
+
+ clear(): Promise;
+
+ /**
+ * @inheritDoc
+ */
+
+ close?(): Promise;
+}
diff --git a/packages/cache/src/adapters/memory-cache-adapter.ts b/packages/cache/src/adapters/memory-cache-adapter.ts
new file mode 100644
index 0000000..96ef080
--- /dev/null
+++ b/packages/cache/src/adapters/memory-cache-adapter.ts
@@ -0,0 +1,51 @@
+import { CacheAdapter } from './cache-adapter';
+
+export class MemoryCacheAdapter implements CacheAdapter {
+ /**
+ * @inheritDoc
+ */
+
+ private readonly data = new Map();
+
+ /**
+ * @inheritDoc
+ */
+
+ async get(name: string): Promise {
+ const data = this.data.get(name);
+
+ if (!data) {
+ return null;
+ }
+
+ return JSON.parse(data);
+ }
+
+ /**
+ * @inheritDoc
+ */
+
+ async set(name: string, data: unknown): Promise {
+ const stringData = JSON.stringify(data, (_, v) =>
+ typeof v === 'bigint' ? v.toString() : v
+ );
+
+ this.data.set(name, stringData);
+ }
+
+ /**
+ * @inheritDoc
+ */
+
+ async remove(name: string): Promise {
+ this.data.delete(name);
+ }
+
+ /**
+ * @inheritDoc
+ */
+
+ async clear(): Promise {
+ this.data.clear();
+ }
+}
diff --git a/packages/cache/src/adapters/redis-cache-adapter.ts b/packages/cache/src/adapters/redis-cache-adapter.ts
new file mode 100644
index 0000000..6340c75
--- /dev/null
+++ b/packages/cache/src/adapters/redis-cache-adapter.ts
@@ -0,0 +1,95 @@
+import type { Redis, RedisOptions } from 'ioredis';
+
+import { CacheAdapter } from './cache-adapter';
+import IORedis from 'ioredis';
+
+export interface BaseOptions {
+ prefix?: string;
+}
+
+export interface BuildOptions extends BaseOptions, RedisOptions {}
+
+export interface ClientOptions extends BaseOptions {
+ client: Redis;
+}
+
+export type Options = BuildOptions | ClientOptions;
+
+export class RedisCacheAdapter implements CacheAdapter {
+ static readonly DEFAULTS = {
+ prefix: 'biscuitland',
+ };
+
+ private readonly client: Redis;
+
+ options: Options;
+
+ constructor(options?: Options) {
+ this.options = Object.assign(RedisCacheAdapter.DEFAULTS, options);
+
+ if ((this.options as ClientOptions).client) {
+ this.client = (this.options as ClientOptions).client;
+ } else {
+ const { ...redisOpt } = this.options as BuildOptions;
+ this.client = new IORedis(redisOpt);
+ }
+ }
+
+ _getPrefix(name: string) {
+ return `${this.options.prefix}:${name}`;
+ }
+
+ /**
+ * @inheritDoc
+ */
+
+ async get(name: string): Promise {
+ const completKey = this._getPrefix(name);
+ const data = await this.client.get(completKey);
+
+ if (!data) {
+ return null;
+ }
+
+ return JSON.parse(data);
+ }
+
+ /**
+ * @inheritDoc
+ */
+
+ async set(name: string, data: unknown): Promise {
+ const stringData = JSON.stringify(data, (_, v) =>
+ typeof v === 'bigint' ? v.toString() : v
+ );
+
+ const completeKey = this._getPrefix(name);
+
+ await this.client.set(completeKey, stringData);
+ }
+
+ /**
+ * @inheritDoc
+ */
+
+ async remove(name: string): Promise {
+ const completKey = this._getPrefix(name);
+ await this.client.del(completKey);
+ }
+
+ /**
+ * @inheritDoc
+ */
+
+ async clear(): Promise {
+ this.client.disconnect();
+ }
+
+ /**
+ * @inheritDoc
+ */
+
+ async close(): Promise {
+ this.client.disconnect();
+ }
+}
diff --git a/packages/cache/src/index.ts b/packages/cache/src/index.ts
new file mode 100644
index 0000000..e663175
--- /dev/null
+++ b/packages/cache/src/index.ts
@@ -0,0 +1,4 @@
+export { CacheAdapter } from './adapters/cache-adapter';
+
+export { MemoryCacheAdapter } from './adapters/memory-cache-adapter';
+export { RedisCacheAdapter } from './adapters/redis-cache-adapter';
diff --git a/packages/cache/tsconfig.json b/packages/cache/tsconfig.json
new file mode 100644
index 0000000..9b4f197
--- /dev/null
+++ b/packages/cache/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "./dist"
+ },
+ "include": ["src/**/*"]
+}
diff --git a/packages/cache/tsup.config.ts b/packages/cache/tsup.config.ts
new file mode 100644
index 0000000..6eebbb4
--- /dev/null
+++ b/packages/cache/tsup.config.ts
@@ -0,0 +1,12 @@
+import { defineConfig } from 'tsup';
+
+const isProduction = process.env.NODE_ENV === 'production';
+
+export default defineConfig({
+ clean: true,
+ dts: true,
+ entry: ['src/index.ts'],
+ format: ['cjs', 'esm'],
+ minify: isProduction,
+ sourcemap: true,
+});
diff --git a/packages/core/README.md b/packages/core/README.md
new file mode 100644
index 0000000..e69de29
diff --git a/packages/core/package.json b/packages/core/package.json
new file mode 100644
index 0000000..34b8797
--- /dev/null
+++ b/packages/core/package.json
@@ -0,0 +1,23 @@
+{
+ "name": "@biscuitland/core",
+ "version": "1.0.0",
+ "main": "./dist/index.js",
+ "module": "./dist/index.mjs",
+ "types": "./dist/index.d.ts",
+ "files": [
+ "dist/**"
+ ],
+ "scripts": {
+ "build": "tsup",
+ "clean": "rm -rf dist && rm -rf .turbo",
+ "dev": "tsup --watch"
+ },
+ "dependencies": {
+ "@biscuitland/api-types": "^1.0.0",
+ "@biscuitland/rest": "^1.0.0",
+ "@biscuitland/ws": "^1.0.0"
+ },
+ "devDependencies": {
+ "tsup": "^6.1.3"
+ }
+}
diff --git a/packages/core/src/adapters/default-event-adapter.ts b/packages/core/src/adapters/default-event-adapter.ts
new file mode 100644
index 0000000..437a556
--- /dev/null
+++ b/packages/core/src/adapters/default-event-adapter.ts
@@ -0,0 +1,25 @@
+import type { EventAdapter } from './event-adapter';
+import type { Events } from './events';
+import EventEmitter from 'node:events';
+
+export class DefaultEventAdapter extends EventEmitter implements EventAdapter {
+ override on(event: K, func: Events[K]): this;
+ override on(event: K, func: (...args: unknown[]) => unknown): this {
+ return super.on(event, func);
+ }
+
+ override off(event: K, func: Events[K]): this;
+ override off(event: K, func: (...args: unknown[]) => unknown): this {
+ return super.off(event, func);
+ }
+
+ override once(event: K, func: Events[K]): this;
+ override once(event: K, func: (...args: unknown[]) => unknown): this {
+ return super.once(event, func);
+ }
+
+ override emit(event: K, ...params: Parameters): boolean;
+ override emit(event: K, ...params: unknown[]): boolean {
+ return super.emit(event, ...params);
+ }
+}
diff --git a/packages/core/src/adapters/event-adapter.ts b/packages/core/src/adapters/event-adapter.ts
new file mode 100644
index 0000000..e132f89
--- /dev/null
+++ b/packages/core/src/adapters/event-adapter.ts
@@ -0,0 +1,25 @@
+import type { Events } from './events';
+
+export interface EventAdapter extends Omit {
+ options?: any;
+
+ emit(
+ event: K,
+ ...params: Parameters
+ ): boolean;
+
+ on(
+ event: K,
+ func: Events[K]
+ ): unknown;
+
+ off(
+ event: K,
+ func: Events[K]
+ ): unknown;
+
+ once(
+ event: K,
+ func: Events[K]
+ ): unknown;
+}
diff --git a/packages/core/src/adapters/events.ts b/packages/core/src/adapters/events.ts
new file mode 100644
index 0000000..c238d94
--- /dev/null
+++ b/packages/core/src/adapters/events.ts
@@ -0,0 +1,784 @@
+/* eslint-disable no-mixed-spaces-and-tabs */
+import type {
+ DiscordAutoModerationActionExecution,
+ DiscordAutoModerationRule,
+ DiscordChannel,
+ DiscordChannelPinsUpdate,
+ DiscordEmoji,
+ DiscordGuild,
+ DiscordGuildBanAddRemove,
+ DiscordGuildEmojisUpdate,
+ DiscordGuildMemberAdd,
+ DiscordGuildMemberRemove,
+ DiscordGuildMemberUpdate,
+ DiscordGuildRoleCreate,
+ DiscordGuildRoleDelete,
+ DiscordGuildRoleUpdate,
+ DiscordIntegration,
+ DiscordIntegrationDelete,
+ DiscordInteraction,
+ DiscordInviteCreate,
+ DiscordInviteDelete,
+ DiscordMemberWithUser,
+ DiscordMessage,
+ DiscordMessageDelete,
+ DiscordMessageReactionAdd,
+ DiscordMessageReactionRemove,
+ DiscordMessageReactionRemoveAll,
+ DiscordMessageReactionRemoveEmoji,
+ DiscordPresenceUpdate,
+ DiscordReady,
+ DiscordRole,
+ DiscordScheduledEvent,
+ DiscordScheduledEventUserAdd,
+ DiscordScheduledEventUserRemove,
+ DiscordThreadListSync,
+ DiscordThreadMembersUpdate,
+ DiscordThreadMemberUpdate,
+ DiscordTypingStart,
+ DiscordUser,
+ DiscordWebhookUpdate,
+} from '@biscuitland/api-types';
+
+import type { Session } from '../biscuit';
+import type { Interaction } from '../structures/interactions';
+import type { Snowflake } from '../snowflakes';
+
+import {
+ AutoModerationRule,
+ AutoModerationExecution,
+} from '../structures/automod';
+
+import type { Channel } from '../structures/channels';
+import {
+ ChannelFactory,
+ GuildChannel,
+ ThreadChannel,
+} from '../structures/channels';
+
+import type { DiscordStageInstanceB } from '../structures/stage-instance';
+import { StageInstance } from '../structures/stage-instance';
+import { ScheduledEvent } from '../structures/scheduled-events';
+import { Presence } from '../structures/presence';
+
+import { Member, ThreadMember } from '../structures/members';
+
+import { Message } from '../structures/message';
+import { User } from '../structures/user';
+import { Integration } from '../structures/integration';
+
+import { Guild } from '../structures/guilds';
+import { InteractionFactory } from '../structures/interactions';
+import type { InviteCreate } from '../structures/invite';
+import { NewInviteCreate } from '../structures/invite';
+
+import type {
+ MessageReactionAdd,
+ MessageReactionRemove,
+ MessageReactionRemoveAll,
+ MessageReactionRemoveEmoji,
+} from '../structures/message-reaction';
+
+import { NewMessageReactionAdd } from '../structures/message-reaction';
+
+export type RawHandler = (...args: [Session, number, T]) => void;
+export type Handler = (
+ ...args: T
+) => unknown;
+
+export const READY: RawHandler = (session, shardId, payload) => {
+ session.applicationId = payload.application.id;
+ session.botId = payload.user.id;
+ session.events.emit(
+ 'ready',
+ { ...payload, user: new User(session, payload.user) },
+ shardId
+ );
+};
+
+export const MESSAGE_CREATE: RawHandler = (
+ session,
+ _shardId,
+ message
+) => {
+ session.events.emit('messageCreate', new Message(session, message));
+};
+
+export const MESSAGE_UPDATE: RawHandler = (
+ session,
+ _shardId,
+ new_message
+) => {
+ // message is partial
+ if (!new_message.edited_timestamp) {
+ const message = {
+ // TODO: improve this
+ // ...new_message,
+ session,
+ id: new_message.id,
+ guildId: new_message.guild_id,
+ channelId: new_message.channel_id,
+ };
+
+ // all methods of Message can run on partial messages
+ // we aknowledge people that their callback could be partial but giving them all functions of Message
+ Object.setPrototypeOf(message, Message.prototype);
+
+ session.events.emit('messageUpdate', message);
+ return;
+ }
+
+ session.events.emit('messageUpdate', new Message(session, new_message));
+};
+
+export const MESSAGE_DELETE: RawHandler = (
+ session,
+ _shardId,
+ { id, channel_id, guild_id }
+) => {
+ session.events.emit('messageDelete', {
+ id,
+ channelId: channel_id,
+ guildId: guild_id,
+ });
+};
+
+export const GUILD_CREATE: RawHandler = (
+ session,
+ _shardId,
+ guild
+) => {
+ session.events.emit('guildCreate', new Guild(session, guild));
+};
+
+export const GUILD_DELETE: RawHandler = (
+ session,
+ _shardId,
+ guild
+) => {
+ session.events.emit('guildDelete', { id: guild.id, unavailable: true });
+};
+
+export const GUILD_MEMBER_ADD: RawHandler = (
+ session,
+ _shardId,
+ member
+) => {
+ session.events.emit(
+ 'guildMemberAdd',
+ new Member(session, member, member.guild_id)
+ );
+};
+
+export const GUILD_MEMBER_UPDATE: RawHandler = (
+ session,
+ _shardId,
+ member
+) => {
+ session.events.emit(
+ 'guildMemberUpdate',
+ new Member(session, member, member.guild_id)
+ );
+};
+
+export const GUILD_MEMBER_REMOVE: RawHandler = (
+ session,
+ _shardId,
+ member
+) => {
+ session.events.emit(
+ 'guildMemberRemove',
+ new User(session, member.user),
+ member.guild_id
+ );
+};
+
+export const GUILD_BAN_ADD: RawHandler = (
+ session,
+ _shardId,
+ data
+) => {
+ session.events.emit('guildBanAdd', {
+ guildId: data.guild_id,
+ user: data.user,
+ });
+};
+
+export const GUILD_BAN_REMOVE: RawHandler = (
+ session,
+ _shardId,
+ data
+) => {
+ session.events.emit('guildBanRemove', {
+ guildId: data.guild_id,
+ user: data.user,
+ });
+};
+
+export const GUILD_EMOJIS_UPDATE: RawHandler = (
+ session,
+ _shardId,
+ data
+) => {
+ session.events.emit('guildEmojisUpdate', {
+ guildId: data.guild_id,
+ emojis: data.emojis,
+ });
+};
+
+export const GUILD_ROLE_CREATE: RawHandler = (
+ session,
+ _shardId,
+ data
+) => {
+ session.events.emit('guildRoleCreate', {
+ guildId: data.guild_id,
+ role: data.role,
+ });
+};
+
+export const GUILD_ROLE_UPDATE: RawHandler = (
+ session,
+ _shardId,
+ data
+) => {
+ session.events.emit('guildRoleUpdate', {
+ guildId: data.guild_id,
+ role: data.role,
+ });
+};
+
+export const GUILD_ROLE_DELETE: RawHandler = (
+ session,
+ _shardId,
+ data
+) => {
+ session.events.emit('guildRoleDelete', {
+ guildId: data.guild_id,
+ roleId: data.role_id,
+ });
+};
+
+export const TYPING_START: RawHandler = (
+ session,
+ _shardId,
+ payload
+) => {
+ session.events.emit('typingStart', {
+ channelId: payload.channel_id,
+ guildId: payload.guild_id ? payload.guild_id : undefined,
+ userId: payload.user_id,
+ timestamp: payload.timestamp,
+ member: payload.guild_id
+ ? new Member(
+ session,
+ payload.member as DiscordMemberWithUser,
+ payload.guild_id
+ )
+ : undefined,
+ });
+};
+
+export const INTERACTION_CREATE: RawHandler = (
+ session,
+ _shardId,
+ interaction
+) => {
+ session.events.emit(
+ 'interactionCreate',
+ InteractionFactory.from(session, interaction)
+ );
+};
+
+export const CHANNEL_CREATE: RawHandler = (
+ session,
+ _shardId,
+ channel
+) => {
+ session.events.emit('channelCreate', ChannelFactory.from(session, channel));
+};
+
+export const CHANNEL_UPDATE: RawHandler = (
+ session,
+ _shardId,
+ channel
+) => {
+ session.events.emit('channelUpdate', ChannelFactory.from(session, channel));
+};
+
+export const CHANNEL_DELETE: RawHandler = (
+ session,
+ _shardId,
+ channel
+) => {
+ if (!channel.guild_id) {
+ return;
+ }
+
+ session.events.emit(
+ 'channelDelete',
+ new GuildChannel(session, channel, channel.guild_id)
+ );
+};
+
+export const THREAD_CREATE: RawHandler = (
+ session,
+ _shardId,
+ channel
+) => {
+ if (!channel.guild_id) {
+ return;
+ }
+
+ session.events.emit(
+ 'threadCreate',
+ new ThreadChannel(session, channel, channel.guild_id)
+ );
+};
+
+export const THREAD_UPDATE: RawHandler = (
+ session,
+ _shardId,
+ channel
+) => {
+ if (!channel.guild_id) {
+ return;
+ }
+
+ session.events.emit(
+ 'threadUpdate',
+ new ThreadChannel(session, channel, channel.guild_id)
+ );
+};
+
+export const THREAD_DELETE: RawHandler = (
+ session,
+ _shardId,
+ channel
+) => {
+ if (!channel.guild_id) {
+ return;
+ }
+
+ session.events.emit(
+ 'threadDelete',
+ new ThreadChannel(session, channel, channel.guild_id)
+ );
+};
+
+export const THREAD_MEMBER_UPDATE: RawHandler = (
+ session,
+ _shardId,
+ payload
+) => {
+ session.events.emit('threadMemberUpdate', {
+ guildId: payload.guild_id,
+ id: payload.id,
+ userId: payload.user_id,
+ joinedAt: payload.joined_at,
+ flags: payload.flags,
+ });
+};
+
+export const THREAD_MEMBERS_UPDATE: RawHandler = (
+ session,
+ _shardId,
+ payload
+) => {
+ session.events.emit('threadMembersUpdate', {
+ memberCount: payload.member_count,
+ addedMembers: payload.added_members
+ ? payload.added_members.map(tm => new ThreadMember(session, tm))
+ : undefined,
+ removedMemberIds: payload.removed_member_ids
+ ? payload.removed_member_ids
+ : undefined,
+ guildId: payload.guild_id,
+ id: payload.id,
+ });
+};
+
+export const THREAD_LIST_SYNC: RawHandler = (
+ session,
+ _shardId,
+ payload
+) => {
+ session.events.emit('threadListSync', {
+ guildId: payload.guild_id,
+ channelIds: payload.channel_ids ?? [],
+ threads: payload.threads.map(
+ channel => new ThreadChannel(session, channel, payload.guild_id)
+ ),
+ members: payload.members.map(
+ member => new ThreadMember(session, member)
+ ),
+ });
+};
+
+export const CHANNEL_PINS_UPDATE: RawHandler = (
+ session,
+ _shardId,
+ payload
+) => {
+ session.events.emit('channelPinsUpdate', {
+ guildId: payload.guild_id,
+ channelId: payload.channel_id,
+ lastPinTimestamp: payload.last_pin_timestamp
+ ? Date.parse(payload.last_pin_timestamp)
+ : undefined,
+ });
+};
+
+export const USER_UPDATE: RawHandler = (
+ session,
+ _shardId,
+ payload
+) => {
+ session.events.emit('userUpdate', new User(session, payload));
+};
+
+export const PRESENCE_UPDATE: RawHandler = (
+ session,
+ _shardId,
+ payload
+) => {
+ session.events.emit('presenceUpdate', new Presence(session, payload));
+};
+
+export const WEBHOOKS_UPDATE: RawHandler = (
+ session,
+ _shardId,
+ webhook
+) => {
+ session.events.emit('webhooksUpdate', {
+ guildId: webhook.guild_id,
+ channelId: webhook.channel_id,
+ });
+};
+
+export const INTEGRATION_CREATE: RawHandler<
+ DiscordIntegration & { guildId?: Snowflake }
+> = (session, _shardId, payload) => {
+ session.events.emit('integrationCreate', new Integration(session, payload));
+};
+
+export const INTEGRATION_UPDATE: RawHandler<
+ DiscordIntegration & { guildId?: Snowflake }
+> = (session, _shardId, payload) => {
+ session.events.emit('integrationCreate', new Integration(session, payload));
+};
+
+export const INTEGRATION_DELETE: RawHandler = (
+ session,
+ _shardId,
+ payload
+) => {
+ session.events.emit('integrationDelete', {
+ id: payload.id,
+ guildId: payload.guild_id,
+ applicationId: payload.application_id,
+ });
+};
+
+export const AUTO_MODERATION_RULE_CREATE: RawHandler<
+ DiscordAutoModerationRule
+> = (session, _shardId, payload) => {
+ session.events.emit(
+ 'autoModerationRuleCreate',
+ new AutoModerationRule(session, payload)
+ );
+};
+
+export const AUTO_MODERATION_RULE_UPDATE: RawHandler<
+ DiscordAutoModerationRule
+> = (session, _shardId, payload) => {
+ session.events.emit(
+ 'autoModerationRuleUpdate',
+ new AutoModerationRule(session, payload)
+ );
+};
+
+export const AUTO_MODERATION_RULE_DELETE: RawHandler<
+ DiscordAutoModerationRule
+> = (session, _shardId, payload) => {
+ session.events.emit(
+ 'autoModerationRuleDelete',
+ new AutoModerationRule(session, payload)
+ );
+};
+
+export const AUTO_MODERATION_ACTION_EXECUTE: RawHandler<
+ DiscordAutoModerationActionExecution
+> = (session, _shardId, payload) => {
+ session.events.emit(
+ 'autoModerationActionExecution',
+ new AutoModerationExecution(session, payload)
+ );
+};
+
+export const MESSAGE_REACTION_ADD: RawHandler = (
+ session,
+ _shardId,
+ reaction
+) => {
+ session.events.emit(
+ 'messageReactionAdd',
+ NewMessageReactionAdd(session, reaction)
+ );
+};
+
+export const MESSAGE_REACTION_REMOVE: RawHandler<
+ DiscordMessageReactionRemove
+> = (session, _shardId, reaction) => {
+ session.events.emit(
+ 'messageReactionRemove',
+ NewMessageReactionAdd(session, reaction)
+ );
+};
+
+export const MESSAGE_REACTION_REMOVE_ALL: RawHandler<
+ DiscordMessageReactionRemoveAll
+> = (session, _shardId, reaction) => {
+ session.events.emit(
+ 'messageReactionRemoveAll',
+ NewMessageReactionAdd(session, reaction as DiscordMessageReactionAdd)
+ );
+};
+
+export const MESSAGE_REACTION_REMOVE_EMOJI: RawHandler<
+ DiscordMessageReactionRemoveEmoji
+> = (session, _shardId, reaction) => {
+ session.events.emit(
+ 'messageReactionRemoveEmoji',
+ NewMessageReactionAdd(session, reaction as DiscordMessageReactionAdd)
+ );
+};
+
+export const INVITE_CREATE: RawHandler = (
+ session,
+ _shardId,
+ invite
+) => {
+ session.events.emit('inviteCreate', NewInviteCreate(session, invite));
+};
+
+export const INVITE_DELETE: RawHandler = (
+ session,
+ _shardId,
+ data
+) => {
+ session.events.emit('inviteDelete', {
+ channelId: data.channel_id,
+ guildId: data.guild_id,
+ code: data.code,
+ });
+};
+
+export const STAGE_INSTANCE_CREATE: RawHandler = (
+ session,
+ _shardId,
+ payload
+) => {
+ session.events.emit(
+ 'stageInstanceCreate',
+ new StageInstance(session, payload)
+ );
+};
+
+export const STAGE_INSTANCE_UPDATE: RawHandler = (
+ session,
+ _shardId,
+ payload
+) => {
+ session.events.emit(
+ 'stageInstanceUpdate',
+ new StageInstance(session, payload)
+ );
+};
+
+export const STAGE_INSTANCE_DELETE: RawHandler = (
+ session,
+ _shardId,
+ payload
+) => {
+ session.events.emit(
+ 'stageInstanceDelete',
+ new StageInstance(session, payload)
+ );
+};
+
+export const GUILD_SCHEDULED_EVENT_CREATE: RawHandler = (
+ session,
+ _shardId,
+ payload
+) => {
+ session.events.emit(
+ 'guildScheduledEventCreate',
+ new ScheduledEvent(session, payload)
+ );
+};
+
+export const GUILD_SCHEDULED_EVENT_UPDATE: RawHandler = (
+ session,
+ _shardId,
+ payload
+) => {
+ session.events.emit(
+ 'guildScheduledEventUpdate',
+ new ScheduledEvent(session, payload)
+ );
+};
+
+export const GUILD_SCHEDULED_EVENT_DELETE: RawHandler = (
+ session,
+ _shardId,
+ payload
+) => {
+ session.events.emit(
+ 'guildScheduledEventDelete',
+ new ScheduledEvent(session, payload)
+ );
+};
+
+export const GUILD_SCHEDULED_EVENT_USER_ADD: RawHandler<
+ DiscordScheduledEventUserAdd
+> = (session, _shardId, payload) => {
+ session.events.emit('guildScheduledEventUserAdd', {
+ scheduledEventId: payload.guild_scheduled_event_id,
+ userId: payload.user_id,
+ guildId: payload.guild_id,
+ });
+};
+
+export const GUILD_SCHEDULED_EVENT_USER_REMOVE: RawHandler<
+ DiscordScheduledEventUserRemove
+> = (session, _shardId, payload) => {
+ session.events.emit('guildScheduledEventUserRemove', {
+ scheduledEventId: payload.guild_scheduled_event_id,
+ userId: payload.user_id,
+ guildId: payload.guild_id,
+ });
+};
+
+export const raw: RawHandler = (session, shardId, data) => {
+ session.events.emit('raw', data as { t: string; d: unknown }, shardId);
+};
+
+export interface Ready extends Omit {
+ user: User;
+}
+
+export interface Events {
+ ready: Handler<[Ready, number]>;
+ messageCreate: Handler<[Message]>;
+ messageUpdate: Handler<[Partial]>;
+ messageDelete: Handler<
+ [{ id: Snowflake; channelId: Snowflake; guildId?: Snowflake }]
+ >;
+ messageReactionAdd: Handler<[MessageReactionAdd]>;
+ messageReactionRemove: Handler<[MessageReactionRemove]>;
+ messageReactionRemoveAll: Handler<[MessageReactionRemoveAll]>;
+ messageReactionRemoveEmoji: Handler<[MessageReactionRemoveEmoji]>;
+ guildCreate: Handler<[Guild]>;
+ guildDelete: Handler<[{ id: Snowflake; unavailable: boolean }]>;
+ guildMemberAdd: Handler<[Member]>;
+ guildMemberUpdate: Handler<[Member]>;
+ guildMemberRemove: Handler<[User, Snowflake]>;
+ guildBanAdd: Handler<[{ guildId: Snowflake; user: DiscordUser }]>;
+ guildBanRemove: Handler<[{ guildId: Snowflake; user: DiscordUser }]>;
+ guildEmojisUpdate: Handler<
+ [{ guildId: Snowflake; emojis: DiscordEmoji[] }]
+ >;
+ guildRoleCreate: Handler<[{ guildId: Snowflake; role: DiscordRole }]>;
+ guildRoleUpdate: Handler<[{ guildId: Snowflake; role: DiscordRole }]>;
+ guildRoleDelete: Handler<[{ guildId: Snowflake; roleId: Snowflake }]>;
+ typingStart: Handler<
+ [
+ {
+ channelId: Snowflake;
+ guildId?: Snowflake;
+ userId: Snowflake;
+ timestamp: number;
+ member?: Member;
+ }
+ ]
+ >;
+ channelCreate: Handler<[Channel]>;
+ channelUpdate: Handler<[Channel]>;
+ channelDelete: Handler<[GuildChannel]>;
+ channelPinsUpdate: Handler<
+ [
+ {
+ guildId?: Snowflake;
+ channelId: Snowflake;
+ lastPinTimestamp?: number;
+ }
+ ]
+ >;
+ threadCreate: Handler<[ThreadChannel]>;
+ threadUpdate: Handler<[ThreadChannel]>;
+ threadDelete: Handler<[ThreadChannel]>;
+ threadListSync: Handler<
+ [
+ {
+ guildId: Snowflake;
+ channelIds: Snowflake[];
+ threads: ThreadChannel[];
+ members: ThreadMember[];
+ }
+ ]
+ >;
+ threadMemberUpdate: Handler<
+ [
+ {
+ id: Snowflake;
+ userId: Snowflake;
+ guildId: Snowflake;
+ joinedAt: string;
+ flags: number;
+ }
+ ]
+ >;
+ threadMembersUpdate: Handler<
+ [
+ {
+ id: Snowflake;
+ memberCount: number;
+ addedMembers?: ThreadMember[];
+ guildId: Snowflake;
+ removedMemberIds?: Snowflake[];
+ }
+ ]
+ >;
+ interactionCreate: Handler<[Interaction]>;
+ integrationCreate: Handler<[Integration]>;
+ integrationUpdate: Handler<[Integration]>;
+ integrationDelete: Handler<
+ [{ id: Snowflake; guildId?: Snowflake; applicationId?: Snowflake }]
+ >;
+ inviteCreate: Handler<[InviteCreate]>;
+ inviteDelete: Handler<
+ [{ channelId: string; guildId?: string; code: string }]
+ >;
+ autoModerationRuleCreate: Handler<[AutoModerationRule]>;
+ autoModerationRuleUpdate: Handler<[AutoModerationRule]>;
+ autoModerationRuleDelete: Handler<[AutoModerationRule]>;
+ autoModerationActionExecution: Handler<[AutoModerationExecution]>;
+ stageInstanceCreate: Handler<[StageInstance]>;
+ stageInstanceUpdate: Handler<[StageInstance]>;
+ stageInstanceDelete: Handler<[StageInstance]>;
+ guildScheduledEventCreate: Handler<[ScheduledEvent]>;
+ guildScheduledEventUpdate: Handler<[ScheduledEvent]>;
+ guildScheduledEventDelete: Handler<[ScheduledEvent]>;
+ guildScheduledEventUserAdd: Handler<
+ [{ scheduledEventId: Snowflake; userId: Snowflake; guildId: Snowflake }]
+ >;
+ guildScheduledEventUserRemove: Handler<
+ [{ scheduledEventId: Snowflake; userId: Snowflake; guildId: Snowflake }]
+ >;
+ raw: Handler<[{ t: string; d: unknown }, number]>;
+ webhooksUpdate: Handler<[{ guildId: Snowflake; channelId: Snowflake }]>;
+ userUpdate: Handler<[User]>;
+ presenceUpdate: Handler<[Presence]>;
+ debug: Handler<[string]>;
+}
diff --git a/packages/core/src/biscuit.ts b/packages/core/src/biscuit.ts
new file mode 100644
index 0000000..e841a2d
--- /dev/null
+++ b/packages/core/src/biscuit.ts
@@ -0,0 +1,212 @@
+import type {
+ DiscordGatewayPayload,
+ GatewayIntents,
+ Snowflake,
+} from '@biscuitland/api-types';
+
+// DiscordGetGatewayBot;
+
+import type { RestAdapter } from '@biscuitland/rest';
+import { DefaultRestAdapter } from '@biscuitland/rest';
+
+import type { WsAdapter } from '@biscuitland/ws';
+import { DefaultWsAdapter } from '@biscuitland/ws';
+
+import type { EventAdapter } from './adapters/event-adapter';
+import { DefaultEventAdapter } from './adapters/default-event-adapter';
+
+import { Util } from './utils/util';
+import { Shard } from '@biscuitland/ws';
+
+export type DiscordRawEventHandler = (
+ shard: Shard,
+ data: MessageEvent
+) => unknown;
+
+export type PickOptions = Pick<
+ BiscuitOptions,
+ Exclude
+> &
+ Partial;
+
+export interface BiscuitOptions {
+ intents?: GatewayIntents;
+ token: string;
+
+ events?: {
+ adapter?: { new (...args: any[]): EventAdapter };
+ options: any;
+ };
+
+ rest: {
+ adapter?: { new (...args: any[]): RestAdapter };
+ options: any;
+ };
+
+ ws: {
+ adapter?: { new (...args: any[]): WsAdapter };
+ options: any;
+ };
+}
+import * as Actions from './adapters/events';
+
+export class Session {
+ #applicationId?: Snowflake;
+ #botId?: Snowflake;
+ token: string;
+
+ set botId(snowflake: Snowflake) {
+ this.#botId = snowflake;
+ }
+
+ get botId(): Snowflake {
+ return this.#botId ?? Util.getBotIdFromToken(this.token);
+ }
+
+ set applicationId(snowflake: Snowflake) {
+ this.#applicationId = snowflake;
+ }
+
+ get applicationId(): Snowflake {
+ return this.#applicationId ?? this.botId;
+ }
+
+ static readonly DEFAULTS = {
+ rest: {
+ adapter: DefaultRestAdapter,
+ options: null,
+ },
+ ws: {
+ adapter: DefaultWsAdapter,
+ options: null,
+ },
+ };
+
+ options: BiscuitOptions;
+
+ readonly events: EventAdapter;
+
+ readonly rest: RestAdapter;
+ readonly ws: WsAdapter;
+
+ private adapters = new Map();
+
+ constructor(options: PickOptions) {
+ this.options = Object.assign(options, Session.DEFAULTS);
+
+ // makeRest
+
+ if (!this.options.rest.options) {
+ this.options.rest.options = {
+ intents: this.options.intents,
+ token: this.options.token,
+ };
+ }
+
+ this.rest = this.getRest();
+
+ // makeWs
+
+ const defHandler: DiscordRawEventHandler = (shard, event) => {
+ let message = event.data;
+ let data = JSON.parse(message) as DiscordGatewayPayload;
+
+ Actions.raw(this, shard.id, data);
+
+ if (!data.t || !data.d) {
+ return;
+ }
+
+ Actions[data.t as keyof typeof Actions]?.(
+ this,
+ shard.id,
+ data.d as any
+ );
+ };
+
+ if (!this.options.ws.options) {
+ this.options.ws.options = {
+ handleDiscordPayload: defHandler,
+
+ gatewayConfig: {
+ token: this.options.token,
+ intents: this.options.intents,
+ },
+
+ intents: this.options.intents,
+ token: this.options.token,
+ };
+ }
+
+ // makeEvents
+
+ this.events = this.options.events?.adapter
+ ? new this.options.events.adapter()
+ : new DefaultEventAdapter();
+
+ this.ws = this.getWs();
+ this.token = options.token;
+ }
+
+ /**
+ * @inheritDoc
+ */
+
+ private getAdapter }>(
+ adapter: T,
+ ...args: ConstructorParameters
+ ): InstanceType {
+ if (!this.adapters.has(adapter.name)) {
+ const Class = adapter as { new (...args: any[]): T };
+ this.adapters.set(adapter.name, new Class(...args));
+ }
+
+ return this.adapters.get(adapter.name);
+ }
+
+ /**
+ * @inheritDoc
+ */
+
+ private getRest(): RestAdapter {
+ return this.getAdapter(
+ this.options.rest.adapter!,
+ this.options.rest.options
+ );
+ }
+
+ /**
+ * @inheritDoc
+ */
+
+ private getWs(): WsAdapter {
+ return this.getAdapter(
+ this.options.ws.adapter!,
+ this.options.ws.options
+ );
+ }
+
+ /**
+ * @inheritDoc
+ */
+
+ async start(): Promise {
+ const nonParsed = await this.rest.get('/gateway/bot');
+
+ this.ws.options.gatewayBot = {
+ url: nonParsed.url,
+ shards: nonParsed.shards,
+ sessionStartLimit: {
+ total: nonParsed.session_start_limit.total,
+ remaining: nonParsed.session_start_limit.remaining,
+ resetAfter: nonParsed.session_start_limit.reset_after,
+ maxConcurrency: nonParsed.session_start_limit.max_concurrency,
+ },
+ };
+
+ this.ws.options.lastShardId = this.ws.options.gatewayBot.shards - 1;
+ this.ws.agent.options.totalShards = this.ws.options.gatewayBot.shards;
+
+ this.ws.shards();
+ }
+}
diff --git a/packages/core/src/builders/components/InputTextBuilder.ts b/packages/core/src/builders/components/InputTextBuilder.ts
new file mode 100644
index 0000000..45f8d92
--- /dev/null
+++ b/packages/core/src/builders/components/InputTextBuilder.ts
@@ -0,0 +1,49 @@
+import type { DiscordInputTextComponent, MessageComponentTypes, TextStyles } from '@biscuitland/api-types';
+
+export class InputTextBuilder {
+ constructor() {
+ this.#data = {} as DiscordInputTextComponent;
+ this.type = 4;
+ }
+ #data: DiscordInputTextComponent;
+ type: MessageComponentTypes.InputText;
+
+ setStyle(style: TextStyles): this {
+ this.#data.style = style;
+ return this;
+ }
+
+ setLabel(label: string): this {
+ this.#data.label = label;
+ return this;
+ }
+
+ setPlaceholder(placeholder: string): this {
+ this.#data.placeholder = placeholder;
+ return this;
+ }
+
+ setLength(max?: number, min?: number): this {
+ this.#data.max_length = max;
+ this.#data.min_length = min;
+ return this;
+ }
+
+ setCustomId(id: string): this {
+ this.#data.custom_id = id;
+ return this;
+ }
+
+ setValue(value: string): this {
+ this.#data.value = value;
+ return this;
+ }
+
+ setRequired(required = true): this {
+ this.#data.required = required;
+ return this;
+ }
+ toJSON(): DiscordInputTextComponent {
+ return { ...this.#data, type: this.type };
+ }
+}
diff --git a/packages/core/src/builders/components/MessageActionRowBuilder.ts b/packages/core/src/builders/components/MessageActionRowBuilder.ts
new file mode 100644
index 0000000..3f066ff
--- /dev/null
+++ b/packages/core/src/builders/components/MessageActionRowBuilder.ts
@@ -0,0 +1,33 @@
+import type { DiscordActionRow, MessageComponentTypes } from '@biscuitland/api-types';
+import type { ComponentBuilder } from '../../utils/util';
+
+export class ActionRowBuilder {
+ constructor() {
+ this.components = [] as T[];
+ this.type = 1;
+ }
+ components: T[];
+ type: MessageComponentTypes.ActionRow;
+
+ addComponents(...components: T[]): this {
+ this.components.push(...components);
+ return this;
+ }
+
+ setComponents(...components: T[]): this {
+ this.components.splice(
+ 0,
+ this.components.length,
+ ...components,
+ );
+ return this;
+ }
+
+ toJSON(): DiscordActionRow {
+ return {
+ type: this.type,
+ // @ts-ignore: socram fix this
+ components: this.components.map((c) => c.toJSON()) as DiscordActionRow['components'],
+ };
+ }
+}
diff --git a/packages/core/src/builders/components/MessageButtonBuilder.ts b/packages/core/src/builders/components/MessageButtonBuilder.ts
new file mode 100644
index 0000000..f2408be
--- /dev/null
+++ b/packages/core/src/builders/components/MessageButtonBuilder.ts
@@ -0,0 +1,45 @@
+import { ButtonStyles, DiscordButtonComponent, MessageComponentTypes } from '@biscuitland/api-types';
+import type { ComponentEmoji } from '../../utils/util';
+
+export class ButtonBuilder {
+ constructor() {
+ this.#data = {} as DiscordButtonComponent;
+ this.type = MessageComponentTypes.Button;
+ }
+ #data: DiscordButtonComponent;
+ type: MessageComponentTypes.Button;
+
+ setStyle(style: ButtonStyles): this {
+ this.#data.style = style;
+ return this;
+ }
+
+ setLabel(label: string): this {
+ this.#data.label = label;
+ return this;
+ }
+
+ setCustomId(id: string): this {
+ this.#data.custom_id = id;
+ return this;
+ }
+
+ setEmoji(emoji: ComponentEmoji): this {
+ this.#data.emoji = emoji;
+ return this;
+ }
+
+ setDisabled(disabled = true): this {
+ this.#data.disabled = disabled;
+ return this;
+ }
+
+ setURL(url: string): this {
+ this.#data.url = url;
+ return this;
+ }
+
+ toJSON(): DiscordButtonComponent {
+ return { ...this.#data, type: this.type };
+ }
+}
diff --git a/packages/core/src/builders/components/MessageSelectMenuBuilder.ts b/packages/core/src/builders/components/MessageSelectMenuBuilder.ts
new file mode 100644
index 0000000..edf419a
--- /dev/null
+++ b/packages/core/src/builders/components/MessageSelectMenuBuilder.ts
@@ -0,0 +1,91 @@
+import type { DiscordSelectOption, DiscordSelectMenuComponent, } from '@biscuitland/api-types';
+import type { ComponentEmoji } from '../../utils/util';
+import { MessageComponentTypes } from '@biscuitland/api-types';
+
+export class SelectMenuOptionBuilder {
+ constructor() {
+ this.#data = {} as DiscordSelectOption;
+ }
+ #data: DiscordSelectOption;
+
+ setLabel(label: string): SelectMenuOptionBuilder {
+ this.#data.label = label;
+ return this;
+ }
+
+ setValue(value: string): SelectMenuOptionBuilder {
+ this.#data.value = value;
+ return this;
+ }
+
+ setDescription(description: string): SelectMenuOptionBuilder {
+ this.#data.description = description;
+ return this;
+ }
+
+ setDefault(Default = true): SelectMenuOptionBuilder {
+ this.#data.default = Default;
+ return this;
+ }
+
+ setEmoji(emoji: ComponentEmoji): SelectMenuOptionBuilder {
+ this.#data.emoji = emoji;
+ return this;
+ }
+
+ toJSON(): DiscordSelectOption {
+ return { ...this.#data };
+ }
+}
+
+export class SelectMenuBuilder {
+ constructor() {
+ this.#data = {} as DiscordSelectMenuComponent;
+ this.type = MessageComponentTypes.SelectMenu;
+ this.options = [];
+ }
+ #data: DiscordSelectMenuComponent;
+ type: MessageComponentTypes.SelectMenu;
+ options: SelectMenuOptionBuilder[];
+
+ setPlaceholder(placeholder: string): this {
+ this.#data.placeholder = placeholder;
+ return this;
+ }
+
+ setValues(max?: number, min?: number): this {
+ this.#data.max_values = max;
+ this.#data.min_values = min;
+ return this;
+ }
+
+ setDisabled(disabled = true): this {
+ this.#data.disabled = disabled;
+ return this;
+ }
+
+ setCustomId(id: string): this {
+ this.#data.custom_id = id;
+ return this;
+ }
+
+ setOptions(...options: SelectMenuOptionBuilder[]): this {
+ this.options.splice(
+ 0,
+ this.options.length,
+ ...options,
+ );
+ return this;
+ }
+
+ addOptions(...options: SelectMenuOptionBuilder[]): this {
+ this.options.push(
+ ...options,
+ );
+ return this;
+ }
+
+ toJSON(): DiscordSelectMenuComponent {
+ return { ...this.#data, type: this.type, options: this.options.map((option) => option.toJSON()) };
+ }
+}
diff --git a/packages/core/src/builders/embed-builder.ts b/packages/core/src/builders/embed-builder.ts
new file mode 100644
index 0000000..49bfbee
--- /dev/null
+++ b/packages/core/src/builders/embed-builder.ts
@@ -0,0 +1,109 @@
+import type { DiscordEmbed, DiscordEmbedField, DiscordEmbedProvider } from '@biscuitland/api-types';
+
+export interface EmbedFooter {
+ text: string;
+ iconUrl?: string;
+ proxyIconUrl?: string;
+}
+
+export interface EmbedAuthor {
+ name: string;
+ text?: string;
+ url?: string;
+ iconUrl?: string;
+ proxyIconUrl?: string;
+}
+
+export interface EmbedVideo {
+ height?: number;
+ proxyUrl?: string;
+ url?: string;
+ width?: number;
+}
+
+export class EmbedBuilder {
+ #data: DiscordEmbed;
+ constructor(data: DiscordEmbed = {}) {
+ this.#data = data;
+ if (!this.#data.fields) this.#data.fields = [];
+ }
+
+ setAuthor(author: EmbedAuthor): EmbedBuilder {
+ this.#data.author = {
+ name: author.name,
+ icon_url: author.iconUrl,
+ proxy_icon_url: author.proxyIconUrl,
+ url: author.url,
+ };
+ return this;
+ }
+
+ setColor(color: number): EmbedBuilder {
+ this.#data.color = color;
+ return this;
+ }
+
+ setDescription(description: string): EmbedBuilder {
+ this.#data.description = description;
+ return this;
+ }
+
+ addField(field: DiscordEmbedField): EmbedBuilder {
+ this.#data.fields!.push(field);
+ return this;
+ }
+
+ setFooter(footer: EmbedFooter): EmbedBuilder {
+ this.#data.footer = {
+ text: footer.text,
+ icon_url: footer.iconUrl,
+ proxy_icon_url: footer.proxyIconUrl,
+ };
+ return this;
+ }
+
+ setImage(image: string): EmbedBuilder {
+ this.#data.image = { url: image };
+ return this;
+ }
+
+ setProvider(provider: DiscordEmbedProvider): EmbedBuilder {
+ this.#data.provider = provider;
+ return this;
+ }
+
+ setThumbnail(thumbnail: string): EmbedBuilder {
+ this.#data.thumbnail = { url: thumbnail };
+ return this;
+ }
+
+ setTimestamp(timestamp: string | Date): EmbedBuilder {
+ this.#data.timestamp = timestamp instanceof Date ? timestamp.toISOString() : timestamp;
+ return this;
+ }
+
+ setTitle(title: string, url?: string): EmbedBuilder {
+ this.#data.title = title;
+ if (url) this.setUrl(url);
+ return this;
+ }
+
+ setUrl(url: string): EmbedBuilder {
+ this.#data.url = url;
+ return this;
+ }
+
+ setVideo(video: EmbedVideo): EmbedBuilder {
+ this.#data.video = {
+ height: video.height,
+ proxy_url: video.proxyUrl,
+ url: video.url,
+ width: video.width,
+ };
+ return this;
+ }
+
+ toJSON(): DiscordEmbed {
+ return this.#data;
+ }
+}
diff --git a/packages/core/src/builders/slash/ApplicationCommand.ts b/packages/core/src/builders/slash/ApplicationCommand.ts
new file mode 100644
index 0000000..95a471c
--- /dev/null
+++ b/packages/core/src/builders/slash/ApplicationCommand.ts
@@ -0,0 +1,129 @@
+import type { Localization, PermissionStrings, DiscordApplicationCommandOption } from '@biscuitland/api-types';
+import type { PermissionResolvable } from '../../structures/special/permissions';
+import { ApplicationCommandTypes } from '@biscuitland/api-types';
+import { OptionBased } from './ApplicationCommandOption';
+
+/**
+ * @link https://discord.com/developers/docs/interactions/application-commands#endpoints-json-params
+ */
+export interface CreateApplicationCommand {
+ name: string;
+ nameLocalizations?: Localization;
+ description: string;
+ descriptionLocalizations?: Localization;
+ type?: ApplicationCommandTypes;
+ options?: DiscordApplicationCommandOption[];
+ defaultMemberPermissions?: PermissionResolvable;
+ dmPermission?: boolean;
+}
+
+export abstract class ApplicationCommandBuilder implements CreateApplicationCommand {
+ constructor(
+ type: ApplicationCommandTypes = ApplicationCommandTypes.ChatInput,
+ name: string = '',
+ description: string = '',
+ defaultMemberPermissions?: PermissionStrings[],
+ nameLocalizations?: Localization,
+ descriptionLocalizations?: Localization,
+ dmPermission: boolean = true,
+ ) {
+ this.type = type;
+ this.name = name;
+ this.description = description;
+ this.defaultMemberPermissions = defaultMemberPermissions;
+ this.nameLocalizations = nameLocalizations;
+ this.descriptionLocalizations = descriptionLocalizations;
+ this.dmPermission = dmPermission;
+ }
+ type: ApplicationCommandTypes;
+ name: string;
+ description: string;
+ defaultMemberPermissions?: PermissionStrings[];
+ nameLocalizations?: Localization;
+ descriptionLocalizations?: Localization;
+ dmPermission: boolean;
+
+ setType(type: ApplicationCommandTypes): this {
+ return (this.type = type), this;
+ }
+
+ setName(name: string): this {
+ return (this.name = name), this;
+ }
+
+ setDescription(description: string): this {
+ return (this.description = description), this;
+ }
+
+ setDefaultMemberPermission(perm: PermissionStrings[]): this {
+ return (this.defaultMemberPermissions = perm), this;
+ }
+
+ setNameLocalizations(l: Localization): this {
+ return (this.nameLocalizations = l), this;
+ }
+
+ setDescriptionLocalizations(l: Localization): this {
+ return (this.descriptionLocalizations = l), this;
+ }
+
+ setDmPermission(perm: boolean): this {
+ return (this.dmPermission = perm), this;
+ }
+}
+
+export type MessageApplicationCommandBuilderJSON = { name: string; type: ApplicationCommandTypes.Message };
+
+export class MessageApplicationCommandBuilder {
+ type: ApplicationCommandTypes;
+ name?: string;
+ constructor(
+ type?: ApplicationCommandTypes,
+ name?: string,
+ ) {
+ this.type = type ?? ApplicationCommandTypes.Message;
+ this.name = name;
+ }
+
+ setName(name: string): this {
+ return (this.name = name), this;
+ }
+
+ toJSON(): MessageApplicationCommandBuilderJSON {
+ if (!this.name) throw new TypeError('Propety \'name\' is required');
+
+ return {
+ type: ApplicationCommandTypes.Message,
+ name: this.name,
+ };
+ }
+}
+
+export class ChatInputApplicationCommandBuilder extends ApplicationCommandBuilder {
+ type: ApplicationCommandTypes.ChatInput = ApplicationCommandTypes.ChatInput;
+
+ toJSON(): CreateApplicationCommand {
+ if (!this.type) throw new TypeError('Propety \'type\' is required');
+ if (!this.name) throw new TypeError('Propety \'name\' is required');
+ if (!this.description) {
+ throw new TypeError('Propety \'description\' is required');
+ }
+
+ return {
+ type: ApplicationCommandTypes.ChatInput,
+ name: this.name,
+ description: this.description,
+ options: this.options?.map((o) => o.toJSON()) ?? [],
+ defaultMemberPermissions: this.defaultMemberPermissions,
+ nameLocalizations: this.nameLocalizations,
+ descriptionLocalizations: this.descriptionLocalizations,
+ dmPermission: this.dmPermission,
+ };
+ }
+}
+
+OptionBased.applyTo(ChatInputApplicationCommandBuilder);
+
+export interface ChatInputApplicationCommandBuilder extends ApplicationCommandBuilder, OptionBased {
+ // pass
+}
diff --git a/packages/core/src/builders/slash/ApplicationCommandOption.ts b/packages/core/src/builders/slash/ApplicationCommandOption.ts
new file mode 100644
index 0000000..d4ed650
--- /dev/null
+++ b/packages/core/src/builders/slash/ApplicationCommandOption.ts
@@ -0,0 +1,346 @@
+import { ApplicationCommandOptionTypes, ChannelTypes, Localization } from '@biscuitland/api-types';
+import { ApplicationCommandOptionChoice } from '../../structures/interactions';
+
+export class ChoiceBuilder {
+ name?: string;
+ value?: string;
+
+ setName(name: string): ChoiceBuilder {
+ this.name = name;
+ return this;
+ }
+
+ setValue(value: string): this {
+ this.value = value;
+ return this;
+ }
+
+ toJSON(): ApplicationCommandOptionChoice {
+ if (!this.name) throw new TypeError('Property \'name\' is required');
+ if (!this.value) throw new TypeError('Property \'value\' is required');
+
+ return {
+ name: this.name,
+ value: this.value,
+ };
+ }
+}
+
+export class OptionBuilder {
+ required?: boolean;
+ autocomplete?: boolean;
+ type?: ApplicationCommandOptionTypes;
+ name?: string;
+ description?: string;
+
+ constructor(type?: ApplicationCommandOptionTypes, name?: string, description?: string) {
+ this.type = type;
+ this.name = name;
+ this.description = description;
+ }
+
+ setType(type: ApplicationCommandOptionTypes): this {
+ return (this.type = type), this;
+ }
+
+ setName(name: string): this {
+ return (this.name = name), this;
+ }
+
+ setDescription(description: string): this {
+ return (this.description = description), this;
+ }
+
+ setRequired(required: boolean): this {
+ return (this.required = required), this;
+ }
+
+ toJSON(): ApplicationCommandOption {
+ if (!this.type) throw new TypeError('Property \'type\' is required');
+ if (!this.name) throw new TypeError('Property \'name\' is required');
+ if (!this.description) {
+ throw new TypeError('Property \'description\' is required');
+ }
+
+ const applicationCommandOption: ApplicationCommandOption = {
+ type: this.type,
+ name: this.name,
+ description: this.description,
+ required: this.required ? true : false,
+ };
+
+ return applicationCommandOption;
+ }
+}
+
+export class OptionBuilderLimitedValues extends OptionBuilder {
+ choices?: ChoiceBuilder[];
+ minValue?: number;
+ maxValue?: number;
+
+ constructor(
+ type?: ApplicationCommandOptionTypes.Integer | ApplicationCommandOptionTypes.Number,
+ name?: string,
+ description?: string,
+ ) {
+ super();
+ this.type = type;
+ this.name = name;
+ this.description = description;
+ }
+
+ setMinValue(n: number): this {
+ return (this.minValue = n), this;
+ }
+
+ setMaxValue(n: number): this {
+ return (this.maxValue = n), this;
+ }
+
+ addChoice(fn: (choice: ChoiceBuilder) => ChoiceBuilder): this {
+ const choice = fn(new ChoiceBuilder());
+ this.choices ??= [];
+ this.choices.push(choice);
+ return this;
+ }
+
+ override toJSON(): ApplicationCommandOption {
+ return {
+ ...super.toJSON(),
+ choices: this.choices?.map((c) => c.toJSON()) ?? [],
+ minValue: this.minValue,
+ maxValue: this.maxValue,
+ };
+ }
+}
+
+export class OptionBuilderString extends OptionBuilder {
+ choices?: ChoiceBuilder[];
+ constructor(
+ type?: ApplicationCommandOptionTypes.String,
+ name?: string,
+ description?: string,
+ ) {
+ super();
+ this.type = type;
+ this.name = name;
+ this.description = description;
+ this;
+ }
+
+ addChoice(fn: (choice: ChoiceBuilder) => ChoiceBuilder): this {
+ const choice = fn(new ChoiceBuilder());
+ this.choices ??= [];
+ this.choices.push(choice);
+ return this;
+ }
+
+ override toJSON(): ApplicationCommandOption {
+ return {
+ ...super.toJSON(),
+ choices: this.choices?.map((c) => c.toJSON()) ?? [],
+ };
+ }
+}
+
+export class OptionBuilderChannel extends OptionBuilder {
+ channelTypes?: ChannelTypes[];
+ constructor(
+ type?: ApplicationCommandOptionTypes.Channel,
+ name?: string,
+ description?: string,
+ ) {
+ super();
+ this.type = type;
+ this.name = name;
+ this.description = description;
+ this;
+ }
+
+ addChannelTypes(...channels: ChannelTypes[]): this {
+ this.channelTypes ??= [];
+ this.channelTypes.push(...channels);
+ return this;
+ }
+
+ override toJSON(): ApplicationCommandOption {
+ return {
+ ...super.toJSON(),
+ channelTypes: this.channelTypes ?? [],
+ };
+ }
+}
+
+export interface OptionBuilderLike {
+ toJSON(): ApplicationCommandOption;
+}
+
+export class OptionBased {
+ options?:
+ & (
+ | OptionBuilder[]
+ | OptionBuilderString[]
+ | OptionBuilderLimitedValues[]
+ | OptionBuilderNested[]
+ | OptionBuilderChannel[]
+ )
+ & OptionBuilderLike[];
+
+ addOption(fn: (option: OptionBuilder) => OptionBuilder, type?: ApplicationCommandOptionTypes): this {
+ const option = fn(new OptionBuilder(type));
+ this.options ??= [];
+ this.options.push(option);
+ return this;
+ }
+
+ addNestedOption(fn: (option: OptionBuilder) => OptionBuilder): this {
+ const option = fn(new OptionBuilder(ApplicationCommandOptionTypes.SubCommand));
+ this.options ??= [];
+ this.options.push(option);
+ return this;
+ }
+
+ addStringOption(fn: (option: OptionBuilderString) => OptionBuilderString): this {
+ const option = fn(new OptionBuilderString(ApplicationCommandOptionTypes.String));
+ this.options ??= [];
+ this.options.push(option);
+ return this;
+ }
+
+ addIntegerOption(fn: (option: OptionBuilderLimitedValues) => OptionBuilderLimitedValues): this {
+ const option = fn(new OptionBuilderLimitedValues(ApplicationCommandOptionTypes.Integer));
+ this.options ??= [];
+ this.options.push(option);
+ return this;
+ }
+
+ addNumberOption(fn: (option: OptionBuilderLimitedValues) => OptionBuilderLimitedValues): this {
+ const option = fn(new OptionBuilderLimitedValues(ApplicationCommandOptionTypes.Number));
+ this.options ??= [];
+ this.options.push(option);
+ return this;
+ }
+
+ addBooleanOption(fn: (option: OptionBuilder) => OptionBuilder): this {
+ return this.addOption(fn, ApplicationCommandOptionTypes.Boolean);
+ }
+
+ addSubCommand(fn: (option: OptionBuilderNested) => OptionBuilderNested): this {
+ const option = fn(new OptionBuilderNested(ApplicationCommandOptionTypes.SubCommand));
+ this.options ??= [];
+ this.options.push(option);
+ return this;
+ }
+
+ addSubCommandGroup(fn: (option: OptionBuilderNested) => OptionBuilderNested): this {
+ const option = fn(new OptionBuilderNested(ApplicationCommandOptionTypes.SubCommandGroup));
+ this.options ??= [];
+ this.options.push(option);
+ return this;
+ }
+
+ addUserOption(fn: (option: OptionBuilder) => OptionBuilder): this {
+ return this.addOption(fn, ApplicationCommandOptionTypes.User);
+ }
+
+ addChannelOption(fn: (option: OptionBuilderChannel) => OptionBuilderChannel): this {
+ const option = fn(new OptionBuilderChannel(ApplicationCommandOptionTypes.Channel));
+ this.options ??= [];
+ this.options.push(option);
+ return this;
+ }
+
+ addRoleOption(fn: (option: OptionBuilder) => OptionBuilder): this {
+ return this.addOption(fn, ApplicationCommandOptionTypes.Role);
+ }
+
+ addMentionableOption(fn: (option: OptionBuilder) => OptionBuilder): this {
+ return this.addOption(fn, ApplicationCommandOptionTypes.Mentionable);
+ }
+
+ // deno-lint-ignore ban-types
+ static applyTo(klass: Function, ignore: Array = []): void {
+ const methods: Array = [
+ 'addOption',
+ 'addNestedOption',
+ 'addStringOption',
+ 'addIntegerOption',
+ 'addNumberOption',
+ 'addBooleanOption',
+ 'addSubCommand',
+ 'addSubCommandGroup',
+ 'addUserOption',
+ 'addChannelOption',
+ 'addRoleOption',
+ 'addMentionableOption',
+ ];
+
+ for (const method of methods) {
+ if (ignore.includes(method)) continue;
+
+ klass.prototype[method] = OptionBased.prototype[method];
+ }
+ }
+}
+
+export class OptionBuilderNested extends OptionBuilder {
+ constructor(
+ type?: ApplicationCommandOptionTypes.SubCommand | ApplicationCommandOptionTypes.SubCommandGroup,
+ name?: string,
+ description?: string,
+ ) {
+ super();
+ this.type = type;
+ this.name = name;
+ this.description = description;
+ }
+
+ override toJSON(): ApplicationCommandOption {
+ if (!this.type) throw new TypeError('Property \'type\' is required');
+ if (!this.name) throw new TypeError('Property \'name\' is required');
+ if (!this.description) {
+ throw new TypeError('Property \'description\' is required');
+ }
+
+ return {
+ type: this.type,
+ name: this.name,
+ description: this.description,
+ options: this.options?.map((o) => o.toJSON()) ?? [],
+ required: this.required ? true : false,
+ };
+ }
+}
+
+OptionBased.applyTo(OptionBuilderNested);
+
+export interface OptionBuilderNested extends OptionBuilder, OptionBased {
+ // pass
+}
+
+export interface ApplicationCommandOption {
+ /** Value of Application Command Option Type */
+ type: ApplicationCommandOptionTypes;
+ /** 1-32 character name matching lowercase `^[\w-]{1,32}$` */
+ name: string;
+ /** Localization object for the `name` field. Values follow the same restrictions as `name` */
+ nameLocalizations?: Localization;
+ /** 1-100 character description */
+ description: string;
+ /** Localization object for the `description` field. Values follow the same restrictions as `description` */
+ descriptionLocalizations?: Localization;
+ /** If the parameter is required or optional--default `false` */
+ required?: boolean;
+ /** Choices for `string` and `int` types for the user to pick from */
+ choices?: ApplicationCommandOptionChoice[];
+ /** If the option is a subcommand or subcommand group type, this nested options will be the parameters */
+ options?: ApplicationCommandOption[];
+ /** if autocomplete interactions are enabled for this `String`, `Integer`, or `Number` type option */
+ autocomplete?: boolean;
+ /** If the option is a channel type, the channels shown will be restricted to these types */
+ channelTypes?: ChannelTypes[];
+ /** Minimum number desired. */
+ minValue?: number;
+ /** Maximum number desired. */
+ maxValue?: number;
+}
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
new file mode 100644
index 0000000..dc05416
--- /dev/null
+++ b/packages/core/src/index.ts
@@ -0,0 +1,21 @@
+// SESSION
+export * as Actions from './adapters/events';
+
+export { Session as Biscuit } from './biscuit';
+export * from './biscuit';
+
+// STRUCTURES
+export * from './structures';
+
+// EVENTS
+export * from './adapters/events';
+export * from './adapters/event-adapter';
+export * from './adapters/default-event-adapter';
+
+// ETC
+export * from './snowflakes';
+
+// UTIL
+export * from './utils/calculate-shard';
+export * from './utils/url-to-base-64';
+export * from './utils/util';
diff --git a/packages/core/src/snowflakes.ts b/packages/core/src/snowflakes.ts
new file mode 100644
index 0000000..bed3406
--- /dev/null
+++ b/packages/core/src/snowflakes.ts
@@ -0,0 +1,12 @@
+/** snowflake type */
+export type Snowflake = string;
+
+/** Discord epoch */
+export const DiscordEpoch = 14200704e5;
+
+/** utilities for Snowflakes */
+export const Snowflake = {
+ snowflakeToTimestamp(id: Snowflake): number {
+ return (Number(id) >> 22) + DiscordEpoch;
+ },
+};
diff --git a/packages/core/src/structures.ts b/packages/core/src/structures.ts
new file mode 100644
index 0000000..8bf2816
--- /dev/null
+++ b/packages/core/src/structures.ts
@@ -0,0 +1,42 @@
+// STRUCTURES
+export * from './structures/application';
+export * from './structures/attachment';
+export * from './structures/automod';
+export * from './structures/base';
+export * from './structures/embed';
+export * from './structures/emojis';
+export * from './structures/scheduled-events';
+export * from './structures/integration';
+export * from './structures/invite';
+export * from './structures/members';
+export * from './structures/message';
+export * from './structures/message-reaction';
+export * from './structures/special/command-interaction-option-resolver';
+export * from './structures/special/permissions';
+export * from './structures/presence';
+export * from './structures/role';
+export * from './structures/stage-instance';
+export * from './structures/sticker';
+export * from './structures/user';
+export * from './structures/webhook';
+export * from './structures/welcome';
+
+// INTERACTIONS
+export * from './structures/interactions';
+
+// CHANNELS
+export * from './structures/channels';
+
+// COMPONENTS
+export * from './structures/components';
+
+// GUILDS
+export * from './structures/guilds';
+
+// BUILDERS
+export * from './builders/components/InputTextBuilder';
+export * from './builders/components/MessageActionRowBuilder';
+export * from './builders/components/MessageButtonBuilder';
+export * from './builders/components/MessageSelectMenuBuilder';
+export * from './builders/slash/ApplicationCommand';
+export * from './builders/slash/ApplicationCommandOption';
diff --git a/packages/core/src/structures/application.ts b/packages/core/src/structures/application.ts
new file mode 100644
index 0000000..f4bd205
--- /dev/null
+++ b/packages/core/src/structures/application.ts
@@ -0,0 +1,112 @@
+import type { Model } from './base';
+import type { Snowflake } from '../snowflakes';
+import type { Session } from '../biscuit';
+import type {
+ DiscordApplication,
+ DiscordInstallParams,
+ DiscordTeam,
+ DiscordUser,
+ TeamMembershipStates,
+} from '@biscuitland/api-types';
+import { User } from './user';
+
+/**
+ * @internal
+ */
+export type SummaryDeprecated = '';
+
+/**
+ * Discord team that holds members
+ */
+export interface Team {
+ /** a hash of the image of the team's icon */
+ icon?: string;
+ /** the unique id of the team */
+ id: string;
+ /** the members of the team */
+ members: TeamMember[];
+ /** user id of the current team owner */
+ ownerUserId: string;
+ /** team name */
+ name: string;
+}
+
+export interface TeamMember {
+ /** the user's membership state on the team */
+ membershipState: TeamMembershipStates;
+ permissions: '*'[];
+ teamId: string;
+ user: Partial &
+ Pick;
+}
+
+// NewTeam create a new Team object for discord applications
+export function NewTeam(session: Session, data: DiscordTeam): Team {
+ return {
+ icon: data.icon ? data.icon : undefined,
+ id: data.id,
+ members: data.members.map(member => {
+ return {
+ membershipState: member.membership_state,
+ permissions: member.permissions,
+ teamId: member.team_id,
+ user: new User(session, member.user),
+ };
+ }),
+ ownerUserId: data.owner_user_id,
+ name: data.name,
+ };
+}
+
+/**
+ * @link https://discord.com/developers/docs/resources/application#application-object
+ */
+export class Application implements Model {
+ constructor(session: Session, data: DiscordApplication) {
+ this.id = data.id;
+ this.session = session;
+
+ this.name = data.name;
+ this.icon = data.icon || undefined;
+ this.description = data.description;
+ this.rpcOrigins = data.rpc_origins;
+ this.botPublic = data.bot_public;
+ this.botRequireCodeGrant = data.bot_require_code_grant;
+ this.termsOfServiceURL = data.terms_of_service_url;
+ this.privacyPolicyURL = data.privacy_policy_url;
+ this.owner = data.owner
+ ? new User(session, data.owner as DiscordUser)
+ : undefined;
+ this.summary = '';
+ this.verifyKey = data.verify_key;
+ this.team = data.team ? NewTeam(session, data.team) : undefined;
+ this.guildId = data.guild_id;
+ this.coverImage = data.cover_image;
+ this.tags = data.tags;
+ this.installParams = data.install_params;
+ this.customInstallURL = data.custom_install_url;
+ }
+
+ readonly session: Session;
+ id: Snowflake;
+ name: string;
+ icon?: string;
+ description: string;
+ rpcOrigins?: string[];
+ botPublic: boolean;
+ botRequireCodeGrant: boolean;
+ termsOfServiceURL?: string;
+ privacyPolicyURL?: string;
+ owner?: Partial;
+ summary: SummaryDeprecated;
+ verifyKey: string;
+ team?: Team;
+ guildId?: Snowflake;
+ primarySkuId?: Snowflake;
+ slug?: string;
+ coverImage?: string;
+ flags?: number;
+ tags?: string[];
+ installParams?: DiscordInstallParams;
+ customInstallURL?: string;
+}
diff --git a/packages/core/src/structures/attachment.ts b/packages/core/src/structures/attachment.ts
new file mode 100644
index 0000000..9d4ab1e
--- /dev/null
+++ b/packages/core/src/structures/attachment.ts
@@ -0,0 +1,36 @@
+import type { Model } from './base';
+import type { Snowflake } from '../snowflakes';
+import type { Session } from '../biscuit';
+import type { DiscordAttachment } from '@biscuitland/api-types';
+
+/**
+ * Represents an attachment
+ * @link https://discord.com/developers/docs/resources/channel#attachment-object
+ */
+export class Attachment implements Model {
+ constructor(session: Session, data: DiscordAttachment) {
+ this.session = session;
+ this.id = data.id;
+
+ this.contentType = data.content_type ? data.content_type : undefined;
+ this.attachment = data.url;
+ this.proxyUrl = data.proxy_url;
+ this.name = data.filename;
+ this.size = data.size;
+ this.height = data.height ? data.height : undefined;
+ this.width = data.width ? data.width : undefined;
+ this.ephemeral = !!data.ephemeral;
+ }
+
+ readonly session: Session;
+ readonly id: Snowflake;
+
+ contentType?: string;
+ attachment: string;
+ proxyUrl: string;
+ name: string;
+ size: number;
+ height?: number;
+ width?: number;
+ ephemeral: boolean;
+}
diff --git a/packages/core/src/structures/automod.ts b/packages/core/src/structures/automod.ts
new file mode 100644
index 0000000..e11a3c6
--- /dev/null
+++ b/packages/core/src/structures/automod.ts
@@ -0,0 +1,115 @@
+import type { Model } from './base';
+import type { Session } from '../biscuit';
+import type { Snowflake } from '../snowflakes';
+import type {
+ AutoModerationActionType,
+ AutoModerationEventTypes,
+ AutoModerationTriggerTypes,
+ DiscordAutoModerationRule,
+ DiscordAutoModerationRuleTriggerMetadataPresets,
+ DiscordAutoModerationActionExecution,
+} from '@biscuitland/api-types';
+
+export interface AutoModerationRuleTriggerMetadata {
+ keywordFilter?: string[];
+ presets?: DiscordAutoModerationRuleTriggerMetadataPresets[];
+}
+
+export interface ActionMetadata {
+ channelId: Snowflake;
+ durationSeconds: number;
+}
+
+export interface AutoModerationAction {
+ type: AutoModerationActionType;
+ metadata: ActionMetadata;
+}
+
+export class AutoModerationRule implements Model {
+ constructor(session: Session, data: DiscordAutoModerationRule) {
+ this.session = session;
+ this.id = data.id;
+ this.guildId = data.guild_id;
+ this.name = data.name;
+ this.creatorId = data.creator_id;
+ this.eventType = data.event_type;
+ this.triggerType = data.trigger_type;
+ this.triggerMetadata = {
+ keywordFilter: data.trigger_metadata.keyword_filter,
+ presets: data.trigger_metadata.presets,
+ };
+ this.actions = data.actions.map(action =>
+ Object.create({
+ type: action.type,
+ metadata: {
+ channelId: action.metadata.channel_id,
+ durationSeconds: action.metadata.duration_seconds,
+ },
+ })
+ );
+ this.enabled = !!data.enabled;
+ this.exemptRoles = data.exempt_roles;
+ this.exemptChannels = data.exempt_channels;
+ }
+
+ session: Session;
+ id: Snowflake;
+ guildId: Snowflake;
+ name: string;
+ creatorId: Snowflake;
+ eventType: AutoModerationEventTypes;
+ triggerType: AutoModerationTriggerTypes;
+ triggerMetadata: AutoModerationRuleTriggerMetadata;
+ actions: AutoModerationAction[];
+ enabled: boolean;
+ exemptRoles: Snowflake[];
+ exemptChannels: Snowflake[];
+}
+
+export class AutoModerationExecution {
+ constructor(session: Session, data: DiscordAutoModerationActionExecution) {
+ this.session = session;
+ this.guildId = data.guild_id;
+ this.action = Object.create({
+ type: data.action.type,
+ metadata: {
+ channelId: data.action.metadata.channel_id,
+ durationSeconds: data.action.metadata.duration_seconds,
+ },
+ });
+ this.ruleId = data.rule_id;
+ this.ruleTriggerType = data.rule_trigger_type;
+ this.userId = data.user_id;
+ this.content = data.content;
+ if (data.channel_id) {
+ this.channelId = data.channel_id;
+ }
+ if (data.message_id) {
+ this.messageId = data.message_id;
+ }
+ if (data.alert_system_message_id) {
+ this.alertSystemMessageId = data.alert_system_message_id;
+ }
+
+ if (data.matched_keyword) {
+ this.matchedKeyword = data.matched_keyword;
+ }
+
+ if (data.matched_content) {
+ this.matched_content = data.matched_content;
+ }
+ }
+
+ session: Session;
+ guildId: Snowflake;
+ action: AutoModerationAction;
+ ruleId: Snowflake;
+ ruleTriggerType: AutoModerationTriggerTypes;
+ userId: Snowflake;
+ channelId?: Snowflake;
+ messageId?: Snowflake;
+ alertSystemMessageId?: Snowflake;
+ content?: string;
+ matchedKeyword?: string;
+ matched_content?: string;
+}
diff --git a/packages/core/src/structures/base.ts b/packages/core/src/structures/base.ts
new file mode 100644
index 0000000..c81fbe0
--- /dev/null
+++ b/packages/core/src/structures/base.ts
@@ -0,0 +1,12 @@
+import type { Snowflake } from '../snowflakes';
+import type { Session } from '../biscuit';
+
+/**
+ * Represents a Discord data model
+ */
+export interface Model {
+ /** id of the model */
+ id: Snowflake;
+ /** reference to the client that instantiated the model */
+ session: Session;
+}
diff --git a/packages/core/src/structures/channels.ts b/packages/core/src/structures/channels.ts
new file mode 100644
index 0000000..bbc365e
--- /dev/null
+++ b/packages/core/src/structures/channels.ts
@@ -0,0 +1,897 @@
+/** Types */
+import type { Model } from './base';
+import type { Snowflake } from '../snowflakes';
+import type { Session } from '../biscuit';
+import type { PermissionsOverwrites } from '../utils/util';
+
+/** Functions and others */
+// import { calculateShardId } from '../utils/calculate-shard';
+import { urlToBase64 } from '../utils/url-to-base-64';
+
+/** Classes and routes */
+import type {
+ DiscordChannel,
+ DiscordInvite,
+ DiscordInviteMetadata,
+ DiscordListArchivedThreads,
+ DiscordMessage,
+ DiscordOverwrite,
+ DiscordThreadMember,
+ DiscordWebhook,
+ TargetTypes,
+ VideoQualityModes,
+ GetReactions,
+ GetMessagesOptions,
+ ListArchivedThreads } from '@biscuitland/api-types';
+import {
+ CHANNEL,
+ CHANNEL_PINS,
+ CHANNEL_INVITES,
+ CHANNEL_TYPING,
+ CHANNEL_MESSAGES,
+ CHANNEL_WEBHOOKS,
+ THREAD_USER,
+ THREAD_ME,
+ THREAD_MEMBERS,
+ THREAD_START_PRIVATE,
+ THREAD_ARCHIVED_PUBLIC,
+ THREAD_ARCHIVED_PRIVATE_JOINED,
+ THREAD_START_PUBLIC,
+ ChannelTypes,
+ GatewayOpcodes as _GatewayOpcodes
+} from '@biscuitland/api-types';
+
+import type { CreateMessage, EditMessage, EmojiResolvable } from './message';
+import { Message } from './message';
+import { Invite } from './invite';
+import { Webhook } from './webhook';
+import { User } from './user';
+import { ThreadMember } from './members';
+import { Permissions } from './special/permissions';
+
+/**
+ * Abstract class that represents the base for creating a new channel.
+ */
+export abstract class BaseChannel implements Model {
+ constructor(session: Session, data: DiscordChannel) {
+ this.id = data.id;
+ this.session = session;
+ this.name = data.name;
+ this.type = data.type;
+ }
+
+ /** id's refers to the identification of the channel */
+ readonly id: Snowflake;
+
+ /** The session that instantiated the channel */
+ readonly session: Session;
+
+ /** Channel name defined by the entity */
+ name?: string;
+
+ /** Refers to the possible channel type implemented (Guild, DM, Voice, News, etc...) */
+ type: ChannelTypes;
+
+ /** If the channel is a TextChannel */
+ isText(): this is TextChannel {
+ return textBasedChannels.includes(this.type);
+ }
+
+ /** If the channel is a VoiceChannel */
+ isVoice(): this is VoiceChannel {
+ return this.type === ChannelTypes.GuildVoice;
+ }
+
+ /** If the channel is a DMChannel */
+ isDM(): this is DMChannel {
+ return this.type === ChannelTypes.DM;
+ }
+
+ /** If the channel is a NewChannel */
+ isNews(): this is NewsChannel {
+ return this.type === ChannelTypes.GuildNews;
+ }
+
+ /** If the channel is a ThreadChannel */
+ isThread(): this is ThreadChannel {
+ return this.type === ChannelTypes.GuildPublicThread || this.type === ChannelTypes.GuildPrivateThread;
+ }
+
+ /** If the channel is a StageChannel */
+ isStage(): this is StageChannel {
+ return this.type === ChannelTypes.GuildStageVoice;
+ }
+
+ toString(): string {
+ return `<#${this.id}>`;
+ }
+}
+
+/**
+ * Represents a category channel.
+ */
+export class CategoryChannel extends BaseChannel {
+ constructor(session: Session, data: DiscordChannel) {
+ super(session, data);
+ this.id = data.id;
+ this.name = data.name ? data.name : '';
+ this.nsfw = data.nsfw ? data.nsfw : false;
+ this.guildId = data.guild_id ? data.guild_id : undefined;
+ this.type = ChannelTypes.GuildCategory;
+ this.position = data.position ? data.position : undefined;
+ this.parentId = data.parent_id ? data.parent_id : undefined;
+
+ this.permissionOverwrites = data.permission_overwrites
+ ? ChannelFactory.permissionOverwrites(data.permission_overwrites)
+ : [];
+ }
+
+ id: Snowflake;
+ parentId?: string;
+ name: string;
+ permissionOverwrites: PermissionsOverwrites[];
+ nsfw: boolean;
+ guildId?: Snowflake;
+ position?: number;
+}
+
+/** TextChannel */
+/**
+ * @link https://discord.com/developers/docs/resources/channel#create-channel-invite-json-params
+ * Represents the options object to create an invitation
+ */
+export interface DiscordInviteOptions {
+ /** duration of invite in seconds before expiry, or 0 for never. between 0 and 604800 (7 days) */
+ maxAge?: number;
+ /** max number of uses or 0 for unlimited. between 0 and 100 */
+ maxUses?: number;
+ /** if the invitation is unique. If it's true, don't try to reuse a similar invite (useful for creating many unique one time use invites) */
+ unique?: boolean;
+ /** whether this invite only grants temporary membership */
+ temporary: boolean;
+ reason?: string;
+ /** the type of target for this voice channel invite */
+ targetType?: TargetTypes;
+ /** the id of the user whose stream to display for this invite, required if targetType is 1, the user must be streaming in the channel */
+ targetUserId?: Snowflake;
+ /** the id of the embedded application to open for this invite, required if targetType is 2, the application must have the EMBEDDED flag */
+ targetApplicationId?: Snowflake;
+}
+
+/** Webhook create object */
+export interface CreateWebhook {
+ /** name of the webhook (1-80 characters) */
+ name: string;
+ /** image for the default webhook avatar */
+ avatar?: string;
+ reason?: string;
+}
+
+/** Available text-channel-types list */
+export const textBasedChannels: ChannelTypes[] = [
+ ChannelTypes.DM,
+ ChannelTypes.GroupDm,
+ ChannelTypes.GuildPrivateThread,
+ ChannelTypes.GuildPublicThread,
+ ChannelTypes.GuildNews,
+ ChannelTypes.GuildVoice,
+ ChannelTypes.GuildText,
+];
+
+/** Available text-channel-types */
+export type TextBasedChannels =
+ | ChannelTypes.DM
+ | ChannelTypes.GroupDm
+ | ChannelTypes.GuildPrivateThread
+ | ChannelTypes.GuildPublicThread
+ | ChannelTypes.GuildNews
+ | ChannelTypes.GuildVoice
+ | ChannelTypes.GuildText;
+
+/**
+ * Represents a text channel.
+ */
+export class TextChannel {
+ constructor(session: Session, data: DiscordChannel) {
+ this.session = session;
+ this.id = data.id;
+ this.name = data.name;
+ this.type = data.type as number;
+ this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
+ this.nsfw = !!data.nsfw ?? false;
+
+ if (data.last_message_id) {
+ this.lastMessageId = data.last_message_id;
+ }
+
+ if (data.last_pin_timestamp) {
+ this.lastPinTimestamp = data.last_pin_timestamp;
+ }
+ }
+
+ /** The session that instantiated the channel */
+ readonly session: Session;
+
+ /** id's refers to the identification of the channel */
+ readonly id: Snowflake;
+
+ /** Current channel name */
+ name?: string;
+
+ /** The type of the channel */
+ type: TextBasedChannels;
+
+ /** The id of the last message sent in this channel (or thread for GUILD_FORUM channels) (may not point to an existing or valid message or thread) */
+ lastMessageId?: Snowflake;
+
+ /** When the last pinned message was pinned. This may be undefined in events such as GUILD_CREATE when a message is not pinned. */
+ lastPinTimestamp?: string;
+
+ /** Amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission manage_messages or manage_channel, are unaffected */
+ rateLimitPerUser: number;
+
+ /** If the channel is NSFW (Not-Safe-For-Work content) */
+ nsfw: boolean;
+
+ /**
+ * Mixin
+ */
+ // deno-lint-ignore ban-types
+ static applyTo(klass: Function, ignore: (keyof TextChannel)[] = []): void {
+ const methods: (keyof TextChannel)[] = [
+ 'fetchPins',
+ 'createInvite',
+ 'fetchMessages',
+ 'sendTyping',
+ 'pinMessage',
+ 'unpinMessage',
+ 'addReaction',
+ 'removeReaction',
+ 'nukeReactions',
+ 'fetchPins',
+ 'sendMessage',
+ 'editMessage',
+ 'createWebhook',
+ ];
+
+ for (const method of methods) {
+ if (ignore.includes(method)) { continue; }
+
+ klass.prototype[method] = TextChannel.prototype[method];
+ }
+ }
+
+ /**
+ * fetchPins makes an asynchronous request and gets the current channel pins.
+ * @returns A promise that resolves with an array of Message objects.
+ */
+ async fetchPins(): Promise {
+ const messages = await this.session.rest.get(
+ CHANNEL_PINS(this.id),
+ );
+
+ return messages[0] ? messages.map((x: DiscordMessage) => new Message(this.session, x)) : [];
+ }
+
+ /**
+ * createInvite makes an asynchronous request to create a new invitation.
+ * @param options - The options to create the invitation
+ * @returns The created invite
+ */
+ async createInvite(options?: DiscordInviteOptions): Promise {
+ const invite = await this.session.rest.post(
+ CHANNEL_INVITES(this.id),
+ options
+ ? {
+ max_age: options.maxAge,
+ max_uses: options.maxUses,
+ temporary: options.temporary,
+ unique: options.unique,
+ target_type: options.targetType,
+ target_user_id: options.targetUserId,
+ target_application_id: options.targetApplicationId,
+ }
+ : {},
+ );
+
+ return new Invite(this.session, invite);
+ }
+
+ /**
+ * fetchMessages makes an asynchronous request and gets the channel messages
+ * @param options - The options to get the messages
+ * @returns The messages
+ */
+ async fetchMessages(options?: GetMessagesOptions): Promise {
+ if (options?.limit! > 100) { throw Error('Values must be between 0-100'); }
+ const messages = await this.session.rest.get(
+ CHANNEL_MESSAGES(this.id, options),
+ );
+
+ return messages[0] ? messages.map(x => new Message(this.session, x)) : [];
+ }
+
+ /** sendTyping sends a typing POST request */
+ async sendTyping(): Promise {
+ await this.session.rest.post(CHANNEL_TYPING(this.id), {});
+ }
+
+ /**
+ * pinMessage pins a channel message.
+ * Same as Message.pin().
+ * @param messageId - The id of the message to pin
+ * @returns The promise that resolves when the request is complete
+ */
+ async pinMessage(messageId: Snowflake): Promise {
+ await Message.prototype.pin.call({ id: messageId, channelId: this.id, session: this.session });
+ }
+
+ /**
+ * unpinMessage unpin a channel message.
+ * Same as Message.unpin()
+ * @param messageId - The id of the message to unpin
+ * @returns The promise of the request
+ */
+ async unpinMessage(messageId: Snowflake): Promise {
+ await Message.prototype.unpin.call({ id: messageId, channelId: this.id, session: this.session });
+ }
+
+ /**
+ * addReaction adds a reaction to the message.
+ * Same as Message.addReaction().
+ * @param messageId - The message to add the reaction to
+ * @param reaction - The reaction to add
+ * @returns The promise of the request
+ */
+ async addReaction(messageId: Snowflake, reaction: EmojiResolvable): Promise {
+ await Message.prototype.addReaction.call(
+ { channelId: this.id, id: messageId, session: this.session },
+ reaction,
+ );
+ }
+
+ /**
+ * removeReaction removes a reaction from the message.
+ * Same as Message.removeReaction().
+ * @param messageId - The id of the message to remove the reaction from
+ * @param reaction - The reaction to remove
+ * @param options - The user to remove the reaction from
+ */
+ async removeReaction(
+ messageId: Snowflake,
+ reaction: EmojiResolvable,
+ options?: { userId: Snowflake },
+ ): Promise {
+ await Message.prototype.removeReaction.call(
+ { channelId: this.id, id: messageId, session: this.session },
+ reaction,
+ options,
+ );
+ }
+
+ /**
+ * removeReactionEmoji removes an emoji reaction from the messageId provided.
+ * Same as Message.removeReactionEmoji().
+ * @param messageId - The message id to remove the reaction from.
+ */
+ async removeReactionEmoji(messageId: Snowflake, reaction: EmojiResolvable): Promise {
+ await Message.prototype.removeReactionEmoji.call(
+ { channelId: this.id, id: messageId, session: this.session },
+ reaction,
+ );
+ }
+
+ /** nukeReactions nukes every reaction on the message.
+ * Same as Message.nukeReactions().
+ * @param messageId The message id to nuke reactions from.
+ * @returns A promise that resolves when the reactions are nuked.
+ */
+ async nukeReactions(messageId: Snowflake): Promise {
+ await Message.prototype.nukeReactions.call({ channelId: this.id, id: messageId });
+ }
+
+ /**
+ * fetchReactions gets the users who reacted with this emoji on the message.
+ * Same as Message.fetchReactions().
+ * @param messageId - The message id to get the reactions from.
+ * @param reaction - The emoji to get the reactions from.
+ * @param options - The options to get the reactions with.
+ * @returns The users who reacted with this emoji on the message.
+ */
+ async fetchReactions(
+ messageId: Snowflake,
+ reaction: EmojiResolvable,
+ options?: GetReactions,
+ ): Promise {
+ const users = await Message.prototype.fetchReactions.call(
+ { channelId: this.id, id: messageId, session: this.session },
+ reaction,
+ options,
+ );
+
+ return users;
+ }
+
+ /**
+ * sendMessage sends a message to the channel.
+ * Same as Message.reply().
+ * @param options - Options for a new message.
+ * @returns The sent message.
+ */
+ sendMessage(options: CreateMessage): Promise {
+ return Message.prototype.reply.call({ channelId: this.id, session: this.session }, options);
+ }
+
+ /**
+ * editMessage edits a message.
+ * Same as Message.edit().
+ * @param messageId - Message ID.
+ * @param options - Options for edit a message.
+ * @returns The edited message.
+ */
+ editMessage(messageId: Snowflake, options: EditMessage): Promise {
+ return Message.prototype.edit.call({ channelId: this.id, id: messageId, session: this.session }, options);
+ }
+
+ /**
+ * createWebhook creates a webhook.
+ * @param options - Options for a new webhook.
+ * @returns The created webhook.
+ */
+ async createWebhook(options: CreateWebhook): Promise {
+ const webhook = await this.session.rest.post(
+ CHANNEL_WEBHOOKS(this.id),
+ {
+ name: options.name,
+ avatar: options.avatar ? urlToBase64(options.avatar) : undefined,
+ reason: options.reason,
+ },
+ );
+
+ return new Webhook(this.session, webhook);
+ }
+}
+
+/** GuildChannel */
+/**
+ * Represent the options object to create a thread channel
+ * @link https://discord.com/developers/docs/resources/channel#start-thread-without-message
+ */
+export interface ThreadCreateOptions {
+ name: string;
+ autoArchiveDuration?: 60 | 1440 | 4320 | 10080;
+ type: 10 | 11 | 12;
+ invitable?: boolean;
+ rateLimitPerUser?: number;
+ reason?: string;
+}
+
+/**
+ * Representations of the objects to edit a guild channel
+ * @link https://discord.com/developers/docs/resources/channel#modify-channel-json-params-guild-channel
+ */
+export interface EditGuildChannelOptions {
+ name?: string;
+ position?: number;
+ permissionOverwrites?: PermissionsOverwrites[];
+}
+
+export interface EditNewsChannelOptions extends EditGuildChannelOptions {
+ type?: ChannelTypes.GuildNews | ChannelTypes.GuildText;
+ topic?: string | null;
+ nfsw?: boolean | null;
+ parentId?: Snowflake | null;
+ defaultAutoArchiveDuration?: number | null;
+}
+
+export interface EditGuildTextChannelOptions extends EditNewsChannelOptions {
+ rateLimitPerUser?: number | null;
+}
+
+export interface EditStageChannelOptions extends EditGuildChannelOptions {
+ bitrate?: number | null;
+ rtcRegion?: Snowflake | null;
+}
+
+export interface EditVoiceChannelOptions extends EditStageChannelOptions {
+ nsfw?: boolean | null;
+ userLimit?: number | null;
+ parentId?: Snowflake | null;
+ videoQualityMode?: VideoQualityModes | null;
+}
+
+/**
+ * Represents the option object to create a thread channel from a message
+ * @link https://discord.com/developers/docs/resources/channel#start-thread-from-message
+ */
+export interface ThreadCreateOptions {
+ name: string;
+ autoArchiveDuration?: 60 | 1440 | 4320 | 10080;
+ rateLimitPerUser?: number;
+ messageId: Snowflake;
+}
+/**
+ * @link https://discord.com/developers/docs/resources/channel#list-public-archived-threads-response-body
+ */
+export interface ReturnThreadsArchive {
+ threads: Record;
+ members: Record;
+ hasMore: boolean;
+}
+
+export class GuildChannel extends BaseChannel implements Model {
+ constructor(session: Session, data: DiscordChannel, guildId: Snowflake) {
+ super(session, data);
+ this.type = data.type as number;
+ this.guildId = guildId;
+ this.position = data.position;
+ data.topic ? this.topic = data.topic : null;
+ data.parent_id ? this.parentId = data.parent_id : undefined;
+ this.permissionOverwrites = data.permission_overwrites
+ ? ChannelFactory.permissionOverwrites(data.permission_overwrites)
+ : [];
+ }
+
+ override type: Exclude;
+ guildId: Snowflake;
+ topic?: string;
+ position?: number;
+ parentId?: Snowflake;
+ permissionOverwrites: PermissionsOverwrites[];
+
+ async fetchInvites(): Promise {
+ const invites = await this.session.rest.get(CHANNEL_INVITES(this.id));
+
+ return invites.map(invite => new Invite(this.session, invite));
+ }
+
+ async edit(options: EditNewsChannelOptions): Promise;
+ async edit(options: EditStageChannelOptions): Promise;
+ async edit(options: EditVoiceChannelOptions): Promise;
+ async edit(
+ options: EditGuildTextChannelOptions | EditNewsChannelOptions | EditVoiceChannelOptions,
+ ): Promise {
+ const channel = await this.session.rest.patch(
+ CHANNEL(this.id),
+ {
+ name: options.name,
+ type: 'type' in options ? options.type : undefined,
+ position: options.position,
+ topic: 'topic' in options ? options.topic : undefined,
+ nsfw: 'nfsw' in options ? options.nfsw : undefined,
+ rate_limit_per_user: 'rateLimitPerUser' in options ? options.rateLimitPerUser : undefined,
+ bitrate: 'bitrate' in options ? options.bitrate : undefined,
+ user_limit: 'userLimit' in options ? options.userLimit : undefined,
+ permissions_overwrites: options.permissionOverwrites,
+ parent_id: 'parentId' in options ? options.parentId : undefined,
+ rtc_region: 'rtcRegion' in options ? options.rtcRegion : undefined,
+ video_quality_mode: 'videoQualityMode' in options ? options.videoQualityMode : undefined,
+ default_auto_archive_duration: 'defaultAutoArchiveDuration' in options
+ ? options.defaultAutoArchiveDuration
+ : undefined,
+ },
+ );
+ return ChannelFactory.from(this.session, channel);
+ }
+
+ async getArchivedThreads(
+ options: ListArchivedThreads & { type: 'public' | 'private' | 'privateJoinedThreads' },
+ ): Promise {
+ let func: (channelId: Snowflake, options: ListArchivedThreads) => string;
+
+ switch (options.type) {
+ case 'public':
+ func = THREAD_ARCHIVED_PUBLIC;
+ break;
+ case 'private':
+ func = THREAD_START_PRIVATE;
+ break;
+ case 'privateJoinedThreads':
+ func = THREAD_ARCHIVED_PRIVATE_JOINED;
+ break;
+ }
+
+ const { threads, members, has_more } = await this.session.rest.get(
+ func(this.id, options),
+ );
+
+ return {
+ threads: Object.fromEntries(
+ threads.map(thread => [thread.id, new ThreadChannel(this.session, thread, this.id)]),
+ ) as Record,
+ members: Object.fromEntries(
+ members.map(threadMember => [threadMember.id, new ThreadMember(this.session, threadMember)]),
+ ) as Record,
+ hasMore: has_more,
+ };
+ }
+
+ async createThread(options: ThreadCreateOptions): Promise {
+ const thread = await this.session.rest.post(
+ 'messageId' in options
+ ? THREAD_START_PUBLIC(this.id, options.messageId)
+ : THREAD_START_PRIVATE(this.id),
+ {
+ name: options.name,
+ auto_archive_duration: options.autoArchiveDuration,
+ },
+ );
+
+ return new ThreadChannel(this.session, thread, thread.guild_id ?? this.guildId);
+ }
+}
+
+/** BaseVoiceChannel */
+/**
+ * @link https://discord.com/developers/docs/topics/gateway#update-voice-state
+ */
+export interface UpdateVoiceState {
+ guildId: string;
+ channelId?: string;
+ selfMute: boolean;
+ selfDeaf: boolean;
+}
+
+export abstract class BaseVoiceChannel extends GuildChannel {
+ constructor(session: Session, data: DiscordChannel, guildId: Snowflake) {
+ super(session, data, guildId);
+ this.bitRate = data.bitrate;
+ this.userLimit = data.user_limit ?? 0;
+ this.videoQuality = data.video_quality_mode;
+ this.nsfw = !!data.nsfw;
+ this.type = data.type as number;
+
+ if (data.rtc_region) {
+ this.rtcRegion = data.rtc_region;
+ }
+ }
+
+ override type: ChannelTypes.GuildVoice | ChannelTypes.GuildStageVoice;
+ bitRate?: number;
+ userLimit: number;
+ rtcRegion?: Snowflake;
+
+ videoQuality?: VideoQualityModes;
+ nsfw: boolean;
+
+ // TODO: CONNECT TO VOICE CHAT
+}
+
+/** DMChannel */
+export class DMChannel extends BaseChannel implements Model {
+ constructor(session: Session, data: DiscordChannel) {
+ super(session, data);
+ this.user = new User(this.session, data.recipents!.find(r => r.id !== this.session.botId)!);
+ this.type = data.type as ChannelTypes.DM | ChannelTypes.GroupDm;
+ if (data.last_message_id) {
+ this.lastMessageId = data.last_message_id;
+ }
+ }
+
+ override type: ChannelTypes.DM | ChannelTypes.GroupDm;
+ user: User;
+ lastMessageId?: Snowflake;
+
+ async close(): Promise {
+ const channel = await this.session.rest.delete(CHANNEL(this.id), {});
+
+ return new DMChannel(this.session, channel);
+ }
+}
+
+export interface DMChannel extends Omit, Omit {}
+
+TextChannel.applyTo(DMChannel);
+
+/** VoiceChannel */
+export class VoiceChannel extends BaseVoiceChannel {
+ constructor(session: Session, data: DiscordChannel, guildId: Snowflake) {
+ super(session, data, guildId);
+ this.type = data.type as number;
+ }
+
+ override type: ChannelTypes.GuildVoice;
+}
+
+export interface VoiceChannel extends TextChannel, BaseVoiceChannel {}
+
+TextChannel.applyTo(VoiceChannel);
+
+/** NewsChannel */
+export class NewsChannel extends GuildChannel {
+ constructor(session: Session, data: DiscordChannel, guildId: Snowflake) {
+ super(session, data, guildId);
+ this.type = data.type as ChannelTypes.GuildNews;
+ this.defaultAutoArchiveDuration = data.default_auto_archive_duration;
+ }
+
+ override type: ChannelTypes.GuildNews;
+ defaultAutoArchiveDuration?: number;
+
+ crosspostMessage(messageId: Snowflake): Promise {
+ return Message.prototype.crosspost.call({ id: messageId, channelId: this.id, session: this.session });
+ }
+
+ get publishMessage() {
+ return this.crosspostMessage;
+ }
+}
+
+TextChannel.applyTo(NewsChannel);
+
+export interface NewsChannel extends TextChannel, GuildChannel {}
+
+/** StageChannel */
+export class StageChannel extends BaseVoiceChannel {
+ constructor(session: Session, data: DiscordChannel, guildId: Snowflake) {
+ super(session, data, guildId);
+ this.type = data.type as number;
+ this.topic = data.topic ? data.topic : undefined;
+ }
+
+ override type: ChannelTypes.GuildStageVoice;
+ topic?: string;
+}
+
+/** ThreadChannel */
+export class ThreadChannel extends GuildChannel implements Model {
+ constructor(session: Session, data: DiscordChannel, guildId: Snowflake) {
+ super(session, data, guildId);
+ this.type = data.type as number;
+ this.archived = !!data.thread_metadata?.archived;
+ this.archiveTimestamp = data.thread_metadata?.archive_timestamp;
+ this.autoArchiveDuration = data.thread_metadata?.auto_archive_duration;
+ this.locked = !!data.thread_metadata?.locked;
+ this.messageCount = data.message_count;
+ this.memberCount = data.member_count;
+ this.ownerId = data.owner_id;
+
+ if (data.member) {
+ this.member = new ThreadMember(session, data.member);
+ }
+ }
+
+ override type: ChannelTypes.GuildNewsThread | ChannelTypes.GuildPrivateThread | ChannelTypes.GuildPublicThread;
+ archived?: boolean;
+ archiveTimestamp?: string;
+ autoArchiveDuration?: number;
+ locked?: boolean;
+ messageCount?: number;
+ memberCount?: number;
+ member?: ThreadMember;
+ ownerId?: Snowflake;
+
+ async joinThread(): Promise {
+ await this.session.rest.put(THREAD_ME(this.id), {});
+ }
+
+ async addToThread(guildMemberId: Snowflake): Promise {
+ await this.session.rest.put(THREAD_USER(this.id, guildMemberId), {});
+ }
+
+ async leaveToThread(guildMemberId: Snowflake): Promise {
+ await this.session.rest.delete(THREAD_USER(this.id, guildMemberId), {});
+ }
+
+ removeMember(memberId: Snowflake = this.session.botId): Promise {
+ return ThreadMember.prototype.quitThread.call({ id: this.id, session: this.session }, memberId);
+ }
+
+ fetchMember(memberId: Snowflake = this.session.botId): Promise {
+ return ThreadMember.prototype.fetchMember.call({ id: this.id, session: this.session }, memberId);
+ }
+
+ async fetchMembers(): Promise {
+ const members = await this.session.rest.get(
+ THREAD_MEMBERS(this.id),
+ );
+
+ return members.map(threadMember => new ThreadMember(this.session, threadMember));
+ }
+}
+
+export interface ThreadChannel extends Omit, Omit {}
+
+TextChannel.applyTo(ThreadChannel);
+
+export class GuildTextChannel extends GuildChannel {
+ constructor(session: Session, data: DiscordChannel, guildId: Snowflake) {
+ super(session, data, guildId);
+ this.type = data.type as ChannelTypes.GuildText;
+ }
+
+ override type: ChannelTypes.GuildText;
+}
+
+export interface GuildTextChannel extends GuildChannel, TextChannel {}
+
+TextChannel.applyTo(GuildTextChannel);
+
+/** ChannelFactory */
+export type Channel =
+ | GuildTextChannel
+ | TextChannel
+ | VoiceChannel
+ | DMChannel
+ | NewsChannel
+ | ThreadChannel
+ | StageChannel
+ | CategoryChannel;
+
+export type ChannelInGuild =
+ | GuildTextChannel
+ | VoiceChannel
+ | StageChannel
+ | NewsChannel
+ | ThreadChannel;
+
+export type ChannelWithMessages =
+ | GuildTextChannel
+ | VoiceChannel
+ | DMChannel
+ | NewsChannel
+ | ThreadChannel;
+
+export type ChannelWithMessagesInGuild = Exclude;
+
+export type PartialChannel = {
+ id: string;
+ name: string;
+ position: number;
+};
+
+export class ChannelFactory {
+ static fromGuildChannel(session: Session, channel: DiscordChannel): ChannelInGuild {
+ switch (channel.type) {
+ case ChannelTypes.GuildPublicThread:
+ case ChannelTypes.GuildPrivateThread:
+ return new ThreadChannel(session, channel, channel.guild_id!);
+ case ChannelTypes.GuildText:
+ return new GuildTextChannel(session, channel, channel.guild_id!);
+ case ChannelTypes.GuildNews:
+ return new NewsChannel(session, channel, channel.guild_id!);
+ case ChannelTypes.GuildVoice:
+ return new VoiceChannel(session, channel, channel.guild_id!);
+ case ChannelTypes.GuildStageVoice:
+ return new StageChannel(session, channel, channel.guild_id!);
+ default:
+ throw new Error('Channel was not implemented');
+ }
+ }
+
+ static from(session: Session, channel: DiscordChannel): Channel {
+ switch (channel.type) {
+ case ChannelTypes.GuildPublicThread:
+ case ChannelTypes.GuildPrivateThread:
+ return new ThreadChannel(session, channel, channel.guild_id!);
+ case ChannelTypes.GuildText:
+ return new GuildTextChannel(session, channel, channel.guild_id!);
+ case ChannelTypes.GuildNews:
+ return new NewsChannel(session, channel, channel.guild_id!);
+ case ChannelTypes.DM:
+ return new DMChannel(session, channel);
+ case ChannelTypes.GuildVoice:
+ return new VoiceChannel(session, channel, channel.guild_id!);
+ case ChannelTypes.GuildStageVoice:
+ return new StageChannel(session, channel, channel.guild_id!);
+ case ChannelTypes.GuildCategory:
+ return new CategoryChannel(session, channel);
+ default:
+ if (textBasedChannels.includes(channel.type)) {
+ return new TextChannel(session, channel);
+ }
+ throw new Error('Channel was not implemented');
+ }
+ }
+
+ static permissionOverwrites(overwrites: DiscordOverwrite[]): PermissionsOverwrites[] {
+ return overwrites.map(v => {
+ return {
+ id: v.id,
+ type: v.type,
+ allow: new Permissions(parseInt(v.allow!)),
+ deny: new Permissions(parseInt(v.deny!)),
+ };
+ });
+ }
+}
diff --git a/packages/core/src/structures/components.ts b/packages/core/src/structures/components.ts
new file mode 100644
index 0000000..7da242c
--- /dev/null
+++ b/packages/core/src/structures/components.ts
@@ -0,0 +1,268 @@
+import type { Session } from '../biscuit';
+import type {
+ DiscordComponent,
+ DiscordInputTextComponent,
+ TextStyles,
+} from '@biscuitland/api-types';
+import { Emoji } from './emojis';
+import { ButtonStyles, MessageComponentTypes } from '@biscuitland/api-types';
+
+export class BaseComponent {
+ constructor(type: MessageComponentTypes) {
+ this.type = type;
+ }
+
+ type: MessageComponentTypes;
+
+ isActionRow(): this is ActionRowComponent {
+ return this.type === MessageComponentTypes.ActionRow;
+ }
+
+ isButton(): this is ButtonComponent {
+ return this.type === MessageComponentTypes.Button;
+ }
+
+ isSelectMenu(): this is SelectMenuComponent {
+ return this.type === MessageComponentTypes.SelectMenu;
+ }
+
+ isTextInput(): this is TextInputComponent {
+ return this.type === MessageComponentTypes.InputText;
+ }
+}
+
+/** Action Row Component */
+export interface ActionRowComponent {
+ type: MessageComponentTypes.ActionRow;
+ components: Exclude[];
+}
+
+/** All Components */
+export type Component =
+ | ActionRowComponent
+ | ButtonComponent
+ | LinkButtonComponent
+ | SelectMenuComponent
+ | TextInputComponent;
+
+/** Button Component */
+export type ClassicButton = Exclude;
+
+export type ComponentsWithoutRow = Exclude;
+
+export interface ButtonComponent {
+ type: MessageComponentTypes.Button;
+ style: ClassicButton;
+ label?: string;
+ emoji?: Emoji;
+ customId?: string;
+ disabled?: boolean;
+}
+
+/** Link Button Component */
+export interface LinkButtonComponent {
+ type: MessageComponentTypes.Button;
+ style: ButtonStyles.Link;
+ label?: string;
+ url: string;
+ disabled?: boolean;
+}
+
+/** Select Menu Component */
+export interface SelectMenuComponent {
+ type: MessageComponentTypes.SelectMenu;
+ customId: string;
+ options: SelectMenuOption[];
+ placeholder?: string;
+ minValue?: number;
+ maxValue?: number;
+ disabled?: boolean;
+}
+
+/** Text Input Component */
+export interface TextInputComponent {
+ type: MessageComponentTypes.InputText;
+ customId: string;
+ style: TextStyles;
+ label: string;
+ minLength?: number;
+ maxLength?: number;
+ required?: boolean;
+ value?: string;
+ placeholder?: string;
+}
+
+export interface SelectMenuOption {
+ label: string;
+ value: string;
+ description?: string;
+ emoji?: Emoji;
+ default?: boolean;
+}
+
+export class Button extends BaseComponent implements ButtonComponent {
+ constructor(session: Session, data: DiscordComponent) {
+ super(data.type);
+
+ this.session = session;
+ this.type = data.type as MessageComponentTypes.Button;
+ this.customId = data.custom_id;
+ this.label = data.label;
+ this.style = data.style as ClassicButton;
+ this.disabled = data.disabled;
+
+ if (data.emoji) {
+ this.emoji = new Emoji(session, data.emoji);
+ }
+ }
+
+ readonly session: Session;
+ override type: MessageComponentTypes.Button;
+ customId?: string;
+ label?: string;
+ style: ClassicButton;
+ disabled?: boolean;
+ emoji?: Emoji;
+}
+
+export class LinkButton extends BaseComponent implements LinkButtonComponent {
+ constructor(session: Session, data: DiscordComponent) {
+ super(data.type);
+
+ this.session = session;
+ this.type = data.type as MessageComponentTypes.Button;
+ this.url = data.url!;
+ this.label = data.label;
+ this.style = data.style as number;
+ this.disabled = data.disabled;
+
+ if (data.emoji) {
+ this.emoji = new Emoji(session, data.emoji);
+ }
+ }
+
+ readonly session: Session;
+ override type: MessageComponentTypes.Button;
+ url: string;
+ label?: string;
+ style: ButtonStyles.Link;
+ disabled?: boolean;
+ emoji?: Emoji;
+}
+
+export class SelectMenu extends BaseComponent implements SelectMenuComponent {
+ constructor(session: Session, data: DiscordComponent) {
+ super(data.type);
+
+ this.session = session;
+ this.type = data.type as MessageComponentTypes.SelectMenu;
+ this.customId = data.custom_id!;
+ this.options = data.options!.map(option => {
+ return {
+ label: option.label,
+ description: option.description,
+ emoji: option.emoji || new Emoji(session, option.emoji!),
+ value: option.value,
+ };
+ });
+ this.placeholder = data.placeholder;
+ this.minValues = data.min_values;
+ this.maxValues = data.max_values;
+ this.disabled = data.disabled;
+ }
+
+ readonly session: Session;
+ override type: MessageComponentTypes.SelectMenu;
+ customId: string;
+ options: SelectMenuOption[];
+ placeholder?: string;
+ minValues?: number;
+ maxValues?: number;
+ disabled?: boolean;
+}
+
+export class TextInput extends BaseComponent implements TextInputComponent {
+ constructor(session: Session, data: DiscordInputTextComponent) {
+ super(data.type);
+
+ this.session = session;
+ this.type = data.type as MessageComponentTypes.InputText;
+ this.customId = data.custom_id!;
+ this.label = data.label!;
+ this.style = data.style as TextStyles;
+
+ this.placeholder = data.placeholder;
+ this.value = data.value;
+
+ this.minLength = data.min_length;
+ this.maxLength = data.max_length;
+ }
+
+ readonly session: Session;
+ override type: MessageComponentTypes.InputText;
+ style: TextStyles;
+ customId: string;
+ label: string;
+ placeholder?: string;
+ value?: string;
+ minLength?: number;
+ maxLength?: number;
+}
+
+export class ActionRow extends BaseComponent implements ActionRowComponent {
+ constructor(session: Session, data: DiscordComponent) {
+ super(data.type);
+
+ this.session = session;
+ this.type = data.type as MessageComponentTypes.ActionRow;
+ this.components = data.components!.map(component => {
+ switch (component.type) {
+ case MessageComponentTypes.Button:
+ if (component.style === ButtonStyles.Link) {
+ return new LinkButton(session, component);
+ }
+ return new Button(session, component);
+ case MessageComponentTypes.SelectMenu:
+ return new SelectMenu(session, component);
+ case MessageComponentTypes.InputText:
+ return new TextInput(
+ session,
+ component as DiscordInputTextComponent
+ );
+ case MessageComponentTypes.ActionRow:
+ throw new Error(
+ 'Cannot have an action row inside an action row'
+ );
+ }
+ });
+ }
+
+ readonly session: Session;
+ override type: MessageComponentTypes.ActionRow;
+ components: ComponentsWithoutRow[];
+}
+
+export class ComponentFactory {
+ /**
+ * Component factory
+ * @internal
+ */
+ static from(session: Session, component: DiscordComponent): Component {
+ switch (component.type) {
+ case MessageComponentTypes.ActionRow:
+ return new ActionRow(session, component);
+ case MessageComponentTypes.Button:
+ if (component.style === ButtonStyles.Link) {
+ return new LinkButton(session, component);
+ }
+ return new Button(session, component);
+ case MessageComponentTypes.SelectMenu:
+ return new SelectMenu(session, component);
+ case MessageComponentTypes.InputText:
+ return new TextInput(
+ session,
+ component as DiscordInputTextComponent
+ );
+ }
+ }
+}
diff --git a/packages/core/src/structures/embed.ts b/packages/core/src/structures/embed.ts
new file mode 100644
index 0000000..7d2d495
--- /dev/null
+++ b/packages/core/src/structures/embed.ts
@@ -0,0 +1,100 @@
+import type { DiscordEmbed, EmbedTypes } from '@biscuitland/api-types';
+
+export interface Embed {
+ title?: string;
+ timestamp?: string;
+ type?: EmbedTypes;
+ url?: string;
+ color?: number;
+ description?: string;
+ author?: {
+ name: string;
+ iconURL?: string;
+ proxyIconURL?: string;
+ url?: string;
+ };
+ footer?: {
+ text: string;
+ iconURL?: string;
+ proxyIconURL?: string;
+ };
+ fields?: {
+ name: string;
+ value: string;
+ inline?: boolean;
+ }[];
+ thumbnail?: {
+ url: string;
+ proxyURL?: string;
+ width?: number;
+ height?: number;
+ };
+ video?: {
+ url?: string;
+ proxyURL?: string;
+ width?: number;
+ height?: number;
+ };
+ image?: {
+ url: string;
+ proxyURL?: string;
+ width?: number;
+ height?: number;
+ };
+ provider?: {
+ url?: string;
+ name?: string;
+ };
+}
+
+export function embed(data: Embed): DiscordEmbed {
+ return {
+ title: data.title,
+ timestamp: data.timestamp,
+ type: data.type,
+ url: data.url,
+ color: data.color,
+ description: data.description,
+ author: data.author && {
+ name: data.author.name,
+ url: data.author.url,
+ icon_url: data.author.iconURL,
+ proxy_icon_url: data.author.proxyIconURL,
+ },
+ footer: data.footer && {
+ text: data.footer.text,
+ icon_url: data.footer.iconURL,
+ proxy_icon_url: data.footer.proxyIconURL,
+ },
+ fields: data.fields?.map(f => {
+ return {
+ name: f.name,
+ value: f.value,
+ inline: f.inline,
+ };
+ }),
+ thumbnail: data.thumbnail && {
+ url: data.thumbnail.url,
+ proxy_url: data.thumbnail.proxyURL,
+ width: data.thumbnail.width,
+ height: data.thumbnail.height,
+ },
+ video: {
+ url: data.video?.url,
+ proxy_url: data.video?.proxyURL,
+ width: data.video?.width,
+ height: data.video?.height,
+ },
+ image: data.image && {
+ url: data.image.url,
+ proxy_url: data.image.proxyURL,
+ width: data.image.width,
+ height: data.image.height,
+ },
+ provider: {
+ url: data.provider?.url,
+ name: data.provider?.name,
+ },
+ };
+}
+
diff --git a/packages/core/src/structures/emojis.ts b/packages/core/src/structures/emojis.ts
new file mode 100644
index 0000000..41d4b77
--- /dev/null
+++ b/packages/core/src/structures/emojis.ts
@@ -0,0 +1,70 @@
+import type { Session } from '../biscuit';
+import type { Model } from './base';
+import type { Snowflake } from '../snowflakes';
+import type { DiscordEmoji } from '@biscuitland/api-types';
+import type { ModifyGuildEmoji } from './guilds';
+import { Guild } from './guilds';
+import { User } from './user';
+import { EMOJI_URL } from '@biscuitland/api-types';
+
+export class Emoji implements Partial {
+ constructor(session: Session, data: DiscordEmoji) {
+ this.id = data.id;
+ this.name = data.name;
+ this.animated = !!data.animated;
+ this.available = !!data.available;
+ this.requireColons = !!data.require_colons;
+ this.session = session;
+ }
+
+ readonly id?: Snowflake;
+ readonly session: Session;
+
+ name?: string;
+ animated: boolean;
+ available: boolean;
+ requireColons: boolean;
+}
+
+export class GuildEmoji extends Emoji implements Model {
+ constructor(session: Session, data: DiscordEmoji, guildId: Snowflake) {
+ super(session, data);
+ this.guildId = guildId;
+ this.roles = data.roles;
+ this.user = data.user ? new User(this.session, data.user) : undefined;
+ this.managed = !!data.managed;
+ this.id = super.id!;
+ }
+
+ guildId: Snowflake;
+ roles?: Snowflake[];
+ user?: User;
+ managed?: boolean;
+
+ // id cannot be null in a GuildEmoji
+ override id: Snowflake;
+
+ async edit(options: ModifyGuildEmoji): Promise {
+ const emoji = await Guild.prototype.editEmoji.call(
+ { id: this.guildId, session: this.session },
+ this.id,
+ options
+ );
+
+ return emoji;
+ }
+
+ async delete(reason?: string): Promise {
+ await Guild.prototype.deleteEmoji.call(
+ { id: this.guildId, session: this.session },
+ this.id,
+ reason
+ );
+
+ return this;
+ }
+
+ get url(): string {
+ return EMOJI_URL(this.id, this.animated);
+ }
+}
diff --git a/packages/core/src/structures/guilds.ts b/packages/core/src/structures/guilds.ts
new file mode 100644
index 0000000..b10208d
--- /dev/null
+++ b/packages/core/src/structures/guilds.ts
@@ -0,0 +1,1204 @@
+import type { Model } from './base';
+import type { Session } from '../biscuit';
+import {
+ ChannelTypes,
+ DefaultMessageNotificationLevels,
+ DiscordBan,
+ DiscordEmoji,
+ DiscordGuild,
+ DiscordGuildPreview,
+ DiscordGuildWidget,
+ DiscordGuildWidgetSettings,
+ DiscordInvite,
+ DiscordInviteMetadata,
+ DiscordListActiveThreads,
+ DiscordMemberWithUser,
+ DiscordOverwrite,
+ DiscordRole,
+ DiscordVoiceRegion,
+ ExplicitContentFilterLevels,
+ GuildNsfwLevel,
+ MakeRequired,
+ SystemChannelFlags,
+ VerificationLevels,
+ VideoQualityModes,
+ GetBans,
+ GetInvite,
+} from '@biscuitland/api-types';
+import type { ImageFormat, ImageSize } from '../utils/util';
+import { GuildFeatures, PremiumTiers } from '@biscuitland/api-types';
+import { Snowflake } from '../snowflakes';
+import { Util } from '../utils/util';
+import {
+ INVITE,
+ GUILD_BANNER,
+ GUILD_ICON,
+ GUILD_SPLASH,
+ USER_NICK,
+ GUILD_EMOJI,
+ GUILD_EMOJIS,
+ GUILDS,
+ GUILD_BANS,
+ GUILD_VOICE_REGIONS,
+ GUILD_BAN,
+ GUILD_PRUNE,
+ GUILD_INVITES,
+ GUILD_MEMBER,
+ GUILD_MEMBER_ROLE,
+ GUILD_ROLE,
+ GUILD_ROLES,
+ THREAD_ACTIVE,
+ GUILD_PREVIEW,
+ GUILD_VANITY,
+ GUILD_WIDGET,
+ USER_GUILDS,
+} from '@biscuitland/api-types';
+import { GuildChannel, ReturnThreadsArchive, ThreadChannel } from './channels';
+import { Member, ThreadMember } from './members';
+import { Role } from './role';
+import { GuildEmoji } from './emojis';
+import { urlToBase64 } from '../utils/url-to-base-64';
+import { Invite } from './invite';
+import { User } from './user';
+import { Widget } from './widget';
+import { Sticker } from './sticker';
+import { WelcomeScreen } from './welcome';
+
+/** BaseGuild */
+/**
+ * Class for {@link Guild} and {@link AnonymousGuild}
+ */
+export abstract class BaseGuild implements Model {
+ constructor(session: Session, data: DiscordGuild) {
+ this.session = session;
+ this.id = data.id;
+
+ this.name = data.name;
+ this.iconHash = data.icon ? data.icon : undefined;
+
+ this.features = data.features;
+ }
+
+ /** The session that instantiated the guild. */
+ readonly session: Session;
+
+ /** Guild id. */
+ readonly id: Snowflake;
+
+ /** Guild name. */
+ name: string;
+
+ /**
+ * Icon hash. Discord uses ids and hashes to render images in the client.
+ * @link https://discord.com/developers/docs/reference#image-formatting
+ */
+ iconHash?: string;
+
+ /**
+ * Enabled guild features (animated banner, news, auto moderation, etc).
+ * @see {@link GuildFeatures}
+ * @link https://discord.com/developers/docs/resources/guild#guild-object-guild-features
+ */
+ features: GuildFeatures[];
+
+ /** createdTimestamp gets the current guild timestamp. */
+ get createdTimestamp(): number {
+ return Snowflake.snowflakeToTimestamp(this.id);
+ }
+
+ /** createdAt gets the creation Date object of the guild. */
+ get createdAt(): Date {
+ return new Date(this.createdTimestamp);
+ }
+
+ /**
+ * If the guild features includes partnered.
+ * @link https://discord.com/developers/docs/resources/guild#guild-object-guild-features
+ */
+ get partnered(): boolean {
+ return this.features.includes(GuildFeatures.Partnered);
+ }
+
+ /**
+ * If the guild is verified.
+ * @link https://discord.com/developers/docs/resources/guild#guild-object-guild-features
+ */
+ get verified(): boolean {
+ return this.features.includes(GuildFeatures.Verified);
+ }
+
+ /**
+ * iconURL gets the current guild icon.
+ * @link https://discord.com/developers/docs/reference#image-formatting
+ */
+ iconURL(
+ options: { size?: ImageSize; format?: ImageFormat } = { size: 128 }
+ ): string | void {
+ if (this.iconHash) {
+ return Util.formatImageURL(
+ GUILD_ICON(this.id, this.iconHash),
+ options.size,
+ options.format
+ );
+ }
+ }
+
+ /** toString gets the guild name */
+ toString(): string {
+ return this.name;
+ }
+}
+
+/** AnonymousGuild */
+/**
+ * Class for anonymous guilds.
+ * @see {@link BaseGuild}
+ * @link https://discord.com/developers/docs/resources/guild#guild-resource
+ */
+export class AnonymousGuild extends BaseGuild implements Model {
+ constructor(session: Session, data: Partial); // TODO: Improve this type (name and id are required)
+ constructor(session: Session, data: DiscordGuild) {
+ super(session, data);
+
+ this.splashHash = data.splash
+ ? data.splash
+ : undefined;
+
+ this.bannerHash = data.banner
+ ? data.banner
+ : undefined;
+
+ this.verificationLevel = data.verification_level;
+ this.vanityUrlCode = data.vanity_url_code
+ ? data.vanity_url_code
+ : undefined;
+
+ this.nsfwLevel = data.nsfw_level;
+ this.description = data.description ? data.description : undefined;
+ this.premiumSubscriptionCount = data.premium_subscription_count;
+ }
+
+ /**
+ * The guild's splash hash.
+ * @link https://discord.com/developers/docs/reference#image-formatting
+ */
+ splashHash?: string;
+
+ /**
+ * The guild's banner hash.
+ * @link https://discord.com/developers/docs/reference#image-formatting
+ */
+ bannerHash?: string;
+
+ /**
+ * The guild's verification level.
+ * @see {@link VerificationLevels}
+ * @link https://discord.com/developers/docs/resources/guild#guild-object-verification-level
+ */
+ verificationLevel: VerificationLevels;
+
+ /** The guild's vanity url code. */
+ vanityUrlCode?: string;
+ /**
+ * The guild's nsfw level.
+ * @see {@link GuildNsfwLevel}
+ * @link https://discord.com/developers/docs/resources/guild#guild-object-guild-nsfw-level
+ */
+ nsfwLevel: GuildNsfwLevel;
+
+ /** The guild's description. */
+ description?: string;
+
+ /** The number of boosts this guild currently has. */
+ premiumSubscriptionCount?: number;
+
+ /**
+ * splashURL gets the current guild splash as a string.
+ * @link https://discord.com/developers/docs/reference#image-formatting
+ * @param options - Image options for the splash url.
+ * @returns Splash url or void.
+ */
+ splashURL(
+ options: { size?: ImageSize; format?: ImageFormat } = { size: 128 }
+ ): string | void {
+ if (this.splashHash) {
+ return Util.formatImageURL(
+ GUILD_SPLASH(this.id, this.splashHash),
+ options.size,
+ options.format
+ );
+ }
+ }
+
+ /**
+ * bannerURL gets the current guild banner as a string.
+ * @link https://discord.com/developers/docs/reference#image-formatting
+ * @param options - Image options for the banner url.
+ * @returns Banner url or void
+ */
+ bannerURL(
+ options: { size?: ImageSize; format?: ImageFormat } = { size: 128 }
+ ): string | void {
+ if (this.bannerHash) {
+ return Util.formatImageURL(
+ GUILD_BANNER(this.id, this.bannerHash),
+ options.size,
+ options.format
+ );
+ }
+ }
+}
+
+/** InviteGuild */
+export class InviteGuild extends AnonymousGuild implements Model {
+ constructor(session: Session, data: Partial) {
+ super(session, data);
+
+ if (data.welcome_screen) {
+ this.welcomeScreen = new WelcomeScreen(
+ session,
+ data.welcome_screen
+ );
+ }
+ }
+
+ welcomeScreen?: WelcomeScreen;
+}
+
+/**
+ * Represent Discord Guild Preview Object
+ * @link https://discord.com/developers/docs/resources/guild#guild-preview-object
+ */
+export class GuildPreview implements Model {
+ constructor(session: Session, data: DiscordGuildPreview) {
+ this.session = session;
+ this.id = data.id;
+ this.name = data.name;
+ this.description = data.description ?? undefined;
+
+ this.iconHash = data.icon
+ ? Util.iconHashToBigInt(data.icon)
+ : undefined;
+
+ this.splashHash = data.splash
+ ? Util.iconHashToBigInt(data.splash)
+ : undefined;
+
+ this.discoverySplashHash = data.discovery_splash
+ ? Util.iconHashToBigInt(data.discovery_splash)
+ : undefined;
+
+ this.emojis = data.emojis.map(
+ x => new GuildEmoji(this.session, x, this.id)
+ );
+
+ this.features = data.features;
+ this.approximateMemberCount = data.approximate_member_count;
+ this.approximatePresenceCount = data.approximate_presence_count;
+ this.stickers = data.stickers.map(x => new Sticker(this.session, x));
+ }
+ session: Session;
+ /** guild id */
+ id: Snowflake;
+ /** guild name (2-100 characters) */
+ name: string;
+ iconHash?: bigint;
+ splashHash?: bigint;
+ discoverySplashHash?: bigint;
+ /** custom guild emojis */
+ emojis: GuildEmoji[];
+ /** enabled guild features */
+ features: GuildFeatures[];
+ /** approximate number of members in this guild */
+ approximateMemberCount: number;
+ /** approximate number of online members in this guild */
+ approximatePresenceCount: number;
+ /** the description for the guild */
+ description?: string;
+ /** custom guild stickers */
+ stickers: Sticker[];
+}
+
+/** Guild */
+
+/** Maximun custom guild emojis per level */
+export type MaxEmojis = 50 | 100 | 150 | 250;
+
+/** Maximun custom guild stickers per level */
+export type MaxStickers = 5 | 15 | 30 | 60;
+
+export type EditBotNickname = { nick: string | null; reason?: string };
+
+export interface CreateRole {
+ name?: string;
+ color?: number;
+ iconHash?: string | bigint;
+ unicodeEmoji?: string;
+ hoist?: boolean;
+ mentionable?: boolean;
+}
+
+export interface ModifyGuildRole {
+ name?: string;
+ color?: number;
+ hoist?: boolean;
+ mentionable?: boolean;
+ unicodeEmoji?: string;
+}
+
+export interface CreateGuildEmoji {
+ name: string;
+ image: string;
+ roles?: Snowflake[];
+ reason?: string;
+}
+
+export interface ModifyGuildEmoji {
+ name?: string;
+ roles?: Snowflake[];
+}
+
+/**
+ * @link https://discord.com/developers/docs/resources/guild#create-guild-ban
+ */
+export interface CreateGuildBan {
+ deleteMessageDays?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
+ reason?: string;
+}
+
+/**
+ * @link https://discord.com/developers/docs/resources/guild#ban-object
+ */
+export interface GuildBan {
+ reason?: string;
+ user: User;
+}
+
+/**
+ * @link https://discord.com/developers/docs/resources/guild#guild-widget-settings-object-guild-widget-settings-structure
+ */
+export interface GuildWidgetSettings {
+ enabled: boolean;
+ channelId?: Snowflake;
+}
+
+export interface PartialVanityURL {
+ code: string;
+ uses: number;
+}
+
+/**
+ * @link https://discord.com/developers/docs/resources/guild#modify-guild-member
+ */
+export interface ModifyGuildMember {
+ nick?: string;
+ roles?: Snowflake[];
+ mute?: boolean;
+ deaf?: boolean;
+ channelId?: Snowflake;
+ communicationDisabledUntil?: number;
+}
+
+/**
+ * @link https://discord.com/developers/docs/resources/guild#begin-guild-prune
+ */
+export interface BeginGuildPrune {
+ days?: number;
+ computePruneCount?: boolean;
+ includeRoles?: Snowflake[];
+}
+
+export interface ModifyRolePositions {
+ id: Snowflake;
+ position?: number | null;
+}
+
+export interface GuildCreateOptionsRole {
+ id: Snowflake;
+ name?: string;
+ color?: number;
+ hoist?: boolean;
+ position?: number;
+ permissions?: bigint;
+ mentionable?: boolean;
+ icon?: string;
+ unicodeEmoji?: string | null;
+}
+
+export interface GuildCreateOptionsChannel {
+ id?: Snowflake;
+ parentId?: Snowflake;
+ type?:
+ | ChannelTypes.GuildText
+ | ChannelTypes.GuildVoice
+ | ChannelTypes.GuildCategory;
+ name: string;
+ topic?: string | null;
+ nsfw?: boolean;
+ bitrate?: number;
+ userLimit?: number;
+ rtcRegion?: string | null;
+ videoQualityMode?: VideoQualityModes;
+ permissionOverwrites?: MakeRequired, 'id'>[];
+ rateLimitPerUser?: number;
+}
+
+/**
+ * @link https://discord.com/developers/docs/resources/guild#create-guild
+ */
+export interface GuildCreateOptions {
+ name: string;
+ afkChannelId?: Snowflake;
+ afkTimeout?: number;
+ channels?: GuildCreateOptionsChannel[];
+ defaultMessageNotifications?: DefaultMessageNotificationLevels;
+ explicitContentFilter?: ExplicitContentFilterLevels;
+ icon?: string;
+ roles?: GuildCreateOptionsRole[];
+ systemChannelFlags?: SystemChannelFlags;
+ systemChannelId?: Snowflake;
+ verificationLevel?: VerificationLevels;
+}
+
+/**
+ * @link https://discord.com/developers/docs/resources/guild#modify-guild-json-params
+ */
+export interface GuildEditOptions extends Partial {
+ ownerId?: Snowflake;
+ splash?: string;
+ banner?: string;
+ discoverySplash?: string;
+ features?: GuildFeatures[];
+ rulesChannelId?: Snowflake;
+ publicUpdatesChannelId?: Snowflake;
+ preferredLocale?: string | null;
+ description?: string;
+ premiumProgressBarEnabled?: boolean;
+}
+
+/**
+ * Represents a guild.
+ * @see {@link BaseGuild}.
+ * @link https://discord.com/developers/docs/resources/guild#guild-object
+ */
+export class Guild extends BaseGuild implements Model {
+ constructor(session: Session, data: DiscordGuild) {
+ super(session, data);
+
+ this.splashHash = data.splash
+ ? Util.iconHashToBigInt(data.splash)
+ : undefined;
+ this.discoverySplashHash = data.discovery_splash
+ ? Util.iconHashToBigInt(data.discovery_splash)
+ : undefined;
+ this.ownerId = data.owner_id;
+ this.widgetEnabled = !!data.widget_enabled;
+ this.widgetChannelId = data.widget_channel_id
+ ? data.widget_channel_id
+ : undefined;
+ this.vefificationLevel = data.verification_level;
+ this.defaultMessageNotificationLevel =
+ data.default_message_notifications;
+ this.explicitContentFilterLevel = data.explicit_content_filter;
+ this.premiumTier = data.premium_tier;
+ this.members = new Map(
+ data.members?.map(member => [
+ data.id,
+ new Member(session, { ...member, user: member.user! }, data.id),
+ ])
+ );
+
+ this.roles = new Map(
+ data.roles.map(role => [data.id, new Role(session, role, data.id)])
+ );
+
+ this.emojis = new Map(
+ data.emojis.map(guildEmoji => [
+ guildEmoji.id!,
+ new GuildEmoji(session, guildEmoji, data.id),
+ ])
+ );
+
+ this.channels = new Map(
+ data.channels?.map(guildChannel => [
+ guildChannel.id,
+ new GuildChannel(session, guildChannel, data.id),
+ ])
+ );
+ }
+
+ /**
+ * The guild's splash hash.
+ * @link https://discord.com/developers/docs/reference#image-formatting
+ */
+ splashHash?: bigint;
+
+ /**
+ * Only present for guilds with the "DISCOVERABLE" feature
+ * @link https://discord.com/developers/docs/reference#image-formatting
+ */
+ discoverySplashHash?: bigint;
+
+ /** ID of the guild owner. */
+ ownerId: Snowflake;
+
+ /** True if the server widget is enabled */
+ widgetEnabled: boolean;
+
+ /** The channel id that the widget will generate an invite to, or undefined if set to no invite. */
+ widgetChannelId?: Snowflake;
+ /**
+ * Verification level required for the guild.
+ * @see {@link VerificationLevels}
+ * @link https://discord.com/developers/docs/resources/guild#guild-object-verification-level
+ */
+ vefificationLevel: VerificationLevels;
+
+ /**
+ * The default message notification level.
+ * @see {@link DefaultMessageNotificationLevels}
+ * @link https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
+ */
+ defaultMessageNotificationLevel: DefaultMessageNotificationLevels;
+
+ /**
+ * The explicit content filter level.
+ * @see {@link ExplicitContentFilterLevels}
+ * @link https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level
+ */
+ explicitContentFilterLevel: ExplicitContentFilterLevels;
+
+ /**
+ * Premium tier (Server Boost level).
+ * @see {@link PremiumTiers}
+ * @link https://discord.com/developers/docs/resources/guild#guild-object-premium-tier
+ */
+ premiumTier: PremiumTiers;
+
+ /**
+ * A map with the guild's members.
+ * @see {@link Member}
+ * @link https://discord.com/developers/docs/resources/guild#guild-member-object
+ */
+ members: Map;
+
+ /**
+ * A map with the guild's roles.
+ * @see {@link Role}
+ * @link https://discord.com/developers/docs/topics/permissions#role-object
+ */
+
+ roles: Map;
+
+ /**
+ * A map with the guild's emojis.
+ * @see {@link GuildEmoji}
+ * @link https://discord.com/developers/docs/resources/emoji#emoji-object-emoji-structure
+ */
+ emojis: Map;
+
+ /**
+ * A map with the guild's channels.
+ * @see {@link GuildChannel}
+ * @link https://discord.com/developers/docs/resources/channel#channel-object
+ */
+ channels: Map;
+
+ /**
+ * Returns the maximum number of emoji slots
+ */
+ get maxEmojis(): MaxEmojis {
+ switch (this.premiumTier) {
+ case 1:
+ return 100;
+ case 2:
+ return 150;
+ case 3:
+ return 250;
+ default:
+ return 50;
+ }
+ }
+
+ /**
+ * Returns the maximum number of custom sticker slots
+ */
+ get maxStickers(): MaxStickers {
+ switch (this.premiumTier) {
+ case 1:
+ return 15;
+ case 2:
+ return 30;
+ case 3:
+ return 60;
+ default:
+ return 5;
+ }
+ }
+
+ /**
+ * edits the bot's nickname in the guild.
+ * 'null' would reset the nickname.
+ */
+ async editBotNickname(
+ options: EditBotNickname
+ ): Promise {
+ const result = await this.session.rest.patch<
+ { nick?: string } | undefined
+ >(USER_NICK(this.id), options);
+
+ return result?.nick;
+ }
+
+ /**
+ * creates an emoji in the guild.
+ * @see {@link CreateGuildEmoji}
+ * @see {@link GuildEmoji}
+ * @param options The options to create a emoji.
+ * @returns A promise that resolves to the guild's new emoji.
+ */
+ async createEmoji(options: CreateGuildEmoji): Promise {
+ if (options.image && !options.image.startsWith('data:image/')) {
+ options.image = await urlToBase64(options.image);
+ }
+
+ const emoji = await this.session.rest.post(
+ GUILD_EMOJIS(this.id),
+ options
+ );
+
+ return new GuildEmoji(this.session, emoji, this.id);
+ }
+
+ /**
+ * deletes an emoji from the guild.
+ * @param id - The id of the emoji to delete.
+ * @param reason - The reason for deleting the emoji.
+ */
+ async deleteEmoji(id: Snowflake, reason?: string): Promise {
+ await this.session.rest.delete(GUILD_EMOJI(this.id, id), {
+ reason,
+ });
+ }
+
+ /**
+ * edits an emoji in the guild.
+ * @see {@link ModifyGuildEmoji}
+ * @see {@link GuildEmoji}
+ * @param id - The id of the emoji to edit.
+ * @param options - Options to modify the emoji.
+ * @returns A promise that resolves to the edited emoji.
+ */
+ async editEmoji(
+ id: Snowflake,
+ options: ModifyGuildEmoji
+ ): Promise {
+ const emoji = await this.session.rest.patch(
+ GUILD_EMOJI(this.id, id),
+ options
+ );
+
+ return new GuildEmoji(this.session, emoji, this.id);
+ }
+
+ /**
+ * creates a role in the guild.
+ * @see {@link CreateRole}
+ * @see {@link Role}
+ * @param options - Options to create a new role.
+ */
+ async createRole(options: CreateRole): Promise {
+ let icon: string | undefined;
+
+ if (options.iconHash) {
+ if (typeof options.iconHash === 'string') {
+ icon = options.iconHash;
+ } else {
+ icon = Util.iconBigintToHash(options.iconHash);
+ }
+ }
+
+ const role = await this.session.rest.put(
+ GUILD_ROLES(this.id),
+ {
+ name: options.name,
+ color: options.color,
+ icon,
+ unicode_emoji: options.unicodeEmoji,
+ hoist: options.hoist,
+ mentionable: options.mentionable,
+ }
+ );
+
+ return new Role(this.session, role, this.id);
+ }
+
+ /**
+ * deletes a role from the guild.
+ * @param roleId - The id of the role to delete.
+ */
+ async deleteRole(roleId: Snowflake): Promise {
+ await this.session.rest.delete(
+ GUILD_ROLE(this.id, roleId),
+ {}
+ );
+ }
+
+ /**
+ * edits a role in the guild.
+ * @see {@link ModifyGuildRole}
+ * @see {@link Role}
+ * @param roleId - The id of the role to edit.
+ * @param options - Options to modify the role.
+ */
+ async editRole(roleId: Snowflake, options: ModifyGuildRole): Promise {
+ const role = await this.session.rest.patch(
+ GUILD_ROLE(this.id, roleId),
+ {
+ name: options.name,
+ color: options.color,
+ hoist: options.hoist,
+ mentionable: options.mentionable,
+ }
+ );
+
+ return new Role(this.session, role, this.id);
+ }
+
+ /**
+ * adds a role to a user in the guild.
+ * @param memberId - The id of the member to add a role to.
+ * @param roleId - The id of the role to add.
+ * @param reason - The reason for adding the role to the member.
+ */
+ async addRole(
+ memberId: Snowflake,
+ roleId: Snowflake,
+ reason?: string
+ ): Promise {
+ await this.session.rest.put(
+ GUILD_MEMBER_ROLE(this.id, memberId, roleId),
+ { reason }
+ );
+ }
+
+ /**
+ * removes a role from a user in the guild.
+ * @param memberId - The id of the member to remove a role from.
+ * @param roleId - The id of the role to remove.
+ * @param reason - The reason for removing the role from the member.
+ */
+ async removeRole(
+ memberId: Snowflake,
+ roleId: Snowflake,
+ reason?: string
+ ): Promise {
+ await this.session.rest.delete(
+ GUILD_MEMBER_ROLE(this.id, memberId, roleId),
+ { reason }
+ );
+ }
+
+ /**
+ * the roles moved.
+ * @see {@link ModifyRolePositions}
+ * @see {@link Role}
+ * @param options - Options to modify the roles.
+ */
+ async moveRoles(options: ModifyRolePositions[]): Promise {
+ const roles = await this.session.rest.patch(
+ GUILD_ROLES(this.id),
+ options
+ );
+
+ return roles.map(role => new Role(this.session, role, this.id));
+ }
+
+ /**
+ * deletes an invite from the guild.
+ * @param inviteCode - The invite code to get the invite for.
+ */
+ async deleteInvite(inviteCode: string): Promise {
+ await this.session.rest.delete(INVITE(inviteCode), {});
+ }
+
+ /**
+ * gets an invite from the guild.
+ * @see {@link Routes.GetInvite}
+ * @see {@link Invite}
+ * @param inviteCode - The invite code to get the invite for.
+ * @param options - Options to get the invite.
+ * @returns Promise resolving to the invite.
+ */
+ async fetchInvite(inviteCode: string, options: GetInvite): Promise {
+ const inviteMetadata =
+ await this.session.rest.get(
+ INVITE(inviteCode, options)
+ );
+
+ return new Invite(this.session, inviteMetadata);
+ }
+
+ /**
+ * gets all invites from the guild.
+ * @see {@link Invite}
+ * @returns A promise that resolves to the guild's invites.
+ */
+ async fetchInvites(): Promise {
+ const invites = await this.session.rest.get(
+ GUILD_INVITES(this.id)
+ );
+
+ return invites.map(invite => new Invite(this.session, invite));
+ }
+
+ /**
+ * bans a member from the guild.
+ * @see {@link CreateGuildBan}
+ * @param memberId - The id of the member to ban.
+ * @param options - Options to ban the member.
+ */
+ async banMember(
+ memberId: Snowflake,
+ options: CreateGuildBan
+ ): Promise {
+ await this.session.rest.put(
+ GUILD_BAN(this.id, memberId),
+ options
+ ? {
+ delete_message_days: options.deleteMessageDays,
+ reason: options.reason,
+ }
+ : {}
+ );
+ }
+
+ /**
+ * kicks a member from the guild.
+ * @param memberId - The id of the member to kick.
+ * @param reason - The reason for kicking the member.
+ */
+ async kickMember(memberId: Snowflake, reason?: string): Promise {
+ await this.session.rest.delete(
+ GUILD_MEMBER(this.id, memberId),
+ { reason }
+ );
+ }
+
+ /**
+ * unbans a member from the guild.
+ * @param memberId - The id of the member to get.
+ */
+ async unbanMember(memberId: Snowflake): Promise {
+ await this.session.rest.delete(
+ GUILD_BAN(this.id, memberId),
+ {}
+ );
+ }
+
+ /**
+ * edits a member in the guild.
+ * @see {@link ModifyGuildMember}
+ * @see {@link Member}
+ * @param memberId - The id of the member to get.
+ * @param options - Options to edit the member.
+ * @returns Promise resolving to the edited member.
+ */
+ async editMember(
+ memberId: Snowflake,
+ options: ModifyGuildMember
+ ): Promise