diff --git a/.eslintrc.json b/.eslintrc.json index d9c6fa782..f524f5f7d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,44 +1,65 @@ { - "extends": "eslint:recommended", + "extends": ["eslint:recommended", "plugin:prettier/recommended"], + "plugins": ["import"], "parserOptions": { - "ecmaVersion": 6 + "ecmaVersion": 2019 }, "env": { "es6": true, "node": true }, + "overrides": [{ "files": ["*.browser.js"], "env": { "browser": true } }], "rules": { + "import/order": [ + "error", + { + "groups": ["builtin", "external", "internal", "index", "sibling", "parent"], + "alphabetize": { + "order": "asc" + } + } + ], + "prettier/prettier": [ + 2, + { + "printWidth": 120, + "singleQuote": true, + "quoteProps": "as-needed", + "trailingComma": "all", + "endOfLine": "lf" + } + ], + "strict": ["error", "global"], "no-await-in-loop": "warn", "no-compare-neg-zero": "error", - "no-extra-parens": ["warn", "all", { - "nestedBinaryExpressions": false - }], "no-template-curly-in-string": "error", "no-unsafe-negation": "error", - "valid-jsdoc": ["error", { - "requireReturn": false, - "requireReturnDescription": false, - "prefer": { - "return": "returns", - "arg": "param" - }, - "preferType": { - "String": "string", - "Number": "number", - "Boolean": "boolean", - "Symbol": "symbol", - "object": "Object", - "function": "Function", - "array": "Array", - "date": "Date", - "error": "Error", - "null": "void" + "valid-jsdoc": [ + "error", + { + "requireReturn": false, + "requireReturnDescription": false, + "prefer": { + "return": "returns", + "arg": "param" + }, + "preferType": { + "String": "string", + "Number": "number", + "Boolean": "boolean", + "Symbol": "symbol", + "object": "Object", + "function": "Function", + "array": "Array", + "date": "Date", + "error": "Error", + "null": "void" + } } - }], + ], "accessor-pairs": "warn", "array-callback-return": "error", - "complexity": "warn", "consistent-return": "error", "curly": ["error", "multi-line", "consistent"], "dot-location": ["error", "property"], @@ -96,7 +117,6 @@ "func-names": "error", "func-name-matching": "error", "func-style": ["error", "declaration", { "allowArrowFunctions": true }], - "indent": ["error", 2, { "SwitchCase": 1 }], "key-spacing": "error", "keyword-spacing": "error", "max-depth": "error", @@ -108,7 +128,6 @@ "no-array-constructor": "error", "no-inline-comments": "error", "no-lonely-if": "error", - "no-mixed-operators": "error", "no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }], "no-new-object": "error", "no-spaced-func": "error", @@ -118,14 +137,20 @@ "nonblock-statement-body-position": "error", "object-curly-spacing": ["error", "always"], "operator-assignment": "error", - "operator-linebreak": ["error", "after"], "padded-blocks": ["error", "never"], "quote-props": ["error", "as-needed"], "quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }], "semi-spacing": "error", "semi": "error", "space-before-blocks": "error", - "space-before-function-paren": ["error", "never"], + "space-before-function-paren": [ + "error", + { + "anonymous": "never", + "named": "never", + "asyncArrow": "always" + } + ], "space-in-parens": "error", "space-infix-ops": "error", "space-unary-ops": "error", diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index fd6de7242..84ecd2d46 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -7,6 +7,7 @@ pull request. We use ESLint to enforce a consistent coding style, so having that is a great boon to your development process. ## Setup + To get ready to work on the codebase, please do the following: 1. Fork & clone the repository, and make sure you're on the **master** branch diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..6aa35f01b --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,11 @@ +# These are supported funding model platforms + +# github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +# patreon: # Replace with a single Patreon username +# open_collective: # Replace with a single Open Collective username +# ko_fi: # Replace with a single Ko-fi username +# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +# custom: # Replace with a single custom sponsorship URL + +github: amishshah +patreon: discordjs diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index b368eeb5c..000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,26 +0,0 @@ - - -**Please describe the problem you are having in as much detail as possible:** - - -**Include a reproducible code sample here, if possible:** -```js - -``` - -**Further details:** - -- discord.js version: -- node.js version: -- Operating system: -- Priority this issue should have – please be realistic and elaborate if possible: - - -- [ ] I have also tested the issue on latest master, commit hash: diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..caa9425b7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,39 @@ +--- + +name: Bug report +about: Report incorrect or unexpected behaviour of discord.js +title: '' +labels: 's: unverified, type: bug' +assignees: '' +--- + + +**Please describe the problem you are having in as much detail as possible:** + +**Include a reproducible code sample here, if possible:** + +```js +// Place your code here +``` + +**Further details:** + +- discord.js version: +- Node.js version: +- Operating system: +- Priority this issue should have – please be realistic and elaborate if possible: + + + +- [ ] I have also tested the issue on latest master, commit hash: diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..2584693cd --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: discord.js discord server + url: https://discord.gg/bRCvFy9 + about: Please use this Discord Server to ask questions and get support. We don't typically answer questions here and they will likely be closed and redirected to the Discord server. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..5510d5f0d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,26 @@ +--- + +name: Feature request +about: Request a feature for the core discord.js library +title: '' +labels: 'type: enhancement' +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 ideal solution** +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/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 735a552ec..3de83cd65 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,7 +1,12 @@ **Please describe the changes this PR makes and why it should be merged:** +**Status** + +- [ ] Code changes have been tested against the Discord API, or there are no code changes +- [ ] I know how to update typings and have done so, or typings don't need updating + +**Semantic versioning classification:** -**Semantic versioning classification:** - [ ] This PR changes the library's interface (methods or parameters added) - [ ] This PR includes breaking changes (methods removed or renamed, parameters moved or removed) - [ ] This PR **only** includes non-code changes, like changes to documentation, README, etc. diff --git a/.github/SUPPORT.md b/.github/SUPPORT.md new file mode 100644 index 000000000..032cbc2b9 --- /dev/null +++ b/.github/SUPPORT.md @@ -0,0 +1,7 @@ +# Seeking support? + +We're sorry, we only use this issue tracker for bugs in the library itself and feature requests for it. We are not able to provide general support or answser questions on the issue tracker. + +Should you want to ask such questions, please post in one of our support channels in our Discord server: https://discord.gg/bRCvFy9 + +Any issues that don't directly involve a bug in the library or a feature request will likely be closed and redirected to the Discord server. diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000..4deae7738 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,47 @@ +name: Deployment +on: + push: + branches: + - '*' + - '!webpack' + - '!docs' +jobs: + docs: + name: Documentation + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@master + + - name: Install Node v12 + uses: actions/setup-node@master + with: + node-version: 12 + + - name: Install dependencies + run: npm install + + - name: Build and deploy documentation + uses: discordjs/action-docs@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + webpack: + name: webpack + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@master + + - name: Install Node v12 + uses: actions/setup-node@master + with: + node-version: 12 + + - name: Install dependencies + run: npm install + + - name: Build and deploy webpack + uses: discordjs/action-webpack@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-cron.yml b/.github/workflows/test-cron.yml new file mode 100644 index 000000000..10f97e38f --- /dev/null +++ b/.github/workflows/test-cron.yml @@ -0,0 +1,58 @@ +name: Testing Cron +on: + schedule: + - cron: '0 */12 * * *' +jobs: + lint: + name: ESLint + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v1 + + - name: Install Node v12 + uses: actions/setup-node@v1 + with: + node-version: 12 + + - name: Install dependencies + run: npm install + + - name: Run ESLint + uses: icrawl/action-eslint@v1 + + typings: + name: TSLint + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v1 + + - name: Install Node v12 + uses: actions/setup-node@v1 + with: + node-version: 12 + + - name: Install dependencies + run: npm install + + - name: Run TSLint + run: npm run lint:typings + + docs: + name: Documentation + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v1 + + - name: Install Node v12 + uses: actions/setup-node@v1 + with: + node-version: 12 + + - name: Install dependencies + run: npm install + + - name: Test documentation + run: npm run docs:test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..6bdfc2967 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,56 @@ +name: Testing +on: [push, pull_request] +jobs: + lint: + name: ESLint + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Node v12 + uses: actions/setup-node@v1 + with: + node-version: 12 + + - name: Install dependencies + run: npm install + + - name: Run ESLint + uses: icrawl/action-eslint@v1 + + typings: + name: TSLint + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Node v12 + uses: actions/setup-node@v1 + with: + node-version: 12 + + - name: Install dependencies + run: npm install + + - name: Run TSLint + run: npm run lint:typings + + docs: + name: Documentation + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install Node v12 + uses: actions/setup-node@v1 + with: + node-version: 12 + + - name: Install dependencies + run: npm install + + - name: Test documentation + run: npm run docs:test diff --git a/.gitignore b/.gitignore index ffe623718..55693512d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Packages node_modules/ yarn.lock +package-lock.json # Log files logs/ diff --git a/.npmignore b/.npmignore index a480c140f..9d6674214 100644 --- a/.npmignore +++ b/.npmignore @@ -14,8 +14,6 @@ deploy/ .vscode/ docs/ -webpack/ - # NPM ignore .eslintrc.json .gitattributes diff --git a/.npmrc b/.npmrc index 579e0e4d9..43c97e719 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1 @@ -package-json=false +package-lock=false diff --git a/.tern-project b/.tern-project index 8f37bf06e..f5ce94809 100644 --- a/.tern-project +++ b/.tern-project @@ -1,12 +1,8 @@ { "ecmaVersion": 7, "libs": [], - "loadEagerly": [ - "./src/*.js" - ], - "dontLoad": [ - "node_modules/**" - ], + "loadEagerly": ["./src/*.js"], + "dontLoad": ["node_modules/**"], "plugins": { "es_modules": {}, "node": {}, @@ -15,7 +11,7 @@ "strong": true }, "webpack": { - "configPath": "./webpack.config.js", + "configPath": "./webpack.config.js" } } } diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b14042581..000000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: node_js -node_js: - - "6" - - "8" - - "10" - - "12" -cache: - directories: - - node_modules -install: npm install -script: bash ./deploy/test.sh -jobs: - include: - - stage: build - node_js: "6" - script: bash ./deploy/deploy.sh -env: - global: - - ENCRYPTION_LABEL: "af862fa96d3e" - - COMMIT_AUTHOR_EMAIL: "amishshah.2k@gmail.com" -dist: trusty -sudo: false diff --git a/LICENSE b/LICENSE index 90cf11032..9997d13f9 100644 --- a/LICENSE +++ b/LICENSE @@ -175,7 +175,7 @@ END OF TERMS AND CONDITIONS - Copyright 2017 Amish Shah + Copyright 2015 - 2020 Amish Shah Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index abb18fb65..b6d86a4ab 100644 --- a/README.md +++ b/README.md @@ -8,17 +8,31 @@ Discord server NPM version NPM downloads - Build status + Build status Dependencies + Patreon

- NPM info + npm installnfo

+## Table of contents + +- [About](#about) +- [Installation](#installation) + - [Audio engines](#audio-engines) + - [Optional packages](#optional-packages) +- [Example Usage](#example-usage) +- [Links](#links) + - [Extensions](#extensions) +- [Contributing](#contributing) +- [Help](#help) + ## About -discord.js is a powerful [node.js](https://nodejs.org) module that allows you to interact with the -[Discord API](https://discordapp.com/developers/docs/intro) very easily. + +discord.js is a powerful [Node.js](https://nodejs.org) module that allows you to easily interact with the +[Discord API](https://discordapp.com/developers/docs/intro). - Object-oriented - Predictable abstractions @@ -26,7 +40,8 @@ discord.js is a powerful [node.js](https://nodejs.org) module that allows you to - 100% coverage of the Discord API ## Installation -**Node.js 6.0.0 or newer is required.** + +**Node.js 12.0.0 or newer is required.** Ignore any warnings about unmet peer dependencies, as they're all optional. Without voice support: `npm install discord.js` @@ -34,18 +49,23 @@ With voice support ([@discordjs/opus](https://www.npmjs.com/package/@discordjs/o With voice support ([opusscript](https://www.npmjs.com/package/opusscript)): `npm install discord.js opusscript` ### Audio engines + The preferred audio engine is @discordjs/opus, as it performs significantly better than opusscript. When both are available, discord.js will automatically choose @discordjs/opus. Using opusscript is only recommended for development environments where @discordjs/opus is tough to get working. For production bots, using @discordjs/opus should be considered a necessity, especially if they're going to be running on multiple servers. ### Optional packages -- [bufferutil](https://www.npmjs.com/package/bufferutil) to greatly speed up the WebSocket when *not* using uws (`npm install bufferutil`) -- [erlpack](https://github.com/hammerandchisel/erlpack) for significantly faster WebSocket data (de)serialisation (`npm install hammerandchisel/erlpack`) + +- [zlib-sync](https://www.npmjs.com/package/zlib-sync) for WebSocket data compression and inflation (`npm install zlib-sync`) +- [erlpack](https://github.com/discordapp/erlpack) for significantly faster WebSocket data (de)serialisation (`npm install discordapp/erlpack`) - One of the following packages can be installed for faster voice packet encryption and decryption: - - [sodium](https://www.npmjs.com/package/sodium) (`npm install sodium`) - - [libsodium.js](https://www.npmjs.com/package/libsodium-wrappers) (`npm install libsodium-wrappers`) + - [sodium](https://www.npmjs.com/package/sodium) (`npm install sodium`) + - [libsodium.js](https://www.npmjs.com/package/libsodium-wrappers) (`npm install libsodium-wrappers`) +- [bufferutil](https://www.npmjs.com/package/bufferutil) for a much faster WebSocket connection (`npm install bufferutil`) +- [utf-8-validate](https://www.npmjs.com/package/utf-8-validate) in combination with `bufferutil` for much faster WebSocket processing (`npm install utf-8-validate`) ## Example usage + ```js const Discord = require('discord.js'); const client = new Discord.Client(); @@ -64,23 +84,28 @@ client.login('token'); ``` ## Links -* [Website](https://discord.js.org/) ([source](https://github.com/discordjs/website)) -* [Documentation](https://discord.js.org/#/docs) -* [Guide](https://discordjs.guide/) ([source](https://github.com/discordjs/guide)) -* [Discord.js Discord server](https://discord.gg/bRCvFy9) -* [Discord API Discord server](https://discord.gg/discord-api) -* [GitHub](https://github.com/discordjs/discord.js) -* [NPM](https://www.npmjs.com/package/discord.js) -* [Related libraries](https://discordapi.com/unofficial/libs.html) + +- [Website](https://discord.js.org/) ([source](https://github.com/discordjs/website)) +- [Documentation](https://discord.js.org/#/docs/main/master/general/welcome) +- [Guide](https://discordjs.guide/) ([source](https://github.com/discordjs/guide)) - this is still for stable + See also the [Update Guide](https://discordjs.guide/additional-info/changes-in-v12.html), including updated and removed items in the library. +- [Discord.js Discord server](https://discord.gg/bRCvFy9) +- [Discord API Discord server](https://discord.gg/discord-api) +- [GitHub](https://github.com/discordjs/discord.js) +- [NPM](https://www.npmjs.com/package/discord.js) +- [Related libraries](https://discordapi.com/unofficial/libs.html) ### Extensions -* [RPC](https://www.npmjs.com/package/discord-rpc) ([source](https://github.com/discordjs/RPC)) + +- [RPC](https://www.npmjs.com/package/discord-rpc) ([source](https://github.com/discordjs/RPC)) ## Contributing + Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the [documentation](https://discord.js.org/#/docs). See [the contribution guide](https://github.com/discordjs/discord.js/blob/master/.github/CONTRIBUTING.md) if you'd like to submit a PR. ## Help + If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official [Discord.js Server](https://discord.gg/bRCvFy9). diff --git a/browser.js b/browser.js deleted file mode 100644 index 9f9341efc..000000000 --- a/browser.js +++ /dev/null @@ -1,9 +0,0 @@ -const browser = typeof window !== 'undefined'; -const webpack = !!process.env.__DISCORD_WEBPACK__; - -const Discord = require('./'); - -module.exports = Discord; -if (browser && webpack) window.Discord = Discord; // eslint-disable-line no-undef -// eslint-disable-next-line no-console -else if (!browser) console.warn('Warning: Attempting to use browser version of Discord.js in a non-browser environment!'); diff --git a/deploy/deploy-key.enc b/deploy/deploy-key.enc deleted file mode 100644 index e03fc36d7..000000000 Binary files a/deploy/deploy-key.enc and /dev/null differ diff --git a/deploy/deploy.sh b/deploy/deploy.sh deleted file mode 100644 index d12ee608b..000000000 --- a/deploy/deploy.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash -# Adapted from https://gist.github.com/domenic/ec8b0fc8ab45f39403dd. - -set -e - -function build { - npm run docs - VERSIONED=false npm run webpack -} - -# For revert branches, do nothing -if [[ "$TRAVIS_BRANCH" == revert-* ]]; then - echo -e "\e[36m\e[1mBuild triggered for reversion branch \"${TRAVIS_BRANCH}\" - doing nothing." - exit 0 -fi - -# For PRs, do nothing -if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then - echo -e "\e[36m\e[1mBuild triggered for PR #${TRAVIS_PULL_REQUEST} to branch \"${TRAVIS_BRANCH}\" - doing nothing." - exit 0 -fi - -# Figure out the source of the build -if [ -n "$TRAVIS_TAG" ]; then - echo -e "\e[36m\e[1mBuild triggered for tag \"${TRAVIS_TAG}\"." - SOURCE=$TRAVIS_TAG - SOURCE_TYPE="tag" -else - echo -e "\e[36m\e[1mBuild triggered for branch \"${TRAVIS_BRANCH}\"." - SOURCE=$TRAVIS_BRANCH - SOURCE_TYPE="branch" -fi - -# For Node != 6, do nothing -if [ "$TRAVIS_NODE_VERSION" != "6" ]; then - echo -e "\e[36m\e[1mBuild triggered with Node v${TRAVIS_NODE_VERSION} - doing nothing." - exit 0 -fi - -build - -# Initialise some useful variables -REPO=`git config remote.origin.url` -SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:} -SHA=`git rev-parse --verify HEAD` - -# Decrypt and add the ssh key -ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key" -ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv" -ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR} -ENCRYPTED_IV=${!ENCRYPTED_IV_VAR} -openssl aes-256-cbc -K $ENCRYPTED_KEY -iv $ENCRYPTED_IV -in deploy/deploy-key.enc -out deploy-key -d -chmod 600 deploy-key -eval `ssh-agent -s` -ssh-add deploy-key - -# Checkout the repo in the target branch so we can build docs and push to it -TARGET_BRANCH="docs" -git clone $REPO out -b $TARGET_BRANCH - -# Move the generated JSON file to the newly-checked-out repo, to be committed and pushed -mv docs/docs.json out/$SOURCE.json - -# Commit and push -cd out -git add . -git config user.name "Travis CI" -git config user.email "$COMMIT_AUTHOR_EMAIL" -git commit -m "Docs build for ${SOURCE_TYPE} ${SOURCE}: ${SHA}" || true -git push $SSH_REPO $TARGET_BRANCH - -# Clean up... -cd .. -rm -rf out - -# ...then do the same once more for the webpack -TARGET_BRANCH="webpack" -git clone $REPO out -b $TARGET_BRANCH - -# Move the generated webpack over -mv webpack/discord.js out/discord.$SOURCE.js -mv webpack/discord.min.js out/discord.$SOURCE.min.js - -# Commit and push -cd out -git add . -git config user.name "Travis CI" -git config user.email "$COMMIT_AUTHOR_EMAIL" -git commit -m "Webpack build for ${SOURCE_TYPE} ${SOURCE}: ${SHA}" || true -git push $SSH_REPO $TARGET_BRANCH diff --git a/deploy/test.sh b/deploy/test.sh deleted file mode 100644 index 9e076a4c4..000000000 --- a/deploy/test.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -set -e - -function tests { - npm run lint - npm run docs:test - exit 0 -} - -# For revert branches, do nothing -if [[ "$TRAVIS_BRANCH" == revert-* ]]; then - echo -e "\e[36m\e[1mTest triggered for reversion branch \"${TRAVIS_BRANCH}\" - doing nothing." - exit 0 -fi - -# For PRs -if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then - echo -e "\e[36m\e[1mTest triggered for PR #${TRAVIS_PULL_REQUEST} to branch \"${TRAVIS_BRANCH}\" - only running tests." - tests -fi - -# Figure out the source of the test -if [ -n "$TRAVIS_TAG" ]; then - echo -e "\e[36m\e[1mTest triggered for tag \"${TRAVIS_TAG}\"." -else - echo -e "\e[36m\e[1mTest triggered for branch \"${TRAVIS_BRANCH}\"." -fi - -# For Node != 6 -if [ "$TRAVIS_NODE_VERSION" != "6" ]; then - echo -e "\e[36m\e[1mTest triggered with Node v${TRAVIS_NODE_VERSION} - only running tests." - tests -fi diff --git a/docs/examples/attachments.md b/docs/examples/attachments.md index 292f964c9..21295acc6 100644 --- a/docs/examples/attachments.md +++ b/docs/examples/attachments.md @@ -6,11 +6,11 @@ In here you'll see a few examples showing how you can send an attachment using d There are a few ways you can do this, but we'll show you the easiest. -The following examples use [Attachment](/#/docs/main/stable/class/Attachment). +The following examples use [MessageAttachment](/#/docs/main/master/class/MessageAttachment). ```js // Extract the required classes from the discord.js module -const { Client, Attachment } = require('discord.js'); +const { Client, MessageAttachment } = require('discord.js'); // Create an instance of a Discord client const client = new Client(); @@ -24,13 +24,13 @@ client.on('ready', () => { }); client.on('message', message => { - // If the message is '!rip' - if (message.content === '!rip') { - // Create the attachment using Attachment - const attachment = new Attachment('https://i.imgur.com/w3duR07.png'); - // Send the attachment in the message channel - message.channel.send(attachment); - } + // If the message is '!rip' + if (message.content === '!rip') { + // Create the attachment using MessageAttachment + const attachment = new MessageAttachment('https://i.imgur.com/w3duR07.png'); + // Send the attachment in the message channel + message.channel.send(attachment); + } }); // Log our bot in using the token from https://discordapp.com/developers/applications/me @@ -41,11 +41,11 @@ And here is the result: ![Image showing the result](/static/attachment-example1.png) -But what if you want to send an attachment with a message content? Fear not, for it is easy to do that too! We'll recommend reading [the TextChannel's "send" function documentation](/#/docs/main/stable/class/TextChannel?scrollTo=send) to see what other options are available. +But what if you want to send an attachment with a message content? Fear not, for it is easy to do that too! We'll recommend reading [the TextChannel's "send" function documentation](/#/docs/main/master/class/TextChannel?scrollTo=send) to see what other options are available. ```js // Extract the required classes from the discord.js module -const { Client, Attachment } = require('discord.js'); +const { Client, MessageAttachment } = require('discord.js'); // Create an instance of a Discord client const client = new Client(); @@ -59,13 +59,13 @@ client.on('ready', () => { }); client.on('message', message => { - // If the message is '!rip' - if (message.content === '!rip') { - // Create the attachment using Attachment - const attachment = new Attachment('https://i.imgur.com/w3duR07.png'); - // Send the attachment in the message channel with a content - message.channel.send(`${message.author},`, attachment); - } + // If the message is '!rip' + if (message.content === '!rip') { + // Create the attachment using MessageAttachment + const attachment = new MessageAttachment('https://i.imgur.com/w3duR07.png'); + // Send the attachment in the message channel with a content + message.channel.send(`${message.author},`, attachment); + } }); // Log our bot in using the token from https://discordapp.com/developers/applications/me @@ -78,11 +78,11 @@ And here's the result of this one: ## Sending a local file or buffer -Sending a local file isn't hard either! We'll be using [Attachment](/#/docs/main/stable/class/Attachment) for these examples too. +Sending a local file isn't hard either! We'll be using [MessageAttachment](/#/docs/main/master/class/MessageAttachment) for these examples too. ```js // Extract the required classes from the discord.js module -const { Client, Attachment } = require('discord.js'); +const { Client, MessageAttachment } = require('discord.js'); // Create an instance of a Discord client const client = new Client(); @@ -96,13 +96,13 @@ client.on('ready', () => { }); client.on('message', message => { - // If the message is '!rip' - if (message.content === '!rip') { - // Create the attachment using Attachment - const attachment = new Attachment('./rip.png'); - // Send the attachment in the message channel with a content - message.channel.send(`${message.author},`, attachment); - } + // If the message is '!rip' + if (message.content === '!rip') { + // Create the attachment using MessageAttachment + const attachment = new MessageAttachment('./rip.png'); + // Send the attachment in the message channel with a content + message.channel.send(`${message.author},`, attachment); + } }); // Log our bot in using the token from https://discordapp.com/developers/applications/me @@ -120,7 +120,7 @@ You can use any buffer you want, and send it. Just make sure to overwrite the fi ```js // Extract the required classes from the discord.js module -const { Client, Attachment } = require('discord.js'); +const { Client, MessageAttachment } = require('discord.js'); // Import the native fs module const fs = require('fs'); @@ -137,21 +137,21 @@ client.on('ready', () => { }); client.on('message', message => { - // If the message is '!memes' - if (message.content === '!memes') { - // Get the buffer from the 'memes.txt', assuming that the file exists - const buffer = fs.readFileSync('./memes.txt'); + // If the message is '!memes' + if (message.content === '!memes') { + // Get the buffer from the 'memes.txt', assuming that the file exists + const buffer = fs.readFileSync('./memes.txt'); - /** - * Create the attachment using Attachment, - * overwritting the default file name to 'memes.txt' - * Read more about it over at - * http://discord.js.org/#/docs/main/stable/class/Attachment - */ - const attachment = new Attachment(buffer, 'memes.txt'); - // Send the attachment in the message channel with a content - message.channel.send(`${message.author}, here are your memes!`, attachment); - } + /** + * Create the attachment using MessageAttachment, + * overwritting the default file name to 'memes.txt' + * Read more about it over at + * http://discord.js.org/#/docs/main/master/class/MessageAttachment + */ + const attachment = new MessageAttachment(buffer, 'memes.txt'); + // Send the attachment in the message channel with a content + message.channel.send(`${message.author}, here are your memes!`, attachment); + } }); // Log our bot in using the token from https://discordapp.com/developers/applications/me diff --git a/docs/examples/avatars.js b/docs/examples/avatars.js index c77020efd..57972f57e 100644 --- a/docs/examples/avatars.js +++ b/docs/examples/avatars.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Send a user a link to their avatar */ @@ -21,7 +23,7 @@ client.on('message', message => { // If the message is "what is my avatar" if (message.content === 'what is my avatar') { // Send the user's avatar URL - message.reply(message.author.avatarURL); + message.reply(message.author.displayAvatarURL()); } }); diff --git a/docs/examples/embed.js b/docs/examples/embed.js index 66e0fcf10..a03921271 100644 --- a/docs/examples/embed.js +++ b/docs/examples/embed.js @@ -1,9 +1,11 @@ +'use strict'; + /** * An example of how you can send embeds */ // Extract the required classes from the discord.js module -const { Client, RichEmbed } = require('discord.js'); +const { Client, MessageEmbed } = require('discord.js'); // Create an instance of a Discord client const client = new Client(); @@ -21,12 +23,12 @@ client.on('message', message => { if (message.content === 'how to embed') { // We can create embeds using the MessageEmbed constructor // Read more about all that you can do with the constructor - // over at https://discord.js.org/#/docs/main/stable/class/RichEmbed - const embed = new RichEmbed() + // over at https://discord.js.org/#/docs/main/master/class/MessageEmbed + const embed = new MessageEmbed() // Set the title of the field .setTitle('A slick little embed') // Set the color of the embed - .setColor(0xFF0000) + .setColor(0xff0000) // Set the main content of the embed .setDescription('Hello, this is a slick embed!'); // Send the embed to the same channel as the message diff --git a/docs/examples/greeting.js b/docs/examples/greeting.js index 8fc1dfada..f61b1c5fe 100644 --- a/docs/examples/greeting.js +++ b/docs/examples/greeting.js @@ -1,3 +1,5 @@ +'use strict'; + /** * A bot that welcomes new guild members when they join */ @@ -19,7 +21,7 @@ client.on('ready', () => { // Create an event listener for new guild members client.on('guildMemberAdd', member => { // Send the message to a designated channel on a server: - const channel = member.guild.channels.find(ch => ch.name === 'member-log'); + const channel = member.guild.channels.cache.find(ch => ch.name === 'member-log'); // Do nothing if the channel wasn't found on this server if (!channel) return; // Send the message, mentioning the member diff --git a/docs/examples/moderation.md b/docs/examples/moderation.md index 959f404a1..36481a462 100644 --- a/docs/examples/moderation.md +++ b/docs/examples/moderation.md @@ -4,7 +4,7 @@ In here, you'll see some basic examples for kicking and banning a member. ## Kicking a member -Let's say you have a member that you'd like to kick. Here is an example of how you *can* do it. +Let's say you have a member that you'd like to kick. Here is an example of how you _can_ do it. ```js // Import the discord.js module @@ -28,7 +28,7 @@ client.on('message', message => { // If the message content starts with "!kick" if (message.content.startsWith('!kick')) { // Assuming we mention someone in the message, this will return the user - // Read more about mentions over at https://discord.js.org/#/docs/main/stable/class/MessageMentions + // Read more about mentions over at https://discord.js.org/#/docs/main/master/class/MessageMentions const user = message.mentions.users.first(); // If we have a user mentioned if (user) { @@ -41,24 +41,27 @@ client.on('message', message => { * Make sure you run this on a member, not a user! * There are big differences between a user and a member */ - member.kick('Optional reason that will display in the audit logs').then(() => { - // We let the message author know we were able to kick the person - message.reply(`Successfully kicked ${user.tag}`); - }).catch(err => { - // An error happened - // This is generally due to the bot not being able to kick the member, - // either due to missing permissions or role hierarchy - message.reply('I was unable to kick the member'); - // Log the error - console.error(err); - }); + member + .kick('Optional reason that will display in the audit logs') + .then(() => { + // We let the message author know we were able to kick the person + message.reply(`Successfully kicked ${user.tag}`); + }) + .catch(err => { + // An error happened + // This is generally due to the bot not being able to kick the member, + // either due to missing permissions or role hierarchy + message.reply('I was unable to kick the member'); + // Log the error + console.error(err); + }); } else { // The mentioned user isn't in this guild - message.reply('That user isn\'t in this guild!'); + message.reply("That user isn't in this guild!"); } - // Otherwise, if no user was mentioned + // Otherwise, if no user was mentioned } else { - message.reply('You didn\'t mention the user to kick!'); + message.reply("You didn't mention the user to kick!"); } } }); @@ -97,7 +100,7 @@ client.on('message', message => { // if the message content starts with "!ban" if (message.content.startsWith('!ban')) { // Assuming we mention someone in the message, this will return the user - // Read more about mentions over at https://discord.js.org/#/docs/main/stable/class/MessageMentions + // Read more about mentions over at https://discord.js.org/#/docs/main/master/class/MessageMentions const user = message.mentions.users.first(); // If we have a user mentioned if (user) { @@ -110,28 +113,31 @@ client.on('message', message => { * Make sure you run this on a member, not a user! * There are big differences between a user and a member * Read more about what ban options there are over at - * https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=ban + * https://discord.js.org/#/docs/main/master/class/GuildMember?scrollTo=ban */ - member.ban({ - reason: 'They were bad!', - }).then(() => { - // We let the message author know we were able to ban the person - message.reply(`Successfully banned ${user.tag}`); - }).catch(err => { - // An error happened - // This is generally due to the bot not being able to ban the member, - // either due to missing permissions or role hierarchy - message.reply('I was unable to ban the member'); - // Log the error - console.error(err); - }); + member + .ban({ + reason: 'They were bad!', + }) + .then(() => { + // We let the message author know we were able to ban the person + message.reply(`Successfully banned ${user.tag}`); + }) + .catch(err => { + // An error happened + // This is generally due to the bot not being able to ban the member, + // either due to missing permissions or role hierarchy + message.reply('I was unable to ban the member'); + // Log the error + console.error(err); + }); } else { // The mentioned user isn't in this guild - message.reply('That user isn\'t in this guild!'); + message.reply("That user isn't in this guild!"); } } else { - // Otherwise, if no user was mentioned - message.reply('You didn\'t mention the user to ban!'); + // Otherwise, if no user was mentioned + message.reply("You didn't mention the user to ban!"); } } }); diff --git a/docs/examples/ping.js b/docs/examples/ping.js index 1b14332de..55888e888 100644 --- a/docs/examples/ping.js +++ b/docs/examples/ping.js @@ -1,3 +1,5 @@ +'use strict'; + /** * A ping pong bot, whenever you send "ping", it replies "pong". */ diff --git a/docs/examples/webhook.js b/docs/examples/webhook.js index 77f58c448..451ac58b3 100644 --- a/docs/examples/webhook.js +++ b/docs/examples/webhook.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Send a message using a webhook */ diff --git a/docs/general/faq.md b/docs/general/faq.md index 69864395b..e265f81c1 100644 --- a/docs/general/faq.md +++ b/docs/general/faq.md @@ -1,23 +1,30 @@ # Frequently Asked Questions -These are just questions that get asked frequently, that usually have a common resolution. -If you have issues not listed here, please ask in the [official Discord server](https://discord.gg/bRCvFy9). -Always make sure to read the documentation. + +These questions are some of the most frequently asked. ## No matter what, I get `SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode`‽ -Update to Node.js 6.0.0 or newer. + +Update to Node.js 12.0.0 or newer. ## How do I get voice working? + - Install FFMPEG. - Install either the `@discordjs/opus` package or the `opusscript` package. @discordjs/opus is greatly preferred, due to it having significantly better performance. ## How do I install FFMPEG? + - **npm:** `npm install ffmpeg-binaries` - **Ubuntu 16.04:** `sudo apt install ffmpeg` - **Ubuntu 14.04:** `sudo apt-get install libav-tools` - **Windows:** `npm install ffmpeg-binaries` or see the [FFMPEG section of AoDude's guide](https://github.com/bdistin/OhGodMusicBot/blob/master/README.md#download-ffmpeg). ## How do I set up @discordjs/opus? + - **Ubuntu:** Simply run `npm install @discordjs/opus`, and it's done. Congrats! - **Windows:** Run `npm install --global --production windows-build-tools` in an admin command prompt or PowerShell. Then, running `npm install @discordjs/opus` in your bot's directory should successfully build it. Woo! + +Other questions can be found at the [official Discord.js guide](https://discordjs.guide/popular-topics/common-questions.html) +If you have issues not listed here or on the guide, feel free to ask in the [official Discord.js server](https://discord.gg/bRCvFy9). +Always make sure to read the [documentation](https://discord.js.org/#/docs/main/stable/general/welcome). diff --git a/docs/general/updating.md b/docs/general/updating.md index 70008c1e8..85fee04e8 100644 --- a/docs/general/updating.md +++ b/docs/general/updating.md @@ -1,92 +1,93 @@ -# Version 11.6.0 -v11.6.0 backports new features from the in-development v12, and fixes bugs in the v11.5.x releases. -See [the changelog](https://github.com/discordjs/discord.js/releases/tag/11.6.0) for a full list of changes, including information about deprecations. +# Version 12.0.0 -# Version 11.5.0 -v11.5.0 backports new features from the in-development v12, and fixes bugs in the v11.4.x releases. -See [the changelog](https://github.com/discordjs/discord.js/releases/tag/11.5.0) for a full list of changes, including information about deprecations. - -# Version 11.4.0 -v11.4.0 backports many new features such as Rich Presence and bugfixes from v11.3.0. -See [the changelog](https://github.com/discordjs/discord.js/releases/tag/11.4.0) for a full list of changes, including information about deprecations. - -# Version 11.3.0 -v11.3.0 backports many new features and bug fixes from the in-development v12. -See [the changelog](https://github.com/discordjs/discord.js/releases/tag/11.3.0) for a full list of changes, including information about deprecations. - -# Version 11.2.0 -v11.2.0 fixes a lot of bugs we encountered along the 11.1.0 release, as well as support for new features such as Message Attachments and UserGuildSettings. -See [the changelog](https://github.com/discordjs/discord.js/releases/tag/11.2.0) for a full list of changes, including information about deprecations. +v12.0.0 contains many new and improved features, optimisations, and bug fixes. +See [the changelog](https://github.com/discordjs/discord.js/releases/tag/12.0.0) for a full list of changes. +You can also visit [the guide](https://discordjs.guide/additional-info/changes-in-v12.html) for help with updating your v11 code to v12. # Version 11.1.0 + v11.1.0 features improved voice and gateway stability, as well as support for new features such as audit logs and searching for messages. See [the changelog](https://github.com/discordjs/discord.js/releases/tag/11.1.0) for a full list of changes, including information about deprecations. # Version 11 + Version 11 contains loads of new and improved features, optimisations, and bug fixes. See [the changelog](https://github.com/discordjs/discord.js/releases/tag/11.0.0) for a full list of changes. ## Significant additions -* Message Reactions and Embeds (rich text) -* Support for uws and erlpack for better performance -* OAuthApplication support -* Web distributions + +- Message Reactions and Embeds (rich text) +- Support for uws and erlpack for better performance +- OAuthApplication support +- Web distributions ## Breaking changes + ### Client.login() no longer supports logging in with email + password + Logging in with an email and password has always been heavily discouraged since the advent of proper token support, but in v11 we have made the decision to completely remove the functionality, since Hammer & Chisel have [officially stated](https://github.com/hammerandchisel/discord-api-docs/issues/69#issuecomment-223886862) it simply shouldn't be done. User accounts can still log in with tokens just like bot accounts. To obtain the token for a user account, you can log in to Discord with that account, and use Ctrl + Shift + I to open the developer tools. In the console tab, evaluating `localStorage.token` will give you the token for that account. ### ClientUser.setEmail()/setPassword() now require the current password, as well as setUsername() on user accounts + Since you can no longer log in with email and password, you must provide the current account password to the `setEmail()`, `setPassword()`, and `setUsername()` methods for user accounts (self-bots). ### Removed TextBasedChannel.sendTTSMessage() + This method was deemed to be an entirely pointless shortcut that virtually nobody even used. The same results can be achieved by passing options to `send()` or `sendMessage()`. Example: + ```js channel.send('Hi there', { tts: true }); ``` ### Using Collection.find()/exists() with IDs will throw an error + This is simply to help prevent a common mistake that is made frequently. To find something or check its existence using an ID, you should use `.get()` and `.has()` which are part of the [ES6 Map class](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Map), which Collection is an extension of. # Version 10 + Version 10's non-BC changes focus on cleaning up some inconsistencies that exist in previous versions. Upgrading from v9 should be quick and painless. ## Client options + All client options have been converted to camelCase rather than snake_case, and `max_message_cache` was renamed to `messageCacheMaxSize`. v9 code example: + ```js const client = new Discord.Client({ disable_everyone: true, max_message_cache: 500, message_cache_lifetime: 120, - message_sweep_interval: 60 + message_sweep_interval: 60, }); ``` v10 code example: + ```js const client = new Discord.Client({ disableEveryone: true, messageCacheMaxSize: 500, messageCacheLifetime: 120, - messageSweepInterval: 60 + messageSweepInterval: 60, }); ``` ## Presences + Presences have been completely restructured. Previous versions of discord.js assumed that users had the same presence amongst all guilds - with the introduction of sharding, however, this is no longer the case. v9 discord.js code may look something like this: + ```js User.status; // the status of the user User.game; // the game that the user is playing @@ -101,6 +102,7 @@ Additionally, the introduction of the Presence class keeps all of the presence d A user may have an entirely different presence between two different guilds.** v10 code: + ```js MemberOrUser.presence.status; // the status of the member or user MemberOrUser.presence.game; // the game that the member or user is playing @@ -110,41 +112,46 @@ ClientUser.setPresence(fullPresence); // status and game combined ``` ## Voice + Voice has been rewritten internally, but in a backwards-compatible manner. There is only one breaking change here; the `disconnected` event was renamed to `disconnect`. Several more events have been made available to a VoiceConnection, so see the documentation. ## Events + Many events have been renamed or had their arguments change. ### Client events -| Version 9 | Version 10 | -|------------------------------------------------------|-----------------------------------------------| -| guildMemberAdd(guild, member) | guildMemberAdd(member) | -| guildMemberAvailable(guild, member) | guildMemberAvailable(member) | -| guildMemberRemove(guild, member) | guildMemberRemove(member) | -| guildMembersChunk(guild, members) | guildMembersChunk(members) | -| guildMemberUpdate(guild, oldMember, newMember) | guildMemberUpdate(oldMember, newMember) | -| guildRoleCreate(guild, role) | roleCreate(role) | -| guildRoleDelete(guild, role) | roleDelete(role) | -| guildRoleUpdate(guild, oldRole, newRole) | roleUpdate(oldRole, newRole) | + +| Version 9 | Version 10 | +| ---------------------------------------------- | --------------------------------------- | +| guildMemberAdd(guild, member) | guildMemberAdd(member) | +| guildMemberAvailable(guild, member) | guildMemberAvailable(member) | +| guildMemberRemove(guild, member) | guildMemberRemove(member) | +| guildMembersChunk(guild, members) | guildMembersChunk(members) | +| guildMemberUpdate(guild, oldMember, newMember) | guildMemberUpdate(oldMember, newMember) | +| guildRoleCreate(guild, role) | roleCreate(role) | +| guildRoleDelete(guild, role) | roleDelete(role) | +| guildRoleUpdate(guild, oldRole, newRole) | roleUpdate(oldRole, newRole) | The guild parameter that has been dropped from the guild-related events can still be derived using `member.guild` or `role.guild`. ### VoiceConnection events + | Version 9 | Version 10 | -|--------------|------------| +| ------------ | ---------- | | disconnected | disconnect | ## Dates and timestamps + All dates/timestamps on the structures have been refactored to have a consistent naming scheme and availability. -All of them are named similarly to this: -**Date:** `Message.createdAt` -**Timestamp:** `Message.createdTimestamp` +All of them are named similarly to this: +**Date:** `Message.createdAt` +**Timestamp:** `Message.createdTimestamp` See the docs for each structure to see which date/timestamps are available on them. - # Version 9 + The version 9 (v9) rewrite takes a much more object-oriented approach than previous versions, which allows your code to be much more readable and manageable. It's been rebuilt from the ground up and should be much more stable, fixing caching issues that affected @@ -157,19 +164,22 @@ into other more relevant classes where they belong. Because of this, you will need to convert most of your calls over to the new methods. Here are a few examples of methods that have changed: -* `Client.sendMessage(channel, message)` ==> `TextChannel.sendMessage(message)` - * `Client.sendMessage(user, message)` ==> `User.sendMessage(message)` -* `Client.updateMessage(message, "New content")` ==> `Message.edit("New Content")` -* `Client.getChannelLogs(channel, limit)` ==> `TextChannel.fetchMessages({options})` -* `Server.detailsOfUser(User)` ==> `Server.members.get(User).properties` (retrieving a member gives a GuildMember object) -* `Client.joinVoiceChannel(voicechannel)` => `VoiceChannel.join()` + +- `Client.sendMessage(channel, message)` ==> `TextChannel.sendMessage(message)` + - `Client.sendMessage(user, message)` ==> `User.sendMessage(message)` +- `Client.updateMessage(message, "New content")` ==> `Message.edit("New Content")` +- `Client.getChannelLogs(channel, limit)` ==> `TextChannel.fetchMessages({options})` +- `Server.detailsOfUser(User)` ==> `Server.members.get(User).properties` (retrieving a member gives a GuildMember object) +- `Client.joinVoiceChannel(voicechannel)` => `VoiceChannel.join()` A couple more important details: -* `Client.loginWithToken("token")` ==> `client.login("token")` -* `Client.servers.length` ==> `client.guilds.size` (all instances of `server` are now `guild`) + +- `Client.loginWithToken("token")` ==> `client.login("token")` +- `Client.servers.length` ==> `client.guilds.size` (all instances of `server` are now `guild`) ## No more callbacks! -Version 9 eschews callbacks in favour of Promises. This means all code relying on callbacks must be changed. + +Version 9 eschews callbacks in favour of Promises. This means all code relying on callbacks must be changed. For example, the following code: ```js @@ -179,7 +189,7 @@ client.getChannelLogs(channel, 100, function(messages) { ``` ```js -channel.fetchMessages({limit: 100}).then(messages => { +channel.fetchMessages({ limit: 100 }).then(messages => { console.log(`${messages.size} messages found`); }); ``` diff --git a/docs/general/welcome.md b/docs/general/welcome.md index 3ffb66026..a83717e62 100644 --- a/docs/general/welcome.md +++ b/docs/general/welcome.md @@ -1,7 +1,7 @@

- discord.js +


@@ -18,15 +18,13 @@

# Welcome! -Welcome to the discord.js v11.6 documentation. -The v11.6 release contains bugfixes from v11.5 and backports features from the in-development v12. -v12 is still very much a work-in-progress, as we're aiming to make it the best it can possibly be before releasing. -If you are fond of living life on the bleeding-edge, check out the master branch. +Welcome to the discord.js v12 documentation. ## About -discord.js is a powerful [Node.js](https://nodejs.org) module that allows you to interact with the -[Discord API](https://discordapp.com/developers/docs/intro) very easily. + +discord.js is a powerful [Node.js](https://nodejs.org) module that allows you to easily interact with the +[Discord API](https://discordapp.com/developers/docs/intro). - Object-oriented - Predictable abstractions @@ -34,7 +32,8 @@ discord.js is a powerful [Node.js](https://nodejs.org) module that allows you to - 100% coverage of the Discord API ## Installation -**Node.js 6.0.0 or newer is required.** + +**Node.js 12.0.0 or newer is required.** Ignore any warnings about unmet peer dependencies, as they're all optional. Without voice support: `npm install discord.js` @@ -42,19 +41,23 @@ With voice support ([@discordjs/opus](https://www.npmjs.com/package/@discordjs/o With voice support ([opusscript](https://www.npmjs.com/package/opusscript)): `npm install discord.js opusscript` ### Audio engines + The preferred audio engine is @discordjs/opus, as it performs significantly better than opusscript. When both are available, discord.js will automatically choose @discordjs/opus. Using opusscript is only recommended for development environments where @discordjs/opus is tough to get working. For production bots, using @discordjs/opus should be considered a necessity, especially if they're going to be running on multiple servers. ### Optional packages -- [bufferutil](https://www.npmjs.com/package/bufferutil) to greatly speed up the WebSocket when *not* using uws (`npm install bufferutil`) -- [erlpack](https://github.com/hammerandchisel/erlpack) for significantly faster WebSocket data (de)serialisation (`npm install hammerandchisel/erlpack`) + +- [zlib-sync](https://www.npmjs.com/package/zlib-sync) for WebSocket data compression and inflation (`npm install zlib-sync`) +- [erlpack](https://github.com/discordapp/erlpack) for significantly faster WebSocket data (de)serialisation (`npm install discordapp/erlpack`) - One of the following packages can be installed for faster voice packet encryption and decryption: - - [sodium](https://www.npmjs.com/package/sodium) (`npm install sodium`) - - [libsodium.js](https://www.npmjs.com/package/libsodium-wrappers) (`npm install libsodium-wrappers`) -- [uws](https://www.npmjs.com/package/@discordjs/uws) for a much faster WebSocket connection (`npm install @discordjs/uws`) + - [sodium](https://www.npmjs.com/package/sodium) (`npm install sodium`) + - [libsodium.js](https://www.npmjs.com/package/libsodium-wrappers) (`npm install libsodium-wrappers`) +- [bufferutil](https://www.npmjs.com/package/bufferutil) for a much faster WebSocket connection (`npm install bufferutil`) +- [utf-8-validate](https://www.npmjs.com/package/utf-8-validate) in combination with `bufferutil` for much faster WebSocket processing (`npm install utf-8-validate`) ## Example usage + ```js const Discord = require('discord.js'); const client = new Discord.Client(); @@ -73,23 +76,28 @@ client.login('token'); ``` ## Links -* [Website](https://discord.js.org/) ([source](https://github.com/discordjs/website)) -* [Documentation](https://discord.js.org/#/docs) -* [Guide](https://discordjs.guide/) ([source](https://github.com/discordjs/guide)) -* [Discord.js Discord server](https://discord.gg/bRCvFy9) -* [Discord API Discord server](https://discord.gg/discord-api) -* [GitHub](https://github.com/discordjs/discord.js) -* [NPM](https://www.npmjs.com/package/discord.js) -* [Related libraries](https://discordapi.com/unofficial/libs.html) + +- [Website](https://discord.js.org/) ([source](https://github.com/discordjs/website)) +- [Documentation](https://discord.js.org/#/docs/main/master/general/welcome) +- [Guide](https://discordjs.guide/) ([source](https://github.com/discordjs/guide)) - this is still for stable + See also the WIP [Update Guide](https://discordjs.guide/additional-info/changes-in-v12.html) also including updated and removed items in the library. +- [Discord.js Discord server](https://discord.gg/bRCvFy9) +- [Discord API Discord server](https://discord.gg/discord-api) +- [GitHub](https://github.com/discordjs/discord.js) +- [NPM](https://www.npmjs.com/package/discord.js) +- [Related libraries](https://discordapi.com/unofficial/libs.html) ### Extensions -* [RPC](https://www.npmjs.com/package/discord-rpc) ([source](https://github.com/discordjs/RPC)) + +- [RPC](https://www.npmjs.com/package/discord-rpc) ([source](https://github.com/discordjs/RPC)) ## Contributing + Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the [documentation](https://discord.js.org/#/docs). See [the contribution guide](https://github.com/discordjs/discord.js/blob/master/.github/CONTRIBUTING.md) if you'd like to submit a PR. ## Help + If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official [Discord.js Server](https://discord.gg/bRCvFy9). diff --git a/docs/index.yml b/docs/index.yml index 7c5b3b280..175780574 100644 --- a/docs/index.yml +++ b/docs/index.yml @@ -12,6 +12,8 @@ path: voice.md - name: Web builds path: web.md + - name: Partials + path: partials.md - name: Examples files: - name: Ping diff --git a/docs/topics/partials.md b/docs/topics/partials.md new file mode 100644 index 000000000..4b58f4356 --- /dev/null +++ b/docs/topics/partials.md @@ -0,0 +1,65 @@ +# Partials + +Partials allow you to receive events that contain uncached instances, providing structures that contain very minimal +data. For example, if you were to receive a `messageDelete` event with an uncached message, normally Discord.js would +discard the event. With partials, you're able to receive the event, with a Message object that contains just an ID. + +## Opting in + +Partials are opt-in, and you can enable them in the Client options by specifying [PartialTypes](/#/docs/main/master/typedef/PartialType): + +```js +// Accept partial messages, DM channels, and reactions when emitting events +new Client({ partials: ['MESSAGE', 'CHANNEL', 'REACTION'] }); +``` + +## Usage & warnings + +The only guaranteed data a partial structure can store is its ID. All other properties/methods should be +considered invalid/defunct while accessing a partial structure. + +After opting-in with the above, you begin to allow partial messages and channels in your caches, so it's important +to check whether they're safe to access whenever you encounter them, whether it be in events or through normal cache +usage. + +All instance of structures that you opted-in for will have a `partial` property. As you'd expect, this value is `true` +when the instance is partial. Partial structures are only guaranteed to contain an ID, any other properties and methods +no longer carry their normal type guarantees. + +This means you have to take time to consider possible parts of your program that might need checks put in place to +prevent accessing partial data: + +```js +client.on('messageDelete', message => { + console.log(`${message.id} was deleted!`); + // Partial messages do not contain any content so skip them + if (!message.partial) { + console.log(`It had content: "${message.content}"`); + } +}); + +// You can also try to upgrade partials to full instances: +client.on('messageReactionAdd', async (reaction, user) => { + // If a message gains a reaction and it is uncached, fetch and cache the message + // You should account for any errors while fetching, it could return API errors if the resource is missing + if (reaction.message.partial) await reaction.message.fetch(); + // Now the message has been cached and is fully available: + console.log(`${reaction.message.author}'s message "${reaction.message.content}" gained a reaction!`); + // Fetches and caches the reaction itself, updating resources that were possibly defunct. + if (reaction.partial) await reaction.fetch(); + // Now the reaction is fully available and the properties will be reflected accurately: + console.log(`${reaction.count} user(s) have given the same reaction to this message!`); +}); +``` + +If a message is deleted and both the message and channel are uncached, you must enable both 'MESSAGE' and +'CHANNEL' in the client options to receive the messageDelete event. + +## Why? + +This allows developers to listen to events that contain uncached data, which is useful if you're running a moderation +bot or any bot that relies on still receiving updates to resources you don't have cached -- message reactions are a +good example. + +Currently, the only type of channel that can be uncached is a DM channel, there is no reason why guild channels should +not be cached. diff --git a/docs/topics/voice.md b/docs/topics/voice.md index 7e9faf056..cb20dd5cc 100644 --- a/docs/topics/voice.md +++ b/docs/topics/voice.md @@ -1,20 +1,23 @@ # Introduction to Voice + Voice in discord.js can be used for many things, such as music bots, recording or relaying audio. In discord.js, you can use voice by connecting to a `VoiceChannel` to obtain a `VoiceConnection`, where you can start streaming and receiving audio. To get started, make sure you have: -* FFmpeg - `npm install ffmpeg-binaries` -* an opus encoder, choose one from below: - * `npm install opusscript` - * `npm install @discordjs/opus` -* a good network connection + +- FFmpeg - `npm install ffmpeg-static` +- an opus encoder, choose one from below: + - `npm install @discordjs/opus` (better performance) + - `npm install opusscript` +- a good network connection The preferred opus engine is @discordjs/opus, as it performs significantly better than opusscript. When both are available, discord.js will automatically choose @discordjs/opus. Using opusscript is only recommended for development environments where @discordjs/opus is tough to get working. For production bots, using @discordjs/opus should be considered a necessity, especially if they're going to be running on multiple servers. ## Joining a voice channel + The example below reacts to a message and joins the sender's voice channel, catching any errors. This is important as it allows us to obtain a `VoiceConnection` that we can start to stream audio with. @@ -24,19 +27,15 @@ const client = new Discord.Client(); client.login('token here'); -client.on('message', message => { +client.on('message', async message => { // Voice only works in guilds, if the message does not come from a guild, // we ignore it if (!message.guild) return; if (message.content === '/join') { // Only try to join the sender's voice channel if they are in one themselves - if (message.member.voiceChannel) { - message.member.voiceChannel.join() - .then(connection => { // Connection is an instance of VoiceConnection - message.reply('I have successfully connected to the channel!'); - }) - .catch(console.log); + if (message.member.voice.channel) { + const connection = await message.member.voice.channel.join(); } else { message.reply('You need to join a voice channel first!'); } @@ -45,69 +44,97 @@ client.on('message', message => { ``` ## Streaming to a Voice Channel + In the previous example, we looked at how to join a voice channel in order to obtain a `VoiceConnection`. Now that we -have obtained a voice connection, we can start streaming audio to it. The following example shows how to stream an mp3 -file: +have obtained a voice connection, we can start streaming audio to it. + +### Introduction to playing on voice connections + +The most basic example of playing audio over a connection would be playing a local file: -**Playing a file:** ```js -// To play a file, we need to give an absolute path to it -const dispatcher = connection.playFile('C:/Users/Discord/Desktop/myfile.mp3'); +const dispatcher = connection.play('/home/discord/audio.mp3'); ``` -Your file doesn't have to be just an mp3; ffmpeg can convert videos and audios of many formats. - -The `dispatcher` variable is an instance of a `StreamDispatcher`, which manages streaming a specific resource to a voice -channel. We can do many things with the dispatcher, such as finding out when the stream ends or changing the volume: +The `dispatcher` in this case is a `StreamDispatcher` - here you can control the volume and playback of the stream: ```js -dispatcher.on('end', () => { - // The song has finished +dispatcher.pause(); +dispatcher.resume(); + +dispatcher.setVolume(0.5); // half the volume + +dispatcher.on('finish', () => { + console.log('Finished playing!'); }); -dispatcher.on('error', e => { - // Catch any errors that may arise - console.log(e); +dispatcher.destroy(); // end the stream +``` + +We can also pass in options when we first play the stream: + +```js +const dispatcher = connection.play('/home/discord/audio.mp3', { + volume: 0.5, +}); +``` + +### What can I play? + +Discord.js allows you to play a lot of things: + +```js +// ReadableStreams, in this example YouTube audio +const ytdl = require('ytdl-core'); +connection.play(ytdl('https://www.youtube.com/watch?v=ZlAU_w7-Xp8', { filter: 'audioonly' })); + +// Files on the internet +connection.play('http://www.sample-videos.com/audio/mp3/wave.mp3'); + +// Local files +connection.play('/home/discord/audio.mp3'); +``` + +New to v12 is the ability to play OggOpus and WebmOpus streams with much better performance by skipping out Ffmpeg. Note this comes at the cost of no longer having volume control over the stream: + +```js +connection.play(fs.createReadStream('./media.webm'), { + type: 'webm/opus', }); -dispatcher.setVolume(0.5); // Set the volume to 50% -dispatcher.setVolume(1); // Set the volume back to 100% - -console.log(dispatcher.time); // The time in milliseconds that the stream dispatcher has been playing for - -dispatcher.pause(); // Pause the stream -dispatcher.resume(); // Carry on playing - -dispatcher.end(); // End the dispatcher, emits 'end' event +connection.play(fs.createReadStream('./media.ogg'), { + type: 'ogg/opus', +}); ``` -If you have an existing [ReadableStream](https://nodejs.org/api/stream.html#stream_readable_streams), -this can also be used: +Make sure to consult the documentation for a full list of what you can play - there's too much to cover here! -**Playing a ReadableStream:** -```js -connection.playStream(myReadableStream); +## Voice Broadcasts -// If you don't want to use absolute paths, you can use -// fs.createReadStream to circumvent it - -const fs = require('fs'); -const stream = fs.createReadStream('./test.mp3'); -connection.playStream(stream); -``` - -It's important to note that creating a readable stream to a file is less efficient than simply using `connection.playFile()`. - -**Playing anything else:** - -For anything else, such as a URL to a file, you can use `connection.playArbitraryInput()`. You should consult the [ffmpeg protocol documentation](https://ffmpeg.org/ffmpeg-protocols.html) to see what you can use this for. +A voice broadcast is very useful for "radio" bots, that play the same audio across multiple channels. It means audio is only transcoded once, and is much better on performance. ```js -// Play an mp3 from a URL -connection.playArbitraryInput('http://mysite.com/sound.mp3'); +const broadcast = client.voice.createBroadcast(); + +broadcast.on('subscribe', dispatcher => { + console.log('New broadcast subscriber!'); +}); + +broadcast.on('unsubscribe', dispatcher => { + console.log('Channel unsubscribed from broadcast :('); +}); ``` -Again, playing a file from a URL like this is more performant than creating a ReadableStream to the file. +`broadcast` is an instance of `VoiceBroadcast`, which has the same `play` method you are used to with regular VoiceConnections: -## Advanced Topics -soon:tm: +```js +const dispatcher = broadcast.play('./audio.mp3'); + +connection.play(broadcast); +``` + +It's important to note that the `dispatcher` stored above is a `BroadcastDispatcher` - it controls all the dispatcher subscribed to the broadcast, e.g. setting the volume of this dispatcher affects the volume of all subscribers. + +## Voice Receive + +coming soon™ diff --git a/docs/topics/web.md b/docs/topics/web.md index 611834e8b..87a853279 100644 --- a/docs/topics/web.md +++ b/docs/topics/web.md @@ -1,13 +1,32 @@ # Web builds + In addition to your usual Node applications, discord.js has special distributions available that are capable of running in web browsers. This is useful for client-side web apps that need to interact with the Discord API. [Webpack 3](https://webpack.js.org/) is used to build these. -## Usage +## Restrictions + +- Any voice-related functionality is unavailable, as there is currently no audio encoding/decoding capabilities without external native libraries, + which web browsers do not support. +- The ShardingManager cannot be used, since it relies on being able to spawn child processes for shards. +- None of the native optional packages are usable. + +### Require Library + +If you are making your own webpack project, you can require `discord.js/browser` wherever you need to use discord.js, like so: + +```js +const Discord = require('discord.js/browser'); +// do something with Discord like you normally would +``` + +### Webpack File + You can obtain your desired version of discord.js' web build from the [webpack branch](https://github.com/discordjs/discord.js/tree/webpack) of the GitHub repository. There is a file for each branch and version of the library, and the ones ending in `.min.js` are minified to substantially reduce the size of the source code. Include the file on the page just as you would any other JS library, like so: + ```html ``` @@ -15,15 +34,10 @@ Include the file on the page just as you would any other JS library, like so: Rather than importing discord.js with `require('discord.js')`, the entire `Discord` object is available as a global (on the `window`) object. The usage of the API isn't any different from using it in Node.js. -## Restrictions -- Any voice-related functionality is unavailable, as there is currently no audio encoding/decoding capabilities without external native libraries, - which web browsers do not support. -- The ShardingManager cannot be used, since it relies on being able to spawn child processes for shards. -- None of the optional packages are usable, since they're native libraries. +#### Example -## Example ```html - + - + - + client.on('message', message => { + console.log(message.author.username, message.author.id, message.content); + }); + + client + .login(localStorage.token || window.token || prompt('token pls', 'abcdef123456')) + .then(token => (localStorage.token = token), console.log); + })(); + + diff --git a/tsconfig.json b/tsconfig.json index 37aa901ee..02c9ecc20 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,13 +1,15 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "noImplicitAny": true, - "strictNullChecks": true, - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "typings/index.d.ts" - ] + "compilerOptions": { + "strict": true, + "moduleResolution": "node", + "declaration": false, + "removeComments": false, + "alwaysStrict": true, + "pretty": true, + "module": "commonjs", + "target": "es2019", + "lib": ["esnext", "esnext.array", "esnext.asynciterable", "esnext.intl", "esnext.symbol"], + "sourceMap": false, + "skipLibCheck": true + } } diff --git a/tslint.json b/tslint.json index 71f850264..61a760850 100644 --- a/tslint.json +++ b/tslint.json @@ -1,62 +1,28 @@ { - "extends": [ - "tslint-config-typings" - ], - "rules": { - "class-name": true, - "comment-format": [ - true, - "check-space" - ], - "indent": [ - true, - "tabs" - ], - "no-duplicate-variable": true, - "no-unused-variable": [false], - "no-eval": true, - "no-internal-module": true, - "no-trailing-whitespace": true, - "no-unsafe-finally": true, - "no-var-keyword": true, - "one-line": [ - true, - "check-open-brace", - "check-whitespace" - ], - "quotemark": [ - true, - "single" - ], - "semicolon": [ - true, - "always" - ], - "triple-equals": [ - true, - "allow-null-check" - ], - "typedef-whitespace": [ - true, - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - } - ], - "variable-name": [ - true, - "ban-keywords" - ], - "whitespace": [ - true, - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type" - ] - } + "extends": ["dtslint/dtslint.json"], + "rules": { + "prefer-readonly": false, + "await-promise": false, + "no-for-in-array": false, + "no-null-undefined-union": false, + "no-promise-as-boolean": false, + "no-void-expression": false, + "strict-string-expressions": false, + "strict-comparisons": false, + "use-default-type-parameter": false, + "no-boolean-literal-compare": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "expect": false, + "no-import-default-of-export-equals": false, + "no-relative-import-in-test": false, + "no-unnecessary-generics": false, + "strict-export-declare-modifiers": false, + "no-single-declare-module": false, + "member-access": true, + "no-unnecessary-class": false, + "array-type": [true, "array"], + + "no-any-union": false + } } diff --git a/typings/discord.js-test.ts b/typings/discord.js-test.ts deleted file mode 100644 index afa957382..000000000 --- a/typings/discord.js-test.ts +++ /dev/null @@ -1,69 +0,0 @@ -/// - -import { Collector, Message, CollectorFilter, Client, CollectorHandler, MessageReaction, Collection, User, ReactionCollectorOptions, Snowflake } from 'discord.js'; - -const client = new Client({ - disableEveryone: false, - disabledEvents: ['GUILD_MEMBER_ADD'] -}); - -client.on('message', (message) => { - if (message.content === 'hello') { - message.channel.sendMessage('o/'); - } - - const collector: ReactionCollector = new ReactionCollector(message, - (reaction: MessageReaction) => reaction.emoji.toString() === '👌', - { time: 30e3 }); - collector.on('end', collected => console.log(collected)); -}); - -client.login('dsfsd754.4fds4f68d4f6sd46f4s.7878easfdsgdfFDSIJIO'); - -export class TestCollector extends Collector { - public filter: CollectorFilter; - public constructor(client: Client, filter: CollectorFilter) { - super(client, filter); - } - - public handle(message: Message): CollectorHandler { - return { key: message.id, value: message }; - } - - public cleanup(): void {} - public postCheck(): null { return null; } -} - -class ReactionCollector extends Collector { - public message: Message; - public users: Collection; - public total: number; - public options: ReactionCollectorOptions; - public constructor(message: Message, filter: CollectorFilter, options?: ReactionCollectorOptions) { - super(message.client, filter, options || {}); - this.message = message; - this.users = new Collection(); - this.total = 0; - this.client.on('messageReactionAdd', this.listener); - } - - public handle(reaction: MessageReaction): CollectorHandler { - if (reaction.message.id !== this.message.id) { return null; } - return { - key: reaction.emoji.id || reaction.emoji.name, - value: reaction - }; - } - - public postCheck(reaction: MessageReaction, user: User): string { - this.users.set(user.id, user); - if (this.options.max && ++this.total >= this.options.max) { return 'limit'; } - if (this.options.maxEmojis && this.collected.size >= this.options.maxEmojis) { return 'emojiLimit'; } - if (this.options.maxUsers && this.users.size >= this.options.maxUsers) { return 'userLimit'; } - return null; - } - - public cleanup(): void { - this.client.removeListener('messageReactionAdd', this.listener as any); - } -} diff --git a/typings/index.d.ts b/typings/index.d.ts index cb5fad51f..8ceee251b 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1,2440 +1,3049 @@ -// Type definitions for discord.js 11.6.1 -// Project: https://github.com/discordjs/discord.js -// Definitions by: -// acdenisSK (https://github.com/acdenisSK) -// Zack Campbell (https://github.com/zajrik) -// License: MIT +declare enum ChannelType { + text = 0, + dm = 1, + voice = 2, + group = 3, + category = 4, + news = 5, + store = 6, + unknown = 7, +} declare module 'discord.js' { - import { EventEmitter } from 'events'; - import { Stream, Readable as ReadableStream } from 'stream'; - import { ChildProcess } from 'child_process'; - - export const version: string; - -//#region Classes - - class Attachment { - constructor(file: BufferResolvable | Stream, name?: string); - private _attach(file: BufferResolvable | Stream, name: string): void; - - public readonly attachment: BufferResolvable | Stream; - public readonly name: string; - public setAttachment(file: BufferResolvable | Stream, name: string): this; - public setFile(attachment: BufferResolvable | Stream): this; - public setName(name: string): this; - } - - class AudioPlayer extends EventEmitter { - constructor(voiceConnection: VoiceConnection); - public readonly dispatcher: StreamDispatcher; - public opusEncoder: object; - public prism: object; - public readonly transcoder: object; - public voiceConnection: VoiceConnection; - public setBitrate(value: number | 'auto'): void; - } - - class BaseOpus { - constructor(options?: { bitrate?: number, fec?: boolean, plp?: number }); - public bitrate: number; - public options: object; - } - - export class BitField { - constructor(bits?: BitFieldResolvable); - public bitfield: number; - public add(...bits: BitFieldResolvable[]): BitField; - public any(bit: BitFieldResolvable): boolean; - public equals(bit: BitFieldResolvable): boolean; - public freeze(): Readonly>; - public has(bit: BitFieldResolvable): boolean; - public missing(bits: BitFieldResolvable, ...hasParam: readonly unknown[]): S[]; - public remove(...bits: BitFieldResolvable[]): BitField; - public serialize(...hasParam: readonly unknown[]): Record; - public toArray(...hasParam: readonly unknown[]): S[]; - public toJSON(): number; - public valueOf(): number; - public [Symbol.iterator](): IterableIterator; - public static FLAGS: object; - public static resolve(bit?: BitFieldResolvable): number; - } - - export class CategoryChannel extends GuildChannel { - public readonly children: Collection; - } - - export class Channel { - constructor(client: Client, data: object); - public readonly client: Client; - public readonly createdAt: Date; - public readonly createdTimestamp: number; - public deleted: boolean; - public id: Snowflake; - public type: 'dm' | 'group' | GuildChannelType; - public delete(): Promise; - } - - export class Client extends EventEmitter { - constructor(options?: ClientOptions); - private _intervals: Set; - private _pingTimestamp: number; - private _timeouts: Set; - private actions: object; - private dataManager: object; - private manager: ClientManager; - private resolver: ClientDataResolver; - private rest: object; - private voice: ClientVoiceManager; - private ws: object; - private _eval(script: string): any; - private _pong(startTime: number): void; - private _setPresence(id: Snowflake, presence: object): void; - private _validateOptions(options?: ClientOptions): void; - - public broadcasts: VoiceBroadcast[]; - public readonly browser: boolean; - public channels: Collection; - public readonly emojis: Collection; - public guilds: Collection; - public options: ClientOptions; - public readonly ping: number; - public pings: number[]; - public presences: Collection; - public readyAt: Date; - public readonly readyTimestamp: number; - public shard: ShardClientUtil; - public readonly status: number; - public token: string; - public readonly uptime: number; - public user: ClientUser; - public users: Collection; - public readonly voiceConnections: Collection; - public clearInterval(interval: NodeJS.Timer): void; - public clearTimeout(timeout: NodeJS.Timer): void; - public createVoiceBroadcast(): VoiceBroadcast; - public destroy(): Promise; - public fetchApplication(id?: Snowflake): Promise; - public fetchInvite(invite: InviteResolvable): Promise; - public fetchUser(id: Snowflake, cache?: boolean): Promise; - public fetchVoiceRegions(): Promise>; - public fetchWebhook(id: Snowflake, token?: string): Promise; - public generateInvite(permissions?: PermissionResolvable): Promise; - public login(token?: string): Promise; - public setInterval(fn: Function, delay: number, ...args: any[]): NodeJS.Timer; - public setTimeout(fn: Function, delay: number, ...args: any[]): NodeJS.Timer; - public sweepMessages(lifetime?: number): number; - public syncGuilds(guilds?: Guild[] | Collection): void; - - public on(event: 'channelCreate', listener: (channel: Channel) => void): this; - public on(event: 'channelDelete', listener: (channel: Channel) => void): this; - public on(event: 'channelPinsUpdate', listener: (channel: Channel, time: Date) => void): this; - public on(event: 'channelUpdate', listener: (oldChannel: Channel, newChannel: Channel) => void): this; - public on(event: 'clientUserGuildSettingsUpdate', listener: (clientUserGuildSettings: ClientUserGuildSettings) => void): this; - public on(event: 'clientUserSettingsUpdate', listener: (clientUserSettings: ClientUserSettings) => void): this; - public on(event: 'debug', listener: (info: string) => void): this; - public on(event: 'disconnect', listener: (event: any) => void): this; - public on(event: 'emojiCreate', listener: (emoji: Emoji) => void): this; - public on(event: 'emojiDelete', listener: (emoji: Emoji) => void): this; - public on(event: 'emojiUpdate', listener: (oldEmoji: Emoji, newEmoji: Emoji) => void): this; - public on(event: 'error', listener: (error: Error) => void): this; - public on(event: 'guildBanAdd', listener: (guild: Guild, user: User) => void): this; - public on(event: 'guildBanRemove', listener: (guild: Guild, user: User) => void): this; - public on(event: 'guildCreate', listener: (guild: Guild) => void): this; - public on(event: 'guildDelete', listener: (guild: Guild) => void): this; - public on(event: 'guildMemberAdd', listener: (member: GuildMember) => void): this; - public on(event: 'guildMemberAvailable', listener: (member: GuildMember) => void): this; - public on(event: 'guildMemberRemove', listener: (member: GuildMember) => void): this; - public on(event: 'guildMembersChunk', listener: (members: GuildMember[], guild: Guild) => void): this; - public on(event: 'guildMemberSpeaking', listener: (member: GuildMember, speaking: boolean) => void): this; - public on(event: 'guildMemberUpdate', listener: (oldMember: GuildMember, newMember: GuildMember) => void): this; - public on(event: 'guildUnavailable', listener: (guild: Guild) => void): this; - public on(event: 'guildUpdate', listener: (oldGuild: Guild, newGuild: Guild) => void): this; - public on(event: 'guildIntegrationsUpdate', listener: (guild: Guild) => void): this; - public on(event: 'inviteCreate' | 'inviteDelete', listener: (invite: Invite) => void): this; - public on(event: 'message', listener: (message: Message) => void): this; - public on(event: 'messageDelete', listener: (message: Message) => void): this; - public on(event: 'messageDeleteBulk', listener: (messages: Collection) => void): this; - public on(event: 'messageReactionAdd', listener: (messageReaction: MessageReaction, user: User) => void): this; - public on(event: 'messageReactionRemove', listener: (messageReaction: MessageReaction, user: User) => void): this; - public on(event: 'messageReactionRemoveEmoji', listener: (messageReaction: MessageReaction) => void): this; - public on(event: 'messageReactionRemoveAll', listener: (message: Message) => void): this; - public on(event: 'messageUpdate', listener: (oldMessage: Message, newMessage: Message) => void): this; - public on(event: 'presenceUpdate', listener: (oldMember: GuildMember, newMember: GuildMember) => void): this; - public on(event: 'rateLimit', listener: (rateLimit: RateLimitInfo) => void): this; - public on(event: 'ready', listener: () => void): this; - public on(event: 'reconnecting', listener: () => void): this; - public on(event: 'resume', listener: (replayed: number) => void): this; - public on(event: 'roleCreate', listener: (role: Role) => void): this; - public on(event: 'roleDelete', listener: (role: Role) => void): this; - public on(event: 'roleUpdate', listener: (oldRole: Role, newRole: Role) => void): this; - public on(event: 'typingStart', listener: (channel: Channel, user: User) => void): this; - public on(event: 'typingStop', listener: (channel: Channel, user: User) => void): this; - public on(event: 'userNoteUpdate', listener: (user: UserResolvable, oldNote: string, newNote: string) => void): this; - public on(event: 'userUpdate', listener: (oldUser: User, newUser: User) => void): this; - public on(event: 'voiceStateUpdate', listener: (oldMember: GuildMember, newMember: GuildMember) => void): this; - public on(event: 'warn', listener: (info: string) => void): this; - public on(event: 'webhookUpdate', listener: (channel: TextChannel) => void): this; - public on(event: string, listener: Function): this; - - public once(event: 'channelCreate', listener: (channel: Channel) => void): this; - public once(event: 'channelDelete', listener: (channel: Channel) => void): this; - public once(event: 'channelPinsUpdate', listener: (channel: Channel, time: Date) => void): this; - public once(event: 'channelUpdate', listener: (oldChannel: Channel, newChannel: Channel) => void): this; - public once(event: 'clientUserGuildSettingsUpdate', listener: (clientUserGuildSettings: ClientUserGuildSettings) => void): this; - public once(event: 'clientUserSettingsUpdate', listener: (clientUserSettings: ClientUserSettings) => void): this; - public once(event: 'debug', listener: (info: string) => void): this; - public once(event: 'disconnect', listener: (event: any) => void): this; - public once(event: 'emojiCreate', listener: (emoji: Emoji) => void): this; - public once(event: 'emojiDelete', listener: (emoji: Emoji) => void): this; - public once(event: 'emojiUpdate', listener: (oldEmoji: Emoji, newEmoji: Emoji) => void): this; - public once(event: 'error', listener: (error: Error) => void): this; - public once(event: 'guildBanAdd', listener: (guild: Guild, user: User) => void): this; - public once(event: 'guildBanRemove', listener: (guild: Guild, user: User) => void): this; - public once(event: 'guildCreate', listener: (guild: Guild) => void): this; - public once(event: 'guildDelete', listener: (guild: Guild) => void): this; - public once(event: 'guildMemberAdd', listener: (member: GuildMember) => void): this; - public once(event: 'guildMemberAvailable', listener: (member: GuildMember) => void): this; - public once(event: 'guildMemberRemove', listener: (member: GuildMember) => void): this; - public once(event: 'guildMembersChunk', listener: (members: GuildMember[], guild: Guild) => void): this; - public once(event: 'guildMemberSpeaking', listener: (member: GuildMember, speaking: boolean) => void): this; - public once(event: 'guildMemberUpdate', listener: (oldMember: GuildMember, newMember: GuildMember) => void): this; - public once(event: 'guildUnavailable', listener: (guild: Guild) => void): this; - public once(event: 'guildUpdate', listener: (oldGuild: Guild, newGuild: Guild) => void): this; - public once(event: 'guildIntegrationsUpdate', listener: (guild: Guild) => void): this; - public once(event: 'message', listener: (message: Message) => void): this; - public once(event: 'messageDelete', listener: (message: Message) => void): this; - public once(event: 'messageDeleteBulk', listener: (messages: Collection) => void): this; - public once(event: 'messageReactionAdd', listener: (messageReaction: MessageReaction, user: User) => void): this; - public once(event: 'messageReactionRemove', listener: (messageReaction: MessageReaction, user: User) => void): this; - public once(event: 'messageReactionRemoveEmoji', listener: (messageReaction: MessageReaction) => void): this; - public once(event: 'messageReactionRemoveAll', listener: (message: Message) => void): this; - public once(event: 'messageUpdate', listener: (oldMessage: Message, newMessage: Message) => void): this; - public once(event: 'presenceUpdate', listener: (oldMember: GuildMember, newMember: GuildMember) => void): this; - public once(event: 'rateLimit', listener: (rateLimit: RateLimitInfo) => void): this; - public once(event: 'ready', listener: () => void): this; - public once(event: 'reconnecting', listener: () => void): this; - public once(event: 'resume', listener: (replayed: number) => void): this; - public once(event: 'roleCreate', listener: (role: Role) => void): this; - public once(event: 'roleDelete', listener: (role: Role) => void): this; - public once(event: 'roleUpdate', listener: (oldRole: Role, newRole: Role) => void): this; - public once(event: 'typingStart', listener: (channel: Channel, user: User) => void): this; - public once(event: 'typingStop', listener: (channel: Channel, user: User) => void): this; - public once(event: 'userNoteUpdate', listener: (user: UserResolvable, oldNote: string, newNote: string) => void): this; - public once(event: 'userUpdate', listener: (oldUser: User, newUser: User) => void): this; - public once(event: 'voiceStateUpdate', listener: (oldMember: GuildMember, newMember: GuildMember) => void): this; - public once(event: 'warn', listener: (info: string) => void): this; - public once(event: 'webhookUpdate', listener: (channel: TextChannel) => void): this; - public once(event: string, listener: Function): this; - } - - class ClientDataResolver { - constructor(client: Client); - public resolveBase64(data: Base64Resolvable): string; - public resolveChannel(channel: ChannelResolvable): Channel; - public resolveChannelID(channel: ChannelResolvable): Snowflake; - public resolveColor(color: ColorResolvable): number; - public resolveString(data: StringResolvable): string; - public resolveEmojiIdentifier(emoji: EmojiIdentifierResolvable): string; - public resolveFile(resource: BufferResolvable | Stream): Promise; - public resolveGuild(guild: GuildResolvable): Guild; - public resolveGuildMember(guild: GuildResolvable, user: UserResolvable): GuildMember; - public resolveImage(imge: BufferResolvable | Base64Resolvable): Promise; - public resolveInviteCode(data: InviteResolvable): string; - public resolveString(data: StringResolvable): string; - public resolveUser(user: UserResolvable): User; - public resolveUserID(user: UserResolvable): Snowflake; - - public static resolveColor(color: ColorResolvable): number; - } - - class ClientManager { - constructor(client: Client); - public client: Client; - public heartbeatInterval: number; - public status: number; - public connectToWebSocket(token: string, resolve: Function, reject: Function): void; - } - - export class ClientUser extends User { - public blocked: Collection; - public email: string; - public friends: Collection; - public guildSettings: Collection; - public mfaEnabled: boolean; - public mobile: boolean; - public notes: Collection; - public premium: boolean; - public settings: ClientUserSettings; - public verified: boolean; - public acceptInvite(invite: Invite | string): Promise; - public addFriend(user?: UserResolvable): Promise; - public createGroupDM(recipients: GroupDMRecipientOptions[]): Promise; - public createGuild(name: string, region: string, icon?: BufferResolvable | Base64Resolvable): Promise; - public fetchMentions(options?: { limit?: number; roles?: boolean, everyone?: boolean; guild?: Guild | Snowflake }): Promise; - public removeFriend(user?: UserResolvable): Promise; - public setActivity(name: string | null, options?: { url?: string, type?: ActivityType | number }): Promise; - public setAFK(afk: boolean): Promise; - public setAvatar(avatar: BufferResolvable | Base64Resolvable): Promise; - public setEmail(email: string, password: string): Promise; - public setGame(game: string | null, streamingURL?: string): Promise; - public setPassword(newPassword: string, oldPassword: string): Promise; - public setPresence(data: PresenceData): Promise; - public setStatus(status: PresenceStatus): Promise; - public setUsername(username: string, password?: string): Promise; - } - - class ClientUserChannelOverride { - constructor(user: User, data: object); - private patch(data: object): void; - - public messageNotifications: GuildChannelMessageNotifications; - public muted: boolean; - } - - class ClientUserGuildSettings { - constructor(data: object, guild: Guild); - private patch(data: object): void; - - public channelOverrides: Collection; - public readonly client: Client; - public guildID: Snowflake; - public messageNotifications: GuildChannelMessageNotifications; - public mobilePush: boolean; - public muted: boolean; - public suppressEveryone: boolean; - public update(name: string, value: any): Promise; - } - - export class ClientUserSettings { - constructor(user: User, data: object); - private patch(data: object): void; - - public convertEmoticons: boolean; - public defaultGuildsRestricted: boolean; - public detectPlatformAccounts: boolean; - public developerMode: boolean; - public enableTTSCommand: boolean; - public explicitContentFilter: 'DISABLED' | 'NON_FRIENDS' | 'FRIENDS_AND_NON_FRIENDS' | string; - public friendsSources: { all: boolean, mutualGuilds: boolean, mutualFriends: boolean }; - public guildsPositions: Snowflake[]; - public inlineAttachmentMedia: boolean; - public inlineEmbedMedia: boolean; - public locale: string; - public messageDisplayCompact: boolean; - public renderReactions: boolean; - public restrictedGuilds: Snowflake[]; - public showCurrentGame: boolean; - public status: PresenceStatus; - public theme: string; - public addRestrictedGuild(guild: Guild): Promise; - public removeRestrictedGuild(guild: Guild): Promise; - public setGuildPosition(guild: Guild, position: number, relative?: boolean): Promise; - public update(name: string, value: any): Promise; - } - - class ClientVoiceManager { - constructor(client: Client); - public client: Client; - public connections: Collection; - public joinChannel(channel: VoiceChannel): Promise; - } - - export class Collection extends Map { - private _array: V[]; - private _keyArray: K[]; - - public array(): V[]; - public clone(): Collection; - public concat(...collections: Collection[]): Collection; - public deleteAll(): Promise[]; - public equals(collection: Collection): boolean; - public every(fn: (value: V, key: K, collection: Collection) => boolean, thisArg?: any): boolean; - public exists(prop: keyof V, value: any): boolean; - public filter(fn: (value: V, key: K, collection: Collection) => boolean, thisArg?: any): Collection; - public filterArray(fn: (value: V, key: K, collection: Collection) => boolean, thisArg?: any): V[]; - public find(prop: keyof V, value: any): V; - public find(fn: (value: V, key: K, collection: Collection) => boolean): V; - public findAll(prop: keyof V, value: any): V[]; - public findKey(prop: keyof V, value: any): K; - public findKey(fn: (value: V, key: K, collection: Collection) => boolean): K; - public first(): V; - public first(count: number): V[]; - public firstKey(): K; - public firstKey(count: number): K[]; - public keyArray(): K[]; - public last(): V; - public last(count: number): V[]; - public lastKey(): K; - public lastKey(count: number): K[]; - public map(fn: (value: V, key: K, collection: Collection) => T, thisArg?: any): T[]; - public partition(fn: (value: V, key: K, collection: Collection) => boolean, thisArg?: any): [Collection, Collection]; - public random(): V; - public random(count: number): V[]; - public randomKey(): K; - public randomKey(count: number): K[]; - public reduce(fn: (accumulator: any, value: V, key: K, collection: Collection) => T, initialValue?: any): T; - public some(fn: (value: V, key: K, collection: Collection) => boolean, thisArg?: any): boolean; - public sort(compareFunction?: (a: V, b: V, c?: K, d?: K) => number): Collection; - public sweep(fn: (value: V, key: K, collection: Collection) => boolean, thisArg?: any): number; - public tap(fn: (value: V, key: K, map: Collection) => void, thisArg?: any): Collection; - } - - abstract class Collector extends EventEmitter { - constructor(client: Client, filter: CollectorFilter, options?: CollectorOptions); - private _timeout: NodeJS.Timer | null; - private _idletimeout: NodeJS.Timer | null; - private _handle(...args: any[]): void; - - public readonly client: Client; - public collected: Collection; - public ended: boolean; - public filter: CollectorFilter; - public readonly next: Promise; - public options: CollectorOptions; - public stop(reason?: string): void; - - protected listener: Function; - public abstract cleanup(): void; - public abstract handle(...args: any[]): CollectorHandler; - public abstract postCheck(...args: any[]): string | null; - - public on(event: 'collect', listener: (element: V, collector: Collector) => void): this; - public on(event: 'end', listener: (collected: Collection, reason: string) => void): this; - public on(event: string, listener: Function): this; - - public once(event: 'collect', listener: (element: V, collector: Collector) => void): this; - public once(event: 'end', listener: (collected: Collection, reason: string) => void): this; - public once(event: string, listener: Function): this; - } - - class DiscordAPIError extends Error { - constructor(error: object); - private static flattenErrors(obj: object, key: string): string[]; - - public code: number; - public method: string; - public path: string; - } - - export class DMChannel extends TextBasedChannel(Channel) { - constructor(client: Client, data: object); - public lastMessageID: Snowflake; - public messages: Collection; - public recipient: User; - public toString(): string; - } - - export class Emoji { - constructor(guild: Guild, data: object); - public animated: boolean; - public available: boolean; - public readonly client: Client; - public readonly createdAt: Date; - public readonly createdTimestamp: number; - public readonly deletable: boolean; - public deleted: boolean; - public guild: Guild; - public id: Snowflake; - public readonly identifier: string; - public managed: boolean; - public name: string; - public requiresColons: boolean; - public readonly roles: Collection; - public readonly url: string; - public addRestrictedRole(role: Role): Promise; - public addRestrictedRoles(roles: Role[]): Promise; - public edit(data: EmojiEditData, reason?: string): Promise; - public equals(other: Emoji | object): boolean; - public delete(reason?: string): Promise; - public fetchAuthor(): Promise; - public removeRestrictedRole(role: Role): Promise; - public removeRestrictedRoles(roles: Role[]): Promise; - public setName(name: string, reason?: string): Promise; - public toString(): string; - } - - export class Game { - constructor(data: object, presence: Presence); - private _flags: string[]; - private syncID: string; - - public applicationID: string; - public assets: RichPresenceAssets; - public details: string; - public emoji: Omit | null; - public name: string; - public readonly streaming: boolean; - public party: { - id: string; - size: [number, number]; - }; - public state: string; - public timestamps: { - start: Date; - end: Date; - }; - public readonly flags: string[]; - public type: number; - public url: string; - public equals(game: Game): boolean; - public toString(): string; - } - - export class GroupDMChannel extends TextBasedChannel(Channel) { - constructor(client: Client, data: object); - public applicationID: string; - public icon: string; - public lastMessageID: string; - public managed: boolean; - public messages: Collection; - public name: string; - public nicks: Collection; - public readonly owner: User; - public ownerID: string; - public recipients: Collection; - public addUser(accessTokenOrID: UserResolvable | string, nick?: string): Promise; - public equals(channel: GroupDMChannel): boolean; - public setIcon(icon: Base64Resolvable | BufferResolvable): Promise; - public toString(): string; - } - - export class Guild { - constructor(client: Client, data: object); - private readonly _sortedRoles: Collection; - private _sortedChannels(type: string): Collection; - private _sortPositionWithID(collection: Collection): Collection; - - protected setup(data: any): void; - - public readonly afkChannel: VoiceChannel; - public afkChannelID: string; - public afkTimeout: number; - public applicationID: string; - public available: boolean; - public banner: string | null; - public readonly bannerURL: string | null; - public deleted: boolean; - public description: string | null; - public channels: Collection; - public defaultMessageNotifications: DefaultMessageNotifications | number; - public readonly client: Client; - public readonly createdAt: Date; - public readonly createdTimestamp: number; - public readonly defaultChannel: TextChannel; - public readonly defaultRole: Role; - public readonly embedChannel: TextChannel | null; - public embedChannelID: Snowflake | null; - public embedEnabled: boolean; - public emojis: Collection; - public explicitContentFilter: number; - public features: string[]; - public icon: string; - public readonly iconURL: string; - public id: Snowflake; - public readonly joinedAt: Date; - public joinedTimestamp: number; - public large: boolean; - public maximumMembers?: number; - public maximumPresences?: number; - public readonly me: GuildMember; - public memberCount: number; - public members: Collection; - public readonly messageNotifications: MessageNotifications; - public readonly mobilePush: boolean; - public readonly muted: boolean; - public name: string; - public readonly nameAcronym: string; - public readonly owner: GuildMember; - public ownerID: string; - public premiumSubscriptionCount: number | null; - public premiumTier: PremiumTier; - public readonly position: number; - public presences: Collection; - public readonly publicUpdatesChannel: TextChannel | null; - public publicUpdatesChannelID: Snowflake | null; - public region: string; - public roles: Collection; - public readonly rulesChannel: TextChannel | null; - public rulesChannelID: Snowflake | null; - public splash: string; - public readonly splashURL: string; - public readonly suppressEveryone: boolean; - public readonly systemChannel: GuildChannel; - public systemChannelFlags: Readonly; - public systemChannelID: Snowflake; - public vanityURLCode: string; - public readonly verified: boolean; - public verificationLevel: number; - public readonly voiceConnection: VoiceConnection; - public readonly widgetChannel: TextChannel | null; - public widgetChannelID?: Snowflake; - public widgetEnabled?: boolean; - public acknowledge(): Promise; - public addMember(user: UserResolvable, options: AddGuildMemberOptions): Promise; - public allowDMs(allow: boolean): Promise; - public ban(user: UserResolvable, options?: BanOptions | number | string): Promise; - public createChannel(name: string, options?: ChannelData): Promise; - public createChannel(name: string, type?: GuildChannelType, permissionOverwrites?: PermissionOverwrites[] | ChannelCreationOverwrites[], reason?: string): Promise; - public createEmoji(attachment: BufferResolvable | Base64Resolvable, name: string, roles?: Collection | Role[], reason?: string): Promise; - public createIntegration(data: IntegrationData, reason?: string): Promise; - public createRole(data?: RoleData, reason?: string): Promise; - public delete(): Promise; - public deleteEmoji(emoji: Emoji | string, reason?: string): Promise; - public edit(data: GuildEditData, reason?: string): Promise; - public equals(guild: Guild): boolean; - public fetch(): Promise; - public fetchAuditLogs(options?: GuildAuditLogsFetchOptions): Promise; - public fetchBan(user: UserResolvable): Promise; - public fetchBans(withReasons?: false): Promise>; - public fetchBans(withReasons: true): Promise>; - public fetchBans(withReasons: boolean): Promise>; - public fetchEmbed(): Promise; - public fetchIntegrations(): Promise>; - public fetchInvites(): Promise>; - public fetchMember(user: UserResolvable, cache?: boolean): Promise; - public fetchMembers(query?: string, limit?: number): Promise; - public fetchVanityCode(): Promise; - public fetchVoiceRegions(): Promise>; - public fetchWebhooks(): Promise>; - public leave(): Promise; - public member(user: UserResolvable): GuildMember; - public pruneMembers(days: number, dry?: boolean, reason?: string): Promise; - public search(options?: MessageSearchOptions): Promise; - public setAFKChannel(afkChannel: ChannelResolvable, reason?: string): Promise; - public setAFKTimeout(afkTimeout: number, reason?: string): Promise; - public setBanner(banner: Base64Resolvable, reason?: string): Promise; - public setChannelPosition(channel: string | GuildChannel, position: number, relative?: boolean): Promise; - public setChannelPositions(channelPositions: ChannelPosition[]): Promise; - public setDefaultMessageNotifications(defaultMessageNotifications: DefaultMessageNotifications, reason?: string): Promise; - public setEmbed(embed: GuildEmbedData, reason?: string): Promise; - public setExplicitContentFilter(explicitContentFilter: number, reason?: string): Promise; - public setIcon(icon: Base64Resolvable, reason?: string): Promise; - public setName(name: string, reason?: string): Promise; - public setOwner(owner: GuildMemberResolvable, reason?: string): Promise; - public setPosition(position: number, relative?: boolean): Promise; - public setRegion(region: string, reason?: string): Promise; - public setRolePosition(role: string | Role, position: number, relative?: boolean): Promise; - public setRolePositions(rolePositions: RolePosition[]): Promise; - public setSplash(splash: Base64Resolvable, reason?: string): Promise; - public setSystemChannel(systemChannel: ChannelResolvable, reason?: string): Promise; - public setSystemChannelFlags(systemChannelFlags: SystemChannelFlagsResolvable, reason?: string): Promise; - public setVerificationLevel(verificationLevel: number, reason?: string): Promise; - public sync(): void; - public toString(): string; - public unban(user: UserResolvable, reason?: string): Promise; - } - - export class GuildAuditLogs { - constructor(guild: Guild, data: object); - private webhooks: Collection; - private integrations: Collection; - - public entries: Collection; - - public static Actions: GuildAuditLogsActions; - public static Targets: GuildAuditLogsTargets; - public static Entry: typeof GuildAuditLogsEntry; - public static actionType(action: number): GuildAuditLogsActionType; - public static build(...args: any[]): Promise; - public static targetType(target: number): GuildAuditLogsTarget; - } - - class GuildAuditLogsEntry { - constructor(logs: GuildAuditLogs, guild: Guild, data: object); - public action: GuildAuditLogsAction; - public actionType: GuildAuditLogsActionType; - public changes: AuditLogChange[]; - public readonly createdAt: Date; - public readonly createdTimestamp: number; - public executor: User; - public extra: object | Role | GuildMember; - public id: Snowflake; - public reason: string; - public target: Guild | User | Role | Emoji | Invite | Webhook | Integration | null; - public targetType: GuildAuditLogsTarget; - } - - export class GuildChannel extends Channel { - constructor(guild: Guild, data: object); - public readonly calculatedPosition: number; - public readonly deletable: boolean; - public guild: Guild; - public readonly manageable: boolean; - public readonly messageNotifications: GuildChannelMessageNotifications; - public readonly muted: boolean; - public name: string; - public readonly parent: CategoryChannel | null; - public parentID: Snowflake | null; - public permissionOverwrites: Collection; - public position: number; - public readonly permissionsLocked: boolean | null; - public clone(options: GuildChannelCloneOptions): Promise; - public clone(name?: string, withPermissions?: boolean, withTopic?: boolean, reason?: string): Promise; - public createInvite(options?: InviteOptions, reason?: string): Promise; - public delete(reason?: string): Promise; - public edit(data: ChannelData, reason?: string): Promise; - public equals(channel: GuildChannel): boolean; - public fetchInvites(): Promise>; - public lockPermissions(): Promise; - public memberPermissions(member: GuildMemberResolvable): Permissions | null; - public overwritePermissions(userOrRole: RoleResolvable | UserResolvable, options: PermissionOverwriteOptions, reason?: string): Promise; - public permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable): Permissions | null; - public replacePermissionOverwrites(options?: { overwrites?: (PermissionOverwrites | ChannelCreationOverwrites)[] | Collection, reason?: string }): Promise; - public rolePermissions(role: RoleResolvable): Permissions; - public setName(name: string, reason?: string): Promise; - public setParent(parent: ChannelResolvable, reason?: string): Promise; - public setPosition(position: number, relative?: boolean): Promise; - public setTopic(topic: string, reason?: string): Promise; - public toString(): string; - } - - export class GuildMember extends PartialTextBasedChannel() { - constructor(guild: Guild, data: object); - public readonly bannable: boolean; - public readonly client: Client; - public readonly colorRole: Role; - public readonly deaf: boolean; - public deleted: boolean; - public readonly displayColor: number; - public readonly displayHexColor: string; - public readonly displayName: string; - public guild: Guild; - public readonly highestRole: Role; - public readonly hoistRole: Role; - public readonly id: Snowflake; - public readonly joinedAt: Date; - public joinedTimestamp: number; - public readonly kickable: boolean; - public lastMessageID: string; - public readonly mute: boolean; - public nickname: string | null; - public readonly manageable: boolean; - public readonly permissions: Permissions; - public readonly premiumSince: Date | null; - public premiumSinceTimestamp: number | null; - public readonly presence: Presence; - public readonly roles: Collection; - public selfDeaf: boolean; - public selfMute: boolean; - public selfStream: boolean; - public serverDeaf: boolean; - public serverMute: boolean; - public speaking: boolean; - public user: User; - public readonly voiceChannel: VoiceChannel; - public voiceChannelID: string; - public voiceSessionID: string; - public addRole(role: Role | Snowflake, reason?: string): Promise; - public addRoles(roles: Collection | Role[] | Snowflake[], reason?: string): Promise; - public ban(options?: BanOptions | number | string): Promise; - public createDM(): Promise; - public deleteDM(): Promise; - public edit(data: GuildMemberEditData, reason?: string): Promise; - public hasPermission(permission: PermissionResolvable, explicit?: boolean, checkAdmin?: boolean, checkOwner?: boolean): boolean; - public hasPermissions(permission: PermissionResolvable, explicit?: boolean): boolean; - public kick(reason?: string): Promise; - public missingPermissions(permissions: PermissionResolvable, explicit?: boolean): PermissionResolvable; - public permissionsIn(channel: ChannelResolvable): Permissions; - public removeRole(role: Role | Snowflake, reason?: string): Promise; - public removeRoles(roles: Collection | Role[] | Snowflake[], reason?: string): Promise; - public setDeaf(deaf: boolean, reason?: string): Promise; - public setMute(mute: boolean, reason?: string): Promise; - public setNickname(nickname: string, reason?: string): Promise; - public setRoles(roles: Collection | Role[] | Snowflake[], reason?: string): Promise; - public setVoiceChannel(voiceChannel: ChannelResolvable | null): Promise; - public toString(): string; - } - - export class Integration { - constructor(client: Client, data: object, guild: Guild); - public account: IntegrationAccount; - public enabled: boolean; - public expireBehavior: number; - public expireGracePeriod: number; - public guild: Guild; - public id: Snowflake; - public name: string; - public role: Role; - public syncedAt: number; - public syncing: boolean; - public type: number; - public user: User; - public delete(reason?: string): Promise; - public edit(data: IntegrationEditData, reason?: string): Promise; - public sync(): Promise; - } - - export class Invite { - constructor(client: Client, data: object); - public channel: GuildChannel | PartialGuildChannel; - public readonly client: Client; - public code: string; - public readonly createdAt: Date; - public createdTimestamp: number; - public readonly expiresAt: Date; - public readonly expiresTimestamp: number; - public guild: Guild | PartialGuild; - public inviter: User; - public maxAge: number; - public maxUses: number; - public memberCount: number; - public presenceCount: number; - public temporary: boolean; - public textChannelCount: number; - public readonly url: string; - public uses: number; - public voiceChannelCount: number; - public delete(reason?: string): Promise; - public toString(): string; - } - - export class Message { - constructor(channel: TextChannel | DMChannel | GroupDMChannel, data: object, client: Client); - private _edits: Message[]; - private patch(data: object): void; - - public attachments: Collection; - public author: User; - public channel: TextChannel | DMChannel | GroupDMChannel; - public readonly cleanContent: string; - public readonly client: Client; - public content: string; - public readonly createdAt: Date; - public createdTimestamp: number; - public readonly deletable: boolean; - public deleted: boolean; - public readonly editable: boolean; - public readonly editedAt: Date; - public editedTimestamp: number; - public readonly edits: Message[]; - public embeds: MessageEmbed[]; - public flags: Readonly; - public readonly guild: Guild; - public hit: boolean; - public id: Snowflake; - public member: GuildMember; - public mentions: MessageMentions; - public nonce: string; - public readonly pinnable: boolean; - public pinned: boolean; - public reactions: Collection; - public reference: MessageReference | null; - public system: boolean; - public tts: boolean; - public type: string; - public readonly url: string; - public webhookID: Snowflake; - public acknowledge(): Promise; - public awaitReactions(filter: CollectorFilter, options?: AwaitReactionsOptions): Promise>; - public clearReactions(): Promise; - public createReactionCollector(filter: CollectorFilter, options?: ReactionCollectorOptions): ReactionCollector; - public delete(timeout?: number): Promise; - public edit(content: StringResolvable, options?: MessageEditOptions | RichEmbed): Promise; - public editCode(lang: string, content: StringResolvable): Promise; - public equals(message: Message, rawData: object): boolean; - public fetchWebhook(): Promise; - public isMemberMentioned(member: GuildMember | User): boolean; - public isMentioned(data: GuildChannel | User | Role | Snowflake): boolean; - public pin(): Promise; - public react(emoji: string | Emoji | ReactionEmoji): Promise; - public reply(content?: StringResolvable, options?: MessageOptions & { split: false }): Promise; - public reply(content?: StringResolvable, options?: MessageOptions): Promise; - public reply(options?: MessageOptions): Promise; - public suppressEmbeds(suppress?: boolean): Promise; - public toString(): string; - public unpin(): Promise; - } - - export class MessageAttachment { - constructor(message: Message, data: object); - public readonly client: Client; - public filename: string; - public filesize: number; - public height: number; - public id: Snowflake; - public message: Message; - public proxyURL: string; - public readonly spoiler: boolean; - public url: string; - public width: number; - } - - export class MessageCollector extends Collector { - constructor(channel: TextChannel | DMChannel | GroupDMChannel, filter: CollectorFilter, options?: MessageCollectorOptions); - public channel: Channel; - public options: MessageCollectorOptions; - public received: number; - - public cleanup(): void; - public handle(message: Message): CollectorHandler; - public postCheck(): string; - } - - export class MessageEmbed { - constructor(message: Message, data: object); - public author: MessageEmbedAuthor; - public readonly client: Client; - public color: number; - public readonly createdAt: Date; - public timestamp: number; - public description: string; - public fields: MessageEmbedField[]; - public footer: MessageEmbedFooter; - public readonly hexColor: string; - public image: MessageEmbedImage; - public message: Message; - public provider: MessageEmbedProvider; - public thumbnail: MessageEmbedThumbnail; - public title: string; - public type: string; - public url: string; - public video: MessageEmbedVideo; - } - - export class MessageEmbedAuthor { - constructor(embed: MessageEmbed, data: object); - public embed: MessageEmbed; - public iconURL: string; - public name: string; - public url: string; - } - - export class MessageEmbedField { - constructor(embed: MessageEmbed, data: object); - public embed: MessageEmbed; - public inline: boolean; - public name: string; - public value: string; - } - - export class MessageEmbedFooter { - constructor(embed: MessageEmbed, data: object); - public embed: MessageEmbed; - public iconURL: string; - public proxyIconURL: string; - public text: string; - } - - export class MessageEmbedImage { - constructor(embed: MessageEmbed, data: object); - public embed: MessageEmbed; - public height: number; - public proxyURL: string; - public url: string; - public width: number; - } - - export class MessageEmbedProvider { - constructor(embed: MessageEmbed, data: object); - public embed: MessageEmbed; - public name: string; - public url: string; - } - - export class MessageEmbedThumbnail { - constructor(embed: MessageEmbed, data: object); - public embed: MessageEmbed; - public height: number; - public proxyURL: string; - public url: string; - public width: number; - } - - export class MessageEmbedVideo { - constructor(embed: MessageEmbed, data: object); - public embed: MessageEmbed; - public height: number; - public url: string; - public width: number; - } - - export class MessageFlags extends BitField { - public static FLAGS: Record; - public static resolve(bit?: BitFieldResolvable): number; - } - - export class MessageMentions { - private _channels: Collection; - private _client: Client; - private _content: Message; - private _guild: Guild; - private _members: Collection; - - public readonly channels: Collection; - public crosspostedChannels: Collection; - public everyone: boolean; - public readonly members: Collection; - public roles: Collection; - public users: Collection; - - public static CHANNELS_PATTERN: RegExp; - public static EVERYONE_PATTERN: RegExp; - public static ROLES_PATTERN: RegExp; - public static USERS_PATTERN: RegExp; - } - - export class MessageReaction { - constructor(message: Message, emoji: object, count: number, me: boolean); - public count: number; - public readonly emoji: Emoji | ReactionEmoji; - public me: boolean; - public message: Message; - public users: Collection; - public fetchUsers(limit?: number, options?: { after?: number; before?: number }): Promise>; - public remove(user?: UserResolvable): Promise; - public removeAll(): Promise; - } - - export class NewsChannel extends TextChannel { - constructor(guild: Guild, data: object); - public rateLimitPerUser: 0; - } - - export class OAuth2Application { - constructor(client: Client, data: object); - public bot: object; - public botPublic: boolean; - public botRequireCodeGrant: boolean; - public readonly client: Client; - public readonly createdAt: Date; - public readonly createdTimestamp: number; - public description: string; - public flags: number; - public icon: string; - public iconURL: string; - public id: Snowflake; - public name: string; - public owner: User; - public redirectURIs: string[]; - public rpcApplicationState: boolean; - public rpcOrigins: string[]; - public secret: string; - public team: Team | null; - public reset(): OAuth2Application; - public toString(): string; - } - - export class PartialGuild { - constructor(client: Client, data: object); - public readonly client: Client; - public icon: string; - public id: Snowflake; - public name: string; - public splash: string; - } - - export class PartialGuildChannel { - constructor(client: Client, data: object); - public readonly client: Client; - public id: Snowflake; - public name: string; - public type: string; - } - - export class PermissionOverwrites { - constructor(guildChannel: GuildChannel, data: object); - public allow: number; - public allowed: Permissions; - public channel: GuildChannel; - public denied: Permissions; - public deny: number; - public id: Snowflake; - public type: string; - public delete(reason?: string): Promise; - } - - export class Permissions extends BitField { - constructor(permissions: PermissionResolvable); - constructor(member: GuildMember, permissions: PermissionResolvable); - - public bitfield: number; - public member: GuildMember; - public readonly raw: number; - public any(permissions: PermissionResolvable, checkAdmin?: boolean): boolean; - public has(permission: PermissionResolvable, checkAdmin?: boolean): boolean; - public hasPermission(permission: PermissionResolvable, explicit?: boolean): boolean; - public hasPermissions(permissions: PermissionResolvable, explicit?: boolean): boolean; - public missing(permissions: PermissionResolvable, checkAdmin?: boolean): PermissionString[]; - public missingPermissions(permissions: PermissionResolvable, checkAdmin?: boolean): PermissionResolvable; - public serialize(checkAdmin?: boolean): Required; - public toArray(checkAdmin?: boolean): PermissionString[]; - public valueOf(): number; - - public static ALL: number; - public static DEFAULT: number; - public static FLAGS: PermissionFlags; - public static resolve(permission?: PermissionResolvable): number; - } - - export class Presence { - constructor(data: object, client: Client); - public activities: Game[]; - public readonly client: Client; - public game: Game; - public status: PresenceStatusData; - public clientStatus: ClientPresenceStatusData; - public equals(presence: Presence): boolean; - } - - export class ReactionCollector extends Collector { - constructor(message: Message, filter: CollectorFilter, options?: ReactionCollectorOptions); - public message: Message; - public options: ReactionCollectorOptions; - public total: number; - public users: Collection; - - public cleanup(): void; - public handle(reaction: MessageReaction): CollectorHandler; - public postCheck(reaction: MessageReaction, user: User): string; - } - - export class ReactionEmoji { - constructor(reaction: MessageReaction, emoji: object); - public animated: boolean; - public readonly client: Client; - public readonly createdAt: number | null; - public readonly createdTimestamp: number | null; - public id: Snowflake; - public readonly identifier: string; - public name: string; - public reaction: MessageReaction; - public readonly url: string | null; - public toString(): string; - } - - class RequestHandler { - constructor(restManager: object); - public readonly globalLimit: boolean; - public queue: object[]; - public restManager: object; - public handle(): void; - public push(request: object): void; - } - - interface EmbedField { - name: string; - value: string; - inline: boolean; - } - - export class RichEmbed { - constructor(data?: RichEmbedOptions | MessageEmbed); - public author?: { name: string; url?: string; icon_url?: string; }; - public color?: number; - public description?: string; - public fields?: { name: string; value: string; inline?: boolean; }[]; - public file?: Attachment | string | FileOptions; - public files?: Array; - public footer?: { text?: string; icon_url?: string; }; - public image?: { url: string; proxy_url?: string; height?: number; width?: number; }; - public readonly length: number; - public thumbnail?: { url: string; height?: number; width?: number; }; - public timestamp?: Date; - public title?: string; - public url?: string; - public addBlankField(inline?: boolean): this; - public spliceFields(index: number, deleteCount: number, ...fields: EmbedFieldData[]): this; - public addField(name: StringResolvable, value: StringResolvable, inline?: boolean): this; - public attachFile(file: Attachment | FileOptions | string): this; - public attachFiles(file: Array): this; - public setAuthor(name: StringResolvable, icon?: string, url?: string): this; - public setColor(color: ColorResolvable): this; - public setDescription(description: StringResolvable): this; - public setFooter(text: StringResolvable, icon?: string): this; - public setImage(url: string): this; - public setThumbnail(url: string): this; - public setTimestamp(timestamp?: Date | number): this; - public setTitle(title: StringResolvable): this; - public setURL(url: string): this; - public static normalizeField(name: StringResolvable, value: StringResolvable, inline?: boolean): EmbedField; - } - - export class RichPresenceAssets { - constructor(game: Game, assets: object); - public largeImage: Snowflake; - public largeText: string; - public smallImage: Snowflake; - public smallText: string; - public readonly smallImageURL: string; - public readonly largeImageURL: string; - } - - export class Role { - constructor(guild: Guild, data: object); - public readonly calculatedPosition: number; - public readonly client: Client; - public color: number; - public readonly createdAt: Date; - public readonly createdTimestamp: number; - public deleted: boolean; - public readonly editable: boolean; - public guild: Guild; - public readonly hexColor: string; - public hoist: boolean; - public id: Snowflake; - public managed: boolean; - public readonly members: Collection; - public mentionable: boolean; - public name: string; - public permissions: number; - public position: number; - public comparePositionTo(role: Role): number; - public delete(reason?: string): Promise; - public edit(data: RoleData, reason?: string): Promise; - public equals(role: Role): boolean; - public hasPermission(permission: PermissionResolvable, explicit?: boolean, checkAdmin?: boolean): boolean; - public hasPermissions(permissions: PermissionResolvable, explicit?: boolean): boolean; - public serialize(): PermissionObject; - public setColor(color: string | number, reason?: string): Promise; - public setHoist(hoist: boolean, reason?: string): Promise; - public setMentionable(mentionable: boolean, reason?: string): Promise; - public setName(name: string, reason?: string): Promise; - public setPermissions(permissions: PermissionResolvable, reason?: string): Promise; - public setPosition(position: number, relative?: boolean): Promise; - public toString(): string; - - public static comparePositions(role1: Role, role2: Role): number; - } - - class SecretKey { - constructor(key: Uint8Array); - public key: Uint8Array; - } - - class SequentialRequestHandler extends RequestHandler { - constructor(restManager: object, endpoint: string); - public busy: boolean; - public endpoint: string; - public readonly globalLimit: boolean; - public queue: object[]; - public restManager: object; - public timeDifference: number; - public execute(item: object): Promise; - public handle(): void; - public push(request: object): void; - } - - export class Shard extends EventEmitter { - constructor(manager: ShardingManager, id: number, args?: string[]); - private _exitListener: Function; - private _handleExit(respawn?: boolean): void; - private _handleMessage(message: any): void; - - public env: object; - public id: string; - public manager: ShardingManager; - public process: ChildProcess; - public readonly: boolean; - public eval(script: string): Promise; - public fetchClientValue(prop: string): Promise; - public kill(): void; - public respawn(delay?: number): Promise; - public spawn(args?: string[], execArgv?: string[]): Promise; - public send(message: any): Promise; - - public on(event: 'death', listener: () => void): this; - public on(event: 'disconnect', listener: () => void): this; - public on(event: 'message', listener: (message: any) => void): this; - public on(event: 'ready', listener: () => void): this; - public on(event: 'reconnecting', listener: () => void): this; - public on(event: string, listener: Function): this; - - public once(event: 'death', listener: () => void): this; - public once(event: 'disconnect', listener: () => void): this; - public once(event: 'message', listener: (message: any) => void): this; - public once(event: 'ready', listener: () => void): this; - public once(event: 'reconnecting', listener: () => void): this; - public once(event: string, listener: Function): this; - } - - export class ShardClientUtil { - constructor(client: Client); - private _handleMessage(message: any): void; - private _respond(type: string, message: any): void; - - public readonly count: number; - public readonly id: number; - public broadcastEval(script: string): Promise; - public fetchClientValues(prop: string): Promise; - public send(message: any): Promise; - - public static singleton(client: Client): ShardClientUtil; - } - - export class ShardingManager extends EventEmitter { - constructor(file: string, options?: { - totalShards?: number | 'auto'; - respawn?: boolean; - shardArgs?: string[]; - token?: string; - }); - private _spawn(amount: number, delay: number): Promise>; - - public execArgv: string[]; - public file: string; - public respawn: boolean; - public shardArgs: string[]; - public shards: Collection; - public token: string; - public totalShards: number | string; - public broadcast(message: any): Promise; - public broadcastEval(script: string): Promise; - public createShard(id: number): Promise; - public fetchClientValues(prop: string): Promise; - public respawnAll(shardDelay?: number, respawnDelay?: number, waitForReady?: true, currentShardIndex?: number): Promise>; - public spawn(amount?: number, delay?: number): Promise>; - - public on(event: 'launch', listener: (shard: Shard) => void): this; - public on(event: 'message', listener: (shard: Shard, message: any) => void): this; - public on(event: string, listener: Function): this; - - public once(event: 'launch', listener: (shard: Shard) => void): this; - public once(event: 'message', listener: (shard: Shard, message: any) => void): this; - public once(event: string, listener: Function): this; - } - - export class SnowflakeUtil { - public static deconstruct(snowflake: Snowflake): DeconstructedSnowflake; - public static generate(timestamp?: number | Date): Snowflake; - } - - export class StoreChannel extends GuildChannel { - constructor(guild: Guild, data: object); - public nsfw: boolean; - } - - export class StreamDispatcher extends VolumeInterface { - constructor(player: AudioPlayer, stream: NodeJS.ReadableStream, streamOptions: StreamOptions); - public destroyed: boolean; - public readonly passes: number; - public paused: boolean; - public player: AudioPlayer; - public stream: ReadableStream | VoiceBroadcast; - public readonly time: number; - public readonly totalStreamTime: number; - public end(reason?: string): void; - public pause(): void; - public resume(): void; - public setBitrate(bitrate: number | 'auto'): void; - } - - export class SystemChannelFlags extends BitField { - public static FLAGS: Record; - public static resolve(bit?: BitFieldResolvable): number; - } - - export class Team { - constructor(client: Client, data: object); - public readonly client: Client; - public readonly createdAt: Date; - public readonly createdTimestamp: number; - public icon: string | null; - public readonly iconURL: string; - public id: Snowflake; - public members: Collection; - public name: string; - public readonly owner: TeamMember; - public ownerID: Snowflake | null; - - public toString(): string; - } - - export class TeamMember { - constructor(client: Client, team: Team, data: object); - public readonly client: Client; - public id: Snowflake; - public membershipState: MembershipStates; - public permissions: string[]; - public team: Team; - public user: User; - - public toString(): string; - } - - export class TextChannel extends TextBasedChannel(GuildChannel) { - constructor(guild: Guild, data: object); - public lastMessageID: string; - public readonly members: Collection; - public messages: Collection; - public nsfw: boolean; - public topic: string | null; - public rateLimitPerUser: number; - public setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise; - public createWebhook(name: string, avatar: BufferResolvable, reason?: string): Promise; - public fetchWebhooks(): Promise>; - public setNSFW(nsfw: boolean, reason?: string): Promise; - } - - export class User extends PartialTextBasedChannel() { - constructor(client: Client, data: object); - public avatar: string; - public readonly avatarURL: string; - public bot: boolean; - public readonly client: Client; - public readonly createdAt: Date; - public readonly createdTimestamp: number; - public readonly defaultAvatarURL: string; - public discriminator: string; - public readonly displayAvatarURL: string; - public readonly dmChannel: DMChannel; - public id: Snowflake; - public lastMessageID: string; - public readonly note: string; - public readonly presence: Presence; - public system?: boolean; - public readonly tag: string; - public username: string; - public addFriend(): Promise; - public block(): Promise; - public createDM(): Promise; - public deleteDM(): Promise; - public equals(user: User): boolean; - public fetchProfile(): Promise; - public removeFriend(): Promise; - public setNote(note: string): Promise; - public toString(): string; - public typingDurationIn(channel: ChannelResolvable): number; - public typingIn(channel: ChannelResolvable): boolean; - public typingSinceIn(channel: ChannelResolvable): Date; - public unblock(): Promise; - } - - export class UserConnection { - constructor(user: User, data: object); - public id: string; - public integrations: object[]; - public name: string; - public revoked: boolean; - public type: string; - public user: User; - } - - export class UserProfile { - constructor(user: User, data: object); - public readonly client: Client; - public connections: Collection; - public mutualGuilds: Collection; - public premium: boolean; - public premiumSince: Date; - public user: User; - } - - export class Util { - public static arraysEqual(a: any[], b: any[]): boolean; - public static cloneObject(obj: object): object; - public static convertToBuffer(ab: ArrayBuffer | string): Buffer; - public static delayFor(ms: number): Promise; - public static escapeMarkdown(text: string, onlyCodeBlock?: boolean, onlyInlineCode?: boolean): string; - public static fetchRecommendedShards(token: string, guildsPerShard?: number): Promise; - public static makeError(obj: { name: string, message: string, stack: string }): Error; - public static makePlainError(err: Error): object; - public static mergeDefault(def: object, given: object): object; - public static moveElementInArray(array: any[], element: any, newIndex: number, offset?: boolean): number; - public static parseEmoji(text: string): { animated: boolean; name: string; id: string; }; - public static splitMessage(text: string, options?: SplitOptions): string | string[]; - public static str2ab(str: string): ArrayBuffer; - } - - export class VoiceBroadcast extends EventEmitter { - constructor(client: Client); - public readonly client: Client; - public currentTranscoder: object; - public readonly dispatchers: StreamDispatcher[]; - public prism: object; - public destroy(): void; - public end(): void; - public pause(): void; - public playArbitraryInput(input: string, options?: StreamOptions): VoiceBroadcast; - public playConvertedStream(stream: ReadableStream, options?: StreamOptions): VoiceBroadcast; - public playFile(file: string, options?: StreamOptions): StreamDispatcher; - public playOpusStream(stream: ReadableStream, options?: StreamOptions): StreamDispatcher; - public playStream(stream: ReadableStream, options?: StreamOptions): VoiceBroadcast; - public resume(): void; - - public on(event: string, listener: Function): this; - public on(event: 'end', listener: () => void): this; - public on(event: 'error', listener: (error: Error) => void): this; - public on(event: 'subscribe', listener: (dispatcher: StreamDispatcher) => void): this; - public on(event: 'unsubscribe', listener: (dispatcher: StreamDispatcher) => void): this; - public on(event: 'warn', listener: (warning: string | Error) => void): this; - public on(event: string, listener: Function): this; - - public once(event: 'end', listener: () => void): this; - public once(event: 'error', listener: (error: Error) => void): this; - public once(event: 'subscribe', listener: (dispatcher: StreamDispatcher) => void): this; - public once(event: 'unsubscribe', listener: (dispatcher: StreamDispatcher) => void): this; - public once(event: 'warn', listener: (warning: string | Error) => void): this; - public once(event: string, listener: Function): this; - } - - export class VoiceChannel extends GuildChannel { - constructor(guild: Guild, data: object); - public bitrate: number; - public readonly connection: VoiceConnection; - public readonly full: boolean; - public readonly joinable: boolean; - public members: Collection; - public readonly speakable: boolean; - public userLimit: number; - public join(): Promise; - public leave(): void; - public setBitrate(bitrate: number, reason?: string): Promise; - public setUserLimit(userLimit: number, reason?: string): Promise; - } - - export class VoiceConnection extends EventEmitter { - constructor(voiceManager: ClientVoiceManager, channel: VoiceChannel); - private authentication: object; - private sockets: object; - private ssrcMap: Map; - private speakingTimeouts: Map; - private authenticate(): void; - private authenticateFailed(reason: string): void; - private checkAuthenticated(): void; - private cleanup(): void; - private connect(): void; - private onReady(data: object): void; - private onSessionDescription(mode: string, secret: string): void; - private onSpeaking(data: object): void; - private reconnect(token: string, endpoint: string): void; - private setSpeaking(value: boolean): void; - private updateChannel(channel: VoiceChannel): void; - - public channel: VoiceChannel; - public readonly client: Client; - public readonly dispatcher: StreamDispatcher; - public player: AudioPlayer; - public prism: object; - public receivers: VoiceReceiver[]; - public speaking: boolean; - public status: number; - public voiceManager: ClientVoiceManager; - public createReceiver(): VoiceReceiver; - public disconnect(): void; - public playArbitraryInput(input: string, options?: StreamOptions): StreamDispatcher; - public playBroadcast(broadcast: VoiceBroadcast, options?: StreamOptions): StreamDispatcher; - public playConvertedStream(stream: ReadableStream, options?: StreamOptions): StreamDispatcher; - public playFile(file: string, options?: StreamOptions): StreamDispatcher; - public playOpusStream(steam: ReadableStream, options?: StreamOptions): StreamDispatcher; - public playStream(stream: ReadableStream, options?: StreamOptions): StreamDispatcher; - public sendVoiceStateUpdate(options: object): void; - public setSessionID(sessionID: string): void; - public setTokenAndEndpoint(token: string, endpoint: string): void; - - public on(event: 'authenticated', listener: () => void): this; - public on(event: 'debug', listener: (message: string) => void): this; - public on(event: 'disconnect', listener: (error: Error) => void): this; - public on(event: 'error', listener: (error: Error) => void): this; - public on(event: 'failed', listener: (error: Error) => void): this; - public on(event: 'newSession', listener: () => void): this; - public on(event: 'ready', listener: () => void): this; - public on(event: 'reconnecting', listener: () => void): this; - public on(event: 'speaking', listener: (user: User, speaking: boolean) => void): this; - public on(event: 'warn', listener: (warning: string | Error) => void): this; - public on(event: string, listener: Function): this; - - public once(event: 'authenticated', listener: () => void): this; - public once(event: 'debug', listener: (message: string) => void): this; - public once(event: 'disconnect', listener: (error: Error) => void): this; - public once(event: 'error', listener: (error: Error) => void): this; - public once(event: 'failed', listener: (error: Error) => void): this; - public once(event: 'newSession', listener: () => void): this; - public once(event: 'ready', listener: () => void): this; - public once(event: 'reconnecting', listener: () => void): this; - public once(event: 'speaking', listener: (user: User, speaking: boolean) => void): this; - public once(event: 'warn', listener: (warning: string | Error) => void): this; - public once(event: string, listener: Function): this; - } - - class VoiceConnectionUDPClient extends EventEmitter { - constructor(voiceConnection: VoiceConnection); - public discordAddress: string; - public readonly discordPort: number; - public localAddress: string; - public localPort: string; - public socket: any; - public voiceConnection: VoiceConnection; - public findEndpointAddress(): Promise; - public send(packet: object): Promise; - } - - export class VoiceReceiver extends EventEmitter { - constructor(connection: VoiceConnection); - private stoppedSpeaking(user: User): void; - - public destroyed: boolean; - public voiceConnection: VoiceConnection; - public createOpusStream(user: UserResolvable): ReadableStream; - public createPCMStream(user: UserResolvable): ReadableStream; - public destroy(): void; - public recreate(): void; - - public on(event: 'opus', listener: (user: User, buffer: Buffer) => void): this; - public on(event: 'pcm', listener: (user: User, buffer: Buffer) => void): this; - public on(event: 'warn', listener: (reason: string, message: string) => void): this; - public on(event: string, listener: Function): this; - - public once(event: 'opus', listener: (user: User, buffer: Buffer) => void): this; - public once(event: 'pcm', listener: (user: User, buffer: Buffer) => void): this; - public once(event: 'warn', listener: (reason: string, message: string) => void): this; - public once(event: string, listener: Function): this; - } - - export class VoiceRegion { - constructor(data: object); - public custom: boolean; - public deprecated: boolean; - public id: string; - public name: string; - public optimal: boolean; - public sampleHostname: string; - public vip: boolean; - } - - class VoiceWebsocket extends EventEmitter { - constructor(voiceConnection: VoiceConnection); - public attempts: number; - public readonly client: Client; - public voiceConnection: VoiceConnection; - public ws: any; - public clearHeartbeat(): void; - public connect(): void; - public onClose(): void; - public onError(error: Error): void; - public onMessage(event: any): void; - public onOpen(): void; - public onPacket(packet: object): void; - public reset(): void; - public send(data: string): Promise; - public sendHeartbeat(): void; - public sendPacket(packet: object): Promise; - public setHeartbeat(interval: number): void; - - public on(event: 'ready', listener: (packet: object) => void): this; - public on(event: 'sessionDescription', listener: (encryptionMode: string, secretKey: SecretKey) => void): this; - public on(event: 'startSpeaking', listener: (data: object) => void): this; - public on(event: 'unknownPacket', listener: (packet: object) => void): this; - public on(event: 'warn', listener: (warn: string) => void): this; - public on(event: string, listener: Function): this; - - public once(event: 'ready', listener: (packet: object) => void): this; - public once(event: 'sessionDescription', listener: (encryptionMode: string, secretKey: SecretKey) => void): this; - public once(event: 'startSpeaking', listener: (data: object) => void): this; - public once(event: 'unknownPacket', listener: (packet: object) => void): this; - public once(event: 'warn', listener: (warn: string) => void): this; - public once(event: string, listener: Function): this; - } - - export class VolumeInterface extends EventEmitter { - constructor(object?: { volume: number }) - public readonly volume: number; - public readonly volumeDecibels: number; - public readonly volumeLogarithmic: number; - public setVolume(volume: number): void; - public setVolumeDecibels(db: number): void; - public setVolumeLogarithmic(value: number): void; - - public on(event: 'debug', listener: (information: string) => void): this; - public on(event: 'end', listener: (reason: string) => void): this; - public on(event: 'error', listener: (err: Error) => void): this; - public on(event: 'speaking', listener: (value: boolean) => void): this; - public on(event: 'start', listener: () => void): this; - public on(event: 'volumeChange', listener: (oldVolume: number, newVolume: number) => void): this; - public on(event: string, listener: Function): this; - - public once(event: 'debug', listener: (information: string) => void): this; - public once(event: 'end', listener: (reason: string) => void): this; - public once(event: 'error', listener: (err: Error) => void): this; - public once(event: 'speaking', listener: (value: boolean) => void): this; - public once(event: 'start', listener: () => void): this; - public once(event: 'volumeChange', listener: (oldVolume: number, newVolume: number) => void): this; - public once(event: string, listener: Function): this; - } - - export class Webhook { - constructor(client: Client, dataOrID: object | string, token: string); - public avatar: string | null; - public readonly avatarURL: string | null; - public channelID: string; - public readonly client: Client; - public guildID: string; - public id: Snowflake; - public name: string; - public owner: User | object; - public token: string | null; - public type: WebhookTypes; - public readonly url: string; - public delete(reason?: string): Promise; - public edit(name?: string, avatar?: BufferResolvable): Promise; - public edit(options?: WebhookEditOptions, reason?: string): Promise; - public send(content?: StringResolvable, options?: WebhookMessageOptions & { split: false } | RichEmbed | Attachment): Promise; - public send(content?: StringResolvable, options?: WebhookMessageOptions | RichEmbed | Attachment): Promise; - public send(options?: WebhookMessageOptions | RichEmbed | Attachment): Promise; - public sendCode(lang: string, content: StringResolvable, options?: WebhookMessageOptions): Promise; - public sendFile(attachment: BufferResolvable, name?: string, content?: StringResolvable, options?: WebhookMessageOptions): Promise; - public sendMessage(content?: StringResolvable, options?: WebhookMessageOptions): Promise; - public sendMessage(options?: WebhookMessageOptions): Promise; - public sendSlackMessage(body: object): Promise; - } - - export class WebhookClient extends Webhook { - constructor(id: string, token: string, options?: ClientOptions); - private _intervals: Set; - private _timeouts: Set; - private resolver: ClientDataResolver; - private rest: object; - public token: string; - - public options: ClientOptions; - public clearInterval(interval: NodeJS.Timer): void; - public clearTimeout(timeout: NodeJS.Timer): void; - public destroy(): void; - public setInterval(fn: Function, delay: number, ...args: any[]): NodeJS.Timer; - public setTimeout(fn: Function, delay: number, ...args: any[]): NodeJS.Timer; - } - -//#endregion - -//#region Mixins - - // Model the TextBasedChannel mixin system, allowing application of these fields - // to the classes that use these methods without having to manually add them - // to each of those classes - - type Constructable = new (...args: any[]) => T; - const PartialTextBasedChannel: (Base?: Constructable) => Constructable; - const TextBasedChannel: (Base?: Constructable) => Constructable; - - type PartialTextBasedChannelFields = { - lastMessage: Message; - acknowledge(): Promise; - send(content?: StringResolvable, options?: MessageOptions & { split: false } | RichEmbed | Attachment): Promise; - send(content?: StringResolvable, options?: MessageOptions | RichEmbed | Attachment): Promise; - send(options?: MessageOptions | RichEmbed | Attachment): Promise; - sendCode(lang: string, content: StringResolvable, options?: MessageOptions): Promise; - sendEmbed(embed: RichEmbed | RichEmbedOptions, content?: string, options?: MessageOptions): Promise; - sendEmbed(embed: RichEmbed | RichEmbedOptions, options?: MessageOptions): Promise; - sendFile(attachment: BufferResolvable, name?: string, content?: StringResolvable, options?: MessageOptions): Promise; - sendMessage(content?: string, options?: MessageOptions): Promise; - sendMessage(options?: MessageOptions): Promise; - }; - - type TextBasedChannelFields = { - lastPinTimestamp: number; - readonly lastPinAt: Date; - typing: boolean; - typingCount: number; - awaitMessages(filter: CollectorFilter, options?: AwaitMessagesOptions): Promise>; - bulkDelete(messages: Collection | Message[] | Snowflake[] | number, filterOld?: boolean): Promise>; - createCollector(filter: CollectorFilter, options?: MessageCollectorOptions): MessageCollector; - createMessageCollector(filter: CollectorFilter, options?: MessageCollectorOptions): MessageCollector; - fetchMessage(messageID: string): Promise; - fetchMessages(options?: ChannelLogsQueryOptions): Promise>; - fetchPinnedMessages(): Promise>; - search(options?: MessageSearchOptions): Promise; - startTyping(count?: number): void; - stopTyping(force?: boolean): void; - } & PartialTextBasedChannelFields; - -//#endregion - -//#region Typedefs - - type ActivityType = 'PLAYING' - | 'STREAMING' - | 'LISTENING' - | 'WATCHING' - | 'CUSTOM_STATUS'; - - type AddGuildMemberOptions = { - accessToken: String; - nick?: string; - roles?: Collection | Role[] | string[]; - mute?: boolean; - deaf?: boolean; - }; - - type AuditLogChange = { - key: string; - old?: any; - new?: any; - }; - - type AwaitMessagesOptions = MessageCollectorOptions & { errors?: string[] }; - - type AwaitReactionsOptions = ReactionCollectorOptions & { errors?: string[] }; - - type BanInfo = { - user: User; - reason: string | null; - }; - - type BanOptions = { - days?: number; - reason?: string; - }; - - type Base64Resolvable = Buffer | Base64String; - - type Base64String = string; - - type BitFieldResolvable = RecursiveArray>> | T | number | Readonly>; - - type BufferResolvable = Buffer | string; - - type ChannelCreationOverwrites = { - allow?: PermissionResolvable; - deny?: PermissionResolvable; - allowed?: PermissionResolvable; - denied?: PermissionResolvable; - id: RoleResolvable | UserResolvable; - }; - - type ChannelData = { - type?: GuildChannelType; - name?: string; - position?: number; - topic?: string; - nsfw?: boolean; - bitrate?: number; - userLimit?: number; - parent?: ChannelResolvable; - permissionOverwrites?: PermissionOverwrites[] | ChannelCreationOverwrites[]; - rateLimitPerUser?: number; - reason?: string; - }; - - type ChannelLogsQueryOptions = { - limit?: number - before?: Snowflake - after?: Snowflake - around?: Snowflake - }; - - type ChannelPosition = { - channel: ChannelResolvable; - position: number; - }; - - type ChannelResolvable = Channel | Guild | Message | Snowflake; - - type ClientOptions = { - apiRequestMethod?: string; - shardId?: number; - shardCount?: number; - messageCacheMaxSize?: number; - messageCacheLifetime?: number; - messageSweepInterval?: number; - fetchAllMembers?: boolean; - disableEveryone?: boolean; - sync?: boolean; - restWsBridgeTimeout?: number; - restTimeOffset?: number; - retryLimit?: number; - disabledEvents?: WSEventType[]; - ws?: WebSocketOptions; - http?: HTTPOptions; - }; - - type CollectorHandler = { key: K, value: V }; - type CollectorFilter = (...args: any[]) => boolean; - type CollectorOptions = { - time?: number; - idle?: number; - }; - - type ColorResolvable = ('DEFAULT' - | 'WHITE' - | 'AQUA' - | 'GREEN' - | 'BLUE' - | 'PURPLE' - | 'LUMINOUS_VIVID_PINK' - | 'GOLD' - | 'ORANGE' - | 'RED' - | 'GREY' - | 'DARKER_GREY' - | 'NAVY' - | 'DARK_AQUA' - | 'DARK_GREEN' - | 'DARK_BLUE' - | 'DARK_PURPLE' - | ' DARK_VIVID_PINK' - | 'DARK_GOLD' - | 'DARK_ORANGE' - | 'DARK_RED' - | 'DARK_GREY' - | 'LIGHT_GREY' - | 'DARK_NAVY' - | 'RANDOM') - | [number, number, number] - | number - | string; - - type CrosspostedChannel = { - channelID: Snowflake; - guildID: Snowflake; - type: Channel["type"] | 'unknown'; - name: string; - }; - - type DeconstructedSnowflake = { - timestamp: number; - date: Date; - workerID: number; - processID: number; - increment: number; - binary: string; - }; - - type DefaultMessageNotifications = 'ALL' - | 'MENTIONS'; - - type EmojiEditData = { - name?: string; - roles?: Collection | Role[] | Snowflake[]; - }; - - type EmojiIdentifierResolvable = string | Emoji | ReactionEmoji; - - type FileOptions = { - attachment: BufferResolvable; - name?: string; - }; - - type GroupDMRecipientOptions = { - user?: UserResolvable | Snowflake; - accessToken?: string; - nick?: string; - }; - - type GuildAuditLogsAction = keyof GuildAuditLogsActions; - - type GuildAuditLogsActions = { - ALL?: null; - GUILD_UPDATE?: number; - CHANNEL_CREATE?: number; - CHANNEL_UPDATE?: number; - CHANNEL_DELETE?: number; - CHANNEL_OVERWRITE_CREATE?: number; - CHANNEL_OVERWRITE_UPDATE?: number; - CHANNEL_OVERWRITE_DELETE?: number; - MEMBER_KICK?: number; - MEMBER_PRUNE?: number; - MEMBER_BAN_ADD?: number; - MEMBER_BAN_REMOVE?: number; - MEMBER_UPDATE?: number; - MEMBER_ROLE_UPDATE?: number; - MEMBER_MOVE?: number; - MEMBER_DISCONNECT?: number; - BOT_ADD?: number; - ROLE_CREATE?: number; - ROLE_UPDATE?: number; - ROLE_DELETE?: number; - INVITE_CREATE?: number; - INVITE_UPDATE?: number; - INVITE_DELETE?: number; - WEBHOOK_CREATE?: number; - WEBHOOK_UPDATE?: number; - WEBHOOK_DELETE?: number; - EMOJI_CREATE?: number; - EMOJI_UPDATE?: number; - EMOJI_DELETE?: number; - MESSAGE_DELETE?: number; - MESSAGE_BULK_DELETE?: number; - MESSAGE_PIN?: number; - MESSAGE_UNPIN?: number; - INTEGRATION_CREATE?: number; - INTEGRATION_UPDATE?: number; - INTEGRATION_DELETE?: number; - }; - - type GuildAuditLogsActionType = 'CREATE' - | 'DELETE' - | 'UPDATE' - | 'ALL'; - - type GuildAuditLogsFetchOptions = { - before?: Snowflake | GuildAuditLogsEntry; - after?: Snowflake | GuildAuditLogsEntry; - limit?: number; - user?: UserResolvable; - type?: string | number; - }; - - type GuildAuditLogsTarget = keyof GuildAuditLogsTargets; - - type GuildAuditLogsTargets = { - ALL?: string; - GUILD?: string; - CHANNEL?: string; - USER?: string; - ROLE?: string; - INVITE?: string; - WEBHOOK?: string; - EMOJI?: string; - MESSAGE?: string; - INTEGRATION?: string; - UNKNOWN?: string; - }; - - type GuildChannelCloneOptions = { - name?: string; - permissionOverwrites?: ChannelCreationOverwrites[] | Collection; - type?: GuildChannelType; - topic?: string; - nsfw?: boolean; - bitrate?: number; - userLimit?: number; - rateLimitPerUser?: number; - parent?: ChannelResolvable; - reason?: string; - } - - type GuildChannelMessageNotifications = MessageNotifications - & 'INHERIT'; - - type GuildChannelType = 'category' | 'text' | 'voice' | 'news' | 'store'; - - type GuildEditData = { - name?: string; - region?: string; - verificationLevel?: number; - explicitContentFilter?: number; - afkChannel?: ChannelResolvable; - systemChannel?: ChannelResolvable; - systemChannelFlags?: SystemChannelFlagsResolvable; - afkTimeout?: number; - banner?: Base64Resolvable; - icon?: Base64Resolvable; - owner?: GuildMemberResolvable; - splash?: Base64Resolvable; - }; - - type GuildEmbedData = { - enabled: boolean; - channel: ChannelResolvable; - }; - - type GuildMemberEditData = { - nick?: string; - roles?: Collection | Role[] | Snowflake[]; - mute?: boolean; - deaf?: boolean; - channel?: ChannelResolvable | null; - }; - - type GuildMemberResolvable = GuildMember | User; - - type GuildResolvable = Guild | Snowflake; - - type HTTPOptions = { - version?: number; - host?: string; - cdn?: string; - }; - - type IntegrationData = { - id: string; - type: string; - } - - type IntegrationEditData = { - expireBehavior?: number; - expireGracePeriod?: number; - } - - type IntegrationAccount = { - id: string; - number: string; - } - - type InviteOptions = { - temporary?: boolean; - maxAge?: number; - maxUses?: number; - unique?: boolean; - }; - - type InviteResolvable = string; - - type MembershipStates = 'INVITED' - | 'ACCEPTED'; - - type MessageCollectorOptions = CollectorOptions & { - max?: number; - maxMatches?: number; - }; - - type MessageEditOptions = { - embed?: RichEmbedOptions; - code?: string | boolean; - flags?: BitFieldResolvable; - }; - - type MessageFlagsString = 'CROSSPOSTED' - | 'IS_CROSSPOST' - | 'SUPRRESS_EMBEDS' - | 'SOURCE_MESSAGE_DELETED' - | 'URGENT'; - - type MessageNotifications = 'EVERYTHING' - | 'MENTIONS' - | 'NOTHING'; - - type MessageOptions = { - tts?: boolean; - nonce?: string; - embed?: RichEmbed | RichEmbedOptions, - disableEveryone?: boolean; - file?: FileOptions | string; - files?: (FileOptions | BufferResolvable | Attachment)[]; - code?: string | boolean; - split?: boolean | SplitOptions; - reply?: UserResolvable; - }; - - type MessageSearchOptions = { - content?: string; - maxID?: Snowflake; - minID?: Snowflake; - has?: 'link' - | 'embed' - | 'file' - | 'video' - | 'image' - | 'sound' - | '-link' - | '-embed' - | '-file' - | '-video' - | '-image' - | '-sound'; - channel?: ChannelResolvable; - author?: UserResolvable; - authorType?: 'user' - | 'bot' - | 'webhook' - | '-user' - | '-bot' - | '-webhook'; - sortBy?: 'relevant' | 'recent'; - sortOrder?: 'asc' | 'desc'; - contextSize?: number; - limit?: number; - offset?: number; - mentions?: UserResolvable; - mentionsEveryone?: boolean; - linkHostname?: string; - embedProvider?: string; - embedType?: 'image' | 'video' | 'url' | 'rich'; - attachmentFilename?: string; - attachmentExtension?: string; - before?: Date; - after?: Date; - during?: Date; - nsfw?: boolean; - }; - - type MessageReference = { - channelID: Snowflake; - guildID: Snowflake | null; - messageID: Snowflake | null; - }; - - type MessageSearchResult = { - totalResults: number; - messages: Message[][]; - }; - - type ActivityFlags = { - INSTANCE?: number; - JOIN?: number; - SPECTATE?: number; - JOIN_REQUEST?: number; - SYNC?: number; - PLAY?: number; - }; - - type PermissionFlags = { - ADMINISTRATOR?: number; - CREATE_INSTANT_INVITE?: number; - KICK_MEMBERS?: number; - BAN_MEMBERS?: number; - MANAGE_CHANNELS?: number; - MANAGE_GUILD?: number; - ADD_REACTIONS?: number; - VIEW_AUDIT_LOG?: number; - PRIORITY_SPEAKER?: number; - STREAM?: number; - VIEW_CHANNEL?: number; - READ_MESSAGES?: number; - SEND_MESSAGES?: number; - SEND_TTS_MESSAGES?: number; - MANAGE_MESSAGES?: number; - EMBED_LINKS?: number; - ATTACH_FILES?: number; - READ_MESSAGE_HISTORY?: number; - MENTION_EVERYONE?: number; - USE_EXTERNAL_EMOJIS?: number; - EXTERNAL_EMOJIS?: number; - CONNECT?: number; - SPEAK?: number; - MUTE_MEMBERS?: number; - DEAFEN_MEMBERS?: number; - MOVE_MEMBERS?: number; - USE_VAD?: number; - CHANGE_NICKNAME?: number; - MANAGE_NICKNAMES?: number; - MANAGE_ROLES?: number; - MANAGE_ROLES_OR_PERMISSIONS?: number; - MANAGE_WEBHOOKS?: number; - MANAGE_EMOJIS?: number; - }; - - type PermissionObject = { - ADMINISTRATOR?: boolean; - CREATE_INSTANT_INVITE?: boolean; - KICK_MEMBERS?: boolean; - BAN_MEMBERS?: boolean; - MANAGE_CHANNELS?: boolean; - MANAGE_GUILD?: boolean; - ADD_REACTIONS?: boolean; - VIEW_AUDIT_LOG?: boolean; - PRIORITY_SPEAKER?: boolean; - STREAM?: boolean; - VIEW_CHANNEL?: boolean; - READ_MESSAGES?: boolean; - SEND_MESSAGES?: boolean; - SEND_TTS_MESSAGES?: boolean; - MANAGE_MESSAGES?: boolean; - EMBED_LINKS?: boolean; - ATTACH_FILES?: boolean; - READ_MESSAGE_HISTORY?: boolean; - MENTION_EVERYONE?: boolean; - USE_EXTERNAL_EMOJIS?: boolean; - EXTERNAL_EMOJIS?: boolean; - CONNECT?: boolean; - SPEAK?: boolean; - MUTE_MEMBERS?: boolean; - DEAFEN_MEMBERS?: boolean; - MOVE_MEMBERS?: boolean; - USE_VAD?: boolean; - CHANGE_NICKNAME?: boolean; - MANAGE_NICKNAMES?: boolean; - MANAGE_ROLES?: boolean; - MANAGE_ROLES_OR_PERMISSIONS?: boolean; - MANAGE_WEBHOOKS?: boolean; - MANAGE_EMOJIS?: boolean; - }; - - type PermissionString = 'ADMINISTRATOR' - | 'CREATE_INSTANT_INVITE' - | 'KICK_MEMBERS' - | 'BAN_MEMBERS' - | 'MANAGE_CHANNELS' - | 'MANAGE_GUILD' - | 'ADD_REACTIONS' - | 'VIEW_AUDIT_LOG' - | 'PRIORITY_SPEAKER' - | 'STREAM' - | 'VIEW_CHANNEL' - | 'READ_MESSAGES' - | 'SEND_MESSAGES' - | 'SEND_TTS_MESSAGES' - | 'MANAGE_MESSAGES' - | 'EMBED_LINKS' - | 'ATTACH_FILES' - | 'READ_MESSAGE_HISTORY' - | 'MENTION_EVERYONE' - | 'USE_EXTERNAL_EMOJIS' - | 'EXTERNAL_EMOJIS' - | 'CONNECT' - | 'SPEAK' - | 'MUTE_MEMBERS' - | 'DEAFEN_MEMBERS' - | 'MOVE_MEMBERS' - | 'USE_VAD' - | 'CHANGE_NICKNAME' - | 'MANAGE_NICKNAMES' - | 'MANAGE_ROLES' - | 'MANAGE_ROLES_OR_PERMISSIONS' - | 'MANAGE_WEBHOOKS' - | 'MANAGE_EMOJIS'; - - type PermissionOverwriteOptions = PermissionObject; - - interface RecursiveArray extends Array> { } - - interface EmbedFieldData { - name: StringResolvable; - value: StringResolvable; - inline?: boolean; - } - - type PermissionResolvable = BitFieldResolvable - - type PremiumTier = number; - - type PresenceData = { - status?: PresenceStatus; - afk?: boolean; - game?: { - name?: string; - url?: string; - type?: ActivityType; - } | null; - }; - - type ClientPresenceStatus = 'online' | 'idle' | 'dnd'; - - type PresenceStatus = ClientPresenceStatus | 'invisible'; - type PresenceStatusData = ClientPresenceStatus | 'offline'; - - type ClientPresenceStatusData = { - web?: ClientPresenceStatus; - mobile?: ClientPresenceStatus; - desktop?: ClientPresenceStatus; - }; - - type RateLimitInfo = { - limit: number; - timeDifference: number; - method: string; - path: string; - }; - - type ReactionCollectorOptions = CollectorOptions & { - max?: number; - maxEmojis?: number; - maxUsers?: number; - }; - - type RichEmbedOptions = { - title?: string; - description?: string; - url?: string; - timestamp?: Date; - color?: number | string; - fields?: { name: string; value: string; inline?: boolean; }[]; - file?: Attachment | string | FileOptions; - author?: { name: string; url?: string; icon_url?: string; }; - thumbnail?: { url: string; height?: number; width?: number; }; - image?: { url: string; proxy_url?: string; height?: number; width?: number; }; - video?: { url: string; height: number; width: number; }; - footer?: { text?: string; icon_url?: string; }; - }; - - type RoleData = { - name?: string; - color?: ColorResolvable; - hoist?: boolean; - position?: number; - permissions?: PermissionResolvable; - mentionable?: boolean; - }; - - type RolePosition = { - role: RoleResolvable; - position: number; - }; - - type RoleResolvable = Role | string; - - type Snowflake = string; - - type SplitOptions = { - maxLength?: number; - char?: string; - prepend?: string; - append?: string; - }; - - type Status = number; - - type StreamOptions = { - seek?: number; - volume?: number; - passes?: number; - bitrate?: number | 'auto'; - }; - - type StringResolvable = string | string[] | any; - - type SystemChannelFlagsString = 'WELCOME_MESSAGE_DISABLED' | 'BOOST_MESSAGE_DISABLED'; - - type SystemChannelFlagsResolvable = BitFieldResolvable; - - type UserResolvable = User | Snowflake | Message | Guild | GuildMember; - - type VoiceStatus = number; - - type WebhookEditOptions = { - name?: string; - avatar?: BufferResolvable; - channel?: ChannelResolvable; - }; - - type WebhookMessageOptions = { - username?: string; - avatarURL?: string; - tts?: boolean; - nonce?: string; - embeds?: (RichEmbed | object)[]; - disableEveryone?: boolean; - file?: FileOptions | BufferResolvable | Attachment; - files?: (FileOptions | BufferResolvable | Attachment)[]; - code?: string | boolean; - split?: boolean | SplitOptions; - }; - - type WebhookTypes = 'Incoming' | 'Channel Follower'; - - type WebSocketOptions = { - large_threshold?: number; - compress?: boolean; - }; - - type WSEventType = 'READY' - | 'RESUMED' - | 'GUILD_SYNC' - | 'GUILD_CREATE' - | 'GUILD_DELETE' - | 'GUILD_UPDATE' - | 'GUILD_MEMBER_ADD' - | 'GUILD_MEMBER_REMOVE' - | 'GUILD_MEMBER_UPDATE' - | 'GUILD_MEMBERS_CHUNK' - | 'GUILD_INTEGRATIONS_UPDATE' - | 'GUILD_ROLE_CREATE' - | 'GUILD_ROLE_DELETE' - | 'GUILD_ROLE_UPDATE' - | 'GUILD_BAN_ADD' - | 'GUILD_BAN_REMOVE' - | 'CHANNEL_CREATE' - | 'CHANNEL_DELETE' - | 'CHANNEL_UPDATE' - | 'CHANNEL_PINS_UPDATE' - | 'MESSAGE_CREATE' - | 'MESSAGE_DELETE' - | 'MESSAGE_UPDATE' - | 'MESSAGE_DELETE_BULK' - | 'MESSAGE_REACTION_ADD' - | 'MESSAGE_REACTION_REMOVE' - | 'MESSAGE_REACTION_REMOVE_ALL' - | 'USER_UPDATE' - | 'USER_NOTE_UPDATE' - | 'USER_SETTINGS_UPDATE' - | 'USER_GUILD_SETTINGS_UPDATE' - | 'PRESENCE_UPDATE' - | 'VOICE_STATE_UPDATE' - | 'TYPING_START' - | 'VOICE_SERVER_UPDATE' - | 'WEBHOOKS_UPDATE' - | 'RELATIONSHIP_ADD' - | 'RELATIONSHIP_REMOVE'; - -//#endregion + import BaseCollection from '@discordjs/collection'; + import { EventEmitter } from 'events'; + import { Stream, Readable, Writable } from 'stream'; + import { ChildProcess } from 'child_process'; + import { PathLike } from 'fs'; + import * as WebSocket from 'ws'; + + export const version: string; + + //#region Classes + + export class Activity { + constructor(presence: Presence, data?: object); + public applicationID: Snowflake | null; + public assets: RichPresenceAssets | null; + public readonly createdAt: Date; + public createdTimestamp: number; + public details: string | null; + public emoji: Emoji | null; + public name: string; + public party: { + id: string | null; + size: [number, number]; + } | null; + public state: string | null; + public timestamps: { + start: Date | null; + end: Date | null; + } | null; + public type: ActivityType; + public url: string | null; + public equals(activity: Activity): boolean; + } + + export class ActivityFlags extends BitField { + public static FLAGS: Record; + public static resolve(bit?: BitFieldResolvable): number; + } + + export class APIMessage { + constructor(target: MessageTarget, options: MessageOptions | WebhookMessageOptions); + public data: object | null; + public readonly isUser: boolean; + public readonly isWebhook: boolean; + public files: object[] | null; + public options: MessageOptions | WebhookMessageOptions; + public target: MessageTarget; + + public static create( + target: MessageTarget, + content?: StringResolvable, + options?: MessageOptions | WebhookMessageOptions | MessageAdditions, + extra?: MessageOptions | WebhookMessageOptions, + ): APIMessage; + public static partitionMessageAdditions( + items: (MessageEmbed | MessageAttachment)[], + ): [MessageEmbed[], MessageAttachment[]]; + public static resolveFile(fileLike: BufferResolvable | Stream | FileOptions | MessageAttachment): Promise; + public static transformOptions( + content: StringResolvable, + options: MessageOptions | WebhookMessageOptions | MessageAdditions, + extra?: MessageOptions | WebhookMessageOptions, + isWebhook?: boolean, + ): MessageOptions | WebhookMessageOptions; + + public makeContent(): string | string[] | undefined; + public resolve(): Promise; + public resolveData(): this; + public resolveFiles(): Promise; + public split(): APIMessage[]; + } + + export class Base { + constructor(client: Client); + public readonly client: Client; + public toJSON(...props: { [key: string]: boolean | string }[]): object; + public valueOf(): string; + } + + export class BaseClient extends EventEmitter { + constructor(options?: ClientOptions); + private _timeouts: Set; + private _intervals: Set; + private _immediates: Set; + private readonly api: object; + private rest: object; + + public options: ClientOptions; + public clearInterval(interval: NodeJS.Timer): void; + public clearTimeout(timeout: NodeJS.Timer): void; + public clearImmediate(timeout: NodeJS.Immediate): void; + public destroy(): void; + public setInterval(fn: (...args: any[]) => void, delay: number, ...args: any[]): NodeJS.Timer; + public setTimeout(fn: (...args: any[]) => void, delay: number, ...args: any[]): NodeJS.Timer; + public setImmediate(fn: (...args: any[]) => void, ...args: any[]): NodeJS.Immediate; + public toJSON(...props: { [key: string]: boolean | string }[]): object; + } + + class BroadcastDispatcher extends VolumeMixin(StreamDispatcher) { + public broadcast: VoiceBroadcast; + } + + export class BitField { + constructor(bits?: BitFieldResolvable); + public bitfield: number; + public add(...bits: BitFieldResolvable[]): BitField; + public any(bit: BitFieldResolvable): boolean; + public equals(bit: BitFieldResolvable): boolean; + public freeze(): Readonly>; + public has(bit: BitFieldResolvable): boolean; + public missing(bits: BitFieldResolvable, ...hasParam: readonly unknown[]): S[]; + public remove(...bits: BitFieldResolvable[]): BitField; + public serialize(...hasParam: readonly unknown[]): Record; + public toArray(...hasParam: readonly unknown[]): S[]; + public toJSON(): number; + public valueOf(): number; + public [Symbol.iterator](): IterableIterator; + public static FLAGS: object; + public static resolve(bit?: BitFieldResolvable): number; + } + + export class CategoryChannel extends GuildChannel { + public readonly children: Collection; + public type: 'category'; + } + + export class Channel extends Base { + constructor(client: Client, data?: object); + public readonly createdAt: Date; + public readonly createdTimestamp: number; + public deleted: boolean; + public id: Snowflake; + public type: keyof typeof ChannelType; + public delete(reason?: string): Promise; + public fetch(): Promise; + public toString(): string; + } + + export class Client extends BaseClient { + constructor(options?: ClientOptions); + private actions: object; + private _eval(script: string): any; + private _validateOptions(options?: ClientOptions): void; + + public channels: ChannelManager; + public readonly emojis: GuildEmojiManager; + public guilds: GuildManager; + public readyAt: Date | null; + public readonly readyTimestamp: number | null; + public shard: ShardClientUtil | null; + public token: string | null; + public readonly uptime: number | null; + public user: ClientUser | null; + public users: UserManager; + public voice: ClientVoiceManager | null; + public ws: WebSocketManager; + public destroy(): void; + public fetchApplication(): Promise; + public fetchInvite(invite: InviteResolvable): Promise; + public fetchVoiceRegions(): Promise>; + public fetchWebhook(id: Snowflake, token?: string): Promise; + public generateInvite(permissions?: PermissionResolvable): Promise; + public login(token?: string): Promise; + public sweepMessages(lifetime?: number): number; + public toJSON(): object; + + public on(event: 'channelCreate' | 'channelDelete', listener: (channel: Channel | PartialChannel) => void): this; + public on(event: 'channelPinsUpdate', listener: (channel: Channel | PartialChannel, time: Date) => void): this; + public on( + event: 'channelUpdate', + listener: (oldChannel: Channel | PartialChannel, newChannel: Channel | PartialChannel) => void, + ): this; + public on(event: 'debug' | 'warn', listener: (info: string) => void): this; + public on(event: 'disconnect', listener: (event: any, shardID: number) => void): this; + public on(event: 'emojiCreate' | 'emojiDelete', listener: (emoji: GuildEmoji) => void): this; + public on(event: 'emojiUpdate', listener: (oldEmoji: GuildEmoji, newEmoji: GuildEmoji) => void): this; + public on(event: 'error', listener: (error: Error) => void): this; + public on( + event: 'guildBanAdd' | 'guildBanRemove', + listener: (guild: Guild, user: User | PartialUser) => void, + ): this; + public on( + event: 'guildCreate' | 'guildDelete' | 'guildUnavailable' | 'guildIntegrationsUpdate', + listener: (guild: Guild) => void, + ): this; + public on( + event: 'guildMemberAdd' | 'guildMemberAvailable' | 'guildMemberRemove', + listener: (member: GuildMember | PartialGuildMember) => void, + ): this; + public on( + event: 'guildMembersChunk', + listener: (members: Collection, guild: Guild) => void, + ): this; + public on( + event: 'guildMemberSpeaking', + listener: (member: GuildMember | PartialGuildMember, speaking: Readonly) => void, + ): this; + public on( + event: 'guildMemberUpdate', + listener: (oldMember: GuildMember | PartialGuildMember, newMember: GuildMember | PartialGuildMember) => void, + ): this; + public on(event: 'guildUpdate', listener: (oldGuild: Guild, newGuild: Guild) => void): this; + public on(event: 'inviteCreate' | 'inviteDelete', listener: (invite: Invite) => void): this; + public on( + event: 'message' | 'messageDelete' | 'messageReactionRemoveAll', + listener: (message: Message | PartialMessage) => void, + ): this; + public on(event: 'messageReactionRemoveEmoji', listener: (reaction: MessageReaction) => void): this; + public on( + event: 'messageDeleteBulk', + listener: (messages: Collection) => void, + ): this; + public on( + event: 'messageReactionAdd' | 'messageReactionRemove', + listener: (messageReaction: MessageReaction, user: User | PartialUser) => void, + ): this; + public on( + event: 'messageUpdate', + listener: (oldMessage: Message | PartialMessage, newMessage: Message | PartialMessage) => void, + ): this; + public on( + event: 'presenceUpdate', + listener: (oldPresence: Presence | undefined, newPresence: Presence) => void, + ): this; + public on(event: 'rateLimit', listener: (rateLimitData: RateLimitData) => void): this; + public on(event: 'ready' | 'invalidated', listener: () => void): this; + public on(event: 'roleCreate' | 'roleDelete', listener: (role: Role) => void): this; + public on(event: 'roleUpdate', listener: (oldRole: Role, newRole: Role) => void): this; + public on( + event: 'typingStart' | 'typingStop', + listener: (channel: Channel | PartialChannel, user: User | PartialUser) => void, + ): this; + public on(event: 'userUpdate', listener: (oldUser: User | PartialUser, newUser: User | PartialUser) => void): this; + public on(event: 'voiceStateUpdate', listener: (oldState: VoiceState, newState: VoiceState) => void): this; + public on(event: 'webhookUpdate', listener: (channel: TextChannel) => void): this; + public on(event: 'shardDisconnect', listener: (event: CloseEvent, id: number) => void): this; + public on(event: 'shardError', listener: (error: Error, id: number) => void): this; + public on(event: 'shardReady' | 'shardReconnecting', listener: (id: number) => void): this; + public on(event: 'shardResume', listener: (id: number, replayed: number) => void): this; + public on(event: string, listener: (...args: any[]) => void): this; + + public once(event: 'channelCreate' | 'channelDelete', listener: (channel: Channel | PartialChannel) => void): this; + public once(event: 'channelPinsUpdate', listener: (channel: Channel | PartialChannel, time: Date) => void): this; + public once( + event: 'channelUpdate', + listener: (oldChannel: Channel | PartialChannel, newChannel: Channel | PartialChannel) => void, + ): this; + public once(event: 'debug' | 'warn', listener: (info: string) => void): this; + public once(event: 'disconnect', listener: (event: any, shardID: number) => void): this; + public once(event: 'emojiCreate' | 'emojiDelete', listener: (emoji: GuildEmoji) => void): this; + public once(event: 'emojiUpdate', listener: (oldEmoji: GuildEmoji, newEmoji: GuildEmoji) => void): this; + public once(event: 'error', listener: (error: Error) => void): this; + public once( + event: 'guildBanAdd' | 'guildBanRemove', + listener: (guild: Guild, user: User | PartialUser) => void, + ): this; + public once( + event: 'guildCreate' | 'guildDelete' | 'guildUnavailable' | 'guildIntegrationsUpdate', + listener: (guild: Guild) => void, + ): this; + public once( + event: 'guildMemberAdd' | 'guildMemberAvailable' | 'guildMemberRemove', + listener: (member: GuildMember | PartialGuildMember) => void, + ): this; + public once( + event: 'guildMembersChunk', + listener: (members: Collection, guild: Guild) => void, + ): this; + public once( + event: 'guildMemberSpeaking', + listener: (member: GuildMember | PartialGuildMember, speaking: Readonly) => void, + ): this; + public once( + event: 'guildMemberUpdate', + listener: (oldMember: GuildMember | PartialGuildMember, newMember: GuildMember | PartialGuildMember) => void, + ): this; + public once(event: 'guildUpdate', listener: (oldGuild: Guild, newGuild: Guild) => void): this; + public once( + event: 'message' | 'messageDelete' | 'messageReactionRemoveAll', + listener: (message: Message | PartialMessage) => void, + ): this; + public once( + event: 'messageDeleteBulk', + listener: (messages: Collection) => void, + ): this; + public once( + event: 'messageReactionAdd' | 'messageReactionRemove', + listener: (messageReaction: MessageReaction, user: User | PartialUser) => void, + ): this; + public once( + event: 'messageUpdate', + listener: (oldMessage: Message | PartialMessage, newMessage: Message | PartialMessage) => void, + ): this; + public once( + event: 'presenceUpdate', + listener: (oldPresence: Presence | undefined, newPresence: Presence) => void, + ): this; + public once(event: 'rateLimit', listener: (rateLimitData: RateLimitData) => void): this; + public once(event: 'ready' | 'invalidated', listener: () => void): this; + public once(event: 'roleCreate' | 'roleDelete', listener: (role: Role) => void): this; + public once(event: 'roleUpdate', listener: (oldRole: Role, newRole: Role) => void): this; + public once( + event: 'typingStart' | 'typingStop', + listener: (channel: Channel | PartialChannel, user: User | PartialUser) => void, + ): this; + public once( + event: 'userUpdate', + listener: (oldUser: User | PartialUser, newUser: User | PartialUser) => void, + ): this; + public once(event: 'voiceStateUpdate', listener: (oldState: VoiceState, newState: VoiceState) => void): this; + public once(event: 'webhookUpdate', listener: (channel: TextChannel) => void): this; + public once(event: 'shardDisconnect', listener: (event: CloseEvent, id: number) => void): this; + public once(event: 'shardError', listener: (error: Error, id: number) => void): this; + public once(event: 'shardReady' | 'shardReconnecting', listener: (id: number) => void): this; + public once(event: 'shardResume', listener: (id: number, replayed: number) => void): this; + public once(event: string, listener: (...args: any[]) => void): this; + } + + export class ClientApplication extends Base { + constructor(client: Client, data: object); + public botPublic: boolean | null; + public botRequireCodeGrant: boolean | null; + public cover: string | null; + public readonly createdAt: Date; + public readonly createdTimestamp: number; + public description: string; + public icon: string; + public id: Snowflake; + public name: string; + public owner: User | Team | null; + public rpcOrigins: string[]; + public coverImage(options?: ImageURLOptions): string; + public fetchAssets(): Promise; + public iconURL(options?: ImageURLOptions): string; + public toJSON(): object; + public toString(): string; + } + + export class ClientUser extends User { + public mfaEnabled: boolean; + public verified: boolean; + public setActivity(options?: ActivityOptions): Promise; + public setActivity(name: string, options?: ActivityOptions): Promise; + public setAFK(afk: boolean): Promise; + public setAvatar(avatar: BufferResolvable | Base64Resolvable): Promise; + public setPresence(data: PresenceData): Promise; + public setStatus(status: PresenceStatusData, shardID?: number | number[]): Promise; + public setUsername(username: string): Promise; + } + + export class ClientVoiceManager { + constructor(client: Client); + public readonly client: Client; + public connections: Collection; + public broadcasts: VoiceBroadcast[]; + + private joinChannel(channel: VoiceChannel): Promise; + + public createBroadcast(): VoiceBroadcast; + } + + export abstract class Collector extends EventEmitter { + constructor(client: Client, filter: CollectorFilter, options?: CollectorOptions); + private _timeout: NodeJS.Timer | null; + private _idletimeout: NodeJS.Timer | null; + + public readonly client: Client; + public collected: Collection; + public ended: boolean; + public filter: CollectorFilter; + public readonly next: Promise; + public options: CollectorOptions; + public checkEnd(): void; + public handleCollect(...args: any[]): void; + public handleDispose(...args: any[]): void; + public stop(reason?: string): void; + public resetTimer(options?: { time?: number; idle?: number }): void; + public [Symbol.asyncIterator](): AsyncIterableIterator; + public toJSON(): object; + + protected listener: (...args: any[]) => void; + public abstract collect(...args: any[]): K; + public abstract dispose(...args: any[]): K; + public abstract endReason(): void; + + public on(event: 'collect' | 'dispose', listener: (...args: any[]) => void): this; + public on(event: 'end', listener: (collected: Collection, reason: string) => void): this; + + public once(event: 'collect' | 'dispose', listener: (...args: any[]) => void): this; + public once(event: 'end', listener: (collected: Collection, reason: string) => void): this; + } + + type AllowedImageFormat = 'webp' | 'png' | 'jpg' | 'gif'; + + export const Constants: { + Package: { + name: string; + version: string; + description: string; + author: string; + license: string; + main: PathLike; + types: PathLike; + homepage: string; + keywords: string[]; + bugs: { url: string }; + repository: { type: string; url: string }; + browser: { [key: string]: boolean }; + scripts: { [key: string]: string }; + engines: { [key: string]: string }; + dependencies: { [key: string]: string }; + peerDependencies: { [key: string]: string }; + devDependencies: { [key: string]: string }; + [key: string]: any; + }; + browser: boolean; + DefaultOptions: ClientOptions; + UserAgent: string | null; + Endpoints: { + botGateway: string; + invite: (root: string, code: string) => string; + CDN: ( + root: string, + ) => { + Asset: (name: string) => string; + DefaultAvatar: (id: string | number) => string; + Emoji: (emojiID: string, format: 'png' | 'gif') => string; + Avatar: (userID: string | number, hash: string, format: 'default' | AllowedImageFormat, size: number) => string; + Banner: (guildID: string | number, hash: string, format: AllowedImageFormat, size: number) => string; + Icon: (userID: string | number, hash: string, format: 'default' | AllowedImageFormat, size: number) => string; + AppIcon: (userID: string | number, hash: string, format: AllowedImageFormat, size: number) => string; + AppAsset: (userID: string | number, hash: string, format: AllowedImageFormat, size: number) => string; + GDMIcon: (userID: string | number, hash: string, format: AllowedImageFormat, size: number) => string; + Splash: (userID: string | number, hash: string, format: AllowedImageFormat, size: number) => string; + TeamIcon: (teamID: string | number, hash: string, format: AllowedImageFormat, size: number) => string; + }; + }; + WSCodes: { + 1000: 'WS_CLOSE_REQUESTED'; + 4004: 'TOKEN_INVALID'; + 4010: 'SHARDING_INVALID'; + 4011: 'SHARDING_REQUIRED'; + }; + Events: { + RATE_LIMIT: 'rateLimit'; + CLIENT_READY: 'ready'; + RESUMED: 'resumed'; + GUILD_CREATE: 'guildCreate'; + GUILD_DELETE: 'guildDelete'; + GUILD_UPDATE: 'guildUpdate'; + INVITE_CREATE: 'inviteCreate'; + INVITE_DELETE: 'inviteDelete'; + GUILD_UNAVAILABLE: 'guildUnavailable'; + GUILD_MEMBER_ADD: 'guildMemberAdd'; + GUILD_MEMBER_REMOVE: 'guildMemberRemove'; + GUILD_MEMBER_UPDATE: 'guildMemberUpdate'; + GUILD_MEMBER_AVAILABLE: 'guildMemberAvailable'; + GUILD_MEMBER_SPEAKING: 'guildMemberSpeaking'; + GUILD_MEMBERS_CHUNK: 'guildMembersChunk'; + GUILD_INTEGRATIONS_UPDATE: 'guildIntegrationsUpdate'; + GUILD_ROLE_CREATE: 'roleCreate'; + GUILD_ROLE_DELETE: 'roleDelete'; + GUILD_ROLE_UPDATE: 'roleUpdate'; + GUILD_EMOJI_CREATE: 'emojiCreate'; + GUILD_EMOJI_DELETE: 'emojiDelete'; + GUILD_EMOJI_UPDATE: 'emojiUpdate'; + GUILD_BAN_ADD: 'guildBanAdd'; + GUILD_BAN_REMOVE: 'guildBanRemove'; + CHANNEL_CREATE: 'channelCreate'; + CHANNEL_DELETE: 'channelDelete'; + CHANNEL_UPDATE: 'channelUpdate'; + CHANNEL_PINS_UPDATE: 'channelPinsUpdate'; + MESSAGE_CREATE: 'message'; + MESSAGE_DELETE: 'messageDelete'; + MESSAGE_UPDATE: 'messageUpdate'; + MESSAGE_BULK_DELETE: 'messageDeleteBulk'; + MESSAGE_REACTION_ADD: 'messageReactionAdd'; + MESSAGE_REACTION_REMOVE: 'messageReactionRemove'; + MESSAGE_REACTION_REMOVE_ALL: 'messageReactionRemoveAll'; + USER_UPDATE: 'userUpdate'; + PRESENCE_UPDATE: 'presenceUpdate'; + VOICE_STATE_UPDATE: 'voiceStateUpdate'; + VOICE_BROADCAST_SUBSCRIBE: 'subscribe'; + VOICE_BROADCAST_UNSUBSCRIBE: 'unsubscribe'; + TYPING_START: 'typingStart'; + WEBHOOKS_UPDATE: 'webhookUpdate'; + DISCONNECT: 'disconnect'; + RECONNECTING: 'reconnecting'; + ERROR: 'error'; + WARN: 'warn'; + DEBUG: 'debug'; + SHARD_DISCONNECT: 'shardDisconnect'; + SHARD_ERROR: 'shardError'; + SHARD_RECONNECTING: 'shardReconnecting'; + SHARD_READY: 'shardReady'; + SHARD_RESUME: 'shardResume'; + INVALIDATED: 'invalidated'; + RAW: 'raw'; + }; + ShardEvents: { + CLOSE: 'close'; + DESTROYED: 'destroyed'; + INVALID_SESSION: 'invalidSession'; + READY: 'ready'; + RESUMED: 'resumed'; + }; + PartialTypes: { + [K in PartialTypes]: K; + }; + WSEvents: { + [K in WSEventType]: K; + }; + Colors: { + DEFAULT: 0x000000; + WHITE: 0xffffff; + AQUA: 0x1abc9c; + GREEN: 0x2ecc71; + BLUE: 0x3498db; + YELLOW: 0xffff00; + PURPLE: 0x9b59b6; + LUMINOUS_VIVID_PINK: 0xe91e63; + GOLD: 0xf1c40f; + ORANGE: 0xe67e22; + RED: 0xe74c3c; + GREY: 0x95a5a6; + NAVY: 0x34495e; + DARK_AQUA: 0x11806a; + DARK_GREEN: 0x1f8b4c; + DARK_BLUE: 0x206694; + DARK_PURPLE: 0x71368a; + DARK_VIVID_PINK: 0xad1457; + DARK_GOLD: 0xc27c0e; + DARK_ORANGE: 0xa84300; + DARK_RED: 0x992d22; + DARK_GREY: 0x979c9f; + DARKER_GREY: 0x7f8c8d; + LIGHT_GREY: 0xbcc0c0; + DARK_NAVY: 0x2c3e50; + BLURPLE: 0x7289da; + GREYPLE: 0x99aab5; + DARK_BUT_NOT_BLACK: 0x2c2f33; + NOT_QUITE_BLACK: 0x23272a; + }; + Status: { + READY: 0; + CONNECTING: 1; + RECONNECTING: 2; + IDLE: 3; + NEARLY: 4; + DISCONNECTED: 5; + }; + OPCodes: { + DISPATCH: 0; + HEARTBEAT: 1; + IDENTIFY: 2; + STATUS_UPDATE: 3; + VOICE_STATE_UPDATE: 4; + VOICE_GUILD_PING: 5; + RESUME: 6; + RECONNECT: 7; + REQUEST_GUILD_MEMBERS: 8; + INVALID_SESSION: 9; + HELLO: 10; + HEARTBEAT_ACK: 11; + }; + APIErrors: { + UNKNOWN_ACCOUNT: 10001; + UNKNOWN_APPLICATION: 10002; + UNKNOWN_CHANNEL: 10003; + UNKNOWN_GUILD: 10004; + UNKNOWN_INTEGRATION: 10005; + UNKNOWN_INVITE: 10006; + UNKNOWN_MEMBER: 10007; + UNKNOWN_MESSAGE: 10008; + UNKNOWN_OVERWRITE: 10009; + UNKNOWN_PROVIDER: 10010; + UNKNOWN_ROLE: 10011; + UNKNOWN_TOKEN: 10012; + UNKNOWN_USER: 10013; + UNKNOWN_EMOJI: 10014; + UNKNOWN_WEBHOOK: 10015; + BOT_PROHIBITED_ENDPOINT: 20001; + BOT_ONLY_ENDPOINT: 20002; + MAXIMUM_GUILDS: 30001; + MAXIMUM_FRIENDS: 30002; + MAXIMUM_PINS: 30003; + MAXIMUM_ROLES: 30005; + MAXIMUM_REACTIONS: 30010; + MAXIMUM_CHANNELS: 30013; + MAXIMUM_INVITES: 30016; + UNAUTHORIZED: 40001; + USER_BANNED: 40007; + MISSING_ACCESS: 50001; + INVALID_ACCOUNT_TYPE: 50002; + CANNOT_EXECUTE_ON_DM: 50003; + EMBED_DISABLED: 50004; + CANNOT_EDIT_MESSAGE_BY_OTHER: 50005; + CANNOT_SEND_EMPTY_MESSAGE: 50006; + CANNOT_MESSAGE_USER: 50007; + CANNOT_SEND_MESSAGES_IN_VOICE_CHANNEL: 50008; + CHANNEL_VERIFICATION_LEVEL_TOO_HIGH: 50009; + OAUTH2_APPLICATION_BOT_ABSENT: 50010; + MAXIMUM_OAUTH2_APPLICATIONS: 50011; + INVALID_OAUTH_STATE: 50012; + MISSING_PERMISSIONS: 50013; + INVALID_AUTHENTICATION_TOKEN: 50014; + NOTE_TOO_LONG: 50015; + INVALID_BULK_DELETE_QUANTITY: 50016; + CANNOT_PIN_MESSAGE_IN_OTHER_CHANNEL: 50019; + CANNOT_EXECUTE_ON_SYSTEM_MESSAGE: 50021; + INVALID_OAUTH_TOKEN: 50025; + BULK_DELETE_MESSAGE_TOO_OLD: 50034; + INVALID_FORM_BODY: 50035; + INVITE_ACCEPTED_TO_GUILD_NOT_CONTAINING_BOT: 50036; + INVALID_API_VERSION: 50041; + REACTION_BLOCKED: 90001; + RESOURCE_OVERLOADED: 130000; + }; + VoiceStatus: { + CONNECTED: 0; + CONNECTING: 1; + AUTHENTICATING: 2; + RECONNECTING: 3; + DISCONNECTED: 4; + }; + VoiceOPCodes: { + IDENTIFY: 0; + SELECT_PROTOCOL: 1; + READY: 2; + HEARTBEAT: 3; + SESSION_DESCRIPTION: 4; + SPEAKING: 5; + HELLO: 8; + CLIENT_CONNECT: 12; + CLIENT_DISCONNECT: 13; + }; + ChannelTypes: { + TEXT: 0; + DM: 1; + VOICE: 2; + GROUP: 3; + CATEGORY: 4; + NEWS: 5; + STORE: 6; + }; + ClientApplicationAssetTypes: { + SMALL: 1; + BIG: 2; + }; + MessageTypes: MessageType[]; + ActivityTypes: ActivityType[]; + ExplicitContentFilterLevels: ExplicitContentFilterLevel[]; + DefaultMessageNotifications: DefaultMessageNotifications[]; + VerificationLevels: VerificationLevel[]; + MembershipStates: 'INVITED' | 'ACCEPTED'; + }; + + export class DataResolver { + public static resolveBase64(data: Base64Resolvable): string; + public static resolveFile(resource: BufferResolvable | Stream): Promise; + public static resolveImage(resource: BufferResolvable | Base64Resolvable): Promise; + public static resolveInviteCode(data: InviteResolvable): string; + } + + export class DiscordAPIError extends Error { + constructor(path: string, error: object, method: string, httpStatus: number); + private static flattenErrors(obj: object, key: string): string[]; + + public code: number; + public method: string; + public path: string; + public httpStatus: number; + } + + export class DMChannel extends TextBasedChannel(Channel) { + constructor(client: Client, data?: object); + public messages: MessageManager; + public recipient: User; + public readonly partial: false; + public type: 'dm'; + public fetch(): Promise; + } + + export class Emoji extends Base { + constructor(client: Client, emoji: object); + public animated: boolean; + public readonly createdAt: Date | null; + public readonly createdTimestamp: number | null; + public deleted: boolean; + public id: Snowflake | null; + public name: string; + public readonly identifier: string; + public readonly url: string | null; + public toJSON(): object; + public toString(): string; + } + + export class Guild extends Base { + constructor(client: Client, data: object); + private _sortedRoles(): Collection; + private _sortedChannels(channel: Channel): Collection; + private _memberSpeakUpdate(user: Snowflake, speaking: boolean): void; + + public readonly afkChannel: VoiceChannel | null; + public afkChannelID: Snowflake | null; + public afkTimeout: number; + public applicationID: Snowflake | null; + public available: boolean; + public banner: string | null; + public channels: GuildChannelManager; + public readonly createdAt: Date; + public readonly createdTimestamp: number; + public defaultMessageNotifications: DefaultMessageNotifications | number; + public deleted: boolean; + public description: string | null; + public embedChannel: GuildChannel | null; + public embedChannelID: Snowflake | null; + public embedEnabled: boolean; + public emojis: GuildEmojiManager; + public explicitContentFilter: ExplicitContentFilterLevel; + public features: GuildFeatures[]; + public icon: string | null; + public id: Snowflake; + public readonly joinedAt: Date; + public joinedTimestamp: number; + public large: boolean; + public maximumMembers: number | null; + public maximumPresences: number | null; + public readonly me: GuildMember | null; + public memberCount: number; + public members: GuildMemberManager; + public mfaLevel: number; + public name: string; + public readonly nameAcronym: string; + public readonly owner: GuildMember | null; + public ownerID: Snowflake; + public readonly partnered: boolean; + public premiumSubscriptionCount: number | null; + public premiumTier: PremiumTier; + public presences: PresenceManager; + public readonly publicUpdatesChannel: TextChannel | null; + public publicUpdatesChannelID: Snowflake | null; + public region: string; + public roles: RoleManager; + public readonly rulesChannel: TextChannel | null; + public rulesChannelID: Snowflake | null; + public readonly shard: WebSocketShard; + public shardID: number; + public splash: string | null; + public readonly systemChannel: TextChannel | null; + public systemChannelFlags: Readonly; + public systemChannelID: Snowflake | null; + public vanityURLCode: string | null; + public verificationLevel: VerificationLevel; + public readonly verified: boolean; + public readonly voice: VoiceState | null; + public readonly voiceStates: VoiceStateManager; + public readonly widgetChannel: TextChannel | null; + public widgetChannelID: Snowflake | null; + public widgetEnabled: boolean | null; + public addMember(user: UserResolvable, options: AddGuildMemberOptions): Promise; + public bannerURL(options?: ImageURLOptions): string | null; + public createIntegration(data: IntegrationData, reason?: string): Promise; + public delete(): Promise; + public edit(data: GuildEditData, reason?: string): Promise; + public equals(guild: Guild): boolean; + public fetch(): Promise; + public fetchAuditLogs(options?: GuildAuditLogsFetchOptions): Promise; + public fetchBan(user: UserResolvable): Promise<{ user: User; reason: string }>; + public fetchBans(): Promise>; + public fetchEmbed(): Promise; + public fetchIntegrations(): Promise>; + public fetchInvites(): Promise>; + public fetchVanityCode(): Promise; + public fetchVoiceRegions(): Promise>; + public fetchWebhooks(): Promise>; + public iconURL(options?: ImageURLOptions & { dynamic?: boolean }): string | null; + public leave(): Promise; + public member(user: UserResolvable): GuildMember | null; + public setAFKChannel(afkChannel: ChannelResolvable | null, reason?: string): Promise; + public setAFKTimeout(afkTimeout: number, reason?: string): Promise; + public setBanner(banner: Base64Resolvable | null, reason?: string): Promise; + public setChannelPositions(channelPositions: ChannelPosition[]): Promise; + public setDefaultMessageNotifications( + defaultMessageNotifications: DefaultMessageNotifications | number, + reason?: string, + ): Promise; + public setEmbed(embed: GuildEmbedData, reason?: string): Promise; + public setExplicitContentFilter(explicitContentFilter: ExplicitContentFilterLevel, reason?: string): Promise; + public setIcon(icon: Base64Resolvable | null, reason?: string): Promise; + public setName(name: string, reason?: string): Promise; + public setOwner(owner: GuildMemberResolvable, reason?: string): Promise; + public setRegion(region: string, reason?: string): Promise; + public setRolePositions(rolePositions: RolePosition[]): Promise; + public setSplash(splash: Base64Resolvable | null, reason?: string): Promise; + public setSystemChannel(systemChannel: ChannelResolvable | null, reason?: string): Promise; + public setSystemChannelFlags(systemChannelFlags: SystemChannelFlagsResolvable, reason?: string): Promise; + public setVerificationLevel(verificationLevel: VerificationLevel, reason?: string): Promise; + public splashURL(options?: ImageURLOptions): string | null; + public toJSON(): object; + public toString(): string; + } + + export class GuildAuditLogs { + constructor(guild: Guild, data: object); + private webhooks: Collection; + private integrations: Collection; + + public entries: Collection; + + public static Actions: GuildAuditLogsActions; + public static Targets: GuildAuditLogsTargets; + public static Entry: typeof GuildAuditLogsEntry; + public static actionType(action: number): GuildAuditLogsActionType; + public static build(...args: any[]): Promise; + public static targetType(target: number): GuildAuditLogsTarget; + public toJSON(): object; + } + + class GuildAuditLogsEntry { + constructor(logs: GuildAuditLogs, guild: Guild, data: object); + public action: GuildAuditLogsAction; + public actionType: GuildAuditLogsActionType; + public changes: AuditLogChange[] | null; + public readonly createdAt: Date; + public readonly createdTimestamp: number; + public executor: User; + public extra: object | Role | GuildMember | null; + public id: Snowflake; + public reason: string | null; + public target: Guild | User | Role | GuildEmoji | Invite | Webhook | Integration | null; + public targetType: GuildAuditLogsTarget; + public toJSON(): object; + } + + export class GuildChannel extends Channel { + constructor(guild: Guild, data?: object); + private memberPermissions(member: GuildMember): Readonly; + private rolePermissions(role: Role): Readonly; + + public readonly calculatedPosition: number; + public readonly deletable: boolean; + public guild: Guild; + public readonly manageable: boolean; + public readonly members: Collection; + public name: string; + public readonly parent: CategoryChannel | null; + public parentID: Snowflake | null; + public permissionOverwrites: Collection; + public readonly permissionsLocked: boolean | null; + public readonly position: number; + public rawPosition: number; + public type: Exclude; + public readonly viewable: boolean; + public clone(options?: GuildChannelCloneOptions): Promise; + public createInvite(options?: InviteOptions): Promise; + public createOverwrite( + userOrRole: RoleResolvable | UserResolvable, + options: PermissionOverwriteOption, + reason?: string, + ): Promise; + public edit(data: ChannelData, reason?: string): Promise; + public equals(channel: GuildChannel): boolean; + public fetchInvites(): Promise>; + public lockPermissions(): Promise; + public overwritePermissions( + overwrites: OverwriteResolvable[] | Collection, + reason?: string, + ): Promise; + public permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable): Readonly | null; + public setName(name: string, reason?: string): Promise; + public setParent( + channel: GuildChannel | Snowflake, + options?: { lockPermissions?: boolean; reason?: string }, + ): Promise; + public setPosition(position: number, options?: { relative?: boolean; reason?: string }): Promise; + public setTopic(topic: string, reason?: string): Promise; + public updateOverwrite( + userOrRole: RoleResolvable | UserResolvable, + options: PermissionOverwriteOption, + reason?: string, + ): Promise; + } + + export class GuildEmoji extends Emoji { + constructor(client: Client, data: object, guild: Guild); + private _roles: string[]; + + public available: boolean; + public readonly deletable: boolean; + public guild: Guild; + public id: Snowflake; + public managed: boolean; + public requiresColons: boolean; + public roles: GuildEmojiRoleManager; + public readonly url: string; + public delete(reason?: string): Promise; + public edit(data: GuildEmojiEditData, reason?: string): Promise; + public equals(other: GuildEmoji | object): boolean; + public fetchAuthor(): Promise; + public setName(name: string, reason?: string): Promise; + } + + export class GuildMember extends PartialTextBasedChannel(Base) { + constructor(client: Client, data: object, guild: Guild); + public readonly bannable: boolean; + public deleted: boolean; + public readonly displayColor: number; + public readonly displayHexColor: string; + public readonly displayName: string; + public guild: Guild; + public readonly id: Snowflake; + public readonly joinedAt: Date | null; + public joinedTimestamp: number | null; + public readonly kickable: boolean; + public readonly manageable: boolean; + public nickname: string | null; + public readonly partial: false; + public readonly permissions: Readonly; + public readonly premiumSince: Date | null; + public premiumSinceTimestamp: number | null; + public readonly presence: Presence; + public roles: GuildMemberRoleManager; + public user: User; + public readonly voice: VoiceState; + public ban(options?: BanOptions): Promise; + public fetch(): Promise; + public createDM(): Promise; + public deleteDM(): Promise; + public edit(data: GuildMemberEditData, reason?: string): Promise; + public hasPermission( + permission: PermissionResolvable, + options?: { checkAdmin?: boolean; checkOwner?: boolean }, + ): boolean; + public kick(reason?: string): Promise; + public permissionsIn(channel: ChannelResolvable): Readonly; + public setNickname(nickname: string, reason?: string): Promise; + public toJSON(): object; + public toString(): string; + public valueOf(): string; + } + + export class HTTPError extends Error { + constructor(message: string, name: string, code: number, method: string, path: string); + public code: number; + public method: string; + public name: string; + public path: string; + } + + export class Integration extends Base { + constructor(client: Client, data: object, guild: Guild); + public account: IntegrationAccount; + public enabled: boolean; + public expireBehavior: number; + public expireGracePeriod: number; + public guild: Guild; + public id: Snowflake; + public name: string; + public role: Role; + public syncedAt: number; + public syncing: boolean; + public type: number; + public user: User; + public delete(reason?: string): Promise; + public edit(data: IntegrationEditData, reason?: string): Promise; + public sync(): Promise; + } + + export class Intents extends BitField { + public static FLAGS: Record; + public static PRIVILEGED: number; + public static ALL: number; + public static NON_PRIVILEGED: number; + public static resolve(bit?: BitFieldResolvable): number; + } + + export class Invite extends Base { + constructor(client: Client, data: object); + public channel: GuildChannel | PartialGroupDMChannel; + public code: string; + public readonly deletable: boolean; + public readonly createdAt: Date | null; + public createdTimestamp: number | null; + public readonly expiresAt: Date | null; + public readonly expiresTimestamp: number | null; + public guild: Guild | null; + public inviter: User | null; + public maxAge: number | null; + public maxUses: number | null; + public memberCount: number; + public presenceCount: number; + public targetUser: User | null; + public targetUserType: TargetUser | null; + public temporary: boolean | null; + public readonly url: string; + public uses: number | null; + public delete(reason?: string): Promise; + public toJSON(): object; + public toString(): string; + } + + export class Message extends Base { + constructor(client: Client, data: object, channel: TextChannel | DMChannel); + private _edits: Message[]; + private patch(data: object): void; + + public activity: MessageActivity | null; + public application: ClientApplication | null; + public attachments: Collection; + public author: User; + public channel: TextChannel | DMChannel; + public readonly cleanContent: string; + public content: string; + public readonly createdAt: Date; + public createdTimestamp: number; + public readonly deletable: boolean; + public deleted: boolean; + public readonly editable: boolean; + public readonly editedAt: Date | null; + public editedTimestamp: number | null; + public readonly edits: Message[]; + public embeds: MessageEmbed[]; + public readonly guild: Guild | null; + public id: Snowflake; + public readonly member: GuildMember | null; + public mentions: MessageMentions; + public nonce: string | null; + public readonly partial: false; + public readonly pinnable: boolean; + public pinned: boolean; + public reactions: ReactionManager; + public system: boolean; + public tts: boolean; + public type: MessageType; + public readonly url: string; + public webhookID: Snowflake | null; + public flags: Readonly; + public reference: MessageReference | null; + public awaitReactions( + filter: CollectorFilter, + options?: AwaitReactionsOptions, + ): Promise>; + public createReactionCollector(filter: CollectorFilter, options?: ReactionCollectorOptions): ReactionCollector; + public delete(options?: { timeout?: number; reason?: string }): Promise; + public edit(content: StringResolvable, options?: MessageEditOptions | MessageEmbed): Promise; + public edit(options: MessageEditOptions | MessageEmbed | APIMessage): Promise; + public equals(message: Message, rawData: object): boolean; + public fetchWebhook(): Promise; + public fetch(): Promise; + public pin(): Promise; + public react(emoji: EmojiIdentifierResolvable): Promise; + public reply( + content?: StringResolvable, + options?: MessageOptions | MessageAdditions | (MessageOptions & { split?: false }) | MessageAdditions, + ): Promise; + public reply( + content?: StringResolvable, + options?: (MessageOptions & { split: true | SplitOptions }) | MessageAdditions, + ): Promise; + public reply( + options?: + | MessageOptions + | MessageAdditions + | APIMessage + | (MessageOptions & { split?: false }) + | MessageAdditions + | APIMessage, + ): Promise; + public reply( + options?: (MessageOptions & { split: true | SplitOptions }) | MessageAdditions | APIMessage, + ): Promise; + public suppressEmbeds(suppress?: boolean): Promise; + public toJSON(): object; + public toString(): string; + public unpin(): Promise; + } + + export class MessageAttachment { + constructor(attachment: BufferResolvable | Stream, name?: string, data?: object); + + public attachment: BufferResolvable | Stream; + public height: number | null; + public id: Snowflake; + public name?: string; + public proxyURL: string; + public size: number; + public readonly spoiler: boolean; + public url: string; + public width: number | null; + public setFile(attachment: BufferResolvable | Stream, name?: string): this; + public setName(name: string): this; + public toJSON(): object; + } + + export class MessageCollector extends Collector { + constructor(channel: TextChannel | DMChannel, filter: CollectorFilter, options?: MessageCollectorOptions); + private _handleChannelDeletion(channel: GuildChannel): void; + private _handleGuildDeletion(guild: Guild): void; + + public channel: Channel; + public options: MessageCollectorOptions; + public received: number; + + public collect(message: Message): Snowflake; + public dispose(message: Message): Snowflake; + public endReason(): string; + } + + export class MessageEmbed { + constructor(data?: MessageEmbed | MessageEmbedOptions); + public author: MessageEmbedAuthor | null; + public color?: number; + public readonly createdAt: Date | null; + public description?: string; + public fields: EmbedField[]; + public files: (MessageAttachment | string | FileOptions)[]; + public footer: MessageEmbedFooter | null; + public readonly hexColor: string | null; + public image: MessageEmbedImage | null; + public readonly length: number; + public provider: MessageEmbedProvider | null; + public thumbnail: MessageEmbedThumbnail | null; + public timestamp: number | null; + public title?: string; + public type: string; + public url?: string; + public readonly video: MessageEmbedVideo | null; + public addField(name: StringResolvable, value: StringResolvable, inline?: boolean): this; + public addFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): this; + public attachFiles(file: (MessageAttachment | FileOptions | string)[]): this; + public setAuthor(name: StringResolvable, iconURL?: string, url?: string): this; + public setColor(color: ColorResolvable): this; + public setDescription(description: StringResolvable): this; + public setFooter(text: StringResolvable, iconURL?: string): this; + public setImage(url: string): this; + public setThumbnail(url: string): this; + public setTimestamp(timestamp?: Date | number): this; + public setTitle(title: StringResolvable): this; + public setURL(url: string): this; + public spliceFields(index: number, deleteCount: number, ...fields: EmbedFieldData[] | EmbedFieldData[][]): this; + public toJSON(): object; + + public static normalizeField( + name: StringResolvable, + value: StringResolvable, + inline?: boolean, + ): Required; + public static normalizeFields(...fields: EmbedFieldData[] | EmbedFieldData[][]): Required[]; + } + + export class MessageFlags extends BitField { + public static FLAGS: Record; + public static resolve(bit?: BitFieldResolvable): number; + } + + export class MessageMentions { + constructor( + message: Message, + users: object[] | Collection, + roles: Snowflake[] | Collection, + everyone: boolean, + ); + private _channels: Collection | null; + private readonly _content: Message; + private _members: Collection | null; + + public readonly channels: Collection; + public readonly client: Client; + public everyone: boolean; + public readonly guild: Guild; + public has( + data: User | GuildMember | Role | GuildChannel, + options?: { + ignoreDirect?: boolean; + ignoreRoles?: boolean; + ignoreEveryone?: boolean; + }, + ): boolean; + public readonly members: Collection | null; + public roles: Collection; + public users: Collection; + public crosspostedChannels: Collection; + public toJSON(): object; + + public static CHANNELS_PATTERN: RegExp; + public static EVERYONE_PATTERN: RegExp; + public static ROLES_PATTERN: RegExp; + public static USERS_PATTERN: RegExp; + } + + export class MessageReaction { + constructor(client: Client, data: object, message: Message); + private _emoji: GuildEmoji | ReactionEmoji; + + public count: number | null; + public readonly emoji: GuildEmoji | ReactionEmoji; + public me: boolean; + public message: Message; + public readonly partial: boolean; + public users: ReactionUserManager; + public remove(): Promise; + public fetch(): Promise; + public toJSON(): object; + } + + export class NewsChannel extends TextBasedChannel(GuildChannel) { + constructor(guild: Guild, data?: object); + public messages: MessageManager; + public nsfw: boolean; + public topic: string | null; + public type: 'news'; + public createWebhook( + name: string, + options?: { avatar?: BufferResolvable | Base64Resolvable; reason?: string }, + ): Promise; + public setNSFW(nsfw: boolean, reason?: string): Promise; + public fetchWebhooks(): Promise>; + } + + export class PartialGroupDMChannel extends Channel { + constructor(client: Client, data: object); + public name: string; + public icon: string | null; + public iconURL(options?: ImageURLOptions): string | null; + } + + export class PermissionOverwrites { + constructor(guildChannel: GuildChannel, data?: object); + public allow: Readonly; + public readonly channel: GuildChannel; + public deny: Readonly; + public id: Snowflake; + public type: OverwriteType; + public update(options: PermissionOverwriteOption, reason?: string): Promise; + public delete(reason?: string): Promise; + public toJSON(): object; + public static resolveOverwriteOptions( + options: ResolvedOverwriteOptions, + initialPermissions: { allow?: PermissionResolvable; deny?: PermissionResolvable }, + ): ResolvedOverwriteOptions; + public static resolve(overwrite: OverwriteResolvable, guild: Guild): RawOverwriteData; + } + + export class Permissions extends BitField { + public any(permission: PermissionResolvable, checkAdmin?: boolean): boolean; + public has(permission: PermissionResolvable, checkAdmin?: boolean): boolean; + public missing(bits: BitFieldResolvable, checkAdmin?: boolean): PermissionString[]; + public serialize(checkAdmin?: boolean): Record; + public toArray(checkAdmin?: boolean): PermissionString[]; + + public static ALL: number; + public static DEFAULT: number; + public static FLAGS: PermissionFlags; + public static resolve(permission?: PermissionResolvable): number; + } + + export class Presence { + constructor(client: Client, data?: object); + public activities: Activity[]; + public clientStatus: ClientPresenceStatusData | null; + public flags: Readonly; + public guild: Guild | null; + public readonly member: GuildMember | null; + public status: PresenceStatus; + public readonly user: User | null; + public equals(presence: Presence): boolean; + } + + export class ReactionCollector extends Collector { + constructor(message: Message, filter: CollectorFilter, options?: ReactionCollectorOptions); + private _handleChannelDeletion(channel: GuildChannel): void; + private _handleGuildDeletion(guild: Guild): void; + private _handleMessageDeletion(message: Message): void; + + public message: Message; + public options: ReactionCollectorOptions; + public total: number; + public users: Collection; + + public static key(reaction: MessageReaction): Snowflake | string; + + public collect(reaction: MessageReaction): Snowflake | string; + public dispose(reaction: MessageReaction, user: User): Snowflake | string; + public empty(): void; + public endReason(): string | null; + + public on(event: 'collect' | 'dispose' | 'remove', listener: (reaction: MessageReaction, user: User) => void): this; + public on( + event: 'end', + listener: (collected: Collection, reason: string) => void, + ): this; + public on(event: string, listener: (...args: any[]) => void): this; + + public once( + event: 'collect' | 'dispose' | 'remove', + listener: (reaction: MessageReaction, user: User) => void, + ): this; + public once( + event: 'end', + listener: (collected: Collection, reason: string) => void, + ): this; + public once(event: string, listener: (...args: any[]) => void): this; + } + + export class ReactionEmoji extends Emoji { + constructor(reaction: MessageReaction, emoji: object); + public reaction: MessageReaction; + public toJSON(): object; + } + + export class RichPresenceAssets { + constructor(activity: Activity, assets: object); + public largeImage: Snowflake | null; + public largeText: string | null; + public smallImage: Snowflake | null; + public smallText: string | null; + public largeImageURL(options?: ImageURLOptions): string | null; + public smallImageURL(options?: ImageURLOptions): string | null; + } + + export class Role extends Base { + constructor(client: Client, data: object, guild: Guild); + public color: number; + public readonly createdAt: Date; + public readonly createdTimestamp: number; + public deleted: boolean; + public readonly editable: boolean; + public guild: Guild; + public readonly hexColor: string; + public hoist: boolean; + public id: Snowflake; + public managed: boolean; + public readonly members: Collection; + public mentionable: boolean; + public name: string; + public permissions: Readonly; + public readonly position: number; + public rawPosition: number; + public comparePositionTo(role: Role): number; + public delete(reason?: string): Promise; + public edit(data: RoleData, reason?: string): Promise; + public equals(role: Role): boolean; + public permissionsIn(channel: ChannelResolvable): Readonly; + public setColor(color: ColorResolvable, reason?: string): Promise; + public setHoist(hoist: boolean, reason?: string): Promise; + public setMentionable(mentionable: boolean, reason?: string): Promise; + public setName(name: string, reason?: string): Promise; + public setPermissions(permissions: PermissionResolvable, reason?: string): Promise; + public setPosition(position: number, options?: { relative?: boolean; reason?: string }): Promise; + public toJSON(): object; + public toString(): string; + + public static comparePositions(role1: Role, role2: Role): number; + } + + export class Shard extends EventEmitter { + constructor(manager: ShardingManager, id: number); + private _evals: Map>; + private _exitListener: (...args: any[]) => void; + private _fetches: Map>; + private _handleExit(respawn?: boolean): void; + private _handleMessage(message: any): void; + + public args: string[]; + public execArgv: string[]; + public env: object; + public id: number; + public manager: ShardingManager; + public process: ChildProcess | null; + public ready: boolean; + public worker: any | null; + public eval(script: string): Promise; + public eval(fn: (client: Client) => T): Promise; + public fetchClientValue(prop: string): Promise; + public kill(): void; + public respawn(delay?: number, spawnTimeout?: number): Promise; + public send(message: any): Promise; + public spawn(spawnTimeout?: number): Promise; + + public on(event: 'spawn' | 'death', listener: (child: ChildProcess) => void): this; + public on(event: 'disconnect' | 'ready' | 'reconnecting', listener: () => void): this; + public on(event: 'error', listener: (error: Error) => void): this; + public on(event: 'message', listener: (message: any) => void): this; + public on(event: string, listener: (...args: any[]) => void): this; + + public once(event: 'spawn' | 'death', listener: (child: ChildProcess) => void): this; + public once(event: 'disconnect' | 'ready' | 'reconnecting', listener: () => void): this; + public once(event: 'error', listener: (error: Error) => void): this; + public once(event: 'message', listener: (message: any) => void): this; + public once(event: string, listener: (...args: any[]) => void): this; + } + + export class ShardClientUtil { + constructor(client: Client, mode: ShardingManagerMode); + private _handleMessage(message: any): void; + private _respond(type: string, message: any): void; + + public client: Client; + public readonly count: number; + public readonly ids: number[]; + public mode: ShardingManagerMode; + public parentPort: any | null; + public broadcastEval(script: string): Promise; + public broadcastEval(fn: (client: Client) => T): Promise; + public fetchClientValues(prop: string): Promise; + public respawnAll(shardDelay?: number, respawnDelay?: number, spawnTimeout?: number): Promise; + public send(message: any): Promise; + + public static singleton(client: Client, mode: ShardingManagerMode): ShardClientUtil; + } + + export class ShardingManager extends EventEmitter { + constructor( + file: string, + options?: { + totalShards?: number | 'auto'; + shardList?: number[] | 'auto'; + mode?: ShardingManagerMode; + respawn?: boolean; + shardArgs?: string[]; + token?: string; + execArgv?: string[]; + }, + ); + + public file: string; + public respawn: boolean; + public shardArgs: string[]; + public shards: Collection; + public token: string | null; + public totalShards: number | 'auto'; + public broadcast(message: any): Promise; + public broadcastEval(script: string): Promise; + public createShard(id: number): Shard; + public fetchClientValues(prop: string): Promise; + public respawnAll( + shardDelay?: number, + respawnDelay?: number, + spawnTimeout?: number, + ): Promise>; + public spawn(amount?: number | 'auto', delay?: number, spawnTimeout?: number): Promise>; + + public on(event: 'shardCreate', listener: (shard: Shard) => void): this; + + public once(event: 'shardCreate', listener: (shard: Shard) => void): this; + } + + export class SnowflakeUtil { + public static deconstruct(snowflake: Snowflake): DeconstructedSnowflake; + public static generate(timestamp?: number | Date): Snowflake; + } + + export class Speaking extends BitField { + public static FLAGS: Record; + public static resolve(bit?: BitFieldResolvable): number; + } + + export class StoreChannel extends GuildChannel { + constructor(guild: Guild, data?: object); + public nsfw: boolean; + } + + class StreamDispatcher extends VolumeMixin(Writable) { + constructor(player: object, options?: StreamOptions, streams?: object); + public player: object; + public pausedSince: number; + public broadcast: VoiceBroadcast | null; + public readonly paused: boolean; + public readonly pausedTime: boolean | null; + public readonly streamTime: number; + public readonly totalStreamTime: number; + public readonly bitrateEditable: boolean; + + public setBitrate(value: number | 'auto'): boolean; + public setPLP(value: number): boolean; + public setFEC(enabled: boolean): boolean; + public pause(silence?: boolean): void; + public resume(): void; + + public on(event: 'close' | 'drain' | 'end' | 'finish' | 'start', listener: () => void): this; + public on(event: 'debug', listener: (info: string) => void): this; + public on(event: 'error', listener: (err: Error) => void): this; + public on(event: 'pipe' | 'unpipe', listener: (src: Readable) => void): this; + public on(event: 'speaking', listener: (speaking: boolean) => void): this; + public on(event: 'volumeChange', listener: (oldVolume: number, newVolume: number) => void): this; + public on(event: string, listener: (...args: any[]) => void): this; + + public once(event: 'close' | 'drain' | 'end' | 'finish' | 'start', listener: () => void): this; + public once(event: 'debug', listener: (info: string) => void): this; + public once(event: 'error', listener: (err: Error) => void): this; + public once(event: 'pipe' | 'unpipe', listener: (src: Readable) => void): this; + public once(event: 'speaking', listener: (speaking: boolean) => void): this; + public once(event: 'volumeChange', listener: (oldVolume: number, newVolume: number) => void): this; + public once(event: string, listener: (...args: any[]) => void): this; + } + + export class Structures { + public static get(structure: K): Extendable[K]; + public static get(structure: string): (...args: any[]) => void; + public static extend( + structure: K, + extender: (baseClass: Extendable[K]) => T, + ): T; + public static extend void>( + structure: string, + extender: (baseClass: typeof Function) => T, + ): T; + } + + export class SystemChannelFlags extends BitField { + public static FLAGS: Record; + public static resolve(bit?: BitFieldResolvable): number; + } + + export class Team extends Base { + constructor(client: Client, data: object); + public id: Snowflake; + public name: string; + public icon: string | null; + public ownerID: Snowflake | null; + public members: Collection; + + public readonly owner: TeamMember; + public readonly createdAt: Date; + public readonly createdTimestamp: number; + + public iconURL(options?: ImageURLOptions): string; + public toJSON(): object; + public toString(): string; + } + + export class TeamMember extends Base { + constructor(team: Team, data: object); + public team: Team; + public readonly id: Snowflake; + public permissions: string[]; + public membershipState: MembershipStates; + public user: User; + + public toString(): string; + } + + export class TextChannel extends TextBasedChannel(GuildChannel) { + constructor(guild: Guild, data?: object); + public messages: MessageManager; + public nsfw: boolean; + public type: 'text'; + public rateLimitPerUser: number; + public topic: string | null; + public createWebhook( + name: string, + options?: { avatar?: BufferResolvable | Base64Resolvable; reason?: string }, + ): Promise; + public setNSFW(nsfw: boolean, reason?: string): Promise; + public setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise; + public fetchWebhooks(): Promise>; + } + + export class User extends PartialTextBasedChannel(Base) { + constructor(client: Client, data: object); + public avatar: string | null; + public bot: boolean; + public readonly createdAt: Date; + public readonly createdTimestamp: number; + public discriminator: string; + public readonly defaultAvatarURL: string; + public readonly dmChannel: DMChannel; + public id: Snowflake; + public locale: string; + public readonly partial: false; + public readonly presence: Presence; + public system?: boolean; + public readonly tag: string; + public username: string; + public avatarURL(options?: ImageURLOptions & { dynamic?: boolean }): string | null; + public createDM(): Promise; + public deleteDM(): Promise; + public displayAvatarURL(options?: ImageURLOptions & { dynamic?: boolean }): string; + public equals(user: User): boolean; + public fetch(): Promise; + public toString(): string; + public typingDurationIn(channel: ChannelResolvable): number; + public typingIn(channel: ChannelResolvable): boolean; + public typingSinceIn(channel: ChannelResolvable): Date; + } + + export class Util { + public static basename(path: string, ext?: string): string; + public static binaryToID(num: string): Snowflake; + public static cleanContent(str: string, message: Message): string; + public static removeMentions(str: string): string; + public static cloneObject(obj: object): object; + public static convertToBuffer(ab: ArrayBuffer | string): Buffer; + public static delayFor(ms: number): Promise; + public static discordSort( + collection: Collection, + ): Collection; + public static escapeMarkdown(text: string, options?: EscapeMarkdownOptions): string; + public static escapeCodeBlock(text: string): string; + public static escapeInlineCode(text: string): string; + public static escapeBold(text: string): string; + public static escapeItalic(text: string): string; + public static escapeUnderline(text: string): string; + public static escapeStrikethrough(text: string): string; + public static escapeSpoiler(text: string): string; + public static cleanCodeBlockContent(text: string): string; + public static fetchRecommendedShards(token: string, guildsPerShard?: number): Promise; + public static flatten(obj: object, ...props: { [key: string]: boolean | string }[]): object; + public static idToBinary(num: Snowflake): string; + public static makeError(obj: { name: string; message: string; stack: string }): Error; + public static makePlainError(err: Error): { name: string; message: string; stack: string }; + public static mergeDefault(def: object, given: object): object; + public static moveElementInArray(array: any[], element: any, newIndex: number, offset?: boolean): number; + public static parseEmoji(text: string): { animated: boolean; name: string; id: string | null } | null; + public static resolveColor(color: ColorResolvable): number; + public static resolveString(data: StringResolvable): string; + public static setPosition( + item: T, + position: number, + relative: boolean, + sorted: Collection, + route: object, + reason?: string, + ): Promise<{ id: Snowflake; position: number }[]>; + public static splitMessage(text: StringResolvable, options?: SplitOptions): string[]; + public static str2ab(str: string): ArrayBuffer; + } + + class VoiceBroadcast extends EventEmitter { + constructor(client: Client); + public client: Client; + public subscribers: StreamDispatcher[]; + public readonly dispatcher: BroadcastDispatcher; + public play(input: string | Readable, options?: StreamOptions): BroadcastDispatcher; + + public on(event: 'end', listener: () => void): this; + public on(event: 'error', listener: (error: Error) => void): this; + public on(event: 'subscribe' | 'unsubscribe', listener: (dispatcher: StreamDispatcher) => void): this; + public on(event: 'warn', listener: (warning: string | Error) => void): this; + public on(event: string, listener: (...args: any[]) => void): this; + + public once(event: 'end', listener: () => void): this; + public once(event: 'error', listener: (error: Error) => void): this; + public once(event: 'subscribe' | 'unsubscribe', listener: (dispatcher: StreamDispatcher) => void): this; + public once(event: 'warn', listener: (warning: string | Error) => void): this; + public once(event: string, listener: (...args: any[]) => void): this; + } + + export class VoiceChannel extends GuildChannel { + constructor(guild: Guild, data?: object); + public bitrate: number; + public readonly editable: boolean; + public readonly full: boolean; + public readonly joinable: boolean; + public readonly speakable: boolean; + public type: 'voice'; + public userLimit: number; + public join(): Promise; + public leave(): void; + public setBitrate(bitrate: number, reason?: string): Promise; + public setUserLimit(userLimit: number, reason?: string): Promise; + } + + class VoiceConnection extends EventEmitter { + constructor(voiceManager: ClientVoiceManager, channel: VoiceChannel); + private authentication: object; + private sockets: object; + private ssrcMap: Map; + private _speaking: Map>; + private _disconnect(): void; + private authenticate(): void; + private authenticateFailed(reason: string): void; + private checkAuthenticated(): void; + private cleanup(): void; + private connect(): void; + private onReady(data: object): void; + private onSessionDescription(mode: string, secret: string): void; + private onSpeaking(data: object): void; + private reconnect(token: string, endpoint: string): void; + private sendVoiceStateUpdate(options: object): Promise; + private setSessionID(sessionID: string): void; + private setSpeaking(value: BitFieldResolvable): void; + private setTokenAndEndpoint(token: string, endpoint: string): void; + private updateChannel(channel: VoiceChannel): void; + + public channel: VoiceChannel; + public readonly client: Client; + public readonly dispatcher: StreamDispatcher; + public player: object; + public receiver: VoiceReceiver; + public speaking: Readonly; + public status: VoiceStatus; + public readonly voice: VoiceState; + public voiceManager: ClientVoiceManager; + public disconnect(): void; + public play(input: VoiceBroadcast | Readable | string, options?: StreamOptions): StreamDispatcher; + + public on(event: 'authenticated' | 'closing' | 'newSession' | 'ready' | 'reconnecting', listener: () => void): this; + public on(event: 'debug', listener: (message: string) => void): this; + public on(event: 'error' | 'failed' | 'disconnect', listener: (error: Error) => void): this; + public on(event: 'speaking', listener: (user: User, speaking: Readonly) => void): this; + public on(event: 'warn', listener: (warning: string | Error) => void): this; + public on(event: string, listener: (...args: any[]) => void): this; + + public once( + event: 'authenticated' | 'closing' | 'newSession' | 'ready' | 'reconnecting', + listener: () => void, + ): this; + public once(event: 'debug', listener: (message: string) => void): this; + public once(event: 'error' | 'failed' | 'disconnect', listener: (error: Error) => void): this; + public once(event: 'speaking', listener: (user: User, speaking: Readonly) => void): this; + public once(event: 'warn', listener: (warning: string | Error) => void): this; + public once(event: string, listener: (...args: any[]) => void): this; + } + + class VoiceReceiver extends EventEmitter { + constructor(connection: VoiceConnection); + public createStream( + user: UserResolvable, + options?: { mode?: 'opus' | 'pcm'; end?: 'silence' | 'manual' }, + ): Readable; + + public on(event: 'debug', listener: (error: Error | string) => void): this; + public on(event: string, listener: (...args: any[]) => void): this; + + public once(event: 'debug', listener: (error: Error | string) => void): this; + public once(event: string, listener: (...args: any[]) => void): this; + } + + export class VoiceRegion { + constructor(data: object); + public custom: boolean; + public deprecated: boolean; + public id: string; + public name: string; + public optimal: boolean; + public vip: boolean; + public toJSON(): object; + } + + export class VoiceState extends Base { + constructor(guild: Guild, data: object); + public readonly channel: VoiceChannel | null; + public channelID?: Snowflake; + public readonly connection: VoiceConnection | null; + public readonly deaf?: boolean; + public guild: Guild; + public id: Snowflake; + public readonly member: GuildMember | null; + public readonly mute?: boolean; + public selfDeaf?: boolean; + public selfMute?: boolean; + public serverDeaf?: boolean; + public serverMute?: boolean; + public sessionID?: string; + public streaming: boolean; + public readonly speaking: boolean | null; + + public setDeaf(deaf: boolean, reason?: string): Promise; + public setMute(mute: boolean, reason?: string): Promise; + public kick(reason?: string): Promise; + public setChannel(channel: ChannelResolvable | null, reason?: string): Promise; + public setSelfDeaf(deaf: boolean): Promise; + public setSelfMute(mute: boolean): Promise; + } + + class VolumeInterface extends EventEmitter { + constructor(options?: { volume?: number }); + public readonly volume: number; + public readonly volumeDecibels: number; + public readonly volumeEditable: boolean; + public readonly volumeLogarithmic: number; + public setVolume(volume: number): void; + public setVolumeDecibels(db: number): void; + public setVolumeLogarithmic(value: number): void; + + public on(event: 'volumeChange', listener: (oldVolume: number, newVolume: number) => void): this; + + public once(event: 'volumeChange', listener: (oldVolume: number, newVolume: number) => void): this; + } + + export class Webhook extends WebhookMixin() { + constructor(client: Client, data?: object); + public avatar: string; + public avatarURL(options?: ImageURLOptions): string | null; + public channelID: Snowflake; + public client: Client; + public guildID: Snowflake; + public name: string; + public owner: User | object | null; + public token: string | null; + public type: WebhookTypes; + } + + export class WebhookClient extends WebhookMixin(BaseClient) { + constructor(id: string, token: string, options?: ClientOptions); + public client: this; + public token: string; + } + + export class WebSocketManager extends EventEmitter { + constructor(client: Client); + private totalShards: number | string; + private shardQueue: Set; + private packetQueue: object[]; + private destroyed: boolean; + private reconnecting: boolean; + private sessionStartLimit?: { total: number; remaining: number; reset_after: number }; + + public readonly client: Client; + public gateway?: string; + public shards: Collection; + public status: Status; + public readonly ping: number; + + public on(event: WSEventType, listener: (data: any, shardID: number) => void): this; + public once(event: WSEventType, listener: (data: any, shardID: number) => void): this; + + private debug(message: string, shard?: WebSocketShard): void; + private connect(): Promise; + private createShards(): Promise; + private reconnect(): Promise; + private broadcast(packet: object): void; + private destroy(): void; + private _handleSessionLimit(remaining?: number, resetAfter?: number): Promise; + private handlePacket(packet?: object, shard?: WebSocketShard): boolean; + private checkShardsReady(): Promise; + private triggerClientReady(): void; + } + + export class WebSocketShard extends EventEmitter { + constructor(manager: WebSocketManager, id: number); + private sequence: number; + private closeSequence: number; + private sessionID?: string; + private lastPingTimestamp: number; + private lastHeartbeatAcked: boolean; + private ratelimit: { queue: object[]; total: number; remaining: number; time: 60e3; timer: NodeJS.Timeout | null }; + private connection: WebSocket | null; + private helloTimeout: NodeJS.Timeout | undefined; + private eventsAttached: boolean; + private expectedGuilds: Set | undefined; + private readyTimeout: NodeJS.Timeout | undefined; + + public manager: WebSocketManager; + public id: number; + public status: Status; + public ping: number; + + private debug(message: string): void; + private connect(): Promise; + private onOpen(): void; + private onMessage(event: MessageEvent): void; + private onError(error: ErrorEvent | object): void; + private onClose(event: CloseEvent): void; + private onPacket(packet: object): void; + private checkReady(): void; + private setHelloTimeout(time?: number): void; + private setHeartbeatTimer(time: number): void; + private sendHeartbeat(): void; + private ackHeartbeat(): void; + private identify(): void; + private identifyNew(): void; + private identifyResume(): void; + private _send(data: object): void; + private processQueue(): void; + private destroy(destroyOptions?: { closeCode?: number; reset?: boolean; emit?: boolean; log?: boolean }): void; + private _cleanupConnection(): void; + private _emitDestroyed(): void; + + public send(data: object): void; + public on(event: 'ready' | 'resumed' | 'invalidSession', listener: () => void): this; + public on(event: 'close', listener: (event: CloseEvent) => void): this; + public on(event: 'allReady', listener: (unavailableGuilds?: Set) => void): this; + public on(event: string, listener: (...args: any[]) => void): this; + + public once(event: 'ready' | 'resumed' | 'invalidSession', listener: () => void): this; + public once(event: 'close', listener: (event: CloseEvent) => void): this; + public once(event: 'allReady', listener: (unavailableGuilds?: Set) => void): this; + public once(event: string, listener: (...args: any[]) => void): this; + } + + //#endregion + + //#region Collections + + export class Collection extends BaseCollection { + public flatMap( + fn: (value: V, key: K, collection: this) => Collection, + thisArg?: unknown, + ): Collection; + public flatMap( + fn: (this: This, value: V, key: K, collection: this) => Collection, + thisArg: This, + ): Collection; + public mapValues(fn: (value: V, key: K, collection: this) => T, thisArg?: unknown): Collection; + public mapValues( + fn: (this: This, value: V, key: K, collection: this) => T, + thisArg: This, + ): Collection; + public toJSON(): object; + } + + //#endregion + + //#region Managers + + export class ChannelManager extends BaseManager { + constructor(client: Client, iterable: Iterable); + public fetch(id: Snowflake, cache?: boolean): Promise; + } + + export abstract class BaseManager { + constructor(client: Client, iterable: Iterable, holds: Constructable, cacheType: Collection); + public holds: Constructable; + public cache: Collection; + public cacheType: Collection; + public readonly client: Client; + public add(data: any, cache?: boolean, { id, extras }?: { id: K; extras: any[] }): Holds; + public remove(key: K): void; + public resolve(resolvable: R): Holds | null; + public resolveID(resolvable: R): K | null; + } + + export class GuildChannelManager extends BaseManager { + constructor(guild: Guild, iterable?: Iterable); + public guild: Guild; + public create(name: string, options: GuildCreateChannelOptions & { type: 'voice' }): Promise; + public create(name: string, options: GuildCreateChannelOptions & { type: 'category' }): Promise; + public create(name: string, options?: GuildCreateChannelOptions & { type?: 'text' }): Promise; + public create( + name: string, + options: GuildCreateChannelOptions, + ): Promise; + } + + export class GuildEmojiManager extends BaseManager { + constructor(guild: Guild, iterable?: Iterable); + public guild: Guild; + public create( + attachment: BufferResolvable | Base64Resolvable, + name: string, + options?: GuildEmojiCreateOptions, + ): Promise; + public resolveIdentifier(emoji: EmojiIdentifierResolvable): string | null; + } + + export class GuildEmojiRoleManager { + constructor(emoji: GuildEmoji); + public emoji: GuildEmoji; + public guild: Guild; + public cache: Collection; + public add(roleOrRoles: RoleResolvable | RoleResolvable[] | Collection): Promise; + public set(roles: RoleResolvable[] | Collection): Promise; + public remove(roleOrRoles: RoleResolvable | RoleResolvable[] | Collection): Promise; + } + + export class GuildManager extends BaseManager { + constructor(client: Client, iterable?: Iterable); + public create( + name: string, + options?: { region?: string; icon: BufferResolvable | Base64Resolvable | null }, + ): Promise; + } + + export class GuildMemberManager extends BaseManager { + constructor(guild: Guild, iterable?: Iterable); + public guild: Guild; + public ban(user: UserResolvable, options?: BanOptions): Promise; + public fetch( + options: UserResolvable | FetchMemberOptions | (FetchMembersOptions & { user: UserResolvable }), + ): Promise; + public fetch(options?: FetchMembersOptions): Promise>; + public prune(options: GuildPruneMembersOptions & { dry?: false; count: false }): Promise; + public prune(options?: GuildPruneMembersOptions): Promise; + public unban(user: UserResolvable, reason?: string): Promise; + } + + export class GuildMemberRoleManager extends OverridableManager { + constructor(member: GuildMember); + public readonly hoist: Role | null; + public readonly color: Role | null; + public readonly highest: Role; + public member: GuildMember; + public guild: Guild; + + public add( + roleOrRoles: RoleResolvable | RoleResolvable[] | Collection, + reason?: string, + ): Promise; + public set(roles: RoleResolvable[] | Collection, reason?: string): Promise; + public remove( + roleOrRoles: RoleResolvable | RoleResolvable[] | Collection, + reason?: string, + ): Promise; + } + + export class MessageManager extends BaseManager { + constructor(channel: TextChannel | DMChannel, iterable?: Iterable); + public channel: TextBasedChannelFields; + public cache: Collection; + public fetch(message: Snowflake, cache?: boolean): Promise; + public fetch(options?: ChannelLogsQueryOptions, cache?: boolean): Promise>; + public fetchPinned(cache?: boolean): Promise>; + public delete(message: MessageResolvable, reason?: string): Promise; + } + + // Hacky workaround because changing the signature of an overridden method errors + class OverridableManager extends BaseManager { + public add(data: any, cache: any): any; + public set(key: any): any; + } + + export class PresenceManager extends BaseManager { + constructor(client: Client, iterable?: Iterable); + } + + export class ReactionManager extends BaseManager { + constructor(message: Message, iterable?: Iterable); + public message: Message; + public removeAll(): Promise; + } + + export class ReactionUserManager extends BaseManager { + constructor(client: Client, iterable: Iterable | undefined, reaction: MessageReaction); + public reaction: MessageReaction; + public fetch(options?: { + limit?: number; + after?: Snowflake; + before?: Snowflake; + }): Promise>; + public remove(user?: UserResolvable): Promise; + } + + export class RoleManager extends BaseManager { + constructor(guild: Guild, iterable?: Iterable); + public readonly everyone: Role | null; + public readonly highest: Role; + public guild: Guild; + + public create(options?: { data?: RoleData; reason?: string }): Promise; + public fetch(id: Snowflake, cache?: boolean): Promise; + public fetch(id?: Snowflake, cache?: boolean): Promise; + } + + export class UserManager extends BaseManager { + constructor(client: Client, iterable?: Iterable); + public fetch(id: Snowflake, cache?: boolean): Promise; + } + + export class VoiceStateManager extends BaseManager { + constructor(guild: Guild, iterable?: Iterable); + public guild: Guild; + } + + //#endregion + + //#region Mixins + + // Model the TextBasedChannel mixin system, allowing application of these fields + // to the classes that use these methods without having to manually add them + // to each of those classes + + type Constructable = new (...args: any[]) => T; + function PartialTextBasedChannel(Base?: Constructable): Constructable; + function TextBasedChannel(Base?: Constructable): Constructable; + + interface PartialTextBasedChannelFields { + lastMessageID: Snowflake | null; + lastMessageChannelID: Snowflake | null; + readonly lastMessage: Message | null; + lastPinTimestamp: number | null; + readonly lastPinAt: Date; + send( + content?: StringResolvable, + options?: MessageOptions | MessageAdditions | (MessageOptions & { split?: false }) | MessageAdditions, + ): Promise; + send( + content?: StringResolvable, + options?: (MessageOptions & { split: true | SplitOptions }) | MessageAdditions, + ): Promise; + send( + options?: + | MessageOptions + | MessageAdditions + | APIMessage + | (MessageOptions & { split?: false }) + | MessageAdditions + | APIMessage, + ): Promise; + send( + options?: (MessageOptions & { split: true | SplitOptions }) | MessageAdditions | APIMessage, + ): Promise; + } + + interface TextBasedChannelFields extends PartialTextBasedChannelFields { + typing: boolean; + typingCount: number; + awaitMessages(filter: CollectorFilter, options?: AwaitMessagesOptions): Promise>; + bulkDelete( + messages: Collection | Message[] | Snowflake[] | number, + filterOld?: boolean, + ): Promise>; + createMessageCollector(filter: CollectorFilter, options?: MessageCollectorOptions): MessageCollector; + startTyping(count?: number): Promise; + stopTyping(force?: boolean): void; + } + + function WebhookMixin(Base?: Constructable): Constructable; + + function VolumeMixin(base: Constructable): Constructable; + + interface WebhookFields { + id: Snowflake; + readonly createdAt: Date; + readonly createdTimestamp: number; + readonly url: string; + delete(reason?: string): Promise; + edit(options: WebhookEditData): Promise; + send( + content?: StringResolvable, + options?: (WebhookMessageOptions & { split?: false }) | MessageAdditions, + ): Promise; + send( + content?: StringResolvable, + options?: (WebhookMessageOptions & { split: true | SplitOptions }) | MessageAdditions, + ): Promise; + send(options?: (WebhookMessageOptions & { split?: false }) | MessageAdditions | APIMessage): Promise; + send( + options?: (WebhookMessageOptions & { split: true | SplitOptions }) | MessageAdditions | APIMessage, + ): Promise; + sendSlackMessage(body: object): Promise; + } + + //#endregion + + //#region Typedefs + + type ActivityFlagsString = 'INSTANCE' | 'JOIN' | 'SPECTATE' | 'JOIN_REQUEST' | 'SYNC' | 'PLAY'; + + interface ActivityOptions { + name?: string; + url?: string; + type?: ActivityType | number; + shardID?: number | number[]; + } + + type ActivityType = 'PLAYING' | 'STREAMING' | 'LISTENING' | 'WATCHING' | 'CUSTOM_STATUS'; + + interface AddGuildMemberOptions { + accessToken: string; + nick?: string; + roles?: Collection | RoleResolvable[]; + mute?: boolean; + deaf?: boolean; + } + + interface APIErrror { + UNKNOWN_ACCOUNT: number; + UNKNOWN_APPLICATION: number; + UNKNOWN_CHANNEL: number; + UNKNOWN_GUILD: number; + UNKNOWN_INTEGRATION: number; + UNKNOWN_INVITE: number; + UNKNOWN_MEMBER: number; + UNKNOWN_MESSAGE: number; + UNKNOWN_OVERWRITE: number; + UNKNOWN_PROVIDER: number; + UNKNOWN_ROLE: number; + UNKNOWN_TOKEN: number; + UNKNOWN_USER: number; + UNKNOWN_EMOJI: number; + UNKNOWN_WEBHOOK: number; + BOT_PROHIBITED_ENDPOINT: number; + BOT_ONLY_ENDPOINT: number; + MAXIMUM_GUILDS: number; + MAXIMUM_FRIENDS: number; + MAXIMUM_PINS: number; + MAXIMUM_ROLES: number; + MAXIMUM_REACTIONS: number; + UNAUTHORIZED: number; + MISSING_ACCESS: number; + INVALID_ACCOUNT_TYPE: number; + CANNOT_EXECUTE_ON_DM: number; + EMBED_DISABLED: number; + CANNOT_EDIT_MESSAGE_BY_OTHER: number; + CANNOT_SEND_EMPTY_MESSAGE: number; + CANNOT_MESSAGE_USER: number; + CANNOT_SEND_MESSAGES_IN_VOICE_CHANNEL: number; + CHANNEL_VERIFICATION_LEVEL_TOO_HIGH: number; + OAUTH2_APPLICATION_BOT_ABSENT: number; + MAXIMUM_OAUTH2_APPLICATIONS: number; + INVALID_OAUTH_STATE: number; + MISSING_PERMISSIONS: number; + INVALID_AUTHENTICATION_TOKEN: number; + NOTE_TOO_LONG: number; + INVALID_BULK_DELETE_QUANTITY: number; + CANNOT_PIN_MESSAGE_IN_OTHER_CHANNEL: number; + CANNOT_EXECUTE_ON_SYSTEM_MESSAGE: number; + BULK_DELETE_MESSAGE_TOO_OLD: number; + INVITE_ACCEPTED_TO_GUILD_NOT_CONTAINING_BOT: number; + REACTION_BLOCKED: number; + } + + interface AuditLogChange { + key: string; + old?: any; + new?: any; + } + + interface AwaitMessagesOptions extends MessageCollectorOptions { + errors?: string[]; + } + + interface AwaitReactionsOptions extends ReactionCollectorOptions { + errors?: string[]; + } + + interface BanOptions { + days?: number; + reason?: string; + } + + type Base64Resolvable = Buffer | Base64String; + + type Base64String = string; + + type BitFieldResolvable = + | RecursiveArray>> + | T + | number + | Readonly>; + + type BufferResolvable = Buffer | string; + + interface ChannelCreationOverwrites { + allow?: PermissionResolvable | number; + deny?: PermissionResolvable | number; + id: RoleResolvable | UserResolvable; + } + + interface ChannelData { + name?: string; + position?: number; + topic?: string; + nsfw?: boolean; + bitrate?: number; + userLimit?: number; + parentID?: Snowflake; + rateLimitPerUser?: number; + lockPermissions?: boolean; + permissionOverwrites?: OverwriteResolvable[] | Collection; + } + + interface ChannelLogsQueryOptions { + limit?: number; + before?: Snowflake; + after?: Snowflake; + around?: Snowflake; + } + + interface ChannelPosition { + channel: ChannelResolvable; + position: number; + } + + type ChannelResolvable = Channel | Snowflake; + + interface ClientApplicationAsset { + name: string; + id: Snowflake; + type: 'BIG' | 'SMALL'; + } + + interface ClientOptions { + shards?: number | number[] | 'auto'; + shardCount?: number; + messageCacheMaxSize?: number; + messageCacheLifetime?: number; + messageSweepInterval?: number; + fetchAllMembers?: boolean; + disableMentions?: 'none' | 'all' | 'everyone'; + partials?: PartialTypes[]; + restWsBridgeTimeout?: number; + restTimeOffset?: number; + restRequestTimeout?: number; + restSweepInterval?: number; + retryLimit?: number; + presence?: PresenceData; + ws?: WebSocketOptions; + http?: HTTPOptions; + } + + type ClientPresenceStatus = 'online' | 'idle' | 'dnd'; + + interface ClientPresenceStatusData { + web?: ClientPresenceStatus; + mobile?: ClientPresenceStatus; + desktop?: ClientPresenceStatus; + } + + interface CloseEvent { + wasClean: boolean; + code: number; + reason: string; + target: WebSocket; + } + + type CollectorFilter = (...args: any[]) => boolean; + + interface CollectorOptions { + time?: number; + idle?: number; + dispose?: boolean; + } + + type ColorResolvable = + | 'DEFAULT' + | 'WHITE' + | 'AQUA' + | 'GREEN' + | 'BLUE' + | 'YELLOW' + | 'PURPLE' + | 'LUMINOUS_VIVID_PINK' + | 'GOLD' + | 'ORANGE' + | 'RED' + | 'GREY' + | 'DARKER_GREY' + | 'NAVY' + | 'DARK_AQUA' + | 'DARK_GREEN' + | 'DARK_BLUE' + | 'DARK_PURPLE' + | 'DARK_VIVID_PINK' + | 'DARK_GOLD' + | 'DARK_ORANGE' + | 'DARK_RED' + | 'DARK_GREY' + | 'LIGHT_GREY' + | 'DARK_NAVY' + | 'RANDOM' + | [number, number, number] + | number + | string; + + interface CrosspostedChannel { + channelID: Snowflake; + guildID: Snowflake; + type: keyof typeof ChannelType; + name: string; + } + + interface DeconstructedSnowflake { + timestamp: number; + readonly date: Date; + workerID: number; + processID: number; + increment: number; + binary: string; + } + + type DefaultMessageNotifications = 'ALL' | 'MENTIONS'; + + interface EmbedField { + name: string; + value: string; + inline: boolean; + } + + interface EmbedFieldData { + name: StringResolvable; + value: StringResolvable; + inline?: boolean; + } + + type EmojiIdentifierResolvable = string | EmojiResolvable; + + type EmojiResolvable = Snowflake | GuildEmoji | ReactionEmoji; + + interface ErrorEvent { + error: any; + message: string; + type: string; + target: WebSocket; + } + + interface EscapeMarkdownOptions { + codeBlock?: boolean; + inlineCode?: boolean; + bold?: boolean; + italic?: boolean; + underline?: boolean; + strikethrough?: boolean; + spoiler?: boolean; + inlineCodeContent?: boolean; + codeBlockContent?: boolean; + } + + type ExplicitContentFilterLevel = 'DISABLED' | 'MEMBERS_WITHOUT_ROLES' | 'ALL_MEMBERS'; + + interface Extendable { + GuildEmoji: typeof GuildEmoji; + DMChannel: typeof DMChannel; + TextChannel: typeof TextChannel; + VoiceChannel: typeof VoiceChannel; + CategoryChannel: typeof CategoryChannel; + NewsChannel: typeof NewsChannel; + StoreChannel: typeof StoreChannel; + GuildMember: typeof GuildMember; + Guild: typeof Guild; + Message: typeof Message; + MessageReaction: typeof MessageReaction; + Presence: typeof Presence; + VoiceState: typeof VoiceState; + Role: typeof Role; + User: typeof User; + } + + interface FetchMemberOptions { + user: UserResolvable; + cache?: boolean; + } + + interface FetchMembersOptions { + user?: UserResolvable | UserResolvable[]; + query?: string; + limit?: number; + withPresences?: boolean; + } + + interface FileOptions { + attachment: BufferResolvable | Stream; + name?: string; + } + + type GuildAuditLogsAction = keyof GuildAuditLogsActions; + + interface GuildAuditLogsActions { + ALL?: null; + GUILD_UPDATE?: number; + CHANNEL_CREATE?: number; + CHANNEL_UPDATE?: number; + CHANNEL_DELETE?: number; + CHANNEL_OVERWRITE_CREATE?: number; + CHANNEL_OVERWRITE_UPDATE?: number; + CHANNEL_OVERWRITE_DELETE?: number; + MEMBER_KICK?: number; + MEMBER_PRUNE?: number; + MEMBER_BAN_ADD?: number; + MEMBER_BAN_REMOVE?: number; + MEMBER_UPDATE?: number; + MEMBER_ROLE_UPDATE?: number; + MEMBER_MOVE?: number; + MEMBER_DISCONNECT?: number; + BOT_ADD?: number; + ROLE_CREATE?: number; + ROLE_UPDATE?: number; + ROLE_DELETE?: number; + INVITE_CREATE?: number; + INVITE_UPDATE?: number; + INVITE_DELETE?: number; + WEBHOOK_CREATE?: number; + WEBHOOK_UPDATE?: number; + WEBHOOK_DELETE?: number; + EMOJI_CREATE?: number; + EMOJI_UPDATE?: number; + EMOJI_DELETE?: number; + MESSAGE_DELETE?: number; + MESSAGE_BULK_DELETE?: number; + MESSAGE_PIN?: number; + MESSAGE_UNPIN?: number; + INTEGRATION_CREATE?: number; + INTEGRATION_UPDATE?: number; + INTEGRATION_DELETE?: number; + } + + type GuildAuditLogsActionType = 'CREATE' | 'DELETE' | 'UPDATE' | 'ALL'; + + interface GuildAuditLogsFetchOptions { + before?: Snowflake | GuildAuditLogsEntry; + limit?: number; + user?: UserResolvable; + type?: GuildAuditLogsAction | number; + } + + type GuildAuditLogsTarget = keyof GuildAuditLogsTargets; + + interface GuildAuditLogsTargets { + ALL?: string; + GUILD?: string; + CHANNEL?: string; + USER?: string; + ROLE?: string; + INVITE?: string; + WEBHOOK?: string; + EMOJI?: string; + MESSAGE?: string; + INTEGRATION?: string; + UNKNOWN?: string; + } + + type GuildChannelResolvable = Snowflake | GuildChannel; + + interface GuildCreateChannelOptions { + permissionOverwrites?: OverwriteResolvable[] | Collection; + topic?: string; + type?: Exclude< + keyof typeof ChannelType | ChannelType, + 'dm' | 'group' | 'unknown' | ChannelType.dm | ChannelType.group | ChannelType.unknown + >; + nsfw?: boolean; + parent?: ChannelResolvable; + bitrate?: number; + userLimit?: number; + rateLimitPerUser?: number; + position?: number; + reason?: string; + } + + interface GuildChannelCloneOptions extends GuildCreateChannelOptions { + name?: string; + } + + interface GuildEditData { + name?: string; + region?: string; + verificationLevel?: VerificationLevel; + explicitContentFilter?: ExplicitContentFilterLevel; + defaultMessageNotifications?: DefaultMessageNotifications | number; + afkChannel?: ChannelResolvable; + systemChannel?: ChannelResolvable; + systemChannelFlags?: SystemChannelFlagsResolvable; + afkTimeout?: number; + icon?: Base64Resolvable; + owner?: GuildMemberResolvable; + splash?: Base64Resolvable; + banner?: Base64Resolvable; + } + + interface GuildEmbedData { + enabled: boolean; + channel: GuildChannelResolvable | null; + } + + interface GuildEmojiCreateOptions { + roles?: Collection | RoleResolvable[]; + reason?: string; + } + + interface GuildEmojiEditData { + name?: string; + roles?: Collection | RoleResolvable[]; + } + + type GuildFeatures = + | 'ANIMATED_ICON' + | 'BANNER' + | 'COMMERCE' + | 'DISCOVERABLE' + | 'FEATURABLE' + | 'INVITE_SPLASH' + | 'PUBLIC' + | 'NEWS' + | 'PARTNERED' + | 'VANITY_URL' + | 'VERIFIED' + | 'VIP_REGIONS'; + + interface GuildMemberEditData { + nick?: string; + roles?: Collection | RoleResolvable[]; + mute?: boolean; + deaf?: boolean; + channel?: ChannelResolvable | null; + } + + type GuildMemberResolvable = GuildMember | UserResolvable; + + type GuildResolvable = Guild | GuildChannel | GuildMember | GuildEmoji | Invite | Role | Snowflake; + + interface GuildPruneMembersOptions { + count?: boolean; + days?: number; + dry?: boolean; + reason?: string; + } + + interface HTTPOptions { + api?: string; + version?: number; + host?: string; + cdn?: string; + invite?: string; + } + + type ImageExt = 'webp' | 'png' | 'jpg' | 'gif'; + + type ImageSize = 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048; + + interface ImageURLOptions { + format?: ImageExt; + size?: ImageSize; + } + + interface IntegrationData { + id: string; + type: string; + } + + interface IntegrationEditData { + expireBehavior?: number; + expireGracePeriod?: number; + } + + interface IntegrationAccount { + id: string; + name: string; + } + + type IntentsString = + | 'GUILDS' + | 'GUILD_MEMBERS' + | 'GUILD_BANS' + | 'GUILD_EMOJIS' + | 'GUILD_INTEGRATIONS' + | 'GUILD_WEBHOOKS' + | 'GUILD_INVITES' + | 'GUILD_VOICE_STATES' + | 'GUILD_PRESENCES' + | 'GUILD_MESSAGES' + | 'GUILD_MESSAGE_REACTIONS' + | 'GUILD_MESSAGE_TYPING' + | 'DIRECT_MESSAGES' + | 'DIRECT_MESSAGE_REACTIONS' + | 'DIRECT_MESSAGE_TYPING'; + + interface InviteOptions { + temporary?: boolean; + maxAge?: number; + maxUses?: number; + unique?: boolean; + reason?: string; + } + + type InviteResolvable = string; + + type MembershipStates = 'INVITED' | 'ACCEPTED'; + + type MessageAdditions = MessageEmbed | MessageAttachment | (MessageEmbed | MessageAttachment)[]; + + interface MessageActivity { + partyID: string; + type: number; + } + + interface MessageCollectorOptions extends CollectorOptions { + max?: number; + maxProcessed?: number; + } + + interface MessageEditOptions { + content?: string; + embed?: MessageEmbedOptions | null; + code?: string | boolean; + flags?: BitFieldResolvable; + } + + interface MessageEmbedAuthor { + name?: string; + url?: string; + iconURL?: string; + proxyIconURL?: string; + } + + interface MessageEmbedFooter { + text?: string; + iconURL?: string; + proxyIconURL?: string; + } + + interface MessageEmbedImage { + url: string; + proxyURL?: string; + height?: number; + width?: number; + } + + interface MessageEmbedOptions { + title?: string; + description?: string; + url?: string; + timestamp?: Date | number; + color?: ColorResolvable; + fields?: EmbedFieldData[]; + files?: (MessageAttachment | string | FileOptions)[]; + author?: Partial & { icon_url?: string; proxy_icon_url?: string }; + thumbnail?: Partial & { proxy_url?: string }; + image?: Partial & { proxy_url?: string }; + video?: Partial & { proxy_url?: string }; + footer?: Partial & { icon_url?: string; proxy_icon_url?: string }; + } + + interface MessageEmbedProvider { + name: string; + url: string; + } + + interface MessageEmbedThumbnail { + url: string; + proxyURL?: string; + height?: number; + width?: number; + } + + interface MessageEmbedVideo { + url?: string; + proxyURL?: string; + height?: number; + width?: number; + } + + interface MessageEvent { + data: WebSocket.Data; + type: string; + target: WebSocket; + } + + type MessageFlagsString = 'CROSSPOSTED' | 'IS_CROSSPOST' | 'SUPPRESS_EMBEDS' | 'SOURCE_MESSAGE_DELETED' | 'URGENT'; + + interface MessageOptions { + tts?: boolean; + nonce?: string; + content?: string; + embed?: MessageEmbed | MessageEmbedOptions; + disableMentions?: 'none' | 'all' | 'everyone'; + files?: (FileOptions | BufferResolvable | Stream | MessageAttachment)[]; + code?: string | boolean; + split?: boolean | SplitOptions; + reply?: UserResolvable; + } + + type MessageReactionResolvable = MessageReaction | Snowflake; + + interface MessageReference { + channelID: string; + guildID: string; + messageID: string | null; + } + + type MessageResolvable = Message | Snowflake; + + type MessageTarget = TextChannel | DMChannel | User | GuildMember | Webhook | WebhookClient; + + type MessageType = + | 'DEFAULT' + | 'RECIPIENT_ADD' + | 'RECIPIENT_REMOVE' + | 'CALL' + | 'CHANNEL_NAME_CHANGE' + | 'CHANNEL_ICON_CHANGE' + | 'PINS_ADD' + | 'GUILD_MEMBER_JOIN' + | 'USER_PREMIUM_GUILD_SUBSCRIPTION' + | 'USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1' + | 'USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2' + | 'USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3' + | 'CHANNEL_FOLLOW_ADD' + | 'GUILD_DISCOVERY_DISQUALIFIED' + | 'GUILD_DISCOVERY_REQUALIFIED'; + + interface OverwriteData { + allow?: PermissionResolvable; + deny?: PermissionResolvable; + id: GuildMemberResolvable | RoleResolvable; + type?: OverwriteType; + } + + type OverwriteResolvable = PermissionOverwrites | OverwriteData; + + type OverwriteType = 'member' | 'role'; + + interface PermissionFlags extends Record {} + + interface PermissionObject extends Record {} + + interface PermissionOverwriteOption extends Partial> {} + + type PermissionResolvable = BitFieldResolvable; + + type PermissionString = + | 'CREATE_INSTANT_INVITE' + | 'KICK_MEMBERS' + | 'BAN_MEMBERS' + | 'ADMINISTRATOR' + | 'MANAGE_CHANNELS' + | 'MANAGE_GUILD' + | 'ADD_REACTIONS' + | 'VIEW_AUDIT_LOG' + | 'PRIORITY_SPEAKER' + | 'STREAM' + | 'VIEW_CHANNEL' + | 'SEND_MESSAGES' + | 'SEND_TTS_MESSAGES' + | 'MANAGE_MESSAGES' + | 'EMBED_LINKS' + | 'ATTACH_FILES' + | 'READ_MESSAGE_HISTORY' + | 'MENTION_EVERYONE' + | 'USE_EXTERNAL_EMOJIS' + | 'CONNECT' + | 'SPEAK' + | 'MUTE_MEMBERS' + | 'DEAFEN_MEMBERS' + | 'MOVE_MEMBERS' + | 'USE_VAD' + | 'CHANGE_NICKNAME' + | 'MANAGE_NICKNAMES' + | 'MANAGE_ROLES' + | 'MANAGE_WEBHOOKS' + | 'MANAGE_EMOJIS'; + + interface RecursiveArray extends Array> {} + + interface PermissionOverwriteOptions { + allow: PermissionResolvable; + deny: PermissionResolvable; + id: UserResolvable | RoleResolvable; + } + + type PremiumTier = number; + + interface PresenceData { + status?: PresenceStatusData; + afk?: boolean; + activity?: { + name?: string; + type?: ActivityType | number; + url?: string; + }; + shardID?: number | number[]; + } + + type PresenceResolvable = Presence | UserResolvable | Snowflake; + + type Partialize = { + id: string; + partial: true; + fetch(): Promise; + } & { + [K in keyof Omit]: T[K] | null; + }; + + interface PartialChannel extends Partialize {} + + interface PartialChannelData { + id?: number; + name: string; + topic?: string; + type?: ChannelType; + parentID?: number; + permissionOverwrites?: { + id: number | Snowflake; + type?: OverwriteType; + allow?: PermissionResolvable; + deny?: PermissionResolvable; + }[]; + } + + interface PartialGuildMember extends Partialize {} + interface PartialMessage extends Partialize {} + + interface PartialRoleData extends RoleData { + id?: number; + } + + type PartialTypes = 'USER' | 'CHANNEL' | 'GUILD_MEMBER' | 'MESSAGE' | 'REACTION'; + + interface PartialUser extends Partialize {} + + type PresenceStatus = ClientPresenceStatus | 'offline'; + + type PresenceStatusData = ClientPresenceStatus | 'invisible'; + + interface RateLimitData { + timeout: number; + limit: number; + timeDifference: number; + method: string; + path: string; + route: string; + } + + interface RawOverwriteData { + id: Snowflake; + allow: number; + deny: number; + type: OverwriteType; + } + + interface ReactionCollectorOptions extends CollectorOptions { + max?: number; + maxEmojis?: number; + maxUsers?: number; + } + + interface ResolvedOverwriteOptions { + allow: Permissions; + deny: Permissions; + } + + interface RoleData { + name?: string; + color?: ColorResolvable; + hoist?: boolean; + position?: number; + permissions?: PermissionResolvable; + mentionable?: boolean; + } + + interface RolePosition { + role: RoleResolvable; + position: number; + } + + type RoleResolvable = Role | string; + + type ShardingManagerMode = 'process' | 'worker'; + + type Snowflake = string; + + interface SplitOptions { + maxLength?: number; + char?: string; + prepend?: string; + append?: string; + } + + type Status = number; + + interface StreamOptions { + type?: StreamType; + seek?: number; + volume?: number | boolean; + plp?: number; + fec?: boolean; + bitrate?: number | 'auto'; + highWaterMark?: number; + } + + type SpeakingString = 'SPEAKING' | 'SOUNDSHARE' | 'PRIORITY_SPEAKING'; + + type StreamType = 'unknown' | 'converted' | 'opus' | 'ogg/opus' | 'webm/opus'; + + type StringResolvable = string | string[] | any; + + type SystemChannelFlagsString = 'WELCOME_MESSAGE_DISABLED' | 'BOOST_MESSAGE_DISABLED'; + + type SystemChannelFlagsResolvable = BitFieldResolvable; + + type TargetUser = number; + + type UserResolvable = User | Snowflake | Message | GuildMember; + + type VerificationLevel = 'NONE' | 'LOW' | 'MEDIUM' | 'HIGH' | 'VERY_HIGH'; + + type VoiceStatus = number; + + interface WebhookEditData { + name?: string; + avatar?: BufferResolvable; + channel?: ChannelResolvable; + reason?: string; + } + + interface WebhookMessageOptions { + username?: string; + avatarURL?: string; + tts?: boolean; + nonce?: string; + embeds?: (MessageEmbed | object)[]; + disableMentions?: 'none' | 'all' | 'everyone'; + files?: (FileOptions | BufferResolvable | Stream | MessageAttachment)[]; + code?: string | boolean; + split?: boolean | SplitOptions; + } + + type WebhookTypes = 'Incoming' | 'Channel Follower'; + + interface WebSocketOptions { + large_threshold?: number; + compress?: boolean; + intents?: BitFieldResolvable | number; + } + + type WSEventType = + | 'READY' + | 'RESUMED' + | 'GUILD_CREATE' + | 'GUILD_DELETE' + | 'GUILD_UPDATE' + | 'INVITE_CREATE' + | 'INVITE_DELETE' + | 'GUILD_MEMBER_ADD' + | 'GUILD_MEMBER_REMOVE' + | 'GUILD_MEMBER_UPDATE' + | 'GUILD_MEMBERS_CHUNK' + | 'GUILD_ROLE_CREATE' + | 'GUILD_ROLE_DELETE' + | 'GUILD_ROLE_UPDATE' + | 'GUILD_BAN_ADD' + | 'GUILD_BAN_REMOVE' + | 'GUILD_EMOJIS_UPDATE' + | 'GUILD_INTEGRATIONS_UPDATE' + | 'CHANNEL_CREATE' + | 'CHANNEL_DELETE' + | 'CHANNEL_UPDATE' + | 'CHANNEL_PINS_UPDATE' + | 'MESSAGE_CREATE' + | 'MESSAGE_DELETE' + | 'MESSAGE_UPDATE' + | 'MESSAGE_DELETE_BULK' + | 'MESSAGE_REACTION_ADD' + | 'MESSAGE_REACTION_REMOVE' + | 'MESSAGE_REACTION_REMOVE_ALL' + | 'MESSAGE_REACTION_REMOVE_EMOJI' + | 'USER_UPDATE' + | 'PRESENCE_UPDATE' + | 'TYPING_START' + | 'VOICE_STATE_UPDATE' + | 'VOICE_SERVER_UPDATE' + | 'WEBHOOKS_UPDATE'; + + //#endregion } diff --git a/webpack.config.js b/webpack.config.js index 6208432e3..2fb29975e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,62 +1,63 @@ -/* - ONLY RUN BUILDS WITH `npm run webpack`! - DO NOT USE NORMAL WEBPACK! IT WILL NOT WORK! -*/ +'use strict'; +const path = require('path'); +const TerserJSPlugin = require('terser-webpack-plugin'); const webpack = require('webpack'); -const createVariants = require('parallel-webpack').createVariants; -const UglifyJSPlugin = require('uglifyjs-webpack-plugin'); const version = require('./package.json').version; -const createConfig = options => { - const plugins = [ - new webpack.DefinePlugin({ 'global.GENTLY': false }), - new webpack.optimize.ModuleConcatenationPlugin(), - new webpack.DefinePlugin({ - 'process.env': { - __DISCORD_WEBPACK__: '"true"', - }, - 'process.emitWarning': (any, ...more) => console.warn(any, more), - }), - ]; +const prod = process.env.NODE_ENV === 'production'; - const filename = `./webpack/discord${process.env.VERSIONED === 'false' ? '' : '.' + version}${options.mode === 'production' ? '.min' : ''}.js`; // eslint-disable-line +// eslint-disable-next-line max-len +const filename = `discord${process.env.VERSIONED ? `.${version}` : ''}${prod ? '.min' : ''}.js`; - return { - entry: './browser.js', - mode: options.mode, - output: { - path: __dirname, - filename, - }, - module: { - rules: [ - { test: /\.md$/, loader: 'ignore-loader' }, - ], - }, - node: { - fs: 'empty', - dns: 'mock', - tls: 'mock', - child_process: 'empty', - dgram: 'empty', - zlib: 'empty', - __dirname: true, - process: true, - }, - optimization: { - minimizer: [ - new UglifyJSPlugin({ - uglifyOptions: { - mangle: { keep_classnames: true }, - compress: { keep_classnames: true }, - output: { comments: false }, +module.exports = { + entry: './src/index.js', + mode: prod ? 'production' : 'development', + output: { + path: path.resolve('./webpack'), + filename, + library: 'Discord', + libraryTarget: 'umd', + }, + module: { + rules: [ + { test: /\.md$/, loader: 'ignore-loader' }, + { + test: require.resolve('./package.json'), + type: 'javascript/auto', + use: { + loader: 'json-filter-loader', + options: { + used: ['version', 'homepage'], }, - }), - ], - }, - plugins, - }; + }, + }, + ], + }, + node: { + fs: 'empty', + dns: 'mock', + tls: 'mock', + child_process: 'empty', + dgram: 'empty', + __dirname: true, + process: true, + path: 'empty', + Buffer: false, + zlib: 'empty', + }, + optimization: { + minimizer: [ + new TerserJSPlugin({ + cache: false, + terserOptions: { + mangle: { keep_classnames: true }, + compress: { keep_classnames: true }, + keep_classnames: true, + output: { comments: false }, + }, + }), + ], + }, + plugins: [new webpack.optimize.ModuleConcatenationPlugin()], }; - -module.exports = createVariants({}, { mode: ['development', 'production'] }, createConfig);