diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
deleted file mode 100644
index 800d0c66f..000000000
--- a/.devcontainer/Dockerfile
+++ /dev/null
@@ -1,19 +0,0 @@
-FROM mcr.microsoft.com/vscode/devcontainers/base:0-buster
-
-ENV DENO_INSTALL=/deno
-RUN mkdir -p /deno \
- && curl -fsSL https://deno.land/x/install/install.sh | sh \
- && chown -R vscode /deno
-
-ENV PATH=${DENO_INSTALL}/bin:${PATH} \
- DENO_DIR=${DENO_INSTALL}/.cache/deno
-
-# [Optional] Uncomment this section to install additional OS packages.
-RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
- && apt-get -y install --no-install-recommends make
-
-# Install node
-RUN curl -sL https://deb.nodesource.com/setup_16.x | bash
-RUN apt-get -y install --no-install-recommends nodejs
-
-USER vscode
\ No newline at end of file
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
deleted file mode 100644
index 14095425e..000000000
--- a/.devcontainer/devcontainer.json
+++ /dev/null
@@ -1,42 +0,0 @@
-// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
-// https://github.com/microsoft/vscode-dev-containers/tree/v0.162.0/containers/deno
-{
- "name": "Deno",
- "dockerFile": "Dockerfile",
- // Set *default* container specific settings.json values on container create.
- "settings": {
- "terminal.integrated.defaultProfile.linux": "/bin/bash",
- "deno.enable": true,
- "editor.defaultFormatter": "denoland.vscode-deno",
- "editor.minimap.enabled": false,
- "editor.wordWrap": "on",
- "editor.codeActionsOnSave": {
- "source.organizeImports": true,
- "source.fixAll": true
- },
- "editor.fontSize": 16,
- "workbench.colorTheme": "Material Theme Darker",
- "workbench.iconTheme": "eq-material-theme-icons-darker",
- "breadcrumbs.enabled": true,
- "editor.renderWhitespace": "all",
- "editor.suggestSelection": "first",
- "editor.formatOnSave": true,
- "files.autoSave": "afterDelay",
- "editor.fontFamily": "Fira Code, Menlo, Monaco, 'Courier New', monospace",
- "typescript.updateImportsOnFileMove.enabled": "always",
- "javascript.updateImportsOnFileMove.enabled": "always"
- },
- // Add the IDs of extensions you want installed when the container is created.
- "extensions": [
- "denoland.vscode-deno",
- "pkief.material-icon-theme",
- "equinusocio.vsc-material-theme",
- "tabnine.tabnine-vscode"
- ],
- // Use 'forwardPorts' to make a list of ports inside the container available locally.
- // "forwardPorts": [],
- // Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
- // "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
- // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
- "remoteUser": "vscode"
-}
diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644
index cb05087a7..000000000
--- a/.gitattributes
+++ /dev/null
@@ -1,5 +0,0 @@
-* text eol=lf
-
-*.png binary
-*.jpg binary
-*.svg binary
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
deleted file mode 100644
index f1ab551df..000000000
--- a/.github/CODEOWNERS
+++ /dev/null
@@ -1 +0,0 @@
-* @Skillz4Killz @itohatweb
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
deleted file mode 100644
index 7e59d317c..000000000
--- a/.github/CONTRIBUTING.md
+++ /dev/null
@@ -1,6 +0,0 @@
-# Contributing
-
-- This isn't a job! Have fun!
-- Commit messages can(but you don't have to hehe) be nonsense!
-- PR description and title should be as detailed as possible!
-- Always remember to blame wolf and @ITOH every day!
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
deleted file mode 100644
index 0173b39a3..000000000
--- a/.github/FUNDING.yml
+++ /dev/null
@@ -1 +0,0 @@
-github: itohatweb
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
deleted file mode 100644
index 9c03e674b..000000000
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ /dev/null
@@ -1,40 +0,0 @@
----
-name: Bug report
-about: Create a report to help us improve
-title: ""
-labels: bug
-assignees: ""
----
-
-**Describe the bug** A clear and concise description of what the bug is.
-
-**To Reproduce** Write a small mod.ts example to replicate the behavior.
-
-```ts
-import { createBot, startBot } from "https://deno.land/x/discordeno/mod.ts";
-
-const token = "DO NOT PUT TOKEN HERE!!!";
-const botId = BigInt(atob(TOKEN.split(".")[0]));
-
-const bot = createBot({
- token,
- botId,
- events: {
- // ADD EVENTS NEEDED TO SHOW THE BUG HERE
- },
- intents: 0, // ADD INTENTS NEEDED HERE FOR YOUR TEST IF NECESSARY
-});
-
-await startBot(bot);
-```
-
-**Expected behavior** A clear and concise description of what you expected to happen.
-
-**Screenshots** If applicable, add screenshots to help explain your problem.
-
-**Version details (please complete the following information):**
-
-- Discordeno version: [e.g. 10.5.0]
-- Deno version: [e.g. 1.8.0]
-
-**Additional context** Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
deleted file mode 100644
index 13412bb5c..000000000
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ /dev/null
@@ -1,17 +0,0 @@
----
-name: Feature request
-about: Suggest an idea for this project
-title: ""
-labels: feat
-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.
-
-**Additional context** Add any other context or screenshots about the feature request here.
diff --git a/.github/sync.yml b/.github/sync.yml
deleted file mode 100644
index a8ce90747..000000000
--- a/.github/sync.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-discordeno/guide:
- - source: site/
- dest: ./
- exclude: |
- README.md
- LICENSE
- deleteOrphaned: true
-
-discordeno/template:
- - source: template/
- dest: ./
- exclude: |
- README.md
- LICENSE
- deleteOrphaned: true
diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml
deleted file mode 100644
index 64cabaa74..000000000
--- a/.github/workflows/fmt.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-name: Automatically format the code when requested
-
-on: issue_comment
-
-jobs:
- test:
- runs-on: ubuntu-latest
- strategy:
- matrix:
- deno: ["v1.x"]
- steps:
- - uses: actions/checkout@v2
- - run: git submodule update --init --recursive
- - uses: denoland/setup-deno@main
- with:
- deno-version: ${{ matrix.deno }}
- - name: Cache dependencies
- run: deno cache mod.ts
- - name: Cache Templates
- run: deno cache template/beginner/mod.ts template/minimal/mod.ts
- - name: Format code
- if: ${{ github.event.issue.pull_request && github.event.comment.body == 'run-fmt' && (github.actor == 'Skillz4Killz' || github.actor == 'itohatweb') }}
- run: deno fmt
- - name: Push changes
- if: ${{ github.event.issue.pull_request && github.event.comment.body == 'run-fmt' && (github.actor == 'Skillz4Killz' || github.actor == 'itohatweb') }}
- continue-on-error: true # if code is unchanged it will error
- run: |
- git config user.name Github Actions
- git config user.email github-actions@github.com
- git add .
- git commit -m "chore: Format code"
- git push
diff --git a/.github/workflows/pr_tests.yml b/.github/workflows/pr_tests.yml
deleted file mode 100644
index 9835564a0..000000000
--- a/.github/workflows/pr_tests.yml
+++ /dev/null
@@ -1,33 +0,0 @@
-name: Test Contributor Pull Requests
-
-on: issue_comment
-
-jobs:
- test:
- runs-on: ubuntu-latest
- strategy:
- matrix:
- deno: ["v1.x"]
- steps:
- - uses: actions/checkout@v2
- - run: git submodule update --init --recursive
- - uses: denoland/setup-deno@main
- with:
- deno-version: ${{ matrix.deno }}
- - name: Cache dependencies
- run: deno cache mod.ts
- - name: Run tests if requested by maintainers
- if: ${{ github.event.issue.pull_request && github.event.comment.body == 'run-tests' && (github.actor == 'Skillz4Killz' || github.actor == 'itohatweb') }}
- run: DISCORD_TOKEN=${{ env.DISCORD_TOKEN }} deno test --coverage=coverage -A tests/ --parallel
- env:
- DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
- - name: Create coverage report
- if: github.ref == 'refs/heads/main'
- run: deno coverage --exclude=tests ./coverage --lcov > coverage.lcov
- - name: Collect and upload the coverage report
- if: github.ref == 'refs/heads/main'
- uses: codecov/codecov-action@v1.0.10
- with:
- file: ./coverage.lcov
- env:
- DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
deleted file mode 100644
index ba63856b0..000000000
--- a/.github/workflows/release.yml
+++ /dev/null
@@ -1,37 +0,0 @@
-name: Release
-
-on:
- push:
- branches:
- - main
-
-jobs:
- publish:
- runs-on: ubuntu-latest
- strategy:
- matrix:
- deno: ["v1.x"]
- steps:
- - uses: actions/checkout@v2
- - uses: denoland/setup-deno@main
- with:
- deno-version: ${{ matrix.deno }}
- - name: Get last tag version
- run: |
- echo "DISCORDENO_VERSION_OLD=$(wget -O- -q https://deno.land/x/discordeno/util/constants.ts | grep 'export const DISCORDENO_VERSION' | awk -F'= ' '{print $2}' | tr -d '"|;')" >> $GITHUB_ENV
- - name: Get new tag version
- run: echo "DISCORDENO_VERSION=$(cat util/constants.ts | grep 'export const DISCORDENO_VERSION' | awk -F'= ' '{print $2}' | tr -d '"|;')" >> $GITHUB_ENV
- - name: Create tag
- if: ${{ env.DISCORDENO_VERSION != env.DISCORDENO_VERSION_OLD }}
- run: git tag ${{ env.DISCORDENO_VERSION }} && git push --tags
- - uses: actions/setup-node@v2
- with:
- node-version: '16.x'
- registry-url: 'https://registry.npmjs.org'
- - name: build npm
- run: deno run -A ./dnt.ts ${{ env.DISCORDENO_VERSION }}
- - name: npm publish
- if: ${{ env.DISCORDENO_VERSION != env.DISCORDENO_VERSION_OLD }}
- env:
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: cd npm && npm publish
diff --git a/.github/workflows/site_tests.yml b/.github/workflows/site_tests.yml
deleted file mode 100644
index a24303116..000000000
--- a/.github/workflows/site_tests.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-name: Test Docusaurus build
-
-on:
- pull_request:
- paths:
- - "site/**"
-
-jobs:
- test-deploy:
- name: Test deployment
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - uses: actions/setup-node@v2
- with:
- node-version: 14.x
- cache: npm
- cache-dependency-path: site/package-lock.json
- - name: Test build
- working-directory: site
- run: |
- npm ci
- npm run build
diff --git a/.github/workflows/sync_repos.yml b/.github/workflows/sync_repos.yml
deleted file mode 100644
index c62a6ab22..000000000
--- a/.github/workflows/sync_repos.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-name: Sync Repos
-
-on:
- push:
- branches:
- - main
- paths:
- - "site/**"
- - "template/**"
-
-jobs:
- sync:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout Repository
- uses: actions/checkout@master
- - name: Run GitHub File Sync
- uses: BetaHuhn/repo-file-sync-action@v1
- with:
- GH_PAT: ${{ secrets.REPO_SYNC }}
- GIT_EMAIL: to@itoh.at
- GIT_USERNAME: itohatweb
- SKIP_PR: true
- COMMIT_EACH_FILE: false
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
deleted file mode 100644
index a93b99fc2..000000000
--- a/.github/workflows/test.yml
+++ /dev/null
@@ -1,77 +0,0 @@
-name: Test
-
-on:
- pull_request:
- push:
-
-jobs:
- format-test:
- name: Format Test
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- - uses: denoland/setup-deno@main
- with:
- deno-version: v1.x
- - name: Check Formatting
- run: deno fmt --check
- type-test:
- name: Type Test
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- - uses: denoland/setup-deno@main
- with:
- deno-version: v1.x
- - name: Check dependencies
- run: deno check mod.ts
- - name: Check plugins
- run: deno check plugins/mod.ts
- - name: Check Templates
- run: deno check template/beginner/mod.ts template/minimal/mod.ts
- integration-test:
- name: Integration Test
- runs-on: ubuntu-latest
- concurrency: integration-test
- steps:
- - uses: actions/checkout@v3
- - uses: denoland/setup-deno@main
- with:
- deno-version: v1.x
- - name: Run integration
- # if: ${{ github.actor == 'Skillz4Killz' || github.actor == 'itohatweb' }}
- run: deno test --coverage=coverage -A tests/
- env:
- DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
- UNIT_TEST_GUILD_ID: ${{ secrets.UNIT_TEST_GUILD_ID }}
- TEST_ENV: INTEGRATION
- PROXY_REST_SECRET: ${{ secrets.PROXY_REST_SECRET }}
- PROXY_REST_URL: ${{ secrets.PROXY_REST_URL }}
- - name: Create coverage report
- if: github.ref == 'refs/heads/main'
- run: deno coverage --exclude=tests ./coverage --lcov > coverage.lcov
- - name: Collect and upload the coverage report
- if: github.ref == 'refs/heads/main'
- uses: codecov/codecov-action@v1.0.10
- with:
- file: ./coverage.lcov
- unit-test:
- name: Unit Test
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- - uses: denoland/setup-deno@main
- with:
- deno-version: v1.x
- - name: Run integration
- run: deno test --coverage=coverage --parallel -A tests/
- env:
- TEST_ENV: UNIT
- - name: Create coverage report
- if: github.ref == 'refs/heads/main'
- run: deno coverage --exclude=tests ./coverage --lcov > coverage.lcov
- - name: Collect and upload the coverage report
- if: github.ref == 'refs/heads/main'
- uses: codecov/codecov-action@v1.0.10
- with:
- file: ./coverage.lcov
diff --git a/.github/workflows/validateCache.yml b/.github/workflows/validateCache.yml
new file mode 100644
index 000000000..bb57e221f
--- /dev/null
+++ b/.github/workflows/validateCache.yml
@@ -0,0 +1,25 @@
+name: Validate Cache
+
+on:
+ schedule:
+ - cron: "0 0 * * *"
+ workflow_dispatch:
+
+jobs:
+ validate-cache:
+ name: Validate Cache
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - uses: denoland/setup-deno@main
+ with:
+ deno-version: "v1.x"
+ - name: Check And Update Objects
+ run: deno run -A cache/checkAndUpdateObjects.ts
+ env:
+ DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
+ - name: Commit and push
+ uses: EndBug/add-and-commit@v9
+ with:
+ add: cache/cachedObject
+ message: "[Scheduled] Auto patch objects"
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 6cfdef440..de70a6536 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -28,4 +28,4 @@
"source.organizeImports": true,
"source.fixAll": true
}
-}
+}
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 80a84a261..3b3c0d0ea 100644
--- a/LICENSE
+++ b/LICENSE
@@ -198,4 +198,4 @@
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.
+ limitations under the License.
\ No newline at end of file
diff --git a/README.md b/README.md
index f19ab7086..788aa9e1f 100644
--- a/README.md
+++ b/README.md
@@ -1,153 +1 @@
-# Discordeno
-
-
-
-Discord API library for [Deno](https://deno.land)
-
-Discordeno follows [semantic versioning](https://semver.org/)
-
-[](https://discord.com/invite/5vBgXk3UcZ)
-
-[](https://codecov.io/gh/discordeno/discordeno)
-
-## Features
-
-Discordeno is actively maintained to guarantee **excellent performance and ease.**
-
-- **Simple, Efficient, and Lightweight**: Discordeno is lightweight, simple to use, and adaptable. By default, no
- caching.
-- **Functional API**: The functional API eliminates the challenges of extending built-in classes and inheritance while
- ensuring overall simple but performant code.
-- **Cross Runtime**: Supports the Node.js and Deno runtimes.
-- **Standalone components**: Discordeno offers the option to have practically any component of a bot as a separate
- piece, including standalone REST, gateways, custom caches, and more.
-- **Plugins:** Designed to allow you to overwrite any portion of the code with your own code. Never go through the
- hassle of maintaining your fork in order to acquire something that is specifically tailored to your requirements.
- Plugins may be used for nearly anything; for instance, we have a few authorised plugins.
- - A caching plugin that makes anything cacheable.
- - A plugin for sweepers that allows them to periodically clear the cache.
- - The permission plugin internally verifies any missing permissions before sending a call to the Discord API to
- prevent the client from receiving a Discord global ban.
-
-- **Flexibility:** You may easily delete an object's attributes if your bot doesn't require them. For instance, you
- shouldn't be required to keep `Channel.topic` if your bot doesn't require it. You may save GBs of RAM in this way. A
- few lines of code are all that are needed to accomplish this for any property on any object.
-
-### REST
-
-- Freedom from 1 hour downtimes due to invalid requests
- - By lowering the maximum downtime to 10 minutes, Discordeno will prevent your bot from being down for an hour.
-- Freedom from global rate limit errors
- - As your bot grows, you want to handle global rate limits better. Shards don't communicate fast enough to truly
- handle it properly so this allows 1 rest handler across the entire bot.
- - You may really run numerous instances of your bot on different hosts, all of which will connect to the same REST
- server.
-- REST does not rest!
- - Separate rest guarantees that your queued requests will continue to be processed even if your bot breaks for
- whatever reason.
- - Seamless updates! There's a chance you'll lose a lot of messages or replies that are waiting to be given when you
- wish to update and restart the bot. You may restart your bot using this technique and never have to worry about
- losing any answers.
-- Single source of contact to Discord API
- - As a result, you will be able to send requests to Discord from any location, even a bot dashboard. You are no longer
- need to interact with your bot processes in order to submit a request or do anything else. Your bot process should
- be freed up to handle bot events.
-- Scalability! Scalability! Scalability!
-
-### Gateway
-
-- **Zero Downtime Updates:**
- - A few seconds are needed to update your bot. When using conventional sharding, you must restart in addition to going
- through a 1/5s rate-limited process of identifying all of your shards. As WS processing has been relocated to a
- proxy process, you may resume the bot code right away without worrying about any delays. Normally, if you had a bot
- that was spread across 200,000 servers, restarting it after making a simple modification would take 20 minutes.
-- **Zero Downtime Resharding:**
- - At various periods in time, Discord stops allowing your bot to be added to new servers. Consider 150 shards
- operating on 150,000 servers, for instance. Your shards may support a maximum of 150 * 2500 = 375,000 servers. Your
- bot will be unable to join new servers once it reaches this point until it re-shards.
- - DD proxy provides 2 types of re-sharding. Automated and manual. You can also have both.
- - Automated: This system will automatically begin a Zero-downtime resharding process behind the scenes when you
- reach 80% of your maximum servers allowed by your shards. For example, since 375,000 was the max, at 300,000 we
- would begin re-sharding behind the scenes with ZERO DOWNTIME.
- - 80% of maximum servers reached (The % of 80% is customizable.)
- - Identify limits have room to allow re-sharding. (Also customizable)
- - Manual: You can also trigger this manually should you choose.
-- **Horizontal Scaling:**
- - The bot may be scaled horizontally thanks to the proxy mechanism. When your business grows significantly, you have
- two options: you can either keep investing money to upgrade your server or you may expand horizontally by purchasing
- numerous more affordable servers. The proxy enables WS handling on a totally other system.
-- **No Loss Restarts:**
- - Without the proxy mechanism, you would typically lose numerous events while restarting a bot. Users could issue
- instructions or send messages that are not screened. As your bot population increases, this amount grows sharply.
- Users who don't receive the automatic roles or any other activities your bot should do may join. You may keep
- restarting your bot thanks to the proxy technology without ever losing any events. While your bot is unavailable,
- events will be added to a queue (the maximum size of the queue is configurable), and once the bot is back online,
- the queue will start processing all of the events.
-- **Controllers:**
- - You have complete control over everything inside the proxy thanks to the controller aspect. To simply override the
- handler, you may supply a function. For instance, you may simply give a method to override a specific function if
- you want it to behave differently rather than forking and maintaining your fork.
-- **Clustering With Workers:**
- - Utilize all of your CPU cores to their greatest potential by distributing the workload across employees. To enhance
- efficiency, manage how many employees and shards there are each worker!
-
-### Custom Cache
-
-Have your cache setup in any way you like. Redis, PGSQL or any cache layer you would like.
-
-## Getting Started
-
-### Minimal Example
-
-Here is a minimal example to get started with:
-
-```typescript
-import { createBot, Intents, startBot } from "https://deno.land/x/discordeno@13.0.0/mod.ts";
-
-const bot = createBot({
- token: Deno.env.get("DISCORD_TOKEN"),
- intents: Intents.Guilds | Intents.GuildMessages,
- events: {
- ready() {
- console.log("Successfully connected to gateway");
- },
- },
-});
-
-// Another way to do events
-bot.events.messageCreate = function (b, message) {
- // Process the message here with your command handler.
-};
-
-await startBot(bot);
-```
-
-### Tools
-
-This library is not intended for beginners, however if you still want to utilise it, check out these excellent official
-and unofficial templates:
-
-**Templates**
-
-- [Discordeno Template (official)](https://github.com/discordeno/discordeno/tree/main/template)
-- [Serverless Slash Commands Template (official)](https://github.com/discordeno/serverless-deno-deploy-template)
-- [`create-discordeno-bot` (WIP, unoffical)](https://github.com/Reboot-Codes/create-discordeno-bot/)
-- [Add Your Own!](https://github.com/discordeno/discordeno/pulls)
-
-**Frameworks**
-
-- [Amethyst Framework](https://github.com/AmethystFramework/framework)
-- [Add Your Own!](https://github.com/discordeno/discordeno/pulls)
-
-**Plugins**
-
-- [Cache Plugin](plugins/cache)
-- [Fileloader Plugin](plugins/fileloader)
-- [Helpers Plugin](plugins/helpers)
-- [Permissions Plugin](plugins/permissions)
-
-## Links
-
-- [Website](https://discordeno.mod.land)
-- [Documentation](https://doc.deno.land/https/deno.land/x/discordeno/mod.ts)
-- [Discord](https://discord.com/invite/5vBgXk3UcZ)
+# Discordeno benchmark database
diff --git a/bot.ts b/bot.ts
deleted file mode 100644
index cb44c2ddd..000000000
--- a/bot.ts
+++ /dev/null
@@ -1,953 +0,0 @@
-import { createGatewayManager } from "./gateway/manager/gatewayManager.ts";
-import * as handlers from "./handlers/mod.ts";
-import * as helpers from "./helpers/mod.ts";
-import { createRestManager, CreateRestManagerOptions } from "./rest/mod.ts";
-import { transformActivity } from "./transformers/activity.ts";
-import { transformApplication } from "./transformers/application.ts";
-import { transformApplicationCommand } from "./transformers/applicationCommand.ts";
-import { transformApplicationCommandOption } from "./transformers/applicationCommandOption.ts";
-import { transformApplicationCommandPermission } from "./transformers/applicationCommandPermission.ts";
-import { transformAttachment } from "./transformers/attachment.ts";
-import { transformAuditLogEntry } from "./transformers/auditLogEntry.ts";
-import { transformComponent } from "./transformers/component.ts";
-import { transformEmbed } from "./transformers/embed.ts";
-import { Emoji, transformEmoji } from "./transformers/emoji.ts";
-import { GetGatewayBot, transformGatewayBot } from "./transformers/gatewayBot.ts";
-import { Integration, transformIntegration } from "./transformers/integration.ts";
-import {
- Interaction,
- InteractionDataOption,
- transformInteraction,
- transformInteractionDataOption,
-} from "./transformers/interaction.ts";
-import { Invite, transformInvite } from "./transformers/invite.ts";
-import {
- Channel,
- Guild,
- Member,
- Message,
- Role,
- ScheduledEvent,
- Template,
- transformApplicationCommandToDiscordApplicationCommand,
- transformAttachmentToDiscordAttachment,
- transformChannel,
- transformGuild,
- transformMember,
- transformMessage,
- transformRole,
- transformTemplate,
- transformUser,
- transformVoiceState,
- User,
- VoiceState,
-} from "./transformers/mod.ts";
-import { PresenceUpdate, transformPresence } from "./transformers/presence.ts";
-import { transformScheduledEvent } from "./transformers/scheduledEvent.ts";
-import { transformStageInstance } from "./transformers/stageInstance.ts";
-import { StickerPack, transformSticker, transformStickerPack } from "./transformers/sticker.ts";
-import { transformTeam } from "./transformers/team.ts";
-import { ThreadMember, transformThreadMember } from "./transformers/threadMember.ts";
-import { transformVoiceRegion } from "./transformers/voiceRegion.ts";
-import { transformWebhook } from "./transformers/webhook.ts";
-import { transformWelcomeScreen } from "./transformers/welcomeScreen.ts";
-import { transformWidget } from "./transformers/widget.ts";
-import { transformWidgetSettings } from "./transformers/widgetSettings.ts";
-import {
- DiscordAllowedMentions,
- DiscordApplicationCommandOptionChoice,
- DiscordAutoModerationActionExecution,
- DiscordAutoModerationRule,
- DiscordCreateApplicationCommand,
- DiscordEmoji,
- DiscordGatewayPayload,
- DiscordInteractionDataOption,
- DiscordInteractionResponse,
- DiscordReady,
- DiscordStickerPack,
- DiscordTemplate,
-} from "./types/discord.ts";
-import { BigString, Errors, GatewayDispatchEventNames, GatewayIntents } from "./types/shared.ts";
-import { bigintToSnowflake, snowflakeToBigint } from "./util/bigint.ts";
-import { calculateShardId } from "./util/calculateShardId.ts";
-import { Collection } from "./util/collection.ts";
-import {
- baseEndpoints,
- CHANNEL_MENTION_REGEX,
- CONTEXT_MENU_COMMANDS_NAME_REGEX,
- DISCORD_SNOWFLAKE_REGEX,
- DISCORDENO_VERSION,
- SLASH_COMMANDS_NAME_REGEX,
- USER_AGENT,
-} from "./util/constants.ts";
-import { iconBigintToHash, iconHashToBigInt } from "./util/hash.ts";
-import { calculateBits, calculatePermissions } from "./util/permissions.ts";
-import { urlToBase64 } from "./util/urlToBase64.ts";
-import { delay, formatImageURL } from "./util/utils.ts";
-import { validateLength } from "./util/validateLength.ts";
-
-import {
- DiscordActivity,
- DiscordApplication,
- DiscordApplicationCommand,
- DiscordApplicationCommandOption,
- DiscordAttachment,
- DiscordAuditLogEntry,
- DiscordChannel,
- DiscordComponent,
- DiscordEmbed,
- DiscordGetGatewayBot,
- DiscordGuild,
- DiscordGuildApplicationCommandPermissions,
- DiscordGuildWidget,
- DiscordGuildWidgetSettings,
- DiscordIntegrationCreateUpdate,
- DiscordInteraction,
- DiscordInviteCreate,
- DiscordMember,
- DiscordMessage,
- DiscordPresenceUpdate,
- DiscordRole,
- DiscordScheduledEvent,
- DiscordStageInstance,
- DiscordSticker,
- DiscordTeam,
- DiscordThreadMember,
- DiscordUser,
- DiscordVoiceRegion,
- DiscordVoiceState,
- DiscordWebhook,
- DiscordWelcomeScreen,
-} from "./types/discord.ts";
-
-import { CreateShardManager } from "./gateway/manager/shardManager.ts";
-import {
- AllowedMentions,
- CreateApplicationCommand,
- InteractionResponse,
- ShardSocketCloseCodes,
- transformApplicationCommandOptionChoiceToDiscordApplicationCommandOptionChoice,
- transformApplicationCommandOptionToDiscordApplicationCommandOption,
-} from "./mod.ts";
-import { Activity } from "./transformers/activity.ts";
-import { Application } from "./transformers/application.ts";
-import { ApplicationCommand } from "./transformers/applicationCommand.ts";
-import { ApplicationCommandOption } from "./transformers/applicationCommandOption.ts";
-import {
- ApplicationCommandOptionChoice,
- transformApplicationCommandOptionChoice,
-} from "./transformers/applicationCommandOptionChoice.ts";
-import { ApplicationCommandPermission } from "./transformers/applicationCommandPermission.ts";
-import { Attachment } from "./transformers/attachment.ts";
-import { AuditLogEntry } from "./transformers/auditLogEntry.ts";
-import {
- AutoModerationActionExecution,
- transformAutoModerationActionExecution,
-} from "./transformers/automodActionExecution.ts";
-import { AutoModerationRule, transformAutoModerationRule } from "./transformers/automodRule.ts";
-import { Component } from "./transformers/component.ts";
-import { Embed } from "./transformers/embed.ts";
-import { transformActivityToDiscordActivity } from "./transformers/reverse/activity.ts";
-import { transformAllowedMentionsToDiscordAllowedMentions } from "./transformers/reverse/allowedMentions.ts";
-import { transformApplicationToDiscordApplication } from "./transformers/reverse/application.ts";
-import { transformComponentToDiscordComponent } from "./transformers/reverse/component.ts";
-import { transformCreateApplicationCommandToDiscordCreateApplicationCommand } from "./transformers/reverse/createApplicationCommand.ts";
-import { transformEmbedToDiscordEmbed } from "./transformers/reverse/embed.ts";
-import { transformInteractionResponseToDiscordInteractionResponse } from "./transformers/reverse/interactionResponse.ts";
-import { transformMemberToDiscordMember, transformUserToDiscordUser } from "./transformers/reverse/member.ts";
-import { transformTeamToDiscordTeam } from "./transformers/reverse/team.ts";
-import { StageInstance } from "./transformers/stageInstance.ts";
-import { Sticker } from "./transformers/sticker.ts";
-import { Team } from "./transformers/team.ts";
-import { VoiceRegions } from "./transformers/voiceRegion.ts";
-import { Webhook } from "./transformers/webhook.ts";
-import { WelcomeScreen } from "./transformers/welcomeScreen.ts";
-import { GuildWidget } from "./transformers/widget.ts";
-import { GuildWidgetSettings } from "./transformers/widgetSettings.ts";
-import { routes } from "./util/routes.ts";
-import { getBotIdFromToken, removeTokenPrefix } from "./util/token.ts";
-
-export function createBot(options: CreateBotOptions): Bot {
- const bot = {
- id: options.botId ?? getBotIdFromToken(options.token),
- applicationId: options.applicationId || options.botId || getBotIdFromToken(options.token),
- token: removeTokenPrefix(options.token),
- events: createEventHandlers(options.events ?? {}),
- intents: options.intents,
- botGatewayData: options.botGatewayData,
- activeGuildIds: new Set(),
- constants: createBotConstants(),
- handlers: createBotGatewayHandlers({}),
- utils: createUtils(options.utils ?? {}),
- transformers: createTransformers(options.transformers ?? {}),
- enabledPlugins: new Set(),
- handleDiscordPayload: options.handleDiscordPayload,
- cache: {
- unrepliedInteractions: new Set(),
- fetchAllMembersProcessingRequests: new Map(),
- },
- rest: createRestManager({
- token: options.token,
- debug: options.events?.debug,
- secretKey: options.secretKey ?? undefined,
- }),
- } as Bot;
-
- bot.helpers = createHelpers(bot, options.helpers ?? {});
- bot.gateway = createGatewayManager({
- gatewayBot: bot.botGatewayData ?? {} as any,
- gatewayConfig: {
- token: options.token,
- intents: options.intents,
- },
-
- debug: bot.events.debug,
-
- handleDiscordPayload: bot.handleDiscordPayload ??
- async function (shard, data: DiscordGatewayPayload) {
- // TRIGGER RAW EVENT
- bot.events.raw(bot as Bot, data, shard.id);
-
- if (!data.t) return;
-
- // RUN DISPATCH CHECK
- await bot.events.dispatchRequirements(bot as Bot, data, shard.id);
- bot.handlers[data.t as GatewayDispatchEventNames]?.(
- bot as Bot,
- data,
- shard.id,
- );
- },
- });
-
- return bot as Bot;
-}
-
-export function createEventHandlers(
- events: Partial,
-): EventHandlers {
- function ignore() {}
-
- return {
- debug: events.debug ?? ignore,
- automodRuleCreate: events.automodRuleCreate ?? ignore,
- automodRuleUpdate: events.automodRuleUpdate ?? ignore,
- automodRuleDelete: events.automodRuleDelete ?? ignore,
- automodActionExecution: events.automodActionExecution ?? ignore,
- threadCreate: events.threadCreate ?? ignore,
- threadDelete: events.threadDelete ?? ignore,
- threadMemberUpdate: events.threadMemberUpdate ?? ignore,
- threadMembersUpdate: events.threadMembersUpdate ?? ignore,
- threadUpdate: events.threadUpdate ?? ignore,
- scheduledEventCreate: events.scheduledEventCreate ?? ignore,
- scheduledEventUpdate: events.scheduledEventUpdate ?? ignore,
- scheduledEventDelete: events.scheduledEventDelete ?? ignore,
- scheduledEventUserAdd: events.scheduledEventUserAdd ?? ignore,
- scheduledEventUserRemove: events.scheduledEventUserRemove ?? ignore,
- ready: events.ready ?? ignore,
- dispatchRequirements: events.dispatchRequirements ?? ignore,
- integrationCreate: events.integrationCreate ?? ignore,
- integrationDelete: events.integrationDelete ?? ignore,
- integrationUpdate: events.integrationUpdate ?? ignore,
- interactionCreate: events.interactionCreate ?? ignore,
- inviteCreate: events.inviteCreate ?? ignore,
- inviteDelete: events.inviteDelete ?? ignore,
- guildMemberAdd: events.guildMemberAdd ?? ignore,
- guildMemberRemove: events.guildMemberRemove ?? ignore,
- guildMemberUpdate: events.guildMemberUpdate ?? ignore,
- messageCreate: events.messageCreate ?? ignore,
- messageDelete: events.messageDelete ?? ignore,
- messageDeleteBulk: events.messageDeleteBulk ?? ignore,
- messageUpdate: events.messageUpdate ?? ignore,
- reactionAdd: events.reactionAdd ?? ignore,
- reactionRemove: events.reactionRemove ?? ignore,
- reactionRemoveAll: events.reactionRemoveAll ?? ignore,
- reactionRemoveEmoji: events.reactionRemoveEmoji ?? ignore,
- presenceUpdate: events.presenceUpdate ?? ignore,
- voiceServerUpdate: events.voiceServerUpdate ?? ignore,
- voiceStateUpdate: events.voiceStateUpdate ?? ignore,
- channelCreate: events.channelCreate ?? ignore,
- channelDelete: events.channelDelete ?? ignore,
- channelPinsUpdate: events.channelPinsUpdate ?? ignore,
- channelUpdate: events.channelUpdate ?? ignore,
- guildEmojisUpdate: events.guildEmojisUpdate ?? ignore,
- guildBanAdd: events.guildBanAdd ?? ignore,
- guildBanRemove: events.guildBanRemove ?? ignore,
- guildCreate: events.guildCreate ?? ignore,
- guildDelete: events.guildDelete ?? ignore,
- guildUpdate: events.guildUpdate ?? ignore,
- raw: events.raw ?? ignore,
- stageInstanceCreate: events.stageInstanceCreate ?? ignore,
- stageInstanceDelete: events.stageInstanceDelete ?? ignore,
- stageInstanceUpdate: events.stageInstanceUpdate ?? ignore,
- roleCreate: events.roleCreate ?? ignore,
- roleDelete: events.roleDelete ?? ignore,
- roleUpdate: events.roleUpdate ?? ignore,
- webhooksUpdate: events.webhooksUpdate ?? ignore,
- botUpdate: events.botUpdate ?? ignore,
- typingStart: events.typingStart ?? ignore,
- };
-}
-
-export async function startBot(bot: Bot) {
- if (!Object.keys(bot.botGatewayData ?? {}).length) {
- bot.gateway.gatewayBot = await bot.helpers.getGatewayBot();
- bot.gateway.lastShardId = bot.gateway.gatewayBot.shards - 1;
- bot.gateway.manager.totalShards = bot.gateway.gatewayBot.shards;
- }
-
- bot.gateway.spawnShards();
-}
-
-export function createUtils(options: Partial) {
- return {
- snowflakeToBigint,
- bigintToSnowflake,
- calculateShardId,
- delay,
- iconHashToBigInt,
- iconBigintToHash,
- validateLength,
- urlToBase64,
- formatImageURL,
- calculateBits,
- calculatePermissions,
- };
-}
-
-export interface HelperUtils {
- snowflakeToBigint: typeof snowflakeToBigint;
- bigintToSnowflake: typeof bigintToSnowflake;
- calculateShardId: typeof calculateShardId;
- delay: typeof delay;
- iconHashToBigInt: typeof iconHashToBigInt;
- iconBigintToHash: typeof iconBigintToHash;
- validateLength: typeof validateLength;
- urlToBase64: typeof urlToBase64;
- formatImageURL: typeof formatImageURL;
- calculateBits: typeof calculateBits;
- calculatePermissions: typeof calculatePermissions;
-}
-
-export async function stopBot(bot: Bot) {
- await bot.gateway.stop(ShardSocketCloseCodes.Shutdown, "User requested bot stop");
-
- return bot;
-}
-
-export interface CreateBotOptions {
- token: string;
- botId?: bigint;
- applicationId?: bigint;
- secretKey?: string;
- events?: Partial;
- intents?: GatewayIntents;
- botGatewayData?: GetGatewayBot;
- rest?: Omit;
- handleDiscordPayload?: CreateShardManager["handleMessage"];
- utils?: Partial>;
- transformers?: Partial>;
- helpers?: Partial;
-}
-
-export type UnPromise> = T extends Promise ? K
- : never;
-
-export interface Bot {
- id: bigint;
- applicationId: bigint;
- token: string;
- intents: GatewayIntents;
- urlWSS: string;
- botGatewayData?: GetGatewayBot;
- utils: ReturnType;
- transformers: Transformers;
- helpers: ReturnType;
- rest: ReturnType;
- gateway: ReturnType;
- events: EventHandlers;
- handlers: ReturnType;
- activeGuildIds: Set;
- constants: ReturnType;
- cache: {
- unrepliedInteractions: Set;
- fetchAllMembersProcessingRequests: Map;
- };
- enabledPlugins: Set;
- handleDiscordPayload?: CreateShardManager["handleMessage"];
-}
-
-export const defaultHelpers = { ...helpers };
-export type DefaultHelpers = typeof defaultHelpers;
-// deno-lint-ignore no-empty-interface
-export interface Helpers extends DefaultHelpers {} // Use interface for declaration merging
-
-export function createHelpers(
- bot: Bot,
- customHelpers?: Partial,
-): FinalHelpers {
- const converted = {} as FinalHelpers;
- for (
- const [name, fun] of Object.entries({
- ...createBaseHelpers(customHelpers || {}),
- })
- ) {
- // @ts-ignore - TODO: make the types better
- converted[name as keyof FinalHelpers] = (
- // @ts-ignore - TODO: make the types better
- ...args: RemoveFirstFromTuple>
- ) =>
- // @ts-ignore - TODO: make the types better
- fun(bot, ...args);
- }
-
- return converted;
-}
-
-export function createBaseHelpers(options: Partial) {
- return {
- ...defaultHelpers,
- ...options,
- };
-}
-
-export interface Transformers {
- reverse: {
- allowedMentions: (bot: Bot, payload: AllowedMentions) => DiscordAllowedMentions;
- embed: (bot: Bot, payload: Embed) => DiscordEmbed;
- component: (bot: Bot, payload: Component) => DiscordComponent;
- activity: (bot: Bot, payload: Activity) => DiscordActivity;
- member: (bot: Bot, payload: Member) => DiscordMember;
- user: (bot: Bot, payload: User) => DiscordUser;
- team: (bot: Bot, payload: Team) => DiscordTeam;
- application: (bot: Bot, payload: Application) => DiscordApplication;
- snowflake: (snowflake: bigint) => string;
- createApplicationCommand: (bot: Bot, payload: CreateApplicationCommand) => DiscordCreateApplicationCommand;
- applicationCommand: (bot: Bot, payload: ApplicationCommand) => DiscordApplicationCommand;
- applicationCommandOption: (bot: Bot, payload: ApplicationCommandOption) => DiscordApplicationCommandOption;
- applicationCommandOptionChoice: (
- bot: Bot,
- payload: ApplicationCommandOptionChoice,
- ) => DiscordApplicationCommandOptionChoice;
- interactionResponse: (bot: Bot, payload: InteractionResponse) => DiscordInteractionResponse;
- attachment: (bot: Bot, payload: Attachment) => DiscordAttachment;
- };
- snowflake: (snowflake: BigString) => bigint;
- gatewayBot: (payload: DiscordGetGatewayBot) => GetGatewayBot;
- automodRule: (bot: Bot, payload: DiscordAutoModerationRule) => AutoModerationRule;
- automodActionExecution: (bot: Bot, payload: DiscordAutoModerationActionExecution) => AutoModerationActionExecution;
- channel: (bot: Bot, payload: { channel: DiscordChannel } & { guildId?: bigint }) => Channel;
- guild: (bot: Bot, payload: { guild: DiscordGuild } & { shardId: number }) => Guild;
- user: (bot: Bot, payload: DiscordUser) => User;
- member: (bot: Bot, payload: DiscordMember, guildId: bigint, userId: bigint) => Member;
- message: (bot: Bot, payload: DiscordMessage) => Message;
- role: (bot: Bot, payload: { role: DiscordRole } & { guildId: bigint }) => Role;
- voiceState: (bot: Bot, payload: { voiceState: DiscordVoiceState } & { guildId: bigint }) => VoiceState;
- interaction: (bot: Bot, payload: DiscordInteraction) => Interaction;
- interactionDataOptions: (bot: Bot, payload: DiscordInteractionDataOption) => InteractionDataOption;
- integration: (bot: Bot, payload: DiscordIntegrationCreateUpdate) => Integration;
- invite: (bot: Bot, invite: DiscordInviteCreate) => Invite;
- application: (bot: Bot, payload: DiscordApplication) => Application;
- team: (bot: Bot, payload: DiscordTeam) => Team;
- emoji: (bot: Bot, payload: DiscordEmoji) => Emoji;
- activity: (bot: Bot, payload: DiscordActivity) => Activity;
- presence: (bot: Bot, payload: DiscordPresenceUpdate) => PresenceUpdate;
- attachment: (bot: Bot, payload: DiscordAttachment) => Attachment;
- embed: (bot: Bot, payload: DiscordEmbed) => Embed;
- component: (bot: Bot, payload: DiscordComponent) => Component;
- webhook: (bot: Bot, payload: DiscordWebhook) => Webhook;
- auditLogEntry: (bot: Bot, payload: DiscordAuditLogEntry) => AuditLogEntry;
- applicationCommand: (bot: Bot, payload: DiscordApplicationCommand) => ApplicationCommand;
- applicationCommandOption: (bot: Bot, payload: DiscordApplicationCommandOption) => ApplicationCommandOption;
- applicationCommandPermission: (
- bot: Bot,
- payload: DiscordGuildApplicationCommandPermissions,
- ) => ApplicationCommandPermission;
- scheduledEvent: (bot: Bot, payload: DiscordScheduledEvent) => ScheduledEvent;
- threadMember: (bot: Bot, payload: DiscordThreadMember) => ThreadMember;
- welcomeScreen: (bot: Bot, payload: DiscordWelcomeScreen) => WelcomeScreen;
- voiceRegion: (bot: Bot, payload: DiscordVoiceRegion) => VoiceRegions;
- widget: (bot: Bot, payload: DiscordGuildWidget) => GuildWidget;
- widgetSettings: (bot: Bot, payload: DiscordGuildWidgetSettings) => GuildWidgetSettings;
- stageInstance: (bot: Bot, payload: DiscordStageInstance) => StageInstance;
- sticker: (bot: Bot, payload: DiscordSticker) => Sticker;
- stickerPack: (bot: Bot, payload: DiscordStickerPack) => StickerPack;
- applicationCommandOptionChoice: (
- bot: Bot,
- payload: DiscordApplicationCommandOptionChoice,
- ) => ApplicationCommandOptionChoice;
- template: (bot: Bot, payload: DiscordTemplate) => Template;
-}
-
-export function createTransformers(options: Partial) {
- return {
- reverse: {
- allowedMentions: options.reverse?.allowedMentions || transformAllowedMentionsToDiscordAllowedMentions,
- embed: options.reverse?.embed || transformEmbedToDiscordEmbed,
- component: options.reverse?.component || transformComponentToDiscordComponent,
- activity: options.reverse?.activity || transformActivityToDiscordActivity,
- member: options.reverse?.member || transformMemberToDiscordMember,
- user: options.reverse?.user || transformUserToDiscordUser,
- team: options.reverse?.team || transformTeamToDiscordTeam,
- application: options.reverse?.application || transformApplicationToDiscordApplication,
- snowflake: options.reverse?.snowflake || bigintToSnowflake,
- createApplicationCommand: options.reverse?.createApplicationCommand ||
- transformCreateApplicationCommandToDiscordCreateApplicationCommand,
- applicationCommand: options.reverse?.applicationCommand ||
- transformApplicationCommandToDiscordApplicationCommand,
- applicationCommandOption: options.reverse?.applicationCommandOption ||
- transformApplicationCommandOptionToDiscordApplicationCommandOption,
- applicationCommandOptionChoice: options.reverse?.applicationCommandOptionChoice ||
- transformApplicationCommandOptionChoiceToDiscordApplicationCommandOptionChoice,
- interactionResponse: options.reverse?.interactionResponse ||
- transformInteractionResponseToDiscordInteractionResponse,
- attachment: options.reverse?.attachment || transformAttachmentToDiscordAttachment,
- },
- automodRule: options.automodRule || transformAutoModerationRule,
- automodActionExecution: options.automodActionExecution || transformAutoModerationActionExecution,
- activity: options.activity || transformActivity,
- application: options.application || transformApplication,
- attachment: options.attachment || transformAttachment,
- channel: options.channel || transformChannel,
- component: options.component || transformComponent,
- embed: options.embed || transformEmbed,
- emoji: options.emoji || transformEmoji,
- guild: options.guild || transformGuild,
- integration: options.integration || transformIntegration,
- interaction: options.interaction || transformInteraction,
- interactionDataOptions: options.interactionDataOptions || transformInteractionDataOption,
- invite: options.invite || transformInvite,
- member: options.member || transformMember,
- message: options.message || transformMessage,
- presence: options.presence || transformPresence,
- role: options.role || transformRole,
- user: options.user || transformUser,
- team: options.team || transformTeam,
- voiceState: options.voiceState || transformVoiceState,
- snowflake: options.snowflake || snowflakeToBigint,
- webhook: options.webhook || transformWebhook,
- auditLogEntry: options.auditLogEntry || transformAuditLogEntry,
- applicationCommand: options.applicationCommand ||
- transformApplicationCommand,
- applicationCommandOption: options.applicationCommandOption ||
- transformApplicationCommandOption,
- applicationCommandPermission: options.applicationCommandPermission ||
- transformApplicationCommandPermission,
- scheduledEvent: options.scheduledEvent || transformScheduledEvent,
- threadMember: options.threadMember || transformThreadMember,
- welcomeScreen: options.welcomeScreen || transformWelcomeScreen,
- voiceRegion: options.voiceRegion || transformVoiceRegion,
- widget: options.widget || transformWidget,
- widgetSettings: options.widgetSettings || transformWidgetSettings,
- stageInstance: options.stageInstance || transformStageInstance,
- sticker: options.sticker || transformSticker,
- stickerPack: options.stickerPack || transformStickerPack,
- gatewayBot: options.gatewayBot || transformGatewayBot,
- applicationCommandOptionChoice: options.applicationCommandOptionChoice || transformApplicationCommandOptionChoice,
- template: options.template || transformTemplate,
- };
-}
-
-export interface EventHandlers {
- debug: (text: string, ...args: any[]) => unknown;
- automodRuleCreate: (bot: Bot, rule: AutoModerationRule) => unknown;
- automodRuleUpdate: (bot: Bot, rule: AutoModerationRule) => unknown;
- automodRuleDelete: (bot: Bot, rule: AutoModerationRule) => unknown;
- automodActionExecution: (bot: Bot, payload: AutoModerationActionExecution) => unknown;
- threadCreate: (bot: Bot, thread: Channel) => unknown;
- threadDelete: (bot: Bot, thread: Channel) => unknown;
- threadMemberUpdate: (bot: Bot, payload: {
- id: bigint;
- guildId: bigint;
- joinedAt: number;
- flags: number;
- }) => unknown;
- threadMembersUpdate: (
- bot: Bot,
- payload: {
- id: bigint;
- guildId: bigint;
- addedMembers?: ThreadMember[];
- removedMemberIds?: bigint[];
- },
- ) => unknown;
- threadUpdate: (bot: Bot, thread: Channel) => unknown;
- scheduledEventCreate: (bot: Bot, event: ScheduledEvent) => unknown;
- scheduledEventUpdate: (bot: Bot, event: ScheduledEvent) => unknown;
- scheduledEventDelete: (bot: Bot, event: ScheduledEvent) => unknown;
- /** Sent when a user has subscribed to a guild scheduled event. EXPERIMENTAL! */
- scheduledEventUserAdd: (
- bot: Bot,
- payload: {
- guildScheduledEventId: bigint;
- guildId: bigint;
- userId: bigint;
- },
- ) => unknown;
- /** Sent when a user has unsubscribed to a guild scheduled event. EXPERIMENTAL! */
- scheduledEventUserRemove: (
- bot: Bot,
- payload: {
- guildScheduledEventId: bigint;
- guildId: bigint;
- userId: bigint;
- },
- ) => unknown;
- ready: (
- bot: Bot,
- payload: {
- shardId: number;
- v: number;
- user: User;
- guilds: bigint[];
- sessionId: string;
- shard?: number[];
- applicationId: bigint;
- },
- rawPayload: DiscordReady,
- ) => unknown;
- interactionCreate: (bot: Bot, interaction: Interaction) => unknown;
- integrationCreate: (bot: Bot, integration: Integration) => unknown;
- integrationDelete: (
- bot: Bot,
- payload: { id: bigint; guildId: bigint; applicationId?: bigint },
- ) => unknown;
- integrationUpdate: (bot: Bot, payload: { guildId: bigint }) => unknown;
- inviteCreate: (bot: Bot, invite: Invite) => unknown;
- inviteDelete: (
- bot: Bot,
- payload: {
- channelId: bigint;
- guildId?: bigint;
- code: string;
- },
- ) => unknown;
- guildMemberAdd: (
- bot: Bot,
- member: Member,
- user: User,
- ) => unknown;
- guildMemberRemove: (bot: Bot, user: User, guildId: bigint) => unknown;
- guildMemberUpdate: (
- bot: Bot,
- member: Member,
- user: User,
- ) => unknown;
- messageCreate: (bot: Bot, message: Message) => unknown;
- messageDelete: (
- bot: Bot,
- payload: { id: bigint; channelId: bigint; guildId?: bigint },
- message?: Message,
- ) => unknown;
- messageDeleteBulk: (bot: Bot, payload: { ids: bigint[]; channelId: bigint; guildId?: bigint }) => unknown;
- messageUpdate: (
- bot: Bot,
- message: Message,
- oldMessage?: Message,
- ) => unknown;
- reactionAdd: (
- bot: Bot,
- payload: {
- userId: bigint;
- channelId: bigint;
- messageId: bigint;
- guildId?: bigint;
- member?: Member;
- user?: User;
- emoji: Emoji;
- },
- ) => unknown;
- reactionRemove: (
- bot: Bot,
- payload: {
- userId: bigint;
- channelId: bigint;
- messageId: bigint;
- guildId?: bigint;
- emoji: Emoji;
- },
- ) => unknown;
- reactionRemoveEmoji: (
- bot: Bot,
- payload: {
- channelId: bigint;
- messageId: bigint;
- guildId?: bigint;
- emoji: Emoji;
- },
- ) => unknown;
- reactionRemoveAll: (
- bot: Bot,
- payload: {
- channelId: bigint;
- messageId: bigint;
- guildId?: bigint;
- },
- ) => unknown;
- presenceUpdate: (
- bot: Bot,
- presence: PresenceUpdate,
- oldPresence?: PresenceUpdate,
- ) => unknown;
- voiceServerUpdate: (
- bot: Bot,
- payload: { token: string; endpoint?: string; guildId: bigint },
- ) => unknown;
- voiceStateUpdate: (
- bot: Bot,
- voiceState: VoiceState,
- ) => unknown;
- channelCreate: (bot: Bot, channel: Channel) => unknown;
- dispatchRequirements: (
- bot: Bot,
- data: DiscordGatewayPayload,
- shardId: number,
- ) => unknown;
- channelDelete: (bot: Bot, channel: Channel) => unknown;
- channelPinsUpdate: (
- bot: Bot,
- data: { guildId?: bigint; channelId: bigint; lastPinTimestamp?: number },
- ) => unknown;
- channelUpdate: (bot: Bot, channel: Channel) => unknown;
- stageInstanceCreate: (
- bot: Bot,
- data: {
- id: bigint;
- guildId: bigint;
- channelId: bigint;
- topic: string;
- },
- ) => unknown;
- stageInstanceDelete: (
- bot: Bot,
- data: {
- id: bigint;
- guildId: bigint;
- channelId: bigint;
- topic: string;
- },
- ) => unknown;
- stageInstanceUpdate: (
- bot: Bot,
- data: {
- id: bigint;
- guildId: bigint;
- channelId: bigint;
- topic: string;
- },
- ) => unknown;
- guildEmojisUpdate: (
- bot: Bot,
- payload: {
- guildId: bigint;
- emojis: Collection;
- },
- ) => unknown;
- guildBanAdd: (bot: Bot, user: User, guildId: bigint) => unknown;
- guildBanRemove: (bot: Bot, user: User, guildId: bigint) => unknown;
- guildCreate: (bot: Bot, guild: Guild) => unknown;
- guildDelete: (bot: Bot, id: bigint, shardId: number) => unknown;
- guildUpdate: (bot: Bot, guild: Guild) => unknown;
- raw: (bot: Bot, data: DiscordGatewayPayload, shardId: number) => unknown;
- roleCreate: (bot: Bot, role: Role) => unknown;
- roleDelete: (bot: Bot, payload: { guildId: bigint; roleId: bigint }) => unknown;
- roleUpdate: (bot: Bot, role: Role) => unknown;
- webhooksUpdate: (
- bot: Bot,
- payload: { channelId: bigint; guildId: bigint },
- ) => unknown;
- botUpdate: (bot: Bot, user: User) => unknown;
- typingStart: (
- bot: Bot,
- payload: {
- guildId: bigint | undefined;
- channelId: bigint;
- userId: bigint;
- timestamp: number;
- member: Member | undefined;
- },
- ) => unknown;
-}
-
-export function createBotConstants() {
- return {
- DISCORDENO_VERSION,
- USER_AGENT,
- BASE_URL: baseEndpoints.BASE_URL,
- CDN_URL: baseEndpoints.CDN_URL,
- routes,
- regexes: {
- SLASH_COMMANDS_NAME_REGEX,
- CONTEXT_MENU_COMMANDS_NAME_REGEX,
- CHANNEL_MENTION_REGEX,
- DISCORD_SNOWFLAKE_REGEX,
- },
- Errors,
- };
-}
-
-export interface BotGatewayHandlerOptions {
- READY: typeof handlers.handleReady;
- CHANNEL_CREATE: typeof handlers.handleChannelCreate;
- CHANNEL_DELETE: typeof handlers.handleChannelDelete;
- CHANNEL_PINS_UPDATE: typeof handlers.handleChannelPinsUpdate;
- CHANNEL_UPDATE: typeof handlers.handleChannelUpdate;
- THREAD_CREATE: typeof handlers.handleThreadCreate;
- THREAD_UPDATE: typeof handlers.handleThreadUpdate;
- THREAD_DELETE: typeof handlers.handleThreadDelete;
- THREAD_LIST_SYNC: typeof handlers.handleThreadListSync;
- THREAD_MEMBERS_UPDATE: typeof handlers.handleThreadMembersUpdate;
- STAGE_INSTANCE_CREATE: typeof handlers.handleStageInstanceCreate;
- STAGE_INSTANCE_UPDATE: typeof handlers.handleStageInstanceUpdate;
- STAGE_INSTANCE_DELETE: typeof handlers.handleStageInstanceDelete;
- GUILD_BAN_ADD: typeof handlers.handleGuildBanAdd;
- GUILD_BAN_REMOVE: typeof handlers.handleGuildBanRemove;
- GUILD_CREATE: typeof handlers.handleGuildCreate;
- GUILD_DELETE: typeof handlers.handleGuildDelete;
- GUILD_EMOJIS_UPDATE: typeof handlers.handleGuildEmojisUpdate;
- GUILD_INTEGRATIONS_UPDATE: typeof handlers.handleGuildIntegrationsUpdate;
- GUILD_MEMBER_ADD: typeof handlers.handleGuildMemberAdd;
- GUILD_MEMBER_REMOVE: typeof handlers.handleGuildMemberRemove;
- GUILD_MEMBER_UPDATE: typeof handlers.handleGuildMemberUpdate;
- GUILD_MEMBERS_CHUNK: typeof handlers.handleGuildMembersChunk;
- GUILD_ROLE_CREATE: typeof handlers.handleGuildRoleCreate;
- GUILD_ROLE_DELETE: typeof handlers.handleGuildRoleDelete;
- GUILD_ROLE_UPDATE: typeof handlers.handleGuildRoleUpdate;
- GUILD_SCHEDULED_EVENT_CREATE: typeof handlers.handleGuildScheduledEventCreate;
- GUILD_SCHEDULED_EVENT_DELETE: typeof handlers.handleGuildScheduledEventDelete;
- GUILD_SCHEDULED_EVENT_UPDATE: typeof handlers.handleGuildScheduledEventUpdate;
- GUILD_SCHEDULED_EVENT_USER_ADD: typeof handlers.handleGuildScheduledEventUserAdd;
- GUILD_SCHEDULED_EVENT_USER_REMOVE: typeof handlers.handleGuildScheduledEventUserRemove;
- GUILD_UPDATE: typeof handlers.handleGuildUpdate;
- INTERACTION_CREATE: typeof handlers.handleInteractionCreate;
- INVITE_CREATE: typeof handlers.handleInviteCreate;
- INVITE_DELETE: typeof handlers.handleInviteCreate;
- MESSAGE_CREATE: typeof handlers.handleMessageCreate;
- MESSAGE_DELETE_BULK: typeof handlers.handleMessageDeleteBulk;
- MESSAGE_DELETE: typeof handlers.handleMessageDelete;
- MESSAGE_REACTION_ADD: typeof handlers.handleMessageReactionAdd;
- MESSAGE_REACTION_REMOVE_ALL: typeof handlers.handleMessageReactionRemoveAll;
- MESSAGE_REACTION_REMOVE_EMOJI: typeof handlers.handleMessageReactionRemoveEmoji;
- MESSAGE_REACTION_REMOVE: typeof handlers.handleMessageReactionRemove;
- MESSAGE_UPDATE: typeof handlers.handleMessageUpdate;
- PRESENCE_UPDATE: typeof handlers.handlePresenceUpdate;
- TYPING_START: typeof handlers.handleTypingStart;
- USER_UPDATE: typeof handlers.handleUserUpdate;
- VOICE_SERVER_UPDATE: typeof handlers.handleVoiceServerUpdate;
- VOICE_STATE_UPDATE: typeof handlers.handleVoiceStateUpdate;
- WEBHOOKS_UPDATE: typeof handlers.handleWebhooksUpdate;
- INTEGRATION_CREATE: typeof handlers.handleIntegrationCreate;
- INTEGRATION_UPDATE: typeof handlers.handleIntegrationUpdate;
- INTEGRATION_DELETE: typeof handlers.handleIntegrationDelete;
-}
-
-export function createBotGatewayHandlers(
- options: Partial,
-): Record<
- GatewayDispatchEventNames,
- (bot: Bot, data: DiscordGatewayPayload, shardId: number) => any
-> {
- return {
- // misc
- READY: options.READY ?? handlers.handleReady,
- // channels
- CHANNEL_CREATE: options.CHANNEL_CREATE ?? handlers.handleChannelCreate,
- CHANNEL_DELETE: options.CHANNEL_DELETE ?? handlers.handleChannelDelete,
- CHANNEL_PINS_UPDATE: options.CHANNEL_PINS_UPDATE ??
- handlers.handleChannelPinsUpdate,
- CHANNEL_UPDATE: options.CHANNEL_UPDATE ?? handlers.handleChannelUpdate,
- THREAD_CREATE: options.THREAD_CREATE ?? handlers.handleThreadCreate,
- THREAD_UPDATE: options.THREAD_UPDATE ?? handlers.handleThreadUpdate,
- THREAD_DELETE: options.THREAD_DELETE ?? handlers.handleThreadDelete,
- THREAD_LIST_SYNC: options.THREAD_LIST_SYNC ?? handlers.handleThreadListSync,
- THREAD_MEMBERS_UPDATE: options.THREAD_MEMBERS_UPDATE ?? handlers.handleThreadMembersUpdate,
- STAGE_INSTANCE_CREATE: options.STAGE_INSTANCE_CREATE ??
- handlers.handleStageInstanceCreate,
- STAGE_INSTANCE_UPDATE: options.STAGE_INSTANCE_UPDATE ??
- handlers.handleStageInstanceUpdate,
- STAGE_INSTANCE_DELETE: options.STAGE_INSTANCE_DELETE ??
- handlers.handleStageInstanceDelete,
-
- // guilds
- GUILD_BAN_ADD: options.GUILD_BAN_ADD ?? handlers.handleGuildBanAdd,
- GUILD_BAN_REMOVE: options.GUILD_BAN_REMOVE ?? handlers.handleGuildBanRemove,
- GUILD_CREATE: options.GUILD_CREATE ?? handlers.handleGuildCreate,
- GUILD_DELETE: options.GUILD_DELETE ?? handlers.handleGuildDelete,
- GUILD_EMOJIS_UPDATE: options.GUILD_EMOJIS_UPDATE ??
- handlers.handleGuildEmojisUpdate,
- GUILD_INTEGRATIONS_UPDATE: options.GUILD_INTEGRATIONS_UPDATE ??
- handlers.handleGuildIntegrationsUpdate,
- GUILD_MEMBER_ADD: options.GUILD_MEMBER_ADD ?? handlers.handleGuildMemberAdd,
- GUILD_MEMBER_REMOVE: options.GUILD_MEMBER_REMOVE ??
- handlers.handleGuildMemberRemove,
- GUILD_MEMBER_UPDATE: options.GUILD_MEMBER_UPDATE ??
- handlers.handleGuildMemberUpdate,
- GUILD_MEMBERS_CHUNK: options.GUILD_MEMBERS_CHUNK ??
- handlers.handleGuildMembersChunk,
- GUILD_ROLE_CREATE: options.GUILD_ROLE_CREATE ??
- handlers.handleGuildRoleCreate,
- GUILD_ROLE_DELETE: options.GUILD_ROLE_DELETE ??
- handlers.handleGuildRoleDelete,
- GUILD_ROLE_UPDATE: options.GUILD_ROLE_UPDATE ??
- handlers.handleGuildRoleUpdate,
- GUILD_UPDATE: options.GUILD_UPDATE ?? handlers.handleGuildUpdate,
- // guild events
- GUILD_SCHEDULED_EVENT_CREATE: options.GUILD_SCHEDULED_EVENT_CREATE ??
- handlers.handleGuildScheduledEventCreate,
- GUILD_SCHEDULED_EVENT_DELETE: options.GUILD_SCHEDULED_EVENT_DELETE ??
- handlers.handleGuildScheduledEventDelete,
- GUILD_SCHEDULED_EVENT_UPDATE: options.GUILD_SCHEDULED_EVENT_UPDATE ??
- handlers.handleGuildScheduledEventUpdate,
- GUILD_SCHEDULED_EVENT_USER_ADD: options.GUILD_SCHEDULED_EVENT_USER_ADD ??
- handlers.handleGuildScheduledEventUserAdd,
- GUILD_SCHEDULED_EVENT_USER_REMOVE: options.GUILD_SCHEDULED_EVENT_USER_REMOVE ??
- handlers.handleGuildScheduledEventUserRemove,
- // interactions
- INTERACTION_CREATE: options.INTERACTION_CREATE ??
- handlers.handleInteractionCreate,
- // invites
- INVITE_CREATE: options.INVITE_CREATE ?? handlers.handleInviteCreate,
- INVITE_DELETE: options.INVITE_DELETE ?? handlers.handleInviteCreate,
- // messages
- MESSAGE_CREATE: options.MESSAGE_CREATE ?? handlers.handleMessageCreate,
- MESSAGE_DELETE_BULK: options.MESSAGE_DELETE_BULK ??
- handlers.handleMessageDeleteBulk,
- MESSAGE_DELETE: options.MESSAGE_DELETE ?? handlers.handleMessageDelete,
- MESSAGE_REACTION_ADD: options.MESSAGE_REACTION_ADD ??
- handlers.handleMessageReactionAdd,
- MESSAGE_REACTION_REMOVE_ALL: options.MESSAGE_REACTION_REMOVE_ALL ??
- handlers.handleMessageReactionRemoveAll,
- MESSAGE_REACTION_REMOVE_EMOJI: options.MESSAGE_REACTION_REMOVE_EMOJI ??
- handlers.handleMessageReactionRemoveEmoji,
- MESSAGE_REACTION_REMOVE: options.MESSAGE_REACTION_REMOVE ??
- handlers.handleMessageReactionRemove,
- MESSAGE_UPDATE: options.MESSAGE_UPDATE ?? handlers.handleMessageUpdate,
- // presence
- PRESENCE_UPDATE: options.PRESENCE_UPDATE ?? handlers.handlePresenceUpdate,
- TYPING_START: options.TYPING_START ?? handlers.handleTypingStart,
- USER_UPDATE: options.USER_UPDATE ?? handlers.handleUserUpdate,
- // voice
- VOICE_SERVER_UPDATE: options.VOICE_SERVER_UPDATE ??
- handlers.handleVoiceServerUpdate,
- VOICE_STATE_UPDATE: options.VOICE_STATE_UPDATE ??
- handlers.handleVoiceStateUpdate,
- // webhooks
- WEBHOOKS_UPDATE: options.WEBHOOKS_UPDATE ?? handlers.handleWebhooksUpdate,
- // integrations
- INTEGRATION_CREATE: options.INTEGRATION_CREATE ??
- handlers.handleIntegrationCreate,
- INTEGRATION_UPDATE: options.INTEGRATION_UPDATE ??
- handlers.handleIntegrationUpdate,
- INTEGRATION_DELETE: options.INTEGRATION_DELETE ??
- handlers.handleIntegrationDelete,
- };
-}
-
-export type RemoveFirstFromTuple = T["length"] extends 0 ? []
- : ((...b: T) => void) extends (a: any, ...b: infer I) => void ? I
- : [];
-export type FinalHelpers = {
- [K in keyof Helpers]: (
- ...args: RemoveFirstFromTuple>
- ) => ReturnType;
-};
diff --git a/cache/checkAndUpdateObjects.ts b/cache/checkAndUpdateObjects.ts
new file mode 100644
index 000000000..6b5cf7eb1
--- /dev/null
+++ b/cache/checkAndUpdateObjects.ts
@@ -0,0 +1,63 @@
+import { createBot } from "https://deno.land/x/discordeno@17.1.0/mod.ts";
+import {
+ hideDate,
+ hideEUDText,
+ hideHash,
+ hideSnowflake,
+ loopObject
+} from "https://raw.githubusercontent.com/discordeno/benchmarks/main/utils.ts";
+
+const token = Deno.env.get("DISCORD_TOKEN");
+if (!token) throw new Error("Token was not provided.");
+
+const guildId = 1034163795146330163n
+
+const bot = createBot({
+ token,
+ botId: BigInt(atob(token.split(".")[0])),
+});
+
+const sortValues = (object: any) => {
+ for (const key of Object.keys(object)) {
+ if (Array.isArray(object[key])) {
+ if (object[key].length > 0 && typeof object[key][0] === "object") {
+ object[key].forEach((element: any) => {
+ sortValues(element)
+ });
+ } else {
+ object[key].sort();
+ }
+ }
+ if (typeof object[key] === "object" && object[key] !== null) {
+ sortValues(object[key])
+ }
+ }
+}
+
+const cleanPayload = (payload: any) => loopObject(payload, (value, key) => {
+ if (typeof value !== "string") return value;
+
+ // IF ITS A NUMBER MASK NUMBER
+ if (/^\d+$/.test(value)) return hideSnowflake(value);
+ if (["icon", "banner", "splash", "avatar"].includes(key)) {
+ return hideHash(value);
+ }
+ // IF ITS DATE REGEX
+ if (Date.parse(value)) return hideDate();
+
+ return hideEUDText(value);
+});
+
+const guild = cleanPayload(await bot.rest.runMethod(bot.rest, "GET", bot.constants.routes.GUILD(guildId, true)))
+await Deno.writeTextFile(`cache/cachedObject/guild.json`, JSON.stringify(guild, undefined, 2))
+const channels = await bot.rest.runMethod(bot.rest, "GET", bot.constants.routes.GUILD_CHANNELS(guildId)) as any[];
+
+const channelNames = ["rules", "announcement-channel", "moderator-channel", "text-channel", "stage-channel", "voice-channel"]
+
+for (const channelName of channelNames) {
+ const channel = cleanPayload(channels.find((channel) => channel.name === channelName))
+ await Deno.writeTextFile(`cache/cachedObject/${channelName}.json`, JSON.stringify(channel, undefined, 2))
+}
+
+const user = cleanPayload(await bot.rest.runMethod(bot.rest, "GET", bot.constants.routes.USER(bot.id)));
+await Deno.writeTextFile(`cache/cachedObject/user.json`, JSON.stringify(user, undefined, 2))
diff --git a/deno.json b/deno.json
deleted file mode 100644
index 2ebd8fac9..000000000
--- a/deno.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "fmt": {
- "files": {
- "exclude": [
- "benchmarks/",
- "site/node_modules/",
- "site/build",
- "site/.docusaurus",
- "site/.cache-loader",
- "template/bigbot/node_modules"
- ]
- },
- "options": {
- "lineWidth": 120
- }
- }
-}
diff --git a/dnt.ts b/dnt.ts
deleted file mode 100644
index 63faf0751..000000000
--- a/dnt.ts
+++ /dev/null
@@ -1,157 +0,0 @@
-import { build } from "https://deno.land/x/dnt@0.30.0/mod.ts";
-
-await Deno.remove("npm", { recursive: true }).catch((_) => {});
-
-await build({
- shims: {
- deno: true,
- timers: true,
- blob: true,
- undici: true,
- custom: [
- {
- package: {
- name: "ws",
- version: "^8.4.0",
- },
- globalNames: [
- {
- name: "WebSocket",
- exportName: "default",
- },
- { name: "CloseEvent", typeOnly: true },
- { name: "MessageEvent", typeOnly: true },
- ],
- },
- ],
- },
- entryPoints: [
- "./mod.ts",
- {
- name: "./rest",
- path: "rest/mod.ts",
- },
- {
- name: "./gateway",
- path: "gateway/mod.ts",
- },
- {
- name: "./types",
- path: "types/mod.ts",
- },
- {
- name: "./transformers",
- path: "transformers/mod.ts",
- },
- {
- name: "./packages",
- path: "packages/mod.ts",
- },
- {
- name: "./logger",
- path: "packages/logger/mod.ts",
- },
- {
- name: "./embeds",
- path: "packages/embeds/mod.ts",
- },
- {
- name: "./plugins",
- path: "plugins/mod.ts",
- },
- {
- name: "./cache-plugin",
- path: "plugins/cache/mod.ts",
- },
- {
- name: "./fileloader-plugin",
- path: "plugins/fileloader/mod.ts",
- },
- {
- name: "./helpers-plugin",
- path: "plugins/helpers/mod.ts",
- },
- {
- name: "./permissions-plugin",
- path: "plugins/permissions/mod.ts",
- },
- ],
- outDir: "./npm",
- typeCheck: false,
- declaration: true,
- test: false,
- package: {
- name: "discordeno",
- version: Deno.args[0],
- description: "Discordeno is simplistic, easy-to-use, versatile while being efficient and lightweight.",
- keywords: [
- "javascript",
- "api",
- "library",
- "typescript",
- "discord",
- "discord-bot",
- "discord-api",
- "deno",
- "discordeno",
- ],
- author: "Skillz4Killz",
- license: "Apache License 2.0",
- bugs: {
- url: "https://github.com/discordeno/discordeno/issues",
- },
- homepage: "https://discordeno.mod.land",
- repository: {
- type: "git",
- url: "https://github.com/discordeno/discordeno",
- },
- typesVersions: {
- "*": {
- "*": [
- "./types/mod.d.ts",
- ],
- "rest": [
- "./types/rest/mod.d.ts",
- ],
- "gateway": [
- "./types/gateway/mod.d.ts",
- ],
- "types": [
- "./types/types/mod.d.ts",
- ],
- "transformers": [
- "./types/transformers/mod.d.ts",
- ],
- "packages": [
- "./types/packages/mod.d.ts",
- ],
- "logger": [
- "./types/packages/logger/mod.d.ts",
- ],
- "embeds": [
- "./types/packages/embeds/mod.d.ts",
- ],
- "plugins": [
- "./types/plugins/mod.d.ts",
- ],
- "cache-plugin": [
- "./types/plugins/cache/mod.d.ts",
- ],
- "fileloader-plugin": [
- "./types/plugins/fileloader/mod.d.ts",
- ],
- "helpers-plugin": [
- "./types/plugins/helpers/mod.d.ts",
- ],
- "permissions-plugin": [
- "./types/plugins/permissions/mod.d.ts",
- ],
- },
- },
- },
- compilerOptions: { target: "ES2020" },
-});
-
-// post build steps
-Deno.copyFileSync("LICENSE", "npm/LICENSE");
-Deno.copyFileSync("README.md", "npm/README.md");
diff --git a/gateway/README.md b/gateway/README.md
deleted file mode 100644
index d608547e2..000000000
--- a/gateway/README.md
+++ /dev/null
@@ -1,61 +0,0 @@
-# Standalone WS / Proxy WS
-
-This WS service is meant for ADVANCED DEVELOPERS ONLY!
-
-## Benefits
-
-- **Zero Downtime Updates**:
-
- - Your bot can be updated in a matter of seconds. With normal sharding, you have to restart which also has to process
- identifying all your shards with a 1/~5s rate limit. With WS handling moved to a proxy process, this allows you to
- instantly get the bot code restarted without any concerns of delays. If you have a bot on 200,000 servers normally
- this would mean a 20 minute delay to restart your bot if you made a small change and restarted.
-
-- **Zero Downtime Resharding**:
-
- - Discord stops letting your bot get added to new servers at certain points in time. For example, suppose you had
- 150,000 servers running 150 shards. The maximum amount of servers your shards could hold is 150 \* 2500 = 375,000.
- If your bot reaches this, it can no longer join new servers until it re-shards.
- - DD proxy provides 2 types of re-sharding. Automated and manual. You can also have both.
- - `Automated`: This system will automatically begin a Zero-downtime resharding process behind the scenes when you
- reach 80% of your maximum servers allowed by your shards. For example, since 375,000 was the max, at 300,000 we
- would begin re-sharding behind the scenes with `ZERO DOWNTIME`.
- - 80% of maximum servers reached (The % of 80% is customizable.)
- - Identify limits have room to allow re-sharding. (Also customizable)
- - `Manual`: You can also trigger this manually should you choose.
-
-- **Horizontal Scaling**:
-
- - The proxy system allows you to scale the bot horizontally. When you reach a huge size, you can either keep spending
- more money to keep beefing up your server or you can buy several cheaper servers and scale horizontally. The proxy
- means you can have WS handling on a completely separate system.
-
-- **No Loss Restarts**:
-
- - When you restart a bot without the proxy system, normally you would lose many events. Users may be using commands or
- messages are sent that will not be filtered. As your bot's grow this number rises dramatically. Users may join who
- wont get the auto-roles or any other actions your bot should take. With the proxy system, you can keep restarting
- your bot and never lose any events. Events will be put into a queue while your bot is down(max size of queue is
- customizable), once the bot is available the queue will begin processing all events.
-
-- **Controllers**:
-
- - The controller aspect gives you full control over everything inside the proxy. You can provide a function to simply
- override the handler. For example, if you would like a certain function to do something different, instead of having
- to fork and maintain your fork, you can just provide a function to override.
-
-- **Clustering With Workers**:
- - Take full advantage of all your CPU cores by using workers to spread the load. Control how many shards per worker
- and how many workers to maximize efficiency!
-
-## Usage
-
-```ts
-createGatewayManager({
- // TODO: (docs) Fill this out
-});
-```
-
-## API/Docs
-
-// TODO: (docs) Fill this out. List all props/methods.
diff --git a/gateway/manager/calculateTotalShards.ts b/gateway/manager/calculateTotalShards.ts
deleted file mode 100644
index 44817f528..000000000
--- a/gateway/manager/calculateTotalShards.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { GatewayManager } from "./gatewayManager.ts";
-
-/** Handler used to determine max number of shards to use based upon the max concurrency. */
-export function calculateTotalShards(gateway: GatewayManager): number {
- // Bots under 100k servers do not have access to total shards.
- if (gateway.manager.totalShards < 100) return gateway.manager.totalShards;
-
- // Calculate a multiple of `maxConcurrency` which can be used to connect to the gateway.
- return Math.ceil(
- gateway.manager.totalShards /
- // If `maxConcurrency` is 1 we can safely use 16.
- (gateway.gatewayBot.sessionStartLimit.maxConcurrency === 1
- ? 16
- : gateway.gatewayBot.sessionStartLimit.maxConcurrency),
- ) * gateway.gatewayBot.sessionStartLimit.maxConcurrency;
-}
diff --git a/gateway/manager/calculateWorkerId.ts b/gateway/manager/calculateWorkerId.ts
deleted file mode 100644
index cd2ac2e62..000000000
--- a/gateway/manager/calculateWorkerId.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { GatewayManager } from "./gatewayManager.ts";
-
-export function calculateWorkerId(manager: GatewayManager, shardId: number) {
- // Ignore decimal numbers.
- let workerId = Math.floor((shardId) / manager.shardsPerWorker);
- // If the workerId overflows the maximal allowed workers we by default just use to last worker.
- if (workerId >= manager.totalWorkers) {
- // The Id of the last available worker is total -1
- workerId = manager.totalWorkers - 1;
- }
-
- return workerId;
-}
diff --git a/gateway/manager/gatewayManager.ts b/gateway/manager/gatewayManager.ts
deleted file mode 100644
index 8507b9aa2..000000000
--- a/gateway/manager/gatewayManager.ts
+++ /dev/null
@@ -1,296 +0,0 @@
-import { GetGatewayBot } from "../../transformers/gatewayBot.ts";
-import { DiscordGatewayPayload } from "../../types/discord.ts";
-import { GatewayIntents, MakeRequired, OmitFirstFnArg, PickPartial } from "../../types/shared.ts";
-import { LeakyBucket } from "../../util/bucket.ts";
-import { Collection } from "../../util/collection.ts";
-import { CreateShard, createShard } from "../shard/createShard.ts";
-import { Shard, ShardGatewayConfig } from "../shard/types.ts";
-import { calculateTotalShards } from "./calculateTotalShards.ts";
-import { calculateWorkerId } from "./calculateWorkerId.ts";
-// import {
-// markNewGuildShardId,
-// resharder,
-// resharderCloseOldShards,
-// resharderIsPending,
-// reshardingEditGuildShardIds,
-// } from "./resharder.ts";
-import { spawnShards } from "./spawnShards.ts";
-import { prepareBuckets } from "./prepareBuckets.ts";
-import { tellWorkerToIdentify } from "./tellWorkerToIdentify.ts";
-import { createShardManager, ShardManager } from "./shardManager.ts";
-import { stop } from "./stop.ts";
-
-export type GatewayManager = ReturnType;
-
-/** Create a new Gateway Manager.
- *
- * @param options: Customize every bit of the manager. If something is not
- * provided, it will fallback to a default which should be suitable for most
- * bots.
- */
-export function createGatewayManager(
- options: PickPartial,
-) {
- const prepareBucketsOverwritten = options.prepareBuckets ?? prepareBuckets;
- const spawnShardsOverwritten = options.spawnShards ?? spawnShards;
- const stopOverwritten = options.stop ?? stop;
- const tellWorkerToIdentifyOverwritten = options.tellWorkerToIdentify ?? tellWorkerToIdentify;
- const calculateTotalShardsOverwritten = options.calculateTotalShards ?? calculateTotalShards;
- const calculateWorkerIdOverwritten = options.calculateWorkerId ?? calculateWorkerId;
-
- const totalShards = options.totalShards ?? options.gatewayBot.shards ?? 1;
-
- const gatewayManager = {
- // ----------
- // PROPERTIES
- // ----------
-
- /** The max concurrency buckets.
- * Those will be created when the `spawnShards` (which calls `prepareBuckets` under the hood) function gets called.
- */
- buckets: new Collection<
- number,
- {
- workers: { id: number; queue: number[] }[];
- leak: LeakyBucket;
- }
- >(),
- /** Id of the first Shard which should get controlled by this manager.
- *
- * NOTE: This is intended for testing purposes
- * if big bots want to test the gateway on smaller scale.
- * This is not recommended to be used in production.
- */
- firstShardId: options.firstShardId ?? 0,
- /** Important data which is used by the manager to connect shards to the gateway. */
- gatewayBot: options.gatewayBot,
- /** Id of the last Shard which should get controlled by this manager.
- *
- * NOTE: This is intended for testing purposes
- * if big bots want to test the gateway on smaller scale.
- * This is not recommended to be used in production.
- */
- lastShardId: options.lastShardId ?? totalShards - 1 ?? 1,
- /** This is where the Shards get stored.
- * This will not be used when having a custom workers solution.
- */
- manager: {} as ShardManager,
- /** Delay in milliseconds to wait before spawning next shard.
- * OPTIMAL IS ABOVE 5100. YOU DON'T WANT TO HIT THE RATE LIMIT!!!
- */
- spawnShardDelay: options.spawnShardDelay ?? 5300,
- /** How many Shards should get assigned to a Worker.
- *
- * IMPORTANT: Discordeno will NOT spawn Workers for you.
- * Instead you have to overwrite the `tellWorkerToIdentify` function to make that for you.
- * Look at the [BigBot template gateway solution](https://github.com/discordeno/discordeno/tree/main/template/bigbot/src/gateway) for reference.
- *
- * NOTE: The last Worker will IGNORE this value,
- * which means that the last worker can get assigned an unlimited amount of shards.
- * This is not a bug but intended behavior and means you have to assign more workers to this manager.
- */
- shardsPerWorker: options.shardsPerWorker ?? 25,
- /** The total amount of Workers which get controlled by this manager.
- *
- * IMPORTANT: Discordeno will NOT spawn Workers for you.
- * Instead you have to overwrite the `tellWorkerToIdentify` function to make that for you.
- * Look at the [BigBot template gateway solution](https://github.com/discordeno/discordeno/tree/main/template/bigbot/src/gateway) for reference.
- */
- totalWorkers: options.totalWorkers ?? 4,
-
- // ----------
- // PROPERTIES
- // ----------
- /** Prepares the buckets for identifying.
- *
- * NOTE: Most of the time this function does not need to be called,
- * since it gets called by the `spawnShards` function indirectly.
- */
- prepareBuckets: function () {
- return prepareBucketsOverwritten(this);
- },
- /** This function starts to spawn the Shards assigned to this manager.
- *
- * The managers `buckets` will be created and
- *
- * if `resharding.useOptimalLargeBotSharding` is set to true,
- * `totalShards` gets double checked and adjusted accordingly if wrong.
- */
- spawnShards: function () {
- return spawnShardsOverwritten(this);
- },
- /** Stop the gateway. This closes all shards. */
- stop: function (code: number, reason: string) {
- return stopOverwritten(this, code, reason);
- },
- /** Tell the Worker with this Id to identify this Shard.
- *
- * Useful if a custom Worker solution should be used.
- *
- * IMPORTANT: Discordeno will NOT spawn Workers for you.
- * Instead you have to overwrite the `tellWorkerToIdentify` function to make that for you.
- * Look at the [BigBot template gateway solution](https://github.com/discordeno/discordeno/tree/main/template/bigbot/src/gateway) for reference.
- */
- tellWorkerToIdentify: function (workerId: number, shardId: number, bucketId: number) {
- return tellWorkerToIdentifyOverwritten(this, workerId, shardId, bucketId);
- },
- // TODO: fix debug
- /** Handle the different logs. Used for debugging. */
- debug: options.debug || function () {},
-
- // /** The methods related to resharding. */
- // resharding: {
- // /** Whether the resharder should automatically switch to LARGE BOT SHARDING when the bot is above 100K servers. */
- // useOptimalLargeBotSharding: options.resharding?.useOptimalLargeBotSharding ?? true,
- // /** Whether or not to automatically reshard.
- // *
- // * @default true
- // */
- // reshard: options.resharding?.reshard ?? true,
- // /** The percentage at which resharding should occur.
- // *
- // * @default 80
- // */
- // reshardPercentage: options.resharding?.reshardPercentage ?? 80,
- // /** Handles resharding the bot when necessary. */
- // resharder: options.resharding?.resharder ?? resharder,
- // /** Handles checking if all new shards are online in the new gateway. */
- // isPending: options.resharding?.isPending ?? resharderIsPending,
- // /** Handles closing all shards in the old gateway. */
- // closeOldShards: options.resharding?.closeOldShards ?? resharderCloseOldShards,
- // /** Handles checking if it is time to reshard and triggers the resharder. */
- // check: options.resharding?.check ?? startReshardingChecks,
- // /** Handler to mark a guild id with its new shard id in cache. */
- // markNewGuildShardId: options.resharding?.markNewGuildShardId ?? markNewGuildShardId,
- // /** Handler to update all guilds in cache with the new shard id. */
- // editGuildShardIds: options.resharding?.editGuildShardIds ?? reshardingEditGuildShardIds,
- // },
-
- /** Calculate the amount of Shards which should be used based on the bot's max concurrency. */
- calculateTotalShards: function () {
- return calculateTotalShardsOverwritten(this);
- },
-
- /** Calculate the Id of the Worker related to this Shard. */
- calculateWorkerId: function (shardId: number) {
- return calculateWorkerIdOverwritten(this, shardId);
- },
- };
-
- gatewayManager.manager = createShardManager({
- createShardOptions: options.createShardOptions,
- gatewayConfig: options.gatewayConfig,
- shardIds: [],
- totalShards,
-
- handleMessage: function (shard, message) {
- return options.handleDiscordPayload(shard, message);
- },
-
- requestIdentify: async (shardId) => {
- // TODO: improve
- await gatewayManager.buckets.get(shardId % gatewayManager.gatewayBot.sessionStartLimit.maxConcurrency)!.leak
- .acquire(1);
- },
- });
-
- return gatewayManager;
-}
-
-export interface CreateGatewayManager {
- /** Delay in milliseconds to wait before spawning next shard. OPTIMAL IS ABOVE 5100. YOU DON'T WANT TO HIT THE RATE LIMIT!!! */
- spawnShardDelay: number;
- /** Total amount of shards your bot uses. Useful for zero-downtime updates or resharding. */
- totalShards: number;
- /** The amount of shards to load per worker. */
- shardsPerWorker: number;
- /** The total amount of workers to use for your bot. */
- totalWorkers: number;
- /** Id of the first Shard which should get controlled by this manager.
- *
- * NOTE: This is intended for testing purposes
- * if big bots want to test the gateway on smaller scale.
- * This is not recommended to be used in production.
- */
- firstShardId: number;
- /** Id of the last Shard which should get controlled by this manager.
- *
- * NOTE: This is intended for testing purposes
- * if big bots want to test the gateway on smaller scale.
- * This is not recommended to be used in production.
- */
- lastShardId: number;
-
- /** Important data which is used by the manager to connect shards to the gateway. */
- gatewayBot: GetGatewayBot;
-
- gatewayConfig: PickPartial;
-
- /** Options which are used to create a new shard. */
- createShardOptions?: Omit;
-
- /** Stored as bucketId: { workers: [workerId, [ShardIds]], createNextShard: boolean } */
- buckets: Collection<
- number,
- {
- workers: { id: number; queue: number[] }[];
- leak: LeakyBucket;
- }
- >;
- // METHODS
-
- /** Prepares the buckets for identifying */
- prepareBuckets: typeof prepareBuckets;
- /** The handler for spawning ALL the shards. */
- spawnShards: typeof spawnShards;
- /** The handler to close all shards. */
- stop: typeof stop;
- /** Sends the discord payload to another server. */
- handleDiscordPayload: (shard: Shard, data: DiscordGatewayPayload) => any;
- /** Tell the worker to begin identifying this shard */
- tellWorkerToIdentify: typeof tellWorkerToIdentify;
- /** Handle the different logs. Used for debugging. */
- debug: (text: GatewayDebugEvents, ...args: any[]) => unknown;
- /** The methods related to resharding. */
- // resharding: {
- // /** Whether the resharder should automatically switch to LARGE BOT SHARDING when you are above 100K servers. */
- // useOptimalLargeBotSharding: boolean;
- // /** Whether or not to automatically reshard. */
- // reshard: boolean;
- // /** The percentage at which resharding should occur. */
- // reshardPercentage: number;
- // /** Handles resharding the bot when necessary. */
- // resharder: typeof resharder;
- // /** Handles checking if all new shards are online in the new gateway. */
- // isPending: typeof resharderIsPending;
- // /** Handles closing all shards in the old gateway. */
- // closeOldShards: typeof resharderCloseOldShards;
- // /** Handler to mark a guild id with its new shard id in cache. */
- // markNewGuildShardId: typeof markNewGuildShardId;
- // /** Handler to update all guilds in cache with the new shard id. */
- // editGuildShardIds: typeof reshardingEditGuildShardIds;
- // };
- /** Calculates the number of shards to use based on the max concurrency */
- calculateTotalShards: typeof calculateTotalShards;
-
- /** Calculate the id of the worker related ot this Shard. */
- calculateWorkerId: typeof calculateWorkerId;
-}
-
-export type GatewayDebugEvents =
- | "GW ERROR"
- | "GW CLOSED"
- | "GW CLOSED_RECONNECT"
- | "GW RAW"
- | "GW RECONNECT"
- | "GW INVALID_SESSION"
- | "GW RESUMED"
- | "GW RESUMING"
- | "GW IDENTIFYING"
- | "GW RAW_SEND"
- | "GW MAX REQUESTS"
- | "GW DEBUG"
- | "GW HEARTBEATING"
- | "GW HEARTBEATING_STARTED"
- | "GW HEARTBEATING_DETAILS"
- | "GW HEARTBEATING_CLOSED";
diff --git a/gateway/manager/mod.ts b/gateway/manager/mod.ts
deleted file mode 100644
index f3c056780..000000000
--- a/gateway/manager/mod.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-export * from "./calculateTotalShards.ts";
-export * from "./calculateWorkerId.ts";
-export * from "./gatewayManager.ts";
-export * from "./prepareBuckets.ts";
-export * from "./shardManager.ts";
-export * from "./spawnShards.ts";
-export * from "./stop.ts";
-export * from "./tellWorkerToIdentify.ts";
diff --git a/gateway/manager/prepareBuckets.ts b/gateway/manager/prepareBuckets.ts
deleted file mode 100644
index 206199161..000000000
--- a/gateway/manager/prepareBuckets.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import { createLeakyBucket } from "../../util/bucket.ts";
-import { GatewayManager } from "./gatewayManager.ts";
-
-export function prepareBuckets(gateway: GatewayManager) {
- for (let i = 0; i < gateway.gatewayBot.sessionStartLimit.maxConcurrency; ++i) {
- gateway.buckets.set(i, {
- workers: [],
- leak: createLeakyBucket({
- max: 1,
- refillAmount: 1,
- // special number which is proven to be working dont change
- refillInterval: gateway.spawnShardDelay,
- }),
- });
- }
-
- // ORGANIZE ALL SHARDS INTO THEIR OWN BUCKETS
- for (let shardId = gateway.firstShardId; shardId <= gateway.lastShardId; ++shardId) {
- if (shardId >= gateway.manager.totalShards) {
- throw new Error(
- `Shard (id: ${shardId}) is bigger or equal to the used amount of used shards which is ${gateway.manager.totalShards}`,
- );
- }
-
- const bucketId = shardId % gateway.gatewayBot.sessionStartLimit.maxConcurrency;
- const bucket = gateway.buckets.get(bucketId);
- if (!bucket) {
- throw new Error(
- `Shard (id: ${shardId}) got assigned to an illegal bucket id: ${bucketId}, expected a bucket id between 0 and ${
- gateway.gatewayBot.sessionStartLimit.maxConcurrency - 1
- }`,
- );
- }
-
- // FIND A QUEUE IN THIS BUCKET THAT HAS SPACE
- // const worker = bucket.workers.find((w) => w.queue.length < gateway.shardsPerWorker);
- const workerId = gateway.calculateWorkerId(shardId);
- const worker = bucket.workers.find((w) => w.id === workerId);
- if (worker) {
- // IF THE QUEUE HAS SPACE JUST ADD IT TO THIS QUEUE
- worker.queue.push(shardId);
- } else {
- bucket.workers.push({ id: workerId, queue: [shardId] });
- }
- }
-}
diff --git a/gateway/manager/resharder.ts b/gateway/manager/resharder.ts
deleted file mode 100644
index 22643980f..000000000
--- a/gateway/manager/resharder.ts
+++ /dev/null
@@ -1,246 +0,0 @@
-import { GetGatewayBot } from "../../transformers/gatewayBot.ts";
-import { DiscordGatewayPayload, DiscordReady } from "../../types/discord.ts";
-import { Collection } from "../../util/collection.ts";
-import { createShard } from "../shard/createShard.ts";
-import { decompressWith } from "../shard/deps.ts";
-import { handleMessage } from "../shard/handleMessage.ts";
-import { Shard, ShardSocketCloseCodes } from "../shard/types.ts";
-import { GatewayManager } from "./gatewayManager.ts";
-
-export type Resharder = ReturnType;
-
-export function activateResharder(options: ActivateResharderOptions) {
- const resharder = {
- // ----------
- // PROPERTIES
- // ----------
-
- /** Interval in milliseconds of when to check whether it's time to reshard.
- *
- * @default 28800000 (8 hours)
- */
- checkInterval: options.checkInterval || 28800000,
-
- /** Gateway manager which is currently processing all shards and events. */
- gateway: options.gatewayManager,
-
- /** Timeout of the reshard checker. */
- intervalId: undefined as number | undefined,
-
- /** Percentage at which resharding should occur.
- * @default 80
- */
- percentage: options.percentage ?? 80,
-
- /** Whether the resharder should automatically switch to LARGE BOT SHARDING when the bot is above 100K servers. */
- useOptimalLargeBotSharding: options.useOptimalLargeBotSharding ?? true,
-
- /** The collection of shards that were created and identified by this resharder but are ignoring incoming events because all shards are not yet online. */
- pendingShards: new Collection(),
-
- // ----------
- // METHODS
- // ----------
-
- /** Activate the resharder and delay the next reshard check. */
- activate: function () {
- return activate(this);
- },
-
- /** Function which is used to fetch the current gateway information of the bot.
- * This function is mainly used by the reshard checker.
- */
- getGatewayBot: options.getGatewayBot,
-
- /** Reshard the bots gateway. */
- reshard: function (gatewayBot: GetGatewayBot) {
- return reshard(this, gatewayBot);
- },
-
- tellWorkerToPrepare: options.tellWorkerToPrepare,
-
- shardIsPending: options.shardIsPending ?? shardIsPending,
-
- markNewGuildShardId: options.markNewGuildShardId ?? markNewGuildShardId,
- };
-
- resharder.activate();
-
- return resharder;
-}
-
-export interface ActivateResharderOptions {
- /** Interval in milliseconds of when to check whether it's time to reshard.
- *
- * @default 28800000 (8 hours)
- */
- checkInterval?: number;
- /** Gateway manager which the resharder should be bound to. */
- gatewayManager: GatewayManager;
- /** Percentage at which resharding should occur.
- * @default 80
- */
- percentage?: number;
- /** Whether the resharder should automatically switch to LARGE BOT SHARDING when the bot is above 100K servers. */
- useOptimalLargeBotSharding?: boolean;
-
- /** Function which can be used to fetch the current gateway information of the bot.
- * This function is mainly used by the reshard checker.
- */
- getGatewayBot(): Promise;
-
- /** Function which is used to tell a Worker that it should identify a resharder Shard to the gateway and wait for further instructions.
- * The worker should **NOT** process any events coming from this Shard.
- */
- tellWorkerToPrepare(
- gatewayManager: GatewayManager,
- workerId: number,
- shardId: number,
- bucketId: number,
- ): Promise;
-
- /** Tell the resharder and manager that the a shard is created and identified using new settings but is currently pending by ignoring incoming events. This can be used to track all shards are online which is when old shards are closed and these new shards replace the old ones. */
- shardIsPending(resharder: Resharder, shard: Shard): Promise;
-
- /** Used to update the shard ids of the cached guilds. When a bot is resharded, guilds can be moved around across shards to evenly distribute, so the shards need to be updated. */
- markNewGuildShardId(guildIds: string[], shardId: number): Promise;
-}
-
-/** Handler that by default will check to see if resharding should occur. Can be overridden if you have multiple servers and you want to communicate through redis pubsub or whatever you prefer. */
-export function activate(resharder: Resharder): void {
- if (resharder.intervalId !== undefined) {
- throw new Error("[RESHARDER] Cannot activate the resharder more than one time.");
- }
-
- resharder.intervalId = setInterval(async () => {
- console.log("[Resharding] Checking if resharding is needed.");
-
- const result = await resharder.getGatewayBot();
-
- // 2500 is the max amount of guilds a single shard can handle
- // 1000 is the amount of guilds discord uses to determine how many shards to recommend.
- // This algo helps check if your bot has grown enough to reshard.
- const percentage = (2500 * result.shards) /
- (resharder.gateway.manager.totalShards * 1000) * 100;
- // Less than necessary% being used so do nothing
- if (percentage < resharder.percentage) return;
-
- // Don't have enough identify rate limits to reshard
- if (result.sessionStartLimit.remaining < result.shards) return;
-
- // MULTI-SERVER BOTS OVERRIDE THIS IF YOU NEED TO RESHARD SERVER BY SERVER
- return resharder.reshard(result);
- }, resharder.checkInterval);
-}
-
-export async function reshard(resharder: Resharder, gatewayBot: GetGatewayBot) {
- console.log("[Resharding] Starting the reshard process.");
-
- resharder.gateway.gatewayBot = gatewayBot;
-
- // If more than 100K servers, begin switching to 16x sharding
- if (resharder.useOptimalLargeBotSharding) {
- console.log("[Resharding] Using optimal large bot sharding solution.");
- resharder.gateway.manager.totalShards = resharder.gateway.calculateTotalShards();
- }
-
- resharder.gateway.prepareBuckets();
-
- // SPREAD THIS OUT TO DIFFERENT WORKERS TO BEGIN STARTING UP
- resharder.gateway.buckets.forEach(async (bucket, bucketId) => {
- for (const worker of bucket.workers) {
- for (const shardId of worker.queue) {
- await resharder.tellWorkerToPrepare(resharder.gateway, worker.id, shardId, bucketId);
- }
- }
- });
-}
-
-/** Handler that by default will save the new shard id for each guild this becomes ready in new gateway. This can be overridden to save the shard ids in a redis cache layer or whatever you prefer. These ids will be used later to update all guilds. */
-export async function markNewGuildShardId(guildIds: bigint[], shardId: number) {
- // PLACEHOLDER TO LET YOU MARK A GUILD ID AND SHARD ID FOR LATER USE ONCE RESHARDED
-}
-
-/** Handler that by default does not do anything since by default the library will not cache. */
-export async function reshardingEditGuildShardIds() {
- // PLACEHOLDER TO LET YOU UPDATE CACHED GUILDS
-}
-
-export async function tellWorkerToPrepare(resharder: Resharder, shardId: number) {
- // First create a shard without identifyin.
- const shard = createShard({
- ...resharder.gateway.manager.createShardOptions,
- id: shardId,
- totalShards: resharder.gateway.manager.totalShards,
- gatewayConfig: resharder.gateway.manager.gatewayConfig,
- requestIdentify: async function () {
- return await resharder.gateway.manager.requestIdentify(shardId);
- },
- // Ignore events in this new shard for now
- handleMessage: async function (shard, message) {
- message = message.data;
-
- // If message compression is enabled,
- // Discord might send zlib compressed payloads.
- if (shard.gatewayConfig.compress && message instanceof Blob) {
- message = decompressWith(
- new Uint8Array(await message.arrayBuffer()),
- 0,
- (slice: Uint8Array) => new TextDecoder().decode(slice),
- );
- }
-
- // Safeguard incase decompression failed to make a string.
- if (typeof message !== "string") return;
-
- const messageData = JSON.parse(message) as DiscordGatewayPayload;
-
- if (messageData.t === "READY") {
- const payload = messageData.d as DiscordReady;
- shard.resumeGatewayUrl = payload.resume_gateway_url;
- await resharder.markNewGuildShardId(payload.guilds.map((g) => g.id), shardId);
- }
- },
- });
-
- // Now identify this shard(still ignoring events)
- await shard.identify();
-
- // Tell the manager that this shard is online
- resharder.shardIsPending(resharder, shard);
-}
-
-export async function shardIsPending(resharder: Resharder, shard: Shard) {
- // Save this in pending at the moment, until all shards are online
- resharder.pendingShards.set(shard.id, shard);
-
- // Check if all shards are now online.
- if (resharder.gateway.gatewayBot.shards <= resharder.pendingShards.size) {
- // Time to replace old shards
-
- // New shards start processing events
- for (const shard of resharder.pendingShards.values()) {
- shard.handleMessage = async function (message) {
- return await handleMessage(shard, message);
- };
- }
-
- // Old shards stop processing events
- for (const shard of resharder.gateway.manager.shards.values()) {
- const oldHandler = shard.handleMessage;
-
- shard.handleMessage = async function (message) {
- // Member checks need to continue but others can stop
- if (message.data.t !== "GUILD_MEMBERS_CHUNK") return;
- // Process only the chunking events
- oldHandler(message);
- };
- }
-
- // Close old shards
- await resharder.gateway.stop(ShardSocketCloseCodes.Resharded, "Resharded!");
-
- // Replace old shards
- resharder.gateway.manager.shards = resharder.pendingShards;
- }
-}
diff --git a/gateway/manager/shardManager.ts b/gateway/manager/shardManager.ts
deleted file mode 100644
index 38af3f2e1..000000000
--- a/gateway/manager/shardManager.ts
+++ /dev/null
@@ -1,122 +0,0 @@
-import { DiscordGatewayPayload } from "../../types/discord.ts";
-import { PickPartial } from "../../types/shared.ts";
-import { Collection } from "../../util/collection.ts";
-import { CreateShard, createShard } from "../shard/createShard.ts";
-import { Shard, ShardGatewayConfig } from "../shard/types.ts";
-
-// TODO: debug
-
-/** This is a Shard manager.
- * This does not manage a specific range of Shard but the provided Shards on create or when an identify is requested.
- * The aim of this is to provide an easy to use manager which can be used by workers or any other kind of separate process.
- */
-export type ShardManager = ReturnType;
-
-/** Create a new Shard manager.
- * This does not manage a specific range of Shard but the provided Shards on create or when an identify is requested.
- * The aim of this is to provide an easy to use manager which can be used by workers or any other kind of separate process.
- */
-export function createShardManager(options: CreateShardManager) {
- return {
- // ----------
- // PROPERTIES
- // ----------
-
- /** Options which are used to create a new Shard. */
- createShardOptions: {
- ...options.createShardOptions,
- events: {
- ...options.createShardOptions?.events,
- message: options.createShardOptions?.events?.message ?? options.handleMessage,
- },
- },
- /** Gateway configuration which is used when creating a Shard. */
- gatewayConfig: options.gatewayConfig,
- /** Managed Shards. */
- shards: new Collection(
- options.shardIds.map((shardId) => {
- const shard = createShard({
- ...options.createShardOptions,
- id: shardId,
- totalShards: options.totalShards,
- gatewayConfig: options.gatewayConfig,
- requestIdentify: async function () {
- return await options.requestIdentify(shardId);
- },
- });
-
- return [shardId, shard] as const;
- }),
- ),
- /** Total amount of Shards used by the bot. */
- totalShards: options.totalShards,
-
- // ----------
- // METHODS
- // ----------
-
- /** Tell the manager to identify a Shard.
- * If this Shard is not already managed this will also add the Shard to the manager.
- */
- identify: async function (shardId: number) {
- let shard = this.shards.get(shardId);
- if (!shard) {
- shard = createShard({
- ...this.createShardOptions,
- id: shardId,
- totalShards: this.totalShards,
- gatewayConfig: this.gatewayConfig,
- requestIdentify: async function () {
- return await options.requestIdentify(shardId);
- },
- });
-
- this.shards.set(shardId, shard);
- }
-
- return await shard.identify();
- },
-
- /** Kill a shard.
- * Close a shards connection to Discord's gateway (if any) and remove it from the manager.
- */
- kill: async function (shardId: number) {
- const shard = this.shards.get(shardId);
- if (!shard) return;
-
- this.shards.delete(shardId);
- return await shard.shutdown();
- },
-
- /** This function communicates with the parent manager,
- * in order to know whether this manager is allowed to identify a new shard.
- */
- requestIdentify: options.requestIdentify,
- };
-}
-
-export interface CreateShardManager {
- // ----------
- // PROPERTIES
- // ----------
- /** Options which are used to create a new Shard. */
- createShardOptions?: Omit;
- /** Gateway configuration which is used when creating a Shard. */
- gatewayConfig: PickPartial;
- /** Ids of the Shards which should be managed. */
- shardIds: number[];
- /** Total amount of Shard used by the bot. */
- totalShards: number;
-
- // ----------
- // METHODS
- // ----------
-
- /** This function is used when a shard receives any message from Discord. */
- handleMessage(shard: Shard, message: DiscordGatewayPayload): unknown;
-
- /** This function communicates with the parent manager,
- * in order to know whether this manager is allowed to identify a new shard. #
- */
- requestIdentify(shardId: number): Promise;
-}
diff --git a/gateway/manager/spawnShards.ts b/gateway/manager/spawnShards.ts
deleted file mode 100644
index 547dda9ac..000000000
--- a/gateway/manager/spawnShards.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { GatewayManager } from "./gatewayManager.ts";
-
-/** Begin spawning shards. */
-export function spawnShards(gateway: GatewayManager) {
- // PREPARES ALL SHARDS IN SPECIFIC BUCKETS
- gateway.prepareBuckets();
-
- // SPREAD THIS OUT TO DIFFERENT WORKERS TO BEGIN STARTING UP
- gateway.buckets.forEach(async (bucket, bucketId) => {
- for (const worker of bucket.workers) {
- for (const shardId of worker.queue) {
- await gateway.tellWorkerToIdentify(worker.id, shardId, bucketId);
- }
- }
- });
-}
diff --git a/gateway/manager/stop.ts b/gateway/manager/stop.ts
deleted file mode 100644
index 99508b0da..000000000
--- a/gateway/manager/stop.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { delay } from "../../util/utils.ts";
-import { GatewayManager } from "./gatewayManager.ts";
-
-export async function stop(gateway: GatewayManager, code: number, reason: string) {
- gateway.manager.shards.forEach((shard) => shard.close(code, reason));
-
- await delay(5000);
-}
diff --git a/gateway/manager/tellWorkerToIdentify.ts b/gateway/manager/tellWorkerToIdentify.ts
deleted file mode 100644
index 69054b648..000000000
--- a/gateway/manager/tellWorkerToIdentify.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { GatewayIntents } from "../../types/shared.ts";
-import { createShard } from "../shard/createShard.ts";
-import { GatewayManager } from "./gatewayManager.ts";
-
-/** Allows users to hook in and change to communicate to different workers across different servers or anything they like. For example using redis pubsub to talk to other servers. */
-export async function tellWorkerToIdentify(
- gateway: GatewayManager,
- _workerId: number,
- shardId: number,
- _bucketId: number,
-): Promise {
- return await gateway.manager.identify(shardId);
-}
diff --git a/gateway/mod.ts b/gateway/mod.ts
deleted file mode 100644
index 9315ff337..000000000
--- a/gateway/mod.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from "./manager/mod.ts";
-export * from "./shard/mod.ts";
diff --git a/gateway/shard/calculateSafeRequests.ts b/gateway/shard/calculateSafeRequests.ts
deleted file mode 100644
index ea0ca6a14..000000000
--- a/gateway/shard/calculateSafeRequests.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { Shard } from "./types.ts";
-
-export function calculateSafeRequests(shard: Shard) {
- // * 2 adds extra safety layer for discords OP 1 requests that we need to respond to
- const safeRequests = shard.maxRequestsPerRateLimitTick -
- Math.ceil(shard.rateLimitResetInterval / shard.heart.interval) * 2;
-
- return safeRequests < 0 ? 0 : safeRequests;
-}
diff --git a/gateway/shard/close.ts b/gateway/shard/close.ts
deleted file mode 100644
index fc8d0b2a7..000000000
--- a/gateway/shard/close.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { Shard } from "./types.ts";
-
-export function close(shard: Shard, code: number, reason: string): void {
- if (shard.socket?.readyState !== WebSocket.OPEN) return;
-
- return shard.socket?.close(code, reason);
-}
diff --git a/gateway/shard/connect.ts b/gateway/shard/connect.ts
deleted file mode 100644
index a5bdf81a6..000000000
--- a/gateway/shard/connect.ts
+++ /dev/null
@@ -1,44 +0,0 @@
-import { Shard, ShardState } from "./types.ts";
-
-export async function connect(shard: Shard): Promise {
- // Only set the shard to `Connecting` state,
- // if the connection request does not come from an identify or resume action.
- if (![ShardState.Identifying, ShardState.Resuming].includes(shard.state)) {
- shard.state = ShardState.Connecting;
- }
- shard.events.connecting?.(shard);
-
- let url = new URL(shard.gatewayConfig.url);
- // If not connecting to a proxy but directly to discord need to handle resuming
- if (url.origin === "wss://gateway.discord.gg") {
- if (shard.state === ShardState.Resuming) {
- url = new URL(shard.resumeGatewayUrl);
- }
- url.searchParams.set("v", shard.gatewayConfig.version.toString());
- url.searchParams.set("encoding", "json");
- }
-
- const socket = new WebSocket(url);
-
- shard.socket = socket;
-
- // TODO: proper event handling
- socket.onerror = (event) => console.log({ error: event });
-
- socket.onclose = (event) => shard.handleClose(event);
-
- socket.onmessage = (message) => shard.handleMessage(message);
-
- return new Promise((resolve) => {
- socket.onopen = () => {
- // Only set the shard to `Unidentified` state,
- // if the connection request does not come from an identify or resume action.
- if (![ShardState.Identifying, ShardState.Resuming].includes(shard.state)) {
- shard.state = ShardState.Unidentified;
- }
- shard.events.connected?.(shard);
-
- resolve();
- };
- });
-}
diff --git a/gateway/shard/createShard.ts b/gateway/shard/createShard.ts
deleted file mode 100644
index 78af23e43..000000000
--- a/gateway/shard/createShard.ts
+++ /dev/null
@@ -1,334 +0,0 @@
-import { StatusUpdate } from "../../helpers/misc/editShardStatus.ts";
-import { DiscordGatewayPayload } from "../../types/discord.ts";
-import { PickPartial } from "../../types/shared.ts";
-import { createLeakyBucket, LeakyBucket } from "../../util/bucket.ts";
-import { API_VERSION } from "../../util/constants.ts";
-import { calculateSafeRequests } from "./calculateSafeRequests.ts";
-import { close } from "./close.ts";
-import { connect } from "./connect.ts";
-import { handleClose } from "./handleClose.ts";
-import { handleMessage } from "./handleMessage.ts";
-import { identify } from "./identify.ts";
-import { isOpen } from "./isOpen.ts";
-import { resume } from "./resume.ts";
-import { send } from "./send.ts";
-import { shutdown } from "./shutdown.ts";
-import { startHeartbeating } from "./startHeartbeating.ts";
-import { stopHeartbeating } from "./stopHeartbeating.ts";
-import {
- DEFAULT_HEARTBEAT_INTERVAL,
- GATEWAY_RATE_LIMIT_RESET_INTERVAL,
- MAX_GATEWAY_REQUESTS_PER_INTERVAL,
- Shard,
- ShardEvents,
- ShardGatewayConfig,
- ShardHeart,
- ShardSocketRequest,
- ShardState,
-} from "./types.ts";
-
-// TODO: debug
-// TODO: function overwrite
-// TODO: improve shard event resolving
-
-/** */
-export function createShard(
- options: CreateShard,
-) {
- // This is done for performance reasons
- const calculateSafeRequestsOverwritten = options.calculateSafeRequests ?? calculateSafeRequests;
- const closeOverwritten = options.close ?? close;
- const connectOverwritten = options.connect ?? connect;
- const identifyOverwritten = options.identify ?? identify;
- const sendOverwritten = options.send ?? send;
- const shutdownOverwritten = options.shutdown ?? shutdown;
- const resumeOverwritten = options.resume ?? resume;
- const handleCloseOverwritten = options.handleClose ?? handleClose;
- const handleMessageOverwritten = options.handleMessage ?? handleMessage;
- const isOpenOverwritten = options.isOpen ?? isOpen;
- const startHeartbeatingOverwritten = options.startHeartbeating ?? startHeartbeating;
- const stopHeartbeatingOverwritten = options.stopHeartbeating ?? stopHeartbeating;
-
- return {
- // ----------
- // PROPERTIES
- // ----------
-
- /** The gateway configuration which is used to connect to Discord. */
- gatewayConfig: {
- compress: options.gatewayConfig.compress ?? false,
- intents: options.gatewayConfig.intents ?? 0,
- properties: {
- os: options.gatewayConfig?.properties?.os ?? Deno.build.os,
- browser: options.gatewayConfig?.properties?.browser ?? "Discordeno",
- device: options.gatewayConfig?.properties?.device ?? "Discordeno",
- },
- token: options.gatewayConfig.token,
- url: options.gatewayConfig.url ?? "wss://gateway.discord.gg",
- version: options.gatewayConfig.version ?? API_VERSION,
- } as ShardGatewayConfig,
- /** This contains all the heartbeat information */
- heart: {
- acknowledged: false,
- interval: DEFAULT_HEARTBEAT_INTERVAL,
- } as ShardHeart,
- /** Id of the shard. */
- id: options.id,
- /** The maximum of requests which can be send to discord per rate limit tick.
- * Typically this value should not be changed.
- */
- maxRequestsPerRateLimitTick: MAX_GATEWAY_REQUESTS_PER_INTERVAL,
- /** The previous payload sequence number. */
- previousSequenceNumber: options.previousSequenceNumber || null,
- /** In which interval (in milliseconds) the gateway resets it's rate limit. */
- rateLimitResetInterval: GATEWAY_RATE_LIMIT_RESET_INTERVAL,
- /** Current session id of the shard if present. */
- sessionId: undefined as string | undefined,
- /** This contains the WebSocket connection to Discord, if currently connected. */
- socket: undefined as WebSocket | undefined,
- /** Current internal state of the shard. */
- state: ShardState.Offline,
- /** The total amount of shards which are used to communicate with Discord. */
- totalShards: options.totalShards,
- resumeGatewayUrl: "",
-
- // ----------
- // METHODS
- // ----------
-
- /** The shard related event handlers. */
- events: options.events ?? {} as ShardEvents,
-
- /** Calculate the amount of requests which can safely be made per rate limit interval,
- * before the gateway gets disconnected due to an exceeded rate limit.
- */
- calculateSafeRequests: function () {
- return calculateSafeRequestsOverwritten(this);
- },
-
- /** Close the socket connection to discord if present. */
- close: function (code: number, reason: string) {
- return closeOverwritten(this, code, reason);
- },
-
- /** Connect the shard with the gateway and start heartbeating.
- * This will not identify the shard to the gateway.
- */
- connect: async function () {
- return await connectOverwritten(this);
- },
-
- /** Identify the shard to the gateway.
- * If not connected, this will also connect the shard to the gateway.
- */
- identify: async function () {
- return await identifyOverwritten(this);
- },
-
- /** Check whether the connection to Discord is currently open. */
- isOpen: function () {
- return isOpenOverwritten(this);
- },
-
- /** Function which can be overwritten in order to get the shards presence. */
- // This function allows to be async, in case the devs create the presence based on eg. database values.
- // Passing the shard's id there to make it easier for the dev to use this function.
- makePresence: options.makePresence,
-
- /** Attempt to resume the previous shards session with the gateway. */
- resume: async function () {
- return await resumeOverwritten(this);
- },
-
- /** Send a message to Discord.
- * @param {boolean} [highPriority=false] - Whether this message should be send asap.
- */
- send: async function (message: ShardSocketRequest, highPriority: boolean = false) {
- return await sendOverwritten(this, message, highPriority);
- },
-
- /** Shutdown the shard.
- * Forcefully disconnect the shard from Discord.
- * The shard may not attempt to reconnect with Discord.
- */
- shutdown: async function () {
- return await shutdownOverwritten(this);
- },
-
- /** @private Internal shard bucket.
- * Only access this if you know what you are doing.
- *
- * Bucket for handling shard request rate limits.
- */
- bucket: createLeakyBucket({
- max: MAX_GATEWAY_REQUESTS_PER_INTERVAL,
- refillInterval: GATEWAY_RATE_LIMIT_RESET_INTERVAL,
- refillAmount: MAX_GATEWAY_REQUESTS_PER_INTERVAL,
- }),
-
- /** @private Internal shard function.
- * Only use this function if you know what you are doing.
- *
- * Handle a gateway connection close.
- */
- handleClose: async function (close: CloseEvent) {
- return await handleCloseOverwritten(this, close);
- },
-
- /** @private Internal shard function.
- * Only use this function if you know what you are doing.
- *
- * Handle an incoming gateway message.
- */
- handleMessage: async function (message: MessageEvent) {
- return await handleMessageOverwritten(this, message);
- },
-
- /** This function communicates with the management process, in order to know whether its free to identify. */
- requestIdentify: async function () {
- return await options.requestIdentify(this.id);
- },
-
- /** @private Internal state.
- * Only use this if you know what you are doing.
- *
- * Cache for pending gateway requests which should have been send while the gateway went offline.
- */
- offlineSendQueue: [] as ((_?: unknown) => void)[],
-
- /** @private Internal shard map.
- * Only use this map if you know what you are doing.
- *
- * This is used to resolve internal waiting states.
- * Mapped by SelectedEvents => ResolveFunction
- */
- resolves: new Map<"READY" | "RESUMED" | "INVALID_SESSION", (payload: DiscordGatewayPayload) => void>(),
-
- /** @private Internal shard function.
- * Only use this function if you know what you are doing.
- *
- * Start sending heartbeat payloads to Discord in the provided interval.
- */
- startHeartbeating: function (interval: number) {
- return startHeartbeatingOverwritten(this, interval);
- },
-
- /** @private Internal shard function.
- * Only use this function if you know what you are doing.
- *
- * Stop the heartbeating process with discord.
- */
- stopHeartbeating: function () {
- return stopHeartbeatingOverwritten(this);
- },
- };
-}
-
-export interface CreateShard {
- /** Id of the shard which should be created. */
- id: number;
-
- /** Gateway configuration for the shard. */
- gatewayConfig: PickPartial;
-
- /** The total amount of shards which are used to communicate with Discord. */
- totalShards: number;
-
- /** This function communicates with the management process, in order to know whether its free to identify.
- * When this function resolves, this means that the shard is allowed to send an identify payload to discord.
- */
- requestIdentify: (shardId: number) => Promise;
-
- /** Calculate the amount of requests which can safely be made per rate limit interval,
- * before the gateway gets disconnected due to an exceeded rate limit.
- */
- calculateSafeRequests?: typeof calculateSafeRequests;
-
- /** Close the socket connection to discord if present. */
- close?: typeof close;
-
- /** Connect the shard with the gateway and start heartbeating.
- * This will not identify the shard to the gateway.
- */
- connect?: typeof connect;
-
- /** @private Internal shard function.
- * Only use this function if you know what you are doing.
- *
- * Handle a gateway connection close.
- */
- handleClose?: typeof handleClose;
-
- /** @private Internal shard function.
- * Only use this function if you know what you are doing.
- *
- * Handle an incoming gateway message.
- */
- handleMessage?: typeof handleMessage;
-
- /** Identify the shard to the gateway.
- * If not connected, this will also connect the shard to the gateway.
- */
- identify?: typeof identify;
-
- /** Check whether the connection to Discord is currently open. */
- isOpen?: typeof isOpen;
-
- /** Function which can be overwritten in order to get the shards presence. */
- makePresence?(shardId: number): Promise | StatusUpdate;
-
- /** The maximum of requests which can be send to discord per rate limit tick.
- * Typically this value should not be changed.
- */
- maxRequestsPerRateLimitTick?: number;
-
- /** The previous payload sequence number. */
- previousSequenceNumber?: number;
-
- /** In which interval (in milliseconds) the gateway resets it's rate limit. */
- rateLimitResetInterval?: number;
-
- /** Attempt to resume the previous shards session with the gateway. */
- resume?: typeof resume;
-
- /** Send a message to Discord.
- * @param {boolean} [highPriority=false] - Whether this message should be send asap.
- */
- send?: typeof send;
-
- /** Shutdown the shard.
- * Forcefully disconnect the shard from Discord.
- * The shard may not attempt to reconnect with Discord.
- */
- shutdown?: typeof shutdown;
-
- /** @private Internal shard function.
- * Only use this function if you know what you are doing.
- *
- * Start sending heartbeat payloads to Discord in the provided interval.
- */
- startHeartbeating?: typeof startHeartbeating;
-
- /** Current internal state of the shard. */
- state?: ShardState;
-
- /** @private Internal shard function.
- * Only use this function if you know what you are doing.
- *
- * Stop the heartbeating process with discord.
- */
- stopHeartbeating?: typeof stopHeartbeating;
-
- /** The shard related event handlers. */
- events?: ShardEvents;
- /** This contains all the heartbeat information */
- heart?: ShardHeart;
- /** Bucket for handling shard request rate limits. */
- bucket?: LeakyBucket;
- /** Cache for pending gateway requests which should have been send while the gateway went offline. */
- offlineSendQueue?: ShardSocketRequest[];
- /** This is used to resolve internal waiting states.
- * Mapped by SelectedEvents => ResolveFunction
- */
- resolves?: Shard["resolves"];
-}
diff --git a/gateway/shard/deps.ts b/gateway/shard/deps.ts
deleted file mode 100644
index 32a9eb3c0..000000000
--- a/gateway/shard/deps.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { decompress_with as decompressWith } from "https://unpkg.com/@evan/wasm@0.0.94/target/zlib/deno.js";
diff --git a/gateway/shard/handleClose.ts b/gateway/shard/handleClose.ts
deleted file mode 100644
index 59f8df485..000000000
--- a/gateway/shard/handleClose.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-import { GatewayCloseEventCodes } from "../../types/shared.ts";
-import { Shard, ShardSocketCloseCodes, ShardState } from "./types.ts";
-
-export async function handleClose(shard: Shard, close: CloseEvent): Promise {
- // gateway.debug("GW CLOSED", { shardId, payload: event });
-
- shard.stopHeartbeating();
-
- switch (close.code) {
- case ShardSocketCloseCodes.TestingFinished: {
- shard.state = ShardState.Offline;
- shard.events.disconnected?.(shard);
-
- return;
- }
- // On these codes a manual start will be done.
- case ShardSocketCloseCodes.Shutdown:
- case ShardSocketCloseCodes.ReIdentifying:
- case ShardSocketCloseCodes.Resharded:
- case ShardSocketCloseCodes.ResumeClosingOldConnection:
- case ShardSocketCloseCodes.ZombiedConnection: {
- shard.state = ShardState.Disconnected;
- shard.events.disconnected?.(shard);
-
- // gateway.debug("GW CLOSED_RECONNECT", { shardId, payload: event });
- return;
- }
- // Gateway connection closes which require a new identify.
- case GatewayCloseEventCodes.UnknownOpcode:
- case GatewayCloseEventCodes.NotAuthenticated:
- case GatewayCloseEventCodes.InvalidSeq:
- case GatewayCloseEventCodes.RateLimited:
- case GatewayCloseEventCodes.SessionTimedOut: {
- shard.state = ShardState.Identifying;
- shard.events.disconnected?.(shard);
-
- return await shard.identify();
- }
- // When these codes are received something went really wrong.
- // On those we cannot start a reconnect attempt.
- case GatewayCloseEventCodes.AuthenticationFailed:
- case GatewayCloseEventCodes.InvalidShard:
- case GatewayCloseEventCodes.ShardingRequired:
- case GatewayCloseEventCodes.InvalidApiVersion:
- case GatewayCloseEventCodes.InvalidIntents:
- case GatewayCloseEventCodes.DisallowedIntents: {
- shard.state = ShardState.Offline;
- shard.events.disconnected?.(shard);
-
- throw new Error(close.reason || "Discord gave no reason! GG! You broke Discord!");
- }
- // Gateway connection closes on which a resume is allowed.
- case GatewayCloseEventCodes.UnknownError:
- case GatewayCloseEventCodes.DecodeError:
- case GatewayCloseEventCodes.AlreadyAuthenticated:
- default: {
- shard.state = ShardState.Resuming;
- shard.events.disconnected?.(shard);
-
- return await shard.resume();
- }
- }
-}
diff --git a/gateway/shard/handleMessage.ts b/gateway/shard/handleMessage.ts
deleted file mode 100644
index 7e4f88848..000000000
--- a/gateway/shard/handleMessage.ts
+++ /dev/null
@@ -1,156 +0,0 @@
-import { DiscordGatewayPayload, DiscordHello, DiscordReady } from "../../types/discord.ts";
-import { GatewayOpcodes } from "../../types/shared.ts";
-import { createLeakyBucket } from "../../util/bucket.ts";
-import { delay } from "../../util/utils.ts";
-import { decompressWith } from "./deps.ts";
-import { GATEWAY_RATE_LIMIT_RESET_INTERVAL, Shard, ShardState } from "./types.ts";
-
-const decoder = new TextDecoder();
-
-export async function handleMessage(shard: Shard, message: MessageEvent): Promise {
- message = message.data;
-
- // If message compression is enabled,
- // Discord might send zlib compressed payloads.
- if (shard.gatewayConfig.compress && message instanceof Blob) {
- message = decompressWith(
- new Uint8Array(await message.arrayBuffer()),
- 0,
- (slice: Uint8Array) => decoder.decode(slice),
- );
- }
-
- // Safeguard incase decompression failed to make a string.
- if (typeof message !== "string") return;
-
- const messageData = JSON.parse(message) as DiscordGatewayPayload;
-
- // Edge case start: https://github.com/discordeno/discordeno/issues/2311
- shard.heart.lastAck = Date.now();
- // Manually calculating the round trip time for users who need it.
- if (shard.heart.lastBeat && !shard.heart.acknowledged) {
- shard.heart.rtt = shard.heart.lastAck - shard.heart.lastBeat;
- }
- shard.heart.acknowledged = true;
- // Edge case end!
-
- switch (messageData.op) {
- case GatewayOpcodes.Heartbeat: {
- // TODO: can this actually happen
- if (!shard.isOpen()) return;
-
- shard.heart.lastBeat = Date.now();
- // Discord randomly sends this requiring an immediate heartbeat back.
- // Using a direct socket.send call here because heartbeat requests are reserved by us.
- shard.socket?.send(
- JSON.stringify({
- op: GatewayOpcodes.Heartbeat,
- d: shard.previousSequenceNumber,
- }),
- );
- shard.events.heartbeat?.(shard);
-
- break;
- }
- case GatewayOpcodes.Hello: {
- const interval = (messageData.d as DiscordHello).heartbeat_interval;
-
- shard.startHeartbeating(interval);
-
- if (shard.state !== ShardState.Resuming) {
- // HELLO has been send on a non resume action.
- // This means that the shard starts a new session,
- // therefore the rate limit interval has been reset too.
- shard.bucket = createLeakyBucket({
- max: shard.calculateSafeRequests(),
- refillInterval: GATEWAY_RATE_LIMIT_RESET_INTERVAL,
- refillAmount: shard.calculateSafeRequests(),
- // Waiting acquires should not be lost on a re-identify.
- waiting: shard.bucket.waiting,
- });
- }
-
- shard.events.hello?.(shard);
-
- break;
- }
- case GatewayOpcodes.HeartbeatACK: {
- shard.events.heartbeatAck?.(shard);
-
- break;
- }
- case GatewayOpcodes.Reconnect: {
- // gateway.debug("GW RECONNECT", { shardId });
-
- shard.events.requestedReconnect?.(shard);
-
- await shard.resume();
-
- break;
- }
- case GatewayOpcodes.InvalidSession: {
- // gateway.debug("GW INVALID_SESSION", { shardId, payload: messageData });
- const resumable = messageData.d as boolean;
-
- shard.events.invalidSession?.(shard, resumable);
-
- // We need to wait for a random amount of time between 1 and 5
- // Reference: https://discord.com/developers/docs/topics/gateway#resuming
- await delay(Math.floor((Math.random() * 4 + 1) * 1000));
-
- shard.resolves.get("INVALID_SESSION")?.(messageData);
- shard.resolves.delete("INVALID_SESSION");
-
- // When resumable is false we need to re-identify
- if (!resumable) {
- await shard.identify();
-
- break;
- }
-
- // The session is invalid but apparently it is resumable
- await shard.resume();
-
- break;
- }
- }
-
- if (messageData.t === "RESUMED") {
- // gateway.debug("GW RESUMED", { shardId });
-
- shard.state = ShardState.Connected;
- shard.events.resumed?.(shard);
-
- // Continue the requests which have been queued since the shard went offline.
- shard.offlineSendQueue.map((resolve) => resolve());
-
- shard.resolves.get("RESUMED")?.(messageData);
- shard.resolves.delete("RESUMED");
- } // Important for future resumes.
- else if (messageData.t === "READY") {
- const payload = messageData.d as DiscordReady;
-
- shard.resumeGatewayUrl = payload.resume_gateway_url;
-
- shard.sessionId = payload.session_id;
- shard.state = ShardState.Connected;
-
- // Continue the requests which have been queued since the shard went offline.
- // Important when this is a re-identify
- shard.offlineSendQueue.map((resolve) => resolve());
-
- shard.resolves.get("READY")?.(messageData);
- shard.resolves.delete("READY");
- }
-
- // Update the sequence number if it is present
- // `s` can be either `null` or a `number`.
- // In order to prevent update misses when `s` is `0` we check against null.
- if (messageData.s !== null) {
- shard.previousSequenceNumber = messageData.s;
- }
-
- // The necessary handling required for the Shards connection has been finished.
- // Now the event can be safely forwarded.
- shard.events.message?.(shard, messageData);
-}
diff --git a/gateway/shard/identify.ts b/gateway/shard/identify.ts
deleted file mode 100644
index 8d9ce59f4..000000000
--- a/gateway/shard/identify.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-import { GatewayOpcodes } from "../../types/shared.ts";
-import { Shard, ShardSocketCloseCodes, ShardState } from "./types.ts";
-
-export async function identify(shard: Shard): Promise {
- // A new identify has been requested even though there is already a connection open.
- // Therefore we need to close the old connection and heartbeating before creating a new one.
- if (shard.isOpen()) {
- console.log("CLOSING EXISTING SHARD: #" + shard.id);
- shard.close(ShardSocketCloseCodes.ReIdentifying, "Re-identifying closure of old connection.");
- }
-
- shard.state = ShardState.Identifying;
- shard.events.identifying?.(shard);
-
- // It is possible that the shard is in Heartbeating state but not identified,
- // so check whether there is already a gateway connection existing.
- // If not we need to create one before we identify.
- if (!shard.isOpen()) {
- await shard.connect();
- }
-
- // Wait until an identify is free for this shard.
- await shard.requestIdentify();
-
- shard.send({
- op: GatewayOpcodes.Identify,
- d: {
- token: `Bot ${shard.gatewayConfig.token}`,
- compress: shard.gatewayConfig.compress,
- properties: shard.gatewayConfig.properties,
- intents: shard.gatewayConfig.intents,
- shard: [shard.id, shard.totalShards],
- presence: await shard.makePresence?.(shard.id),
- },
- }, true);
-
- return new Promise((resolve) => {
- shard.resolves.set("READY", () => {
- shard.events.identified?.(shard);
- resolve();
- });
- // When identifying too fast,
- // Discord sends an invalid session payload.
- // This can safely be ignored though and the shard starts a new identify action.
- shard.resolves.set("INVALID_SESSION", () => {
- shard.resolves.delete("READY");
- resolve();
- });
- });
-}
diff --git a/gateway/shard/isOpen.ts b/gateway/shard/isOpen.ts
deleted file mode 100644
index c5bb149fc..000000000
--- a/gateway/shard/isOpen.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { Shard } from "./types.ts";
-
-export function isOpen(shard: Shard): boolean {
- return shard.socket?.readyState === WebSocket.OPEN;
-}
diff --git a/gateway/shard/mod.ts b/gateway/shard/mod.ts
deleted file mode 100644
index 753770e50..000000000
--- a/gateway/shard/mod.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-export * from "./calculateSafeRequests.ts";
-export * from "./close.ts";
-export * from "./connect.ts";
-export * from "./createShard.ts";
-export * from "./handleClose.ts";
-export * from "./handleMessage.ts";
-export * from "./identify.ts";
-export * from "./isOpen.ts";
-export * from "./resume.ts";
-export * from "./send.ts";
-export * from "./shutdown.ts";
-export * from "./startHeartbeating.ts";
-export * from "./stopHeartbeating.ts";
-export * from "./types.ts";
diff --git a/gateway/shard/resume.ts b/gateway/shard/resume.ts
deleted file mode 100644
index 0739c90db..000000000
--- a/gateway/shard/resume.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import { GatewayOpcodes } from "../../types/shared.ts";
-import { Shard, ShardSocketCloseCodes, ShardState } from "./types.ts";
-
-export async function resume(shard: Shard): Promise {
- // gateway.debug("GW RESUMING", { shardId });
- // It has been requested to resume the Shards session.
- // It's possible that the shard is still connected with Discord's gateway therefore we need to forcefully close it.
- if (shard.isOpen()) {
- shard.close(ShardSocketCloseCodes.ResumeClosingOldConnection, "Reconnecting the shard, closing old connection.");
- }
-
- // Shard has never identified, so we cannot resume.
- if (!shard.sessionId) {
- // gateway.debug(
- // "GW DEBUG",
- // `[Error] Trying to resume a shard (id: ${shardId}) that was not first identified.`,
- // );
-
- return await shard.identify();
-
- // throw new Error(`[SHARD] Trying to resume a shard (id: ${shard.id}) which was never identified`);
- }
-
- shard.state = ShardState.Resuming;
-
- // Before we can resume, we need to create a new connection with Discord's gateway.
- await shard.connect();
-
- shard.send({
- op: GatewayOpcodes.Resume,
- d: {
- token: `Bot ${shard.gatewayConfig.token}`,
- session_id: shard.sessionId,
- seq: shard.previousSequenceNumber ?? 0,
- },
- }, true);
-
- return new Promise((resolve) => {
- shard.resolves.set("RESUMED", () => resolve());
- // If it is attempted to resume with an invalid session id,
- // Discord sends an invalid session payload
- // Not erroring here since it is easy that this happens, also it would be not catchable
- shard.resolves.set("INVALID_SESSION", () => {
- shard.resolves.delete("RESUMED");
- resolve();
- });
- });
-}
diff --git a/gateway/shard/send.ts b/gateway/shard/send.ts
deleted file mode 100644
index 4adc3a7e3..000000000
--- a/gateway/shard/send.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { Shard, ShardSocketRequest } from "./types.ts";
-
-async function checkOffline(shard: Shard, highPriority: boolean): Promise {
- if (!shard.isOpen()) {
- await new Promise((resolve) => {
- if (highPriority) {
- // Higher priority requests get added at the beginning of the array.
- shard.offlineSendQueue.unshift(resolve);
- } else {
- shard.offlineSendQueue.push(resolve);
- }
- });
- }
-}
-
-export async function send(shard: Shard, message: ShardSocketRequest, highPriority: boolean): Promise {
- // Before acquiring a token from the bucket, check whether the shard is currently offline or not.
- // Else bucket and token wait time just get wasted.
- await checkOffline(shard, highPriority);
-
- await shard.bucket.acquire(1, highPriority);
-
- // It's possible, that the shard went offline after a token has been acquired from the bucket.
- await checkOffline(shard, highPriority);
-
- shard.socket?.send(JSON.stringify(message));
-}
diff --git a/gateway/shard/shutdown.ts b/gateway/shard/shutdown.ts
deleted file mode 100644
index 13b9d8a84..000000000
--- a/gateway/shard/shutdown.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { Shard, ShardSocketCloseCodes, ShardState } from "./types.ts";
-
-export async function shutdown(shard: Shard): Promise {
- shard.close(ShardSocketCloseCodes.Shutdown, "Shard shutting down.");
- shard.state = ShardState.Offline;
-}
diff --git a/gateway/shard/startHeartbeating.ts b/gateway/shard/startHeartbeating.ts
deleted file mode 100644
index 8ee804f53..000000000
--- a/gateway/shard/startHeartbeating.ts
+++ /dev/null
@@ -1,64 +0,0 @@
-import { GatewayOpcodes } from "../../types/shared.ts";
-import { Shard, ShardSocketCloseCodes, ShardState } from "./types.ts";
-
-export function startHeartbeating(shard: Shard, interval: number) {
- // gateway.debug("GW HEARTBEATING_STARTED", { shardId, interval });
-
- shard.heart.interval = interval;
-
- // Only set the shard's state to `Unidentified`
- // if heartbeating has not been started due to an identify or resume action.
- if ([ShardState.Disconnected, ShardState.Offline].includes(shard.state)) {
- shard.state = ShardState.Unidentified;
- }
-
- // The first heartbeat needs to be send with a random delay between `0` and `interval`
- // Using a `setTimeout(_, jitter)` here to accomplish that.
- // `Math.random()` can be `0` so we use `0.5` if this happens
- // Reference: https://discord.com/developers/docs/topics/gateway#heartbeating
- const jitter = Math.ceil(shard.heart.interval * (Math.random() || 0.5));
- shard.heart.timeoutId = setTimeout(() => {
- // Using a direct socket.send call here because heartbeat requests are reserved by us.
- shard.socket?.send(JSON.stringify({
- op: GatewayOpcodes.Heartbeat,
- d: shard.previousSequenceNumber,
- }));
-
- shard.heart.lastBeat = Date.now();
- shard.heart.acknowledged = false;
-
- // After the random heartbeat jitter we can start a normal interval.
- shard.heart.intervalId = setInterval(async () => {
- // gateway.debug("GW DEBUG", `Running setInterval in heartbeat file. Shard: ${shardId}`);
-
- // gateway.debug("GW HEARTBEATING", { shardId, shard: currentShard });
-
- // The Shard did not receive a heartbeat ACK from Discord in time,
- // therefore we have to assume that the connection has failed or got "zombied".
- // The Shard needs to start a re-identify action accordingly.
- // Reference: https://discord.com/developers/docs/topics/gateway#heartbeating-example-gateway-heartbeat-ack
- if (!shard.heart.acknowledged) {
- shard.close(
- ShardSocketCloseCodes.ZombiedConnection,
- "Zombied connection, did not receive an heartbeat ACK in time.",
- );
-
- return await shard.identify();
- }
-
- shard.heart.acknowledged = false;
-
- // Using a direct socket.send call here because heartbeat requests are reserved by us.
- shard.socket?.send(
- JSON.stringify({
- op: GatewayOpcodes.Heartbeat,
- d: shard.previousSequenceNumber,
- }),
- );
-
- shard.heart.lastBeat = Date.now();
-
- shard.events.heartbeat?.(shard);
- }, shard.heart.interval);
- }, jitter);
-}
diff --git a/gateway/shard/stopHeartbeating.ts b/gateway/shard/stopHeartbeating.ts
deleted file mode 100644
index f22739ac1..000000000
--- a/gateway/shard/stopHeartbeating.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { Shard } from "./types.ts";
-
-export function stopHeartbeating(shard: Shard): void {
- // Clear the regular heartbeat interval.
- clearInterval(shard.heart.intervalId);
- // It's possible that the Shard got closed before the first jittered heartbeat.
- // To go safe we should clear the related timeout too.
- clearTimeout(shard.heart.timeoutId);
-}
diff --git a/gateway/shard/types.ts b/gateway/shard/types.ts
deleted file mode 100644
index a9e326ded..000000000
--- a/gateway/shard/types.ts
+++ /dev/null
@@ -1,150 +0,0 @@
-import { StatusUpdate } from "../../helpers/misc/editShardStatus.ts";
-import { DiscordGatewayPayload } from "../../types/discord.ts";
-import { GatewayOpcodes } from "../../types/shared.ts";
-import { LeakyBucket } from "../../util/bucket.ts";
-import { createShard } from "./createShard.ts";
-
-// TODO: think whether we also need an identifiedShard function
-
-export const MAX_GATEWAY_REQUESTS_PER_INTERVAL = 120;
-export const GATEWAY_RATE_LIMIT_RESET_INTERVAL = 60_000; // 60 seconds
-export const DEFAULT_HEARTBEAT_INTERVAL = 45000;
-
-export type Shard = ReturnType;
-
-export enum ShardState {
- /** Shard is fully connected to the gateway and receiving events from Discord. */
- Connected = 0,
- /** Shard started to connect to the gateway.
- * This is only used if the shard is not currently trying to identify or resume.
- */
- Connecting = 1,
- /** Shard got disconnected and reconnection actions have been started. */
- Disconnected = 2,
- /** The shard is connected to the gateway but only heartbeating.
- * At this state the shard has not been identified with discord.
- */
- Unidentified = 3,
- /** Shard is trying to identify with the gateway to create a new session. */
- Identifying = 4,
- /** Shard is trying to resume a session with the gateway. */
- Resuming = 5,
- /** Shard got shut down studied or due to a not (self) fixable error and may not attempt to reconnect on its own. */
- Offline = 6,
-}
-
-export interface ShardGatewayConfig {
- /** Whether incoming payloads are compressed using zlib.
- *
- * @default false
- */
- compress: boolean;
- /** The calculated intent value of the events which the shard should receive.
- *
- * @default 0
- */
- intents: number;
- /** Identify properties to use */
- properties: {
- /** Operating system the shard runs on.
- *
- * @default "darwin" | "linux" | "windows"
- */
- os: string;
- /** The "browser" where this shard is running on.
- *
- * @default "Discordeno"
- */
- browser: string;
- /** The device on which the shard is running.
- *
- * @default "Discordeno"
- */
- device: string;
- };
- /** Bot token which is used to connect to Discord */
- token: string;
- /** The URL of the gateway which should be connected to.
- *
- * @default "wss://gateway.discord.gg"
- */
- url: string;
- /** The gateway version which should be used.
- *
- * @default 10
- */
- version: number;
-}
-
-export interface ShardHeart {
- /** Whether or not the heartbeat was acknowledged by Discord in time. */
- acknowledged: boolean;
- /** Interval between heartbeats requested by Discord. */
- interval: number;
- /** Id of the interval, which is used for sending the heartbeats. */
- intervalId?: number;
- /** Unix (in milliseconds) timestamp when the last heartbeat ACK was received from Discord. */
- lastAck?: number;
- /** Unix timestamp (in milliseconds) when the last heartbeat was sent. */
- lastBeat?: number;
- /** Round trip time (in milliseconds) from Shard to Discord and back.
- * Calculated using the heartbeat system.
- * Note: this value is undefined until the first heartbeat to Discord has happened.
- */
- rtt?: number;
- /** Id of the timeout which is used for sending the first heartbeat to Discord since it's "special". */
- timeoutId?: number;
-}
-
-export interface ShardEvents {
- /** A heartbeat has been send. */
- heartbeat?(shard: Shard): unknown;
- /** A heartbeat ACK was received. */
- heartbeatAck?(shard: Shard): unknown;
- /** Shard has received a Hello payload. */
- hello?(shard: Shard): unknown;
- /** The Shards session has been invalidated. */
- invalidSession?(shard: Shard, resumable: boolean): unknown;
- /** The shard has started a resume action. */
- resuming?(shard: Shard): unknown;
- /** The shard has successfully resumed an old session. */
- resumed?(shard: Shard): unknown;
- /** Discord has requested the Shard to reconnect. */
- requestedReconnect?(shard: Shard): unknown;
- /** The shard started to connect to Discord's gateway. */
- connecting?(shard: Shard): unknown;
- /** The shard is connected with Discord's gateway. */
- connected?(shard: Shard): unknown;
- /** The shard has been disconnected from Discord's gateway. */
- disconnected?(shard: Shard): unknown;
- /** The shard has started to identify itself to Discord. */
- identifying?(shard: Shard): unknown;
- /** The shard has successfully been identified itself with Discord. */
- identified?(shard: Shard): unknown;
- /** The shard has received a message from Discord. */
- message?(shard: Shard, payload: DiscordGatewayPayload): unknown;
-}
-
-export enum ShardSocketCloseCodes {
- /** A regular Shard shutdown. */
- Shutdown = 3000,
- /** A resume has been requested and therefore the old connection needs to be closed. */
- ResumeClosingOldConnection = 3024,
- /** Did not receive a heartbeat ACK in time.
- * Closing the shard and creating a new session.
- */
- ZombiedConnection = 3010,
- /** Discordeno's gateway tests hae been finished, therefore the Shard can be turned off. */
- TestingFinished = 3064,
- /** Special close code reserved for Discordeno's zero-downtime resharding system. */
- Resharded = 3065,
- /** Shard is re-identifying therefore the old connection needs to be closed. */
- ReIdentifying = 3066,
-}
-
-export interface ShardSocketRequest {
- /** The OP-Code for the payload to send. */
- op: GatewayOpcodes;
- /** Payload data. */
- d: unknown;
-}
diff --git a/handlers/channels/CHANNEL_CREATE.ts b/handlers/channels/CHANNEL_CREATE.ts
deleted file mode 100644
index f7a8c690f..000000000
--- a/handlers/channels/CHANNEL_CREATE.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { DiscordChannel, DiscordGatewayPayload } from "../../types/discord.ts";
-
-export async function handleChannelCreate(bot: Bot, payload: DiscordGatewayPayload) {
- const channel = bot.transformers.channel(bot, { channel: payload.d as DiscordChannel });
-
- bot.events.channelCreate(bot, channel);
-}
diff --git a/handlers/channels/CHANNEL_DELETE.ts b/handlers/channels/CHANNEL_DELETE.ts
deleted file mode 100644
index fb6c7be9b..000000000
--- a/handlers/channels/CHANNEL_DELETE.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { DiscordChannel, DiscordGatewayPayload } from "../../types/discord.ts";
-
-export async function handleChannelDelete(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordChannel;
- if (!payload.guild_id) return;
-
- bot.events.channelDelete(
- bot,
- bot.transformers.channel(bot, {
- channel: payload,
- guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
- }),
- );
-}
diff --git a/handlers/channels/CHANNEL_PINS_UPDATE.ts b/handlers/channels/CHANNEL_PINS_UPDATE.ts
deleted file mode 100644
index 7361a44e5..000000000
--- a/handlers/channels/CHANNEL_PINS_UPDATE.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { DiscordChannelPinsUpdate, DiscordGatewayPayload } from "../../types/discord.ts";
-
-export async function handleChannelPinsUpdate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordChannelPinsUpdate;
-
- bot.events.channelPinsUpdate(bot, {
- guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
- channelId: bot.transformers.snowflake(payload.channel_id),
- lastPinTimestamp: payload.last_pin_timestamp ? Date.parse(payload.last_pin_timestamp) : undefined,
- });
-}
diff --git a/handlers/channels/CHANNEL_UPDATE.ts b/handlers/channels/CHANNEL_UPDATE.ts
deleted file mode 100644
index 6933f0b7a..000000000
--- a/handlers/channels/CHANNEL_UPDATE.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { DiscordChannel, DiscordGatewayPayload } from "../../types/discord.ts";
-
-export async function handleChannelUpdate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordChannel;
- const channel = bot.transformers.channel(bot, { channel: payload });
-
- bot.events.channelUpdate(bot, channel);
-}
diff --git a/handlers/channels/STAGE_INSTANCE_CREATE.ts b/handlers/channels/STAGE_INSTANCE_CREATE.ts
deleted file mode 100644
index e2c2ac58a..000000000
--- a/handlers/channels/STAGE_INSTANCE_CREATE.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordStageInstance } from "../../types/discord.ts";
-
-export function handleStageInstanceCreate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordStageInstance;
-
- bot.events.stageInstanceCreate(bot, {
- id: bot.transformers.snowflake(payload.id),
- guildId: bot.transformers.snowflake(payload.guild_id),
- channelId: bot.transformers.snowflake(payload.channel_id),
- topic: payload.topic,
- });
-}
diff --git a/handlers/channels/STAGE_INSTANCE_DELETE.ts b/handlers/channels/STAGE_INSTANCE_DELETE.ts
deleted file mode 100644
index b98f27008..000000000
--- a/handlers/channels/STAGE_INSTANCE_DELETE.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordStageInstance } from "../../types/discord.ts";
-
-export function handleStageInstanceDelete(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordStageInstance;
-
- bot.events.stageInstanceDelete(bot, {
- id: bot.transformers.snowflake(payload.id),
- guildId: bot.transformers.snowflake(payload.guild_id),
- channelId: bot.transformers.snowflake(payload.channel_id),
- topic: payload.topic,
- });
-}
diff --git a/handlers/channels/STAGE_INSTANCE_UPDATE.ts b/handlers/channels/STAGE_INSTANCE_UPDATE.ts
deleted file mode 100644
index 0685127fc..000000000
--- a/handlers/channels/STAGE_INSTANCE_UPDATE.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordStageInstance } from "../../types/discord.ts";
-
-export function handleStageInstanceUpdate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordStageInstance;
-
- bot.events.stageInstanceUpdate(bot, {
- id: bot.transformers.snowflake(payload.id),
- guildId: bot.transformers.snowflake(payload.guild_id),
- channelId: bot.transformers.snowflake(payload.channel_id),
- topic: payload.topic,
- });
-}
diff --git a/handlers/channels/THREAD_CREATE.ts b/handlers/channels/THREAD_CREATE.ts
deleted file mode 100644
index a13d1247b..000000000
--- a/handlers/channels/THREAD_CREATE.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordChannel, DiscordGatewayPayload } from "../../types/discord.ts";
-
-export async function handleThreadCreate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordChannel;
-
- bot.events.threadCreate(bot, bot.transformers.channel(bot, { channel: payload }));
-}
diff --git a/handlers/channels/THREAD_DELETE.ts b/handlers/channels/THREAD_DELETE.ts
deleted file mode 100644
index 9b9755752..000000000
--- a/handlers/channels/THREAD_DELETE.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordChannel, DiscordGatewayPayload } from "../../types/discord.ts";
-
-export async function handleThreadDelete(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordChannel;
- bot.events.threadDelete(bot, bot.transformers.channel(bot, { channel: payload }));
-}
diff --git a/handlers/channels/THREAD_LIST_SYNC.ts b/handlers/channels/THREAD_LIST_SYNC.ts
deleted file mode 100644
index b476e1385..000000000
--- a/handlers/channels/THREAD_LIST_SYNC.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordThreadListSync } from "../../types/discord.ts";
-
-export async function handleThreadListSync(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordThreadListSync;
-
- const guildId = bot.transformers.snowflake(payload.guild_id);
- return {
- guildId,
- channelIds: payload.channel_ids?.map((id) => bot.transformers.snowflake(id)),
- threads: payload.threads.map((thread) => bot.transformers.channel(bot, { channel: thread, guildId })),
- members: payload.members.map((member) => ({
- id: member.id ? bot.transformers.snowflake(member.id) : undefined,
- userId: member.user_id ? bot.transformers.snowflake(member.user_id) : undefined,
- joinTimestamp: Date.parse(member.join_timestamp),
- })),
- };
-}
diff --git a/handlers/channels/THREAD_MEMBERS_UPDATE.ts b/handlers/channels/THREAD_MEMBERS_UPDATE.ts
deleted file mode 100644
index be40fe07d..000000000
--- a/handlers/channels/THREAD_MEMBERS_UPDATE.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordThreadMembersUpdate } from "../../types/discord.ts";
-
-export async function handleThreadMembersUpdate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordThreadMembersUpdate;
- bot.events.threadMembersUpdate(bot, {
- id: bot.transformers.snowflake(payload.id),
- guildId: bot.transformers.snowflake(payload.guild_id),
- addedMembers: payload.added_members?.map((member) => bot.transformers.threadMember(bot, member)),
- removedMemberIds: payload.removed_member_ids?.map((id) => bot.transformers.snowflake(id)),
- });
-}
diff --git a/handlers/channels/THREAD_MEMBER_UPDATE.ts b/handlers/channels/THREAD_MEMBER_UPDATE.ts
deleted file mode 100644
index 404c7bc3f..000000000
--- a/handlers/channels/THREAD_MEMBER_UPDATE.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordThreadMemberUpdate } from "../../types/discord.ts";
-
-export async function handleThreadMemberUpdate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordThreadMemberUpdate;
-
- bot.events.threadMemberUpdate(bot, {
- id: bot.transformers.snowflake(payload.id),
- guildId: bot.transformers.snowflake(payload.guild_id),
- joinedAt: Date.parse(payload.joined_at),
- flags: payload.flags,
- });
-}
diff --git a/handlers/channels/THREAD_UPDATE.ts b/handlers/channels/THREAD_UPDATE.ts
deleted file mode 100644
index ec839a350..000000000
--- a/handlers/channels/THREAD_UPDATE.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordChannel, DiscordGatewayPayload } from "../../types/discord.ts";
-
-export async function handleThreadUpdate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordChannel;
-
- bot.events.threadUpdate(bot, bot.transformers.channel(bot, { channel: payload }));
-}
diff --git a/handlers/channels/mod.ts b/handlers/channels/mod.ts
deleted file mode 100644
index 3361d1170..000000000
--- a/handlers/channels/mod.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export * from "./CHANNEL_CREATE.ts";
-export * from "./CHANNEL_DELETE.ts";
-export * from "./CHANNEL_PINS_UPDATE.ts";
-export * from "./CHANNEL_UPDATE.ts";
-export * from "./STAGE_INSTANCE_CREATE.ts";
-export * from "./STAGE_INSTANCE_DELETE.ts";
-export * from "./STAGE_INSTANCE_UPDATE.ts";
-export * from "./THREAD_CREATE.ts";
-export * from "./THREAD_DELETE.ts";
-export * from "./THREAD_LIST_SYNC.ts";
-export * from "./THREAD_MEMBERS_UPDATE.ts";
-export * from "./THREAD_UPDATE.ts";
diff --git a/handlers/emojis/GUILD_EMOJIS_UPDATE.ts b/handlers/emojis/GUILD_EMOJIS_UPDATE.ts
deleted file mode 100644
index ba7712750..000000000
--- a/handlers/emojis/GUILD_EMOJIS_UPDATE.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordGuildEmojisUpdate } from "../../types/discord.ts";
-import { Collection } from "../../util/collection.ts";
-
-export async function handleGuildEmojisUpdate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordGuildEmojisUpdate;
-
- bot.events.guildEmojisUpdate(bot, {
- guildId: bot.transformers.snowflake(payload.guild_id),
- emojis: new Collection(payload.emojis.map((emoji) => [bot.transformers.snowflake(emoji.id!), emoji])),
- });
-}
diff --git a/handlers/emojis/mod.ts b/handlers/emojis/mod.ts
deleted file mode 100644
index e0198281f..000000000
--- a/handlers/emojis/mod.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./GUILD_EMOJIS_UPDATE.ts";
diff --git a/handlers/guilds/GUILD_BAN_ADD.ts b/handlers/guilds/GUILD_BAN_ADD.ts
deleted file mode 100644
index 889cd2133..000000000
--- a/handlers/guilds/GUILD_BAN_ADD.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordGuildBanAddRemove } from "../../types/discord.ts";
-
-export async function handleGuildBanAdd(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordGuildBanAddRemove;
- bot.events.guildBanAdd(bot, bot.transformers.user(bot, payload.user), bot.transformers.snowflake(payload.guild_id));
-}
diff --git a/handlers/guilds/GUILD_BAN_REMOVE.ts b/handlers/guilds/GUILD_BAN_REMOVE.ts
deleted file mode 100644
index 993df1c8b..000000000
--- a/handlers/guilds/GUILD_BAN_REMOVE.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordGuildBanAddRemove } from "../../types/discord.ts";
-
-export async function handleGuildBanRemove(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordGuildBanAddRemove;
-
- await bot.events.guildBanRemove(
- bot,
- bot.transformers.user(bot, payload.user),
- bot.transformers.snowflake(payload.guild_id),
- );
-}
diff --git a/handlers/guilds/GUILD_CREATE.ts b/handlers/guilds/GUILD_CREATE.ts
deleted file mode 100644
index 95728e445..000000000
--- a/handlers/guilds/GUILD_CREATE.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import type { Guild } from "../../transformers/guild.ts";
-import { DiscordGatewayPayload, DiscordGuild } from "../../types/discord.ts";
-
-export function handleGuildCreate(bot: Bot, data: DiscordGatewayPayload, shardId: number) {
- const payload = data.d as DiscordGuild;
- bot.events.guildCreate(bot, bot.transformers.guild(bot, { guild: payload, shardId }) as Guild);
-}
diff --git a/handlers/guilds/GUILD_DELETE.ts b/handlers/guilds/GUILD_DELETE.ts
deleted file mode 100644
index 80bddd0e0..000000000
--- a/handlers/guilds/GUILD_DELETE.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordUnavailableGuild } from "../../types/discord.ts";
-
-export async function handleGuildDelete(bot: Bot, data: DiscordGatewayPayload, shardId: number) {
- const payload = data.d as DiscordUnavailableGuild;
- bot.events.guildDelete(bot, bot.transformers.snowflake(payload.id), shardId);
-}
diff --git a/handlers/guilds/GUILD_INTEGRATIONS_UPDATE.ts b/handlers/guilds/GUILD_INTEGRATIONS_UPDATE.ts
deleted file mode 100644
index ae05e67ca..000000000
--- a/handlers/guilds/GUILD_INTEGRATIONS_UPDATE.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordGuildIntegrationsUpdate } from "../../types/discord.ts";
-
-export async function handleGuildIntegrationsUpdate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordGuildIntegrationsUpdate;
-
- bot.events.integrationUpdate(bot, { guildId: bot.transformers.snowflake(payload.guild_id) });
-}
diff --git a/handlers/guilds/GUILD_UPDATE.ts b/handlers/guilds/GUILD_UPDATE.ts
deleted file mode 100644
index d360ae7c7..000000000
--- a/handlers/guilds/GUILD_UPDATE.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import type { Guild } from "../../transformers/guild.ts";
-import { DiscordGatewayPayload, DiscordGuild } from "../../types/discord.ts";
-
-export function handleGuildUpdate(bot: Bot, data: DiscordGatewayPayload, shardId: number) {
- const payload = data.d as DiscordGuild;
-
- bot.events.guildUpdate(bot, bot.transformers.guild(bot, { guild: payload, shardId }) as Guild);
-}
diff --git a/handlers/guilds/automod/AUTO_MODERATION_ACTION_EXECUTION.ts b/handlers/guilds/automod/AUTO_MODERATION_ACTION_EXECUTION.ts
deleted file mode 100644
index d44220ba4..000000000
--- a/handlers/guilds/automod/AUTO_MODERATION_ACTION_EXECUTION.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { DiscordAutoModerationActionExecution, DiscordGatewayPayload } from "../../../types/discord.ts";
-
-/** Requires the MANAGE_GUILD permission. */
-export function handleAutoModerationActionExecution(bot: Bot, data: DiscordGatewayPayload, shardId: number) {
- const payload = data.d as DiscordAutoModerationActionExecution;
- bot.events.automodActionExecution(bot, bot.transformers.automodActionExecution(bot, payload));
-}
diff --git a/handlers/guilds/automod/AUTO_MODERATION_RULE_CREATE.ts b/handlers/guilds/automod/AUTO_MODERATION_RULE_CREATE.ts
deleted file mode 100644
index a41d27b36..000000000
--- a/handlers/guilds/automod/AUTO_MODERATION_RULE_CREATE.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { DiscordAutoModerationRule, DiscordGatewayPayload } from "../../../types/discord.ts";
-
-/** Requires the MANAGE_GUILD permission. */
-export function handleAutoModerationRuleCreate(bot: Bot, data: DiscordGatewayPayload, shardId: number) {
- const payload = data.d as DiscordAutoModerationRule;
- bot.events.automodRuleCreate(bot, bot.transformers.automodRule(bot, payload));
-}
diff --git a/handlers/guilds/automod/AUTO_MODERATION_RULE_DELETE.ts b/handlers/guilds/automod/AUTO_MODERATION_RULE_DELETE.ts
deleted file mode 100644
index 28ec5f3c1..000000000
--- a/handlers/guilds/automod/AUTO_MODERATION_RULE_DELETE.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { DiscordAutoModerationRule, DiscordGatewayPayload } from "../../../types/discord.ts";
-
-/** Requires the MANAGE_GUILD permission. */
-export function handleAutoModerationRuleDelete(bot: Bot, data: DiscordGatewayPayload, shardId: number) {
- const payload = data.d as DiscordAutoModerationRule;
- bot.events.automodRuleDelete(bot, bot.transformers.automodRule(bot, payload));
-}
diff --git a/handlers/guilds/automod/AUTO_MODERATION_RULE_UPDATE.ts b/handlers/guilds/automod/AUTO_MODERATION_RULE_UPDATE.ts
deleted file mode 100644
index 4e717fc5c..000000000
--- a/handlers/guilds/automod/AUTO_MODERATION_RULE_UPDATE.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { DiscordAutoModerationRule, DiscordGatewayPayload } from "../../../types/discord.ts";
-
-/** Requires the MANAGE_GUILD permission. */
-export function handleAutoModerationRuleUpdate(bot: Bot, data: DiscordGatewayPayload, shardId: number) {
- const payload = data.d as DiscordAutoModerationRule;
- bot.events.automodRuleUpdate(bot, bot.transformers.automodRule(bot, payload));
-}
diff --git a/handlers/guilds/automod/mod.ts b/handlers/guilds/automod/mod.ts
deleted file mode 100644
index e69de29bb..000000000
diff --git a/handlers/guilds/mod.ts b/handlers/guilds/mod.ts
deleted file mode 100644
index 354f21794..000000000
--- a/handlers/guilds/mod.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-export * from "./scheduledEvents/mod.ts";
-
-export * from "./GUILD_BAN_ADD.ts";
-export * from "./GUILD_BAN_REMOVE.ts";
-export * from "./GUILD_CREATE.ts";
-export * from "./GUILD_DELETE.ts";
-export * from "./GUILD_INTEGRATIONS_UPDATE.ts";
-export * from "./GUILD_UPDATE.ts";
diff --git a/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_CREATE.ts b/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_CREATE.ts
deleted file mode 100644
index 91841b958..000000000
--- a/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_CREATE.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { DiscordGatewayPayload, DiscordScheduledEvent } from "../../../types/discord.ts";
-
-export function handleGuildScheduledEventCreate(bot: Bot, data: DiscordGatewayPayload, shardId: number) {
- const payload = data.d as DiscordScheduledEvent;
- bot.events.scheduledEventCreate(bot, bot.transformers.scheduledEvent(bot, payload));
-}
diff --git a/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_DELETE.ts b/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_DELETE.ts
deleted file mode 100644
index 704df9697..000000000
--- a/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_DELETE.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { DiscordGatewayPayload, DiscordScheduledEvent } from "../../../types/discord.ts";
-
-export function handleGuildScheduledEventDelete(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordScheduledEvent;
- bot.events.scheduledEventDelete(bot, bot.transformers.scheduledEvent(bot, payload));
-}
diff --git a/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_UPDATE.ts b/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_UPDATE.ts
deleted file mode 100644
index a08f89f94..000000000
--- a/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_UPDATE.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { DiscordGatewayPayload, DiscordScheduledEvent } from "../../../types/discord.ts";
-
-export function handleGuildScheduledEventUpdate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordScheduledEvent;
- bot.events.scheduledEventUpdate(bot, bot.transformers.scheduledEvent(bot, payload));
-}
diff --git a/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_ADD.ts b/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_ADD.ts
deleted file mode 100644
index 144fd672a..000000000
--- a/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_ADD.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { DiscordGatewayPayload, DiscordScheduledEventUserAdd } from "../../../types/discord.ts";
-
-export function handleGuildScheduledEventUserAdd(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordScheduledEventUserAdd;
-
- return bot.events.scheduledEventUserAdd(bot, {
- guildScheduledEventId: bot.transformers.snowflake(payload.guild_scheduled_event_id),
- userId: bot.transformers.snowflake(payload.user_id),
- guildId: bot.transformers.snowflake(payload.guild_id),
- });
-}
diff --git a/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_REMOVE.ts b/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_REMOVE.ts
deleted file mode 100644
index 7a53e9b26..000000000
--- a/handlers/guilds/scheduledEvents/GUILD_SCHEDULED_EVENT_USER_REMOVE.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { DiscordGatewayPayload, DiscordScheduledEventUserRemove } from "../../../types/discord.ts";
-
-export function handleGuildScheduledEventUserRemove(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordScheduledEventUserRemove;
-
- return bot.events.scheduledEventUserRemove(bot, {
- guildScheduledEventId: bot.transformers.snowflake(payload.guild_scheduled_event_id),
- userId: bot.transformers.snowflake(payload.user_id),
- guildId: bot.transformers.snowflake(payload.guild_id),
- });
-}
diff --git a/handlers/guilds/scheduledEvents/mod.ts b/handlers/guilds/scheduledEvents/mod.ts
deleted file mode 100644
index d2f7713dc..000000000
--- a/handlers/guilds/scheduledEvents/mod.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export * from "./GUILD_SCHEDULED_EVENT_CREATE.ts";
-export * from "./GUILD_SCHEDULED_EVENT_DELETE.ts";
-export * from "./GUILD_SCHEDULED_EVENT_UPDATE.ts";
-export * from "./GUILD_SCHEDULED_EVENT_USER_ADD.ts";
-export * from "./GUILD_SCHEDULED_EVENT_USER_REMOVE.ts";
diff --git a/handlers/integrations/INTEGRATION_CREATE.ts b/handlers/integrations/INTEGRATION_CREATE.ts
deleted file mode 100644
index 87a10ab58..000000000
--- a/handlers/integrations/INTEGRATION_CREATE.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordIntegrationCreateUpdate } from "../../types/discord.ts";
-
-export function handleIntegrationCreate(bot: Bot, data: DiscordGatewayPayload) {
- bot.events.integrationCreate(
- bot,
- bot.transformers.integration(bot, data.d as DiscordIntegrationCreateUpdate),
- );
-}
diff --git a/handlers/integrations/INTEGRATION_DELETE.ts b/handlers/integrations/INTEGRATION_DELETE.ts
deleted file mode 100644
index a9f19e1b1..000000000
--- a/handlers/integrations/INTEGRATION_DELETE.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordIntegrationDelete } from "../../types/discord.ts";
-
-export function handleIntegrationDelete(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordIntegrationDelete;
-
- bot.events.integrationDelete(bot, {
- id: bot.transformers.snowflake(payload.id),
- guildId: bot.transformers.snowflake(payload.guild_id),
- applicationId: payload.application_id ? bot.transformers.snowflake(payload.application_id) : undefined,
- });
-}
diff --git a/handlers/integrations/INTEGRATION_UPDATE.ts b/handlers/integrations/INTEGRATION_UPDATE.ts
deleted file mode 100644
index 40cc920f3..000000000
--- a/handlers/integrations/INTEGRATION_UPDATE.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordIntegrationCreateUpdate } from "../../types/discord.ts";
-
-export function handleIntegrationUpdate(bot: Bot, data: DiscordGatewayPayload) {
- bot.events.integrationUpdate(
- bot,
- bot.transformers.integration(bot, data.d as DiscordIntegrationCreateUpdate),
- );
-}
diff --git a/handlers/integrations/mod.ts b/handlers/integrations/mod.ts
deleted file mode 100644
index 43dc6e8b0..000000000
--- a/handlers/integrations/mod.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export * from "./INTEGRATION_CREATE.ts";
-export * from "./INTEGRATION_DELETE.ts";
-export * from "./INTEGRATION_UPDATE.ts";
diff --git a/handlers/interactions/INTERACTION_CREATE.ts b/handlers/interactions/INTERACTION_CREATE.ts
deleted file mode 100644
index 9c9d4cfb2..000000000
--- a/handlers/interactions/INTERACTION_CREATE.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordInteraction } from "../../types/discord.ts";
-
-export async function handleInteractionCreate(bot: Bot, data: DiscordGatewayPayload) {
- bot.cache.unrepliedInteractions.add(bot.transformers.snowflake((data.d as DiscordInteraction).id));
- bot.events.interactionCreate(bot, bot.transformers.interaction(bot, data.d as DiscordInteraction));
-}
diff --git a/handlers/interactions/mod.ts b/handlers/interactions/mod.ts
deleted file mode 100644
index a46da318a..000000000
--- a/handlers/interactions/mod.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./INTERACTION_CREATE.ts";
diff --git a/handlers/invites/INVITE_CREATE.ts b/handlers/invites/INVITE_CREATE.ts
deleted file mode 100644
index 624a694ec..000000000
--- a/handlers/invites/INVITE_CREATE.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordInviteCreate } from "../../types/discord.ts";
-
-export function handleInviteCreate(bot: Bot, data: DiscordGatewayPayload) {
- bot.events.inviteCreate(bot, bot.transformers.invite(bot, data.d as DiscordInviteCreate));
-}
diff --git a/handlers/invites/INVITE_DELETE.ts b/handlers/invites/INVITE_DELETE.ts
deleted file mode 100644
index db4e54d44..000000000
--- a/handlers/invites/INVITE_DELETE.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordInviteDelete } from "../../types/discord.ts";
-
-export function handleInviteDelete(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordInviteDelete;
-
- bot.events.inviteDelete(bot, {
- /** The channel of the invite */
- channelId: bot.transformers.snowflake(payload.channel_id),
- /** The guild of the invite */
- guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
- /** The unique invite code */
- code: payload.code,
- });
-}
diff --git a/handlers/invites/mod.ts b/handlers/invites/mod.ts
deleted file mode 100644
index c41e8a603..000000000
--- a/handlers/invites/mod.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from "./INVITE_CREATE.ts";
-export * from "./INVITE_DELETE.ts";
diff --git a/handlers/members/GUILD_MEMBERS_CHUNK.ts b/handlers/members/GUILD_MEMBERS_CHUNK.ts
deleted file mode 100644
index 99aa05695..000000000
--- a/handlers/members/GUILD_MEMBERS_CHUNK.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordGuildMembersChunk } from "../../types/discord.ts";
-import { PresenceStatus } from "../../types/shared.ts";
-
-export async function handleGuildMembersChunk(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordGuildMembersChunk;
-
- const guildId = bot.transformers.snowflake(payload.guild_id);
-
- if (payload.nonce && payload.chunk_index >= payload.chunk_count - 1) {
- bot.cache.fetchAllMembersProcessingRequests.get(payload.nonce)?.(
- `Member fetching complete. Nonce: ${payload.nonce}`,
- );
- }
-
- return {
- guildId,
- members: payload.members.map((m) =>
- bot.transformers.member(bot, m, guildId, bot.transformers.snowflake(m.user.id))
- ),
- chunkIndex: payload.chunk_index,
- chunkCount: payload.chunk_count,
- notFound: payload.not_found?.map((id) => bot.transformers.snowflake(id)),
- presences: payload.presences?.map((presence) => ({
- user: bot.transformers.user(bot, presence.user),
- guildId,
- status: PresenceStatus[presence.status],
- activities: presence.activities.map((activity) => bot.transformers.activity(bot, activity)),
- clientStatus: {
- desktop: presence.client_status.desktop,
- mobile: presence.client_status.mobile,
- web: presence.client_status.web,
- },
- })),
- nonce: payload.nonce,
- };
-}
diff --git a/handlers/members/GUILD_MEMBER_ADD.ts b/handlers/members/GUILD_MEMBER_ADD.ts
deleted file mode 100644
index 0c87836a0..000000000
--- a/handlers/members/GUILD_MEMBER_ADD.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordGuildMemberAdd } from "../../types/discord.ts";
-
-export async function handleGuildMemberAdd(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordGuildMemberAdd;
- const guildId = bot.transformers.snowflake(payload.guild_id);
- const user = bot.transformers.user(bot, payload.user);
- const member = bot.transformers.member(bot, payload, guildId, user.id);
- bot.events.guildMemberAdd(bot, member, user);
-}
diff --git a/handlers/members/GUILD_MEMBER_REMOVE.ts b/handlers/members/GUILD_MEMBER_REMOVE.ts
deleted file mode 100644
index 383a32be4..000000000
--- a/handlers/members/GUILD_MEMBER_REMOVE.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordGuildMemberRemove } from "../../types/discord.ts";
-
-export async function handleGuildMemberRemove(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordGuildMemberRemove;
- const guildId = bot.transformers.snowflake(payload.guild_id);
- const user = bot.transformers.user(bot, payload.user);
-
- bot.events.guildMemberRemove(bot, user, guildId);
-}
diff --git a/handlers/members/GUILD_MEMBER_UPDATE.ts b/handlers/members/GUILD_MEMBER_UPDATE.ts
deleted file mode 100644
index ba413141b..000000000
--- a/handlers/members/GUILD_MEMBER_UPDATE.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordGuildMemberUpdate } from "../../types/discord.ts";
-
-export async function handleGuildMemberUpdate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordGuildMemberUpdate;
-
- const user = bot.transformers.user(bot, payload.user);
- bot.events.guildMemberUpdate(
- bot,
- bot.transformers.member(bot, payload, bot.transformers.snowflake(payload.guild_id), user.id),
- user,
- );
-}
diff --git a/handlers/members/mod.ts b/handlers/members/mod.ts
deleted file mode 100644
index 77ef238cf..000000000
--- a/handlers/members/mod.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export * from "./GUILD_MEMBER_ADD.ts";
-export * from "./GUILD_MEMBER_REMOVE.ts";
-export * from "./GUILD_MEMBER_UPDATE.ts";
-export * from "./GUILD_MEMBERS_CHUNK.ts";
diff --git a/handlers/messages/MESSAGE_CREATE.ts b/handlers/messages/MESSAGE_CREATE.ts
deleted file mode 100644
index 012bd4104..000000000
--- a/handlers/messages/MESSAGE_CREATE.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordMessage } from "../../types/discord.ts";
-
-export async function handleMessageCreate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordMessage;
-
- bot.events.messageCreate(bot, bot.transformers.message(bot, payload));
-}
diff --git a/handlers/messages/MESSAGE_DELETE.ts b/handlers/messages/MESSAGE_DELETE.ts
deleted file mode 100644
index a20f6c5e2..000000000
--- a/handlers/messages/MESSAGE_DELETE.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordMessageDelete } from "../../types/discord.ts";
-
-export async function handleMessageDelete(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordMessageDelete;
-
- bot.events.messageDelete(bot, {
- id: bot.transformers.snowflake(payload.id),
- channelId: bot.transformers.snowflake(payload.channel_id),
- guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
- });
-}
diff --git a/handlers/messages/MESSAGE_DELETE_BULK.ts b/handlers/messages/MESSAGE_DELETE_BULK.ts
deleted file mode 100644
index 6fd856e64..000000000
--- a/handlers/messages/MESSAGE_DELETE_BULK.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordMessageDeleteBulk } from "../../types/discord.ts";
-
-export async function handleMessageDeleteBulk(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordMessageDeleteBulk;
-
- const channelId = bot.transformers.snowflake(payload.channel_id);
- const guildId = payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined;
-
- bot.events.messageDeleteBulk(bot, {
- ids: payload.ids.map((id) => bot.transformers.snowflake(id)),
- channelId: bot.transformers.snowflake(payload.channel_id),
- guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
- });
-}
diff --git a/handlers/messages/MESSAGE_REACTION_ADD.ts b/handlers/messages/MESSAGE_REACTION_ADD.ts
deleted file mode 100644
index 9d14b2a1a..000000000
--- a/handlers/messages/MESSAGE_REACTION_ADD.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordMessageReactionAdd } from "../../types/discord.ts";
-
-export async function handleMessageReactionAdd(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordMessageReactionAdd;
-
- const guildId = payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined;
- const userId = bot.transformers.snowflake(payload.user_id);
- bot.events.reactionAdd(bot, {
- userId,
- channelId: bot.transformers.snowflake(payload.channel_id),
- messageId: bot.transformers.snowflake(payload.message_id),
- guildId,
- member: payload.member && guildId ? bot.transformers.member(bot, payload.member, guildId, userId) : undefined,
- user: payload.member ? bot.transformers.user(bot, payload.member.user) : undefined,
- emoji: bot.transformers.emoji(bot, payload.emoji),
- });
-}
diff --git a/handlers/messages/MESSAGE_REACTION_REMOVE.ts b/handlers/messages/MESSAGE_REACTION_REMOVE.ts
deleted file mode 100644
index b33341863..000000000
--- a/handlers/messages/MESSAGE_REACTION_REMOVE.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordMessageReactionRemove } from "../../types/discord.ts";
-
-export async function handleMessageReactionRemove(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordMessageReactionRemove;
-
- bot.events.reactionRemove(bot, {
- userId: bot.transformers.snowflake(payload.user_id),
- channelId: bot.transformers.snowflake(payload.channel_id),
- messageId: bot.transformers.snowflake(payload.message_id),
- guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
- emoji: bot.transformers.emoji(bot, payload.emoji),
- });
-}
diff --git a/handlers/messages/MESSAGE_REACTION_REMOVE_ALL.ts b/handlers/messages/MESSAGE_REACTION_REMOVE_ALL.ts
deleted file mode 100644
index f2a384925..000000000
--- a/handlers/messages/MESSAGE_REACTION_REMOVE_ALL.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordMessageReactionRemoveAll } from "../../types/discord.ts";
-
-export async function handleMessageReactionRemoveAll(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordMessageReactionRemoveAll;
-
- bot.events.reactionRemoveAll(bot, {
- channelId: bot.transformers.snowflake(payload.channel_id),
- messageId: bot.transformers.snowflake(payload.message_id),
- guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
- });
-}
diff --git a/handlers/messages/MESSAGE_REACTION_REMOVE_EMOJI.ts b/handlers/messages/MESSAGE_REACTION_REMOVE_EMOJI.ts
deleted file mode 100644
index 3f102a110..000000000
--- a/handlers/messages/MESSAGE_REACTION_REMOVE_EMOJI.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordMessageReactionRemoveEmoji } from "../../types/discord.ts";
-
-export async function handleMessageReactionRemoveEmoji(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordMessageReactionRemoveEmoji;
-
- bot.events.reactionRemoveEmoji(bot, {
- channelId: bot.transformers.snowflake(payload.channel_id),
- messageId: bot.transformers.snowflake(payload.message_id),
- guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
- emoji: bot.transformers.emoji(bot, payload.emoji),
- });
-}
diff --git a/handlers/messages/MESSAGE_UPDATE.ts b/handlers/messages/MESSAGE_UPDATE.ts
deleted file mode 100644
index d26b8ed54..000000000
--- a/handlers/messages/MESSAGE_UPDATE.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordMessage } from "../../types/discord.ts";
-
-export async function handleMessageUpdate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordMessage;
- if (!payload.edited_timestamp) return;
-
- bot.events.messageUpdate(bot, bot.transformers.message(bot, payload));
-}
diff --git a/handlers/messages/mod.ts b/handlers/messages/mod.ts
deleted file mode 100644
index 7ad80508a..000000000
--- a/handlers/messages/mod.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-export * from "./MESSAGE_CREATE.ts";
-export * from "./MESSAGE_DELETE_BULK.ts";
-export * from "./MESSAGE_DELETE.ts";
-export * from "./MESSAGE_REACTION_ADD.ts";
-export * from "./MESSAGE_REACTION_REMOVE_ALL.ts";
-export * from "./MESSAGE_REACTION_REMOVE_EMOJI.ts";
-export * from "./MESSAGE_REACTION_REMOVE.ts";
-export * from "./MESSAGE_UPDATE.ts";
diff --git a/handlers/misc/PRESENCE_UPDATE.ts b/handlers/misc/PRESENCE_UPDATE.ts
deleted file mode 100644
index 2071f8da1..000000000
--- a/handlers/misc/PRESENCE_UPDATE.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordPresenceUpdate } from "../../types/discord.ts";
-
-export async function handlePresenceUpdate(bot: Bot, data: DiscordGatewayPayload) {
- bot.events.presenceUpdate(bot, bot.transformers.presence(bot, data.d as DiscordPresenceUpdate));
-}
diff --git a/handlers/misc/READY.ts b/handlers/misc/READY.ts
deleted file mode 100644
index f1d6b8616..000000000
--- a/handlers/misc/READY.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordReady } from "../../types/discord.ts";
-
-export function handleReady(bot: Bot, data: DiscordGatewayPayload, shardId: number) {
- const payload = data.d as DiscordReady;
- // Triggered on each shard
- bot.events.ready(
- bot,
- {
- shardId,
- v: payload.v,
- user: bot.transformers.user(bot, payload.user),
- guilds: payload.guilds.map((p) => bot.transformers.snowflake(p.id)),
- sessionId: payload.session_id,
- shard: payload.shard,
- applicationId: bot.transformers.snowflake(payload.application.id),
- },
- payload,
- );
-
- bot.id = bot.transformers.snowflake(payload.user.id);
- bot.applicationId = bot.transformers.snowflake(payload.application.id);
-}
diff --git a/handlers/misc/TYPING_START.ts b/handlers/misc/TYPING_START.ts
deleted file mode 100644
index 6bb6e06fd..000000000
--- a/handlers/misc/TYPING_START.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordTypingStart } from "../../types/discord.ts";
-
-export function handleTypingStart(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordTypingStart;
-
- const guildId = payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined;
- const userId = bot.transformers.snowflake(payload.user_id);
-
- bot.events.typingStart(bot, {
- guildId,
- channelId: bot.transformers.snowflake(payload.channel_id),
- userId,
- timestamp: payload.timestamp,
- member: payload.member && guildId ? bot.transformers.member(bot, payload.member, guildId, userId) : undefined,
- });
-}
diff --git a/handlers/misc/USER_UPDATE.ts b/handlers/misc/USER_UPDATE.ts
deleted file mode 100644
index c02f2bdf8..000000000
--- a/handlers/misc/USER_UPDATE.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordUser } from "../../types/discord.ts";
-
-export async function handleUserUpdate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordUser;
- bot.events.botUpdate(bot, bot.transformers.user(bot, payload));
-}
diff --git a/handlers/misc/mod.ts b/handlers/misc/mod.ts
deleted file mode 100644
index 49de2cb20..000000000
--- a/handlers/misc/mod.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export * from "./PRESENCE_UPDATE.ts";
-export * from "./READY.ts";
-export * from "./TYPING_START.ts";
-export * from "./USER_UPDATE.ts";
diff --git a/handlers/mod.ts b/handlers/mod.ts
deleted file mode 100644
index 56c25632b..000000000
--- a/handlers/mod.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export * from "./channels/mod.ts";
-export * from "./emojis/mod.ts";
-export * from "./guilds/mod.ts";
-export * from "./integrations/mod.ts";
-export * from "./interactions/mod.ts";
-export * from "./invites/mod.ts";
-export * from "./members/mod.ts";
-export * from "./messages/mod.ts";
-export * from "./misc/mod.ts";
-export * from "./roles/mod.ts";
-export * from "./voice/mod.ts";
-export * from "./webhooks/mod.ts";
diff --git a/handlers/roles/GUILD_ROLE_CREATE.ts b/handlers/roles/GUILD_ROLE_CREATE.ts
deleted file mode 100644
index d1fc1e9d4..000000000
--- a/handlers/roles/GUILD_ROLE_CREATE.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordGuildRoleCreate } from "../../types/discord.ts";
-
-export async function handleGuildRoleCreate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordGuildRoleCreate;
- bot.events.roleCreate(
- bot,
- bot.transformers.role(bot, { role: payload.role, guildId: bot.transformers.snowflake(payload.guild_id) }),
- );
-}
diff --git a/handlers/roles/GUILD_ROLE_DELETE.ts b/handlers/roles/GUILD_ROLE_DELETE.ts
deleted file mode 100644
index e0e13fa22..000000000
--- a/handlers/roles/GUILD_ROLE_DELETE.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordGuildRoleDelete } from "../../types/discord.ts";
-
-export async function handleGuildRoleDelete(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordGuildRoleDelete;
- bot.events.roleDelete(bot, {
- roleId: bot.transformers.snowflake(payload.role_id),
- guildId: bot.transformers.snowflake(payload.guild_id),
- });
-}
diff --git a/handlers/roles/GUILD_ROLE_UPDATE.ts b/handlers/roles/GUILD_ROLE_UPDATE.ts
deleted file mode 100644
index 7d4ce211d..000000000
--- a/handlers/roles/GUILD_ROLE_UPDATE.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordGuildRoleUpdate } from "../../types/discord.ts";
-
-export async function handleGuildRoleUpdate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordGuildRoleUpdate;
-
- bot.events.roleUpdate(
- bot,
- bot.transformers.role(bot, { role: payload.role, guildId: bot.transformers.snowflake(payload.guild_id) }),
- );
-}
diff --git a/handlers/roles/mod.ts b/handlers/roles/mod.ts
deleted file mode 100644
index 1a82c4299..000000000
--- a/handlers/roles/mod.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export * from "./GUILD_ROLE_CREATE.ts";
-export * from "./GUILD_ROLE_DELETE.ts";
-export * from "./GUILD_ROLE_UPDATE.ts";
diff --git a/handlers/voice/VOICE_SERVER_UPDATE.ts b/handlers/voice/VOICE_SERVER_UPDATE.ts
deleted file mode 100644
index 73b5dd250..000000000
--- a/handlers/voice/VOICE_SERVER_UPDATE.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordVoiceServerUpdate } from "../../types/discord.ts";
-
-export async function handleVoiceServerUpdate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordVoiceServerUpdate;
-
- bot.events.voiceServerUpdate(bot, {
- token: payload.token,
- guildId: bot.transformers.snowflake(payload.guild_id),
- endpoint: payload.endpoint ?? undefined,
- });
-}
diff --git a/handlers/voice/VOICE_STATE_UPDATE.ts b/handlers/voice/VOICE_STATE_UPDATE.ts
deleted file mode 100644
index 9c3767812..000000000
--- a/handlers/voice/VOICE_STATE_UPDATE.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordVoiceState } from "../../types/discord.ts";
-
-export async function handleVoiceStateUpdate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordVoiceState;
- if (!payload.guild_id) return;
-
- const guildId = bot.transformers.snowflake(payload.guild_id);
-
- bot.events.voiceStateUpdate(bot, bot.transformers.voiceState(bot, { voiceState: payload, guildId }));
-}
diff --git a/handlers/voice/mod.ts b/handlers/voice/mod.ts
deleted file mode 100644
index 86644b46e..000000000
--- a/handlers/voice/mod.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from "./VOICE_SERVER_UPDATE.ts";
-export * from "./VOICE_STATE_UPDATE.ts";
diff --git a/handlers/webhooks/WEBHOOKS_UPDATE.ts b/handlers/webhooks/WEBHOOKS_UPDATE.ts
deleted file mode 100644
index 3271649e8..000000000
--- a/handlers/webhooks/WEBHOOKS_UPDATE.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { DiscordGatewayPayload, DiscordWebhookUpdate } from "../../types/discord.ts";
-
-export function handleWebhooksUpdate(bot: Bot, data: DiscordGatewayPayload) {
- const payload = data.d as DiscordWebhookUpdate;
- bot.events.webhooksUpdate(bot, {
- channelId: bot.transformers.snowflake(payload.channel_id),
- guildId: bot.transformers.snowflake(payload.guild_id),
- });
-}
diff --git a/handlers/webhooks/mod.ts b/handlers/webhooks/mod.ts
deleted file mode 100644
index 36629c80b..000000000
--- a/handlers/webhooks/mod.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./WEBHOOKS_UPDATE.ts";
diff --git a/helpers/channels/announcements/followAnnouncementChannel.ts b/helpers/channels/announcements/followAnnouncementChannel.ts
deleted file mode 100644
index c8ed985bb..000000000
--- a/helpers/channels/announcements/followAnnouncementChannel.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { DiscordFollowedChannel } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Follows an announcement channel, allowing messages posted within it to be cross-posted into the target channel.
- *
- * @param bot - The bot instance to use to make the request.
- * @param sourceChannelId - The ID of the announcement channel to follow.
- * @param targetChannelId - The ID of the target channel - the channel to cross-post to.
- * @returns An instance of {@link FollowedChannel}.
- *
- * @remarks
- * Requires the `MANAGE_WEBHOOKS` permission in the __target channel__.
- *
- * Fires a _Webhooks Update_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#follow-announcement-channel}
- */
-export async function followAnnouncementChannel(
- bot: Bot,
- sourceChannelId: BigString,
- targetChannelId: BigString,
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "POST",
- bot.constants.routes.CHANNEL_FOLLOW(sourceChannelId),
- {
- webhook_channel_id: targetChannelId,
- },
- );
-
- return bot.transformers.snowflake(result.webhook_id);
-}
diff --git a/helpers/channels/announcements/mod.ts b/helpers/channels/announcements/mod.ts
deleted file mode 100644
index 47fa8cc58..000000000
--- a/helpers/channels/announcements/mod.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./followAnnouncementChannel.ts";
diff --git a/helpers/channels/createChannel.ts b/helpers/channels/createChannel.ts
deleted file mode 100644
index 394fb5725..000000000
--- a/helpers/channels/createChannel.ts
+++ /dev/null
@@ -1,84 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { WithReason } from "../../mod.ts";
-import { Channel } from "../../transformers/channel.ts";
-import { DiscordChannel } from "../../types/discord.ts";
-import { OverwriteReadable } from "../../types/discordeno.ts";
-import { BigString, ChannelTypes } from "../../types/shared.ts";
-
-/**
- * Creates a channel within a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to create the channel within.
- * @param options - The parameters for the creation of the channel.
- * @returns An instance of the created {@link Channel}.
- *
- * @remarks
- * Requires the `MANAGE_CHANNELS` permission.
- *
- * If setting permission overwrites, only the permissions the bot user has in the guild can be allowed or denied.
- *
- * Setting the `MANAGE_ROLES` permission is only possible for guild administrators.
- *
- * Fires a _Channel Create_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#create-guild-channel}
- */
-export async function createChannel(bot: Bot, guildId: BigString, options: CreateGuildChannel): Promise {
- // BITRATE IS IN THOUSANDS SO IF USER PROVIDES 32 WE CONVERT TO 32000
- if (options?.bitrate && options.bitrate < 1000) options.bitrate *= 1000;
-
- const result = await bot.rest.runMethod(
- bot.rest,
- "POST",
- bot.constants.routes.GUILD_CHANNELS(guildId),
- options
- ? {
- name: options.name,
- topic: options.topic,
- bitrate: options.bitrate,
- user_limit: options.userLimit,
- rate_limit_per_user: options.rateLimitPerUser,
- position: options.position,
- parent_id: options.parentId?.toString(),
- nsfw: options.nsfw,
- permission_overwrites: options?.permissionOverwrites?.map((overwrite) => ({
- id: overwrite.id.toString(),
- type: overwrite.type,
- allow: overwrite.allow ? bot.utils.calculateBits(overwrite.allow) : null,
- deny: overwrite.deny ? bot.utils.calculateBits(overwrite.deny) : null,
- })),
- type: options?.type || ChannelTypes.GuildText,
- reason: options.reason,
- default_auto_archive_duration: options?.defaultAutoArchiveDuration,
- }
- : {},
- );
-
- return bot.transformers.channel(bot, { channel: result, guildId: bot.transformers.snowflake(guildId) });
-}
-
-export interface CreateGuildChannel extends WithReason {
- /** Channel name (1-100 characters) */
- name: string;
- /** The type of channel */
- type?: ChannelTypes;
- /** Channel topic (0-1024 characters) */
- topic?: string;
- /** The bitrate (in bits) of the voice channel (voice only) */
- bitrate?: number;
- /** The user limit of the voice channel (voice only) */
- userLimit?: 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 */
- rateLimitPerUser?: number;
- /** Sorting position of the channel */
- position?: number;
- /** The channel's permission overwrites */
- permissionOverwrites?: OverwriteReadable[];
- /** Id of the parent category for a channel */
- parentId?: BigString;
- /** Whether the channel is nsfw */
- nsfw?: boolean;
- /** Default duration (in minutes) that clients (not the API) use for newly created threads in this channel, to determine when to automatically archive the thread after the last activity */
- defaultAutoArchiveDuration?: number;
-}
diff --git a/helpers/channels/deleteChannel.ts b/helpers/channels/deleteChannel.ts
deleted file mode 100644
index 53fbcc20b..000000000
--- a/helpers/channels/deleteChannel.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { BigString } from "../../types/shared.ts";
-
-/**
- * Deletes a channel from within a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the channel to delete.
- * @returns An instance of the deleted {@link Channel}.
- *
- * @remarks
- * For community guilds, the _Rules_, _Guidelines_ and _Community Update_ channels cannot be deleted.
- *
- * If the channel is a thread:
- * - Requires the `MANAGE_THREADS` permission.
- *
- * - Fires a _Thread Delete_ gateway event.
- *
- * Otherwise:
- * - Requires the `MANAGE_CHANNELS` permission.
- *
- * - ⚠️ Deleting a category channel does not delete its child channels.
- * Instead, they will have their `parent_id` property removed, and a `Channel Update` gateway event will fire for each of them.
- *
- * - Fires a _Channel Delete_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#deleteclose-channel}
- */
-export async function deleteChannel(bot: Bot, channelId: BigString, reason?: string): Promise {
- return await bot.rest.runMethod(
- bot.rest,
- "DELETE",
- bot.constants.routes.CHANNEL(channelId),
- {
- reason,
- },
- );
-}
diff --git a/helpers/channels/deleteChannelPermissionOverride.ts b/helpers/channels/deleteChannelPermissionOverride.ts
deleted file mode 100644
index 581cfdc8e..000000000
--- a/helpers/channels/deleteChannelPermissionOverride.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { BigString } from "../../types/shared.ts";
-
-/**
- * Deletes a permission override for a user or role in a channel.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the channel to delete the permission override of.
- * @param overwriteId - The ID of the permission override to delete.
- *
- * @remarks
- * Requires the `MANAGE_ROLES` permission.
- *
- * Fires a _Channel Update_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#delete-channel-permission}
- */
-export async function deleteChannelPermissionOverride(
- bot: Bot,
- channelId: BigString,
- overwriteId: BigString,
- reason?: string,
-): Promise {
- return await bot.rest.runMethod(
- bot.rest,
- "DELETE",
- bot.constants.routes.CHANNEL_OVERWRITE(channelId, overwriteId),
- reason ? { reason } : undefined,
- );
-}
diff --git a/helpers/channels/editChannel.ts b/helpers/channels/editChannel.ts
deleted file mode 100644
index 4fb317470..000000000
--- a/helpers/channels/editChannel.ts
+++ /dev/null
@@ -1,226 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { WithReason } from "../../mod.ts";
-import { Channel } from "../../transformers/channel.ts";
-import { DiscordChannel } from "../../types/discord.ts";
-import { OverwriteReadable } from "../../types/discordeno.ts";
-import { BigString, ChannelTypes, VideoQualityModes } from "../../types/shared.ts";
-
-/**
- * Edits a channel's settings.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the channel to edit.
- * @param options - The parameters for the edit of the channel.
- * @returns An instance of the edited {@link Channel}.
- *
- * @remarks
- * If editing a channel of type {@link ChannelTypes.GroupDm}:
- * - Fires a _Channel Update_ gateway event.
- *
- * If editing a thread channel:
- * - Requires the `MANAGE_THREADS` permission __unless__ if setting the `archived` property to `false` when the `locked` property is also `false`, in which case only the `SEND_MESSAGES` permission is required.
- *
- * - Fires a _Thread Update_ gateway event.
- *
- * If editing a guild channel:
- * - Requires the `MANAGE_CHANNELS` permission.
- *
- * - If modifying permission overrides:
- * - Requires the `MANAGE_ROLES` permission.
- *
- * - Only permissions the bot user has in the guild or parent channel can be allowed/denied __unless__ the bot user has a `MANAGE_ROLES` permission override in the channel.
- *
- * - If modifying a channel of type {@link ChannelTypes.GuildCategory}:
- * - Fires a _Channel Update_ gateway event for each child channel impacted in this change.
- * - Otherwise:
- * - Fires a _Channel Update_ gateway event.
- */
-export async function editChannel(bot: Bot, channelId: BigString, options: ModifyChannel): Promise {
- if (options.name || options.topic) {
- const request = editChannelNameTopicQueue.get(channelId);
- if (!request) {
- // If this hasn't been done before simply add 1 for it
- editChannelNameTopicQueue.set(channelId, {
- channelId: channelId,
- amount: 1,
- // 10 minutes from now
- timestamp: Date.now() + 600000,
- items: [],
- });
- } else if (request.amount === 1) {
- // Start queuing future requests to this channel
- request.amount = 2;
- request.timestamp = Date.now() + 600000;
- } else {
- return new Promise((resolve, reject) => {
- // 2 have already been used add to queue
- request.items.push({ channelId, options, resolve, reject });
- if (editChannelProcessing) return;
- editChannelProcessing = true;
- processEditChannelQueue(bot);
- });
- }
- }
-
- const result = await bot.rest.runMethod(
- bot.rest,
- "PATCH",
- bot.constants.routes.CHANNEL(channelId),
- {
- name: options.name,
- topic: options.topic,
- bitrate: options.bitrate,
- user_limit: options.userLimit,
- rate_limit_per_user: options.rateLimitPerUser,
- position: options.position,
- parent_id: options.parentId === null ? null : options.parentId?.toString(),
- nsfw: options.nsfw,
- type: options.type,
- archived: options.archived,
- auto_archive_duration: options.autoArchiveDuration,
- locked: options.locked,
- invitable: options.invitable,
- permission_overwrites: options.permissionOverwrites
- ? options.permissionOverwrites?.map((overwrite) => ({
- id: overwrite.id.toString(),
- type: overwrite.type,
- allow: overwrite.allow ? bot.utils.calculateBits(overwrite.allow) : null,
- deny: overwrite.deny ? bot.utils.calculateBits(overwrite.deny) : null,
- }))
- : undefined,
- available_tags: options.availableTags
- ? options.availableTags.map((availableTag) => ({
- id: availableTag.id,
- name: availableTag.name,
- moderated: availableTag.moderated,
- emoji_id: availableTag.emojiId,
- emoji_name: availableTag.emojiName,
- }))
- : undefined,
- default_reaction_emoji: options.defaultReactionEmoji
- ? {
- emoji_id: options.defaultReactionEmoji.emojiId,
- emoji_name: options.defaultReactionEmoji.emojiName,
- }
- : undefined,
- reason: options.reason,
- },
- );
-
- return bot.transformers.channel(bot, { channel: result, guildId: bot.transformers.snowflake(result.guild_id!) });
-}
-
-interface EditChannelRequest {
- amount: number;
- timestamp: number;
- channelId: BigString;
- items: {
- channelId: BigString;
- options: ModifyChannel;
- resolve: (channel: Channel) => void;
- // deno-lint-ignore no-explicit-any
- reject: (error: any) => void;
- }[];
-}
-
-const editChannelNameTopicQueue = new Map();
-let editChannelProcessing = false;
-
-function processEditChannelQueue(bot: Bot): void {
- if (!editChannelProcessing) return;
-
- const now = Date.now();
- editChannelNameTopicQueue.forEach(async (request) => {
- bot.events.debug(`Running forEach loop in edit_channel file.`);
- if (now < request.timestamp) return;
- // 10 minutes have passed so we can reset this channel again
- if (!request.items.length) {
- return editChannelNameTopicQueue.delete(request.channelId);
- }
- request.amount = 0;
- // There are items to process for this request
- const details = request.items.shift();
-
- if (!details) return;
-
- await bot.helpers
- .editChannel(details.channelId, details.options)
- .then((result) => details.resolve(result))
- .catch(details.reject);
- const secondDetails = request.items.shift();
- if (!secondDetails) return;
-
- await bot.helpers
- .editChannel(secondDetails.channelId, secondDetails.options)
- .then((result) => secondDetails.resolve(result))
- .catch(secondDetails.reject);
- return;
- });
-
- if (editChannelNameTopicQueue.size) {
- setTimeout(() => {
- bot.events.debug(`Running setTimeout in EDIT_CHANNEL file.`);
- processEditChannelQueue(bot);
- }, 60000);
- } else {
- editChannelProcessing = false;
- }
-}
-
-export interface ModifyChannel extends WithReason {
- /** 1-100 character channel name */
- name?: string;
- /** The type of channel; only conversion between text and news is supported and only in guilds with the "NEWS" feature */
- type?: ChannelTypes;
- /** The position of the channel in the left-hand listing */
- position?: number | null;
- /** 0-1024 character channel topic */
- topic?: string | null;
- /** Whether the channel is nsfw */
- nsfw?: boolean | null;
- /** 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 | null;
- /** The bitrate (in bits) of the voice channel; 8000 to 96000 (128000 for VIP servers) */
- bitrate?: number | null;
- /** The user limit of the voice channel; 0 refers to no limit, 1 to 99 refers to a user limit */
- userLimit?: number | null;
- /** Channel or category-specific permissions */
- permissionOverwrites?: OverwriteReadable[] | null;
- /** Id of the new parent category for a channel */
- parentId?: BigString | null;
- /** Voice region id for the voice channel, automatic when set to null */
- rtcRegion?: string | null;
- /** The camera video quality mode of the voice channel */
- videoQualityMode?: VideoQualityModes;
- /** Whether the thread is archived */
- archived?: boolean;
- /** Duration in minutes to automatically archive the thread after recent activity */
- autoArchiveDuration?: 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;
-
- /** The set of tags that can be used in a GUILD_FORUM channel */
- availableTags?: {
- /** The id of the tag */
- id: string;
- /** The name of the tag (0-20 characters) */
- name: string;
- /** Whether this tag can only be added to or removed from threads by a member with the MANAGE_THREADS permission */
- moderated: boolean;
- /** The id of a guild's custom emoji At most one of emoji_id and emoji_name may be set. */
- emojiId: string;
- /** The unicode character of the emoji */
- emojiName: string;
- }[];
- /** the emoji to show in the add reaction button on a thread in a GUILD_FORUM channel */
- defaultReactionEmoji?: {
- /** The id of a guild's custom emoji */
- emojiId: string;
- /** The unicode character of the emoji */
- emojiName: string | null;
- };
- /** the initial rate_limit_per_user to set on newly created threads in a channel. this field is copied to the thread at creation time and does not live update. */
- defaultThreadRateLimitPerUser?: number;
-}
diff --git a/helpers/channels/editChannelPermissionOverrides.ts b/helpers/channels/editChannelPermissionOverrides.ts
deleted file mode 100644
index 256441ae7..000000000
--- a/helpers/channels/editChannelPermissionOverrides.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { BigString, WithReason } from "../../mod.ts";
-import { OverwriteReadable } from "../../types/discordeno.ts";
-
-/**
- * Edits the permission overrides for a user or role in a channel.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the channel to edit the permission overrides of.
- * @param options - The permission override.
- *
- * @remarks
- * Requires the `MANAGE_ROLES` permission.
- *
- * Only permissions the bot user has in the guild or parent channel can be allowed/denied __unless__ the bot user has a `MANAGE_ROLES` permission override in the channel.
- *
- * Fires a _Channel Update_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#edit-channel-permissions}
- */
-export async function editChannelPermissionOverrides(
- bot: Bot,
- channelId: BigString,
- options: EditChannelPermissionOverridesOptions,
-): Promise {
- return await bot.rest.runMethod(
- bot.rest,
- "PUT",
- bot.constants.routes.CHANNEL_OVERWRITE(channelId, options.id),
- {
- allow: options.allow ? bot.utils.calculateBits(options.allow) : "0",
- deny: options.deny ? bot.utils.calculateBits(options.deny) : "0",
- type: options.type,
- reason: options.reason,
- },
- );
-}
-
-export interface EditChannelPermissionOverridesOptions extends OverwriteReadable, WithReason {}
diff --git a/helpers/channels/editChannelPositions.ts b/helpers/channels/editChannelPositions.ts
deleted file mode 100644
index e4c3823a2..000000000
--- a/helpers/channels/editChannelPositions.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { BigString } from "../../types/shared.ts";
-
-export const swapChannels = editChannelPositions;
-
-/**
- * Edits the positions of a set of channels in a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild in which to edit the positions of the channels.
- * @param channelPositions - A set of objects defining the updated positions of the channels.
- *
- * @remarks
- * Requires the `MANAGE_CHANNELS` permission.
- *
- * Fires a _Channel Update_ gateway event for every channel impacted in this change.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions}
- */
-export async function editChannelPositions(
- bot: Bot,
- guildId: BigString,
- channelPositions: ModifyGuildChannelPositions[],
-): Promise {
- if (!channelPositions.length) {
- throw new Error("You must provide at least one channels to be moved.");
- }
-
- return await bot.rest.runMethod(
- bot.rest,
- "PATCH",
- bot.constants.routes.GUILD_CHANNELS(guildId),
- channelPositions.map((channelPosition) => ({
- id: channelPosition.id,
- position: channelPosition.position,
- lock_positions: channelPosition.lockPositions,
- parent_id: channelPosition.parentId,
- })),
- );
-}
-
-/** https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions */
-export interface ModifyGuildChannelPositions {
- /** Channel id */
- id: string;
- /** Sorting position of the channel */
- position: number | null;
- /** Syncs the permission overwrites with the new parent, if moving to a new category */
- lockPositions?: boolean | null;
- /** The new parent ID for the channel that is moved */
- parentId?: string | null;
-}
diff --git a/helpers/channels/forums/createForumThread.ts b/helpers/channels/forums/createForumThread.ts
deleted file mode 100644
index 6ff993b6d..000000000
--- a/helpers/channels/forums/createForumThread.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { Channel } from "../../../transformers/channel.ts";
-import { Embed } from "../../../transformers/embed.ts";
-import { DiscordChannel } from "../../../types/discord.ts";
-import { AllowedMentions, BigString, FileContent, MessageComponents, WithReason } from "../../../types/mod.ts";
-
-/**
- * Creates a new thread in a forum channel, and sends a message within the created thread.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the forum channel to create the thread within.
- * @param options - The parameters for the creation of the thread.
- * @returns An instance of {@link Channel} with a nested {@link Message} object.
- *
- * @remarks
- * Requires the `CREATE_MESSAGES` permission.
- *
- * Fires a _Thread Create_ gateway event.
- * Fires a _Message Create_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#start-thread-in-forum-channel}
- *
- * @experimental
- */
-export async function createForumThread(
- bot: Bot,
- channelId: BigString,
- options: CreateForumPostWithMessage,
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "POST",
- bot.constants.routes.FORUM_START(channelId),
- {
- name: options.name,
- auto_archive_duration: options.autoArchiveDuration,
- rate_limit_per_user: options.rateLimitPerUser,
- reason: options.reason,
-
- content: options.content,
- embeds: options.embeds?.map((embed) => bot.transformers.reverse.embed(bot, embed)),
- allowed_mentions: options.allowedMentions
- ? {
- parse: options.allowedMentions?.parse,
- roles: options.allowedMentions?.roles?.map((id) => id.toString()),
- users: options.allowedMentions?.users?.map((id) => id.toString()),
- replied_user: options.allowedMentions?.repliedUser,
- }
- : undefined,
- file: options.file,
- components: options.components?.map((component) => bot.transformers.reverse.component(bot, component)),
- },
- );
-
- return bot.transformers.channel(bot, { channel: result, guildId: bot.transformers.snowflake(result.guild_id!) });
-}
-
-export interface CreateForumPostWithMessage extends WithReason {
- /** 1-100 character thread name */
- name: string;
- /** Duration in minutes to automatically archive the thread after recent activity */
- autoArchiveDuration: 60 | 1440 | 4320 | 10080;
- /** Amount of seconds a user has to wait before sending another message (0-21600) */
- rateLimitPerUser?: number | null;
- /** The message contents (up to 2000 characters) */
- content?: string;
- /** Embedded `rich` content (up to 6000 characters) */
- embeds?: Embed[];
- /** Allowed mentions for the message */
- allowedMentions?: AllowedMentions;
- /** The contents of the file being sent */
- file?: FileContent | FileContent[];
- /** The components you would like to have sent in this message */
- components?: MessageComponents;
-}
diff --git a/helpers/channels/forums/mod.ts b/helpers/channels/forums/mod.ts
deleted file mode 100644
index c1408122b..000000000
--- a/helpers/channels/forums/mod.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./createForumThread.ts";
diff --git a/helpers/channels/getChannel.ts b/helpers/channels/getChannel.ts
deleted file mode 100644
index e9740f056..000000000
--- a/helpers/channels/getChannel.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { Channel } from "../../transformers/channel.ts";
-import { DiscordChannel } from "../../types/discord.ts";
-import { BigString } from "../../types/shared.ts";
-
-/**
- * Gets a channel by its ID.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the channel to get.
- * @returns An instance of {@link Channel}.
- *
- * @remarks
- * If the channel is a thread, a {@link ThreadMember} object is included in the result.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#get-channel}
- */
-export async function getChannel(bot: Bot, channelId: BigString): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.CHANNEL(channelId),
- );
-
- // IF A CHANNEL DOESN'T EXIST, DISCORD RETURNS `{}`
- return bot.transformers.channel(bot, {
- channel: result,
- guildId: result.guild_id ? bot.transformers.snowflake(result.guild_id) : undefined,
- });
-}
diff --git a/helpers/channels/getChannelInvites.ts b/helpers/channels/getChannelInvites.ts
deleted file mode 100644
index 423f639f9..000000000
--- a/helpers/channels/getChannelInvites.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { DiscordInviteMetadata } from "../../types/discord.ts";
-import { BigString, TargetTypes } from "../../types/shared.ts";
-import { Collection } from "../../util/collection.ts";
-import { InviteMetadata } from "../guilds/invites/mod.ts";
-
-/**
- * Gets the list of invites for a channel.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the channel to get the invites of.
- * @returns A collection of {@link InviteMetadata} objects assorted by invite code.
- *
- * @remarks
- * Requires the `MANAGE_CHANNELS` permission.
- *
- * Only usable for guild channels.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#get-channel-invites}
- */
-export async function getChannelInvites(bot: Bot, channelId: BigString): Promise> {
- const results = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.CHANNEL_INVITES(channelId),
- );
-
- return new Collection(
- results.map<[string, InviteMetadata]>((result) => {
- const invite = {
- code: result.code,
- guildId: result.guild?.id ? bot.transformers.snowflake(result.guild.id) : undefined,
- channelId: result.channel?.id ? bot.transformers.snowflake(result.channel.id) : undefined,
- inviter: result.inviter ? bot.transformers.user(bot, result.inviter) : undefined,
- targetType: result.target_type
- ? (result.target_type === 1 ? TargetTypes.Stream : TargetTypes.EmbeddedApplication)
- : undefined,
- targetUser: result.target_user ? bot.transformers.user(bot, result.target_user) : undefined,
- targetApplicationId: result.target_application?.id
- ? bot.transformers.snowflake(result.target_application.id)
- : undefined,
- approximatePresenceCount: result.approximate_presence_count,
- approximateMemberCount: result.approximate_member_count,
- expiresAt: result.expires_at ? Date.parse(result.expires_at) : undefined,
- guildScheduledEvent: result.guild_scheduled_event
- ? bot.transformers.scheduledEvent(bot, result.guild_scheduled_event)
- : undefined,
- // Metadata structure
- uses: result.uses,
- maxUses: result.max_uses,
- maxAge: result.max_age,
- temporary: result.temporary,
- createdAt: Date.parse(result.created_at),
- };
- return [invite.code, invite];
- }),
- );
-}
diff --git a/helpers/channels/getChannels.ts b/helpers/channels/getChannels.ts
deleted file mode 100644
index 82e3142a7..000000000
--- a/helpers/channels/getChannels.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { Channel } from "../../transformers/channel.ts";
-import { DiscordChannel } from "../../types/discord.ts";
-import { BigString } from "../../types/shared.ts";
-import { Collection } from "../../util/collection.ts";
-
-/**
- * Gets the list of channels for a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to get the channels of.
- * @returns A collection of {@link Channel} objects assorted by channel ID.
- *
- * @remarks
- * Excludes threads.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#get-guild-channels}
- */
-export async function getChannels(bot: Bot, guildId: BigString): Promise> {
- const results = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.GUILD_CHANNELS(guildId),
- );
-
- const id = bot.transformers.snowflake(guildId);
-
- return new Collection(
- results.map((result) => {
- const channel = bot.transformers.channel(bot, { channel: result, guildId: id });
- return [channel.id, channel];
- }),
- );
-}
diff --git a/helpers/channels/mod.ts b/helpers/channels/mod.ts
deleted file mode 100644
index e5ebc6003..000000000
--- a/helpers/channels/mod.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-export * from "./announcements/mod.ts";
-export * from "./forums/mod.ts";
-export * from "./stages/mod.ts";
-export * from "./threads/mod.ts";
-
-export * from "./createChannel.ts";
-export * from "./deleteChannel.ts";
-export * from "./deleteChannelPermissionOverride.ts";
-export * from "./editChannel.ts";
-export * from "./editChannelPermissionOverrides.ts";
-export * from "./getChannel.ts";
-export * from "./getChannelInvites.ts";
-export * from "./getChannels.ts";
-export * from "./triggerTypingIndicator.ts";
-export * from "./editChannelPositions.ts";
diff --git a/helpers/channels/stages/createStageInstance.ts b/helpers/channels/stages/createStageInstance.ts
deleted file mode 100644
index fa0f026d1..000000000
--- a/helpers/channels/stages/createStageInstance.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { BigString, WithReason } from "../../../mod.ts";
-import { StageInstance } from "../../../transformers/stageInstance.ts";
-import { DiscordStageInstance } from "../../../types/discord.ts";
-
-/**
- * Creates a stage instance associated with a stage channel.
- *
- * @param bot - The bot instance to use to make the request.
- * @param options - The parameters for the creation of the stage instance.
- * @returns An instance of the created {@link StageInstance}.
- *
- * @remarks
- * Requires the user to be a moderator of the stage channel.
- *
- * Fires a _Stage Instance Create_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/stage-instance#create-stage-instance}
- */
-export async function createStageInstance(bot: Bot, options: CreateStageInstance): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "POST",
- bot.constants.routes.STAGE_INSTANCES(),
- {
- channel_id: options.channelId.toString(),
- topic: options.topic,
- send_start_notification: options.sendStartNotification,
- reason: options.reason,
- },
- );
-
- return bot.transformers.stageInstance(bot, result);
-}
-
-export interface CreateStageInstance extends WithReason {
- channelId: BigString;
- topic: string;
- /** Notify @everyone that the stage instance has started. Requires the MENTION_EVERYONE permission. */
- sendStartNotification?: boolean;
-}
diff --git a/helpers/channels/stages/deleteStageInstance.ts b/helpers/channels/stages/deleteStageInstance.ts
deleted file mode 100644
index 370ef1f27..000000000
--- a/helpers/channels/stages/deleteStageInstance.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Deletes the stage instance associated with a stage channel, if one exists.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the stage channel the stage instance is associated with.
- *
- * @remarks
- * Requires the user to be a moderator of the stage channel.
- *
- * Fires a _Stage Instance Delete_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/stage-instance#delete-stage-instance}
- */
-export async function deleteStageInstance(bot: Bot, channelId: BigString, reason?: string): Promise {
- return await bot.rest.runMethod(
- bot.rest,
- "DELETE",
- bot.constants.routes.STAGE_INSTANCE(channelId),
- reason ? { reason } : undefined,
- );
-}
diff --git a/helpers/channels/stages/editStageInstance.ts b/helpers/channels/stages/editStageInstance.ts
deleted file mode 100644
index 6d01b110c..000000000
--- a/helpers/channels/stages/editStageInstance.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { BigString, WithReason } from "../../../mod.ts";
-import { StageInstance } from "../../../transformers/stageInstance.ts";
-import { DiscordStageInstance } from "../../../types/discord.ts";
-
-/**
- * Edits a stage instance.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the stage channel the stage instance is associated with.
- * @returns An instance of the updated {@link StageInstance}.
- *
- * @remarks
- * Requires the user to be a moderator of the stage channel.
- *
- * Fires a _Stage Instance Update_ event.
- *
- * @see {@link https://discord.com/developers/docs/resources/stage-instance#modify-stage-instance}
- */
-export async function editStageInstance(
- bot: Bot,
- channelId: BigString,
- data: EditStageInstanceOptions,
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "PATCH",
- bot.constants.routes.STAGE_INSTANCE(channelId),
- {
- topic: data.topic,
- },
- );
-
- return bot.transformers.stageInstance(bot, result);
-}
-
-export interface EditStageInstanceOptions extends WithReason {
- /** The topic of the Stage instance (1-120 characters) */
- topic: string;
-}
diff --git a/helpers/channels/stages/getStageInstance.ts b/helpers/channels/stages/getStageInstance.ts
deleted file mode 100644
index df1cbf77a..000000000
--- a/helpers/channels/stages/getStageInstance.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { StageInstance } from "../../../transformers/stageInstance.ts";
-import { DiscordStageInstance } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Gets the stage instance associated with a stage channel, if one exists.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the stage channel the stage instance is associated with.
- * @returns An instance of {@link StageInstance}.
- *
- * @see {@link https://discord.com/developers/docs/resources/stage-instance#get-stage-instance}
- */
-export async function getStageInstance(bot: Bot, channelId: BigString): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.STAGE_INSTANCE(channelId),
- );
-
- return bot.transformers.stageInstance(bot, result);
-}
diff --git a/helpers/channels/stages/mod.ts b/helpers/channels/stages/mod.ts
deleted file mode 100644
index 2fa6aee4d..000000000
--- a/helpers/channels/stages/mod.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export * from "./createStageInstance.ts";
-export * from "./deleteStageInstance.ts";
-export * from "./editStageInstance.ts";
-export * from "./getStageInstance.ts";
diff --git a/helpers/channels/threads/addThreadMember.ts b/helpers/channels/threads/addThreadMember.ts
deleted file mode 100644
index d4206d2cd..000000000
--- a/helpers/channels/threads/addThreadMember.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Adds a member to a thread.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the thread to add the member to.
- * @param userId - The user ID of the member to add to the thread.
- *
- * @remarks
- * Requires the ability to send messages in the thread.
- * Requires the thread not be archived.
- *
- * Fires a _Thread Members Update_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#add-thread-member}
- */
-export async function addThreadMember(bot: Bot, channelId: BigString, userId: BigString): Promise {
- return await bot.rest.runMethod(bot.rest, "PUT", bot.constants.routes.THREAD_USER(channelId, userId));
-}
diff --git a/helpers/channels/threads/getActiveThreads.ts b/helpers/channels/threads/getActiveThreads.ts
deleted file mode 100644
index e95914383..000000000
--- a/helpers/channels/threads/getActiveThreads.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { BigString, Channel, ThreadMember } from "../../../mod.ts";
-import { DiscordListActiveThreads } from "../../../types/discord.ts";
-import { Collection } from "../../../util/collection.ts";
-
-/**
- * Gets the list of all active threads for a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to get the threads of.
- * @returns An instance of {@link ActiveThreads}.
- *
- * @remarks
- * Returns both public and private threads.
- *
- * Threads are ordered by the `id` property in descending order.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#list-active-guild-threads}
- */
-export async function getActiveThreads(bot: Bot, guildId: BigString): Promise {
- const results = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.THREAD_ACTIVE(guildId),
- );
-
- return {
- threads: new Collection(
- results.threads.map((result) => {
- const thread = bot.transformers.channel(bot, { channel: result });
- return [thread.id, thread];
- }),
- ),
- members: new Collection(
- results.members.map((result) => {
- const member = bot.transformers.threadMember(bot, result);
- return [member.id!, member];
- }),
- ),
- };
-}
-
-export type ActiveThreads = {
- threads: Collection;
- members: Collection;
-};
diff --git a/helpers/channels/threads/getPrivateArchivedThreads.ts b/helpers/channels/threads/getPrivateArchivedThreads.ts
deleted file mode 100644
index 982eb4637..000000000
--- a/helpers/channels/threads/getPrivateArchivedThreads.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { DiscordListArchivedThreads } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-import { Collection } from "../../../util/collection.ts";
-import { ArchivedThreads, ListArchivedThreads } from "./getPublicArchivedThreads.ts";
-
-/**
- * Gets the list of private archived threads for a channel.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the channel to get the archived threads for.
- * @param options - The parameters for the fetching of threads.
- * @returns An instance of {@link ArchivedThreads}.
- *
- * @remarks
- * Requires the `READ_MESSAGE_HISTORY` permission.
- * Requires the `MANAGE_THREADS` permission.
- *
- * Returns threads of type {@link ChannelTypes.GuildPrivateThread}.
- *
- * Threads are ordered by the `archive_timestamp` property included in the metadata of the object in descending order.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#list-private-archived-threads}
- */
-export async function getPrivateArchivedThreads(
- bot: Bot,
- channelId: BigString,
- options?: ListArchivedThreads,
-): Promise {
- const results = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.THREAD_ARCHIVED_PRIVATE(channelId, options),
- );
-
- return {
- threads: new Collection(
- results.threads.map((result) => {
- const thread = bot.transformers.channel(bot, { channel: result });
- return [thread.id, thread];
- }),
- ),
- members: new Collection(
- results.members.map((result) => {
- const member = bot.transformers.threadMember(bot, result);
- return [member.id!, member];
- }),
- ),
- hasMore: results.has_more,
- };
-}
diff --git a/helpers/channels/threads/getPrivateJoinedArchivedThreads.ts b/helpers/channels/threads/getPrivateJoinedArchivedThreads.ts
deleted file mode 100644
index 28827ced9..000000000
--- a/helpers/channels/threads/getPrivateJoinedArchivedThreads.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { DiscordListArchivedThreads } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-import { Collection } from "../../../util/collection.ts";
-import { ArchivedThreads, ListArchivedThreads } from "./getPublicArchivedThreads.ts";
-
-/**
- * Gets the list of private archived threads the bot is a member of for a channel.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the channel to get the archived threads for.
- * @param options - The parameters for the fetching of threads.
- * @returns An instance of {@link ArchivedThreads}.
- *
- * @remarks
- * Requires the `READ_MESSAGE_HISTORY` permission.
- *
- * Returns threads of type {@link ChannelTypes.GuildPrivateThread}.
- *
- * Threads are ordered by the `id` property in descending order.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#list-joined-private-archived-threads}
- */
-export async function getPrivateJoinedArchivedThreads(
- bot: Bot,
- channelId: BigString,
- options?: ListArchivedThreads,
-): Promise {
- const results = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.THREAD_ARCHIVED_PRIVATE_JOINED(channelId, options),
- );
-
- return {
- threads: new Collection(
- results.threads.map((result) => {
- const thread = bot.transformers.channel(bot, { channel: result });
- return [thread.id, thread];
- }),
- ),
- members: new Collection(
- results.members.map((result) => {
- const member = bot.transformers.threadMember(bot, result);
- return [member.id!, member];
- }),
- ),
- hasMore: results.has_more,
- };
-}
diff --git a/helpers/channels/threads/getPublicArchivedThreads.ts b/helpers/channels/threads/getPublicArchivedThreads.ts
deleted file mode 100644
index ccc4604da..000000000
--- a/helpers/channels/threads/getPublicArchivedThreads.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { DiscordListArchivedThreads } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-import { Collection } from "../../../util/collection.ts";
-import { ActiveThreads } from "./getActiveThreads.ts";
-
-/**
- * Gets the list of public archived threads for a channel.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the channel to get the archived threads for.
- * @param options - The parameters for the fetching of threads.
- * @returns An instance of {@link ArchivedThreads}.
- *
- * @remarks
- * Requires the `READ_MESSAGE_HISTORY` permission.
- *
- * If called on a channel of type {@link ChannelTypes.GuildText}, returns threads of type {@link ChannelTypes.GuildPublicThread}.
- * If called on a channel of type {@link ChannelTypes.GuildNews}, returns threads of type {@link ChannelTypes.GuildNewsThread}.
- *
- * Threads are ordered by the `archive_timestamp` property included in the metadata of the object in descending order.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#list-public-archived-threads}
- */
-export async function getPublicArchivedThreads(
- bot: Bot,
- channelId: BigString,
- options?: ListArchivedThreads,
-): Promise {
- const results = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.THREAD_ARCHIVED_PUBLIC(channelId, options),
- );
-
- return {
- threads: new Collection(
- results.threads.map((result) => {
- const thread = bot.transformers.channel(bot, { channel: result });
- return [thread.id, thread];
- }),
- ),
- members: new Collection(
- results.members.map((result) => {
- const member = bot.transformers.threadMember(bot, result);
- return [member.id!, member];
- }),
- ),
- hasMore: results.has_more,
- };
-}
-
-/** https://discord.com/developers/docs/resources/channel#list-public-archived-threads-query-string-params */
-export interface ListArchivedThreads {
- /** Returns threads before this timestamp */
- before?: number;
- /** Optional maximum number of threads to return */
- limit?: number;
-}
-
-export type ArchivedThreads = ActiveThreads & {
- hasMore: boolean;
-};
diff --git a/helpers/channels/threads/getThreadMember.ts b/helpers/channels/threads/getThreadMember.ts
deleted file mode 100644
index 16eadfefc..000000000
--- a/helpers/channels/threads/getThreadMember.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { ThreadMember } from "../../../transformers/threadMember.ts";
-import { DiscordThreadMember } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Gets a thread member by their user ID.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the thread to get the thread member of.
- * @param userId - The user ID of the thread member to get.
- * @returns An instance of {@link ThreadMember}.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#get-thread-member}
- */
-export async function getThreadMember(bot: Bot, channelId: BigString, userId: BigString): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.THREAD_USER(channelId, userId),
- );
-
- return bot.transformers.threadMember(bot, result);
-}
diff --git a/helpers/channels/threads/getThreadMembers.ts b/helpers/channels/threads/getThreadMembers.ts
deleted file mode 100644
index 2b3a6bbbe..000000000
--- a/helpers/channels/threads/getThreadMembers.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { ThreadMember } from "../../../transformers/threadMember.ts";
-import { DiscordThreadMember } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-import { Collection } from "../../../util/collection.ts";
-
-/**
- * Gets the list of thread members for a thread.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the thread to get the thread members of.
- * @returns A collection of {@link ThreadMember} assorted by user ID.
- *
- * @remarks
- * Requires the application to have the `GUILD_MEMBERS` privileged intent enabled.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#list-thread-members}
- */
-export async function getThreadMembers(bot: Bot, channelId: BigString): Promise> {
- const results = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.THREAD_MEMBERS(channelId),
- );
-
- return new Collection(
- results.map((result) => {
- const member = bot.transformers.threadMember(bot, result);
- return [member.id!, member];
- }),
- );
-}
diff --git a/helpers/channels/threads/joinThread.ts b/helpers/channels/threads/joinThread.ts
deleted file mode 100644
index 730293139..000000000
--- a/helpers/channels/threads/joinThread.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Adds the bot user to a thread.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the thread to add the bot user to.
- *
- * @remarks
- * Requires the thread not be archived.
- *
- * Fires a _Thread Members Update_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#join-thread}
- */
-export async function joinThread(bot: Bot, channelId: BigString): Promise {
- return await bot.rest.runMethod(bot.rest, "PUT", bot.constants.routes.THREAD_ME(channelId));
-}
diff --git a/helpers/channels/threads/leaveThread.ts b/helpers/channels/threads/leaveThread.ts
deleted file mode 100644
index 544dc33a0..000000000
--- a/helpers/channels/threads/leaveThread.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Removes the bot user from a thread.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the thread to remove the bot user from.
- *
- * @remarks
- * Requires the thread not be archived.
- *
- * Fires a _Thread Members Update_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#leave-thread}
- */
-export async function leaveThread(bot: Bot, channelId: BigString): Promise {
- return await bot.rest.runMethod(bot.rest, "DELETE", bot.constants.routes.THREAD_ME(channelId));
-}
diff --git a/helpers/channels/threads/mod.ts b/helpers/channels/threads/mod.ts
deleted file mode 100644
index dcbaf9fe5..000000000
--- a/helpers/channels/threads/mod.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export * from "./addThreadMember.ts";
-export * from "./getActiveThreads.ts";
-export * from "./getPrivateArchivedThreads.ts";
-export * from "./getPrivateJoinedArchivedThreads.ts";
-export * from "./getPublicArchivedThreads.ts";
-export * from "./getThreadMember.ts";
-export * from "./getThreadMembers.ts";
-export * from "./joinThread.ts";
-export * from "./leaveThread.ts";
-export * from "./removeThreadMember.ts";
-export * from "./startThreadWithMessage.ts";
-export * from "./startThreadWithoutMessage.ts";
diff --git a/helpers/channels/threads/removeThreadMember.ts b/helpers/channels/threads/removeThreadMember.ts
deleted file mode 100644
index 004a4f53c..000000000
--- a/helpers/channels/threads/removeThreadMember.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Removes a member from a thread.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the thread to remove the thread member of.
- * @param userId - The user ID of the thread member to remove.
- *
- * @remarks
- * If the thread is of type {@link ChannelTypes.GuildPrivateThread}, requires to be the creator of the thread.
- * Otherwise, requires the `MANAGE_THREADS` permission.
- *
- * Requires the thread not be archived.
- *
- * Fires a _Thread Members Update_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#remove-thread-member}
- */
-export async function removeThreadMember(bot: Bot, channelId: BigString, userId: BigString): Promise {
- return await bot.rest.runMethod(
- bot.rest,
- "DELETE",
- bot.constants.routes.THREAD_USER(channelId, userId),
- );
-}
diff --git a/helpers/channels/threads/startThreadWithMessage.ts b/helpers/channels/threads/startThreadWithMessage.ts
deleted file mode 100644
index b17771501..000000000
--- a/helpers/channels/threads/startThreadWithMessage.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { BigString, WithReason } from "../../../mod.ts";
-import { Channel } from "../../../transformers/channel.ts";
-import { DiscordChannel } from "../../../types/discord.ts";
-
-/**
- * Creates a thread, using an existing message as its point of origin.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the channel in which to create the thread.
- * @param messageId - The ID of the message to use as the thread's point of origin.
- * @param options - The parameters to use for the creation of the thread.
- * @returns An instance of the created {@link Channel | Thread}.
- *
- * @remarks
- * If called on a channel of type {@link ChannelTypes.GuildText}, creates a {@link ChannelTypes.GuildPublicThread}.
- * If called on a channel of type {@link ChannelTypes.GuildNews}, creates a {@link ChannelTypes.GuildNewsThread}.
- * Does not work on channels of type {@link ChannelTypes.GuildForum}.
- *
- * The ID of the created thread will be the same as the ID of the source message.
- *
- * Fires a _Thread Create_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#start-thread-from-message}
- */
-export async function startThreadWithMessage(
- bot: Bot,
- channelId: BigString,
- messageId: BigString,
- options: StartThreadWithMessage,
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "POST",
- bot.constants.routes.THREAD_START_PUBLIC(channelId, messageId),
- {
- name: options.name,
- auto_archive_duration: options.autoArchiveDuration,
- rate_limit_per_user: options.rateLimitPerUser,
- reason: options.reason,
- },
- );
-
- return bot.transformers.channel(bot, { channel: result, guildId: bot.transformers.snowflake(result.guild_id!) });
-}
-
-export interface StartThreadWithMessage extends WithReason {
- /** 1-100 character thread name */
- name: string;
- /** Duration in minutes to automatically archive the thread after recent activity */
- autoArchiveDuration: 60 | 1440 | 4320 | 10080;
- /** Amount of seconds a user has to wait before sending another message (0-21600) */
- rateLimitPerUser?: number | null;
-}
diff --git a/helpers/channels/threads/startThreadWithoutMessage.ts b/helpers/channels/threads/startThreadWithoutMessage.ts
deleted file mode 100644
index c02bd4416..000000000
--- a/helpers/channels/threads/startThreadWithoutMessage.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { WithReason } from "../../../mod.ts";
-import { Channel } from "../../../transformers/channel.ts";
-import { DiscordChannel } from "../../../types/discord.ts";
-import { BigString, ChannelTypes } from "../../../types/shared.ts";
-
-/**
- * Creates a thread without using a message as the thread's point of origin.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the channel in which to create the thread.
- * @param options - The parameters to use for the creation of the thread.
- * @returns An instance of the created {@link Channel | Thread}.
- *
- * @remarks
- * Creating a private thread requires the server to be boosted.
- *
- * Fires a _Thread Create_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#start-thread-without-message}
- */
-export async function startThreadWithoutMessage(
- bot: Bot,
- channelId: BigString,
- options: StartThreadWithoutMessage,
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "POST",
- bot.constants.routes.THREAD_START_PRIVATE(channelId),
- {
- name: options.name,
- auto_archive_duration: options.autoArchiveDuration,
- rate_limit_per_user: options.rateLimitPerUser,
- type: options.type,
- invitable: options.invitable,
- reason: options.reason,
- },
- );
-
- return bot.transformers.channel(bot, {
- channel: result,
- guildId: result.guild_id ? bot.transformers.snowflake(result.guild_id) : undefined,
- });
-}
-
-export interface StartThreadWithoutMessage extends WithReason {
- /** 1-100 character thread name */
- name: string;
- /** Duration in minutes to automatically archive the thread after recent activity */
- autoArchiveDuration: 60 | 1440 | 4320 | 10080;
- /** Amount of seconds a user has to wait before sending another message (0-21600) */
- rateLimitPerUser?: number | null;
- /** the type of thread to create */
- type: ChannelTypes.AnnouncementThread | ChannelTypes.PublicThread | ChannelTypes.PrivateThread;
- /** whether non-moderators can add other non-moderators to a thread; only available when creating a private thread */
- invitable?: boolean;
-}
diff --git a/helpers/channels/triggerTypingIndicator.ts b/helpers/channels/triggerTypingIndicator.ts
deleted file mode 100644
index d462edf15..000000000
--- a/helpers/channels/triggerTypingIndicator.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { BigString } from "../../types/shared.ts";
-
-export const startTyping = triggerTypingIndicator;
-
-/**
- * Triggers a typing indicator for the bot user.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the channel in which to trigger the typing indicator.
- *
- * @remarks
- * Generally, bots should _not_ use this route.
- *
- * Fires a _Typing Start_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#trigger-typing-indicator}
- */
-export async function triggerTypingIndicator(bot: Bot, channelId: BigString): Promise {
- return await bot.rest.runMethod(bot.rest, "POST", bot.constants.routes.CHANNEL_TYPING(channelId));
-}
diff --git a/helpers/emojis/createEmoji.ts b/helpers/emojis/createEmoji.ts
deleted file mode 100644
index 809600dad..000000000
--- a/helpers/emojis/createEmoji.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { BigString, WithReason } from "../../mod.ts";
-import { Emoji } from "../../transformers/emoji.ts";
-import { DiscordEmoji } from "../../types/discord.ts";
-
-/**
- * Creates an emoji in a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild in which to create the emoji.
- * @param options - The parameters for the creation of the emoji.
- * @returns An instance of the created {@link Emoji}.
- *
- * @remarks
- * Requires the `MANAGE_EMOJIS_AND_STICKERS` permission.
- *
- * Emojis have a maximum file size of 256 kilobits. Attempting to upload a larger emoji will cause the route to return 400 Bad Request.
- *
- * Fires a _Guild Emojis Update_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/emoji#create-guild-emoji}
- */
-export async function createEmoji(bot: Bot, guildId: BigString, options: CreateGuildEmoji): Promise {
- if (options.image && !options.image.startsWith("data:image/")) {
- options.image = await bot.utils.urlToBase64(options.image);
- }
-
- const result = await bot.rest.runMethod(
- bot.rest,
- "POST",
- bot.constants.routes.GUILD_EMOJIS(guildId),
- {
- name: options.name,
- image: options.image,
- roles: options.roles?.map((role) => role.toString()),
- reason: options.reason,
- },
- );
-
- return bot.transformers.emoji(bot, result);
-}
-
-/** https://discord.com/developers/docs/resources/emoji#create-guild-emoji */
-export interface CreateGuildEmoji extends WithReason {
- /** Name of the emoji */
- name: string;
- /** The 128x128 emoji image. Emojis and animated emojis have a maximum file size of 256kb. Attempting to upload an emoji larger than this limit will fail and return 400 Bad Request and an error message, but not a JSON status code. If a URL is provided to the image parameter, Discordeno will automatically convert it to a base64 string internally. */
- image: string;
- /** Roles allowed to use this emoji */
- roles?: BigString[];
-}
diff --git a/helpers/emojis/deleteEmoji.ts b/helpers/emojis/deleteEmoji.ts
deleted file mode 100644
index d0789f05e..000000000
--- a/helpers/emojis/deleteEmoji.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { BigString } from "../../types/shared.ts";
-
-/**
- * Deletes an emoji from a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild from which to delete the emoji.
- * @param id - The ID of the emoji to delete.
- *
- * @remarks
- * Requires the `MANAGE_EMOJIS_AND_STICKERS` permission.
- *
- * Fires a _Guild Emojis Update_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/emoji#delete-guild-emoji}
- */
-export async function deleteEmoji(bot: Bot, guildId: BigString, id: BigString, reason?: string): Promise {
- return await bot.rest.runMethod(bot.rest, "DELETE", bot.constants.routes.GUILD_EMOJI(guildId, id), {
- reason,
- });
-}
diff --git a/helpers/emojis/editEmoji.ts b/helpers/emojis/editEmoji.ts
deleted file mode 100644
index 1c0270610..000000000
--- a/helpers/emojis/editEmoji.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { BigString, WithReason } from "../../mod.ts";
-import { Emoji } from "../../transformers/emoji.ts";
-import { DiscordEmoji } from "../../types/discord.ts";
-
-/**
- * Edits an emoji.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild in which to edit the emoji.
- * @param id - The ID of the emoji to edit.
- * @param options - The parameters for the edit of the emoji.
- * @returns An instance of the updated {@link Emoji}.
- *
- * @remarks
- * Requires the `MANAGE_EMOJIS_AND_STICKERS` permission.
- *
- * Fires a `Guild Emojis Update` gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/emoji#modify-guild-emoji}
- */
-export async function editEmoji(
- bot: Bot,
- guildId: BigString,
- id: BigString,
- options: ModifyGuildEmoji,
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "PATCH",
- bot.constants.routes.GUILD_EMOJI(guildId, id),
- {
- name: options.name,
- // NEED TERNARY TO SUPPORT NULL AS VALID
- roles: options.roles ? options.roles.map((role) => role.toString()) : options.roles,
- reason: options.reason,
- },
- );
-
- return bot.transformers.emoji(bot, result);
-}
-
-/** https://discord.com/developers/docs/resources/emoji#modify-guild-emoji */
-export interface ModifyGuildEmoji extends WithReason {
- /** Name of the emoji */
- name?: string;
- /** Roles allowed to use this emoji */
- roles?: BigString[] | null;
-}
diff --git a/helpers/emojis/getEmoji.ts b/helpers/emojis/getEmoji.ts
deleted file mode 100644
index e3ec5a2ca..000000000
--- a/helpers/emojis/getEmoji.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { Emoji } from "../../transformers/emoji.ts";
-import { DiscordEmoji } from "../../types/discord.ts";
-import { BigString } from "../../types/shared.ts";
-
-/**
- * Gets an emoji by its ID.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild from which to get the emoji.
- * @param emojiId - The ID of the emoji to get.
- * @returns An instance of {@link Emoji}.
- *
- * @see {@link https://discord.com/developers/docs/resources/emoji#get-guild-emoji}
- */
-export async function getEmoji(bot: Bot, guildId: BigString, emojiId: BigString): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.GUILD_EMOJI(guildId, emojiId),
- );
-
- return bot.transformers.emoji(bot, result);
-}
diff --git a/helpers/emojis/getEmojiUrl.ts b/helpers/emojis/getEmojiUrl.ts
deleted file mode 100644
index ba0dba82c..000000000
--- a/helpers/emojis/getEmojiUrl.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { Bot } from "../../bot.ts";
-import { BigString } from "../../types/shared.ts";
-
-/**
- * Builds a URL to an emoji in the Discord CDN.
- *
- * @param emojiId - The ID of the emoji to access.
- * @param animated - Whether the emoji is animated or static.
- * @returns The link to the resource.
- */
-export function getEmojiURL(_bot: Bot, emojiId: BigString, animated = false): string {
- return `https://cdn.discordapp.com/emojis/${emojiId}.${animated ? "gif" : "png"}`;
-}
diff --git a/helpers/emojis/getEmojis.ts b/helpers/emojis/getEmojis.ts
deleted file mode 100644
index 88a9d888c..000000000
--- a/helpers/emojis/getEmojis.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { Emoji } from "../../transformers/emoji.ts";
-import { DiscordEmoji } from "../../types/discord.ts";
-import { BigString } from "../../types/shared.ts";
-import { Collection } from "../../util/collection.ts";
-
-/**
- * Gets the list of emojis for a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild which to get the emojis of.
- * @returns A collection of {@link Emoji} objects assorted by emoji ID.
- *
- * @see {@link https://discord.com/developers/docs/resources/emoji#list-guild-emojis}
- */
-export async function getEmojis(bot: Bot, guildId: BigString): Promise> {
- const results = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.GUILD_EMOJIS(guildId),
- );
-
- return new Collection(
- results.map((result) => {
- const emoji = bot.transformers.emoji(bot, result);
- return [emoji.id!, emoji];
- }),
- );
-}
diff --git a/helpers/emojis/mod.ts b/helpers/emojis/mod.ts
deleted file mode 100644
index a7c824f51..000000000
--- a/helpers/emojis/mod.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export * from "./createEmoji.ts";
-export * from "./deleteEmoji.ts";
-export * from "./editEmoji.ts";
-export * from "./getEmoji.ts";
-export * from "./getEmojis.ts";
-export * from "./getEmojiUrl.ts";
diff --git a/helpers/guilds/automod/createAutomodRule.ts b/helpers/guilds/automod/createAutomodRule.ts
deleted file mode 100644
index ccadf7032..000000000
--- a/helpers/guilds/automod/createAutomodRule.ts
+++ /dev/null
@@ -1,101 +0,0 @@
-import { Bot } from "../../../bot.ts";
-import { BigString, WithReason } from "../../../mod.ts";
-import { AutoModerationRule } from "../../../transformers/automodRule.ts";
-import {
- AutoModerationActionType,
- AutoModerationEventTypes,
- AutoModerationTriggerTypes,
- DiscordAutoModerationRule,
- DiscordAutoModerationRuleTriggerMetadataPresets,
-} from "../../../types/discord.ts";
-
-/**
- * Creates an automod rule in a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to create the rule in.
- * @param options - The parameters for the creation of the rule.
- * @returns An instance of the created {@link AutoModerationRule}.
- *
- * @remarks
- * Requires the `MANAGE_GUILD` permission.
- *
- * Fires an _Auto Moderation Rule Create_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/auto-moderation#create-auto-moderation-rule}
- */
-export async function createAutomodRule(
- bot: Bot,
- guildId: BigString,
- options: CreateAutoModerationRuleOptions,
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "POST",
- bot.constants.routes.AUTOMOD_RULES(guildId),
- {
- name: options.name,
- event_type: options.eventType,
- trigger_type: options.triggerType,
- trigger_metadata: {
- keyword_filter: options.triggerMetadata.keywordFilter,
- presets: options.triggerMetadata.presets,
- allow_list: options.triggerMetadata.allowList,
- mention_total_limit: options.triggerMetadata.mentionTotalLimit,
- },
- actions: options.actions.map((action) => ({
- type: action.type,
- metadata: action.metadata
- ? {
- channel_id: action.metadata.channelId?.toString(),
- duration_seconds: action.metadata.durationSeconds,
- }
- : undefined,
- })),
- enabled: options.enabled ?? true,
- exempt_roles: options.exemptRoles?.map((id) => id.toString()),
- exempt_channels: options.exemptChannels?.map((id) => id.toString()),
- reason: options.reason,
- },
- );
-
- return bot.transformers.automodRule(bot, result);
-}
-
-export interface CreateAutoModerationRuleOptions extends WithReason {
- /** The name of the rule. */
- name: string;
- /** The type of event to trigger the rule on. */
- eventType: AutoModerationEventTypes;
- /** The type of trigger to use for the rule. */
- triggerType: AutoModerationTriggerTypes;
- /** The metadata to use for the trigger. */
- triggerMetadata: {
- /** The keywords needed to match. Only present when TriggerType.Keyword */
- keywordFilter?: string[];
- /** The pre-defined lists of words to match from. Only present when TriggerType.KeywordPreset */
- presets?: DiscordAutoModerationRuleTriggerMetadataPresets[];
- /** The substrings which will exempt from triggering the preset trigger type. Only present when TriggerType.KeywordPreset */
- allowList?: string[];
- /** Total number of mentions (role & user) allowed per message (Maximum of 50). Only present when TriggerType.MentionSpam */
- mentionTotalLimit?: number;
- };
- /** The actions that will trigger for this rule */
- actions: {
- /** The type of action to take when a rule is triggered */
- type: AutoModerationActionType;
- /** additional metadata needed during execution for this specific action type */
- metadata?: {
- /** The id of channel to which user content should be logged. Only in SendAlertMessage */
- channelId?: BigString;
- /** Timeout duration in seconds. Max is 2419200(4 weeks). Only supported for TriggerType.Keyword */
- durationSeconds?: number;
- };
- }[];
- /** Whether the rule should be enabled, true by default. */
- enabled?: boolean;
- /** The role ids that should not be effected by the rule */
- exemptRoles?: BigString[];
- /** The channel ids that should not be effected by the rule. */
- exemptChannels?: BigString[];
-}
diff --git a/helpers/guilds/automod/deleteAutomodRule.ts b/helpers/guilds/automod/deleteAutomodRule.ts
deleted file mode 100644
index ac80986d7..000000000
--- a/helpers/guilds/automod/deleteAutomodRule.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { Bot } from "../../../bot.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Deletes an automod rule.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to delete the rule from.
- * @param ruleId - The ID of the automod rule to delete.
- *
- * @remarks
- * Requires the `MANAGE_GUILD` permission.
- *
- * Fires an _Auto Moderation Rule Delete_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/auto-moderation#delete-auto-moderation-rule}
- */
-export async function deleteAutomodRule(
- bot: Bot,
- guildId: BigString,
- ruleId: BigString,
- reason?: string,
-): Promise {
- return await bot.rest.runMethod(
- bot.rest,
- "DELETE",
- bot.constants.routes.AUTOMOD_RULE(guildId, ruleId),
- { reason },
- );
-}
diff --git a/helpers/guilds/automod/editAutomodRule.ts b/helpers/guilds/automod/editAutomodRule.ts
deleted file mode 100644
index ab2de80c1..000000000
--- a/helpers/guilds/automod/editAutomodRule.ts
+++ /dev/null
@@ -1,100 +0,0 @@
-import { Bot } from "../../../bot.ts";
-import { BigString, WithReason } from "../../../mod.ts";
-import { AutoModerationRule } from "../../../transformers/automodRule.ts";
-import {
- AutoModerationActionType,
- AutoModerationEventTypes,
- DiscordAutoModerationRule,
- DiscordAutoModerationRuleTriggerMetadataPresets,
-} from "../../../types/discord.ts";
-
-/**
- * Edits an automod rule.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to edit the rule in.
- * @param ruleId - The ID of the rule to edit.
- * @param options - The parameters for the edit of the rule.
- * @returns An instance of the edited {@link AutoModerationRule}.
- *
- * @remarks
- * Requires the `MANAGE_GUILD` permission.
- *
- * Fires an _Auto Moderation Rule Update_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/auto-moderation#modify-auto-moderation-rule}
- */
-export async function editAutomodRule(
- bot: Bot,
- guildId: BigString,
- ruleId: BigString,
- options: Partial,
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "PATCH",
- bot.constants.routes.AUTOMOD_RULE(guildId, ruleId),
- {
- name: options.name,
- event_type: options.eventType,
- trigger_metadata: options.triggerMetadata
- ? {
- keyword_filter: options.triggerMetadata.keywordFilter,
- presets: options.triggerMetadata.presets,
- allow_list: options.triggerMetadata.allowList,
- mention_total_limit: options.triggerMetadata.mentionTotalLimit,
- }
- : undefined,
- actions: options.actions?.map((action) => ({
- type: action.type,
- metadata: {
- channel_id: action.metadata.channelId?.toString(),
- duration_seconds: action.metadata.durationSeconds,
- },
- })),
- enabled: options.enabled ?? true,
- exempt_roles: options.exemptRoles?.map((id) => id.toString()),
- exempt_channels: options.exemptChannels?.map((id) => id.toString()),
- reason: options.reason,
- },
- );
-
- return bot.transformers.automodRule(bot, result);
-}
-
-export interface EditAutoModerationRuleOptions extends WithReason {
- /** The name of the rule. */
- name: string;
- /** The type of event to trigger the rule on. */
- eventType: AutoModerationEventTypes;
- /** The metadata to use for the trigger. */
- triggerMetadata: {
- /** The keywords needed to match. Only present when TriggerType.Keyword */
- keywordFilter?: string[];
- // TODO: This may need a special type or enum
- /** The pre-defined lists of words to match from. Only present when TriggerType.KeywordPreset */
- presets?: DiscordAutoModerationRuleTriggerMetadataPresets[];
- /** The substrings which will exempt from triggering the preset trigger type. Only present when TriggerType.KeywordPreset */
- allowList?: string[];
- /** Total number of mentions (role & user) allowed per message (Maximum of 50) */
- mentionTotalLimit: number;
- };
- /** The actions that will trigger for this rule */
- actions: {
- /** The type of action to take when a rule is triggered */
- type: AutoModerationActionType;
- /** additional metadata needed during execution for this specific action type */
- metadata: {
- /** The id of channel to which user content should be logged. Only in SendAlertMessage */
- channelId?: BigString;
- /** Timeout duration in seconds. Only supported for TriggerType.Keyword */
- durationSeconds?: number;
- };
- }[];
- /** Whether the rule should be enabled. */
- enabled?: boolean;
- /** The role ids that should not be effected by the rule */
- exemptRoles?: BigString[];
- /** The channel ids that should not be effected by the rule. */
- exemptChannels?: BigString[];
-}
diff --git a/helpers/guilds/automod/getAutomodRule.ts b/helpers/guilds/automod/getAutomodRule.ts
deleted file mode 100644
index 300fc5066..000000000
--- a/helpers/guilds/automod/getAutomodRule.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { Bot } from "../../../bot.ts";
-import { AutoModerationRule } from "../../../transformers/automodRule.ts";
-import { DiscordAutoModerationRule } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Gets an automod rule by its ID.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to get the rule of.
- * @param ruleId - The ID of the rule to get.
- * @returns An instance of {@link AutoModerationRule}.
- *
- * @remarks
- * Requires the `MANAGE_GUILD` permission.
- *
- * @see {@link https://discord.com/developers/docs/resources/auto-moderation#get-auto-moderation-rule}
- */
-export async function getAutomodRule(bot: Bot, guildId: BigString, ruleId: BigString): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.AUTOMOD_RULE(guildId, ruleId),
- );
-
- return bot.transformers.automodRule(bot, result);
-}
diff --git a/helpers/guilds/automod/getAutomodRules.ts b/helpers/guilds/automod/getAutomodRules.ts
deleted file mode 100644
index f36e02015..000000000
--- a/helpers/guilds/automod/getAutomodRules.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import { Bot } from "../../../bot.ts";
-import { AutoModerationRule } from "../../../transformers/automodRule.ts";
-import { DiscordAutoModerationRule } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-import { Collection } from "../../../util/collection.ts";
-
-/**
- * Gets the list of automod rules for a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to get the rules from.
- * @returns A collection of {@link AutoModerationRule} objects assorted by rule ID.
- *
- * @remarks
- * Requires the `MANAGE_GUILD` permission.
- *
- * @see {@link https://discord.com/developers/docs/resources/auto-moderation#list-auto-moderation-rules-for-guild}
- */
-export async function getAutomodRules(bot: Bot, guildId: BigString): Promise> {
- const results = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.AUTOMOD_RULES(guildId),
- );
-
- return new Collection(
- results.map((result) => {
- const rule = bot.transformers.automodRule(bot, result);
- return [rule.id, rule];
- }),
- );
-}
diff --git a/helpers/guilds/automod/mod.ts b/helpers/guilds/automod/mod.ts
deleted file mode 100644
index 677e29c70..000000000
--- a/helpers/guilds/automod/mod.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export * from "./createAutomodRule.ts";
-export * from "./deleteAutomodRule.ts";
-export * from "./editAutomodRule.ts";
-export * from "./getAutomodRule.ts";
-export * from "./getAutomodRules.ts";
diff --git a/helpers/guilds/createGuild.ts b/helpers/guilds/createGuild.ts
deleted file mode 100644
index a1e1b4f64..000000000
--- a/helpers/guilds/createGuild.ts
+++ /dev/null
@@ -1,69 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { Channel } from "../../transformers/channel.ts";
-import { Guild } from "../../transformers/guild.ts";
-import { Role } from "../../transformers/role.ts";
-import { DiscordGuild } from "../../types/discord.ts";
-import {
- DefaultMessageNotificationLevels,
- ExplicitContentFilterLevels,
- SystemChannelFlags,
- VerificationLevels,
-} from "../../types/shared.ts";
-
-/**
- * Creates a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param options - The parameters for the creation of the guild.
- * @returns An instance of the created {@link Guild}.
- *
- * @remarks
- * ⚠️ This route can only be used by bots in __fewer than 10 guilds__.
- *
- * Fires a _Guild Create_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#create-guild}
- */
-export async function createGuild(bot: Bot, options: CreateGuild): Promise {
- const result = await bot.rest.runMethod(bot.rest, "POST", bot.constants.routes.GUILDS(), {
- name: options.name,
- afk_channel_id: options.afkChannelId,
- afk_timeout: options.afkTimeout,
- channels: options.channels,
- default_message_notifications: options.defaultMessageNotifications,
- explicit_content_filter: options.explicitContentFilter,
- icon: options.icon,
- roles: options.roles,
- system_channel_flags: options.systemChannelFlags,
- system_channel_id: options.systemChannelId,
- verification_level: options.verificationLevel,
- });
-
- return bot.transformers.guild(bot, { guild: result, shardId: 0 });
-}
-
-/** https://discord.com/developers/docs/resources/guild#create-guild */
-export interface CreateGuild {
- /** Name of the guild (1-100 characters) */
- name: string;
- /** Base64 128x128 image for the guild icon */
- icon?: string;
- /** Verification level */
- verificationLevel?: VerificationLevels;
- /** Default message notification level */
- defaultMessageNotifications?: DefaultMessageNotificationLevels;
- /** Explicit content filter level */
- explicitContentFilter?: ExplicitContentFilterLevels;
- /** New guild roles (first role is the everyone role) */
- roles?: Role[];
- /** New guild's channels */
- channels?: Partial[];
- /** Id for afk channel */
- afkChannelId?: string;
- /** Afk timeout in seconds */
- afkTimeout?: number;
- /** The id of the channel where guild notices such as welcome messages and boost events are posted */
- systemChannelId?: string;
- /** System channel flags */
- systemChannelFlags?: SystemChannelFlags;
-}
diff --git a/helpers/guilds/deleteGuild.ts b/helpers/guilds/deleteGuild.ts
deleted file mode 100644
index 338402554..000000000
--- a/helpers/guilds/deleteGuild.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { BigString } from "../../types/shared.ts";
-
-/**
- * Deletes a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to delete.
- *
- * @remarks
- * The bot user must be the owner of the guild.
- *
- * Fires a _Guild Delete_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#delete-guild}
- */
-export async function deleteGuild(bot: Bot, guildId: BigString): Promise {
- return await bot.rest.runMethod(bot.rest, "DELETE", bot.constants.routes.GUILD(guildId));
-}
diff --git a/helpers/guilds/editGuild.ts b/helpers/guilds/editGuild.ts
deleted file mode 100644
index 31e1bbd9a..000000000
--- a/helpers/guilds/editGuild.ts
+++ /dev/null
@@ -1,116 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { Guild } from "../../transformers/guild.ts";
-import { DiscordGuild } from "../../types/discord.ts";
-import {
- BigString,
- DefaultMessageNotificationLevels,
- ExplicitContentFilterLevels,
- GuildFeatures,
- SystemChannelFlags,
- VerificationLevels,
-} from "../../types/shared.ts";
-
-// TODO: Put the `shardId` parameter before `options`.
-
-/**
- * Edits a guild's settings.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to edit.
- * @param shardId - The ID of the shard the guild is in.
- * @param options - The parameters for the edit of the guild.
- * @returns An instance of the edited {@link Guild}.
- *
- * @remarks
- * Requires the `MANAGE_GUILD` permission.
- *
- * If attempting to add or remove the {@link GuildFeatures.Community} feature:
- * - Requires the `ADMINISTRATOR` permission.
- *
- * Fires a _Guild Update_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#modify-guild}
- */
-export async function editGuild(bot: Bot, guildId: BigString, options: ModifyGuild, shardId: number): Promise {
- if (options.icon && !options.icon.startsWith("data:image/")) {
- options.icon = await bot.utils.urlToBase64(options.icon);
- }
-
- if (options.banner && !options.banner.startsWith("data:image/")) {
- options.banner = await bot.utils.urlToBase64(options.banner);
- }
-
- if (options.splash && !options.splash.startsWith("data:image/")) {
- options.splash = await bot.utils.urlToBase64(options.splash);
- }
-
- const result = await bot.rest.runMethod(
- bot.rest,
- "PATCH",
- bot.constants.routes.GUILD(guildId),
- {
- name: options.name,
- verification_levels: options.verificationLevel,
- default_message_notifications: options.defaultMessageNotifications,
- explicit_content_filter: options.explicitContentFilter,
- afk_channel_id: options.afkChannelId ? options.afkChannelId.toString() : options.afkChannelId,
- afk_timeout: options.afkTimeout,
- icon: options.icon,
- owner_id: options.ownerId ? options.ownerId.toString() : options.ownerId,
- splash: options.splash,
- discovery_splash: options.discoverySplash,
- banner: options.banner,
- system_channel_id: options.systemChannelId ? options.systemChannelId.toString() : options.systemChannelId,
- system_channel_flags: options.systemChannelFlags,
- rules_channel_id: options.rulesChannelId ? options.rulesChannelId.toString() : options.rulesChannelId,
- public_updates_channel_id: options.publicUpdatesChannelId
- ? options.publicUpdatesChannelId.toString()
- : options.publicUpdatesChannelId,
- preferred_locale: options.preferredLocale,
- features: options.features,
- premium_progress_bar_enabled: options.premiumProgressBarEnabled,
- },
- );
-
- return bot.transformers.guild(bot, { guild: result, shardId });
-}
-
-/** https://discord.com/developers/docs/resources/guild#modify-guild */
-export interface ModifyGuild {
- /** Guild name */
- name?: string;
- /** Verification level */
- verificationLevel?: VerificationLevels | null;
- /** Default message notification filter level */
- defaultMessageNotifications?: DefaultMessageNotificationLevels | null;
- /** Explicit content filter level */
- explicitContentFilter?: ExplicitContentFilterLevels | null;
- /** Id for afk channel */
- afkChannelId?: BigString | null;
- /** Afk timeout in seconds */
- afkTimeout?: number;
- /** Base64 1024x1024 png/jpeg/gif image for the guild icon (can be animated gif when the server has the `ANIMATED_ICON` feature) */
- icon?: string | null;
- /** User id to transfer guild ownership to (must be owner) */
- ownerId?: BigString;
- /** Base64 16:9 png/jpeg image for the guild splash (when the server has `INVITE_SPLASH` feature) */
- splash?: string | null;
- /** Base64 16:9 png/jpeg image for the guild discovery spash (when the server has the `DISCOVERABLE` feature) */
- discoverySplash?: string | null;
- /** Base64 16:9 png/jpeg image for the guild banner (when the server has BANNER feature) */
- banner?: string | null;
- /** The id of the channel where guild notices such as welcome messages and boost events are posted */
- systemChannelId?: BigString | null;
- /** System channel flags */
- systemChannelFlags?: SystemChannelFlags;
- /** The id of the channel where Community guilds display rules and/or guidelines */
- rulesChannelId?: BigString | null;
- /** The id of the channel where admins and moderators of Community guilds receive notices from Discord */
- publicUpdatesChannelId?: BigString | null;
- /** The preferred locale of a Community guild used in server discovery and notices from Discord; defaults to "en-US" */
- preferredLocale?: string | null;
- /** Enabled guild features */
- features?: GuildFeatures[];
- /** Whether the guild's boost progress bar should be enabled */
- premiumProgressBarEnabled?: boolean;
-}
diff --git a/helpers/guilds/editGuildMfaLevel.ts b/helpers/guilds/editGuildMfaLevel.ts
deleted file mode 100644
index 3523bed60..000000000
--- a/helpers/guilds/editGuildMfaLevel.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import type { Bot } from "../../mod.ts";
-import type { BigString, MfaLevels } from "../../types/shared.ts";
-
-/** Modify a guild's MFA level. Requires guild ownership. */
-export async function editGuildMfaLevel(bot: Bot, guildId: BigString, mfaLevel: MfaLevels, reason?: string) {
- return await bot.rest.runMethod(
- bot.rest,
- "POST",
- bot.constants.routes.GUILD_MFA_LEVEL(guildId),
- { level: mfaLevel, reason },
- );
-}
diff --git a/helpers/guilds/editWelcomeScreen.ts b/helpers/guilds/editWelcomeScreen.ts
deleted file mode 100644
index 857b20622..000000000
--- a/helpers/guilds/editWelcomeScreen.ts
+++ /dev/null
@@ -1,64 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { WelcomeScreen } from "../../transformers/welcomeScreen.ts";
-import { DiscordWelcomeScreen } from "../../types/discord.ts";
-import { BigString } from "../../types/shared.ts";
-
-/**
- * Edits a guild's welcome screen.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to edit the welcome screen of.
- * @param options - The parameters for the edit of the welcome screen.
- * @returns An instance of the edited {@link WelcomeScreen}.
- *
- * @remarks
- * Requires the `MANAGE_GUILD` permission.
- *
- * Fires a _Guild Update_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen}
- */
-export async function editWelcomeScreen(
- bot: Bot,
- guildId: BigString,
- options: ModifyGuildWelcomeScreen,
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "PATCH",
- bot.constants.routes.GUILD_WELCOME_SCREEN(guildId),
- {
- enabled: options.enabled,
- welcome_screen: options.welcomeScreen?.map((welcomeScreen) => ({
- channel_id: welcomeScreen.channelId,
- description: welcomeScreen.description,
- emoji_id: welcomeScreen.emojiId,
- emoji_name: welcomeScreen.emojiName,
- })),
- description: options.description,
- },
- );
-
- return bot.transformers.welcomeScreen(bot, result);
-}
-
-/** https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen */
-export interface ModifyGuildWelcomeScreen {
- /** Whether the welcome screen is enabled */
- enabled?: boolean | null;
- /** Channels linked in the welcome screen and their display options */
- welcomeScreen?: WelcomeScreenChannel[] | null;
- /** The server description to show in the welcome screen */
- description?: string | null;
-}
-
-export interface WelcomeScreenChannel {
- /** The channel's id */
- channelId: BigString;
- /** The emoji id, if the emoji is custom */
- emojiId?: BigString;
- /** The emoji name if custom, the unicode character if standard, or `null` if no emoji is set */
- emojiName?: string;
- /** The description shown for the channel */
- description: string;
-}
diff --git a/helpers/guilds/events/createScheduledEvent.ts b/helpers/guilds/events/createScheduledEvent.ts
deleted file mode 100644
index b7835b9d0..000000000
--- a/helpers/guilds/events/createScheduledEvent.ts
+++ /dev/null
@@ -1,88 +0,0 @@
-import { Bot } from "../../../bot.ts";
-import { WithReason } from "../../../mod.ts";
-import { ScheduledEvent } from "../../../transformers/scheduledEvent.ts";
-import { DiscordScheduledEvent } from "../../../types/discord.ts";
-import { BigString, ScheduledEventEntityType, ScheduledEventPrivacyLevel } from "../../../types/shared.ts";
-
-/**
- * Creates a scheduled event in a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to create the scheduled event in.
- * @param options - The parameters for the creation of the scheduled event.
- * @returns An instance of the created {@link ScheduledEvent}.
- *
- * @remarks
- * Requires the `MANAGE_EVENTS` permission.
- *
- * A guild can only have a maximum of 100 events with a status of {@link ScheduledEventStatus.Active} or {@link ScheduledEventStatus.Scheduled} (inclusive).
- *
- * Fires a _Guild Scheduled Event Create_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event}
- */
-export async function createScheduledEvent(
- bot: Bot,
- guildId: BigString,
- options: CreateScheduledEvent,
-): Promise {
- if (!bot.utils.validateLength(options.name, { min: 1, max: 100 })) {
- throw new Error("Name must be between 1-100 characters.");
- }
- if (options.description && !bot.utils.validateLength(options.description, { max: 1000 })) {
- throw new Error("Description must be below 1000 characters.");
- }
- if (options.location) {
- if (!bot.utils.validateLength(options.location, { max: 100 })) {
- throw new Error("Location must be below 100 characters.");
- }
- if (options.entityType === ScheduledEventEntityType.Voice) {
- throw new Error("Location can not be provided for a Voice event.");
- }
- }
- if (options.entityType === ScheduledEventEntityType.External) {
- if (!options.scheduledEndTime) throw new Error("A scheduled end time is required when making an External event.");
- if (!options.location) throw new Error("A location is required when making an External event.");
- }
- if (options.scheduledStartTime && options.scheduledEndTime && options.scheduledStartTime > options.scheduledEndTime) {
- throw new Error("Cannot schedule event to end before starting.");
- }
-
- const result = await bot.rest.runMethod(
- bot.rest,
- "POST",
- bot.constants.routes.GUILD_SCHEDULED_EVENTS(guildId),
- {
- channel_id: options.channelId?.toString(),
- entity_metadata: options.location ? { location: options.location } : undefined,
- name: options.name,
- description: options.description,
- scheduled_start_time: new Date(options.scheduledStartTime).toISOString(),
- scheduled_end_time: options.scheduledEndTime ? new Date(options.scheduledEndTime).toISOString() : undefined,
- privacy_level: options.privacyLevel || ScheduledEventPrivacyLevel.GuildOnly,
- entity_type: options.entityType,
- reason: options.reason,
- },
- );
-
- return bot.transformers.scheduledEvent(bot, result);
-}
-
-export interface CreateScheduledEvent extends WithReason {
- /** the channel id of the scheduled event. */
- channelId?: BigString;
- /** location of the event. Required for events with `entityType: ScheduledEventEntityType.External` */
- location?: string;
- /** the name of the scheduled event */
- name: string;
- /** the description of the scheduled event */
- description: string;
- /** the time the scheduled event will start */
- scheduledStartTime: number;
- /** the time the scheduled event will end if it does end. Required for events with `entityType: ScheduledEventEntityType.External` */
- scheduledEndTime?: number;
- /** the privacy level of the scheduled event */
- privacyLevel?: ScheduledEventPrivacyLevel;
- /** the type of hosting entity associated with a scheduled event */
- entityType: ScheduledEventEntityType;
-}
diff --git a/helpers/guilds/events/deleteScheduledEvent.ts b/helpers/guilds/events/deleteScheduledEvent.ts
deleted file mode 100644
index 6c5c13708..000000000
--- a/helpers/guilds/events/deleteScheduledEvent.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { Bot } from "../../../bot.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Deletes a scheduled event from a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to delete the scheduled event from.
- * @param eventId - The ID of the scheduled event to delete.
- *
- * @remarks
- * Requires the `MANAGE_EVENTS` permission.
- *
- * Fires a _Guild Scheduled Event Delete_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#delete-guild-scheduled-event}
- */
-export async function deleteScheduledEvent(bot: Bot, guildId: BigString, eventId: BigString): Promise {
- return await bot.rest.runMethod(
- bot.rest,
- "DELETE",
- bot.constants.routes.GUILD_SCHEDULED_EVENT(guildId, eventId),
- );
-}
diff --git a/helpers/guilds/events/editScheduledEvent.ts b/helpers/guilds/events/editScheduledEvent.ts
deleted file mode 100644
index a35bc8684..000000000
--- a/helpers/guilds/events/editScheduledEvent.ts
+++ /dev/null
@@ -1,90 +0,0 @@
-import { Bot } from "../../../bot.ts";
-import { WithReason } from "../../../mod.ts";
-import { ScheduledEvent } from "../../../transformers/scheduledEvent.ts";
-import { DiscordScheduledEvent } from "../../../types/discord.ts";
-import {
- BigString,
- ScheduledEventEntityType,
- ScheduledEventPrivacyLevel,
- ScheduledEventStatus,
-} from "../../../types/shared.ts";
-
-/**
- * Edits a scheduled event.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to edit the scheduled event in.
- * @param eventId - The ID of the scheduled event to edit.
- * @returns An instance of the edited {@link ScheduledEvent}.
- *
- * @remarks
- * Requires the `MANAGE_EVENTS` permission.
- *
- * To start or end an event, modify the event's `status` property.
- *
- * The `entity_metadata` property is discarded for events whose `entity_type` is not {@link ScheduledEventEntityType.External}.
- *
- * Fires a _Guild Scheduled Event Update_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event}
- */
-export async function editScheduledEvent(
- bot: Bot,
- guildId: BigString,
- eventId: BigString,
- options: Partial,
-): Promise {
- if (options.name && !bot.utils.validateLength(options.name, { min: 1, max: 100 })) {
- throw new Error("Name must be between 1-100 characters.");
- }
- if (options.description && !bot.utils.validateLength(options.description, { max: 1000 })) {
- throw new Error("Description must be below 1000 characters.");
- }
- if (options.location && !bot.utils.validateLength(options.location, { max: 100 })) {
- throw new Error("Location must be below 100 characters.");
- }
- if (options.scheduledStartTime && options.scheduledEndTime && options.scheduledStartTime > options.scheduledEndTime) {
- throw new Error("Cannot schedule event to end before starting.");
- }
-
- const result = await bot.rest.runMethod(
- bot.rest,
- "PATCH",
- bot.constants.routes.GUILD_SCHEDULED_EVENT(guildId, eventId),
- {
- channel_id: options.channelId === null ? null : options.channelId?.toString(),
- entity_metadata: options.location ? { location: options.location } : undefined,
- name: options.name,
- description: options.description,
- scheduled_start_time: options.scheduledStartTime ? new Date(options.scheduledStartTime).toISOString() : undefined,
- scheduled_end_time: options.scheduledEndTime ? new Date(options.scheduledEndTime).toISOString() : undefined,
- privacy_level: options.privacyLevel,
- entity_type: options.entityType,
- status: options.status,
- reason: options.reason,
- },
- );
-
- return bot.transformers.scheduledEvent(bot, result);
-}
-
-export interface EditScheduledEvent extends WithReason {
- /** the channel id of the scheduled event. null if switching to external event. */
- channelId: BigString | null;
- /** location of the event */
- location?: string;
- /** the name of the scheduled event */
- name: string;
- /** the description of the scheduled event */
- description?: string;
- /** the time the scheduled event will start */
- scheduledStartTime: number;
- /** the time the scheduled event will end if it does end. */
- scheduledEndTime?: number;
- /** the privacy level of the scheduled event */
- privacyLevel: ScheduledEventPrivacyLevel;
- /** the type of hosting entity associated with a scheduled event */
- entityType: ScheduledEventEntityType;
- /** the status of the scheduled event */
- status: ScheduledEventStatus;
-}
diff --git a/helpers/guilds/events/getScheduledEvent.ts b/helpers/guilds/events/getScheduledEvent.ts
deleted file mode 100644
index d777c9e19..000000000
--- a/helpers/guilds/events/getScheduledEvent.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { Bot } from "../../../bot.ts";
-import { ScheduledEvent } from "../../../transformers/scheduledEvent.ts";
-import { DiscordScheduledEvent } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Gets a scheduled event by its ID.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to get the scheduled event from.
- * @param eventId - The ID of the scheduled event to get.
- * @param options - The parameters for the fetching of the scheduled event.
- * @returns An instance of {@link ScheduledEvent}.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event}
- */
-export async function getScheduledEvent(
- bot: Bot,
- guildId: BigString,
- eventId: BigString,
- options?: { withUserCount?: boolean },
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.GUILD_SCHEDULED_EVENT(guildId, eventId, options?.withUserCount),
- );
-
- return bot.transformers.scheduledEvent(bot, result);
-}
diff --git a/helpers/guilds/events/getScheduledEventUsers.ts b/helpers/guilds/events/getScheduledEventUsers.ts
deleted file mode 100644
index 6738e6ad8..000000000
--- a/helpers/guilds/events/getScheduledEventUsers.ts
+++ /dev/null
@@ -1,93 +0,0 @@
-import { Bot } from "../../../bot.ts";
-import { Member, User } from "../../../transformers/member.ts";
-import { DiscordMember, DiscordUser } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-import { Collection } from "../../../util/collection.ts";
-
-// TODO: This endpoint discards certain data from the result.
-// Create `ScheduledEventUser` type and parse the data to it.
-
-/**
- * Gets the list of subscribers to a scheduled event from a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to get the subscribers to the scheduled event from.
- * @param eventId - The ID of the scheduled event to get the subscribers of.
- * @param options - The parameters for the fetching of the subscribers.
- * @returns A collection of {@link User} objects assorted by user ID.
- *
- * @remarks
- * Requires the `MANAGE_EVENTS` permission.
- *
- * Users are ordered by their IDs in _ascending_ order.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event-users}
- */
-export async function getScheduledEventUsers(
- bot: Bot,
- guildId: BigString,
- eventId: BigString,
- options?: GetScheduledEventUsers & { withMember?: false },
-): Promise>;
-export async function getScheduledEventUsers(
- bot: Bot,
- guildId: BigString,
- eventId: BigString,
- options?: GetScheduledEventUsers & { withMember: true },
-): Promise>;
-export async function getScheduledEventUsers(
- bot: Bot,
- guildId: BigString,
- eventId: BigString,
- options?: GetScheduledEventUsers,
-): Promise<
- Collection | Collection
-> {
- let url = bot.constants.routes.GUILD_SCHEDULED_EVENT_USERS(guildId, eventId, options);
-
- if (options) {
- url = "?";
-
- if (options.limit) url += `limit=${options.limit}`;
- if (options.withMember) url += `&with_member=${options.withMember}`;
- if (options.after) url += `&after=${options.after}`;
- if (options.before) url += `&before=${options.before}`;
- }
-
- const results = await bot.rest.runMethod<{ user: DiscordUser; member?: DiscordMember }[]>(
- bot.rest,
- "GET",
- url,
- );
-
- if (!options?.withMember) {
- return new Collection(
- results.map((result) => {
- const user = bot.transformers.user(bot, result.user);
- return [user.id, user];
- }),
- );
- }
-
- const id = bot.transformers.snowflake(guildId);
-
- return new Collection(
- results.map((result) => {
- const user = bot.transformers.user(bot, result.user);
- const member = bot.transformers.member(bot, result.member!, id, user.id);
-
- return [user.id, { member, user }];
- }),
- );
-}
-
-export interface GetScheduledEventUsers {
- /** number of users to return (up to maximum 100), defaults to 100 */
- limit?: number;
- /** whether to also have member objects provided, defaults to false */
- withMember?: boolean;
- /** consider only users before given user id */
- before?: BigString;
- /** consider only users after given user id. If both before and after are provided, only before is respected. Fetching users in-between before and after is not supported. */
- after?: BigString;
-}
diff --git a/helpers/guilds/events/getScheduledEvents.ts b/helpers/guilds/events/getScheduledEvents.ts
deleted file mode 100644
index c25784be7..000000000
--- a/helpers/guilds/events/getScheduledEvents.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { Bot } from "../../../bot.ts";
-import { ScheduledEvent } from "../../../transformers/scheduledEvent.ts";
-import { DiscordScheduledEvent } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-import { Collection } from "../../../util/collection.ts";
-
-/**
- * Gets the list of scheduled events for a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to get the scheduled events from.
- * @param options - The parameters for the fetching of the scheduled events.
- * @returns A collection of {@link ScheduledEvent} objects assorted by event ID.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild-scheduled-event#list-scheduled-events-for-guild}
- */
-export async function getScheduledEvents(
- bot: Bot,
- guildId: BigString,
- options?: GetScheduledEvents,
-): Promise> {
- const results = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.GUILD_SCHEDULED_EVENTS(guildId, options?.withUserCount),
- );
-
- return new Collection(
- results.map((result) => {
- const event = bot.transformers.scheduledEvent(bot, result);
- return [event.id, event];
- }),
- );
-}
-
-export interface GetScheduledEvents {
- /** include number of users subscribed to each event */
- withUserCount?: boolean;
-}
diff --git a/helpers/guilds/events/mod.ts b/helpers/guilds/events/mod.ts
deleted file mode 100644
index 978760b30..000000000
--- a/helpers/guilds/events/mod.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export * from "./createScheduledEvent.ts";
-export * from "./deleteScheduledEvent.ts";
-export * from "./editScheduledEvent.ts";
-export * from "./getScheduledEvent.ts";
-export * from "./getScheduledEvents.ts";
-export * from "./getScheduledEventUsers.ts";
diff --git a/helpers/guilds/getAuditLog.ts b/helpers/guilds/getAuditLog.ts
deleted file mode 100644
index bd0b07a09..000000000
--- a/helpers/guilds/getAuditLog.ts
+++ /dev/null
@@ -1,104 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { ApplicationCommand } from "../../transformers/applicationCommand.ts";
-import { AuditLogEntry } from "../../transformers/auditLogEntry.ts";
-import { AutoModerationRule } from "../../transformers/automodRule.ts";
-import { Channel } from "../../transformers/channel.ts";
-import { Integration } from "../../transformers/integration.ts";
-import { User } from "../../transformers/member.ts";
-import { ScheduledEvent } from "../../transformers/scheduledEvent.ts";
-import { Webhook } from "../../transformers/webhook.ts";
-import { DiscordAuditLog } from "../../types/discord.ts";
-import { AuditLogEvents, BigString } from "../../types/shared.ts";
-
-export type AuditLog = {
- auditLogEntries: AuditLogEntry[];
- autoModerationRules?: AutoModerationRule[];
- guildScheduledEvents?: ScheduledEvent[];
- integrations: Partial>[];
- threads: Channel[];
- users: User[];
- webhooks: Webhook[];
- applicationCommands: ApplicationCommand[];
-};
-
-// TODO: Move `AuditLog` into its own transformer file.
-
-/**
- * Gets a guild's audit log.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to get the audit log of.
- * @param options - The parameters for the fetching of the audit log.
- * @returns An instance of {@link AuditLog}.
- *
- * @remarks
- * Requires the `VIEW_AUDIT_LOG` permission.
- *
- * @see {@link https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log}
- */
-export async function getAuditLog(bot: Bot, guildId: BigString, options?: GetGuildAuditLog): Promise {
- if (options?.limit) {
- options.limit = options.limit >= 1 && options.limit <= 100 ? options.limit : 50;
- }
-
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.GUILD_AUDIT_LOGS(guildId, options),
- );
-
- const id = bot.transformers.snowflake(guildId);
- return {
- auditLogEntries: result.audit_log_entries.map((entry) => bot.transformers.auditLogEntry(bot, entry)),
- autoModerationRules: result.auto_moderation_rules?.map((rule) => bot.transformers.automodRule(bot, rule)),
- guildScheduledEvents: result.guild_scheduled_events?.map((event) => bot.transformers.scheduledEvent(bot, event)),
- integrations: result.integrations.map((integration) => ({
- id: integration.id ? bot.transformers.snowflake(integration.id) : undefined,
- name: integration.name,
- type: integration.type,
- enabled: integration.enabled,
- syncing: integration.syncing,
- roleId: integration.role_id ? bot.transformers.snowflake(integration.role_id) : undefined,
- enableEmoticons: integration.enable_emoticons,
- expireBehavior: integration.expire_behavior,
- expireGracePeriod: integration.expire_grace_period,
- user: integration.user ? bot.transformers.user(bot, integration.user) : undefined,
- account: integration.account
- ? {
- id: bot.transformers.snowflake(integration.account.id),
- name: integration.account.name,
- }
- : undefined,
- syncedAt: integration.synced_at ? Date.parse(integration.synced_at) : undefined,
- subscriberCount: integration.subscriber_count,
- revoked: integration.revoked,
- application: integration.application
- ? {
- id: bot.transformers.snowflake(integration.application.id),
- name: integration.application.name,
- icon: integration.application.icon ? bot.utils.iconHashToBigInt(integration.application.icon) : undefined,
- description: integration.application.description,
- bot: integration.application.bot ? bot.transformers.user(bot, integration.application.bot) : undefined,
- }
- : undefined,
- })),
- threads: result.threads.map((thread) => bot.transformers.channel(bot, { channel: thread, guildId: id })),
- users: result.users.map((user) => bot.transformers.user(bot, user)),
- webhooks: result.webhooks.map((hook) => bot.transformers.webhook(bot, hook)),
- applicationCommands: result.application_commands.map((applicationCommand) =>
- bot.transformers.applicationCommand(bot, applicationCommand)
- ),
- };
-}
-
-/** https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log-query-string-parameters */
-export interface GetGuildAuditLog {
- /** Entries from a specific user ID */
- userId?: BigString | string;
- /** Entries for a specific audit log event */
- actionType?: AuditLogEvents;
- /** Entries that preceded a specific audit log entry ID */
- before?: BigString | string;
- /** Maximum number of entries (between 1-100) to return, defaults to 50 */
- limit?: number;
-}
diff --git a/helpers/guilds/getBan.ts b/helpers/guilds/getBan.ts
deleted file mode 100644
index 89fbd290a..000000000
--- a/helpers/guilds/getBan.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { User } from "../../transformers/member.ts";
-import { DiscordBan } from "../../types/discord.ts";
-import { BigString } from "../../types/shared.ts";
-
-export type Ban = {
- reason?: string;
- user: User;
-};
-
-// TODO: Move `Ban` into its own transformer file.
-
-/**
- * Gets a ban by user ID.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to get the ban from.
- * @param userId - The ID of the user to get the ban for.
- * @returns An instance of {@link Ban}.
- *
- * @remarks
- * Requires the `BAN_MEMBERS` permission.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#get-guild-ban}
- */
-export async function getBan(bot: Bot, guildId: BigString, userId: BigString): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.GUILD_BAN(guildId, userId),
- );
-
- return {
- reason: result.reason ?? undefined,
- user: bot.transformers.user(bot, result.user),
- };
-}
diff --git a/helpers/guilds/getBans.ts b/helpers/guilds/getBans.ts
deleted file mode 100644
index f6ed8dcd2..000000000
--- a/helpers/guilds/getBans.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { DiscordBan } from "../../types/discord.ts";
-import { BigString } from "../../types/shared.ts";
-import { Collection } from "../../util/collection.ts";
-import { Ban } from "./getBan.ts";
-
-/**
- * Gets the list of bans for a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to get the list of bans for.
- * @param options - The parameters for the fetching of the list of bans.
- * @returns A collection of {@link Ban} objects assorted by user ID.
- *
- * @remarks
- * Requires the `BAN_MEMBERS` permission.
- *
- * Users are ordered by their IDs in _ascending_ order.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#get-guild-bans}
- */
-export async function getBans(bot: Bot, guildId: BigString, options?: GetBans): Promise> {
- const results = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.GUILD_BANS(guildId, options),
- );
-
- return new Collection(
- results.map<[bigint, Ban]>((result) => {
- const user = bot.transformers.user(bot, result.user);
- return [
- user.id,
- {
- reason: result.reason ?? undefined,
- user: user,
- },
- ];
- }),
- );
-}
-
-export interface GetBans {
- /** Number of users to return (up to maximum 1000). Default: 1000 */
- limit?: number;
- /** Consider only users before given user id */
- before?: BigString;
- /** Consider only users after given user id */
- after?: BigString;
-}
diff --git a/helpers/guilds/getGuild.ts b/helpers/guilds/getGuild.ts
deleted file mode 100644
index 9feccdae5..000000000
--- a/helpers/guilds/getGuild.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { Guild } from "../../transformers/guild.ts";
-import { DiscordGuild } from "../../types/discord.ts";
-import { BigString } from "../../types/shared.ts";
-
-/**
- * Gets a guild by its ID.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to get.
- * @param options - The parameters for the fetching of the guild.
- * @returns An instance of {@link Guild}.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#get-guild}
- */
-export async function getGuild(
- bot: Bot,
- guildId: BigString,
- options: { counts?: boolean } = {
- counts: true,
- },
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.GUILD(guildId, options.counts),
- );
-
- return bot.transformers.guild(bot, {
- guild: result,
- shardId: bot.utils.calculateShardId(bot.gateway, bot.transformers.snowflake(guildId)),
- });
-}
diff --git a/helpers/guilds/getGuildBannerUrl.ts b/helpers/guilds/getGuildBannerUrl.ts
deleted file mode 100644
index ad349cc1f..000000000
--- a/helpers/guilds/getGuildBannerUrl.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { BigString } from "../../types/shared.ts";
-import { ImageFormat, ImageSize } from "../members/getAvatarUrl.ts";
-
-// TODO: Move `banner` from `options` into the parameters and rename to `imageHash`.
-
-/**
- * Builds a URL to the guild banner stored in the Discord CDN.
- *
- * @param bot - The bot instance to use to build the URL.
- * @param guildId - The ID of the guild to get the link to the banner for.
- * @param options - The parameters for the building of the URL.
- * @returns The link to the resource or `undefined` if no banner has been set.
- */
-export function getGuildBannerURL(
- bot: Bot,
- guildId: BigString,
- options: {
- banner?: string | bigint;
- size?: ImageSize;
- format?: ImageFormat;
- },
-): string | undefined {
- return options.banner
- ? bot.utils.formatImageURL(
- bot.constants.routes.GUILD_BANNER(
- guildId,
- typeof options.banner === "string" ? options.banner : bot.utils.iconBigintToHash(options.banner),
- ),
- options.size || 128,
- options.format,
- )
- : undefined;
-}
diff --git a/helpers/guilds/getGuildIconUrl.ts b/helpers/guilds/getGuildIconUrl.ts
deleted file mode 100644
index fbd7f4707..000000000
--- a/helpers/guilds/getGuildIconUrl.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { BigString } from "../../types/shared.ts";
-import { ImageFormat, ImageSize } from "../members/getAvatarUrl.ts";
-
-/**
- * Builds a URL to the guild icon stored in the Discord CDN.
- *
- * @param bot - The bot instance to use to build the URL.
- * @param guildId - The ID of the guild to get the link to the banner for.
- * @param options - The parameters for the building of the URL.
- * @returns The link to the resource or `undefined` if no banner has been set.
- */
-export function getGuildIconURL(
- bot: Bot,
- guildId: BigString,
- imageHash: BigString | undefined,
- options?: {
- size?: ImageSize;
- format?: ImageFormat;
- },
-): string | undefined {
- return imageHash
- ? bot.utils.formatImageURL(
- bot.constants.routes.GUILD_ICON(
- guildId,
- typeof imageHash === "string" ? imageHash : bot.utils.iconBigintToHash(imageHash),
- ),
- options?.size || 128,
- options?.format,
- )
- : undefined;
-}
diff --git a/helpers/guilds/getGuildPreview.ts b/helpers/guilds/getGuildPreview.ts
deleted file mode 100644
index 36f6bcd1e..000000000
--- a/helpers/guilds/getGuildPreview.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { Emoji } from "../../transformers/emoji.ts";
-import { Sticker } from "../../transformers/sticker.ts";
-import { DiscordGuildPreview } from "../../types/discord.ts";
-import { BigString, GuildFeatures } from "../../types/shared.ts";
-
-export type GuildPreview = {
- id: BigString;
- name?: string;
- icon?: string;
- splash?: string;
- discoverySplash?: string;
- emojis?: Emoji[];
- features: GuildFeatures[];
- approximateMemberCount: number;
- approximatePresenceCount: number;
- description?: string;
- stickers: Sticker[];
-};
-
-// TODO: Move `GuildPreview` into its own transformer file.
-
-/**
- * Gets the preview of a guild by a guild's ID.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to get the preview of.
- * @returns An instance of {@link GuildPreview}.
- *
- * @remarks
- * If the bot user is not in the guild, the guild must be lurkable.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#get-guild-preview}
- */
-export async function getGuildPreview(bot: Bot, guildId: BigString): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.GUILD_PREVIEW(guildId),
- );
-
- return {
- id: bot.transformers.snowflake(result.id),
- name: result.name,
- icon: result.icon ?? undefined,
- splash: result.splash ?? undefined,
- discoverySplash: result.discovery_splash ?? undefined,
- emojis: result.emojis.map((emoji) => bot.transformers.emoji(bot, emoji)),
- features: result.features,
- approximateMemberCount: result.approximate_member_count,
- approximatePresenceCount: result.approximate_presence_count,
- description: result.description ?? undefined,
- stickers: result.stickers.map((sticker) => bot.transformers.sticker(bot, sticker)),
- };
-}
diff --git a/helpers/guilds/getGuildSplashUrl.ts b/helpers/guilds/getGuildSplashUrl.ts
deleted file mode 100644
index 3c757502f..000000000
--- a/helpers/guilds/getGuildSplashUrl.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { BigString } from "../../types/shared.ts";
-import { ImageFormat, ImageSize } from "../members/getAvatarUrl.ts";
-
-/**
- * Builds the URL to a guild splash stored in the Discord CDN.
- *
- * @param bot - The bot instance to use to build the URL.
- * @param guildId - The ID of the guild to get the splash of.
- * @param imageHash - The hash identifying the splash image.
- * @param options - The parameters for the building of the URL.
- * @returns The link to the resource or `undefined` if the guild does not have a splash image set.
- */
-export function getGuildSplashURL(
- bot: Bot,
- guildId: BigString,
- imageHash: BigString | undefined,
- options?: {
- size?: ImageSize;
- format?: ImageFormat;
- },
-): string | undefined {
- return imageHash
- ? bot.utils.formatImageURL(
- bot.constants.routes.GUILD_SPLASH(
- guildId,
- typeof imageHash === "string" ? imageHash : bot.utils.iconBigintToHash(imageHash),
- ),
- options?.size || 128,
- options?.format,
- )
- : undefined;
-}
diff --git a/helpers/guilds/getPruneCount.ts b/helpers/guilds/getPruneCount.ts
deleted file mode 100644
index 3f3aa6e6f..000000000
--- a/helpers/guilds/getPruneCount.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { BigString } from "../../types/shared.ts";
-
-interface DiscordPrunedCount {
- pruned: number;
-}
-
-/**
- * Gets the number of members that would be kicked from a guild during pruning.
- *
- * @param bot - The bot instance used to make the request
- * @param guildId - The ID of the guild to get the prune count of.
- * @param options - The parameters for the fetching of the prune count.
- * @returns A number indicating the number of members that would be kicked.
- *
- * @remarks
- * Requires the `KICK_MEMBERS` permission.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#get-guild-prune-count}
- */
-export async function getPruneCount(bot: Bot, guildId: BigString, options?: GetGuildPruneCountQuery): Promise {
- if (options?.days && options.days < 1) throw new Error(bot.constants.Errors.PRUNE_MIN_DAYS);
- if (options?.days && options.days > 30) throw new Error(bot.constants.Errors.PRUNE_MAX_DAYS);
-
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.GUILD_PRUNE(guildId),
- );
-
- return result.pruned;
-}
-
-/** https://discord.com/developers/docs/resources/guild#get-guild-prune-count */
-export interface GetGuildPruneCountQuery {
- /** Number of days to count prune for (1 or more), default: 7 */
- days?: number;
- /** Role(s) to include, default: none */
- includeRoles?: string | string[];
-}
diff --git a/helpers/guilds/getVanityUrl.ts b/helpers/guilds/getVanityUrl.ts
deleted file mode 100644
index 42ae200ec..000000000
--- a/helpers/guilds/getVanityUrl.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { BigString } from "../../types/shared.ts";
-
-export type VanityUrl = {
- code: string | null;
- uses: number;
-};
-
-// TODO: Move `VanityUrl` into its own transformer file.
-
-/**
- * Gets information about the vanity url of a guild.
- *
- * @param bot - The bot instance used to make the request
- * @param guildId - The ID of the guild to get the vanity url information for.
- * @returns An instance of {@link VanityUrl}.
- *
- * @remarks
- * Requires the `MANAGE_GUILD` permission.
- *
- * The `code` property will be `null` if the guild does not have a set vanity url.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#get-guild-vanity-url}
- */
-export async function getVanityUrl(bot: Bot, guildId: BigString): Promise {
- return await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.GUILD_VANITY_URL(guildId),
- );
-}
diff --git a/helpers/guilds/getWelcomeScreen.ts b/helpers/guilds/getWelcomeScreen.ts
deleted file mode 100644
index 134d48b1a..000000000
--- a/helpers/guilds/getWelcomeScreen.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { WelcomeScreen } from "../../transformers/welcomeScreen.ts";
-import { DiscordWelcomeScreen } from "../../types/discord.ts";
-import { BigString } from "../../types/shared.ts";
-
-/**
- * Gets the welcome screen for a guild.
- *
- * @param bot - The bot instance used to make the request
- * @param guildId - The ID of the guild to get the welcome screen for.
- * @returns An instance of {@link WelcomeScreen}.
- *
- * @remarks
- * If the welcome screen is not enabled:
- * - Requires the `MANAGE_GUILD` permission.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen}
- */
-export async function getWelcomeScreen(bot: Bot, guildId: BigString): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.GUILD_WELCOME_SCREEN(guildId),
- );
-
- return bot.transformers.welcomeScreen(bot, result);
-}
diff --git a/helpers/guilds/integrations/deleteIntegration.ts b/helpers/guilds/integrations/deleteIntegration.ts
deleted file mode 100644
index 8333d96dd..000000000
--- a/helpers/guilds/integrations/deleteIntegration.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Deletes an integration attached to a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild from which to delete the integration.
- * @param integrationId - The ID of the integration to delete from the guild.
- *
- * @remarks
- * Requires the `MANAGE_GUILD` permission.
- *
- * Deletes all webhooks associated with the integration, and kicks the associated bot if there is one.
- *
- * Fires a _Guild Integrations Update_ gateway event.
- * Fires a _Integration Delete_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#delete-guild-integration}
- */
-export async function deleteIntegration(bot: Bot, guildId: BigString, integrationId: BigString): Promise {
- return await bot.rest.runMethod(
- bot.rest,
- "DELETE",
- bot.constants.routes.GUILD_INTEGRATION(guildId, integrationId),
- );
-}
diff --git a/helpers/guilds/integrations/getIntegrations.ts b/helpers/guilds/integrations/getIntegrations.ts
deleted file mode 100644
index 7ed91d089..000000000
--- a/helpers/guilds/integrations/getIntegrations.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { Integration } from "../../../transformers/integration.ts";
-import { DiscordIntegration } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-import { Collection } from "../../../util/collection.ts";
-
-/**
- * Gets the list of integrations attached to a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to get the list of integrations from.
- * @returns A collection of {@link Integration} objects assorted by integration ID.
- *
- * @remarks
- * Requires the `MANAGE_GUILD` permission.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#get-guild-integrations}
- */
-export async function getIntegrations(bot: Bot, guildId: BigString): Promise> {
- const results = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.GUILD_INTEGRATIONS(guildId),
- );
-
- return new Collection(
- results.map((result) => {
- const integration = bot.transformers.integration(bot, {
- guild_id: guildId.toString(),
- id: result.id,
- name: result.name,
- type: result.type,
- enabled: result.enabled,
- syncing: result.syncing,
- role_id: result.role_id,
- enable_emoticons: result.enable_emoticons,
- expire_behavior: result.expire_behavior,
- expire_grace_period: result.expire_grace_period,
- user: result.user,
- account: result.account,
- synced_at: result.synced_at,
- subscriber_count: result.subscriber_count,
- revoked: result.revoked,
- application: result.application,
- scopes: result.scopes,
- });
- return [integration.id, integration];
- }),
- );
-}
diff --git a/helpers/guilds/integrations/mod.ts b/helpers/guilds/integrations/mod.ts
deleted file mode 100644
index b8ea12ebf..000000000
--- a/helpers/guilds/integrations/mod.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from "./deleteIntegration.ts";
-export * from "./getIntegrations.ts";
diff --git a/helpers/guilds/invites/createInvite.ts b/helpers/guilds/invites/createInvite.ts
deleted file mode 100644
index bd16c0594..000000000
--- a/helpers/guilds/invites/createInvite.ts
+++ /dev/null
@@ -1,77 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { WithReason } from "../../../mod.ts";
-import { DiscordInvite } from "../../../types/discord.ts";
-import { BigString, TargetTypes } from "../../../types/shared.ts";
-import { BaseInvite } from "./getInvite.ts";
-
-/**
- * Creates an invite to a channel in a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param channelId - The ID of the channel to create the invite to.
- * @param options - The parameters for the creation of the invite.
- * @returns An instance of the created {@link BaseInvite | Invite}.
- *
- * @remarks
- * Requires the `CREATE_INSTANT_INVITE` permission.
- *
- * Fires an _Invite Create_ gateway event.
- *
- * @privateRemarks
- * The request body is not optional, and an empty JSON object must be sent regardless of whether any fields are being transmitted.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#create-channel-invite}
- */
-export async function createInvite(
- bot: Bot,
- channelId: BigString,
- options: CreateChannelInvite = {},
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "POST",
- bot.constants.routes.CHANNEL_INVITES(channelId),
- {
- max_age: options.maxAge,
- max_uses: options.maxUses,
- temporary: options.temporary,
- unique: options.unique,
- target_type: options.targetType,
- target_user_id: options.targetUserId?.toString(),
- target_application_id: options.targetApplicationId?.toString(),
- reason: options.reason,
- },
- );
-
- return {
- code: result.code,
- guildId: result.guild?.id ? bot.transformers.snowflake(result.guild.id) : undefined,
- channelId: result.channel?.id ? bot.transformers.snowflake(result.channel.id) : undefined,
- inviter: result.inviter ? bot.transformers.user(bot, result.inviter) : undefined,
- targetType: result.target_type,
- targetUser: result.target_user ? bot.transformers.user(bot, result.target_user) : undefined,
- targetApplicationId: result.target_application?.id
- ? bot.transformers.snowflake(result.target_application.id)
- : undefined,
- approximatePresenceCount: result.approximate_presence_count,
- approximateMemberCount: result.approximate_member_count,
- expiresAt: result.expires_at ? Date.parse(result.expires_at) : undefined,
- };
-}
-
-export interface CreateChannelInvite extends WithReason {
- /** Duration of invite in seconds before expiry, or 0 for never. Between 0 and 604800 (7 days). Default: 86400 (24 hours) */
- maxAge?: number;
- /** Max number of users or 0 for unlimited. Between 0 and 100. Default: 0 */
- maxUses?: number;
- /** Whether this invite only grants temporary membership. Default: false */
- temporary?: boolean;
- /** If true, don't try to reuse similar invite (useful for creating many unique one time use invites). Default: false */
- unique?: boolean;
- /** 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 `target_type` is 1, the user must be streaming in the channel */
- targetUserId?: BigString;
- /** The id of the embedded application to open for this invite, required if `target_type` is 2, the application must have the `EMBEDDED` flag */
- targetApplicationId?: BigString;
-}
diff --git a/helpers/guilds/invites/deleteInvite.ts b/helpers/guilds/invites/deleteInvite.ts
deleted file mode 100644
index 1e80acfae..000000000
--- a/helpers/guilds/invites/deleteInvite.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-
-/**
- * Deletes an invite to a channel.
- *
- * @param bot - The bot instance to use to make the request.
- * @param inviteCode - The invite code of the invite to delete.
- *
- * @remarks
- * Requires the `MANAGE_CHANNELS` permission.
- *
- * Fires an _Invite Delete_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/channel#delete-channel-invite}
- */
-export async function deleteInvite(bot: Bot, inviteCode: string, reason?: string): Promise {
- return await bot.rest.runMethod(
- bot.rest,
- "DELETE",
- bot.constants.routes.INVITE(inviteCode),
- reason ? { reason } : undefined,
- );
-}
diff --git a/helpers/guilds/invites/getInvite.ts b/helpers/guilds/invites/getInvite.ts
deleted file mode 100644
index 9049eedfe..000000000
--- a/helpers/guilds/invites/getInvite.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { BigString, ScheduledEvent, TargetTypes, User } from "../../../mod.ts";
-import { DiscordInviteMetadata } from "../../../types/discord.ts";
-
-export type BaseInvite = {
- code: string;
- guildId?: BigString;
- channelId?: BigString;
- inviter?: User;
- targetType?: TargetTypes;
- targetUser?: User;
- targetApplicationId?: BigString;
- approximatePresenceCount?: number;
- approximateMemberCount?: number;
- expiresAt?: number;
- guildScheduledEvent?: ScheduledEvent;
-};
-
-export type InviteMetadata = BaseInvite & {
- uses: number;
- maxUses: number;
- maxAge: number;
- temporary: boolean;
- createdAt: number;
-};
-
-/**
- * Gets an invite to a channel by its invite code.
- *
- * @param bot - The bot instance to use to make the request.
- * @param inviteCode - The invite code of the invite to get.
- * @param options - The parameters for the fetching of the invite.
- * @returns An instance of {@link BaseInvite | Invite}.
- *
- * @see {@link https://discord.com/developers/docs/resources/invite#get-invite}
- */
-export async function getInvite(bot: Bot, inviteCode: string, options?: GetInvite): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.INVITE(inviteCode, options),
- );
-
- return {
- code: result.code,
- guildId: result.guild?.id ? bot.transformers.snowflake(result.guild.id) : undefined,
- channelId: result.channel?.id ? bot.transformers.snowflake(result.channel.id) : undefined,
- inviter: result.inviter ? bot.transformers.user(bot, result.inviter) : undefined,
- targetType: result.target_type
- ? (result.target_type === 1 ? TargetTypes.Stream : TargetTypes.EmbeddedApplication)
- : undefined,
- targetUser: result.target_user ? bot.transformers.user(bot, result.target_user) : undefined,
- targetApplicationId: result.target_application?.id
- ? bot.transformers.snowflake(result.target_application.id)
- : undefined,
- approximatePresenceCount: result.approximate_presence_count,
- approximateMemberCount: result.approximate_member_count,
- expiresAt: result.expires_at ? Date.parse(result.expires_at) : undefined,
- };
-}
-
-/** https://discord.com/developers/docs/resources/invite#get-invite */
-export interface GetInvite {
- /** Whether the invite should contain approximate member counts */
- withCounts?: boolean;
- /** Whether the invite should contain the expiration date */
- withExpiration?: boolean;
- /** the guild scheduled event to include with the invite */
- scheduledEventId?: BigString;
-}
diff --git a/helpers/guilds/invites/getInvites.ts b/helpers/guilds/invites/getInvites.ts
deleted file mode 100644
index 1edb8299c..000000000
--- a/helpers/guilds/invites/getInvites.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { BigString, TargetTypes } from "../../../mod.ts";
-import { DiscordInviteMetadata } from "../../../types/discord.ts";
-import { Collection } from "../../../util/collection.ts";
-import { InviteMetadata } from "./getInvite.ts";
-
-/**
- * Gets the list of invites for a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to get the invites from.
- * @returns A collection of {@link InviteMetadata | Invite} objects assorted by invite code.
- *
- * @remarks
- * Requires the `MANAGE_GUILD` permission.
- *
- * @see {@link https://discord.com/developers/docs/resources/invite#get-invites}
- */
-export async function getInvites(bot: Bot, guildId: BigString): Promise> {
- const results = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.GUILD_INVITES(guildId),
- );
-
- return new Collection(
- results.map<[string, InviteMetadata]>((result) => {
- const inviteMetadata = {
- code: result.code,
- guildId: result.guild?.id ? bot.transformers.snowflake(result.guild.id) : undefined,
- channelId: result.channel?.id ? bot.transformers.snowflake(result.channel.id) : undefined,
- inviter: result.inviter ? bot.transformers.user(bot, result.inviter) : undefined,
- targetType: result.target_type
- ? (result.target_type === 1 ? TargetTypes.Stream : TargetTypes.EmbeddedApplication)
- : undefined,
- targetUser: result.target_user ? bot.transformers.user(bot, result.target_user) : undefined,
- targetApplicationId: result.target_application?.id
- ? bot.transformers.snowflake(result.target_application.id)
- : undefined,
- approximatePresenceCount: result.approximate_presence_count,
- approximateMemberCount: result.approximate_member_count,
- expiresAt: result.expires_at ? Date.parse(result.expires_at) : undefined,
- guildScheduledEvent: result.guild_scheduled_event
- ? bot.transformers.scheduledEvent(bot, result.guild_scheduled_event)
- : undefined,
- // Metadata structure
- uses: result.uses,
- maxUses: result.max_uses,
- maxAge: result.max_age,
- temporary: result.temporary,
- createdAt: Date.parse(result.created_at),
- };
- return [inviteMetadata.code, inviteMetadata];
- }),
- );
-}
diff --git a/helpers/guilds/invites/mod.ts b/helpers/guilds/invites/mod.ts
deleted file mode 100644
index e0bccf784..000000000
--- a/helpers/guilds/invites/mod.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export * from "./createInvite.ts";
-export * from "./deleteInvite.ts";
-export * from "./getInvite.ts";
-export * from "./getInvites.ts";
diff --git a/helpers/guilds/leaveGuild.ts b/helpers/guilds/leaveGuild.ts
deleted file mode 100644
index 94be730dd..000000000
--- a/helpers/guilds/leaveGuild.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import type { Bot } from "../../bot.ts";
-import { BigString } from "../../types/shared.ts";
-
-/**
- * Leaves a guild.
- *
- * @param bot - The bot instance used to make the request
- * @param guildId - The ID of the guild to leave.
- *
- * @remarks
- * Fires a _Guild Delete_ event.
- *
- * @see {@link https://discord.com/developers/docs/resources/user#leave-guild}
- */
-export async function leaveGuild(bot: Bot, guildId: BigString): Promise {
- return await bot.rest.runMethod(bot.rest, "DELETE", bot.constants.routes.GUILD_LEAVE(guildId));
-}
diff --git a/helpers/guilds/mod.ts b/helpers/guilds/mod.ts
deleted file mode 100644
index 5820019ac..000000000
--- a/helpers/guilds/mod.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-export * from "./automod/mod.ts";
-export * from "./integrations/mod.ts";
-export * from "./invites/mod.ts";
-export * from "./events/mod.ts";
-export * from "./voice/mod.ts";
-export * from "./widget/mod.ts";
-
-export * from "./createGuild.ts";
-export * from "./deleteGuild.ts";
-export * from "./editGuild.ts";
-export * from "./editGuildMfaLevel.ts";
-export * from "./editWelcomeScreen.ts";
-export * from "./getAuditLog.ts";
-export * from "./getBan.ts";
-export * from "./getBans.ts";
-export * from "./getGuild.ts";
-export * from "./getGuildBannerUrl.ts";
-export * from "./getGuildIconUrl.ts";
-export * from "./getGuildPreview.ts";
-export * from "./getGuildSplashUrl.ts";
-export * from "./getPruneCount.ts";
-export * from "./getVanityUrl.ts";
-export * from "./getWelcomeScreen.ts";
-export * from "./leaveGuild.ts";
diff --git a/helpers/guilds/voice/connectToVoiceChannel.ts b/helpers/guilds/voice/connectToVoiceChannel.ts
deleted file mode 100644
index 2cdbe21ec..000000000
--- a/helpers/guilds/voice/connectToVoiceChannel.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { AtLeastOne, BigString, GatewayOpcodes } from "../../../types/shared.ts";
-
-/**
- * Connects the bot user to a voice or stage channel.
- *
- * This function sends the _Update Voice State_ gateway command over the gateway behind the scenes.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild the voice channel to leave is in.
- *
- * @remarks
- * Requires the `CONNECT` permission.
- *
- * Fires a _Voice State Update_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/topics/gateway#update-voice-state}
- */
-export async function connectToVoiceChannel(
- bot: Bot,
- guildId: BigString,
- channelId: BigString,
- options?: AtLeastOne>,
-): Promise {
- const shardId = bot.utils.calculateShardId(bot.gateway, bot.transformers.snowflake(guildId));
- const shard = bot.gateway.manager.shards.get(shardId);
- if (!shard) {
- throw new Error(`Shard (id: ${shardId} not found`);
- }
-
- return shard.send({
- op: GatewayOpcodes.VoiceStateUpdate,
- d: {
- guild_id: guildId.toString(),
- channel_id: channelId.toString(),
- self_mute: Boolean(options?.selfMute),
- self_deaf: options?.selfDeaf ?? true,
- },
- });
-}
-
-/** https://discord.com/developers/docs/topics/gateway#update-voice-state */
-export interface UpdateVoiceState {
- /** id of the guild */
- guildId: string;
- /** id of the voice channel client wants to join (null if disconnecting) */
- channelId: string | null;
- /** Is the client muted */
- selfMute: boolean;
- /** Is the client deafened */
- selfDeaf: boolean;
-}
diff --git a/helpers/guilds/voice/editVoiceState.ts b/helpers/guilds/voice/editVoiceState.ts
deleted file mode 100644
index 875df5ae4..000000000
--- a/helpers/guilds/voice/editVoiceState.ts
+++ /dev/null
@@ -1,81 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { BigString } from "../../../types/shared.ts";
-
-export const updateBotVoiceState = editOwnVoiceState;
-
-/**
- * Edits the voice state of the bot user.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild in which to edit the voice state of the bot user.
- * @param options - The parameters for the edit of the voice state.
- *
- * @remarks
- * The {@link EditOwnVoiceState.channelId | channelId} property of the {@link options} object parameter must point to a stage channel, and the bot user must already have joined it.
- *
- * If attempting to unmute oneself:
- * - Requires the `MUTE_MEMBERS` permission.
- *
- * If attempting to request to speak:
- * - Requires the `REQUEST_TO_SPEAK` permission.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state}
- */
-export async function editOwnVoiceState(bot: Bot, guildId: BigString, options: EditOwnVoiceState): Promise {
- return await bot.rest.runMethod(bot.rest, "PATCH", bot.constants.routes.UPDATE_VOICE_STATE(guildId), {
- channel_id: options.channelId,
- suppress: options.suppress,
- request_to_speak_timestamp: options.requestToSpeakTimestamp
- ? new Date(options.requestToSpeakTimestamp).toISOString()
- : options.requestToSpeakTimestamp,
- });
-}
-
-// TODO: Make the `userId` property of `options` its own parameter.
-
-/**
- * Edits the voice state of another user.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild in which to edit the voice state of the bot user.
- * @param options - The parameters for the edit of the voice state.
- *
- * @remarks
- * The {@link EditOwnVoiceState.channelId | channelId} property of the {@link options} object parameter must point to a stage channel, and the user must already have joined it.
- *
- * Requires the `MUTE_MEMBERS` permission.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state}
- */
-export async function editUserVoiceState(bot: Bot, guildId: BigString, options: EditUserVoiceState): Promise {
- return await bot.rest.runMethod(
- bot.rest,
- "PATCH",
- bot.constants.routes.UPDATE_VOICE_STATE(guildId, options.userId),
- {
- channel_id: options.channelId,
- suppress: options.suppress,
- user_id: options.userId,
- },
- );
-}
-
-/** https://discord.com/developers/docs/resources/guild#update-current-user-voice-state */
-export interface EditOwnVoiceState {
- /** The id of the channel the user is currently in */
- channelId: BigString;
- /** Toggles the user's suppress state */
- suppress?: boolean;
- /** Sets the user's request to speak */
- requestToSpeakTimestamp?: number | null;
-}
-
-/** https://discord.com/developers/docs/resources/guild#update-user-voice-state */
-export interface EditUserVoiceState {
- /** The id of the channel the user is currently in */
- channelId: BigString;
- /** Toggles the user's suppress state */
- suppress?: boolean;
- /** The user id to target */
- userId: BigString;
-}
diff --git a/helpers/guilds/voice/getAvailableVoiceRegions.ts b/helpers/guilds/voice/getAvailableVoiceRegions.ts
deleted file mode 100644
index a05d2da39..000000000
--- a/helpers/guilds/voice/getAvailableVoiceRegions.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { VoiceRegions } from "../../../transformers/voiceRegion.ts";
-import { DiscordVoiceRegion } from "../../../types/discord.ts";
-import { Collection } from "../../../util/collection.ts";
-
-/**
- * Gets the list of available voice regions.
- *
- * @param bot - The bot instance to use to make the request.
- * @returns A collection of {@link VoiceRegions | VoiceRegion} objects assorted by voice region ID.
- */
-export async function getAvailableVoiceRegions(bot: Bot): Promise> {
- const results = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.VOICE_REGIONS(),
- );
-
- return new Collection(
- results.map((result) => {
- const region = bot.transformers.voiceRegion(bot, result);
- return [region.id, region];
- }),
- );
-}
diff --git a/helpers/guilds/voice/getVoiceRegions.ts b/helpers/guilds/voice/getVoiceRegions.ts
deleted file mode 100644
index 1f2c7df23..000000000
--- a/helpers/guilds/voice/getVoiceRegions.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { VoiceRegions } from "../../../transformers/voiceRegion.ts";
-import { DiscordVoiceRegion } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-import { Collection } from "../../../util/collection.ts";
-
-/**
- * Gets the list of voice regions for a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to get the voice regions for.
- * @returns A collection of {@link VoiceRegions | VoiceRegion} objects assorted by voice region ID.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#get-guild-voice-regions}
- */
-export async function getVoiceRegions(bot: Bot, guildId: BigString): Promise> {
- const results = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.GUILD_REGIONS(guildId),
- );
-
- return new Collection(
- results.map((result) => {
- const region = bot.transformers.voiceRegion(bot, result);
- return [region.id, region];
- }),
- );
-}
diff --git a/helpers/guilds/voice/leaveVoiceChannel.ts b/helpers/guilds/voice/leaveVoiceChannel.ts
deleted file mode 100644
index 9d6e4e628..000000000
--- a/helpers/guilds/voice/leaveVoiceChannel.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { BigString, GatewayOpcodes } from "../../../types/shared.ts";
-
-/**
- * Leaves the voice channel the bot user is currently in.
- *
- * This function sends the _Update Voice State_ gateway command over the gateway behind the scenes.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild the voice channel to leave is in.
- *
- * @remarks
- * Fires a _Voice State Update_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/topics/gateway#update-voice-state}
- */
-export async function leaveVoiceChannel(
- bot: Bot,
- guildId: BigString,
-): Promise {
- const shardId = bot.utils.calculateShardId(bot.gateway, bot.transformers.snowflake(guildId));
- const shard = bot.gateway.manager.shards.get(shardId);
- if (!shard) {
- throw new Error(`Shard (id: ${shardId} not found`);
- }
-
- return shard.send({
- op: GatewayOpcodes.VoiceStateUpdate,
- d: {
- guild_id: guildId.toString(),
- channel_id: null,
- self_mute: false,
- self_deaf: false,
- },
- });
-}
diff --git a/helpers/guilds/voice/mod.ts b/helpers/guilds/voice/mod.ts
deleted file mode 100644
index 80a759613..000000000
--- a/helpers/guilds/voice/mod.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export * from "./connectToVoiceChannel.ts";
-export * from "./editVoiceState.ts";
-export * from "./getAvailableVoiceRegions.ts";
-export * from "./getVoiceRegions.ts";
-export * from "./leaveVoiceChannel.ts";
diff --git a/helpers/guilds/widget/editWidgetSettings.ts b/helpers/guilds/widget/editWidgetSettings.ts
deleted file mode 100644
index 6c2d27d0f..000000000
--- a/helpers/guilds/widget/editWidgetSettings.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { GuildWidgetSettings } from "../../../transformers/widgetSettings.ts";
-import { DiscordGuildWidgetSettings } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-
-// TODO: Use `options` instead of `enabled` and `channelId`.
-
-/**
- * Edits the settings of a guild's widget.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to edit the settings of the widget of.
- * @returns An instance of the edited {@link GuildWidgetSettings}.
- *
- * @remarks
- * Requires the `MANAGE_GUILD` permission.
- *
- * Fires a _Guild Update_ gateway event.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#modify-guild-widget}
- */
-export async function editWidgetSettings(
- bot: Bot,
- guildId: BigString,
- enabled: boolean,
- channelId?: string | null,
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "PATCH",
- bot.constants.routes.GUILD_WIDGET(guildId),
- {
- enabled,
- channel_id: channelId,
- },
- );
-
- return bot.transformers.widgetSettings(bot, result);
-}
diff --git a/helpers/guilds/widget/getWidget.ts b/helpers/guilds/widget/getWidget.ts
deleted file mode 100644
index 7053a498f..000000000
--- a/helpers/guilds/widget/getWidget.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { GuildWidget } from "../../../transformers/widget.ts";
-import { DiscordGuildWidget } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Gets the guild widget by guild ID.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to get the widget of.
- * @returns An instance of {@link GuildWidget}.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#get-guild-widget}
- */
-export async function getWidget(bot: Bot, guildId: BigString): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.GUILD_WIDGET_JSON(guildId),
- );
-
- return bot.transformers.widget(bot, result);
-}
diff --git a/helpers/guilds/widget/getWidgetImageUrl.ts b/helpers/guilds/widget/getWidgetImageUrl.ts
deleted file mode 100644
index 9d7e96221..000000000
--- a/helpers/guilds/widget/getWidgetImageUrl.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Builds a URL to the guild widget image stored in the Discord CDN.
- *
- * @param bot - The bot instance to use to build the URL.
- * @param guildId - The ID of the guild to get the link to the widget image for.
- * @param options - The parameters for the building of the URL.
- * @returns The link to the resource.
- */
-export function getWidgetImageURL(bot: Bot, guildId: BigString, options?: GetGuildWidgetImageQuery): string {
- return bot.constants.routes.GUILD_WIDGET_IMAGE(guildId, options?.style);
-}
-
-/** https://discord.com/developers/docs/resources/guild#get-guild-widget-image-query-string-params */
-export interface GetGuildWidgetImageQuery {
- /**
- * Style of the widget returned, default: shield
- *
- * Shield: Widget with Discord icon and guild members online count.
- * Banner1: Large image with guild icon, name and online count. "POWERED BY DISCORD" as the footer of the widget
- * Banner2: Smaller widget style with guild icon, name and online count. Split on the right with Discord logo
- * Banner3: Large image with guild icon, name and online count. In the footer, Discord logo on the left and "Chat Now" on the right
- * Banner4: Large Discord logo at the top of the widget. Guild icon, name and online count in the middle portion of the widget and a "JOIN MY SERVER" button at the bottom
- */
- style?:
- | "shield"
- | "banner1"
- | "banner2"
- | "banner3"
- | "banner4";
-}
diff --git a/helpers/guilds/widget/getWidgetSettings.ts b/helpers/guilds/widget/getWidgetSettings.ts
deleted file mode 100644
index 60dd5b6cc..000000000
--- a/helpers/guilds/widget/getWidgetSettings.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { GuildWidgetSettings } from "../../../transformers/widgetSettings.ts";
-import { DiscordGuildWidgetSettings } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Gets the settings of a guild's widget.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to get the widget of.
- * @returns An instance of {@link GuildWidgetSettings}.
- *
- * @remarks
- * Requires the `MANAGE_GUILD` permission.
- *
- * @see {@link https://discord.com/developers/docs/resources/guild#get-guild-widget-settings}
- */
-export async function getWidgetSettings(bot: Bot, guildId: BigString): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.GUILD_WIDGET(guildId),
- );
-
- return bot.transformers.widgetSettings(bot, result);
-}
diff --git a/helpers/guilds/widget/mod.ts b/helpers/guilds/widget/mod.ts
deleted file mode 100644
index 061123e3d..000000000
--- a/helpers/guilds/widget/mod.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export * from "./editWidgetSettings.ts";
-export * from "./getWidget.ts";
-export * from "./getWidgetImageUrl.ts";
-export * from "./getWidgetSettings.ts";
diff --git a/helpers/interactions/commands/createGlobalApplicationCommand.ts b/helpers/interactions/commands/createGlobalApplicationCommand.ts
deleted file mode 100644
index 608ca788c..000000000
--- a/helpers/interactions/commands/createGlobalApplicationCommand.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { ApplicationCommand, CreateApplicationCommand } from "../../../mod.ts";
-import { DiscordApplicationCommand } from "../../../types/discord.ts";
-
-/**
- * Creates an application command accessible globally; across different guilds and channels.
- *
- * @param bot - The bot instance to use to make the request.
- * @param command - The command to create.
- * @returns An instance of the created {@link ApplicationCommand}.
- *
- * @remarks
- * ⚠️ Creating a command with the same name as an existing command for your application will overwrite the old command.
- * ⚠️ Global commands once created are cached for periods of __an hour__, so changes made to existing commands will take an hour to surface.
- * ⚠️ You can only create up to 200 _new_ commands daily.
- *
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#create-global-application-command}
- */
-export async function createGlobalApplicationCommand(
- bot: Bot,
- command: CreateApplicationCommand,
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "POST",
- bot.constants.routes.COMMANDS(bot.applicationId),
- bot.transformers.reverse.createApplicationCommand(bot, command),
- );
-
- return bot.transformers.applicationCommand(bot, result);
-}
diff --git a/helpers/interactions/commands/createGuildApplicationCommand.ts b/helpers/interactions/commands/createGuildApplicationCommand.ts
deleted file mode 100644
index 57b42d462..000000000
--- a/helpers/interactions/commands/createGuildApplicationCommand.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import { Bot } from "../../../bot.ts";
-import { ApplicationCommand, BigString, CreateApplicationCommand, DiscordApplicationCommand } from "../../../mod.ts";
-
-/**
- * Creates an application command only accessible in a specific guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param command - The command to create.
- * @param guildId - The ID of the guild to create the command for.
- * @returns An instance of the created {@link ApplicationCommand}.
- *
- * @remarks
- * ⚠️ Creating a command with the same name as an existing command for your application will overwrite the old command.
- * ⚠️ You can only create up to 200 _new_ commands daily.
- *
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command}
- */
-export async function createGuildApplicationCommand(
- bot: Bot,
- command: CreateApplicationCommand,
- guildId: BigString,
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "POST",
- bot.constants.routes.COMMANDS_GUILD(bot.applicationId, guildId),
- bot.transformers.reverse.createApplicationCommand(bot, command),
- );
-
- return bot.transformers.applicationCommand(bot, result);
-}
diff --git a/helpers/interactions/commands/deleteGlobalApplicationCommand.ts b/helpers/interactions/commands/deleteGlobalApplicationCommand.ts
deleted file mode 100644
index 1f9cddfe0..000000000
--- a/helpers/interactions/commands/deleteGlobalApplicationCommand.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Deletes an application command registered globally.
- *
- * @param bot - The bot instance to use to make the request.
- * @param commandId - The ID of the command to delete.
- *
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#delete-global-application-command}
- */
-export async function deleteGlobalApplicationCommand(bot: Bot, commandId: BigString): Promise {
- return await bot.rest.runMethod(
- bot.rest,
- "DELETE",
- bot.constants.routes.COMMANDS_ID(bot.applicationId, commandId),
- );
-}
diff --git a/helpers/interactions/commands/deleteGuildApplicationCommand.ts b/helpers/interactions/commands/deleteGuildApplicationCommand.ts
deleted file mode 100644
index 69fecf7e4..000000000
--- a/helpers/interactions/commands/deleteGuildApplicationCommand.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { BigString } from "../../../types/shared.ts";
-
-// TODO: `guildId` and `commandId` should be swapped.
-
-/**
- * Deletes an application command registered in a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to delete the command from.
- * @param commandId - The ID of the command to delete from the guild.
- *
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#delete-guild-application-command}
- */
-export async function deleteGuildApplicationCommand(bot: Bot, commandId: BigString, guildId: BigString): Promise {
- return await bot.rest.runMethod(
- bot.rest,
- "DELETE",
- bot.constants.routes.COMMANDS_GUILD_ID(bot.applicationId, guildId, commandId),
- );
-}
diff --git a/helpers/interactions/commands/editApplicationCommandPermissions.ts b/helpers/interactions/commands/editApplicationCommandPermissions.ts
deleted file mode 100644
index 45c522396..000000000
--- a/helpers/interactions/commands/editApplicationCommandPermissions.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { ApplicationCommandPermission } from "../../../transformers/applicationCommandPermission.ts";
-import { DiscordGuildApplicationCommandPermissions } from "../../../types/discord.ts";
-import { ApplicationCommandPermissionTypes, BigString } from "../../../types/shared.ts";
-
-// TODO: Make `options` into an object with a `permissions` field.
-
-/**
- * Edits the permissions for a guild application command.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild the command is registered in.
- * @param commandId - The ID of the command to edit the permissions of.
- * @param bearerToken - The bearer token to use to make the request.
- * @param options - The parameters for the edit of the command permissions.
- * @returns An instance of the edited {@link ApplicationCommandPermission}.
- *
- * @remarks
- * The bearer token requires the `applications.commands.permissions.update` scope to be enabled, and to have access to the guild whose ID has been provided in the parameters.
- *
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions}
- */
-export async function editApplicationCommandPermissions(
- bot: Bot,
- guildId: BigString,
- commandId: BigString,
- /** Bearer token which has the `applications.commands.permissions.update` scope and also access to this guild. */
- bearerToken: string,
- options: ApplicationCommandPermissions[],
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "PUT",
- bot.constants.routes.COMMANDS_PERMISSION(bot.applicationId, guildId, commandId),
- {
- permissions: options,
- },
- {
- headers: { authorization: `Bearer ${bearerToken}` },
- },
- );
-
- return bot.transformers.applicationCommandPermission(bot, result);
-}
-
-/** https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions */
-export interface ApplicationCommandPermissions {
- /** The id of the role or user */
- id: string;
- /** Role or User */
- type: ApplicationCommandPermissionTypes;
- /** `true` to allow, `false`, to disallow */
- permission: boolean;
-}
diff --git a/helpers/interactions/commands/editGlobalApplicationCommand.ts b/helpers/interactions/commands/editGlobalApplicationCommand.ts
deleted file mode 100644
index b6d77774a..000000000
--- a/helpers/interactions/commands/editGlobalApplicationCommand.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { ApplicationCommand } from "../../../transformers/applicationCommand.ts";
-import { BigString, CreateApplicationCommand, DiscordApplicationCommand } from "../../../types/mod.ts";
-
-/**
- * Edits a global application command.
- *
- * @param bot - The bot instance to use to make the request.
- * @param commandId - The ID of the command to edit.
- * @param options - The parameters for the edit of the command.
- * @returns An instance of the edited {@link ApplicationCommand}.
- *
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command}
- */
-export async function editGlobalApplicationCommand(
- bot: Bot,
- commandId: BigString,
- options: CreateApplicationCommand,
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "PATCH",
- bot.constants.routes.COMMANDS_ID(bot.applicationId, commandId),
- bot.transformers.reverse.createApplicationCommand(bot, options),
- );
-
- return bot.transformers.applicationCommand(bot, result);
-}
diff --git a/helpers/interactions/commands/editGuildApplicationCommand.ts b/helpers/interactions/commands/editGuildApplicationCommand.ts
deleted file mode 100644
index 3ff7d1610..000000000
--- a/helpers/interactions/commands/editGuildApplicationCommand.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { ApplicationCommand } from "../../../transformers/applicationCommand.ts";
-import { BigString, CreateApplicationCommand, DiscordApplicationCommand } from "../../../types/mod.ts";
-
-// TODO: Swap `commandId` and `guildId` parameters.
-
-/**
- * Edits an application command registered in a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild the command is registered in.
- * @param commandId - The ID of the command to edit.
- * @param options - The parameters for the edit of the command.
- * @returns An instance of the edited {@link ApplicationCommand}.
- *
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command}
- */
-export async function editGuildApplicationCommand(
- bot: Bot,
- commandId: BigString,
- guildId: BigString,
- options: CreateApplicationCommand,
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "PATCH",
- bot.constants.routes.COMMANDS_GUILD_ID(bot.applicationId, guildId, commandId),
- bot.transformers.reverse.createApplicationCommand(bot, options),
- );
-
- return bot.transformers.applicationCommand(bot, result);
-}
diff --git a/helpers/interactions/commands/getApplicationCommandPermission.ts b/helpers/interactions/commands/getApplicationCommandPermission.ts
deleted file mode 100644
index c258946cf..000000000
--- a/helpers/interactions/commands/getApplicationCommandPermission.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { ApplicationCommandPermission } from "../../../transformers/applicationCommandPermission.ts";
-import { DiscordGuildApplicationCommandPermissions } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Gets the permissions of a guild application command.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild the command is registered in.
- * @param commandId - The ID of the command to get the permissions of.
- * @returns An instance of {@link ApplicationCommandPermission}.
- *
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#get-application-command-permissions}
- */
-export async function getApplicationCommandPermission(
- bot: Bot,
- guildId: BigString,
- commandId: BigString,
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.COMMANDS_PERMISSION(bot.applicationId, guildId, commandId),
- );
-
- return bot.transformers.applicationCommandPermission(bot, result);
-}
diff --git a/helpers/interactions/commands/getApplicationCommandPermissions.ts b/helpers/interactions/commands/getApplicationCommandPermissions.ts
deleted file mode 100644
index c76a4f2b4..000000000
--- a/helpers/interactions/commands/getApplicationCommandPermissions.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { ApplicationCommandPermission } from "../../../transformers/applicationCommandPermission.ts";
-import { DiscordGuildApplicationCommandPermissions } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-import { Collection } from "../../../util/collection.ts";
-
-/**
- * Gets the permissions of all application commands registered in a guild by the ID of the guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild to get the permissions objects of.
- * @returns A collection of {@link ApplicationCommandPermission} objects assorted by command ID.
- *
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions}
- */
-export async function getApplicationCommandPermissions(
- bot: Bot,
- guildId: BigString,
-): Promise> {
- const results = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.COMMANDS_PERMISSIONS(bot.applicationId, guildId),
- );
-
- return new Collection(
- results.map((result) => {
- const permission = bot.transformers.applicationCommandPermission(bot, result);
- return [permission.id, permission];
- }),
- );
-}
diff --git a/helpers/interactions/commands/getGlobalApplicationCommand.ts b/helpers/interactions/commands/getGlobalApplicationCommand.ts
deleted file mode 100644
index c70aa6022..000000000
--- a/helpers/interactions/commands/getGlobalApplicationCommand.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { ApplicationCommand } from "../../../transformers/applicationCommand.ts";
-import { DiscordApplicationCommand } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Gets a global application command by its ID.
- *
- * @param bot - The bot instance to use to make the request.
- * @param commandId - The ID of the command to get.
- * @returns An instance of {@link ApplicationCommand}.
- *
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#get-global-application-command}
- */
-export async function getGlobalApplicationCommand(bot: Bot, commandId: BigString): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.COMMANDS_ID(bot.applicationId, commandId),
- );
-
- return bot.transformers.applicationCommand(bot, result);
-}
diff --git a/helpers/interactions/commands/getGlobalApplicationCommands.ts b/helpers/interactions/commands/getGlobalApplicationCommands.ts
deleted file mode 100644
index c3c07ddce..000000000
--- a/helpers/interactions/commands/getGlobalApplicationCommands.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { ApplicationCommand } from "../../../transformers/applicationCommand.ts";
-import { DiscordApplicationCommand } from "../../../types/discord.ts";
-import { Collection } from "../../../util/collection.ts";
-
-// TODO: Implement `with_localizations` options field.
-
-/**
- * Gets the list of your bot's global application commands.
- *
- * @param bot - The bot instance to use to make the request.
- * @returns A collection of {@link ApplicationCommand} objects assorted by command ID.
- *
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#get-global-application-commands}
- */
-export async function getGlobalApplicationCommands(bot: Bot): Promise> {
- const results = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.COMMANDS(bot.applicationId),
- );
-
- return new Collection(
- results.map((result) => {
- const command = bot.transformers.applicationCommand(bot, result);
- return [command.id, command];
- }),
- );
-}
diff --git a/helpers/interactions/commands/getGuildApplicationCommand.ts b/helpers/interactions/commands/getGuildApplicationCommand.ts
deleted file mode 100644
index 36f4362d0..000000000
--- a/helpers/interactions/commands/getGuildApplicationCommand.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { ApplicationCommand } from "../../../transformers/applicationCommand.ts";
-import { DiscordApplicationCommand } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-
-// TODO: Swap `commandId` and `guildId` parameters.
-
-/**
- * Gets a guild application command by its ID.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild the command is registered in.
- * @param commandId - The ID of the command to get.
- * @returns An instance of {@link ApplicationCommand}.
- *
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command}
- */
-export async function getGuildApplicationCommand(
- bot: Bot,
- commandId: BigString,
- guildId: BigString,
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.COMMANDS_GUILD_ID(bot.applicationId, guildId, commandId),
- );
-
- return bot.transformers.applicationCommand(bot, result);
-}
diff --git a/helpers/interactions/commands/getGuildApplicationCommands.ts b/helpers/interactions/commands/getGuildApplicationCommands.ts
deleted file mode 100644
index f739c79e5..000000000
--- a/helpers/interactions/commands/getGuildApplicationCommands.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { ApplicationCommand } from "../../../transformers/applicationCommand.ts";
-import { DiscordApplicationCommand } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-import { Collection } from "../../../util/collection.ts";
-
-/**
- * Gets the list of application commands registered by your bot in a guild.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild the commands are registered in.
- * @returns A collection of {@link ApplicationCommand} objects assorted by command ID.
- *
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#get-global-application-commandss}
- */
-export async function getGuildApplicationCommands(
- bot: Bot,
- guildId: BigString,
-): Promise> {
- const results = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.COMMANDS_GUILD(bot.applicationId, guildId),
- );
-
- return new Collection(
- results.map((result) => {
- const command = bot.transformers.applicationCommand(bot, result);
- return [command.id, command];
- }),
- );
-}
diff --git a/helpers/interactions/commands/mod.ts b/helpers/interactions/commands/mod.ts
deleted file mode 100644
index c0a9c4e68..000000000
--- a/helpers/interactions/commands/mod.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-export * from "./createGlobalApplicationCommand.ts";
-export * from "./createGuildApplicationCommand.ts";
-export * from "./deleteGlobalApplicationCommand.ts";
-export * from "./deleteGuildApplicationCommand.ts";
-export * from "./editApplicationCommandPermissions.ts";
-export * from "./editGlobalApplicationCommand.ts";
-export * from "./editGuildApplicationCommand.ts";
-export * from "./getApplicationCommandPermission.ts";
-export * from "./getApplicationCommandPermissions.ts";
-export * from "./getGlobalApplicationCommand.ts";
-export * from "./getGlobalApplicationCommands.ts";
-export * from "./getGuildApplicationCommand.ts";
-export * from "./getGuildApplicationCommands.ts";
-export * from "./upsertGlobalApplicationCommands.ts";
-export * from "./upsertGuildApplicationCommands.ts";
diff --git a/helpers/interactions/commands/upsertGlobalApplicationCommands.ts b/helpers/interactions/commands/upsertGlobalApplicationCommands.ts
deleted file mode 100644
index 4bda82283..000000000
--- a/helpers/interactions/commands/upsertGlobalApplicationCommands.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { ApplicationCommand } from "../../../transformers/applicationCommand.ts";
-import { CreateApplicationCommand, DiscordApplicationCommand } from "../../../types/mod.ts";
-import { Collection } from "../../../util/collection.ts";
-
-/**
- * Re-registers the list of global application commands, overwriting the previous commands completely.
- *
- * @param bot - The bot instance to use to make the request.
- * @param commands - The list of commands to use to overwrite the previous list.
- * @returns A collection of {@link ApplicationCommand} objects assorted by command ID.
- *
- * @remarks
- * ❗ Commands that are not present in the `commands` array will be __deleted__.
- *
- * ⚠️ Commands that do not already exist will count towards the daily limit of _200_ new commands.
- *
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands}
- */
-export async function upsertGlobalApplicationCommands(
- bot: Bot,
- commands: CreateApplicationCommand[],
-): Promise> {
- const results = await bot.rest.runMethod(
- bot.rest,
- "PUT",
- bot.constants.routes.COMMANDS(bot.applicationId),
- commands.map((command) => bot.transformers.reverse.createApplicationCommand(bot, command)),
- );
-
- return new Collection(
- results.map((result) => {
- const command = bot.transformers.applicationCommand(bot, result);
- return [command.id, command];
- }),
- );
-}
diff --git a/helpers/interactions/commands/upsertGuildApplicationCommands.ts b/helpers/interactions/commands/upsertGuildApplicationCommands.ts
deleted file mode 100644
index d8f7c22cd..000000000
--- a/helpers/interactions/commands/upsertGuildApplicationCommands.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { ApplicationCommand } from "../../../transformers/applicationCommand.ts";
-import { BigString, CreateApplicationCommand, DiscordApplicationCommand } from "../../../types/mod.ts";
-import { Collection } from "../../../util/collection.ts";
-
-/**
- * Re-registers the list of application commands registered in a guild, overwriting the previous commands completely.
- *
- * @param bot - The bot instance to use to make the request.
- * @param guildId - The ID of the guild whose list of commands to overwrite.
- * @param commands - The list of commands to use to overwrite the previous list.
- * @returns A collection of {@link ApplicationCommand} objects assorted by command ID.
- *
- * @remarks
- * ❗ Commands that are not present in the `commands` array will be __deleted__.
- *
- * ⚠️ Commands that do not already exist will count towards the daily limit of _200_ new commands.
- *
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands}
- */
-export async function upsertGuildApplicationCommands(
- bot: Bot,
- guildId: BigString,
- commands: CreateApplicationCommand[],
-): Promise> {
- const results = await bot.rest.runMethod(
- bot.rest,
- "PUT",
- bot.constants.routes.COMMANDS_GUILD(bot.applicationId, guildId),
- commands.map((command) => bot.transformers.reverse.createApplicationCommand(bot, command)),
- );
-
- return new Collection(
- results.map((result) => {
- const command = bot.transformers.applicationCommand(bot, result);
- return [command.id, command];
- }),
- );
-}
diff --git a/helpers/interactions/mod.ts b/helpers/interactions/mod.ts
deleted file mode 100644
index 8532dd52e..000000000
--- a/helpers/interactions/mod.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from "./commands/mod.ts";
-export * from "./responses/mod.ts";
diff --git a/helpers/interactions/responses/deleteFollowupMessage.ts b/helpers/interactions/responses/deleteFollowupMessage.ts
deleted file mode 100644
index 7346e32d3..000000000
--- a/helpers/interactions/responses/deleteFollowupMessage.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Deletes a follow-up message to an interaction.
- *
- * @param bot - The bot instance to use to make the request.
- * @param token - The interaction token to use, provided in the original interaction.
- * @param messageId - The ID of the message to delete.
- *
- * @remarks
- * Unlike `deleteMessage()`, this endpoint allows the bot user to act without needing to see the channel the message is in.
- *
- * Does not support ephemeral follow-up messages due to these being stateless.
- *
- * Fires a _Message Delete_ event.
- *
- * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#delete-followup-message}
- */
-export async function deleteFollowupMessage(bot: Bot, token: string, messageId: BigString): Promise {
- return await bot.rest.runMethod(
- bot.rest,
- "DELETE",
- bot.constants.routes.INTERACTION_ID_TOKEN_MESSAGE_ID(bot.applicationId, token, messageId),
- );
-}
diff --git a/helpers/interactions/responses/deleteOriginalInteractionResponse.ts b/helpers/interactions/responses/deleteOriginalInteractionResponse.ts
deleted file mode 100644
index 854f6a64f..000000000
--- a/helpers/interactions/responses/deleteOriginalInteractionResponse.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-
-/**
- * Deletes the initial message response to an interaction.
- *
- * @param bot - The bot instance to use to make the request.
- * @param token - The interaction token to use, provided in the original interaction.
- *
- * @remarks
- * Unlike `deleteMessage()`, this endpoint allows the bot user to act without needing to see the channel the message is in.
- *
- * Does not support ephemeral follow-up messages due to these being stateless.
- *
- * Fires a _Message Delete_ event.
- *
- * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#delete-original-interaction-response}
- */
-export async function deleteOriginalInteractionResponse(bot: Bot, token: string): Promise {
- return await bot.rest.runMethod(
- bot.rest,
- "DELETE",
- bot.constants.routes.INTERACTION_ORIGINAL_ID_TOKEN(bot.applicationId, token),
- );
-}
diff --git a/helpers/interactions/responses/editFollowupMessage.ts b/helpers/interactions/responses/editFollowupMessage.ts
deleted file mode 100644
index 66b44f6cd..000000000
--- a/helpers/interactions/responses/editFollowupMessage.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { InteractionCallbackData } from "../../../mod.ts";
-import { Message } from "../../../transformers/message.ts";
-import { DiscordMessage } from "../../../types/discord.ts";
-import { BigString, InteractionResponseTypes } from "../../../types/shared.ts";
-
-/**
- * Edits a follow-up message to an interaction.
- *
- * @param bot - The bot instance to use to make the request.
- * @param token - The interaction token to use, provided in the original interaction.
- * @param messageId - The ID of the message to edit.
- * @param options - The parameters for the edit of the message.
- * @returns An instance of the edited {@link Message}.
- *
- * @remarks
- * Unlike `editMessage()`, this endpoint allows the bot user to act without needing to see the channel the message is in.
- *
- * Does not support ephemeral follow-up messages due to these being stateless.
- *
- * Fires a _Message Update_ event.
- *
- * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message}
- */
-export async function editFollowupMessage(
- bot: Bot,
- token: string,
- messageId: BigString,
- options: InteractionCallbackData,
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "PATCH",
- bot.constants.routes.WEBHOOK_MESSAGE(bot.applicationId, token, messageId),
- {
- messageId: messageId.toString(),
- ...bot.transformers.reverse.interactionResponse(bot, {
- type: InteractionResponseTypes.UpdateMessage,
- data: options,
- }).data,
- file: options.file,
- },
- );
-
- return bot.transformers.message(bot, result);
-}
diff --git a/helpers/interactions/responses/editOriginalInteractionResponse.ts b/helpers/interactions/responses/editOriginalInteractionResponse.ts
deleted file mode 100644
index 4a9e4b872..000000000
--- a/helpers/interactions/responses/editOriginalInteractionResponse.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { Message } from "../../../transformers/message.ts";
-import { DiscordMessage } from "../../../types/discord.ts";
-import { InteractionCallbackData, InteractionResponseTypes } from "../../../types/mod.ts";
-
-/**
- * Edits the initial message response to an interaction.
- *
- * @param bot - The bot instance to use to make the request.
- * @param token - The interaction token to use, provided in the original interaction.
- * @param options - The parameters for the edit of the response.
- * @returns An instance of the edited {@link Message}.
- *
- * @remarks
- * Unlike `editMessage()`, this endpoint allows the bot user to act without needing to see the channel the message is in.
- *
- * Does not support ephemeral follow-up messages due to these being stateless.
- *
- * Fires a _Message Update_ event.
- *
- * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#edit-original-interaction-response}
- */
-export async function editOriginalInteractionResponse(
- bot: Bot,
- token: string,
- options: InteractionCallbackData,
-): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "PATCH",
- bot.constants.routes.INTERACTION_ORIGINAL_ID_TOKEN(bot.applicationId, token),
- {
- ...bot.transformers.reverse.interactionResponse(bot, {
- type: InteractionResponseTypes.UpdateMessage,
- data: options,
- }).data,
- file: options.file,
- },
- );
-
- return bot.transformers.message(bot, result);
-}
diff --git a/helpers/interactions/responses/getFollowupMessage.ts b/helpers/interactions/responses/getFollowupMessage.ts
deleted file mode 100644
index e954d5a1c..000000000
--- a/helpers/interactions/responses/getFollowupMessage.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { Message } from "../../../transformers/message.ts";
-import { DiscordMessage } from "../../../types/discord.ts";
-import { BigString } from "../../../types/shared.ts";
-
-/**
- * Gets a follow-up message to an interaction by the ID of the message.
- *
- * @param bot - The bot instance to use to make the request.
- * @param token - The interaction token to use, provided in the original interaction.
- * @param messageId - The ID of the message to get.
- * @returns An instance of {@link Message}.
- *
- * @remarks
- * Unlike `getMessage()`, this endpoint allows the bot user to act without:
- * - Needing to be able to see the contents of the channel that the message is in. (`READ_MESSAGES` permission.)
- * - Requiring the `MESSAGE_CONTENT` intent.
- *
- * Does not support ephemeral follow-up messages due to these being stateless.
- *
- * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#get-followup-message}
- */
-export async function getFollowupMessage(bot: Bot, token: string, messageId: BigString): Promise {
- const result = await bot.rest.runMethod(
- bot.rest,
- "GET",
- bot.constants.routes.INTERACTION_ID_TOKEN_MESSAGE_ID(bot.applicationId, token, messageId),
- );
-
- return bot.transformers.message(bot, result);
-}
diff --git a/helpers/interactions/responses/getOriginalInteractionResponse.ts b/helpers/interactions/responses/getOriginalInteractionResponse.ts
deleted file mode 100644
index 6998a8164..000000000
--- a/helpers/interactions/responses/getOriginalInteractionResponse.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import type { Bot } from "../../../bot.ts";
-import { Message } from "../../../transformers/message.ts";
-import { DiscordMessage } from "../../../types/discord.ts";
-
-/**
- * Gets the initial message response to an interaction.
- *
- * @param bot - The bot instance to use to make the request.
- * @param token - The interaction token to use, provided in the original interaction.
- * @returns An instance of {@link Message}.
- *
- * @remarks
- * Unlike `getMessage()`, this endpoint allows the bot user to act without:
- * - Needing to be able to see the contents of the channel that the message is in. (`READ_MESSAGES` permission.)
- * - Requiring the `MESSAGE_CONTENT` intent.
- *
- * Does not support ephemeral follow-up messages due to these being stateless.
- *
- * @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response}
- */
-export async function getOriginalInteractionResponse(bot: Bot, token: string): Promise {
- const result = await bot.rest.runMethod