Spaces:
Runtime error
Runtime error
mahiatlinux
commited on
Commit
•
311cc15
1
Parent(s):
1cc8315
Upload 3053 files
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .dockerignore +5 -0
- .env +57 -0
- .eslintrc.json +53 -0
- .gitignore +5 -0
- Dockerfile +7 -0
- Makefile +27 -0
- README.md +43 -9
- assets/screenshot.png +0 -0
- docker-compose.yml +9 -0
- node_modules/.package-lock.json +369 -0
- node_modules/@discordjs/builders/LICENSE +191 -0
- node_modules/@discordjs/builders/README.md +72 -0
- node_modules/@discordjs/builders/dist/index.d.mts +2008 -0
- node_modules/@discordjs/builders/dist/index.d.ts +2008 -0
- node_modules/@discordjs/builders/dist/index.js +2763 -0
- node_modules/@discordjs/builders/dist/index.js.map +0 -0
- node_modules/@discordjs/builders/dist/index.mjs +2703 -0
- node_modules/@discordjs/builders/dist/index.mjs.map +0 -0
- node_modules/@discordjs/builders/package.json +97 -0
- node_modules/@discordjs/collection/CHANGELOG.md +190 -0
- node_modules/@discordjs/collection/LICENSE +191 -0
- node_modules/@discordjs/collection/README.md +67 -0
- node_modules/@discordjs/collection/dist/index.d.mts +457 -0
- node_modules/@discordjs/collection/dist/index.d.ts +457 -0
- node_modules/@discordjs/collection/dist/index.js +543 -0
- node_modules/@discordjs/collection/dist/index.js.map +1 -0
- node_modules/@discordjs/collection/dist/index.mjs +517 -0
- node_modules/@discordjs/collection/dist/index.mjs.map +1 -0
- node_modules/@discordjs/collection/package.json +76 -0
- node_modules/@discordjs/formatters/LICENSE +191 -0
- node_modules/@discordjs/formatters/README.md +82 -0
- node_modules/@discordjs/formatters/dist/index.d.mts +586 -0
- node_modules/@discordjs/formatters/dist/index.d.ts +586 -0
- node_modules/@discordjs/formatters/dist/index.js +441 -0
- node_modules/@discordjs/formatters/dist/index.js.map +1 -0
- node_modules/@discordjs/formatters/dist/index.mjs +378 -0
- node_modules/@discordjs/formatters/dist/index.mjs.map +1 -0
- node_modules/@discordjs/formatters/package.json +79 -0
- node_modules/@discordjs/rest/LICENSE +192 -0
- node_modules/@discordjs/rest/README.md +139 -0
- node_modules/@discordjs/rest/dist/index.d.mts +901 -0
- node_modules/@discordjs/rest/dist/index.d.ts +901 -0
- node_modules/@discordjs/rest/dist/index.js +1474 -0
- node_modules/@discordjs/rest/dist/index.js.map +0 -0
- node_modules/@discordjs/rest/dist/index.mjs +1432 -0
- node_modules/@discordjs/rest/dist/index.mjs.map +0 -0
- node_modules/@discordjs/rest/dist/strategies/undiciRequest.d.mts +13 -0
- node_modules/@discordjs/rest/dist/strategies/undiciRequest.d.ts +13 -0
- node_modules/@discordjs/rest/dist/strategies/undiciRequest.js +94 -0
- node_modules/@discordjs/rest/dist/strategies/undiciRequest.js.map +1 -0
.dockerignore
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
package-lock.json
|
2 |
+
pnpm-lock.yaml
|
3 |
+
pnpm-lock.yml
|
4 |
+
node_modules/
|
5 |
+
.env
|
.env
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Discord bot token
|
2 |
+
TOKEN=MTIzNTE0MjgyODE5MTkxMTk2Ng.GTigmW.AkCl8B8TWqsrbRrgvuu1QWO7vgr-GLWN51qMW8
|
3 |
+
|
4 |
+
# What language model to use, orca is one of the lower-end models that doesn't require as much computer power as llama2
|
5 |
+
MODEL=tinydolphin
|
6 |
+
|
7 |
+
# Ollama URL (if you want to use multiple, separate them by commas)
|
8 |
+
OLLAMA=https://mahiatlinux-ollama-server.hf.space
|
9 |
+
|
10 |
+
# What Discord channels to enable it in (by ID)
|
11 |
+
CHANNELS=1235145472470159391
|
12 |
+
|
13 |
+
# System message that the language model can understand
|
14 |
+
# Feel free to change this
|
15 |
+
#SYSTEM="The current date and time is <date>.
|
16 |
+
|
17 |
+
Basic markdown is supported.
|
18 |
+
Bold: **bold text here**
|
19 |
+
Italics: _italic text here_
|
20 |
+
Underlined: __underlined text here__
|
21 |
+
Strikethrough: ~~strikethrough text here~~
|
22 |
+
Spoiler: ||spoiler text here||
|
23 |
+
Block quotes: Start the line with a > followed by a space, e.g
|
24 |
+
> Hello there
|
25 |
+
|
26 |
+
Inline code blocks are supported by surrounding text in backticks, e.g `print('Hello');`, block code is supported by surrounding text in three backticks, e.g ```print('Hello');```.
|
27 |
+
Surround code that is produced in code blocks. Use a code block with three backticks if the code has multiple lines, otherwise use an inline code block with one backtick.
|
28 |
+
|
29 |
+
Links are supported by wrapping the text in square brackets and the link in parenthesis, e.g [Example](https://example.com)
|
30 |
+
|
31 |
+
Lists are supported by starting the line with a dash followed by a space, e.g - List
|
32 |
+
Numbered lists are supported by starting the line with a number followed by a dot and a space, e.g 1. List.
|
33 |
+
Images, links, tables, LaTeX, and anything else is not supported.
|
34 |
+
|
35 |
+
If you need to use the symbols >, |, _, *, ~, @, #, :, `, put a backslash before them to escape them.
|
36 |
+
|
37 |
+
If the user is chatting casually, your responses should be only a few sentences, unless they are asking for help or a question.
|
38 |
+
Don't use unicode emoji unless needed."
|
39 |
+
|
40 |
+
# Use the system message above? (true/false)
|
41 |
+
USE_SYSTEM=true
|
42 |
+
|
43 |
+
# Use the model's system message? (true/false) If both are specified, model system message will be first
|
44 |
+
USE_MODEL_SYSTEM=true
|
45 |
+
|
46 |
+
# Require users to mention the bot to interact with it? (true/false)
|
47 |
+
REQUIRES_MENTION=true
|
48 |
+
|
49 |
+
# Whether to show a message at the start of a conversation
|
50 |
+
SHOW_START_OF_CONVERSATION=true
|
51 |
+
|
52 |
+
# Whether to use a random Ollama server or use the first available one
|
53 |
+
RANDOM_SERVER=false
|
54 |
+
|
55 |
+
# Whether to add a message before the first prompt of the conversation
|
56 |
+
INITIAL_PROMPT=""
|
57 |
+
USE_INITIAL_PROMPT=false
|
.eslintrc.json
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"extends": "eslint:recommended",
|
3 |
+
"env": {
|
4 |
+
"node": true,
|
5 |
+
"es6": true
|
6 |
+
},
|
7 |
+
"parserOptions": {
|
8 |
+
"ecmaVersion": 2021,
|
9 |
+
"sourceType": "module"
|
10 |
+
},
|
11 |
+
"rules": {
|
12 |
+
"arrow-spacing": ["warn", { "before": true, "after": true }],
|
13 |
+
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
|
14 |
+
"comma-dangle": ["error", "never"],
|
15 |
+
"comma-spacing": "error",
|
16 |
+
"comma-style": "error",
|
17 |
+
"curly": ["error", "multi-line", "consistent"],
|
18 |
+
"dot-location": ["error", "property"],
|
19 |
+
"handle-callback-err": "off",
|
20 |
+
"indent": ["error", "tab", { "SwitchCase": 1 }],
|
21 |
+
"keyword-spacing": "error",
|
22 |
+
"max-nested-callbacks": ["error", { "max": 4 }],
|
23 |
+
"max-statements-per-line": ["error", { "max": 2 }],
|
24 |
+
"no-console": "off",
|
25 |
+
"no-empty": "warn",
|
26 |
+
"no-empty-function": "error",
|
27 |
+
"no-floating-decimal": "error",
|
28 |
+
"no-inline-comments": "error",
|
29 |
+
"no-lonely-if": "error",
|
30 |
+
"no-multi-spaces": "error",
|
31 |
+
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }],
|
32 |
+
"no-shadow": ["error", { "allow": ["err", "resolve", "reject"] }],
|
33 |
+
"no-trailing-spaces": ["error"],
|
34 |
+
"no-var": "error",
|
35 |
+
"object-curly-spacing": ["error", "always"],
|
36 |
+
"prefer-const": "error",
|
37 |
+
"quotes": ["error", "double"],
|
38 |
+
"semi": ["error", "always"],
|
39 |
+
"space-before-blocks": "error",
|
40 |
+
"space-before-function-paren": ["error", {
|
41 |
+
"anonymous": "never",
|
42 |
+
"named": "never",
|
43 |
+
"asyncArrow": "always"
|
44 |
+
}],
|
45 |
+
"space-in-parens": "error",
|
46 |
+
"space-infix-ops": "error",
|
47 |
+
"space-unary-ops": "error",
|
48 |
+
"spaced-comment": "error",
|
49 |
+
"yoda": "error",
|
50 |
+
"default-case-last": "error",
|
51 |
+
"switch-colon-spacing": ["error", {"after": true, "before": false}]
|
52 |
+
}
|
53 |
+
}
|
.gitignore
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
package-lock.json
|
2 |
+
pnpm-lock.yaml
|
3 |
+
pnpm-lock.yml
|
4 |
+
node_modules/
|
5 |
+
.env
|
Dockerfile
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM node:20
|
2 |
+
|
3 |
+
COPY . .
|
4 |
+
RUN npm i --omit=dev --no-package-lock
|
5 |
+
USER node
|
6 |
+
|
7 |
+
CMD ["node","./src/index.js"]
|
Makefile
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# As long as you have Make running on your machine you should be able to use this file.
|
2 |
+
# make <command-name> runs a given command (e.g. make compose-up)
|
3 |
+
# Command-names are given by starting a line without a tab and followed by a colon (i.e.':').
|
4 |
+
# what the command runs is the line below the colon and that line must start with a tab of size 4.
|
5 |
+
# Running make without a command after it will run the first command in the file.
|
6 |
+
|
7 |
+
# starts the discord-ai-bot
|
8 |
+
compose-up:
|
9 |
+
$(MAKE) setup_env && docker compose -p discord-ai up
|
10 |
+
|
11 |
+
# Stops docker compose without removing the containers from the system.
|
12 |
+
compose-stop:
|
13 |
+
docker compose -p discord-ai stop
|
14 |
+
|
15 |
+
# Stops docker compose and removes the containers from the system
|
16 |
+
compose-down:
|
17 |
+
docker compose -p discord-ai down
|
18 |
+
|
19 |
+
# Run the local node project with make and without docker
|
20 |
+
local:
|
21 |
+
$(MAKE) setup_env && npm i && node ./src/index.js
|
22 |
+
|
23 |
+
# This copies the .env.example (source) file to the .env (destination) file location
|
24 |
+
# The -n or no clobber means it will not overwrite the .env file if it already exists.
|
25 |
+
# The || : basically ignores the error code of the previous command and always succeeds.
|
26 |
+
setup_env:
|
27 |
+
cp -n ./.env.example ./.env 2>/dev/null || :
|
README.md
CHANGED
@@ -1,10 +1,44 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
pinned: false
|
8 |
-
---
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div align="center">
|
2 |
+
<h1><a href="#"></a>Discord AI Bot</h1>
|
3 |
+
<h3 align="center"><a href="#"></a>Discord bot to interact with <a href="https://github.com/jmorganca/ollama">Ollama</a> as a chatbot</h3>
|
4 |
+
<h3><a href="#"></a><img alt="Stars" src="https://img.shields.io/github/stars/mekb-turtle/discord-ai-bot?display_name=tag&style=for-the-badge" /></h3>
|
5 |
+
<h3><a href="#"></a><img alt="Discord chat with the bot" src="assets/screenshot.png" /></h3>
|
6 |
+
</div>
|
|
|
|
|
7 |
|
8 |
+
### Archived
|
9 |
+
I have decided to archive this project as I no longer have the time to maintain it. If you would like to take over the project, [please let me know](https://github.com/mekb-turtle).
|
10 |
+
|
11 |
+
### Set-up instructions
|
12 |
+
1. Install [Node.js](https://nodejs.org) (if you have a package manager, use that instead to install this)
|
13 |
+
- Make sure to install at least v14 of Node.js
|
14 |
+
2. Install [Ollama](https://github.com/jmorganca/ollama) (ditto)
|
15 |
+
3. Pull (download) a model, e.g `ollama pull orca` or `ollama pull llama2`
|
16 |
+
4. Start Ollama by running `ollama serve`
|
17 |
+
5. [Create a Discord bot](https://discord.com/developers/applications)
|
18 |
+
- Under Application » Bot
|
19 |
+
- Enable Message Content Intent
|
20 |
+
- Enable Server Members Intent (for replacing user mentions with the username)
|
21 |
+
6. Invite the bot to a server
|
22 |
+
1. Go to Application » OAuth2 » URL Generator
|
23 |
+
2. Enable `bot`
|
24 |
+
3. Enable Send Messages, Read Messages/View Channels, and Read Message History
|
25 |
+
4. Under Generated URL, click Copy and paste the URL in your browser
|
26 |
+
7. Rename `.env.example` to `.env` and edit the `.env` file
|
27 |
+
- You can get the token from Application » Bot » Token, **never share this with anyone**
|
28 |
+
- Make sure to change the model if you aren't using `orca`
|
29 |
+
- Ollama URL can be kept the same unless you have changed the port
|
30 |
+
- You can use multiple Ollama servers at the same time by separating the URLs with commas
|
31 |
+
- Set the channels to the channel ID, comma separated
|
32 |
+
1. In Discord, go to User Settings » Advanced, and enable Developer Mode
|
33 |
+
2. Right click on a channel you want to use, and click Copy Channel ID
|
34 |
+
- You can edit the system message the bot uses, or disable it entirely
|
35 |
+
8. Start the bot with `npm start`
|
36 |
+
9. You can interact with the bot by @mentioning it with your message
|
37 |
+
|
38 |
+
### Set-up instructions with Docker
|
39 |
+
1. Install [Docker](https://docs.docker.com/get-docker/)
|
40 |
+
- Should be atleast compatible with version 3 of compose (docker engine 1.13.0+)
|
41 |
+
2. Repeat steps 2—7 from the other setup instructions
|
42 |
+
3. Start the bot with `make compose-up` if you have Make installed
|
43 |
+
- Otherwise, try `docker compose -p discord-ai up` instead
|
44 |
+
4. You can interact with the bot by @mentioning it with your message
|
assets/screenshot.png
ADDED
docker-compose.yml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: "3"
|
2 |
+
|
3 |
+
services:
|
4 |
+
bot:
|
5 |
+
build: .
|
6 |
+
env_file: .env
|
7 |
+
environment:
|
8 |
+
- OLLAMA=http://host.docker.internal:11434
|
9 |
+
restart: unless-stopped
|
node_modules/.package-lock.json
ADDED
@@ -0,0 +1,369 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "discord-ai-bot",
|
3 |
+
"lockfileVersion": 3,
|
4 |
+
"requires": true,
|
5 |
+
"packages": {
|
6 |
+
"node_modules/@discordjs/builders": {
|
7 |
+
"version": "1.7.0",
|
8 |
+
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.7.0.tgz",
|
9 |
+
"integrity": "sha512-GDtbKMkg433cOZur8Dv6c25EHxduNIBsxeHrsRoIM8+AwmEZ8r0tEpckx/sHwTLwQPOF3e2JWloZh9ofCaMfAw==",
|
10 |
+
"dependencies": {
|
11 |
+
"@discordjs/formatters": "^0.3.3",
|
12 |
+
"@discordjs/util": "^1.0.2",
|
13 |
+
"@sapphire/shapeshift": "^3.9.3",
|
14 |
+
"discord-api-types": "0.37.61",
|
15 |
+
"fast-deep-equal": "^3.1.3",
|
16 |
+
"ts-mixer": "^6.0.3",
|
17 |
+
"tslib": "^2.6.2"
|
18 |
+
},
|
19 |
+
"engines": {
|
20 |
+
"node": ">=16.11.0"
|
21 |
+
}
|
22 |
+
},
|
23 |
+
"node_modules/@discordjs/collection": {
|
24 |
+
"version": "1.5.3",
|
25 |
+
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-1.5.3.tgz",
|
26 |
+
"integrity": "sha512-SVb428OMd3WO1paV3rm6tSjM4wC+Kecaa1EUGX7vc6/fddvw/6lg90z4QtCqm21zvVe92vMMDt9+DkIvjXImQQ==",
|
27 |
+
"engines": {
|
28 |
+
"node": ">=16.11.0"
|
29 |
+
}
|
30 |
+
},
|
31 |
+
"node_modules/@discordjs/formatters": {
|
32 |
+
"version": "0.3.3",
|
33 |
+
"resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.3.3.tgz",
|
34 |
+
"integrity": "sha512-wTcI1Q5cps1eSGhl6+6AzzZkBBlVrBdc9IUhJbijRgVjCNIIIZPgqnUj3ntFODsHrdbGU8BEG9XmDQmgEEYn3w==",
|
35 |
+
"dependencies": {
|
36 |
+
"discord-api-types": "0.37.61"
|
37 |
+
},
|
38 |
+
"engines": {
|
39 |
+
"node": ">=16.11.0"
|
40 |
+
}
|
41 |
+
},
|
42 |
+
"node_modules/@discordjs/rest": {
|
43 |
+
"version": "2.2.0",
|
44 |
+
"resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.2.0.tgz",
|
45 |
+
"integrity": "sha512-nXm9wT8oqrYFRMEqTXQx9DUTeEtXUDMmnUKIhZn6O2EeDY9VCdwj23XCPq7fkqMPKdF7ldAfeVKyxxFdbZl59A==",
|
46 |
+
"dependencies": {
|
47 |
+
"@discordjs/collection": "^2.0.0",
|
48 |
+
"@discordjs/util": "^1.0.2",
|
49 |
+
"@sapphire/async-queue": "^1.5.0",
|
50 |
+
"@sapphire/snowflake": "^3.5.1",
|
51 |
+
"@vladfrangu/async_event_emitter": "^2.2.2",
|
52 |
+
"discord-api-types": "0.37.61",
|
53 |
+
"magic-bytes.js": "^1.5.0",
|
54 |
+
"tslib": "^2.6.2",
|
55 |
+
"undici": "5.27.2"
|
56 |
+
},
|
57 |
+
"engines": {
|
58 |
+
"node": ">=16.11.0"
|
59 |
+
}
|
60 |
+
},
|
61 |
+
"node_modules/@discordjs/rest/node_modules/@discordjs/collection": {
|
62 |
+
"version": "2.0.0",
|
63 |
+
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.0.0.tgz",
|
64 |
+
"integrity": "sha512-YTWIXLrf5FsrLMycpMM9Q6vnZoR/lN2AWX23/Cuo8uOOtS8eHB2dyQaaGnaF8aZPYnttf2bkLMcXn/j6JUOi3w==",
|
65 |
+
"engines": {
|
66 |
+
"node": ">=18"
|
67 |
+
}
|
68 |
+
},
|
69 |
+
"node_modules/@discordjs/util": {
|
70 |
+
"version": "1.0.2",
|
71 |
+
"resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.0.2.tgz",
|
72 |
+
"integrity": "sha512-IRNbimrmfb75GMNEjyznqM1tkI7HrZOf14njX7tCAAUetyZM1Pr8hX/EK2lxBCOgWDRmigbp24fD1hdMfQK5lw==",
|
73 |
+
"engines": {
|
74 |
+
"node": ">=16.11.0"
|
75 |
+
}
|
76 |
+
},
|
77 |
+
"node_modules/@discordjs/ws": {
|
78 |
+
"version": "1.0.2",
|
79 |
+
"resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-1.0.2.tgz",
|
80 |
+
"integrity": "sha512-+XI82Rm2hKnFwAySXEep4A7Kfoowt6weO6381jgW+wVdTpMS/56qCvoXyFRY0slcv7c/U8My2PwIB2/wEaAh7Q==",
|
81 |
+
"dependencies": {
|
82 |
+
"@discordjs/collection": "^2.0.0",
|
83 |
+
"@discordjs/rest": "^2.1.0",
|
84 |
+
"@discordjs/util": "^1.0.2",
|
85 |
+
"@sapphire/async-queue": "^1.5.0",
|
86 |
+
"@types/ws": "^8.5.9",
|
87 |
+
"@vladfrangu/async_event_emitter": "^2.2.2",
|
88 |
+
"discord-api-types": "0.37.61",
|
89 |
+
"tslib": "^2.6.2",
|
90 |
+
"ws": "^8.14.2"
|
91 |
+
},
|
92 |
+
"engines": {
|
93 |
+
"node": ">=16.11.0"
|
94 |
+
}
|
95 |
+
},
|
96 |
+
"node_modules/@discordjs/ws/node_modules/@discordjs/collection": {
|
97 |
+
"version": "2.0.0",
|
98 |
+
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.0.0.tgz",
|
99 |
+
"integrity": "sha512-YTWIXLrf5FsrLMycpMM9Q6vnZoR/lN2AWX23/Cuo8uOOtS8eHB2dyQaaGnaF8aZPYnttf2bkLMcXn/j6JUOi3w==",
|
100 |
+
"engines": {
|
101 |
+
"node": ">=18"
|
102 |
+
}
|
103 |
+
},
|
104 |
+
"node_modules/@fastify/busboy": {
|
105 |
+
"version": "2.1.1",
|
106 |
+
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz",
|
107 |
+
"integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==",
|
108 |
+
"engines": {
|
109 |
+
"node": ">=14"
|
110 |
+
}
|
111 |
+
},
|
112 |
+
"node_modules/@sapphire/async-queue": {
|
113 |
+
"version": "1.5.2",
|
114 |
+
"resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.2.tgz",
|
115 |
+
"integrity": "sha512-7X7FFAA4DngXUl95+hYbUF19bp1LGiffjJtu7ygrZrbdCSsdDDBaSjB7Akw0ZbOu6k0xpXyljnJ6/RZUvLfRdg==",
|
116 |
+
"engines": {
|
117 |
+
"node": ">=v14.0.0",
|
118 |
+
"npm": ">=7.0.0"
|
119 |
+
}
|
120 |
+
},
|
121 |
+
"node_modules/@sapphire/shapeshift": {
|
122 |
+
"version": "3.9.7",
|
123 |
+
"resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-3.9.7.tgz",
|
124 |
+
"integrity": "sha512-4It2mxPSr4OGn4HSQWGmhFMsNFGfFVhWeRPCRwbH972Ek2pzfGRZtb0pJ4Ze6oIzcyh2jw7nUDa6qGlWofgd9g==",
|
125 |
+
"dependencies": {
|
126 |
+
"fast-deep-equal": "^3.1.3",
|
127 |
+
"lodash": "^4.17.21"
|
128 |
+
},
|
129 |
+
"engines": {
|
130 |
+
"node": ">=v16"
|
131 |
+
}
|
132 |
+
},
|
133 |
+
"node_modules/@sapphire/snowflake": {
|
134 |
+
"version": "3.5.1",
|
135 |
+
"resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.5.1.tgz",
|
136 |
+
"integrity": "sha512-BxcYGzgEsdlG0dKAyOm0ehLGm2CafIrfQTZGWgkfKYbj+pNNsorZ7EotuZukc2MT70E0UbppVbtpBrqpzVzjNA==",
|
137 |
+
"engines": {
|
138 |
+
"node": ">=v14.0.0",
|
139 |
+
"npm": ">=7.0.0"
|
140 |
+
}
|
141 |
+
},
|
142 |
+
"node_modules/@types/node": {
|
143 |
+
"version": "20.12.7",
|
144 |
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.7.tgz",
|
145 |
+
"integrity": "sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==",
|
146 |
+
"dependencies": {
|
147 |
+
"undici-types": "~5.26.4"
|
148 |
+
}
|
149 |
+
},
|
150 |
+
"node_modules/@types/ws": {
|
151 |
+
"version": "8.5.9",
|
152 |
+
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.9.tgz",
|
153 |
+
"integrity": "sha512-jbdrY0a8lxfdTp/+r7Z4CkycbOFN8WX+IOchLJr3juT/xzbJ8URyTVSJ/hvNdadTgM1mnedb47n+Y31GsFnQlg==",
|
154 |
+
"dependencies": {
|
155 |
+
"@types/node": "*"
|
156 |
+
}
|
157 |
+
},
|
158 |
+
"node_modules/@vladfrangu/async_event_emitter": {
|
159 |
+
"version": "2.2.4",
|
160 |
+
"resolved": "https://registry.npmjs.org/@vladfrangu/async_event_emitter/-/async_event_emitter-2.2.4.tgz",
|
161 |
+
"integrity": "sha512-ButUPz9E9cXMLgvAW8aLAKKJJsPu1dY1/l/E8xzLFuysowXygs6GBcyunK9rnGC4zTsnIc2mQo71rGw9U+Ykug==",
|
162 |
+
"engines": {
|
163 |
+
"node": ">=v14.0.0",
|
164 |
+
"npm": ">=7.0.0"
|
165 |
+
}
|
166 |
+
},
|
167 |
+
"node_modules/asynckit": {
|
168 |
+
"version": "0.4.0",
|
169 |
+
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
170 |
+
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
171 |
+
},
|
172 |
+
"node_modules/axios": {
|
173 |
+
"version": "1.6.8",
|
174 |
+
"resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz",
|
175 |
+
"integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==",
|
176 |
+
"dependencies": {
|
177 |
+
"follow-redirects": "^1.15.6",
|
178 |
+
"form-data": "^4.0.0",
|
179 |
+
"proxy-from-env": "^1.1.0"
|
180 |
+
}
|
181 |
+
},
|
182 |
+
"node_modules/combined-stream": {
|
183 |
+
"version": "1.0.8",
|
184 |
+
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
185 |
+
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
186 |
+
"dependencies": {
|
187 |
+
"delayed-stream": "~1.0.0"
|
188 |
+
},
|
189 |
+
"engines": {
|
190 |
+
"node": ">= 0.8"
|
191 |
+
}
|
192 |
+
},
|
193 |
+
"node_modules/delayed-stream": {
|
194 |
+
"version": "1.0.0",
|
195 |
+
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
196 |
+
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
197 |
+
"engines": {
|
198 |
+
"node": ">=0.4.0"
|
199 |
+
}
|
200 |
+
},
|
201 |
+
"node_modules/discord-api-types": {
|
202 |
+
"version": "0.37.61",
|
203 |
+
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.61.tgz",
|
204 |
+
"integrity": "sha512-o/dXNFfhBpYHpQFdT6FWzeO7pKc838QeeZ9d91CfVAtpr5XLK4B/zYxQbYgPdoMiTDvJfzcsLW5naXgmHGDNXw=="
|
205 |
+
},
|
206 |
+
"node_modules/discord.js": {
|
207 |
+
"version": "14.14.1",
|
208 |
+
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.14.1.tgz",
|
209 |
+
"integrity": "sha512-/hUVzkIerxKHyRKopJy5xejp4MYKDPTszAnpYxzVVv4qJYf+Tkt+jnT2N29PIPschicaEEpXwF2ARrTYHYwQ5w==",
|
210 |
+
"dependencies": {
|
211 |
+
"@discordjs/builders": "^1.7.0",
|
212 |
+
"@discordjs/collection": "1.5.3",
|
213 |
+
"@discordjs/formatters": "^0.3.3",
|
214 |
+
"@discordjs/rest": "^2.1.0",
|
215 |
+
"@discordjs/util": "^1.0.2",
|
216 |
+
"@discordjs/ws": "^1.0.2",
|
217 |
+
"@sapphire/snowflake": "3.5.1",
|
218 |
+
"@types/ws": "8.5.9",
|
219 |
+
"discord-api-types": "0.37.61",
|
220 |
+
"fast-deep-equal": "3.1.3",
|
221 |
+
"lodash.snakecase": "4.1.1",
|
222 |
+
"tslib": "2.6.2",
|
223 |
+
"undici": "5.27.2",
|
224 |
+
"ws": "8.14.2"
|
225 |
+
},
|
226 |
+
"engines": {
|
227 |
+
"node": ">=16.11.0"
|
228 |
+
}
|
229 |
+
},
|
230 |
+
"node_modules/dotenv": {
|
231 |
+
"version": "16.4.5",
|
232 |
+
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
|
233 |
+
"integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==",
|
234 |
+
"engines": {
|
235 |
+
"node": ">=12"
|
236 |
+
},
|
237 |
+
"funding": {
|
238 |
+
"url": "https://dotenvx.com"
|
239 |
+
}
|
240 |
+
},
|
241 |
+
"node_modules/fast-deep-equal": {
|
242 |
+
"version": "3.1.3",
|
243 |
+
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
244 |
+
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
|
245 |
+
},
|
246 |
+
"node_modules/follow-redirects": {
|
247 |
+
"version": "1.15.6",
|
248 |
+
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
|
249 |
+
"integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
|
250 |
+
"funding": [
|
251 |
+
{
|
252 |
+
"type": "individual",
|
253 |
+
"url": "https://github.com/sponsors/RubenVerborgh"
|
254 |
+
}
|
255 |
+
],
|
256 |
+
"engines": {
|
257 |
+
"node": ">=4.0"
|
258 |
+
},
|
259 |
+
"peerDependenciesMeta": {
|
260 |
+
"debug": {
|
261 |
+
"optional": true
|
262 |
+
}
|
263 |
+
}
|
264 |
+
},
|
265 |
+
"node_modules/form-data": {
|
266 |
+
"version": "4.0.0",
|
267 |
+
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
268 |
+
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
269 |
+
"dependencies": {
|
270 |
+
"asynckit": "^0.4.0",
|
271 |
+
"combined-stream": "^1.0.8",
|
272 |
+
"mime-types": "^2.1.12"
|
273 |
+
},
|
274 |
+
"engines": {
|
275 |
+
"node": ">= 6"
|
276 |
+
}
|
277 |
+
},
|
278 |
+
"node_modules/lodash": {
|
279 |
+
"version": "4.17.21",
|
280 |
+
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
281 |
+
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
|
282 |
+
},
|
283 |
+
"node_modules/lodash.snakecase": {
|
284 |
+
"version": "4.1.1",
|
285 |
+
"resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz",
|
286 |
+
"integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw=="
|
287 |
+
},
|
288 |
+
"node_modules/magic-bytes.js": {
|
289 |
+
"version": "1.10.0",
|
290 |
+
"resolved": "https://registry.npmjs.org/magic-bytes.js/-/magic-bytes.js-1.10.0.tgz",
|
291 |
+
"integrity": "sha512-/k20Lg2q8LE5xiaaSkMXk4sfvI+9EGEykFS4b0CHHGWqDYU0bGUFSwchNOMA56D7TCs9GwVTkqe9als1/ns8UQ=="
|
292 |
+
},
|
293 |
+
"node_modules/meklog": {
|
294 |
+
"version": "1.0.2",
|
295 |
+
"resolved": "https://registry.npmjs.org/meklog/-/meklog-1.0.2.tgz",
|
296 |
+
"integrity": "sha512-9jkTaZzWEpO0tiWQl0xoj/DPktcHELg74nSzsEaLaN7IYGmcczMXgQXQmZT1cXWykj2FAhv0BBRUGpnFCZn/dg=="
|
297 |
+
},
|
298 |
+
"node_modules/mime-db": {
|
299 |
+
"version": "1.52.0",
|
300 |
+
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
301 |
+
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
302 |
+
"engines": {
|
303 |
+
"node": ">= 0.6"
|
304 |
+
}
|
305 |
+
},
|
306 |
+
"node_modules/mime-types": {
|
307 |
+
"version": "2.1.35",
|
308 |
+
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
309 |
+
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
310 |
+
"dependencies": {
|
311 |
+
"mime-db": "1.52.0"
|
312 |
+
},
|
313 |
+
"engines": {
|
314 |
+
"node": ">= 0.6"
|
315 |
+
}
|
316 |
+
},
|
317 |
+
"node_modules/proxy-from-env": {
|
318 |
+
"version": "1.1.0",
|
319 |
+
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
320 |
+
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
|
321 |
+
},
|
322 |
+
"node_modules/ts-mixer": {
|
323 |
+
"version": "6.0.4",
|
324 |
+
"resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.4.tgz",
|
325 |
+
"integrity": "sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA=="
|
326 |
+
},
|
327 |
+
"node_modules/tslib": {
|
328 |
+
"version": "2.6.2",
|
329 |
+
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
330 |
+
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
|
331 |
+
},
|
332 |
+
"node_modules/undici": {
|
333 |
+
"version": "5.27.2",
|
334 |
+
"resolved": "https://registry.npmjs.org/undici/-/undici-5.27.2.tgz",
|
335 |
+
"integrity": "sha512-iS857PdOEy/y3wlM3yRp+6SNQQ6xU0mmZcwRSriqk+et/cwWAtwmIGf6WkoDN2EK/AMdCO/dfXzIwi+rFMrjjQ==",
|
336 |
+
"dependencies": {
|
337 |
+
"@fastify/busboy": "^2.0.0"
|
338 |
+
},
|
339 |
+
"engines": {
|
340 |
+
"node": ">=14.0"
|
341 |
+
}
|
342 |
+
},
|
343 |
+
"node_modules/undici-types": {
|
344 |
+
"version": "5.26.5",
|
345 |
+
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
|
346 |
+
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="
|
347 |
+
},
|
348 |
+
"node_modules/ws": {
|
349 |
+
"version": "8.14.2",
|
350 |
+
"resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz",
|
351 |
+
"integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==",
|
352 |
+
"engines": {
|
353 |
+
"node": ">=10.0.0"
|
354 |
+
},
|
355 |
+
"peerDependencies": {
|
356 |
+
"bufferutil": "^4.0.1",
|
357 |
+
"utf-8-validate": ">=5.0.2"
|
358 |
+
},
|
359 |
+
"peerDependenciesMeta": {
|
360 |
+
"bufferutil": {
|
361 |
+
"optional": true
|
362 |
+
},
|
363 |
+
"utf-8-validate": {
|
364 |
+
"optional": true
|
365 |
+
}
|
366 |
+
}
|
367 |
+
}
|
368 |
+
}
|
369 |
+
}
|
node_modules/@discordjs/builders/LICENSE
ADDED
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Apache License
|
2 |
+
Version 2.0, January 2004
|
3 |
+
http://www.apache.org/licenses/
|
4 |
+
|
5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6 |
+
|
7 |
+
1. Definitions.
|
8 |
+
|
9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
11 |
+
|
12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13 |
+
the copyright owner that is granting the License.
|
14 |
+
|
15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
16 |
+
other entities that control, are controlled by, or are under common
|
17 |
+
control with that entity. For the purposes of this definition,
|
18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
19 |
+
direction or management of such entity, whether by contract or
|
20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22 |
+
|
23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24 |
+
exercising permissions granted by this License.
|
25 |
+
|
26 |
+
"Source" form shall mean the preferred form for making modifications,
|
27 |
+
including but not limited to software source code, documentation
|
28 |
+
source, and configuration files.
|
29 |
+
|
30 |
+
"Object" form shall mean any form resulting from mechanical
|
31 |
+
transformation or translation of a Source form, including but
|
32 |
+
not limited to compiled object code, generated documentation,
|
33 |
+
and conversions to other media types.
|
34 |
+
|
35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
36 |
+
Object form, made available under the License, as indicated by a
|
37 |
+
copyright notice that is included in or attached to the work
|
38 |
+
(an example is provided in the Appendix below).
|
39 |
+
|
40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41 |
+
form, that is based on (or derived from) the Work and for which the
|
42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
44 |
+
of this License, Derivative Works shall not include works that remain
|
45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46 |
+
the Work and Derivative Works thereof.
|
47 |
+
|
48 |
+
"Contribution" shall mean any work of authorship, including
|
49 |
+
the original version of the Work and any modifications or additions
|
50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
54 |
+
means any form of electronic, verbal, or written communication sent
|
55 |
+
to the Licensor or its representatives, including but not limited to
|
56 |
+
communication on electronic mailing lists, source code control systems,
|
57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
59 |
+
excluding communication that is conspicuously marked or otherwise
|
60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
61 |
+
|
62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
64 |
+
subsequently incorporated within the Work.
|
65 |
+
|
66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
71 |
+
Work and such Derivative Works in Source or Object form.
|
72 |
+
|
73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76 |
+
(except as stated in this section) patent license to make, have made,
|
77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78 |
+
where such license applies only to those patent claims licensable
|
79 |
+
by such Contributor that are necessarily infringed by their
|
80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
82 |
+
institute patent litigation against any entity (including a
|
83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84 |
+
or a Contribution incorporated within the Work constitutes direct
|
85 |
+
or contributory patent infringement, then any patent licenses
|
86 |
+
granted to You under this License for that Work shall terminate
|
87 |
+
as of the date such litigation is filed.
|
88 |
+
|
89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
90 |
+
Work or Derivative Works thereof in any medium, with or without
|
91 |
+
modifications, and in Source or Object form, provided that You
|
92 |
+
meet the following conditions:
|
93 |
+
|
94 |
+
(a) You must give any other recipients of the Work or
|
95 |
+
Derivative Works a copy of this License; and
|
96 |
+
|
97 |
+
(b) You must cause any modified files to carry prominent notices
|
98 |
+
stating that You changed the files; and
|
99 |
+
|
100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
101 |
+
that You distribute, all copyright, patent, trademark, and
|
102 |
+
attribution notices from the Source form of the Work,
|
103 |
+
excluding those notices that do not pertain to any part of
|
104 |
+
the Derivative Works; and
|
105 |
+
|
106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107 |
+
distribution, then any Derivative Works that You distribute must
|
108 |
+
include a readable copy of the attribution notices contained
|
109 |
+
within such NOTICE file, excluding those notices that do not
|
110 |
+
pertain to any part of the Derivative Works, in at least one
|
111 |
+
of the following places: within a NOTICE text file distributed
|
112 |
+
as part of the Derivative Works; within the Source form or
|
113 |
+
documentation, if provided along with the Derivative Works; or,
|
114 |
+
within a display generated by the Derivative Works, if and
|
115 |
+
wherever such third-party notices normally appear. The contents
|
116 |
+
of the NOTICE file are for informational purposes only and
|
117 |
+
do not modify the License. You may add Your own attribution
|
118 |
+
notices within Derivative Works that You distribute, alongside
|
119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
120 |
+
that such additional attribution notices cannot be construed
|
121 |
+
as modifying the License.
|
122 |
+
|
123 |
+
You may add Your own copyright statement to Your modifications and
|
124 |
+
may provide additional or different license terms and conditions
|
125 |
+
for use, reproduction, or distribution of Your modifications, or
|
126 |
+
for any such Derivative Works as a whole, provided Your use,
|
127 |
+
reproduction, and distribution of the Work otherwise complies with
|
128 |
+
the conditions stated in this License.
|
129 |
+
|
130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
132 |
+
by You to the Licensor shall be under the terms and conditions of
|
133 |
+
this License, without any additional terms or conditions.
|
134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135 |
+
the terms of any separate license agreement you may have executed
|
136 |
+
with Licensor regarding such Contributions.
|
137 |
+
|
138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
140 |
+
except as required for reasonable and customary use in describing the
|
141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
142 |
+
|
143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144 |
+
agreed to in writing, Licensor provides the Work (and each
|
145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147 |
+
implied, including, without limitation, any warranties or conditions
|
148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150 |
+
appropriateness of using or redistributing the Work and assume any
|
151 |
+
risks associated with Your exercise of permissions under this License.
|
152 |
+
|
153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
154 |
+
whether in tort (including negligence), contract, or otherwise,
|
155 |
+
unless required by applicable law (such as deliberate and grossly
|
156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157 |
+
liable to You for damages, including any direct, indirect, special,
|
158 |
+
incidental, or consequential damages of any character arising as a
|
159 |
+
result of this License or out of the use or inability to use the
|
160 |
+
Work (including but not limited to damages for loss of goodwill,
|
161 |
+
work stoppage, computer failure or malfunction, or any and all
|
162 |
+
other commercial damages or losses), even if such Contributor
|
163 |
+
has been advised of the possibility of such damages.
|
164 |
+
|
165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168 |
+
or other liability obligations and/or rights consistent with this
|
169 |
+
License. However, in accepting such obligations, You may act only
|
170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171 |
+
of any other Contributor, and only if You agree to indemnify,
|
172 |
+
defend, and hold each Contributor harmless for any liability
|
173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
174 |
+
of your accepting any such warranty or additional liability.
|
175 |
+
|
176 |
+
END OF TERMS AND CONDITIONS
|
177 |
+
|
178 |
+
Copyright 2021 Noel Buechler
|
179 |
+
Copyright 2021 Vlad Frangu
|
180 |
+
|
181 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
182 |
+
you may not use this file except in compliance with the License.
|
183 |
+
You may obtain a copy of the License at
|
184 |
+
|
185 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
186 |
+
|
187 |
+
Unless required by applicable law or agreed to in writing, software
|
188 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
189 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
190 |
+
See the License for the specific language governing permissions and
|
191 |
+
limitations under the License.
|
node_modules/@discordjs/builders/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div align="center">
|
2 |
+
<br />
|
3 |
+
<p>
|
4 |
+
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
|
5 |
+
</p>
|
6 |
+
<br />
|
7 |
+
<p>
|
8 |
+
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
|
9 |
+
<a href="https://www.npmjs.com/package/@discordjs/builders"><img src="https://img.shields.io/npm/v/@discordjs/builders.svg?maxAge=3600" alt="npm version" /></a>
|
10 |
+
<a href="https://www.npmjs.com/package/@discordjs/builders"><img src="https://img.shields.io/npm/dt/@discordjs/builders.svg?maxAge=3600" alt="npm downloads" /></a>
|
11 |
+
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
|
12 |
+
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=builders" alt="Code coverage" /></a>
|
13 |
+
</p>
|
14 |
+
<p>
|
15 |
+
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
16 |
+
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
|
17 |
+
</p>
|
18 |
+
</div>
|
19 |
+
|
20 |
+
## About
|
21 |
+
|
22 |
+
`@discordjs/builders` is a utility package for easily building Discord API payloads.
|
23 |
+
|
24 |
+
## Installation
|
25 |
+
|
26 |
+
**Node.js 16.11.0 or newer is required.**
|
27 |
+
|
28 |
+
```sh
|
29 |
+
npm install @discordjs/builders
|
30 |
+
yarn add @discordjs/builders
|
31 |
+
pnpm add @discordjs/builders
|
32 |
+
```
|
33 |
+
|
34 |
+
## Examples
|
35 |
+
|
36 |
+
You can find examples of how to use the builders in the [Slash Command Builders][example] examples.
|
37 |
+
|
38 |
+
## Links
|
39 |
+
|
40 |
+
- [Website][website] ([source][website-source])
|
41 |
+
- [Documentation][documentation]
|
42 |
+
- [Guide][guide] ([source][guide-source])
|
43 |
+
Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
|
44 |
+
- [discord.js Discord server][discord]
|
45 |
+
- [Discord API Discord server][discord-api]
|
46 |
+
- [GitHub][source]
|
47 |
+
- [npm][npm]
|
48 |
+
- [Related libraries][related-libs]
|
49 |
+
|
50 |
+
## Contributing
|
51 |
+
|
52 |
+
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
|
53 |
+
[documentation][documentation].
|
54 |
+
See [the contribution guide][contributing] if you'd like to submit a PR.
|
55 |
+
|
56 |
+
## Help
|
57 |
+
|
58 |
+
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][discord].
|
59 |
+
|
60 |
+
[example]: https://github.com/discordjs/discord.js/blob/main/packages/builders/docs/examples/Slash%20Command%20Builders.md
|
61 |
+
[website]: https://discord.js.org
|
62 |
+
[website-source]: https://github.com/discordjs/discord.js/tree/main/apps/website
|
63 |
+
[documentation]: https://discord.js.org/docs/packages/builders/stable
|
64 |
+
[guide]: https://discordjs.guide/
|
65 |
+
[guide-source]: https://github.com/discordjs/guide
|
66 |
+
[guide-update]: https://discordjs.guide/additional-info/changes-in-v14.html
|
67 |
+
[discord]: https://discord.gg/djs
|
68 |
+
[discord-api]: https://discord.gg/discord-api
|
69 |
+
[source]: https://github.com/discordjs/discord.js/tree/main/packages/builders
|
70 |
+
[npm]: https://www.npmjs.com/package/@discordjs/builders
|
71 |
+
[related-libs]: https://discord.com/developers/docs/topics/community-resources#libraries
|
72 |
+
[contributing]: https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md
|
node_modules/@discordjs/builders/dist/index.d.mts
ADDED
@@ -0,0 +1,2008 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import * as _sapphire_shapeshift from '@sapphire/shapeshift';
|
2 |
+
import { APIEmbedField, APIEmbedAuthor, APIEmbedFooter, APIEmbedImage, APIEmbed, APISelectMenuOption, APIMessageComponentEmoji, ButtonStyle, ChannelType, APIActionRowComponent, APIActionRowComponentTypes, APIBaseComponent, ComponentType, APIButtonComponent, APISelectMenuComponent, APIChannelSelectComponent, Snowflake, APIMentionableSelectComponent, APISelectMenuDefaultValue, SelectMenuDefaultValueType, APIRoleSelectComponent, APIStringSelectComponent, APIUserSelectComponent, APITextInputComponent, TextInputStyle, APIMessageActionRowComponent, APIModalActionRowComponent, APIModalComponent, APIMessageComponent, APIModalInteractionResponseCallbackData, LocalizationMap, LocaleString, ApplicationCommandOptionType, APIApplicationCommandBasicOption, APIApplicationCommandAttachmentOption, APIApplicationCommandBooleanOption, APIApplicationCommandChannelOption, APIApplicationCommandOptionChoice, APIApplicationCommandIntegerOption, APIApplicationCommandMentionableOption, APIApplicationCommandNumberOption, APIApplicationCommandRoleOption, APIApplicationCommandStringOption, APIApplicationCommandUserOption, APIApplicationCommandSubcommandGroupOption, APIApplicationCommandSubcommandOption, Permissions, RESTPostAPIChatInputApplicationCommandsJSONBody, APIApplicationCommandOption, Locale, ApplicationCommandType, RESTPostAPIContextMenuApplicationCommandsJSONBody } from 'discord-api-types/v10';
|
3 |
+
export * from '@discordjs/formatters';
|
4 |
+
import { JSONEncodable, Equatable } from '@discordjs/util';
|
5 |
+
|
6 |
+
declare const fieldNamePredicate: _sapphire_shapeshift.StringValidator<string>;
|
7 |
+
declare const fieldValuePredicate: _sapphire_shapeshift.StringValidator<string>;
|
8 |
+
declare const fieldInlinePredicate: _sapphire_shapeshift.UnionValidator<boolean | undefined>;
|
9 |
+
declare const embedFieldPredicate: _sapphire_shapeshift.ObjectValidator<{
|
10 |
+
name: string;
|
11 |
+
value: string;
|
12 |
+
inline: boolean | undefined;
|
13 |
+
}, _sapphire_shapeshift.UndefinedToOptional<{
|
14 |
+
name: string;
|
15 |
+
value: string;
|
16 |
+
inline: boolean | undefined;
|
17 |
+
}>>;
|
18 |
+
declare const embedFieldsArrayPredicate: _sapphire_shapeshift.ArrayValidator<_sapphire_shapeshift.UndefinedToOptional<{
|
19 |
+
name: string;
|
20 |
+
value: string;
|
21 |
+
inline: boolean | undefined;
|
22 |
+
}>[], _sapphire_shapeshift.UndefinedToOptional<{
|
23 |
+
name: string;
|
24 |
+
value: string;
|
25 |
+
inline: boolean | undefined;
|
26 |
+
}>>;
|
27 |
+
declare const fieldLengthPredicate: _sapphire_shapeshift.NumberValidator<number>;
|
28 |
+
declare function validateFieldLength(amountAdding: number, fields?: APIEmbedField[]): void;
|
29 |
+
declare const authorNamePredicate: _sapphire_shapeshift.UnionValidator<string | null>;
|
30 |
+
declare const imageURLPredicate: _sapphire_shapeshift.UnionValidator<string | null | undefined>;
|
31 |
+
declare const urlPredicate: _sapphire_shapeshift.UnionValidator<string | null | undefined>;
|
32 |
+
declare const embedAuthorPredicate: _sapphire_shapeshift.ObjectValidator<{
|
33 |
+
name: string | null;
|
34 |
+
iconURL: string | null | undefined;
|
35 |
+
url: string | null | undefined;
|
36 |
+
}, _sapphire_shapeshift.UndefinedToOptional<{
|
37 |
+
name: string | null;
|
38 |
+
iconURL: string | null | undefined;
|
39 |
+
url: string | null | undefined;
|
40 |
+
}>>;
|
41 |
+
declare const RGBPredicate: _sapphire_shapeshift.NumberValidator<number>;
|
42 |
+
declare const colorPredicate: _sapphire_shapeshift.UnionValidator<number | [number, number, number] | null>;
|
43 |
+
declare const descriptionPredicate: _sapphire_shapeshift.UnionValidator<string | null>;
|
44 |
+
declare const footerTextPredicate: _sapphire_shapeshift.UnionValidator<string | null>;
|
45 |
+
declare const embedFooterPredicate: _sapphire_shapeshift.ObjectValidator<{
|
46 |
+
text: string | null;
|
47 |
+
iconURL: string | null | undefined;
|
48 |
+
}, _sapphire_shapeshift.UndefinedToOptional<{
|
49 |
+
text: string | null;
|
50 |
+
iconURL: string | null | undefined;
|
51 |
+
}>>;
|
52 |
+
declare const timestampPredicate: _sapphire_shapeshift.UnionValidator<number | Date | null>;
|
53 |
+
declare const titlePredicate: _sapphire_shapeshift.UnionValidator<string | null>;
|
54 |
+
|
55 |
+
declare const Assertions$5_RGBPredicate: typeof RGBPredicate;
|
56 |
+
declare const Assertions$5_authorNamePredicate: typeof authorNamePredicate;
|
57 |
+
declare const Assertions$5_colorPredicate: typeof colorPredicate;
|
58 |
+
declare const Assertions$5_descriptionPredicate: typeof descriptionPredicate;
|
59 |
+
declare const Assertions$5_embedAuthorPredicate: typeof embedAuthorPredicate;
|
60 |
+
declare const Assertions$5_embedFieldPredicate: typeof embedFieldPredicate;
|
61 |
+
declare const Assertions$5_embedFieldsArrayPredicate: typeof embedFieldsArrayPredicate;
|
62 |
+
declare const Assertions$5_embedFooterPredicate: typeof embedFooterPredicate;
|
63 |
+
declare const Assertions$5_fieldInlinePredicate: typeof fieldInlinePredicate;
|
64 |
+
declare const Assertions$5_fieldLengthPredicate: typeof fieldLengthPredicate;
|
65 |
+
declare const Assertions$5_fieldNamePredicate: typeof fieldNamePredicate;
|
66 |
+
declare const Assertions$5_fieldValuePredicate: typeof fieldValuePredicate;
|
67 |
+
declare const Assertions$5_footerTextPredicate: typeof footerTextPredicate;
|
68 |
+
declare const Assertions$5_imageURLPredicate: typeof imageURLPredicate;
|
69 |
+
declare const Assertions$5_timestampPredicate: typeof timestampPredicate;
|
70 |
+
declare const Assertions$5_titlePredicate: typeof titlePredicate;
|
71 |
+
declare const Assertions$5_urlPredicate: typeof urlPredicate;
|
72 |
+
declare const Assertions$5_validateFieldLength: typeof validateFieldLength;
|
73 |
+
declare namespace Assertions$5 {
|
74 |
+
export {
|
75 |
+
Assertions$5_RGBPredicate as RGBPredicate,
|
76 |
+
Assertions$5_authorNamePredicate as authorNamePredicate,
|
77 |
+
Assertions$5_colorPredicate as colorPredicate,
|
78 |
+
Assertions$5_descriptionPredicate as descriptionPredicate,
|
79 |
+
Assertions$5_embedAuthorPredicate as embedAuthorPredicate,
|
80 |
+
Assertions$5_embedFieldPredicate as embedFieldPredicate,
|
81 |
+
Assertions$5_embedFieldsArrayPredicate as embedFieldsArrayPredicate,
|
82 |
+
Assertions$5_embedFooterPredicate as embedFooterPredicate,
|
83 |
+
Assertions$5_fieldInlinePredicate as fieldInlinePredicate,
|
84 |
+
Assertions$5_fieldLengthPredicate as fieldLengthPredicate,
|
85 |
+
Assertions$5_fieldNamePredicate as fieldNamePredicate,
|
86 |
+
Assertions$5_fieldValuePredicate as fieldValuePredicate,
|
87 |
+
Assertions$5_footerTextPredicate as footerTextPredicate,
|
88 |
+
Assertions$5_imageURLPredicate as imageURLPredicate,
|
89 |
+
Assertions$5_timestampPredicate as timestampPredicate,
|
90 |
+
Assertions$5_titlePredicate as titlePredicate,
|
91 |
+
Assertions$5_urlPredicate as urlPredicate,
|
92 |
+
Assertions$5_validateFieldLength as validateFieldLength,
|
93 |
+
};
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Normalizes data that is a rest parameter or an array into an array with a depth of 1.
|
98 |
+
*
|
99 |
+
* @typeParam ItemType - The data that must satisfy {@link RestOrArray}.
|
100 |
+
* @param arr - The (possibly variadic) data to normalize
|
101 |
+
*/
|
102 |
+
declare function normalizeArray<ItemType>(arr: RestOrArray<ItemType>): ItemType[];
|
103 |
+
/**
|
104 |
+
* Represents data that may be an array or came from a rest parameter.
|
105 |
+
*
|
106 |
+
* @remarks
|
107 |
+
* This type is used throughout builders to ensure both an array and variadic arguments
|
108 |
+
* may be used. It is normalized with {@link normalizeArray}.
|
109 |
+
*/
|
110 |
+
type RestOrArray<Type> = Type[] | [Type[]];
|
111 |
+
|
112 |
+
/**
|
113 |
+
* A tuple satisfying the RGB color model.
|
114 |
+
*
|
115 |
+
* @see {@link https://developer.mozilla.org/docs/Glossary/RGB}
|
116 |
+
*/
|
117 |
+
type RGBTuple = [red: number, green: number, blue: number];
|
118 |
+
/**
|
119 |
+
* The base icon data typically used in payloads.
|
120 |
+
*/
|
121 |
+
interface IconData {
|
122 |
+
/**
|
123 |
+
* The URL of the icon.
|
124 |
+
*/
|
125 |
+
iconURL?: string;
|
126 |
+
/**
|
127 |
+
* The proxy URL of the icon.
|
128 |
+
*/
|
129 |
+
proxyIconURL?: string;
|
130 |
+
}
|
131 |
+
/**
|
132 |
+
* Represents the author data of an embed.
|
133 |
+
*/
|
134 |
+
type EmbedAuthorData = IconData & Omit<APIEmbedAuthor, 'icon_url' | 'proxy_icon_url'>;
|
135 |
+
/**
|
136 |
+
* Represents the author options of an embed.
|
137 |
+
*/
|
138 |
+
type EmbedAuthorOptions = Omit<EmbedAuthorData, 'proxyIconURL'>;
|
139 |
+
/**
|
140 |
+
* Represents the footer data of an embed.
|
141 |
+
*/
|
142 |
+
type EmbedFooterData = IconData & Omit<APIEmbedFooter, 'icon_url' | 'proxy_icon_url'>;
|
143 |
+
/**
|
144 |
+
* Represents the footer options of an embed.
|
145 |
+
*/
|
146 |
+
type EmbedFooterOptions = Omit<EmbedFooterData, 'proxyIconURL'>;
|
147 |
+
/**
|
148 |
+
* Represents the image data of an embed.
|
149 |
+
*/
|
150 |
+
interface EmbedImageData extends Omit<APIEmbedImage, 'proxy_url'> {
|
151 |
+
/**
|
152 |
+
* The proxy URL for the image.
|
153 |
+
*/
|
154 |
+
proxyURL?: string;
|
155 |
+
}
|
156 |
+
/**
|
157 |
+
* A builder that creates API-compatible JSON data for embeds.
|
158 |
+
*/
|
159 |
+
declare class EmbedBuilder {
|
160 |
+
/**
|
161 |
+
* The API data associated with this embed.
|
162 |
+
*/
|
163 |
+
readonly data: APIEmbed;
|
164 |
+
/**
|
165 |
+
* Creates a new embed from API data.
|
166 |
+
*
|
167 |
+
* @param data - The API data to create this embed with
|
168 |
+
*/
|
169 |
+
constructor(data?: APIEmbed);
|
170 |
+
/**
|
171 |
+
* Appends fields to the embed.
|
172 |
+
*
|
173 |
+
* @remarks
|
174 |
+
* This method accepts either an array of fields or a variable number of field parameters.
|
175 |
+
* The maximum amount of fields that can be added is 25.
|
176 |
+
* @example
|
177 |
+
* Using an array:
|
178 |
+
* ```ts
|
179 |
+
* const fields: APIEmbedField[] = ...;
|
180 |
+
* const embed = new EmbedBuilder()
|
181 |
+
* .addFields(fields);
|
182 |
+
* ```
|
183 |
+
* @example
|
184 |
+
* Using rest parameters (variadic):
|
185 |
+
* ```ts
|
186 |
+
* const embed = new EmbedBuilder()
|
187 |
+
* .addFields(
|
188 |
+
* { name: 'Field 1', value: 'Value 1' },
|
189 |
+
* { name: 'Field 2', value: 'Value 2' },
|
190 |
+
* );
|
191 |
+
* ```
|
192 |
+
* @param fields - The fields to add
|
193 |
+
*/
|
194 |
+
addFields(...fields: RestOrArray<APIEmbedField>): this;
|
195 |
+
/**
|
196 |
+
* Removes, replaces, or inserts fields for this embed.
|
197 |
+
*
|
198 |
+
* @remarks
|
199 |
+
* This method behaves similarly
|
200 |
+
* to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
201 |
+
* The maximum amount of fields that can be added is 25.
|
202 |
+
*
|
203 |
+
* It's useful for modifying and adjusting order of the already-existing fields of an embed.
|
204 |
+
* @example
|
205 |
+
* Remove the first field:
|
206 |
+
* ```ts
|
207 |
+
* embed.spliceFields(0, 1);
|
208 |
+
* ```
|
209 |
+
* @example
|
210 |
+
* Remove the first n fields:
|
211 |
+
* ```ts
|
212 |
+
* const n = 4;
|
213 |
+
* embed.spliceFields(0, n);
|
214 |
+
* ```
|
215 |
+
* @example
|
216 |
+
* Remove the last field:
|
217 |
+
* ```ts
|
218 |
+
* embed.spliceFields(-1, 1);
|
219 |
+
* ```
|
220 |
+
* @param index - The index to start at
|
221 |
+
* @param deleteCount - The number of fields to remove
|
222 |
+
* @param fields - The replacing field objects
|
223 |
+
*/
|
224 |
+
spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this;
|
225 |
+
/**
|
226 |
+
* Sets the fields for this embed.
|
227 |
+
*
|
228 |
+
* @remarks
|
229 |
+
* This method is an alias for {@link EmbedBuilder.spliceFields}. More specifically,
|
230 |
+
* it splices the entire array of fields, replacing them with the provided fields.
|
231 |
+
*
|
232 |
+
* You can set a maximum of 25 fields.
|
233 |
+
* @param fields - The fields to set
|
234 |
+
*/
|
235 |
+
setFields(...fields: RestOrArray<APIEmbedField>): this;
|
236 |
+
/**
|
237 |
+
* Sets the author of this embed.
|
238 |
+
*
|
239 |
+
* @param options - The options to use
|
240 |
+
*/
|
241 |
+
setAuthor(options: EmbedAuthorOptions | null): this;
|
242 |
+
/**
|
243 |
+
* Sets the color of this embed.
|
244 |
+
*
|
245 |
+
* @param color - The color to use
|
246 |
+
*/
|
247 |
+
setColor(color: RGBTuple | number | null): this;
|
248 |
+
/**
|
249 |
+
* Sets the description of this embed.
|
250 |
+
*
|
251 |
+
* @param description - The description to use
|
252 |
+
*/
|
253 |
+
setDescription(description: string | null): this;
|
254 |
+
/**
|
255 |
+
* Sets the footer of this embed.
|
256 |
+
*
|
257 |
+
* @param options - The footer to use
|
258 |
+
*/
|
259 |
+
setFooter(options: EmbedFooterOptions | null): this;
|
260 |
+
/**
|
261 |
+
* Sets the image of this embed.
|
262 |
+
*
|
263 |
+
* @param url - The image URL to use
|
264 |
+
*/
|
265 |
+
setImage(url: string | null): this;
|
266 |
+
/**
|
267 |
+
* Sets the thumbnail of this embed.
|
268 |
+
*
|
269 |
+
* @param url - The thumbnail URL to use
|
270 |
+
*/
|
271 |
+
setThumbnail(url: string | null): this;
|
272 |
+
/**
|
273 |
+
* Sets the timestamp of this embed.
|
274 |
+
*
|
275 |
+
* @param timestamp - The timestamp or date to use
|
276 |
+
*/
|
277 |
+
setTimestamp(timestamp?: Date | number | null): this;
|
278 |
+
/**
|
279 |
+
* Sets the title for this embed.
|
280 |
+
*
|
281 |
+
* @param title - The title to use
|
282 |
+
*/
|
283 |
+
setTitle(title: string | null): this;
|
284 |
+
/**
|
285 |
+
* Sets the URL of this embed.
|
286 |
+
*
|
287 |
+
* @param url - The URL to use
|
288 |
+
*/
|
289 |
+
setURL(url: string | null): this;
|
290 |
+
/**
|
291 |
+
* Serializes this builder to API-compatible JSON data.
|
292 |
+
*
|
293 |
+
* @remarks
|
294 |
+
* This method runs validations on the data before serializing it.
|
295 |
+
* As such, it may throw an error if the data is invalid.
|
296 |
+
*/
|
297 |
+
toJSON(): APIEmbed;
|
298 |
+
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* A builder that creates API-compatible JSON data for string select menu options.
|
302 |
+
*/
|
303 |
+
declare class StringSelectMenuOptionBuilder implements JSONEncodable<APISelectMenuOption> {
|
304 |
+
data: Partial<APISelectMenuOption>;
|
305 |
+
/**
|
306 |
+
* Creates a new string select menu option from API data.
|
307 |
+
*
|
308 |
+
* @param data - The API data to create this string select menu option with
|
309 |
+
* @example
|
310 |
+
* Creating a string select menu option from an API data object:
|
311 |
+
* ```ts
|
312 |
+
* const selectMenuOption = new SelectMenuOptionBuilder({
|
313 |
+
* label: 'catchy label',
|
314 |
+
* value: '1',
|
315 |
+
* });
|
316 |
+
* ```
|
317 |
+
* @example
|
318 |
+
* Creating a string select menu option using setters and API data:
|
319 |
+
* ```ts
|
320 |
+
* const selectMenuOption = new SelectMenuOptionBuilder({
|
321 |
+
* default: true,
|
322 |
+
* value: '1',
|
323 |
+
* })
|
324 |
+
* .setLabel('woah');
|
325 |
+
* ```
|
326 |
+
*/
|
327 |
+
constructor(data?: Partial<APISelectMenuOption>);
|
328 |
+
/**
|
329 |
+
* Sets the label for this option.
|
330 |
+
*
|
331 |
+
* @param label - The label to use
|
332 |
+
*/
|
333 |
+
setLabel(label: string): this;
|
334 |
+
/**
|
335 |
+
* Sets the value for this option.
|
336 |
+
*
|
337 |
+
* @param value - The value to use
|
338 |
+
*/
|
339 |
+
setValue(value: string): this;
|
340 |
+
/**
|
341 |
+
* Sets the description for this option.
|
342 |
+
*
|
343 |
+
* @param description - The description to use
|
344 |
+
*/
|
345 |
+
setDescription(description: string): this;
|
346 |
+
/**
|
347 |
+
* Sets whether this option is selected by default.
|
348 |
+
*
|
349 |
+
* @param isDefault - Whether this option is selected by default
|
350 |
+
*/
|
351 |
+
setDefault(isDefault?: boolean): this;
|
352 |
+
/**
|
353 |
+
* Sets the emoji to display for this option.
|
354 |
+
*
|
355 |
+
* @param emoji - The emoji to use
|
356 |
+
*/
|
357 |
+
setEmoji(emoji: APIMessageComponentEmoji): this;
|
358 |
+
/**
|
359 |
+
* {@inheritDoc BaseSelectMenuBuilder.toJSON}
|
360 |
+
*/
|
361 |
+
toJSON(): APISelectMenuOption;
|
362 |
+
}
|
363 |
+
|
364 |
+
declare const customIdValidator: _sapphire_shapeshift.StringValidator<string>;
|
365 |
+
declare const emojiValidator: _sapphire_shapeshift.ObjectValidator<{
|
366 |
+
name?: string | undefined;
|
367 |
+
id?: string | undefined;
|
368 |
+
animated?: boolean | undefined;
|
369 |
+
}, _sapphire_shapeshift.UndefinedToOptional<{
|
370 |
+
name?: string | undefined;
|
371 |
+
id?: string | undefined;
|
372 |
+
animated?: boolean | undefined;
|
373 |
+
}>>;
|
374 |
+
declare const disabledValidator: _sapphire_shapeshift.BooleanValidator<boolean>;
|
375 |
+
declare const buttonLabelValidator: _sapphire_shapeshift.StringValidator<string>;
|
376 |
+
declare const buttonStyleValidator: _sapphire_shapeshift.NativeEnumValidator<typeof ButtonStyle>;
|
377 |
+
declare const placeholderValidator$1: _sapphire_shapeshift.StringValidator<string>;
|
378 |
+
declare const minMaxValidator: _sapphire_shapeshift.NumberValidator<number>;
|
379 |
+
declare const labelValueDescriptionValidator: _sapphire_shapeshift.StringValidator<string>;
|
380 |
+
declare const jsonOptionValidator: _sapphire_shapeshift.ObjectValidator<{
|
381 |
+
label: string;
|
382 |
+
value: string;
|
383 |
+
description: string | undefined;
|
384 |
+
emoji: _sapphire_shapeshift.UndefinedToOptional<{
|
385 |
+
name?: string | undefined;
|
386 |
+
id?: string | undefined;
|
387 |
+
animated?: boolean | undefined;
|
388 |
+
}> | undefined;
|
389 |
+
default: boolean | undefined;
|
390 |
+
}, _sapphire_shapeshift.UndefinedToOptional<{
|
391 |
+
label: string;
|
392 |
+
value: string;
|
393 |
+
description: string | undefined;
|
394 |
+
emoji: _sapphire_shapeshift.UndefinedToOptional<{
|
395 |
+
name?: string | undefined;
|
396 |
+
id?: string | undefined;
|
397 |
+
animated?: boolean | undefined;
|
398 |
+
}> | undefined;
|
399 |
+
default: boolean | undefined;
|
400 |
+
}>>;
|
401 |
+
declare const optionValidator: _sapphire_shapeshift.InstanceValidator<StringSelectMenuOptionBuilder>;
|
402 |
+
declare const optionsValidator: _sapphire_shapeshift.ArrayValidator<StringSelectMenuOptionBuilder[], StringSelectMenuOptionBuilder>;
|
403 |
+
declare const optionsLengthValidator: _sapphire_shapeshift.NumberValidator<number>;
|
404 |
+
declare function validateRequiredSelectMenuParameters(options: StringSelectMenuOptionBuilder[], customId?: string): void;
|
405 |
+
declare const defaultValidator: _sapphire_shapeshift.BooleanValidator<boolean>;
|
406 |
+
declare function validateRequiredSelectMenuOptionParameters(label?: string, value?: string): void;
|
407 |
+
declare const channelTypesValidator: _sapphire_shapeshift.ArrayValidator<ChannelType[], ChannelType>;
|
408 |
+
declare const urlValidator: _sapphire_shapeshift.StringValidator<string>;
|
409 |
+
declare function validateRequiredButtonParameters(style?: ButtonStyle, label?: string, emoji?: APIMessageComponentEmoji, customId?: string, url?: string): void;
|
410 |
+
|
411 |
+
declare const Assertions$4_buttonLabelValidator: typeof buttonLabelValidator;
|
412 |
+
declare const Assertions$4_buttonStyleValidator: typeof buttonStyleValidator;
|
413 |
+
declare const Assertions$4_channelTypesValidator: typeof channelTypesValidator;
|
414 |
+
declare const Assertions$4_customIdValidator: typeof customIdValidator;
|
415 |
+
declare const Assertions$4_defaultValidator: typeof defaultValidator;
|
416 |
+
declare const Assertions$4_disabledValidator: typeof disabledValidator;
|
417 |
+
declare const Assertions$4_emojiValidator: typeof emojiValidator;
|
418 |
+
declare const Assertions$4_jsonOptionValidator: typeof jsonOptionValidator;
|
419 |
+
declare const Assertions$4_labelValueDescriptionValidator: typeof labelValueDescriptionValidator;
|
420 |
+
declare const Assertions$4_minMaxValidator: typeof minMaxValidator;
|
421 |
+
declare const Assertions$4_optionValidator: typeof optionValidator;
|
422 |
+
declare const Assertions$4_optionsLengthValidator: typeof optionsLengthValidator;
|
423 |
+
declare const Assertions$4_optionsValidator: typeof optionsValidator;
|
424 |
+
declare const Assertions$4_urlValidator: typeof urlValidator;
|
425 |
+
declare const Assertions$4_validateRequiredButtonParameters: typeof validateRequiredButtonParameters;
|
426 |
+
declare const Assertions$4_validateRequiredSelectMenuOptionParameters: typeof validateRequiredSelectMenuOptionParameters;
|
427 |
+
declare const Assertions$4_validateRequiredSelectMenuParameters: typeof validateRequiredSelectMenuParameters;
|
428 |
+
declare namespace Assertions$4 {
|
429 |
+
export {
|
430 |
+
Assertions$4_buttonLabelValidator as buttonLabelValidator,
|
431 |
+
Assertions$4_buttonStyleValidator as buttonStyleValidator,
|
432 |
+
Assertions$4_channelTypesValidator as channelTypesValidator,
|
433 |
+
Assertions$4_customIdValidator as customIdValidator,
|
434 |
+
Assertions$4_defaultValidator as defaultValidator,
|
435 |
+
Assertions$4_disabledValidator as disabledValidator,
|
436 |
+
Assertions$4_emojiValidator as emojiValidator,
|
437 |
+
Assertions$4_jsonOptionValidator as jsonOptionValidator,
|
438 |
+
Assertions$4_labelValueDescriptionValidator as labelValueDescriptionValidator,
|
439 |
+
Assertions$4_minMaxValidator as minMaxValidator,
|
440 |
+
Assertions$4_optionValidator as optionValidator,
|
441 |
+
Assertions$4_optionsLengthValidator as optionsLengthValidator,
|
442 |
+
Assertions$4_optionsValidator as optionsValidator,
|
443 |
+
placeholderValidator$1 as placeholderValidator,
|
444 |
+
Assertions$4_urlValidator as urlValidator,
|
445 |
+
Assertions$4_validateRequiredButtonParameters as validateRequiredButtonParameters,
|
446 |
+
Assertions$4_validateRequiredSelectMenuOptionParameters as validateRequiredSelectMenuOptionParameters,
|
447 |
+
Assertions$4_validateRequiredSelectMenuParameters as validateRequiredSelectMenuParameters,
|
448 |
+
};
|
449 |
+
}
|
450 |
+
|
451 |
+
/**
|
452 |
+
* Any action row component data represented as an object.
|
453 |
+
*/
|
454 |
+
type AnyAPIActionRowComponent = APIActionRowComponent<APIActionRowComponentTypes> | APIActionRowComponentTypes;
|
455 |
+
/**
|
456 |
+
* The base component builder that contains common symbols for all sorts of components.
|
457 |
+
*
|
458 |
+
* @typeParam DataType - The type of internal API data that is stored within the component
|
459 |
+
*/
|
460 |
+
declare abstract class ComponentBuilder<DataType extends Partial<APIBaseComponent<ComponentType>> = APIBaseComponent<ComponentType>> implements JSONEncodable<AnyAPIActionRowComponent> {
|
461 |
+
/**
|
462 |
+
* The API data associated with this component.
|
463 |
+
*/
|
464 |
+
readonly data: Partial<DataType>;
|
465 |
+
/**
|
466 |
+
* Serializes this builder to API-compatible JSON data.
|
467 |
+
*
|
468 |
+
* @remarks
|
469 |
+
* This method runs validations on the data before serializing it.
|
470 |
+
* As such, it may throw an error if the data is invalid.
|
471 |
+
*/
|
472 |
+
abstract toJSON(): AnyAPIActionRowComponent;
|
473 |
+
/**
|
474 |
+
* Constructs a new kind of component.
|
475 |
+
*
|
476 |
+
* @param data - The data to construct a component out of
|
477 |
+
*/
|
478 |
+
constructor(data: Partial<DataType>);
|
479 |
+
}
|
480 |
+
|
481 |
+
/**
|
482 |
+
* A builder that creates API-compatible JSON data for buttons.
|
483 |
+
*/
|
484 |
+
declare class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
|
485 |
+
/**
|
486 |
+
* Creates a new button from API data.
|
487 |
+
*
|
488 |
+
* @param data - The API data to create this button with
|
489 |
+
* @example
|
490 |
+
* Creating a button from an API data object:
|
491 |
+
* ```ts
|
492 |
+
* const button = new ButtonBuilder({
|
493 |
+
* custom_id: 'a cool button',
|
494 |
+
* style: ButtonStyle.Primary,
|
495 |
+
* label: 'Click Me',
|
496 |
+
* emoji: {
|
497 |
+
* name: 'smile',
|
498 |
+
* id: '123456789012345678',
|
499 |
+
* },
|
500 |
+
* });
|
501 |
+
* ```
|
502 |
+
* @example
|
503 |
+
* Creating a button using setters and API data:
|
504 |
+
* ```ts
|
505 |
+
* const button = new ButtonBuilder({
|
506 |
+
* style: ButtonStyle.Secondary,
|
507 |
+
* label: 'Click Me',
|
508 |
+
* })
|
509 |
+
* .setEmoji({ name: '🙂' })
|
510 |
+
* .setCustomId('another cool button');
|
511 |
+
* ```
|
512 |
+
*/
|
513 |
+
constructor(data?: Partial<APIButtonComponent>);
|
514 |
+
/**
|
515 |
+
* Sets the style of this button.
|
516 |
+
*
|
517 |
+
* @param style - The style to use
|
518 |
+
*/
|
519 |
+
setStyle(style: ButtonStyle): this;
|
520 |
+
/**
|
521 |
+
* Sets the URL for this button.
|
522 |
+
*
|
523 |
+
* @remarks
|
524 |
+
* This method is only available to buttons using the `Link` button style.
|
525 |
+
* Only three types of URL schemes are currently supported: `https://`, `http://`, and `discord://`.
|
526 |
+
* @param url - The URL to use
|
527 |
+
*/
|
528 |
+
setURL(url: string): this;
|
529 |
+
/**
|
530 |
+
* Sets the custom id for this button.
|
531 |
+
*
|
532 |
+
* @remarks
|
533 |
+
* This method is only applicable to buttons that are not using the `Link` button style.
|
534 |
+
* @param customId - The custom id to use
|
535 |
+
*/
|
536 |
+
setCustomId(customId: string): this;
|
537 |
+
/**
|
538 |
+
* Sets the emoji to display on this button.
|
539 |
+
*
|
540 |
+
* @param emoji - The emoji to use
|
541 |
+
*/
|
542 |
+
setEmoji(emoji: APIMessageComponentEmoji): this;
|
543 |
+
/**
|
544 |
+
* Sets whether this button is disabled.
|
545 |
+
*
|
546 |
+
* @param disabled - Whether to disable this button
|
547 |
+
*/
|
548 |
+
setDisabled(disabled?: boolean): this;
|
549 |
+
/**
|
550 |
+
* Sets the label for this button.
|
551 |
+
*
|
552 |
+
* @param label - The label to use
|
553 |
+
*/
|
554 |
+
setLabel(label: string): this;
|
555 |
+
/**
|
556 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
557 |
+
*/
|
558 |
+
toJSON(): APIButtonComponent;
|
559 |
+
}
|
560 |
+
|
561 |
+
/**
|
562 |
+
* The base select menu builder that contains common symbols for select menu builders.
|
563 |
+
*
|
564 |
+
* @typeParam SelectMenuType - The type of select menu this would be instantiated for.
|
565 |
+
*/
|
566 |
+
declare abstract class BaseSelectMenuBuilder<SelectMenuType extends APISelectMenuComponent> extends ComponentBuilder<SelectMenuType> {
|
567 |
+
/**
|
568 |
+
* Sets the placeholder for this select menu.
|
569 |
+
*
|
570 |
+
* @param placeholder - The placeholder to use
|
571 |
+
*/
|
572 |
+
setPlaceholder(placeholder: string): this;
|
573 |
+
/**
|
574 |
+
* Sets the minimum values that must be selected in the select menu.
|
575 |
+
*
|
576 |
+
* @param minValues - The minimum values that must be selected
|
577 |
+
*/
|
578 |
+
setMinValues(minValues: number): this;
|
579 |
+
/**
|
580 |
+
* Sets the maximum values that must be selected in the select menu.
|
581 |
+
*
|
582 |
+
* @param maxValues - The maximum values that must be selected
|
583 |
+
*/
|
584 |
+
setMaxValues(maxValues: number): this;
|
585 |
+
/**
|
586 |
+
* Sets the custom id for this select menu.
|
587 |
+
*
|
588 |
+
* @param customId - The custom id to use
|
589 |
+
*/
|
590 |
+
setCustomId(customId: string): this;
|
591 |
+
/**
|
592 |
+
* Sets whether this select menu is disabled.
|
593 |
+
*
|
594 |
+
* @param disabled - Whether this select menu is disabled
|
595 |
+
*/
|
596 |
+
setDisabled(disabled?: boolean): this;
|
597 |
+
/**
|
598 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
599 |
+
*/
|
600 |
+
toJSON(): SelectMenuType;
|
601 |
+
}
|
602 |
+
|
603 |
+
/**
|
604 |
+
* A builder that creates API-compatible JSON data for channel select menus.
|
605 |
+
*/
|
606 |
+
declare class ChannelSelectMenuBuilder extends BaseSelectMenuBuilder<APIChannelSelectComponent> {
|
607 |
+
/**
|
608 |
+
* Creates a new select menu from API data.
|
609 |
+
*
|
610 |
+
* @param data - The API data to create this select menu with
|
611 |
+
* @example
|
612 |
+
* Creating a select menu from an API data object:
|
613 |
+
* ```ts
|
614 |
+
* const selectMenu = new ChannelSelectMenuBuilder({
|
615 |
+
* custom_id: 'a cool select menu',
|
616 |
+
* placeholder: 'select an option',
|
617 |
+
* max_values: 2,
|
618 |
+
* });
|
619 |
+
* ```
|
620 |
+
* @example
|
621 |
+
* Creating a select menu using setters and API data:
|
622 |
+
* ```ts
|
623 |
+
* const selectMenu = new ChannelSelectMenuBuilder({
|
624 |
+
* custom_id: 'a cool select menu',
|
625 |
+
* })
|
626 |
+
* .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
|
627 |
+
* .setMinValues(2);
|
628 |
+
* ```
|
629 |
+
*/
|
630 |
+
constructor(data?: Partial<APIChannelSelectComponent>);
|
631 |
+
/**
|
632 |
+
* Adds channel types to this select menu.
|
633 |
+
*
|
634 |
+
* @param types - The channel types to use
|
635 |
+
*/
|
636 |
+
addChannelTypes(...types: RestOrArray<ChannelType>): this;
|
637 |
+
/**
|
638 |
+
* Sets channel types for this select menu.
|
639 |
+
*
|
640 |
+
* @param types - The channel types to use
|
641 |
+
*/
|
642 |
+
setChannelTypes(...types: RestOrArray<ChannelType>): this;
|
643 |
+
/**
|
644 |
+
* Adds default channels to this auto populated select menu.
|
645 |
+
*
|
646 |
+
* @param channels - The channels to add
|
647 |
+
*/
|
648 |
+
addDefaultChannels(...channels: RestOrArray<Snowflake>): this;
|
649 |
+
/**
|
650 |
+
* Sets default channels to this auto populated select menu.
|
651 |
+
*
|
652 |
+
* @param channels - The channels to set
|
653 |
+
*/
|
654 |
+
setDefaultChannels(...channels: RestOrArray<Snowflake>): this;
|
655 |
+
/**
|
656 |
+
* {@inheritDoc BaseSelectMenuBuilder.toJSON}
|
657 |
+
*/
|
658 |
+
toJSON(): APIChannelSelectComponent;
|
659 |
+
}
|
660 |
+
|
661 |
+
/**
|
662 |
+
* A builder that creates API-compatible JSON data for mentionable select menus.
|
663 |
+
*/
|
664 |
+
declare class MentionableSelectMenuBuilder extends BaseSelectMenuBuilder<APIMentionableSelectComponent> {
|
665 |
+
/**
|
666 |
+
* Creates a new select menu from API data.
|
667 |
+
*
|
668 |
+
* @param data - The API data to create this select menu with
|
669 |
+
* @example
|
670 |
+
* Creating a select menu from an API data object:
|
671 |
+
* ```ts
|
672 |
+
* const selectMenu = new MentionableSelectMenuBuilder({
|
673 |
+
* custom_id: 'a cool select menu',
|
674 |
+
* placeholder: 'select an option',
|
675 |
+
* max_values: 2,
|
676 |
+
* });
|
677 |
+
* ```
|
678 |
+
* @example
|
679 |
+
* Creating a select menu using setters and API data:
|
680 |
+
* ```ts
|
681 |
+
* const selectMenu = new MentionableSelectMenuBuilder({
|
682 |
+
* custom_id: 'a cool select menu',
|
683 |
+
* })
|
684 |
+
* .setMinValues(1);
|
685 |
+
* ```
|
686 |
+
*/
|
687 |
+
constructor(data?: Partial<APIMentionableSelectComponent>);
|
688 |
+
/**
|
689 |
+
* Adds default roles to this auto populated select menu.
|
690 |
+
*
|
691 |
+
* @param roles - The roles to add
|
692 |
+
*/
|
693 |
+
addDefaultRoles(...roles: RestOrArray<Snowflake>): this;
|
694 |
+
/**
|
695 |
+
* Adds default users to this auto populated select menu.
|
696 |
+
*
|
697 |
+
* @param users - The users to add
|
698 |
+
*/
|
699 |
+
addDefaultUsers(...users: RestOrArray<Snowflake>): this;
|
700 |
+
/**
|
701 |
+
* Adds default values to this auto populated select menu.
|
702 |
+
*
|
703 |
+
* @param values - The values to add
|
704 |
+
*/
|
705 |
+
addDefaultValues(...values: RestOrArray<APISelectMenuDefaultValue<SelectMenuDefaultValueType.Role> | APISelectMenuDefaultValue<SelectMenuDefaultValueType.User>>): this;
|
706 |
+
/**
|
707 |
+
* Sets default values to this auto populated select menu.
|
708 |
+
*
|
709 |
+
* @param values - The values to set
|
710 |
+
*/
|
711 |
+
setDefaultValues(...values: RestOrArray<APISelectMenuDefaultValue<SelectMenuDefaultValueType.Role> | APISelectMenuDefaultValue<SelectMenuDefaultValueType.User>>): this;
|
712 |
+
}
|
713 |
+
|
714 |
+
/**
|
715 |
+
* A builder that creates API-compatible JSON data for role select menus.
|
716 |
+
*/
|
717 |
+
declare class RoleSelectMenuBuilder extends BaseSelectMenuBuilder<APIRoleSelectComponent> {
|
718 |
+
/**
|
719 |
+
* Creates a new select menu from API data.
|
720 |
+
*
|
721 |
+
* @param data - The API data to create this select menu with
|
722 |
+
* @example
|
723 |
+
* Creating a select menu from an API data object:
|
724 |
+
* ```ts
|
725 |
+
* const selectMenu = new RoleSelectMenuBuilder({
|
726 |
+
* custom_id: 'a cool select menu',
|
727 |
+
* placeholder: 'select an option',
|
728 |
+
* max_values: 2,
|
729 |
+
* });
|
730 |
+
* ```
|
731 |
+
* @example
|
732 |
+
* Creating a select menu using setters and API data:
|
733 |
+
* ```ts
|
734 |
+
* const selectMenu = new RoleSelectMenuBuilder({
|
735 |
+
* custom_id: 'a cool select menu',
|
736 |
+
* })
|
737 |
+
* .setMinValues(1);
|
738 |
+
* ```
|
739 |
+
*/
|
740 |
+
constructor(data?: Partial<APIRoleSelectComponent>);
|
741 |
+
/**
|
742 |
+
* Adds default roles to this auto populated select menu.
|
743 |
+
*
|
744 |
+
* @param roles - The roles to add
|
745 |
+
*/
|
746 |
+
addDefaultRoles(...roles: RestOrArray<Snowflake>): this;
|
747 |
+
/**
|
748 |
+
* Sets default roles to this auto populated select menu.
|
749 |
+
*
|
750 |
+
* @param roles - The roles to set
|
751 |
+
*/
|
752 |
+
setDefaultRoles(...roles: RestOrArray<Snowflake>): this;
|
753 |
+
}
|
754 |
+
|
755 |
+
/**
|
756 |
+
* A builder that creates API-compatible JSON data for string select menus.
|
757 |
+
*/
|
758 |
+
declare class StringSelectMenuBuilder extends BaseSelectMenuBuilder<APIStringSelectComponent> {
|
759 |
+
/**
|
760 |
+
* The options within this select menu.
|
761 |
+
*/
|
762 |
+
readonly options: StringSelectMenuOptionBuilder[];
|
763 |
+
/**
|
764 |
+
* Creates a new select menu from API data.
|
765 |
+
*
|
766 |
+
* @param data - The API data to create this select menu with
|
767 |
+
* @example
|
768 |
+
* Creating a select menu from an API data object:
|
769 |
+
* ```ts
|
770 |
+
* const selectMenu = new StringSelectMenuBuilder({
|
771 |
+
* custom_id: 'a cool select menu',
|
772 |
+
* placeholder: 'select an option',
|
773 |
+
* max_values: 2,
|
774 |
+
* options: [
|
775 |
+
* { label: 'option 1', value: '1' },
|
776 |
+
* { label: 'option 2', value: '2' },
|
777 |
+
* { label: 'option 3', value: '3' },
|
778 |
+
* ],
|
779 |
+
* });
|
780 |
+
* ```
|
781 |
+
* @example
|
782 |
+
* Creating a select menu using setters and API data:
|
783 |
+
* ```ts
|
784 |
+
* const selectMenu = new StringSelectMenuBuilder({
|
785 |
+
* custom_id: 'a cool select menu',
|
786 |
+
* })
|
787 |
+
* .setMinValues(1)
|
788 |
+
* .addOptions({
|
789 |
+
* label: 'Catchy',
|
790 |
+
* value: 'catch',
|
791 |
+
* });
|
792 |
+
* ```
|
793 |
+
*/
|
794 |
+
constructor(data?: Partial<APIStringSelectComponent>);
|
795 |
+
/**
|
796 |
+
* Adds options to this select menu.
|
797 |
+
*
|
798 |
+
* @param options - The options to add
|
799 |
+
*/
|
800 |
+
addOptions(...options: RestOrArray<APISelectMenuOption | StringSelectMenuOptionBuilder>): this;
|
801 |
+
/**
|
802 |
+
* Sets the options for this select menu.
|
803 |
+
*
|
804 |
+
* @param options - The options to set
|
805 |
+
*/
|
806 |
+
setOptions(...options: RestOrArray<APISelectMenuOption | StringSelectMenuOptionBuilder>): this;
|
807 |
+
/**
|
808 |
+
* Removes, replaces, or inserts options for this select menu.
|
809 |
+
*
|
810 |
+
* @remarks
|
811 |
+
* This method behaves similarly
|
812 |
+
* to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | Array.prototype.splice()}.
|
813 |
+
* It's useful for modifying and adjusting the order of existing options.
|
814 |
+
* @example
|
815 |
+
* Remove the first option:
|
816 |
+
* ```ts
|
817 |
+
* selectMenu.spliceOptions(0, 1);
|
818 |
+
* ```
|
819 |
+
* @example
|
820 |
+
* Remove the first n option:
|
821 |
+
* ```ts
|
822 |
+
* const n = 4;
|
823 |
+
* selectMenu.spliceOptions(0, n);
|
824 |
+
* ```
|
825 |
+
* @example
|
826 |
+
* Remove the last option:
|
827 |
+
* ```ts
|
828 |
+
* selectMenu.spliceOptions(-1, 1);
|
829 |
+
* ```
|
830 |
+
* @param index - The index to start at
|
831 |
+
* @param deleteCount - The number of options to remove
|
832 |
+
* @param options - The replacing option objects or builders
|
833 |
+
*/
|
834 |
+
spliceOptions(index: number, deleteCount: number, ...options: RestOrArray<APISelectMenuOption | StringSelectMenuOptionBuilder>): this;
|
835 |
+
/**
|
836 |
+
* {@inheritDoc BaseSelectMenuBuilder.toJSON}
|
837 |
+
*/
|
838 |
+
toJSON(): APIStringSelectComponent;
|
839 |
+
}
|
840 |
+
|
841 |
+
/**
|
842 |
+
* A builder that creates API-compatible JSON data for user select menus.
|
843 |
+
*/
|
844 |
+
declare class UserSelectMenuBuilder extends BaseSelectMenuBuilder<APIUserSelectComponent> {
|
845 |
+
/**
|
846 |
+
* Creates a new select menu from API data.
|
847 |
+
*
|
848 |
+
* @param data - The API data to create this select menu with
|
849 |
+
* @example
|
850 |
+
* Creating a select menu from an API data object:
|
851 |
+
* ```ts
|
852 |
+
* const selectMenu = new UserSelectMenuBuilder({
|
853 |
+
* custom_id: 'a cool select menu',
|
854 |
+
* placeholder: 'select an option',
|
855 |
+
* max_values: 2,
|
856 |
+
* });
|
857 |
+
* ```
|
858 |
+
* @example
|
859 |
+
* Creating a select menu using setters and API data:
|
860 |
+
* ```ts
|
861 |
+
* const selectMenu = new UserSelectMenuBuilder({
|
862 |
+
* custom_id: 'a cool select menu',
|
863 |
+
* })
|
864 |
+
* .setMinValues(1);
|
865 |
+
* ```
|
866 |
+
*/
|
867 |
+
constructor(data?: Partial<APIUserSelectComponent>);
|
868 |
+
/**
|
869 |
+
* Adds default users to this auto populated select menu.
|
870 |
+
*
|
871 |
+
* @param users - The users to add
|
872 |
+
*/
|
873 |
+
addDefaultUsers(...users: RestOrArray<Snowflake>): this;
|
874 |
+
/**
|
875 |
+
* Sets default users to this auto populated select menu.
|
876 |
+
*
|
877 |
+
* @param users - The users to set
|
878 |
+
*/
|
879 |
+
setDefaultUsers(...users: RestOrArray<Snowflake>): this;
|
880 |
+
}
|
881 |
+
|
882 |
+
/**
|
883 |
+
* A builder that creates API-compatible JSON data for text inputs.
|
884 |
+
*/
|
885 |
+
declare class TextInputBuilder extends ComponentBuilder<APITextInputComponent> implements Equatable<APITextInputComponent | JSONEncodable<APITextInputComponent>> {
|
886 |
+
/**
|
887 |
+
* Creates a new text input from API data.
|
888 |
+
*
|
889 |
+
* @param data - The API data to create this text input with
|
890 |
+
* @example
|
891 |
+
* Creating a select menu option from an API data object:
|
892 |
+
* ```ts
|
893 |
+
* const textInput = new TextInputBuilder({
|
894 |
+
* custom_id: 'a cool select menu',
|
895 |
+
* label: 'Type something',
|
896 |
+
* style: TextInputStyle.Short,
|
897 |
+
* });
|
898 |
+
* ```
|
899 |
+
* @example
|
900 |
+
* Creating a select menu option using setters and API data:
|
901 |
+
* ```ts
|
902 |
+
* const textInput = new TextInputBuilder({
|
903 |
+
* label: 'Type something else',
|
904 |
+
* })
|
905 |
+
* .setCustomId('woah')
|
906 |
+
* .setStyle(TextInputStyle.Paragraph);
|
907 |
+
* ```
|
908 |
+
*/
|
909 |
+
constructor(data?: APITextInputComponent & {
|
910 |
+
type?: ComponentType.TextInput;
|
911 |
+
});
|
912 |
+
/**
|
913 |
+
* Sets the custom id for this text input.
|
914 |
+
*
|
915 |
+
* @param customId - The custom id to use
|
916 |
+
*/
|
917 |
+
setCustomId(customId: string): this;
|
918 |
+
/**
|
919 |
+
* Sets the label for this text input.
|
920 |
+
*
|
921 |
+
* @param label - The label to use
|
922 |
+
*/
|
923 |
+
setLabel(label: string): this;
|
924 |
+
/**
|
925 |
+
* Sets the style for this text input.
|
926 |
+
*
|
927 |
+
* @param style - The style to use
|
928 |
+
*/
|
929 |
+
setStyle(style: TextInputStyle): this;
|
930 |
+
/**
|
931 |
+
* Sets the minimum length of text for this text input.
|
932 |
+
*
|
933 |
+
* @param minLength - The minimum length of text for this text input
|
934 |
+
*/
|
935 |
+
setMinLength(minLength: number): this;
|
936 |
+
/**
|
937 |
+
* Sets the maximum length of text for this text input.
|
938 |
+
*
|
939 |
+
* @param maxLength - The maximum length of text for this text input
|
940 |
+
*/
|
941 |
+
setMaxLength(maxLength: number): this;
|
942 |
+
/**
|
943 |
+
* Sets the placeholder for this text input.
|
944 |
+
*
|
945 |
+
* @param placeholder - The placeholder to use
|
946 |
+
*/
|
947 |
+
setPlaceholder(placeholder: string): this;
|
948 |
+
/**
|
949 |
+
* Sets the value for this text input.
|
950 |
+
*
|
951 |
+
* @param value - The value to use
|
952 |
+
*/
|
953 |
+
setValue(value: string): this;
|
954 |
+
/**
|
955 |
+
* Sets whether this text input is required.
|
956 |
+
*
|
957 |
+
* @param required - Whether this text input is required
|
958 |
+
*/
|
959 |
+
setRequired(required?: boolean): this;
|
960 |
+
/**
|
961 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
962 |
+
*/
|
963 |
+
toJSON(): APITextInputComponent;
|
964 |
+
/**
|
965 |
+
* {@inheritDoc Equatable.equals}
|
966 |
+
*/
|
967 |
+
equals(other: APITextInputComponent | JSONEncodable<APITextInputComponent>): boolean;
|
968 |
+
}
|
969 |
+
|
970 |
+
/**
|
971 |
+
* The builders that may be used for messages.
|
972 |
+
*/
|
973 |
+
type MessageComponentBuilder = ActionRowBuilder<MessageActionRowComponentBuilder> | MessageActionRowComponentBuilder;
|
974 |
+
/**
|
975 |
+
* The builders that may be used for modals.
|
976 |
+
*/
|
977 |
+
type ModalComponentBuilder = ActionRowBuilder<ModalActionRowComponentBuilder> | ModalActionRowComponentBuilder;
|
978 |
+
/**
|
979 |
+
* The builders that may be used within an action row for messages.
|
980 |
+
*/
|
981 |
+
type MessageActionRowComponentBuilder = ButtonBuilder | ChannelSelectMenuBuilder | MentionableSelectMenuBuilder | RoleSelectMenuBuilder | StringSelectMenuBuilder | UserSelectMenuBuilder;
|
982 |
+
/**
|
983 |
+
* The builders that may be used within an action row for modals.
|
984 |
+
*/
|
985 |
+
type ModalActionRowComponentBuilder = TextInputBuilder;
|
986 |
+
/**
|
987 |
+
* Any builder.
|
988 |
+
*/
|
989 |
+
type AnyComponentBuilder = MessageActionRowComponentBuilder | ModalActionRowComponentBuilder;
|
990 |
+
/**
|
991 |
+
* A builder that creates API-compatible JSON data for action rows.
|
992 |
+
*
|
993 |
+
* @typeParam ComponentType - The types of components this action row holds
|
994 |
+
*/
|
995 |
+
declare class ActionRowBuilder<ComponentType extends AnyComponentBuilder> extends ComponentBuilder<APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>> {
|
996 |
+
/**
|
997 |
+
* The components within this action row.
|
998 |
+
*/
|
999 |
+
readonly components: ComponentType[];
|
1000 |
+
/**
|
1001 |
+
* Creates a new action row from API data.
|
1002 |
+
*
|
1003 |
+
* @param data - The API data to create this action row with
|
1004 |
+
* @example
|
1005 |
+
* Creating an action row from an API data object:
|
1006 |
+
* ```ts
|
1007 |
+
* const actionRow = new ActionRowBuilder({
|
1008 |
+
* components: [
|
1009 |
+
* {
|
1010 |
+
* custom_id: "custom id",
|
1011 |
+
* label: "Type something",
|
1012 |
+
* style: TextInputStyle.Short,
|
1013 |
+
* type: ComponentType.TextInput,
|
1014 |
+
* },
|
1015 |
+
* ],
|
1016 |
+
* });
|
1017 |
+
* ```
|
1018 |
+
* @example
|
1019 |
+
* Creating an action row using setters and API data:
|
1020 |
+
* ```ts
|
1021 |
+
* const actionRow = new ActionRowBuilder({
|
1022 |
+
* components: [
|
1023 |
+
* {
|
1024 |
+
* custom_id: "custom id",
|
1025 |
+
* label: "Click me",
|
1026 |
+
* style: ButtonStyle.Primary,
|
1027 |
+
* type: ComponentType.Button,
|
1028 |
+
* },
|
1029 |
+
* ],
|
1030 |
+
* })
|
1031 |
+
* .addComponents(button2, button3);
|
1032 |
+
* ```
|
1033 |
+
*/
|
1034 |
+
constructor({ components, ...data }?: Partial<APIActionRowComponent<APIActionRowComponentTypes>>);
|
1035 |
+
/**
|
1036 |
+
* Adds components to this action row.
|
1037 |
+
*
|
1038 |
+
* @param components - The components to add
|
1039 |
+
*/
|
1040 |
+
addComponents(...components: RestOrArray<ComponentType>): this;
|
1041 |
+
/**
|
1042 |
+
* Sets components for this action row.
|
1043 |
+
*
|
1044 |
+
* @param components - The components to set
|
1045 |
+
*/
|
1046 |
+
setComponents(...components: RestOrArray<ComponentType>): this;
|
1047 |
+
/**
|
1048 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
1049 |
+
*/
|
1050 |
+
toJSON(): APIActionRowComponent<ReturnType<ComponentType['toJSON']>>;
|
1051 |
+
}
|
1052 |
+
|
1053 |
+
/**
|
1054 |
+
* Components here are mapped to their respective builder.
|
1055 |
+
*/
|
1056 |
+
interface MappedComponentTypes {
|
1057 |
+
/**
|
1058 |
+
* The action row component type is associated with an {@link ActionRowBuilder}.
|
1059 |
+
*/
|
1060 |
+
[ComponentType.ActionRow]: ActionRowBuilder<AnyComponentBuilder>;
|
1061 |
+
/**
|
1062 |
+
* The button component type is associated with an {@link ButtonBuilder}.
|
1063 |
+
*/
|
1064 |
+
[ComponentType.Button]: ButtonBuilder;
|
1065 |
+
/**
|
1066 |
+
* The string select component type is associated with an {@link StringSelectMenuBuilder}.
|
1067 |
+
*/
|
1068 |
+
[ComponentType.StringSelect]: StringSelectMenuBuilder;
|
1069 |
+
/**
|
1070 |
+
* The text inpiut component type is associated with an {@link TextInputBuilder}.
|
1071 |
+
*/
|
1072 |
+
[ComponentType.TextInput]: TextInputBuilder;
|
1073 |
+
/**
|
1074 |
+
* The user select component type is associated with an {@link UserSelectMenuBuilder}.
|
1075 |
+
*/
|
1076 |
+
[ComponentType.UserSelect]: UserSelectMenuBuilder;
|
1077 |
+
/**
|
1078 |
+
* The role select component type is associated with an {@link RoleSelectMenuBuilder}.
|
1079 |
+
*/
|
1080 |
+
[ComponentType.RoleSelect]: RoleSelectMenuBuilder;
|
1081 |
+
/**
|
1082 |
+
* The mentionable select component type is associated with an {@link MentionableSelectMenuBuilder}.
|
1083 |
+
*/
|
1084 |
+
[ComponentType.MentionableSelect]: MentionableSelectMenuBuilder;
|
1085 |
+
/**
|
1086 |
+
* The channel select component type is associated with an {@link ChannelSelectMenuBuilder}.
|
1087 |
+
*/
|
1088 |
+
[ComponentType.ChannelSelect]: ChannelSelectMenuBuilder;
|
1089 |
+
}
|
1090 |
+
/**
|
1091 |
+
* Factory for creating components from API data.
|
1092 |
+
*
|
1093 |
+
* @typeParam ComponentType - The type of component to use
|
1094 |
+
* @param data - The API data to transform to a component class
|
1095 |
+
*/
|
1096 |
+
declare function createComponentBuilder<ComponentType extends keyof MappedComponentTypes>(data: (APIModalComponent | APIMessageComponent) & {
|
1097 |
+
type: ComponentType;
|
1098 |
+
}): MappedComponentTypes[ComponentType];
|
1099 |
+
/**
|
1100 |
+
* Factory for creating components from API data.
|
1101 |
+
*
|
1102 |
+
* @typeParam ComponentBuilder - The type of component to use
|
1103 |
+
* @param data - The API data to transform to a component class
|
1104 |
+
*/
|
1105 |
+
declare function createComponentBuilder<ComponentBuilder extends MessageComponentBuilder | ModalComponentBuilder>(data: ComponentBuilder): ComponentBuilder;
|
1106 |
+
|
1107 |
+
declare const textInputStyleValidator: _sapphire_shapeshift.NativeEnumValidator<typeof TextInputStyle>;
|
1108 |
+
declare const minLengthValidator: _sapphire_shapeshift.NumberValidator<number>;
|
1109 |
+
declare const maxLengthValidator: _sapphire_shapeshift.NumberValidator<number>;
|
1110 |
+
declare const requiredValidator: _sapphire_shapeshift.BooleanValidator<boolean>;
|
1111 |
+
declare const valueValidator: _sapphire_shapeshift.StringValidator<string>;
|
1112 |
+
declare const placeholderValidator: _sapphire_shapeshift.StringValidator<string>;
|
1113 |
+
declare const labelValidator: _sapphire_shapeshift.StringValidator<string>;
|
1114 |
+
declare function validateRequiredParameters$3(customId?: string, style?: TextInputStyle, label?: string): void;
|
1115 |
+
|
1116 |
+
declare const Assertions$3_labelValidator: typeof labelValidator;
|
1117 |
+
declare const Assertions$3_maxLengthValidator: typeof maxLengthValidator;
|
1118 |
+
declare const Assertions$3_minLengthValidator: typeof minLengthValidator;
|
1119 |
+
declare const Assertions$3_placeholderValidator: typeof placeholderValidator;
|
1120 |
+
declare const Assertions$3_requiredValidator: typeof requiredValidator;
|
1121 |
+
declare const Assertions$3_textInputStyleValidator: typeof textInputStyleValidator;
|
1122 |
+
declare const Assertions$3_valueValidator: typeof valueValidator;
|
1123 |
+
declare namespace Assertions$3 {
|
1124 |
+
export {
|
1125 |
+
Assertions$3_labelValidator as labelValidator,
|
1126 |
+
Assertions$3_maxLengthValidator as maxLengthValidator,
|
1127 |
+
Assertions$3_minLengthValidator as minLengthValidator,
|
1128 |
+
Assertions$3_placeholderValidator as placeholderValidator,
|
1129 |
+
Assertions$3_requiredValidator as requiredValidator,
|
1130 |
+
Assertions$3_textInputStyleValidator as textInputStyleValidator,
|
1131 |
+
validateRequiredParameters$3 as validateRequiredParameters,
|
1132 |
+
Assertions$3_valueValidator as valueValidator,
|
1133 |
+
};
|
1134 |
+
}
|
1135 |
+
|
1136 |
+
/**
|
1137 |
+
* A builder that creates API-compatible JSON data for modals.
|
1138 |
+
*/
|
1139 |
+
declare class ModalBuilder implements JSONEncodable<APIModalInteractionResponseCallbackData> {
|
1140 |
+
/**
|
1141 |
+
* The API data associated with this modal.
|
1142 |
+
*/
|
1143 |
+
readonly data: Partial<APIModalInteractionResponseCallbackData>;
|
1144 |
+
/**
|
1145 |
+
* The components within this modal.
|
1146 |
+
*/
|
1147 |
+
readonly components: ActionRowBuilder<ModalActionRowComponentBuilder>[];
|
1148 |
+
/**
|
1149 |
+
* Creates a new modal from API data.
|
1150 |
+
*
|
1151 |
+
* @param data - The API data to create this modal with
|
1152 |
+
*/
|
1153 |
+
constructor({ components, ...data }?: Partial<APIModalInteractionResponseCallbackData>);
|
1154 |
+
/**
|
1155 |
+
* Sets the title of this modal.
|
1156 |
+
*
|
1157 |
+
* @param title - The title to use
|
1158 |
+
*/
|
1159 |
+
setTitle(title: string): this;
|
1160 |
+
/**
|
1161 |
+
* Sets the custom id of this modal.
|
1162 |
+
*
|
1163 |
+
* @param customId - The custom id to use
|
1164 |
+
*/
|
1165 |
+
setCustomId(customId: string): this;
|
1166 |
+
/**
|
1167 |
+
* Adds components to this modal.
|
1168 |
+
*
|
1169 |
+
* @param components - The components to add
|
1170 |
+
*/
|
1171 |
+
addComponents(...components: RestOrArray<ActionRowBuilder<ModalActionRowComponentBuilder> | APIActionRowComponent<APIModalActionRowComponent>>): this;
|
1172 |
+
/**
|
1173 |
+
* Sets components for this modal.
|
1174 |
+
*
|
1175 |
+
* @param components - The components to set
|
1176 |
+
*/
|
1177 |
+
setComponents(...components: RestOrArray<ActionRowBuilder<ModalActionRowComponentBuilder>>): this;
|
1178 |
+
/**
|
1179 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
1180 |
+
*/
|
1181 |
+
toJSON(): APIModalInteractionResponseCallbackData;
|
1182 |
+
}
|
1183 |
+
|
1184 |
+
declare const titleValidator: _sapphire_shapeshift.StringValidator<string>;
|
1185 |
+
declare const componentsValidator: _sapphire_shapeshift.ArrayValidator<[ActionRowBuilder<AnyComponentBuilder>, ...ActionRowBuilder<AnyComponentBuilder>[]], ActionRowBuilder<AnyComponentBuilder>>;
|
1186 |
+
declare function validateRequiredParameters$2(customId?: string, title?: string, components?: ActionRowBuilder<ModalActionRowComponentBuilder>[]): void;
|
1187 |
+
|
1188 |
+
declare const Assertions$2_componentsValidator: typeof componentsValidator;
|
1189 |
+
declare const Assertions$2_titleValidator: typeof titleValidator;
|
1190 |
+
declare namespace Assertions$2 {
|
1191 |
+
export {
|
1192 |
+
Assertions$2_componentsValidator as componentsValidator,
|
1193 |
+
Assertions$2_titleValidator as titleValidator,
|
1194 |
+
validateRequiredParameters$2 as validateRequiredParameters,
|
1195 |
+
};
|
1196 |
+
}
|
1197 |
+
|
1198 |
+
/**
|
1199 |
+
* This mixin holds name and description symbols for slash commands.
|
1200 |
+
*/
|
1201 |
+
declare class SharedNameAndDescription {
|
1202 |
+
/**
|
1203 |
+
* The name of this command.
|
1204 |
+
*/
|
1205 |
+
readonly name: string;
|
1206 |
+
/**
|
1207 |
+
* The name localizations of this command.
|
1208 |
+
*/
|
1209 |
+
readonly name_localizations?: LocalizationMap;
|
1210 |
+
/**
|
1211 |
+
* The description of this command.
|
1212 |
+
*/
|
1213 |
+
readonly description: string;
|
1214 |
+
/**
|
1215 |
+
* The description localizations of this command.
|
1216 |
+
*/
|
1217 |
+
readonly description_localizations?: LocalizationMap;
|
1218 |
+
/**
|
1219 |
+
* Sets the name of this command.
|
1220 |
+
*
|
1221 |
+
* @param name - The name to use
|
1222 |
+
*/
|
1223 |
+
setName(name: string): this;
|
1224 |
+
/**
|
1225 |
+
* Sets the description of this command.
|
1226 |
+
*
|
1227 |
+
* @param description - The description to use
|
1228 |
+
*/
|
1229 |
+
setDescription(description: string): this;
|
1230 |
+
/**
|
1231 |
+
* Sets a name localization for this command.
|
1232 |
+
*
|
1233 |
+
* @param locale - The locale to set
|
1234 |
+
* @param localizedName - The localized name for the given `locale`
|
1235 |
+
*/
|
1236 |
+
setNameLocalization(locale: LocaleString, localizedName: string | null): this;
|
1237 |
+
/**
|
1238 |
+
* Sets the name localizations for this command.
|
1239 |
+
*
|
1240 |
+
* @param localizedNames - The object of localized names to set
|
1241 |
+
*/
|
1242 |
+
setNameLocalizations(localizedNames: LocalizationMap | null): this;
|
1243 |
+
/**
|
1244 |
+
* Sets a description localization for this command.
|
1245 |
+
*
|
1246 |
+
* @param locale - The locale to set
|
1247 |
+
* @param localizedDescription - The localized description for the given locale
|
1248 |
+
*/
|
1249 |
+
setDescriptionLocalization(locale: LocaleString, localizedDescription: string | null): this;
|
1250 |
+
/**
|
1251 |
+
* Sets the description localizations for this command.
|
1252 |
+
*
|
1253 |
+
* @param localizedDescriptions - The object of localized descriptions to set
|
1254 |
+
*/
|
1255 |
+
setDescriptionLocalizations(localizedDescriptions: LocalizationMap | null): this;
|
1256 |
+
}
|
1257 |
+
|
1258 |
+
/**
|
1259 |
+
* The base application command option builder that contains common symbols for application command builders.
|
1260 |
+
*/
|
1261 |
+
declare abstract class ApplicationCommandOptionBase extends SharedNameAndDescription {
|
1262 |
+
/**
|
1263 |
+
* The type of this option.
|
1264 |
+
*/
|
1265 |
+
abstract readonly type: ApplicationCommandOptionType;
|
1266 |
+
/**
|
1267 |
+
* Whether this option is required.
|
1268 |
+
*
|
1269 |
+
* @defaultValue `false`
|
1270 |
+
*/
|
1271 |
+
readonly required: boolean;
|
1272 |
+
/**
|
1273 |
+
* Sets whether this option is required.
|
1274 |
+
*
|
1275 |
+
* @param required - Whether this option should be required
|
1276 |
+
*/
|
1277 |
+
setRequired(required: boolean): this;
|
1278 |
+
/**
|
1279 |
+
* Serializes this builder to API-compatible JSON data.
|
1280 |
+
*
|
1281 |
+
* @remarks
|
1282 |
+
* This method runs validations on the data before serializing it.
|
1283 |
+
* As such, it may throw an error if the data is invalid.
|
1284 |
+
*/
|
1285 |
+
abstract toJSON(): APIApplicationCommandBasicOption;
|
1286 |
+
/**
|
1287 |
+
* This method runs required validators on this builder.
|
1288 |
+
*/
|
1289 |
+
protected runRequiredValidations(): void;
|
1290 |
+
}
|
1291 |
+
|
1292 |
+
/**
|
1293 |
+
* A slash command attachment option.
|
1294 |
+
*/
|
1295 |
+
declare class SlashCommandAttachmentOption extends ApplicationCommandOptionBase {
|
1296 |
+
/**
|
1297 |
+
* The type of this option.
|
1298 |
+
*/
|
1299 |
+
readonly type: ApplicationCommandOptionType.Attachment;
|
1300 |
+
/**
|
1301 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1302 |
+
*/
|
1303 |
+
toJSON(): APIApplicationCommandAttachmentOption;
|
1304 |
+
}
|
1305 |
+
|
1306 |
+
/**
|
1307 |
+
* A slash command boolean option.
|
1308 |
+
*/
|
1309 |
+
declare class SlashCommandBooleanOption extends ApplicationCommandOptionBase {
|
1310 |
+
/**
|
1311 |
+
* The type of this option.
|
1312 |
+
*/
|
1313 |
+
readonly type: ApplicationCommandOptionType.Boolean;
|
1314 |
+
/**
|
1315 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1316 |
+
*/
|
1317 |
+
toJSON(): APIApplicationCommandBooleanOption;
|
1318 |
+
}
|
1319 |
+
|
1320 |
+
/**
|
1321 |
+
* The allowed channel types used for a channel option in a slash command builder.
|
1322 |
+
*
|
1323 |
+
* @privateRemarks This can't be dynamic because const enums are erased at runtime.
|
1324 |
+
* @internal
|
1325 |
+
*/
|
1326 |
+
declare const allowedChannelTypes: readonly [ChannelType.GuildText, ChannelType.GuildVoice, ChannelType.GuildCategory, ChannelType.GuildAnnouncement, ChannelType.AnnouncementThread, ChannelType.PublicThread, ChannelType.PrivateThread, ChannelType.GuildStageVoice, ChannelType.GuildForum, ChannelType.GuildMedia];
|
1327 |
+
/**
|
1328 |
+
* The type of allowed channel types used for a channel option.
|
1329 |
+
*/
|
1330 |
+
type ApplicationCommandOptionAllowedChannelTypes = (typeof allowedChannelTypes)[number];
|
1331 |
+
/**
|
1332 |
+
* This mixin holds channel type symbols used for options.
|
1333 |
+
*/
|
1334 |
+
declare class ApplicationCommandOptionChannelTypesMixin {
|
1335 |
+
/**
|
1336 |
+
* The channel types of this option.
|
1337 |
+
*/
|
1338 |
+
readonly channel_types?: ApplicationCommandOptionAllowedChannelTypes[];
|
1339 |
+
/**
|
1340 |
+
* Adds channel types to this option.
|
1341 |
+
*
|
1342 |
+
* @param channelTypes - The channel types
|
1343 |
+
*/
|
1344 |
+
addChannelTypes(...channelTypes: ApplicationCommandOptionAllowedChannelTypes[]): this;
|
1345 |
+
}
|
1346 |
+
|
1347 |
+
/**
|
1348 |
+
* A slash command channel option.
|
1349 |
+
*/
|
1350 |
+
declare class SlashCommandChannelOption extends ApplicationCommandOptionBase {
|
1351 |
+
/**
|
1352 |
+
* The type of this option.
|
1353 |
+
*/
|
1354 |
+
readonly type: ApplicationCommandOptionType.Channel;
|
1355 |
+
/**
|
1356 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1357 |
+
*/
|
1358 |
+
toJSON(): APIApplicationCommandChannelOption;
|
1359 |
+
}
|
1360 |
+
interface SlashCommandChannelOption extends ApplicationCommandOptionChannelTypesMixin {
|
1361 |
+
}
|
1362 |
+
|
1363 |
+
/**
|
1364 |
+
* This mixin holds minimum and maximum symbols used for options.
|
1365 |
+
*/
|
1366 |
+
declare abstract class ApplicationCommandNumericOptionMinMaxValueMixin {
|
1367 |
+
/**
|
1368 |
+
* The maximum value of this option.
|
1369 |
+
*/
|
1370 |
+
readonly max_value?: number;
|
1371 |
+
/**
|
1372 |
+
* The minimum value of this option.
|
1373 |
+
*/
|
1374 |
+
readonly min_value?: number;
|
1375 |
+
/**
|
1376 |
+
* Sets the maximum number value of this option.
|
1377 |
+
*
|
1378 |
+
* @param max - The maximum value this option can be
|
1379 |
+
*/
|
1380 |
+
abstract setMaxValue(max: number): this;
|
1381 |
+
/**
|
1382 |
+
* Sets the minimum number value of this option.
|
1383 |
+
*
|
1384 |
+
* @param min - The minimum value this option can be
|
1385 |
+
*/
|
1386 |
+
abstract setMinValue(min: number): this;
|
1387 |
+
}
|
1388 |
+
|
1389 |
+
/**
|
1390 |
+
* This mixin holds choices and autocomplete symbols used for options.
|
1391 |
+
*/
|
1392 |
+
declare class ApplicationCommandOptionWithChoicesAndAutocompleteMixin<ChoiceType extends number | string> {
|
1393 |
+
/**
|
1394 |
+
* The choices of this option.
|
1395 |
+
*/
|
1396 |
+
readonly choices?: APIApplicationCommandOptionChoice<ChoiceType>[];
|
1397 |
+
/**
|
1398 |
+
* Whether this option utilizes autocomplete.
|
1399 |
+
*/
|
1400 |
+
readonly autocomplete?: boolean;
|
1401 |
+
/**
|
1402 |
+
* The type of this option.
|
1403 |
+
*
|
1404 |
+
* @privateRemarks Since this is present and this is a mixin, this is needed.
|
1405 |
+
*/
|
1406 |
+
readonly type: ApplicationCommandOptionType;
|
1407 |
+
/**
|
1408 |
+
* Adds multiple choices to this option.
|
1409 |
+
*
|
1410 |
+
* @param choices - The choices to add
|
1411 |
+
*/
|
1412 |
+
addChoices(...choices: APIApplicationCommandOptionChoice<ChoiceType>[]): this;
|
1413 |
+
/**
|
1414 |
+
* Sets multiple choices for this option.
|
1415 |
+
*
|
1416 |
+
* @param choices - The choices to set
|
1417 |
+
*/
|
1418 |
+
setChoices<Input extends APIApplicationCommandOptionChoice<ChoiceType>[]>(...choices: Input): this;
|
1419 |
+
/**
|
1420 |
+
* Whether this option uses autocomplete.
|
1421 |
+
*
|
1422 |
+
* @param autocomplete - Whether this option should use autocomplete
|
1423 |
+
*/
|
1424 |
+
setAutocomplete(autocomplete: boolean): this;
|
1425 |
+
}
|
1426 |
+
|
1427 |
+
/**
|
1428 |
+
* A slash command integer option.
|
1429 |
+
*/
|
1430 |
+
declare class SlashCommandIntegerOption extends ApplicationCommandOptionBase implements ApplicationCommandNumericOptionMinMaxValueMixin {
|
1431 |
+
/**
|
1432 |
+
* The type of this option.
|
1433 |
+
*/
|
1434 |
+
readonly type: ApplicationCommandOptionType.Integer;
|
1435 |
+
/**
|
1436 |
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}
|
1437 |
+
*/
|
1438 |
+
setMaxValue(max: number): this;
|
1439 |
+
/**
|
1440 |
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMinValue}
|
1441 |
+
*/
|
1442 |
+
setMinValue(min: number): this;
|
1443 |
+
/**
|
1444 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1445 |
+
*/
|
1446 |
+
toJSON(): APIApplicationCommandIntegerOption;
|
1447 |
+
}
|
1448 |
+
interface SlashCommandIntegerOption extends ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin<number> {
|
1449 |
+
}
|
1450 |
+
|
1451 |
+
/**
|
1452 |
+
* A slash command mentionable option.
|
1453 |
+
*/
|
1454 |
+
declare class SlashCommandMentionableOption extends ApplicationCommandOptionBase {
|
1455 |
+
/**
|
1456 |
+
* The type of this option.
|
1457 |
+
*/
|
1458 |
+
readonly type: ApplicationCommandOptionType.Mentionable;
|
1459 |
+
/**
|
1460 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1461 |
+
*/
|
1462 |
+
toJSON(): APIApplicationCommandMentionableOption;
|
1463 |
+
}
|
1464 |
+
|
1465 |
+
/**
|
1466 |
+
* A slash command number option.
|
1467 |
+
*/
|
1468 |
+
declare class SlashCommandNumberOption extends ApplicationCommandOptionBase implements ApplicationCommandNumericOptionMinMaxValueMixin {
|
1469 |
+
/**
|
1470 |
+
* The type of this option.
|
1471 |
+
*/
|
1472 |
+
readonly type: ApplicationCommandOptionType.Number;
|
1473 |
+
/**
|
1474 |
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}
|
1475 |
+
*/
|
1476 |
+
setMaxValue(max: number): this;
|
1477 |
+
/**
|
1478 |
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMinValue}
|
1479 |
+
*/
|
1480 |
+
setMinValue(min: number): this;
|
1481 |
+
/**
|
1482 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1483 |
+
*/
|
1484 |
+
toJSON(): APIApplicationCommandNumberOption;
|
1485 |
+
}
|
1486 |
+
interface SlashCommandNumberOption extends ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin<number> {
|
1487 |
+
}
|
1488 |
+
|
1489 |
+
/**
|
1490 |
+
* A slash command role option.
|
1491 |
+
*/
|
1492 |
+
declare class SlashCommandRoleOption extends ApplicationCommandOptionBase {
|
1493 |
+
/**
|
1494 |
+
* The type of this option.
|
1495 |
+
*/
|
1496 |
+
readonly type: ApplicationCommandOptionType.Role;
|
1497 |
+
/**
|
1498 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1499 |
+
*/
|
1500 |
+
toJSON(): APIApplicationCommandRoleOption;
|
1501 |
+
}
|
1502 |
+
|
1503 |
+
/**
|
1504 |
+
* A slash command string option.
|
1505 |
+
*/
|
1506 |
+
declare class SlashCommandStringOption extends ApplicationCommandOptionBase {
|
1507 |
+
/**
|
1508 |
+
* The type of this option.
|
1509 |
+
*/
|
1510 |
+
readonly type: ApplicationCommandOptionType.String;
|
1511 |
+
/**
|
1512 |
+
* The maximum length of this option.
|
1513 |
+
*/
|
1514 |
+
readonly max_length?: number;
|
1515 |
+
/**
|
1516 |
+
* The minimum length of this option.
|
1517 |
+
*/
|
1518 |
+
readonly min_length?: number;
|
1519 |
+
/**
|
1520 |
+
* Sets the maximum length of this string option.
|
1521 |
+
*
|
1522 |
+
* @param max - The maximum length this option can be
|
1523 |
+
*/
|
1524 |
+
setMaxLength(max: number): this;
|
1525 |
+
/**
|
1526 |
+
* Sets the minimum length of this string option.
|
1527 |
+
*
|
1528 |
+
* @param min - The minimum length this option can be
|
1529 |
+
*/
|
1530 |
+
setMinLength(min: number): this;
|
1531 |
+
/**
|
1532 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1533 |
+
*/
|
1534 |
+
toJSON(): APIApplicationCommandStringOption;
|
1535 |
+
}
|
1536 |
+
interface SlashCommandStringOption extends ApplicationCommandOptionWithChoicesAndAutocompleteMixin<string> {
|
1537 |
+
}
|
1538 |
+
|
1539 |
+
/**
|
1540 |
+
* A slash command user option.
|
1541 |
+
*/
|
1542 |
+
declare class SlashCommandUserOption extends ApplicationCommandOptionBase {
|
1543 |
+
/**
|
1544 |
+
* The type of this option.
|
1545 |
+
*/
|
1546 |
+
readonly type: ApplicationCommandOptionType.User;
|
1547 |
+
/**
|
1548 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1549 |
+
*/
|
1550 |
+
toJSON(): APIApplicationCommandUserOption;
|
1551 |
+
}
|
1552 |
+
|
1553 |
+
/**
|
1554 |
+
* This mixin holds symbols that can be shared in slash command options.
|
1555 |
+
*
|
1556 |
+
* @typeParam ShouldOmitSubcommandFunctions - Whether to omit subcommand functions.
|
1557 |
+
*/
|
1558 |
+
declare class SharedSlashCommandOptions<ShouldOmitSubcommandFunctions = true> {
|
1559 |
+
readonly options: ToAPIApplicationCommandOptions[];
|
1560 |
+
/**
|
1561 |
+
* Adds a boolean option.
|
1562 |
+
*
|
1563 |
+
* @param input - A function that returns an option builder or an already built builder
|
1564 |
+
*/
|
1565 |
+
addBooleanOption(input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
|
1566 |
+
/**
|
1567 |
+
* Adds a user option.
|
1568 |
+
*
|
1569 |
+
* @param input - A function that returns an option builder or an already built builder
|
1570 |
+
*/
|
1571 |
+
addUserOption(input: SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
|
1572 |
+
/**
|
1573 |
+
* Adds a channel option.
|
1574 |
+
*
|
1575 |
+
* @param input - A function that returns an option builder or an already built builder
|
1576 |
+
*/
|
1577 |
+
addChannelOption(input: SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
|
1578 |
+
/**
|
1579 |
+
* Adds a role option.
|
1580 |
+
*
|
1581 |
+
* @param input - A function that returns an option builder or an already built builder
|
1582 |
+
*/
|
1583 |
+
addRoleOption(input: SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
|
1584 |
+
/**
|
1585 |
+
* Adds an attachment option.
|
1586 |
+
*
|
1587 |
+
* @param input - A function that returns an option builder or an already built builder
|
1588 |
+
*/
|
1589 |
+
addAttachmentOption(input: SlashCommandAttachmentOption | ((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
|
1590 |
+
/**
|
1591 |
+
* Adds a mentionable option.
|
1592 |
+
*
|
1593 |
+
* @param input - A function that returns an option builder or an already built builder
|
1594 |
+
*/
|
1595 |
+
addMentionableOption(input: SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
|
1596 |
+
/**
|
1597 |
+
* Adds a string option.
|
1598 |
+
*
|
1599 |
+
* @param input - A function that returns an option builder or an already built builder
|
1600 |
+
*/
|
1601 |
+
addStringOption(input: Omit<SlashCommandStringOption, 'addChoices'> | Omit<SlashCommandStringOption, 'setAutocomplete'> | SlashCommandStringOption | ((builder: SlashCommandStringOption) => Omit<SlashCommandStringOption, 'addChoices'> | Omit<SlashCommandStringOption, 'setAutocomplete'> | SlashCommandStringOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
|
1602 |
+
/**
|
1603 |
+
* Adds an integer option.
|
1604 |
+
*
|
1605 |
+
* @param input - A function that returns an option builder or an already built builder
|
1606 |
+
*/
|
1607 |
+
addIntegerOption(input: Omit<SlashCommandIntegerOption, 'addChoices'> | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | SlashCommandIntegerOption | ((builder: SlashCommandIntegerOption) => Omit<SlashCommandIntegerOption, 'addChoices'> | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | SlashCommandIntegerOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
|
1608 |
+
/**
|
1609 |
+
* Adds a number option.
|
1610 |
+
*
|
1611 |
+
* @param input - A function that returns an option builder or an already built builder
|
1612 |
+
*/
|
1613 |
+
addNumberOption(input: Omit<SlashCommandNumberOption, 'addChoices'> | Omit<SlashCommandNumberOption, 'setAutocomplete'> | SlashCommandNumberOption | ((builder: SlashCommandNumberOption) => Omit<SlashCommandNumberOption, 'addChoices'> | Omit<SlashCommandNumberOption, 'setAutocomplete'> | SlashCommandNumberOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
|
1614 |
+
/**
|
1615 |
+
* Where the actual adding magic happens. ✨
|
1616 |
+
*
|
1617 |
+
* @param input - The input. What else?
|
1618 |
+
* @param Instance - The instance of whatever is being added
|
1619 |
+
* @internal
|
1620 |
+
*/
|
1621 |
+
private _sharedAddOptionMethod;
|
1622 |
+
}
|
1623 |
+
|
1624 |
+
/**
|
1625 |
+
* Represents a folder for subcommands.
|
1626 |
+
*
|
1627 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups}
|
1628 |
+
*/
|
1629 |
+
declare class SlashCommandSubcommandGroupBuilder implements ToAPIApplicationCommandOptions {
|
1630 |
+
/**
|
1631 |
+
* The name of this subcommand group.
|
1632 |
+
*/
|
1633 |
+
readonly name: string;
|
1634 |
+
/**
|
1635 |
+
* The description of this subcommand group.
|
1636 |
+
*/
|
1637 |
+
readonly description: string;
|
1638 |
+
/**
|
1639 |
+
* The subcommands within this subcommand group.
|
1640 |
+
*/
|
1641 |
+
readonly options: SlashCommandSubcommandBuilder[];
|
1642 |
+
/**
|
1643 |
+
* Adds a new subcommand to this group.
|
1644 |
+
*
|
1645 |
+
* @param input - A function that returns a subcommand builder or an already built builder
|
1646 |
+
*/
|
1647 |
+
addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): this;
|
1648 |
+
/**
|
1649 |
+
* Serializes this builder to API-compatible JSON data.
|
1650 |
+
*
|
1651 |
+
* @remarks
|
1652 |
+
* This method runs validations on the data before serializing it.
|
1653 |
+
* As such, it may throw an error if the data is invalid.
|
1654 |
+
*/
|
1655 |
+
toJSON(): APIApplicationCommandSubcommandGroupOption;
|
1656 |
+
}
|
1657 |
+
interface SlashCommandSubcommandGroupBuilder extends SharedNameAndDescription {
|
1658 |
+
}
|
1659 |
+
/**
|
1660 |
+
* A builder that creates API-compatible JSON data for slash command subcommands.
|
1661 |
+
*
|
1662 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups}
|
1663 |
+
*/
|
1664 |
+
declare class SlashCommandSubcommandBuilder implements ToAPIApplicationCommandOptions {
|
1665 |
+
/**
|
1666 |
+
* The name of this subcommand.
|
1667 |
+
*/
|
1668 |
+
readonly name: string;
|
1669 |
+
/**
|
1670 |
+
* The description of this subcommand.
|
1671 |
+
*/
|
1672 |
+
readonly description: string;
|
1673 |
+
/**
|
1674 |
+
* The options within this subcommand.
|
1675 |
+
*/
|
1676 |
+
readonly options: ApplicationCommandOptionBase[];
|
1677 |
+
/**
|
1678 |
+
* Serializes this builder to API-compatible JSON data.
|
1679 |
+
*
|
1680 |
+
* @remarks
|
1681 |
+
* This method runs validations on the data before serializing it.
|
1682 |
+
* As such, it may throw an error if the data is invalid.
|
1683 |
+
*/
|
1684 |
+
toJSON(): APIApplicationCommandSubcommandOption;
|
1685 |
+
}
|
1686 |
+
interface SlashCommandSubcommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions<false> {
|
1687 |
+
}
|
1688 |
+
|
1689 |
+
/**
|
1690 |
+
* A builder that creates API-compatible JSON data for slash commands.
|
1691 |
+
*/
|
1692 |
+
declare class SlashCommandBuilder {
|
1693 |
+
/**
|
1694 |
+
* The name of this command.
|
1695 |
+
*/
|
1696 |
+
readonly name: string;
|
1697 |
+
/**
|
1698 |
+
* The name localizations of this command.
|
1699 |
+
*/
|
1700 |
+
readonly name_localizations?: LocalizationMap;
|
1701 |
+
/**
|
1702 |
+
* The description of this command.
|
1703 |
+
*/
|
1704 |
+
readonly description: string;
|
1705 |
+
/**
|
1706 |
+
* The description localizations of this command.
|
1707 |
+
*/
|
1708 |
+
readonly description_localizations?: LocalizationMap;
|
1709 |
+
/**
|
1710 |
+
* The options of this command.
|
1711 |
+
*/
|
1712 |
+
readonly options: ToAPIApplicationCommandOptions[];
|
1713 |
+
/**
|
1714 |
+
* Whether this command is enabled by default when the application is added to a guild.
|
1715 |
+
*
|
1716 |
+
* @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
|
1717 |
+
*/
|
1718 |
+
readonly default_permission: boolean | undefined;
|
1719 |
+
/**
|
1720 |
+
* The set of permissions represented as a bit set for the command.
|
1721 |
+
*/
|
1722 |
+
readonly default_member_permissions: Permissions | null | undefined;
|
1723 |
+
/**
|
1724 |
+
* Indicates whether the command is available in direct messages with the application.
|
1725 |
+
*
|
1726 |
+
* @remarks
|
1727 |
+
* By default, commands are visible. This property is only for global commands.
|
1728 |
+
*/
|
1729 |
+
readonly dm_permission: boolean | undefined;
|
1730 |
+
/**
|
1731 |
+
* Whether this command is NSFW.
|
1732 |
+
*/
|
1733 |
+
readonly nsfw: boolean | undefined;
|
1734 |
+
/**
|
1735 |
+
* Sets whether the command is enabled by default when the application is added to a guild.
|
1736 |
+
*
|
1737 |
+
* @remarks
|
1738 |
+
* If set to `false`, you will have to later `PUT` the permissions for this command.
|
1739 |
+
* @param value - Whether or not to enable this command by default
|
1740 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
1741 |
+
* @deprecated Use {@link SlashCommandBuilder.setDefaultMemberPermissions} or {@link SlashCommandBuilder.setDMPermission} instead.
|
1742 |
+
*/
|
1743 |
+
setDefaultPermission(value: boolean): this;
|
1744 |
+
/**
|
1745 |
+
* Sets the default permissions a member should have in order to run the command.
|
1746 |
+
*
|
1747 |
+
* @remarks
|
1748 |
+
* You can set this to `'0'` to disable the command by default.
|
1749 |
+
* @param permissions - The permissions bit field to set
|
1750 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
1751 |
+
*/
|
1752 |
+
setDefaultMemberPermissions(permissions: Permissions | bigint | number | null | undefined): this;
|
1753 |
+
/**
|
1754 |
+
* Sets if the command is available in direct messages with the application.
|
1755 |
+
*
|
1756 |
+
* @remarks
|
1757 |
+
* By default, commands are visible. This method is only for global commands.
|
1758 |
+
* @param enabled - Whether the command should be enabled in direct messages
|
1759 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
1760 |
+
*/
|
1761 |
+
setDMPermission(enabled: boolean | null | undefined): this;
|
1762 |
+
/**
|
1763 |
+
* Sets whether this command is NSFW.
|
1764 |
+
*
|
1765 |
+
* @param nsfw - Whether this command is NSFW
|
1766 |
+
*/
|
1767 |
+
setNSFW(nsfw?: boolean): this;
|
1768 |
+
/**
|
1769 |
+
* Adds a new subcommand group to this command.
|
1770 |
+
*
|
1771 |
+
* @param input - A function that returns a subcommand group builder or an already built builder
|
1772 |
+
*/
|
1773 |
+
addSubcommandGroup(input: SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)): SlashCommandSubcommandsOnlyBuilder;
|
1774 |
+
/**
|
1775 |
+
* Adds a new subcommand to this command.
|
1776 |
+
*
|
1777 |
+
* @param input - A function that returns a subcommand builder or an already built builder
|
1778 |
+
*/
|
1779 |
+
addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): SlashCommandSubcommandsOnlyBuilder;
|
1780 |
+
/**
|
1781 |
+
* Serializes this builder to API-compatible JSON data.
|
1782 |
+
*
|
1783 |
+
* @remarks
|
1784 |
+
* This method runs validations on the data before serializing it.
|
1785 |
+
* As such, it may throw an error if the data is invalid.
|
1786 |
+
*/
|
1787 |
+
toJSON(): RESTPostAPIChatInputApplicationCommandsJSONBody;
|
1788 |
+
}
|
1789 |
+
interface SlashCommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions {
|
1790 |
+
}
|
1791 |
+
/**
|
1792 |
+
* An interface specifically for slash command subcommands.
|
1793 |
+
*/
|
1794 |
+
interface SlashCommandSubcommandsOnlyBuilder extends Omit<SlashCommandBuilder, Exclude<keyof SharedSlashCommandOptions, 'options'>> {
|
1795 |
+
}
|
1796 |
+
/**
|
1797 |
+
* An interface specifically for slash command options.
|
1798 |
+
*/
|
1799 |
+
interface SlashCommandOptionsOnlyBuilder extends SharedNameAndDescription, SharedSlashCommandOptions, Pick<SlashCommandBuilder, 'toJSON'> {
|
1800 |
+
}
|
1801 |
+
/**
|
1802 |
+
* An interface that ensures the `toJSON()` call will return something
|
1803 |
+
* that can be serialized into API-compatible data.
|
1804 |
+
*/
|
1805 |
+
interface ToAPIApplicationCommandOptions {
|
1806 |
+
toJSON(): APIApplicationCommandOption;
|
1807 |
+
}
|
1808 |
+
|
1809 |
+
declare function validateName$1(name: unknown): asserts name is string;
|
1810 |
+
declare function validateDescription(description: unknown): asserts description is string;
|
1811 |
+
declare function validateLocale(locale: unknown): Locale;
|
1812 |
+
declare function validateMaxOptionsLength(options: unknown): asserts options is ToAPIApplicationCommandOptions[];
|
1813 |
+
declare function validateRequiredParameters$1(name: string, description: string, options: ToAPIApplicationCommandOptions[]): void;
|
1814 |
+
declare function validateDefaultPermission$1(value: unknown): asserts value is boolean;
|
1815 |
+
declare function validateRequired(required: unknown): asserts required is boolean;
|
1816 |
+
declare function validateChoicesLength(amountAdding: number, choices?: APIApplicationCommandOptionChoice[]): void;
|
1817 |
+
declare function assertReturnOfBuilder<ReturnType extends ApplicationCommandOptionBase | SlashCommandSubcommandBuilder | SlashCommandSubcommandGroupBuilder>(input: unknown, ExpectedInstanceOf: new () => ReturnType): asserts input is ReturnType;
|
1818 |
+
declare const localizationMapPredicate: _sapphire_shapeshift.UnionValidator<_sapphire_shapeshift.UndefinedToOptional<Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "sv-SE" | "th" | "tr" | "uk" | "vi", string | null>>> | null | undefined>;
|
1819 |
+
declare function validateLocalizationMap(value: unknown): asserts value is LocalizationMap;
|
1820 |
+
declare function validateDMPermission$1(value: unknown): asserts value is boolean | null | undefined;
|
1821 |
+
declare function validateDefaultMemberPermissions$1(permissions: unknown): string | null | undefined;
|
1822 |
+
declare function validateNSFW(value: unknown): asserts value is boolean;
|
1823 |
+
|
1824 |
+
declare const Assertions$1_assertReturnOfBuilder: typeof assertReturnOfBuilder;
|
1825 |
+
declare const Assertions$1_localizationMapPredicate: typeof localizationMapPredicate;
|
1826 |
+
declare const Assertions$1_validateChoicesLength: typeof validateChoicesLength;
|
1827 |
+
declare const Assertions$1_validateDescription: typeof validateDescription;
|
1828 |
+
declare const Assertions$1_validateLocale: typeof validateLocale;
|
1829 |
+
declare const Assertions$1_validateLocalizationMap: typeof validateLocalizationMap;
|
1830 |
+
declare const Assertions$1_validateMaxOptionsLength: typeof validateMaxOptionsLength;
|
1831 |
+
declare const Assertions$1_validateNSFW: typeof validateNSFW;
|
1832 |
+
declare const Assertions$1_validateRequired: typeof validateRequired;
|
1833 |
+
declare namespace Assertions$1 {
|
1834 |
+
export {
|
1835 |
+
Assertions$1_assertReturnOfBuilder as assertReturnOfBuilder,
|
1836 |
+
Assertions$1_localizationMapPredicate as localizationMapPredicate,
|
1837 |
+
Assertions$1_validateChoicesLength as validateChoicesLength,
|
1838 |
+
validateDMPermission$1 as validateDMPermission,
|
1839 |
+
validateDefaultMemberPermissions$1 as validateDefaultMemberPermissions,
|
1840 |
+
validateDefaultPermission$1 as validateDefaultPermission,
|
1841 |
+
Assertions$1_validateDescription as validateDescription,
|
1842 |
+
Assertions$1_validateLocale as validateLocale,
|
1843 |
+
Assertions$1_validateLocalizationMap as validateLocalizationMap,
|
1844 |
+
Assertions$1_validateMaxOptionsLength as validateMaxOptionsLength,
|
1845 |
+
Assertions$1_validateNSFW as validateNSFW,
|
1846 |
+
validateName$1 as validateName,
|
1847 |
+
Assertions$1_validateRequired as validateRequired,
|
1848 |
+
validateRequiredParameters$1 as validateRequiredParameters,
|
1849 |
+
};
|
1850 |
+
}
|
1851 |
+
|
1852 |
+
/**
|
1853 |
+
* The type a context menu command can be.
|
1854 |
+
*/
|
1855 |
+
type ContextMenuCommandType = ApplicationCommandType.Message | ApplicationCommandType.User;
|
1856 |
+
/**
|
1857 |
+
* A builder that creates API-compatible JSON data for context menu commands.
|
1858 |
+
*/
|
1859 |
+
declare class ContextMenuCommandBuilder {
|
1860 |
+
/**
|
1861 |
+
* The name of this command.
|
1862 |
+
*/
|
1863 |
+
readonly name: string;
|
1864 |
+
/**
|
1865 |
+
* The name localizations of this command.
|
1866 |
+
*/
|
1867 |
+
readonly name_localizations?: LocalizationMap;
|
1868 |
+
/**
|
1869 |
+
* The type of this command.
|
1870 |
+
*/
|
1871 |
+
readonly type: ContextMenuCommandType;
|
1872 |
+
/**
|
1873 |
+
* Whether this command is enabled by default when the application is added to a guild.
|
1874 |
+
*
|
1875 |
+
* @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
|
1876 |
+
*/
|
1877 |
+
readonly default_permission: boolean | undefined;
|
1878 |
+
/**
|
1879 |
+
* The set of permissions represented as a bit set for the command.
|
1880 |
+
*/
|
1881 |
+
readonly default_member_permissions: Permissions | null | undefined;
|
1882 |
+
/**
|
1883 |
+
* Indicates whether the command is available in direct messages with the application.
|
1884 |
+
*
|
1885 |
+
* @remarks
|
1886 |
+
* By default, commands are visible. This property is only for global commands.
|
1887 |
+
*/
|
1888 |
+
readonly dm_permission: boolean | undefined;
|
1889 |
+
/**
|
1890 |
+
* Sets the name of this command.
|
1891 |
+
*
|
1892 |
+
* @param name - The name to use
|
1893 |
+
*/
|
1894 |
+
setName(name: string): this;
|
1895 |
+
/**
|
1896 |
+
* Sets the type of this command.
|
1897 |
+
*
|
1898 |
+
* @param type - The type to use
|
1899 |
+
*/
|
1900 |
+
setType(type: ContextMenuCommandType): this;
|
1901 |
+
/**
|
1902 |
+
* Sets whether the command is enabled by default when the application is added to a guild.
|
1903 |
+
*
|
1904 |
+
* @remarks
|
1905 |
+
* If set to `false`, you will have to later `PUT` the permissions for this command.
|
1906 |
+
* @param value - Whether to enable this command by default
|
1907 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
1908 |
+
* @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
|
1909 |
+
*/
|
1910 |
+
setDefaultPermission(value: boolean): this;
|
1911 |
+
/**
|
1912 |
+
* Sets the default permissions a member should have in order to run this command.
|
1913 |
+
*
|
1914 |
+
* @remarks
|
1915 |
+
* You can set this to `'0'` to disable the command by default.
|
1916 |
+
* @param permissions - The permissions bit field to set
|
1917 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
1918 |
+
*/
|
1919 |
+
setDefaultMemberPermissions(permissions: Permissions | bigint | number | null | undefined): this;
|
1920 |
+
/**
|
1921 |
+
* Sets if the command is available in direct messages with the application.
|
1922 |
+
*
|
1923 |
+
* @remarks
|
1924 |
+
* By default, commands are visible. This method is only for global commands.
|
1925 |
+
* @param enabled - Whether the command should be enabled in direct messages
|
1926 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
1927 |
+
*/
|
1928 |
+
setDMPermission(enabled: boolean | null | undefined): this;
|
1929 |
+
/**
|
1930 |
+
* Sets a name localization for this command.
|
1931 |
+
*
|
1932 |
+
* @param locale - The locale to set
|
1933 |
+
* @param localizedName - The localized name for the given `locale`
|
1934 |
+
*/
|
1935 |
+
setNameLocalization(locale: LocaleString, localizedName: string | null): this;
|
1936 |
+
/**
|
1937 |
+
* Sets the name localizations for this command.
|
1938 |
+
*
|
1939 |
+
* @param localizedNames - The object of localized names to set
|
1940 |
+
*/
|
1941 |
+
setNameLocalizations(localizedNames: LocalizationMap | null): this;
|
1942 |
+
/**
|
1943 |
+
* Serializes this builder to API-compatible JSON data.
|
1944 |
+
*
|
1945 |
+
* @remarks
|
1946 |
+
* This method runs validations on the data before serializing it.
|
1947 |
+
* As such, it may throw an error if the data is invalid.
|
1948 |
+
*/
|
1949 |
+
toJSON(): RESTPostAPIContextMenuApplicationCommandsJSONBody;
|
1950 |
+
}
|
1951 |
+
|
1952 |
+
declare function validateDefaultPermission(value: unknown): asserts value is boolean;
|
1953 |
+
declare function validateName(name: unknown): asserts name is string;
|
1954 |
+
declare function validateType(type: unknown): asserts type is ContextMenuCommandType;
|
1955 |
+
declare function validateRequiredParameters(name: string, type: number): void;
|
1956 |
+
declare function validateDMPermission(value: unknown): asserts value is boolean | null | undefined;
|
1957 |
+
declare function validateDefaultMemberPermissions(permissions: unknown): string | null | undefined;
|
1958 |
+
|
1959 |
+
declare const Assertions_validateDMPermission: typeof validateDMPermission;
|
1960 |
+
declare const Assertions_validateDefaultMemberPermissions: typeof validateDefaultMemberPermissions;
|
1961 |
+
declare const Assertions_validateDefaultPermission: typeof validateDefaultPermission;
|
1962 |
+
declare const Assertions_validateName: typeof validateName;
|
1963 |
+
declare const Assertions_validateRequiredParameters: typeof validateRequiredParameters;
|
1964 |
+
declare const Assertions_validateType: typeof validateType;
|
1965 |
+
declare namespace Assertions {
|
1966 |
+
export {
|
1967 |
+
Assertions_validateDMPermission as validateDMPermission,
|
1968 |
+
Assertions_validateDefaultMemberPermissions as validateDefaultMemberPermissions,
|
1969 |
+
Assertions_validateDefaultPermission as validateDefaultPermission,
|
1970 |
+
Assertions_validateName as validateName,
|
1971 |
+
Assertions_validateRequiredParameters as validateRequiredParameters,
|
1972 |
+
Assertions_validateType as validateType,
|
1973 |
+
};
|
1974 |
+
}
|
1975 |
+
|
1976 |
+
/**
|
1977 |
+
* Calculates the length of the embed.
|
1978 |
+
*
|
1979 |
+
* @param data - The embed data to check
|
1980 |
+
*/
|
1981 |
+
declare function embedLength(data: APIEmbed): number;
|
1982 |
+
|
1983 |
+
/**
|
1984 |
+
* Enables validators.
|
1985 |
+
*
|
1986 |
+
* @returns Whether validation is occurring.
|
1987 |
+
*/
|
1988 |
+
declare function enableValidators(): boolean;
|
1989 |
+
/**
|
1990 |
+
* Disables validators.
|
1991 |
+
*
|
1992 |
+
* @returns Whether validation is occurring.
|
1993 |
+
*/
|
1994 |
+
declare function disableValidators(): boolean;
|
1995 |
+
/**
|
1996 |
+
* Checks whether validation is occurring.
|
1997 |
+
*/
|
1998 |
+
declare function isValidationEnabled(): boolean;
|
1999 |
+
|
2000 |
+
/**
|
2001 |
+
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/builders#readme | @discordjs/builders} version
|
2002 |
+
* that you are currently using.
|
2003 |
+
*
|
2004 |
+
* @privateRemarks This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild.
|
2005 |
+
*/
|
2006 |
+
declare const version: string;
|
2007 |
+
|
2008 |
+
export { ActionRowBuilder, AnyAPIActionRowComponent, AnyComponentBuilder, ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionAllowedChannelTypes, ApplicationCommandOptionBase, ApplicationCommandOptionChannelTypesMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin, BaseSelectMenuBuilder, ButtonBuilder, ChannelSelectMenuBuilder, Assertions$4 as ComponentAssertions, ComponentBuilder, Assertions as ContextMenuCommandAssertions, ContextMenuCommandBuilder, ContextMenuCommandType, Assertions$5 as EmbedAssertions, EmbedAuthorData, EmbedAuthorOptions, EmbedBuilder, EmbedFooterData, EmbedFooterOptions, EmbedImageData, IconData, MappedComponentTypes, MentionableSelectMenuBuilder, MessageActionRowComponentBuilder, MessageComponentBuilder, ModalActionRowComponentBuilder, Assertions$2 as ModalAssertions, ModalBuilder, ModalComponentBuilder, RGBTuple, RestOrArray, RoleSelectMenuBuilder, StringSelectMenuBuilder as SelectMenuBuilder, StringSelectMenuOptionBuilder as SelectMenuOptionBuilder, SharedNameAndDescription, SharedSlashCommandOptions, Assertions$1 as SlashCommandAssertions, SlashCommandAttachmentOption, SlashCommandBooleanOption, SlashCommandBuilder, SlashCommandChannelOption, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandOptionsOnlyBuilder, SlashCommandRoleOption, SlashCommandStringOption, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder, SlashCommandUserOption, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, Assertions$3 as TextInputAssertions, TextInputBuilder, ToAPIApplicationCommandOptions, UserSelectMenuBuilder, createComponentBuilder, disableValidators, embedLength, enableValidators, isValidationEnabled, normalizeArray, version };
|
node_modules/@discordjs/builders/dist/index.d.ts
ADDED
@@ -0,0 +1,2008 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import * as _sapphire_shapeshift from '@sapphire/shapeshift';
|
2 |
+
import { APIEmbedField, APIEmbedAuthor, APIEmbedFooter, APIEmbedImage, APIEmbed, APISelectMenuOption, APIMessageComponentEmoji, ButtonStyle, ChannelType, APIActionRowComponent, APIActionRowComponentTypes, APIBaseComponent, ComponentType, APIButtonComponent, APISelectMenuComponent, APIChannelSelectComponent, Snowflake, APIMentionableSelectComponent, APISelectMenuDefaultValue, SelectMenuDefaultValueType, APIRoleSelectComponent, APIStringSelectComponent, APIUserSelectComponent, APITextInputComponent, TextInputStyle, APIMessageActionRowComponent, APIModalActionRowComponent, APIModalComponent, APIMessageComponent, APIModalInteractionResponseCallbackData, LocalizationMap, LocaleString, ApplicationCommandOptionType, APIApplicationCommandBasicOption, APIApplicationCommandAttachmentOption, APIApplicationCommandBooleanOption, APIApplicationCommandChannelOption, APIApplicationCommandOptionChoice, APIApplicationCommandIntegerOption, APIApplicationCommandMentionableOption, APIApplicationCommandNumberOption, APIApplicationCommandRoleOption, APIApplicationCommandStringOption, APIApplicationCommandUserOption, APIApplicationCommandSubcommandGroupOption, APIApplicationCommandSubcommandOption, Permissions, RESTPostAPIChatInputApplicationCommandsJSONBody, APIApplicationCommandOption, Locale, ApplicationCommandType, RESTPostAPIContextMenuApplicationCommandsJSONBody } from 'discord-api-types/v10';
|
3 |
+
export * from '@discordjs/formatters';
|
4 |
+
import { JSONEncodable, Equatable } from '@discordjs/util';
|
5 |
+
|
6 |
+
declare const fieldNamePredicate: _sapphire_shapeshift.StringValidator<string>;
|
7 |
+
declare const fieldValuePredicate: _sapphire_shapeshift.StringValidator<string>;
|
8 |
+
declare const fieldInlinePredicate: _sapphire_shapeshift.UnionValidator<boolean | undefined>;
|
9 |
+
declare const embedFieldPredicate: _sapphire_shapeshift.ObjectValidator<{
|
10 |
+
name: string;
|
11 |
+
value: string;
|
12 |
+
inline: boolean | undefined;
|
13 |
+
}, _sapphire_shapeshift.UndefinedToOptional<{
|
14 |
+
name: string;
|
15 |
+
value: string;
|
16 |
+
inline: boolean | undefined;
|
17 |
+
}>>;
|
18 |
+
declare const embedFieldsArrayPredicate: _sapphire_shapeshift.ArrayValidator<_sapphire_shapeshift.UndefinedToOptional<{
|
19 |
+
name: string;
|
20 |
+
value: string;
|
21 |
+
inline: boolean | undefined;
|
22 |
+
}>[], _sapphire_shapeshift.UndefinedToOptional<{
|
23 |
+
name: string;
|
24 |
+
value: string;
|
25 |
+
inline: boolean | undefined;
|
26 |
+
}>>;
|
27 |
+
declare const fieldLengthPredicate: _sapphire_shapeshift.NumberValidator<number>;
|
28 |
+
declare function validateFieldLength(amountAdding: number, fields?: APIEmbedField[]): void;
|
29 |
+
declare const authorNamePredicate: _sapphire_shapeshift.UnionValidator<string | null>;
|
30 |
+
declare const imageURLPredicate: _sapphire_shapeshift.UnionValidator<string | null | undefined>;
|
31 |
+
declare const urlPredicate: _sapphire_shapeshift.UnionValidator<string | null | undefined>;
|
32 |
+
declare const embedAuthorPredicate: _sapphire_shapeshift.ObjectValidator<{
|
33 |
+
name: string | null;
|
34 |
+
iconURL: string | null | undefined;
|
35 |
+
url: string | null | undefined;
|
36 |
+
}, _sapphire_shapeshift.UndefinedToOptional<{
|
37 |
+
name: string | null;
|
38 |
+
iconURL: string | null | undefined;
|
39 |
+
url: string | null | undefined;
|
40 |
+
}>>;
|
41 |
+
declare const RGBPredicate: _sapphire_shapeshift.NumberValidator<number>;
|
42 |
+
declare const colorPredicate: _sapphire_shapeshift.UnionValidator<number | [number, number, number] | null>;
|
43 |
+
declare const descriptionPredicate: _sapphire_shapeshift.UnionValidator<string | null>;
|
44 |
+
declare const footerTextPredicate: _sapphire_shapeshift.UnionValidator<string | null>;
|
45 |
+
declare const embedFooterPredicate: _sapphire_shapeshift.ObjectValidator<{
|
46 |
+
text: string | null;
|
47 |
+
iconURL: string | null | undefined;
|
48 |
+
}, _sapphire_shapeshift.UndefinedToOptional<{
|
49 |
+
text: string | null;
|
50 |
+
iconURL: string | null | undefined;
|
51 |
+
}>>;
|
52 |
+
declare const timestampPredicate: _sapphire_shapeshift.UnionValidator<number | Date | null>;
|
53 |
+
declare const titlePredicate: _sapphire_shapeshift.UnionValidator<string | null>;
|
54 |
+
|
55 |
+
declare const Assertions$5_RGBPredicate: typeof RGBPredicate;
|
56 |
+
declare const Assertions$5_authorNamePredicate: typeof authorNamePredicate;
|
57 |
+
declare const Assertions$5_colorPredicate: typeof colorPredicate;
|
58 |
+
declare const Assertions$5_descriptionPredicate: typeof descriptionPredicate;
|
59 |
+
declare const Assertions$5_embedAuthorPredicate: typeof embedAuthorPredicate;
|
60 |
+
declare const Assertions$5_embedFieldPredicate: typeof embedFieldPredicate;
|
61 |
+
declare const Assertions$5_embedFieldsArrayPredicate: typeof embedFieldsArrayPredicate;
|
62 |
+
declare const Assertions$5_embedFooterPredicate: typeof embedFooterPredicate;
|
63 |
+
declare const Assertions$5_fieldInlinePredicate: typeof fieldInlinePredicate;
|
64 |
+
declare const Assertions$5_fieldLengthPredicate: typeof fieldLengthPredicate;
|
65 |
+
declare const Assertions$5_fieldNamePredicate: typeof fieldNamePredicate;
|
66 |
+
declare const Assertions$5_fieldValuePredicate: typeof fieldValuePredicate;
|
67 |
+
declare const Assertions$5_footerTextPredicate: typeof footerTextPredicate;
|
68 |
+
declare const Assertions$5_imageURLPredicate: typeof imageURLPredicate;
|
69 |
+
declare const Assertions$5_timestampPredicate: typeof timestampPredicate;
|
70 |
+
declare const Assertions$5_titlePredicate: typeof titlePredicate;
|
71 |
+
declare const Assertions$5_urlPredicate: typeof urlPredicate;
|
72 |
+
declare const Assertions$5_validateFieldLength: typeof validateFieldLength;
|
73 |
+
declare namespace Assertions$5 {
|
74 |
+
export {
|
75 |
+
Assertions$5_RGBPredicate as RGBPredicate,
|
76 |
+
Assertions$5_authorNamePredicate as authorNamePredicate,
|
77 |
+
Assertions$5_colorPredicate as colorPredicate,
|
78 |
+
Assertions$5_descriptionPredicate as descriptionPredicate,
|
79 |
+
Assertions$5_embedAuthorPredicate as embedAuthorPredicate,
|
80 |
+
Assertions$5_embedFieldPredicate as embedFieldPredicate,
|
81 |
+
Assertions$5_embedFieldsArrayPredicate as embedFieldsArrayPredicate,
|
82 |
+
Assertions$5_embedFooterPredicate as embedFooterPredicate,
|
83 |
+
Assertions$5_fieldInlinePredicate as fieldInlinePredicate,
|
84 |
+
Assertions$5_fieldLengthPredicate as fieldLengthPredicate,
|
85 |
+
Assertions$5_fieldNamePredicate as fieldNamePredicate,
|
86 |
+
Assertions$5_fieldValuePredicate as fieldValuePredicate,
|
87 |
+
Assertions$5_footerTextPredicate as footerTextPredicate,
|
88 |
+
Assertions$5_imageURLPredicate as imageURLPredicate,
|
89 |
+
Assertions$5_timestampPredicate as timestampPredicate,
|
90 |
+
Assertions$5_titlePredicate as titlePredicate,
|
91 |
+
Assertions$5_urlPredicate as urlPredicate,
|
92 |
+
Assertions$5_validateFieldLength as validateFieldLength,
|
93 |
+
};
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Normalizes data that is a rest parameter or an array into an array with a depth of 1.
|
98 |
+
*
|
99 |
+
* @typeParam ItemType - The data that must satisfy {@link RestOrArray}.
|
100 |
+
* @param arr - The (possibly variadic) data to normalize
|
101 |
+
*/
|
102 |
+
declare function normalizeArray<ItemType>(arr: RestOrArray<ItemType>): ItemType[];
|
103 |
+
/**
|
104 |
+
* Represents data that may be an array or came from a rest parameter.
|
105 |
+
*
|
106 |
+
* @remarks
|
107 |
+
* This type is used throughout builders to ensure both an array and variadic arguments
|
108 |
+
* may be used. It is normalized with {@link normalizeArray}.
|
109 |
+
*/
|
110 |
+
type RestOrArray<Type> = Type[] | [Type[]];
|
111 |
+
|
112 |
+
/**
|
113 |
+
* A tuple satisfying the RGB color model.
|
114 |
+
*
|
115 |
+
* @see {@link https://developer.mozilla.org/docs/Glossary/RGB}
|
116 |
+
*/
|
117 |
+
type RGBTuple = [red: number, green: number, blue: number];
|
118 |
+
/**
|
119 |
+
* The base icon data typically used in payloads.
|
120 |
+
*/
|
121 |
+
interface IconData {
|
122 |
+
/**
|
123 |
+
* The URL of the icon.
|
124 |
+
*/
|
125 |
+
iconURL?: string;
|
126 |
+
/**
|
127 |
+
* The proxy URL of the icon.
|
128 |
+
*/
|
129 |
+
proxyIconURL?: string;
|
130 |
+
}
|
131 |
+
/**
|
132 |
+
* Represents the author data of an embed.
|
133 |
+
*/
|
134 |
+
type EmbedAuthorData = IconData & Omit<APIEmbedAuthor, 'icon_url' | 'proxy_icon_url'>;
|
135 |
+
/**
|
136 |
+
* Represents the author options of an embed.
|
137 |
+
*/
|
138 |
+
type EmbedAuthorOptions = Omit<EmbedAuthorData, 'proxyIconURL'>;
|
139 |
+
/**
|
140 |
+
* Represents the footer data of an embed.
|
141 |
+
*/
|
142 |
+
type EmbedFooterData = IconData & Omit<APIEmbedFooter, 'icon_url' | 'proxy_icon_url'>;
|
143 |
+
/**
|
144 |
+
* Represents the footer options of an embed.
|
145 |
+
*/
|
146 |
+
type EmbedFooterOptions = Omit<EmbedFooterData, 'proxyIconURL'>;
|
147 |
+
/**
|
148 |
+
* Represents the image data of an embed.
|
149 |
+
*/
|
150 |
+
interface EmbedImageData extends Omit<APIEmbedImage, 'proxy_url'> {
|
151 |
+
/**
|
152 |
+
* The proxy URL for the image.
|
153 |
+
*/
|
154 |
+
proxyURL?: string;
|
155 |
+
}
|
156 |
+
/**
|
157 |
+
* A builder that creates API-compatible JSON data for embeds.
|
158 |
+
*/
|
159 |
+
declare class EmbedBuilder {
|
160 |
+
/**
|
161 |
+
* The API data associated with this embed.
|
162 |
+
*/
|
163 |
+
readonly data: APIEmbed;
|
164 |
+
/**
|
165 |
+
* Creates a new embed from API data.
|
166 |
+
*
|
167 |
+
* @param data - The API data to create this embed with
|
168 |
+
*/
|
169 |
+
constructor(data?: APIEmbed);
|
170 |
+
/**
|
171 |
+
* Appends fields to the embed.
|
172 |
+
*
|
173 |
+
* @remarks
|
174 |
+
* This method accepts either an array of fields or a variable number of field parameters.
|
175 |
+
* The maximum amount of fields that can be added is 25.
|
176 |
+
* @example
|
177 |
+
* Using an array:
|
178 |
+
* ```ts
|
179 |
+
* const fields: APIEmbedField[] = ...;
|
180 |
+
* const embed = new EmbedBuilder()
|
181 |
+
* .addFields(fields);
|
182 |
+
* ```
|
183 |
+
* @example
|
184 |
+
* Using rest parameters (variadic):
|
185 |
+
* ```ts
|
186 |
+
* const embed = new EmbedBuilder()
|
187 |
+
* .addFields(
|
188 |
+
* { name: 'Field 1', value: 'Value 1' },
|
189 |
+
* { name: 'Field 2', value: 'Value 2' },
|
190 |
+
* );
|
191 |
+
* ```
|
192 |
+
* @param fields - The fields to add
|
193 |
+
*/
|
194 |
+
addFields(...fields: RestOrArray<APIEmbedField>): this;
|
195 |
+
/**
|
196 |
+
* Removes, replaces, or inserts fields for this embed.
|
197 |
+
*
|
198 |
+
* @remarks
|
199 |
+
* This method behaves similarly
|
200 |
+
* to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
201 |
+
* The maximum amount of fields that can be added is 25.
|
202 |
+
*
|
203 |
+
* It's useful for modifying and adjusting order of the already-existing fields of an embed.
|
204 |
+
* @example
|
205 |
+
* Remove the first field:
|
206 |
+
* ```ts
|
207 |
+
* embed.spliceFields(0, 1);
|
208 |
+
* ```
|
209 |
+
* @example
|
210 |
+
* Remove the first n fields:
|
211 |
+
* ```ts
|
212 |
+
* const n = 4;
|
213 |
+
* embed.spliceFields(0, n);
|
214 |
+
* ```
|
215 |
+
* @example
|
216 |
+
* Remove the last field:
|
217 |
+
* ```ts
|
218 |
+
* embed.spliceFields(-1, 1);
|
219 |
+
* ```
|
220 |
+
* @param index - The index to start at
|
221 |
+
* @param deleteCount - The number of fields to remove
|
222 |
+
* @param fields - The replacing field objects
|
223 |
+
*/
|
224 |
+
spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this;
|
225 |
+
/**
|
226 |
+
* Sets the fields for this embed.
|
227 |
+
*
|
228 |
+
* @remarks
|
229 |
+
* This method is an alias for {@link EmbedBuilder.spliceFields}. More specifically,
|
230 |
+
* it splices the entire array of fields, replacing them with the provided fields.
|
231 |
+
*
|
232 |
+
* You can set a maximum of 25 fields.
|
233 |
+
* @param fields - The fields to set
|
234 |
+
*/
|
235 |
+
setFields(...fields: RestOrArray<APIEmbedField>): this;
|
236 |
+
/**
|
237 |
+
* Sets the author of this embed.
|
238 |
+
*
|
239 |
+
* @param options - The options to use
|
240 |
+
*/
|
241 |
+
setAuthor(options: EmbedAuthorOptions | null): this;
|
242 |
+
/**
|
243 |
+
* Sets the color of this embed.
|
244 |
+
*
|
245 |
+
* @param color - The color to use
|
246 |
+
*/
|
247 |
+
setColor(color: RGBTuple | number | null): this;
|
248 |
+
/**
|
249 |
+
* Sets the description of this embed.
|
250 |
+
*
|
251 |
+
* @param description - The description to use
|
252 |
+
*/
|
253 |
+
setDescription(description: string | null): this;
|
254 |
+
/**
|
255 |
+
* Sets the footer of this embed.
|
256 |
+
*
|
257 |
+
* @param options - The footer to use
|
258 |
+
*/
|
259 |
+
setFooter(options: EmbedFooterOptions | null): this;
|
260 |
+
/**
|
261 |
+
* Sets the image of this embed.
|
262 |
+
*
|
263 |
+
* @param url - The image URL to use
|
264 |
+
*/
|
265 |
+
setImage(url: string | null): this;
|
266 |
+
/**
|
267 |
+
* Sets the thumbnail of this embed.
|
268 |
+
*
|
269 |
+
* @param url - The thumbnail URL to use
|
270 |
+
*/
|
271 |
+
setThumbnail(url: string | null): this;
|
272 |
+
/**
|
273 |
+
* Sets the timestamp of this embed.
|
274 |
+
*
|
275 |
+
* @param timestamp - The timestamp or date to use
|
276 |
+
*/
|
277 |
+
setTimestamp(timestamp?: Date | number | null): this;
|
278 |
+
/**
|
279 |
+
* Sets the title for this embed.
|
280 |
+
*
|
281 |
+
* @param title - The title to use
|
282 |
+
*/
|
283 |
+
setTitle(title: string | null): this;
|
284 |
+
/**
|
285 |
+
* Sets the URL of this embed.
|
286 |
+
*
|
287 |
+
* @param url - The URL to use
|
288 |
+
*/
|
289 |
+
setURL(url: string | null): this;
|
290 |
+
/**
|
291 |
+
* Serializes this builder to API-compatible JSON data.
|
292 |
+
*
|
293 |
+
* @remarks
|
294 |
+
* This method runs validations on the data before serializing it.
|
295 |
+
* As such, it may throw an error if the data is invalid.
|
296 |
+
*/
|
297 |
+
toJSON(): APIEmbed;
|
298 |
+
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* A builder that creates API-compatible JSON data for string select menu options.
|
302 |
+
*/
|
303 |
+
declare class StringSelectMenuOptionBuilder implements JSONEncodable<APISelectMenuOption> {
|
304 |
+
data: Partial<APISelectMenuOption>;
|
305 |
+
/**
|
306 |
+
* Creates a new string select menu option from API data.
|
307 |
+
*
|
308 |
+
* @param data - The API data to create this string select menu option with
|
309 |
+
* @example
|
310 |
+
* Creating a string select menu option from an API data object:
|
311 |
+
* ```ts
|
312 |
+
* const selectMenuOption = new SelectMenuOptionBuilder({
|
313 |
+
* label: 'catchy label',
|
314 |
+
* value: '1',
|
315 |
+
* });
|
316 |
+
* ```
|
317 |
+
* @example
|
318 |
+
* Creating a string select menu option using setters and API data:
|
319 |
+
* ```ts
|
320 |
+
* const selectMenuOption = new SelectMenuOptionBuilder({
|
321 |
+
* default: true,
|
322 |
+
* value: '1',
|
323 |
+
* })
|
324 |
+
* .setLabel('woah');
|
325 |
+
* ```
|
326 |
+
*/
|
327 |
+
constructor(data?: Partial<APISelectMenuOption>);
|
328 |
+
/**
|
329 |
+
* Sets the label for this option.
|
330 |
+
*
|
331 |
+
* @param label - The label to use
|
332 |
+
*/
|
333 |
+
setLabel(label: string): this;
|
334 |
+
/**
|
335 |
+
* Sets the value for this option.
|
336 |
+
*
|
337 |
+
* @param value - The value to use
|
338 |
+
*/
|
339 |
+
setValue(value: string): this;
|
340 |
+
/**
|
341 |
+
* Sets the description for this option.
|
342 |
+
*
|
343 |
+
* @param description - The description to use
|
344 |
+
*/
|
345 |
+
setDescription(description: string): this;
|
346 |
+
/**
|
347 |
+
* Sets whether this option is selected by default.
|
348 |
+
*
|
349 |
+
* @param isDefault - Whether this option is selected by default
|
350 |
+
*/
|
351 |
+
setDefault(isDefault?: boolean): this;
|
352 |
+
/**
|
353 |
+
* Sets the emoji to display for this option.
|
354 |
+
*
|
355 |
+
* @param emoji - The emoji to use
|
356 |
+
*/
|
357 |
+
setEmoji(emoji: APIMessageComponentEmoji): this;
|
358 |
+
/**
|
359 |
+
* {@inheritDoc BaseSelectMenuBuilder.toJSON}
|
360 |
+
*/
|
361 |
+
toJSON(): APISelectMenuOption;
|
362 |
+
}
|
363 |
+
|
364 |
+
declare const customIdValidator: _sapphire_shapeshift.StringValidator<string>;
|
365 |
+
declare const emojiValidator: _sapphire_shapeshift.ObjectValidator<{
|
366 |
+
name?: string | undefined;
|
367 |
+
id?: string | undefined;
|
368 |
+
animated?: boolean | undefined;
|
369 |
+
}, _sapphire_shapeshift.UndefinedToOptional<{
|
370 |
+
name?: string | undefined;
|
371 |
+
id?: string | undefined;
|
372 |
+
animated?: boolean | undefined;
|
373 |
+
}>>;
|
374 |
+
declare const disabledValidator: _sapphire_shapeshift.BooleanValidator<boolean>;
|
375 |
+
declare const buttonLabelValidator: _sapphire_shapeshift.StringValidator<string>;
|
376 |
+
declare const buttonStyleValidator: _sapphire_shapeshift.NativeEnumValidator<typeof ButtonStyle>;
|
377 |
+
declare const placeholderValidator$1: _sapphire_shapeshift.StringValidator<string>;
|
378 |
+
declare const minMaxValidator: _sapphire_shapeshift.NumberValidator<number>;
|
379 |
+
declare const labelValueDescriptionValidator: _sapphire_shapeshift.StringValidator<string>;
|
380 |
+
declare const jsonOptionValidator: _sapphire_shapeshift.ObjectValidator<{
|
381 |
+
label: string;
|
382 |
+
value: string;
|
383 |
+
description: string | undefined;
|
384 |
+
emoji: _sapphire_shapeshift.UndefinedToOptional<{
|
385 |
+
name?: string | undefined;
|
386 |
+
id?: string | undefined;
|
387 |
+
animated?: boolean | undefined;
|
388 |
+
}> | undefined;
|
389 |
+
default: boolean | undefined;
|
390 |
+
}, _sapphire_shapeshift.UndefinedToOptional<{
|
391 |
+
label: string;
|
392 |
+
value: string;
|
393 |
+
description: string | undefined;
|
394 |
+
emoji: _sapphire_shapeshift.UndefinedToOptional<{
|
395 |
+
name?: string | undefined;
|
396 |
+
id?: string | undefined;
|
397 |
+
animated?: boolean | undefined;
|
398 |
+
}> | undefined;
|
399 |
+
default: boolean | undefined;
|
400 |
+
}>>;
|
401 |
+
declare const optionValidator: _sapphire_shapeshift.InstanceValidator<StringSelectMenuOptionBuilder>;
|
402 |
+
declare const optionsValidator: _sapphire_shapeshift.ArrayValidator<StringSelectMenuOptionBuilder[], StringSelectMenuOptionBuilder>;
|
403 |
+
declare const optionsLengthValidator: _sapphire_shapeshift.NumberValidator<number>;
|
404 |
+
declare function validateRequiredSelectMenuParameters(options: StringSelectMenuOptionBuilder[], customId?: string): void;
|
405 |
+
declare const defaultValidator: _sapphire_shapeshift.BooleanValidator<boolean>;
|
406 |
+
declare function validateRequiredSelectMenuOptionParameters(label?: string, value?: string): void;
|
407 |
+
declare const channelTypesValidator: _sapphire_shapeshift.ArrayValidator<ChannelType[], ChannelType>;
|
408 |
+
declare const urlValidator: _sapphire_shapeshift.StringValidator<string>;
|
409 |
+
declare function validateRequiredButtonParameters(style?: ButtonStyle, label?: string, emoji?: APIMessageComponentEmoji, customId?: string, url?: string): void;
|
410 |
+
|
411 |
+
declare const Assertions$4_buttonLabelValidator: typeof buttonLabelValidator;
|
412 |
+
declare const Assertions$4_buttonStyleValidator: typeof buttonStyleValidator;
|
413 |
+
declare const Assertions$4_channelTypesValidator: typeof channelTypesValidator;
|
414 |
+
declare const Assertions$4_customIdValidator: typeof customIdValidator;
|
415 |
+
declare const Assertions$4_defaultValidator: typeof defaultValidator;
|
416 |
+
declare const Assertions$4_disabledValidator: typeof disabledValidator;
|
417 |
+
declare const Assertions$4_emojiValidator: typeof emojiValidator;
|
418 |
+
declare const Assertions$4_jsonOptionValidator: typeof jsonOptionValidator;
|
419 |
+
declare const Assertions$4_labelValueDescriptionValidator: typeof labelValueDescriptionValidator;
|
420 |
+
declare const Assertions$4_minMaxValidator: typeof minMaxValidator;
|
421 |
+
declare const Assertions$4_optionValidator: typeof optionValidator;
|
422 |
+
declare const Assertions$4_optionsLengthValidator: typeof optionsLengthValidator;
|
423 |
+
declare const Assertions$4_optionsValidator: typeof optionsValidator;
|
424 |
+
declare const Assertions$4_urlValidator: typeof urlValidator;
|
425 |
+
declare const Assertions$4_validateRequiredButtonParameters: typeof validateRequiredButtonParameters;
|
426 |
+
declare const Assertions$4_validateRequiredSelectMenuOptionParameters: typeof validateRequiredSelectMenuOptionParameters;
|
427 |
+
declare const Assertions$4_validateRequiredSelectMenuParameters: typeof validateRequiredSelectMenuParameters;
|
428 |
+
declare namespace Assertions$4 {
|
429 |
+
export {
|
430 |
+
Assertions$4_buttonLabelValidator as buttonLabelValidator,
|
431 |
+
Assertions$4_buttonStyleValidator as buttonStyleValidator,
|
432 |
+
Assertions$4_channelTypesValidator as channelTypesValidator,
|
433 |
+
Assertions$4_customIdValidator as customIdValidator,
|
434 |
+
Assertions$4_defaultValidator as defaultValidator,
|
435 |
+
Assertions$4_disabledValidator as disabledValidator,
|
436 |
+
Assertions$4_emojiValidator as emojiValidator,
|
437 |
+
Assertions$4_jsonOptionValidator as jsonOptionValidator,
|
438 |
+
Assertions$4_labelValueDescriptionValidator as labelValueDescriptionValidator,
|
439 |
+
Assertions$4_minMaxValidator as minMaxValidator,
|
440 |
+
Assertions$4_optionValidator as optionValidator,
|
441 |
+
Assertions$4_optionsLengthValidator as optionsLengthValidator,
|
442 |
+
Assertions$4_optionsValidator as optionsValidator,
|
443 |
+
placeholderValidator$1 as placeholderValidator,
|
444 |
+
Assertions$4_urlValidator as urlValidator,
|
445 |
+
Assertions$4_validateRequiredButtonParameters as validateRequiredButtonParameters,
|
446 |
+
Assertions$4_validateRequiredSelectMenuOptionParameters as validateRequiredSelectMenuOptionParameters,
|
447 |
+
Assertions$4_validateRequiredSelectMenuParameters as validateRequiredSelectMenuParameters,
|
448 |
+
};
|
449 |
+
}
|
450 |
+
|
451 |
+
/**
|
452 |
+
* Any action row component data represented as an object.
|
453 |
+
*/
|
454 |
+
type AnyAPIActionRowComponent = APIActionRowComponent<APIActionRowComponentTypes> | APIActionRowComponentTypes;
|
455 |
+
/**
|
456 |
+
* The base component builder that contains common symbols for all sorts of components.
|
457 |
+
*
|
458 |
+
* @typeParam DataType - The type of internal API data that is stored within the component
|
459 |
+
*/
|
460 |
+
declare abstract class ComponentBuilder<DataType extends Partial<APIBaseComponent<ComponentType>> = APIBaseComponent<ComponentType>> implements JSONEncodable<AnyAPIActionRowComponent> {
|
461 |
+
/**
|
462 |
+
* The API data associated with this component.
|
463 |
+
*/
|
464 |
+
readonly data: Partial<DataType>;
|
465 |
+
/**
|
466 |
+
* Serializes this builder to API-compatible JSON data.
|
467 |
+
*
|
468 |
+
* @remarks
|
469 |
+
* This method runs validations on the data before serializing it.
|
470 |
+
* As such, it may throw an error if the data is invalid.
|
471 |
+
*/
|
472 |
+
abstract toJSON(): AnyAPIActionRowComponent;
|
473 |
+
/**
|
474 |
+
* Constructs a new kind of component.
|
475 |
+
*
|
476 |
+
* @param data - The data to construct a component out of
|
477 |
+
*/
|
478 |
+
constructor(data: Partial<DataType>);
|
479 |
+
}
|
480 |
+
|
481 |
+
/**
|
482 |
+
* A builder that creates API-compatible JSON data for buttons.
|
483 |
+
*/
|
484 |
+
declare class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
|
485 |
+
/**
|
486 |
+
* Creates a new button from API data.
|
487 |
+
*
|
488 |
+
* @param data - The API data to create this button with
|
489 |
+
* @example
|
490 |
+
* Creating a button from an API data object:
|
491 |
+
* ```ts
|
492 |
+
* const button = new ButtonBuilder({
|
493 |
+
* custom_id: 'a cool button',
|
494 |
+
* style: ButtonStyle.Primary,
|
495 |
+
* label: 'Click Me',
|
496 |
+
* emoji: {
|
497 |
+
* name: 'smile',
|
498 |
+
* id: '123456789012345678',
|
499 |
+
* },
|
500 |
+
* });
|
501 |
+
* ```
|
502 |
+
* @example
|
503 |
+
* Creating a button using setters and API data:
|
504 |
+
* ```ts
|
505 |
+
* const button = new ButtonBuilder({
|
506 |
+
* style: ButtonStyle.Secondary,
|
507 |
+
* label: 'Click Me',
|
508 |
+
* })
|
509 |
+
* .setEmoji({ name: '🙂' })
|
510 |
+
* .setCustomId('another cool button');
|
511 |
+
* ```
|
512 |
+
*/
|
513 |
+
constructor(data?: Partial<APIButtonComponent>);
|
514 |
+
/**
|
515 |
+
* Sets the style of this button.
|
516 |
+
*
|
517 |
+
* @param style - The style to use
|
518 |
+
*/
|
519 |
+
setStyle(style: ButtonStyle): this;
|
520 |
+
/**
|
521 |
+
* Sets the URL for this button.
|
522 |
+
*
|
523 |
+
* @remarks
|
524 |
+
* This method is only available to buttons using the `Link` button style.
|
525 |
+
* Only three types of URL schemes are currently supported: `https://`, `http://`, and `discord://`.
|
526 |
+
* @param url - The URL to use
|
527 |
+
*/
|
528 |
+
setURL(url: string): this;
|
529 |
+
/**
|
530 |
+
* Sets the custom id for this button.
|
531 |
+
*
|
532 |
+
* @remarks
|
533 |
+
* This method is only applicable to buttons that are not using the `Link` button style.
|
534 |
+
* @param customId - The custom id to use
|
535 |
+
*/
|
536 |
+
setCustomId(customId: string): this;
|
537 |
+
/**
|
538 |
+
* Sets the emoji to display on this button.
|
539 |
+
*
|
540 |
+
* @param emoji - The emoji to use
|
541 |
+
*/
|
542 |
+
setEmoji(emoji: APIMessageComponentEmoji): this;
|
543 |
+
/**
|
544 |
+
* Sets whether this button is disabled.
|
545 |
+
*
|
546 |
+
* @param disabled - Whether to disable this button
|
547 |
+
*/
|
548 |
+
setDisabled(disabled?: boolean): this;
|
549 |
+
/**
|
550 |
+
* Sets the label for this button.
|
551 |
+
*
|
552 |
+
* @param label - The label to use
|
553 |
+
*/
|
554 |
+
setLabel(label: string): this;
|
555 |
+
/**
|
556 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
557 |
+
*/
|
558 |
+
toJSON(): APIButtonComponent;
|
559 |
+
}
|
560 |
+
|
561 |
+
/**
|
562 |
+
* The base select menu builder that contains common symbols for select menu builders.
|
563 |
+
*
|
564 |
+
* @typeParam SelectMenuType - The type of select menu this would be instantiated for.
|
565 |
+
*/
|
566 |
+
declare abstract class BaseSelectMenuBuilder<SelectMenuType extends APISelectMenuComponent> extends ComponentBuilder<SelectMenuType> {
|
567 |
+
/**
|
568 |
+
* Sets the placeholder for this select menu.
|
569 |
+
*
|
570 |
+
* @param placeholder - The placeholder to use
|
571 |
+
*/
|
572 |
+
setPlaceholder(placeholder: string): this;
|
573 |
+
/**
|
574 |
+
* Sets the minimum values that must be selected in the select menu.
|
575 |
+
*
|
576 |
+
* @param minValues - The minimum values that must be selected
|
577 |
+
*/
|
578 |
+
setMinValues(minValues: number): this;
|
579 |
+
/**
|
580 |
+
* Sets the maximum values that must be selected in the select menu.
|
581 |
+
*
|
582 |
+
* @param maxValues - The maximum values that must be selected
|
583 |
+
*/
|
584 |
+
setMaxValues(maxValues: number): this;
|
585 |
+
/**
|
586 |
+
* Sets the custom id for this select menu.
|
587 |
+
*
|
588 |
+
* @param customId - The custom id to use
|
589 |
+
*/
|
590 |
+
setCustomId(customId: string): this;
|
591 |
+
/**
|
592 |
+
* Sets whether this select menu is disabled.
|
593 |
+
*
|
594 |
+
* @param disabled - Whether this select menu is disabled
|
595 |
+
*/
|
596 |
+
setDisabled(disabled?: boolean): this;
|
597 |
+
/**
|
598 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
599 |
+
*/
|
600 |
+
toJSON(): SelectMenuType;
|
601 |
+
}
|
602 |
+
|
603 |
+
/**
|
604 |
+
* A builder that creates API-compatible JSON data for channel select menus.
|
605 |
+
*/
|
606 |
+
declare class ChannelSelectMenuBuilder extends BaseSelectMenuBuilder<APIChannelSelectComponent> {
|
607 |
+
/**
|
608 |
+
* Creates a new select menu from API data.
|
609 |
+
*
|
610 |
+
* @param data - The API data to create this select menu with
|
611 |
+
* @example
|
612 |
+
* Creating a select menu from an API data object:
|
613 |
+
* ```ts
|
614 |
+
* const selectMenu = new ChannelSelectMenuBuilder({
|
615 |
+
* custom_id: 'a cool select menu',
|
616 |
+
* placeholder: 'select an option',
|
617 |
+
* max_values: 2,
|
618 |
+
* });
|
619 |
+
* ```
|
620 |
+
* @example
|
621 |
+
* Creating a select menu using setters and API data:
|
622 |
+
* ```ts
|
623 |
+
* const selectMenu = new ChannelSelectMenuBuilder({
|
624 |
+
* custom_id: 'a cool select menu',
|
625 |
+
* })
|
626 |
+
* .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
|
627 |
+
* .setMinValues(2);
|
628 |
+
* ```
|
629 |
+
*/
|
630 |
+
constructor(data?: Partial<APIChannelSelectComponent>);
|
631 |
+
/**
|
632 |
+
* Adds channel types to this select menu.
|
633 |
+
*
|
634 |
+
* @param types - The channel types to use
|
635 |
+
*/
|
636 |
+
addChannelTypes(...types: RestOrArray<ChannelType>): this;
|
637 |
+
/**
|
638 |
+
* Sets channel types for this select menu.
|
639 |
+
*
|
640 |
+
* @param types - The channel types to use
|
641 |
+
*/
|
642 |
+
setChannelTypes(...types: RestOrArray<ChannelType>): this;
|
643 |
+
/**
|
644 |
+
* Adds default channels to this auto populated select menu.
|
645 |
+
*
|
646 |
+
* @param channels - The channels to add
|
647 |
+
*/
|
648 |
+
addDefaultChannels(...channels: RestOrArray<Snowflake>): this;
|
649 |
+
/**
|
650 |
+
* Sets default channels to this auto populated select menu.
|
651 |
+
*
|
652 |
+
* @param channels - The channels to set
|
653 |
+
*/
|
654 |
+
setDefaultChannels(...channels: RestOrArray<Snowflake>): this;
|
655 |
+
/**
|
656 |
+
* {@inheritDoc BaseSelectMenuBuilder.toJSON}
|
657 |
+
*/
|
658 |
+
toJSON(): APIChannelSelectComponent;
|
659 |
+
}
|
660 |
+
|
661 |
+
/**
|
662 |
+
* A builder that creates API-compatible JSON data for mentionable select menus.
|
663 |
+
*/
|
664 |
+
declare class MentionableSelectMenuBuilder extends BaseSelectMenuBuilder<APIMentionableSelectComponent> {
|
665 |
+
/**
|
666 |
+
* Creates a new select menu from API data.
|
667 |
+
*
|
668 |
+
* @param data - The API data to create this select menu with
|
669 |
+
* @example
|
670 |
+
* Creating a select menu from an API data object:
|
671 |
+
* ```ts
|
672 |
+
* const selectMenu = new MentionableSelectMenuBuilder({
|
673 |
+
* custom_id: 'a cool select menu',
|
674 |
+
* placeholder: 'select an option',
|
675 |
+
* max_values: 2,
|
676 |
+
* });
|
677 |
+
* ```
|
678 |
+
* @example
|
679 |
+
* Creating a select menu using setters and API data:
|
680 |
+
* ```ts
|
681 |
+
* const selectMenu = new MentionableSelectMenuBuilder({
|
682 |
+
* custom_id: 'a cool select menu',
|
683 |
+
* })
|
684 |
+
* .setMinValues(1);
|
685 |
+
* ```
|
686 |
+
*/
|
687 |
+
constructor(data?: Partial<APIMentionableSelectComponent>);
|
688 |
+
/**
|
689 |
+
* Adds default roles to this auto populated select menu.
|
690 |
+
*
|
691 |
+
* @param roles - The roles to add
|
692 |
+
*/
|
693 |
+
addDefaultRoles(...roles: RestOrArray<Snowflake>): this;
|
694 |
+
/**
|
695 |
+
* Adds default users to this auto populated select menu.
|
696 |
+
*
|
697 |
+
* @param users - The users to add
|
698 |
+
*/
|
699 |
+
addDefaultUsers(...users: RestOrArray<Snowflake>): this;
|
700 |
+
/**
|
701 |
+
* Adds default values to this auto populated select menu.
|
702 |
+
*
|
703 |
+
* @param values - The values to add
|
704 |
+
*/
|
705 |
+
addDefaultValues(...values: RestOrArray<APISelectMenuDefaultValue<SelectMenuDefaultValueType.Role> | APISelectMenuDefaultValue<SelectMenuDefaultValueType.User>>): this;
|
706 |
+
/**
|
707 |
+
* Sets default values to this auto populated select menu.
|
708 |
+
*
|
709 |
+
* @param values - The values to set
|
710 |
+
*/
|
711 |
+
setDefaultValues(...values: RestOrArray<APISelectMenuDefaultValue<SelectMenuDefaultValueType.Role> | APISelectMenuDefaultValue<SelectMenuDefaultValueType.User>>): this;
|
712 |
+
}
|
713 |
+
|
714 |
+
/**
|
715 |
+
* A builder that creates API-compatible JSON data for role select menus.
|
716 |
+
*/
|
717 |
+
declare class RoleSelectMenuBuilder extends BaseSelectMenuBuilder<APIRoleSelectComponent> {
|
718 |
+
/**
|
719 |
+
* Creates a new select menu from API data.
|
720 |
+
*
|
721 |
+
* @param data - The API data to create this select menu with
|
722 |
+
* @example
|
723 |
+
* Creating a select menu from an API data object:
|
724 |
+
* ```ts
|
725 |
+
* const selectMenu = new RoleSelectMenuBuilder({
|
726 |
+
* custom_id: 'a cool select menu',
|
727 |
+
* placeholder: 'select an option',
|
728 |
+
* max_values: 2,
|
729 |
+
* });
|
730 |
+
* ```
|
731 |
+
* @example
|
732 |
+
* Creating a select menu using setters and API data:
|
733 |
+
* ```ts
|
734 |
+
* const selectMenu = new RoleSelectMenuBuilder({
|
735 |
+
* custom_id: 'a cool select menu',
|
736 |
+
* })
|
737 |
+
* .setMinValues(1);
|
738 |
+
* ```
|
739 |
+
*/
|
740 |
+
constructor(data?: Partial<APIRoleSelectComponent>);
|
741 |
+
/**
|
742 |
+
* Adds default roles to this auto populated select menu.
|
743 |
+
*
|
744 |
+
* @param roles - The roles to add
|
745 |
+
*/
|
746 |
+
addDefaultRoles(...roles: RestOrArray<Snowflake>): this;
|
747 |
+
/**
|
748 |
+
* Sets default roles to this auto populated select menu.
|
749 |
+
*
|
750 |
+
* @param roles - The roles to set
|
751 |
+
*/
|
752 |
+
setDefaultRoles(...roles: RestOrArray<Snowflake>): this;
|
753 |
+
}
|
754 |
+
|
755 |
+
/**
|
756 |
+
* A builder that creates API-compatible JSON data for string select menus.
|
757 |
+
*/
|
758 |
+
declare class StringSelectMenuBuilder extends BaseSelectMenuBuilder<APIStringSelectComponent> {
|
759 |
+
/**
|
760 |
+
* The options within this select menu.
|
761 |
+
*/
|
762 |
+
readonly options: StringSelectMenuOptionBuilder[];
|
763 |
+
/**
|
764 |
+
* Creates a new select menu from API data.
|
765 |
+
*
|
766 |
+
* @param data - The API data to create this select menu with
|
767 |
+
* @example
|
768 |
+
* Creating a select menu from an API data object:
|
769 |
+
* ```ts
|
770 |
+
* const selectMenu = new StringSelectMenuBuilder({
|
771 |
+
* custom_id: 'a cool select menu',
|
772 |
+
* placeholder: 'select an option',
|
773 |
+
* max_values: 2,
|
774 |
+
* options: [
|
775 |
+
* { label: 'option 1', value: '1' },
|
776 |
+
* { label: 'option 2', value: '2' },
|
777 |
+
* { label: 'option 3', value: '3' },
|
778 |
+
* ],
|
779 |
+
* });
|
780 |
+
* ```
|
781 |
+
* @example
|
782 |
+
* Creating a select menu using setters and API data:
|
783 |
+
* ```ts
|
784 |
+
* const selectMenu = new StringSelectMenuBuilder({
|
785 |
+
* custom_id: 'a cool select menu',
|
786 |
+
* })
|
787 |
+
* .setMinValues(1)
|
788 |
+
* .addOptions({
|
789 |
+
* label: 'Catchy',
|
790 |
+
* value: 'catch',
|
791 |
+
* });
|
792 |
+
* ```
|
793 |
+
*/
|
794 |
+
constructor(data?: Partial<APIStringSelectComponent>);
|
795 |
+
/**
|
796 |
+
* Adds options to this select menu.
|
797 |
+
*
|
798 |
+
* @param options - The options to add
|
799 |
+
*/
|
800 |
+
addOptions(...options: RestOrArray<APISelectMenuOption | StringSelectMenuOptionBuilder>): this;
|
801 |
+
/**
|
802 |
+
* Sets the options for this select menu.
|
803 |
+
*
|
804 |
+
* @param options - The options to set
|
805 |
+
*/
|
806 |
+
setOptions(...options: RestOrArray<APISelectMenuOption | StringSelectMenuOptionBuilder>): this;
|
807 |
+
/**
|
808 |
+
* Removes, replaces, or inserts options for this select menu.
|
809 |
+
*
|
810 |
+
* @remarks
|
811 |
+
* This method behaves similarly
|
812 |
+
* to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | Array.prototype.splice()}.
|
813 |
+
* It's useful for modifying and adjusting the order of existing options.
|
814 |
+
* @example
|
815 |
+
* Remove the first option:
|
816 |
+
* ```ts
|
817 |
+
* selectMenu.spliceOptions(0, 1);
|
818 |
+
* ```
|
819 |
+
* @example
|
820 |
+
* Remove the first n option:
|
821 |
+
* ```ts
|
822 |
+
* const n = 4;
|
823 |
+
* selectMenu.spliceOptions(0, n);
|
824 |
+
* ```
|
825 |
+
* @example
|
826 |
+
* Remove the last option:
|
827 |
+
* ```ts
|
828 |
+
* selectMenu.spliceOptions(-1, 1);
|
829 |
+
* ```
|
830 |
+
* @param index - The index to start at
|
831 |
+
* @param deleteCount - The number of options to remove
|
832 |
+
* @param options - The replacing option objects or builders
|
833 |
+
*/
|
834 |
+
spliceOptions(index: number, deleteCount: number, ...options: RestOrArray<APISelectMenuOption | StringSelectMenuOptionBuilder>): this;
|
835 |
+
/**
|
836 |
+
* {@inheritDoc BaseSelectMenuBuilder.toJSON}
|
837 |
+
*/
|
838 |
+
toJSON(): APIStringSelectComponent;
|
839 |
+
}
|
840 |
+
|
841 |
+
/**
|
842 |
+
* A builder that creates API-compatible JSON data for user select menus.
|
843 |
+
*/
|
844 |
+
declare class UserSelectMenuBuilder extends BaseSelectMenuBuilder<APIUserSelectComponent> {
|
845 |
+
/**
|
846 |
+
* Creates a new select menu from API data.
|
847 |
+
*
|
848 |
+
* @param data - The API data to create this select menu with
|
849 |
+
* @example
|
850 |
+
* Creating a select menu from an API data object:
|
851 |
+
* ```ts
|
852 |
+
* const selectMenu = new UserSelectMenuBuilder({
|
853 |
+
* custom_id: 'a cool select menu',
|
854 |
+
* placeholder: 'select an option',
|
855 |
+
* max_values: 2,
|
856 |
+
* });
|
857 |
+
* ```
|
858 |
+
* @example
|
859 |
+
* Creating a select menu using setters and API data:
|
860 |
+
* ```ts
|
861 |
+
* const selectMenu = new UserSelectMenuBuilder({
|
862 |
+
* custom_id: 'a cool select menu',
|
863 |
+
* })
|
864 |
+
* .setMinValues(1);
|
865 |
+
* ```
|
866 |
+
*/
|
867 |
+
constructor(data?: Partial<APIUserSelectComponent>);
|
868 |
+
/**
|
869 |
+
* Adds default users to this auto populated select menu.
|
870 |
+
*
|
871 |
+
* @param users - The users to add
|
872 |
+
*/
|
873 |
+
addDefaultUsers(...users: RestOrArray<Snowflake>): this;
|
874 |
+
/**
|
875 |
+
* Sets default users to this auto populated select menu.
|
876 |
+
*
|
877 |
+
* @param users - The users to set
|
878 |
+
*/
|
879 |
+
setDefaultUsers(...users: RestOrArray<Snowflake>): this;
|
880 |
+
}
|
881 |
+
|
882 |
+
/**
|
883 |
+
* A builder that creates API-compatible JSON data for text inputs.
|
884 |
+
*/
|
885 |
+
declare class TextInputBuilder extends ComponentBuilder<APITextInputComponent> implements Equatable<APITextInputComponent | JSONEncodable<APITextInputComponent>> {
|
886 |
+
/**
|
887 |
+
* Creates a new text input from API data.
|
888 |
+
*
|
889 |
+
* @param data - The API data to create this text input with
|
890 |
+
* @example
|
891 |
+
* Creating a select menu option from an API data object:
|
892 |
+
* ```ts
|
893 |
+
* const textInput = new TextInputBuilder({
|
894 |
+
* custom_id: 'a cool select menu',
|
895 |
+
* label: 'Type something',
|
896 |
+
* style: TextInputStyle.Short,
|
897 |
+
* });
|
898 |
+
* ```
|
899 |
+
* @example
|
900 |
+
* Creating a select menu option using setters and API data:
|
901 |
+
* ```ts
|
902 |
+
* const textInput = new TextInputBuilder({
|
903 |
+
* label: 'Type something else',
|
904 |
+
* })
|
905 |
+
* .setCustomId('woah')
|
906 |
+
* .setStyle(TextInputStyle.Paragraph);
|
907 |
+
* ```
|
908 |
+
*/
|
909 |
+
constructor(data?: APITextInputComponent & {
|
910 |
+
type?: ComponentType.TextInput;
|
911 |
+
});
|
912 |
+
/**
|
913 |
+
* Sets the custom id for this text input.
|
914 |
+
*
|
915 |
+
* @param customId - The custom id to use
|
916 |
+
*/
|
917 |
+
setCustomId(customId: string): this;
|
918 |
+
/**
|
919 |
+
* Sets the label for this text input.
|
920 |
+
*
|
921 |
+
* @param label - The label to use
|
922 |
+
*/
|
923 |
+
setLabel(label: string): this;
|
924 |
+
/**
|
925 |
+
* Sets the style for this text input.
|
926 |
+
*
|
927 |
+
* @param style - The style to use
|
928 |
+
*/
|
929 |
+
setStyle(style: TextInputStyle): this;
|
930 |
+
/**
|
931 |
+
* Sets the minimum length of text for this text input.
|
932 |
+
*
|
933 |
+
* @param minLength - The minimum length of text for this text input
|
934 |
+
*/
|
935 |
+
setMinLength(minLength: number): this;
|
936 |
+
/**
|
937 |
+
* Sets the maximum length of text for this text input.
|
938 |
+
*
|
939 |
+
* @param maxLength - The maximum length of text for this text input
|
940 |
+
*/
|
941 |
+
setMaxLength(maxLength: number): this;
|
942 |
+
/**
|
943 |
+
* Sets the placeholder for this text input.
|
944 |
+
*
|
945 |
+
* @param placeholder - The placeholder to use
|
946 |
+
*/
|
947 |
+
setPlaceholder(placeholder: string): this;
|
948 |
+
/**
|
949 |
+
* Sets the value for this text input.
|
950 |
+
*
|
951 |
+
* @param value - The value to use
|
952 |
+
*/
|
953 |
+
setValue(value: string): this;
|
954 |
+
/**
|
955 |
+
* Sets whether this text input is required.
|
956 |
+
*
|
957 |
+
* @param required - Whether this text input is required
|
958 |
+
*/
|
959 |
+
setRequired(required?: boolean): this;
|
960 |
+
/**
|
961 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
962 |
+
*/
|
963 |
+
toJSON(): APITextInputComponent;
|
964 |
+
/**
|
965 |
+
* {@inheritDoc Equatable.equals}
|
966 |
+
*/
|
967 |
+
equals(other: APITextInputComponent | JSONEncodable<APITextInputComponent>): boolean;
|
968 |
+
}
|
969 |
+
|
970 |
+
/**
|
971 |
+
* The builders that may be used for messages.
|
972 |
+
*/
|
973 |
+
type MessageComponentBuilder = ActionRowBuilder<MessageActionRowComponentBuilder> | MessageActionRowComponentBuilder;
|
974 |
+
/**
|
975 |
+
* The builders that may be used for modals.
|
976 |
+
*/
|
977 |
+
type ModalComponentBuilder = ActionRowBuilder<ModalActionRowComponentBuilder> | ModalActionRowComponentBuilder;
|
978 |
+
/**
|
979 |
+
* The builders that may be used within an action row for messages.
|
980 |
+
*/
|
981 |
+
type MessageActionRowComponentBuilder = ButtonBuilder | ChannelSelectMenuBuilder | MentionableSelectMenuBuilder | RoleSelectMenuBuilder | StringSelectMenuBuilder | UserSelectMenuBuilder;
|
982 |
+
/**
|
983 |
+
* The builders that may be used within an action row for modals.
|
984 |
+
*/
|
985 |
+
type ModalActionRowComponentBuilder = TextInputBuilder;
|
986 |
+
/**
|
987 |
+
* Any builder.
|
988 |
+
*/
|
989 |
+
type AnyComponentBuilder = MessageActionRowComponentBuilder | ModalActionRowComponentBuilder;
|
990 |
+
/**
|
991 |
+
* A builder that creates API-compatible JSON data for action rows.
|
992 |
+
*
|
993 |
+
* @typeParam ComponentType - The types of components this action row holds
|
994 |
+
*/
|
995 |
+
declare class ActionRowBuilder<ComponentType extends AnyComponentBuilder> extends ComponentBuilder<APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>> {
|
996 |
+
/**
|
997 |
+
* The components within this action row.
|
998 |
+
*/
|
999 |
+
readonly components: ComponentType[];
|
1000 |
+
/**
|
1001 |
+
* Creates a new action row from API data.
|
1002 |
+
*
|
1003 |
+
* @param data - The API data to create this action row with
|
1004 |
+
* @example
|
1005 |
+
* Creating an action row from an API data object:
|
1006 |
+
* ```ts
|
1007 |
+
* const actionRow = new ActionRowBuilder({
|
1008 |
+
* components: [
|
1009 |
+
* {
|
1010 |
+
* custom_id: "custom id",
|
1011 |
+
* label: "Type something",
|
1012 |
+
* style: TextInputStyle.Short,
|
1013 |
+
* type: ComponentType.TextInput,
|
1014 |
+
* },
|
1015 |
+
* ],
|
1016 |
+
* });
|
1017 |
+
* ```
|
1018 |
+
* @example
|
1019 |
+
* Creating an action row using setters and API data:
|
1020 |
+
* ```ts
|
1021 |
+
* const actionRow = new ActionRowBuilder({
|
1022 |
+
* components: [
|
1023 |
+
* {
|
1024 |
+
* custom_id: "custom id",
|
1025 |
+
* label: "Click me",
|
1026 |
+
* style: ButtonStyle.Primary,
|
1027 |
+
* type: ComponentType.Button,
|
1028 |
+
* },
|
1029 |
+
* ],
|
1030 |
+
* })
|
1031 |
+
* .addComponents(button2, button3);
|
1032 |
+
* ```
|
1033 |
+
*/
|
1034 |
+
constructor({ components, ...data }?: Partial<APIActionRowComponent<APIActionRowComponentTypes>>);
|
1035 |
+
/**
|
1036 |
+
* Adds components to this action row.
|
1037 |
+
*
|
1038 |
+
* @param components - The components to add
|
1039 |
+
*/
|
1040 |
+
addComponents(...components: RestOrArray<ComponentType>): this;
|
1041 |
+
/**
|
1042 |
+
* Sets components for this action row.
|
1043 |
+
*
|
1044 |
+
* @param components - The components to set
|
1045 |
+
*/
|
1046 |
+
setComponents(...components: RestOrArray<ComponentType>): this;
|
1047 |
+
/**
|
1048 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
1049 |
+
*/
|
1050 |
+
toJSON(): APIActionRowComponent<ReturnType<ComponentType['toJSON']>>;
|
1051 |
+
}
|
1052 |
+
|
1053 |
+
/**
|
1054 |
+
* Components here are mapped to their respective builder.
|
1055 |
+
*/
|
1056 |
+
interface MappedComponentTypes {
|
1057 |
+
/**
|
1058 |
+
* The action row component type is associated with an {@link ActionRowBuilder}.
|
1059 |
+
*/
|
1060 |
+
[ComponentType.ActionRow]: ActionRowBuilder<AnyComponentBuilder>;
|
1061 |
+
/**
|
1062 |
+
* The button component type is associated with an {@link ButtonBuilder}.
|
1063 |
+
*/
|
1064 |
+
[ComponentType.Button]: ButtonBuilder;
|
1065 |
+
/**
|
1066 |
+
* The string select component type is associated with an {@link StringSelectMenuBuilder}.
|
1067 |
+
*/
|
1068 |
+
[ComponentType.StringSelect]: StringSelectMenuBuilder;
|
1069 |
+
/**
|
1070 |
+
* The text inpiut component type is associated with an {@link TextInputBuilder}.
|
1071 |
+
*/
|
1072 |
+
[ComponentType.TextInput]: TextInputBuilder;
|
1073 |
+
/**
|
1074 |
+
* The user select component type is associated with an {@link UserSelectMenuBuilder}.
|
1075 |
+
*/
|
1076 |
+
[ComponentType.UserSelect]: UserSelectMenuBuilder;
|
1077 |
+
/**
|
1078 |
+
* The role select component type is associated with an {@link RoleSelectMenuBuilder}.
|
1079 |
+
*/
|
1080 |
+
[ComponentType.RoleSelect]: RoleSelectMenuBuilder;
|
1081 |
+
/**
|
1082 |
+
* The mentionable select component type is associated with an {@link MentionableSelectMenuBuilder}.
|
1083 |
+
*/
|
1084 |
+
[ComponentType.MentionableSelect]: MentionableSelectMenuBuilder;
|
1085 |
+
/**
|
1086 |
+
* The channel select component type is associated with an {@link ChannelSelectMenuBuilder}.
|
1087 |
+
*/
|
1088 |
+
[ComponentType.ChannelSelect]: ChannelSelectMenuBuilder;
|
1089 |
+
}
|
1090 |
+
/**
|
1091 |
+
* Factory for creating components from API data.
|
1092 |
+
*
|
1093 |
+
* @typeParam ComponentType - The type of component to use
|
1094 |
+
* @param data - The API data to transform to a component class
|
1095 |
+
*/
|
1096 |
+
declare function createComponentBuilder<ComponentType extends keyof MappedComponentTypes>(data: (APIModalComponent | APIMessageComponent) & {
|
1097 |
+
type: ComponentType;
|
1098 |
+
}): MappedComponentTypes[ComponentType];
|
1099 |
+
/**
|
1100 |
+
* Factory for creating components from API data.
|
1101 |
+
*
|
1102 |
+
* @typeParam ComponentBuilder - The type of component to use
|
1103 |
+
* @param data - The API data to transform to a component class
|
1104 |
+
*/
|
1105 |
+
declare function createComponentBuilder<ComponentBuilder extends MessageComponentBuilder | ModalComponentBuilder>(data: ComponentBuilder): ComponentBuilder;
|
1106 |
+
|
1107 |
+
declare const textInputStyleValidator: _sapphire_shapeshift.NativeEnumValidator<typeof TextInputStyle>;
|
1108 |
+
declare const minLengthValidator: _sapphire_shapeshift.NumberValidator<number>;
|
1109 |
+
declare const maxLengthValidator: _sapphire_shapeshift.NumberValidator<number>;
|
1110 |
+
declare const requiredValidator: _sapphire_shapeshift.BooleanValidator<boolean>;
|
1111 |
+
declare const valueValidator: _sapphire_shapeshift.StringValidator<string>;
|
1112 |
+
declare const placeholderValidator: _sapphire_shapeshift.StringValidator<string>;
|
1113 |
+
declare const labelValidator: _sapphire_shapeshift.StringValidator<string>;
|
1114 |
+
declare function validateRequiredParameters$3(customId?: string, style?: TextInputStyle, label?: string): void;
|
1115 |
+
|
1116 |
+
declare const Assertions$3_labelValidator: typeof labelValidator;
|
1117 |
+
declare const Assertions$3_maxLengthValidator: typeof maxLengthValidator;
|
1118 |
+
declare const Assertions$3_minLengthValidator: typeof minLengthValidator;
|
1119 |
+
declare const Assertions$3_placeholderValidator: typeof placeholderValidator;
|
1120 |
+
declare const Assertions$3_requiredValidator: typeof requiredValidator;
|
1121 |
+
declare const Assertions$3_textInputStyleValidator: typeof textInputStyleValidator;
|
1122 |
+
declare const Assertions$3_valueValidator: typeof valueValidator;
|
1123 |
+
declare namespace Assertions$3 {
|
1124 |
+
export {
|
1125 |
+
Assertions$3_labelValidator as labelValidator,
|
1126 |
+
Assertions$3_maxLengthValidator as maxLengthValidator,
|
1127 |
+
Assertions$3_minLengthValidator as minLengthValidator,
|
1128 |
+
Assertions$3_placeholderValidator as placeholderValidator,
|
1129 |
+
Assertions$3_requiredValidator as requiredValidator,
|
1130 |
+
Assertions$3_textInputStyleValidator as textInputStyleValidator,
|
1131 |
+
validateRequiredParameters$3 as validateRequiredParameters,
|
1132 |
+
Assertions$3_valueValidator as valueValidator,
|
1133 |
+
};
|
1134 |
+
}
|
1135 |
+
|
1136 |
+
/**
|
1137 |
+
* A builder that creates API-compatible JSON data for modals.
|
1138 |
+
*/
|
1139 |
+
declare class ModalBuilder implements JSONEncodable<APIModalInteractionResponseCallbackData> {
|
1140 |
+
/**
|
1141 |
+
* The API data associated with this modal.
|
1142 |
+
*/
|
1143 |
+
readonly data: Partial<APIModalInteractionResponseCallbackData>;
|
1144 |
+
/**
|
1145 |
+
* The components within this modal.
|
1146 |
+
*/
|
1147 |
+
readonly components: ActionRowBuilder<ModalActionRowComponentBuilder>[];
|
1148 |
+
/**
|
1149 |
+
* Creates a new modal from API data.
|
1150 |
+
*
|
1151 |
+
* @param data - The API data to create this modal with
|
1152 |
+
*/
|
1153 |
+
constructor({ components, ...data }?: Partial<APIModalInteractionResponseCallbackData>);
|
1154 |
+
/**
|
1155 |
+
* Sets the title of this modal.
|
1156 |
+
*
|
1157 |
+
* @param title - The title to use
|
1158 |
+
*/
|
1159 |
+
setTitle(title: string): this;
|
1160 |
+
/**
|
1161 |
+
* Sets the custom id of this modal.
|
1162 |
+
*
|
1163 |
+
* @param customId - The custom id to use
|
1164 |
+
*/
|
1165 |
+
setCustomId(customId: string): this;
|
1166 |
+
/**
|
1167 |
+
* Adds components to this modal.
|
1168 |
+
*
|
1169 |
+
* @param components - The components to add
|
1170 |
+
*/
|
1171 |
+
addComponents(...components: RestOrArray<ActionRowBuilder<ModalActionRowComponentBuilder> | APIActionRowComponent<APIModalActionRowComponent>>): this;
|
1172 |
+
/**
|
1173 |
+
* Sets components for this modal.
|
1174 |
+
*
|
1175 |
+
* @param components - The components to set
|
1176 |
+
*/
|
1177 |
+
setComponents(...components: RestOrArray<ActionRowBuilder<ModalActionRowComponentBuilder>>): this;
|
1178 |
+
/**
|
1179 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
1180 |
+
*/
|
1181 |
+
toJSON(): APIModalInteractionResponseCallbackData;
|
1182 |
+
}
|
1183 |
+
|
1184 |
+
declare const titleValidator: _sapphire_shapeshift.StringValidator<string>;
|
1185 |
+
declare const componentsValidator: _sapphire_shapeshift.ArrayValidator<[ActionRowBuilder<AnyComponentBuilder>, ...ActionRowBuilder<AnyComponentBuilder>[]], ActionRowBuilder<AnyComponentBuilder>>;
|
1186 |
+
declare function validateRequiredParameters$2(customId?: string, title?: string, components?: ActionRowBuilder<ModalActionRowComponentBuilder>[]): void;
|
1187 |
+
|
1188 |
+
declare const Assertions$2_componentsValidator: typeof componentsValidator;
|
1189 |
+
declare const Assertions$2_titleValidator: typeof titleValidator;
|
1190 |
+
declare namespace Assertions$2 {
|
1191 |
+
export {
|
1192 |
+
Assertions$2_componentsValidator as componentsValidator,
|
1193 |
+
Assertions$2_titleValidator as titleValidator,
|
1194 |
+
validateRequiredParameters$2 as validateRequiredParameters,
|
1195 |
+
};
|
1196 |
+
}
|
1197 |
+
|
1198 |
+
/**
|
1199 |
+
* This mixin holds name and description symbols for slash commands.
|
1200 |
+
*/
|
1201 |
+
declare class SharedNameAndDescription {
|
1202 |
+
/**
|
1203 |
+
* The name of this command.
|
1204 |
+
*/
|
1205 |
+
readonly name: string;
|
1206 |
+
/**
|
1207 |
+
* The name localizations of this command.
|
1208 |
+
*/
|
1209 |
+
readonly name_localizations?: LocalizationMap;
|
1210 |
+
/**
|
1211 |
+
* The description of this command.
|
1212 |
+
*/
|
1213 |
+
readonly description: string;
|
1214 |
+
/**
|
1215 |
+
* The description localizations of this command.
|
1216 |
+
*/
|
1217 |
+
readonly description_localizations?: LocalizationMap;
|
1218 |
+
/**
|
1219 |
+
* Sets the name of this command.
|
1220 |
+
*
|
1221 |
+
* @param name - The name to use
|
1222 |
+
*/
|
1223 |
+
setName(name: string): this;
|
1224 |
+
/**
|
1225 |
+
* Sets the description of this command.
|
1226 |
+
*
|
1227 |
+
* @param description - The description to use
|
1228 |
+
*/
|
1229 |
+
setDescription(description: string): this;
|
1230 |
+
/**
|
1231 |
+
* Sets a name localization for this command.
|
1232 |
+
*
|
1233 |
+
* @param locale - The locale to set
|
1234 |
+
* @param localizedName - The localized name for the given `locale`
|
1235 |
+
*/
|
1236 |
+
setNameLocalization(locale: LocaleString, localizedName: string | null): this;
|
1237 |
+
/**
|
1238 |
+
* Sets the name localizations for this command.
|
1239 |
+
*
|
1240 |
+
* @param localizedNames - The object of localized names to set
|
1241 |
+
*/
|
1242 |
+
setNameLocalizations(localizedNames: LocalizationMap | null): this;
|
1243 |
+
/**
|
1244 |
+
* Sets a description localization for this command.
|
1245 |
+
*
|
1246 |
+
* @param locale - The locale to set
|
1247 |
+
* @param localizedDescription - The localized description for the given locale
|
1248 |
+
*/
|
1249 |
+
setDescriptionLocalization(locale: LocaleString, localizedDescription: string | null): this;
|
1250 |
+
/**
|
1251 |
+
* Sets the description localizations for this command.
|
1252 |
+
*
|
1253 |
+
* @param localizedDescriptions - The object of localized descriptions to set
|
1254 |
+
*/
|
1255 |
+
setDescriptionLocalizations(localizedDescriptions: LocalizationMap | null): this;
|
1256 |
+
}
|
1257 |
+
|
1258 |
+
/**
|
1259 |
+
* The base application command option builder that contains common symbols for application command builders.
|
1260 |
+
*/
|
1261 |
+
declare abstract class ApplicationCommandOptionBase extends SharedNameAndDescription {
|
1262 |
+
/**
|
1263 |
+
* The type of this option.
|
1264 |
+
*/
|
1265 |
+
abstract readonly type: ApplicationCommandOptionType;
|
1266 |
+
/**
|
1267 |
+
* Whether this option is required.
|
1268 |
+
*
|
1269 |
+
* @defaultValue `false`
|
1270 |
+
*/
|
1271 |
+
readonly required: boolean;
|
1272 |
+
/**
|
1273 |
+
* Sets whether this option is required.
|
1274 |
+
*
|
1275 |
+
* @param required - Whether this option should be required
|
1276 |
+
*/
|
1277 |
+
setRequired(required: boolean): this;
|
1278 |
+
/**
|
1279 |
+
* Serializes this builder to API-compatible JSON data.
|
1280 |
+
*
|
1281 |
+
* @remarks
|
1282 |
+
* This method runs validations on the data before serializing it.
|
1283 |
+
* As such, it may throw an error if the data is invalid.
|
1284 |
+
*/
|
1285 |
+
abstract toJSON(): APIApplicationCommandBasicOption;
|
1286 |
+
/**
|
1287 |
+
* This method runs required validators on this builder.
|
1288 |
+
*/
|
1289 |
+
protected runRequiredValidations(): void;
|
1290 |
+
}
|
1291 |
+
|
1292 |
+
/**
|
1293 |
+
* A slash command attachment option.
|
1294 |
+
*/
|
1295 |
+
declare class SlashCommandAttachmentOption extends ApplicationCommandOptionBase {
|
1296 |
+
/**
|
1297 |
+
* The type of this option.
|
1298 |
+
*/
|
1299 |
+
readonly type: ApplicationCommandOptionType.Attachment;
|
1300 |
+
/**
|
1301 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1302 |
+
*/
|
1303 |
+
toJSON(): APIApplicationCommandAttachmentOption;
|
1304 |
+
}
|
1305 |
+
|
1306 |
+
/**
|
1307 |
+
* A slash command boolean option.
|
1308 |
+
*/
|
1309 |
+
declare class SlashCommandBooleanOption extends ApplicationCommandOptionBase {
|
1310 |
+
/**
|
1311 |
+
* The type of this option.
|
1312 |
+
*/
|
1313 |
+
readonly type: ApplicationCommandOptionType.Boolean;
|
1314 |
+
/**
|
1315 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1316 |
+
*/
|
1317 |
+
toJSON(): APIApplicationCommandBooleanOption;
|
1318 |
+
}
|
1319 |
+
|
1320 |
+
/**
|
1321 |
+
* The allowed channel types used for a channel option in a slash command builder.
|
1322 |
+
*
|
1323 |
+
* @privateRemarks This can't be dynamic because const enums are erased at runtime.
|
1324 |
+
* @internal
|
1325 |
+
*/
|
1326 |
+
declare const allowedChannelTypes: readonly [ChannelType.GuildText, ChannelType.GuildVoice, ChannelType.GuildCategory, ChannelType.GuildAnnouncement, ChannelType.AnnouncementThread, ChannelType.PublicThread, ChannelType.PrivateThread, ChannelType.GuildStageVoice, ChannelType.GuildForum, ChannelType.GuildMedia];
|
1327 |
+
/**
|
1328 |
+
* The type of allowed channel types used for a channel option.
|
1329 |
+
*/
|
1330 |
+
type ApplicationCommandOptionAllowedChannelTypes = (typeof allowedChannelTypes)[number];
|
1331 |
+
/**
|
1332 |
+
* This mixin holds channel type symbols used for options.
|
1333 |
+
*/
|
1334 |
+
declare class ApplicationCommandOptionChannelTypesMixin {
|
1335 |
+
/**
|
1336 |
+
* The channel types of this option.
|
1337 |
+
*/
|
1338 |
+
readonly channel_types?: ApplicationCommandOptionAllowedChannelTypes[];
|
1339 |
+
/**
|
1340 |
+
* Adds channel types to this option.
|
1341 |
+
*
|
1342 |
+
* @param channelTypes - The channel types
|
1343 |
+
*/
|
1344 |
+
addChannelTypes(...channelTypes: ApplicationCommandOptionAllowedChannelTypes[]): this;
|
1345 |
+
}
|
1346 |
+
|
1347 |
+
/**
|
1348 |
+
* A slash command channel option.
|
1349 |
+
*/
|
1350 |
+
declare class SlashCommandChannelOption extends ApplicationCommandOptionBase {
|
1351 |
+
/**
|
1352 |
+
* The type of this option.
|
1353 |
+
*/
|
1354 |
+
readonly type: ApplicationCommandOptionType.Channel;
|
1355 |
+
/**
|
1356 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1357 |
+
*/
|
1358 |
+
toJSON(): APIApplicationCommandChannelOption;
|
1359 |
+
}
|
1360 |
+
interface SlashCommandChannelOption extends ApplicationCommandOptionChannelTypesMixin {
|
1361 |
+
}
|
1362 |
+
|
1363 |
+
/**
|
1364 |
+
* This mixin holds minimum and maximum symbols used for options.
|
1365 |
+
*/
|
1366 |
+
declare abstract class ApplicationCommandNumericOptionMinMaxValueMixin {
|
1367 |
+
/**
|
1368 |
+
* The maximum value of this option.
|
1369 |
+
*/
|
1370 |
+
readonly max_value?: number;
|
1371 |
+
/**
|
1372 |
+
* The minimum value of this option.
|
1373 |
+
*/
|
1374 |
+
readonly min_value?: number;
|
1375 |
+
/**
|
1376 |
+
* Sets the maximum number value of this option.
|
1377 |
+
*
|
1378 |
+
* @param max - The maximum value this option can be
|
1379 |
+
*/
|
1380 |
+
abstract setMaxValue(max: number): this;
|
1381 |
+
/**
|
1382 |
+
* Sets the minimum number value of this option.
|
1383 |
+
*
|
1384 |
+
* @param min - The minimum value this option can be
|
1385 |
+
*/
|
1386 |
+
abstract setMinValue(min: number): this;
|
1387 |
+
}
|
1388 |
+
|
1389 |
+
/**
|
1390 |
+
* This mixin holds choices and autocomplete symbols used for options.
|
1391 |
+
*/
|
1392 |
+
declare class ApplicationCommandOptionWithChoicesAndAutocompleteMixin<ChoiceType extends number | string> {
|
1393 |
+
/**
|
1394 |
+
* The choices of this option.
|
1395 |
+
*/
|
1396 |
+
readonly choices?: APIApplicationCommandOptionChoice<ChoiceType>[];
|
1397 |
+
/**
|
1398 |
+
* Whether this option utilizes autocomplete.
|
1399 |
+
*/
|
1400 |
+
readonly autocomplete?: boolean;
|
1401 |
+
/**
|
1402 |
+
* The type of this option.
|
1403 |
+
*
|
1404 |
+
* @privateRemarks Since this is present and this is a mixin, this is needed.
|
1405 |
+
*/
|
1406 |
+
readonly type: ApplicationCommandOptionType;
|
1407 |
+
/**
|
1408 |
+
* Adds multiple choices to this option.
|
1409 |
+
*
|
1410 |
+
* @param choices - The choices to add
|
1411 |
+
*/
|
1412 |
+
addChoices(...choices: APIApplicationCommandOptionChoice<ChoiceType>[]): this;
|
1413 |
+
/**
|
1414 |
+
* Sets multiple choices for this option.
|
1415 |
+
*
|
1416 |
+
* @param choices - The choices to set
|
1417 |
+
*/
|
1418 |
+
setChoices<Input extends APIApplicationCommandOptionChoice<ChoiceType>[]>(...choices: Input): this;
|
1419 |
+
/**
|
1420 |
+
* Whether this option uses autocomplete.
|
1421 |
+
*
|
1422 |
+
* @param autocomplete - Whether this option should use autocomplete
|
1423 |
+
*/
|
1424 |
+
setAutocomplete(autocomplete: boolean): this;
|
1425 |
+
}
|
1426 |
+
|
1427 |
+
/**
|
1428 |
+
* A slash command integer option.
|
1429 |
+
*/
|
1430 |
+
declare class SlashCommandIntegerOption extends ApplicationCommandOptionBase implements ApplicationCommandNumericOptionMinMaxValueMixin {
|
1431 |
+
/**
|
1432 |
+
* The type of this option.
|
1433 |
+
*/
|
1434 |
+
readonly type: ApplicationCommandOptionType.Integer;
|
1435 |
+
/**
|
1436 |
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}
|
1437 |
+
*/
|
1438 |
+
setMaxValue(max: number): this;
|
1439 |
+
/**
|
1440 |
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMinValue}
|
1441 |
+
*/
|
1442 |
+
setMinValue(min: number): this;
|
1443 |
+
/**
|
1444 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1445 |
+
*/
|
1446 |
+
toJSON(): APIApplicationCommandIntegerOption;
|
1447 |
+
}
|
1448 |
+
interface SlashCommandIntegerOption extends ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin<number> {
|
1449 |
+
}
|
1450 |
+
|
1451 |
+
/**
|
1452 |
+
* A slash command mentionable option.
|
1453 |
+
*/
|
1454 |
+
declare class SlashCommandMentionableOption extends ApplicationCommandOptionBase {
|
1455 |
+
/**
|
1456 |
+
* The type of this option.
|
1457 |
+
*/
|
1458 |
+
readonly type: ApplicationCommandOptionType.Mentionable;
|
1459 |
+
/**
|
1460 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1461 |
+
*/
|
1462 |
+
toJSON(): APIApplicationCommandMentionableOption;
|
1463 |
+
}
|
1464 |
+
|
1465 |
+
/**
|
1466 |
+
* A slash command number option.
|
1467 |
+
*/
|
1468 |
+
declare class SlashCommandNumberOption extends ApplicationCommandOptionBase implements ApplicationCommandNumericOptionMinMaxValueMixin {
|
1469 |
+
/**
|
1470 |
+
* The type of this option.
|
1471 |
+
*/
|
1472 |
+
readonly type: ApplicationCommandOptionType.Number;
|
1473 |
+
/**
|
1474 |
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}
|
1475 |
+
*/
|
1476 |
+
setMaxValue(max: number): this;
|
1477 |
+
/**
|
1478 |
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMinValue}
|
1479 |
+
*/
|
1480 |
+
setMinValue(min: number): this;
|
1481 |
+
/**
|
1482 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1483 |
+
*/
|
1484 |
+
toJSON(): APIApplicationCommandNumberOption;
|
1485 |
+
}
|
1486 |
+
interface SlashCommandNumberOption extends ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin<number> {
|
1487 |
+
}
|
1488 |
+
|
1489 |
+
/**
|
1490 |
+
* A slash command role option.
|
1491 |
+
*/
|
1492 |
+
declare class SlashCommandRoleOption extends ApplicationCommandOptionBase {
|
1493 |
+
/**
|
1494 |
+
* The type of this option.
|
1495 |
+
*/
|
1496 |
+
readonly type: ApplicationCommandOptionType.Role;
|
1497 |
+
/**
|
1498 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1499 |
+
*/
|
1500 |
+
toJSON(): APIApplicationCommandRoleOption;
|
1501 |
+
}
|
1502 |
+
|
1503 |
+
/**
|
1504 |
+
* A slash command string option.
|
1505 |
+
*/
|
1506 |
+
declare class SlashCommandStringOption extends ApplicationCommandOptionBase {
|
1507 |
+
/**
|
1508 |
+
* The type of this option.
|
1509 |
+
*/
|
1510 |
+
readonly type: ApplicationCommandOptionType.String;
|
1511 |
+
/**
|
1512 |
+
* The maximum length of this option.
|
1513 |
+
*/
|
1514 |
+
readonly max_length?: number;
|
1515 |
+
/**
|
1516 |
+
* The minimum length of this option.
|
1517 |
+
*/
|
1518 |
+
readonly min_length?: number;
|
1519 |
+
/**
|
1520 |
+
* Sets the maximum length of this string option.
|
1521 |
+
*
|
1522 |
+
* @param max - The maximum length this option can be
|
1523 |
+
*/
|
1524 |
+
setMaxLength(max: number): this;
|
1525 |
+
/**
|
1526 |
+
* Sets the minimum length of this string option.
|
1527 |
+
*
|
1528 |
+
* @param min - The minimum length this option can be
|
1529 |
+
*/
|
1530 |
+
setMinLength(min: number): this;
|
1531 |
+
/**
|
1532 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1533 |
+
*/
|
1534 |
+
toJSON(): APIApplicationCommandStringOption;
|
1535 |
+
}
|
1536 |
+
interface SlashCommandStringOption extends ApplicationCommandOptionWithChoicesAndAutocompleteMixin<string> {
|
1537 |
+
}
|
1538 |
+
|
1539 |
+
/**
|
1540 |
+
* A slash command user option.
|
1541 |
+
*/
|
1542 |
+
declare class SlashCommandUserOption extends ApplicationCommandOptionBase {
|
1543 |
+
/**
|
1544 |
+
* The type of this option.
|
1545 |
+
*/
|
1546 |
+
readonly type: ApplicationCommandOptionType.User;
|
1547 |
+
/**
|
1548 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1549 |
+
*/
|
1550 |
+
toJSON(): APIApplicationCommandUserOption;
|
1551 |
+
}
|
1552 |
+
|
1553 |
+
/**
|
1554 |
+
* This mixin holds symbols that can be shared in slash command options.
|
1555 |
+
*
|
1556 |
+
* @typeParam ShouldOmitSubcommandFunctions - Whether to omit subcommand functions.
|
1557 |
+
*/
|
1558 |
+
declare class SharedSlashCommandOptions<ShouldOmitSubcommandFunctions = true> {
|
1559 |
+
readonly options: ToAPIApplicationCommandOptions[];
|
1560 |
+
/**
|
1561 |
+
* Adds a boolean option.
|
1562 |
+
*
|
1563 |
+
* @param input - A function that returns an option builder or an already built builder
|
1564 |
+
*/
|
1565 |
+
addBooleanOption(input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
|
1566 |
+
/**
|
1567 |
+
* Adds a user option.
|
1568 |
+
*
|
1569 |
+
* @param input - A function that returns an option builder or an already built builder
|
1570 |
+
*/
|
1571 |
+
addUserOption(input: SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
|
1572 |
+
/**
|
1573 |
+
* Adds a channel option.
|
1574 |
+
*
|
1575 |
+
* @param input - A function that returns an option builder or an already built builder
|
1576 |
+
*/
|
1577 |
+
addChannelOption(input: SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
|
1578 |
+
/**
|
1579 |
+
* Adds a role option.
|
1580 |
+
*
|
1581 |
+
* @param input - A function that returns an option builder or an already built builder
|
1582 |
+
*/
|
1583 |
+
addRoleOption(input: SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
|
1584 |
+
/**
|
1585 |
+
* Adds an attachment option.
|
1586 |
+
*
|
1587 |
+
* @param input - A function that returns an option builder or an already built builder
|
1588 |
+
*/
|
1589 |
+
addAttachmentOption(input: SlashCommandAttachmentOption | ((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
|
1590 |
+
/**
|
1591 |
+
* Adds a mentionable option.
|
1592 |
+
*
|
1593 |
+
* @param input - A function that returns an option builder or an already built builder
|
1594 |
+
*/
|
1595 |
+
addMentionableOption(input: SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
|
1596 |
+
/**
|
1597 |
+
* Adds a string option.
|
1598 |
+
*
|
1599 |
+
* @param input - A function that returns an option builder or an already built builder
|
1600 |
+
*/
|
1601 |
+
addStringOption(input: Omit<SlashCommandStringOption, 'addChoices'> | Omit<SlashCommandStringOption, 'setAutocomplete'> | SlashCommandStringOption | ((builder: SlashCommandStringOption) => Omit<SlashCommandStringOption, 'addChoices'> | Omit<SlashCommandStringOption, 'setAutocomplete'> | SlashCommandStringOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
|
1602 |
+
/**
|
1603 |
+
* Adds an integer option.
|
1604 |
+
*
|
1605 |
+
* @param input - A function that returns an option builder or an already built builder
|
1606 |
+
*/
|
1607 |
+
addIntegerOption(input: Omit<SlashCommandIntegerOption, 'addChoices'> | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | SlashCommandIntegerOption | ((builder: SlashCommandIntegerOption) => Omit<SlashCommandIntegerOption, 'addChoices'> | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | SlashCommandIntegerOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
|
1608 |
+
/**
|
1609 |
+
* Adds a number option.
|
1610 |
+
*
|
1611 |
+
* @param input - A function that returns an option builder or an already built builder
|
1612 |
+
*/
|
1613 |
+
addNumberOption(input: Omit<SlashCommandNumberOption, 'addChoices'> | Omit<SlashCommandNumberOption, 'setAutocomplete'> | SlashCommandNumberOption | ((builder: SlashCommandNumberOption) => Omit<SlashCommandNumberOption, 'addChoices'> | Omit<SlashCommandNumberOption, 'setAutocomplete'> | SlashCommandNumberOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
|
1614 |
+
/**
|
1615 |
+
* Where the actual adding magic happens. ✨
|
1616 |
+
*
|
1617 |
+
* @param input - The input. What else?
|
1618 |
+
* @param Instance - The instance of whatever is being added
|
1619 |
+
* @internal
|
1620 |
+
*/
|
1621 |
+
private _sharedAddOptionMethod;
|
1622 |
+
}
|
1623 |
+
|
1624 |
+
/**
|
1625 |
+
* Represents a folder for subcommands.
|
1626 |
+
*
|
1627 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups}
|
1628 |
+
*/
|
1629 |
+
declare class SlashCommandSubcommandGroupBuilder implements ToAPIApplicationCommandOptions {
|
1630 |
+
/**
|
1631 |
+
* The name of this subcommand group.
|
1632 |
+
*/
|
1633 |
+
readonly name: string;
|
1634 |
+
/**
|
1635 |
+
* The description of this subcommand group.
|
1636 |
+
*/
|
1637 |
+
readonly description: string;
|
1638 |
+
/**
|
1639 |
+
* The subcommands within this subcommand group.
|
1640 |
+
*/
|
1641 |
+
readonly options: SlashCommandSubcommandBuilder[];
|
1642 |
+
/**
|
1643 |
+
* Adds a new subcommand to this group.
|
1644 |
+
*
|
1645 |
+
* @param input - A function that returns a subcommand builder or an already built builder
|
1646 |
+
*/
|
1647 |
+
addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): this;
|
1648 |
+
/**
|
1649 |
+
* Serializes this builder to API-compatible JSON data.
|
1650 |
+
*
|
1651 |
+
* @remarks
|
1652 |
+
* This method runs validations on the data before serializing it.
|
1653 |
+
* As such, it may throw an error if the data is invalid.
|
1654 |
+
*/
|
1655 |
+
toJSON(): APIApplicationCommandSubcommandGroupOption;
|
1656 |
+
}
|
1657 |
+
interface SlashCommandSubcommandGroupBuilder extends SharedNameAndDescription {
|
1658 |
+
}
|
1659 |
+
/**
|
1660 |
+
* A builder that creates API-compatible JSON data for slash command subcommands.
|
1661 |
+
*
|
1662 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups}
|
1663 |
+
*/
|
1664 |
+
declare class SlashCommandSubcommandBuilder implements ToAPIApplicationCommandOptions {
|
1665 |
+
/**
|
1666 |
+
* The name of this subcommand.
|
1667 |
+
*/
|
1668 |
+
readonly name: string;
|
1669 |
+
/**
|
1670 |
+
* The description of this subcommand.
|
1671 |
+
*/
|
1672 |
+
readonly description: string;
|
1673 |
+
/**
|
1674 |
+
* The options within this subcommand.
|
1675 |
+
*/
|
1676 |
+
readonly options: ApplicationCommandOptionBase[];
|
1677 |
+
/**
|
1678 |
+
* Serializes this builder to API-compatible JSON data.
|
1679 |
+
*
|
1680 |
+
* @remarks
|
1681 |
+
* This method runs validations on the data before serializing it.
|
1682 |
+
* As such, it may throw an error if the data is invalid.
|
1683 |
+
*/
|
1684 |
+
toJSON(): APIApplicationCommandSubcommandOption;
|
1685 |
+
}
|
1686 |
+
interface SlashCommandSubcommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions<false> {
|
1687 |
+
}
|
1688 |
+
|
1689 |
+
/**
|
1690 |
+
* A builder that creates API-compatible JSON data for slash commands.
|
1691 |
+
*/
|
1692 |
+
declare class SlashCommandBuilder {
|
1693 |
+
/**
|
1694 |
+
* The name of this command.
|
1695 |
+
*/
|
1696 |
+
readonly name: string;
|
1697 |
+
/**
|
1698 |
+
* The name localizations of this command.
|
1699 |
+
*/
|
1700 |
+
readonly name_localizations?: LocalizationMap;
|
1701 |
+
/**
|
1702 |
+
* The description of this command.
|
1703 |
+
*/
|
1704 |
+
readonly description: string;
|
1705 |
+
/**
|
1706 |
+
* The description localizations of this command.
|
1707 |
+
*/
|
1708 |
+
readonly description_localizations?: LocalizationMap;
|
1709 |
+
/**
|
1710 |
+
* The options of this command.
|
1711 |
+
*/
|
1712 |
+
readonly options: ToAPIApplicationCommandOptions[];
|
1713 |
+
/**
|
1714 |
+
* Whether this command is enabled by default when the application is added to a guild.
|
1715 |
+
*
|
1716 |
+
* @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
|
1717 |
+
*/
|
1718 |
+
readonly default_permission: boolean | undefined;
|
1719 |
+
/**
|
1720 |
+
* The set of permissions represented as a bit set for the command.
|
1721 |
+
*/
|
1722 |
+
readonly default_member_permissions: Permissions | null | undefined;
|
1723 |
+
/**
|
1724 |
+
* Indicates whether the command is available in direct messages with the application.
|
1725 |
+
*
|
1726 |
+
* @remarks
|
1727 |
+
* By default, commands are visible. This property is only for global commands.
|
1728 |
+
*/
|
1729 |
+
readonly dm_permission: boolean | undefined;
|
1730 |
+
/**
|
1731 |
+
* Whether this command is NSFW.
|
1732 |
+
*/
|
1733 |
+
readonly nsfw: boolean | undefined;
|
1734 |
+
/**
|
1735 |
+
* Sets whether the command is enabled by default when the application is added to a guild.
|
1736 |
+
*
|
1737 |
+
* @remarks
|
1738 |
+
* If set to `false`, you will have to later `PUT` the permissions for this command.
|
1739 |
+
* @param value - Whether or not to enable this command by default
|
1740 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
1741 |
+
* @deprecated Use {@link SlashCommandBuilder.setDefaultMemberPermissions} or {@link SlashCommandBuilder.setDMPermission} instead.
|
1742 |
+
*/
|
1743 |
+
setDefaultPermission(value: boolean): this;
|
1744 |
+
/**
|
1745 |
+
* Sets the default permissions a member should have in order to run the command.
|
1746 |
+
*
|
1747 |
+
* @remarks
|
1748 |
+
* You can set this to `'0'` to disable the command by default.
|
1749 |
+
* @param permissions - The permissions bit field to set
|
1750 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
1751 |
+
*/
|
1752 |
+
setDefaultMemberPermissions(permissions: Permissions | bigint | number | null | undefined): this;
|
1753 |
+
/**
|
1754 |
+
* Sets if the command is available in direct messages with the application.
|
1755 |
+
*
|
1756 |
+
* @remarks
|
1757 |
+
* By default, commands are visible. This method is only for global commands.
|
1758 |
+
* @param enabled - Whether the command should be enabled in direct messages
|
1759 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
1760 |
+
*/
|
1761 |
+
setDMPermission(enabled: boolean | null | undefined): this;
|
1762 |
+
/**
|
1763 |
+
* Sets whether this command is NSFW.
|
1764 |
+
*
|
1765 |
+
* @param nsfw - Whether this command is NSFW
|
1766 |
+
*/
|
1767 |
+
setNSFW(nsfw?: boolean): this;
|
1768 |
+
/**
|
1769 |
+
* Adds a new subcommand group to this command.
|
1770 |
+
*
|
1771 |
+
* @param input - A function that returns a subcommand group builder or an already built builder
|
1772 |
+
*/
|
1773 |
+
addSubcommandGroup(input: SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)): SlashCommandSubcommandsOnlyBuilder;
|
1774 |
+
/**
|
1775 |
+
* Adds a new subcommand to this command.
|
1776 |
+
*
|
1777 |
+
* @param input - A function that returns a subcommand builder or an already built builder
|
1778 |
+
*/
|
1779 |
+
addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): SlashCommandSubcommandsOnlyBuilder;
|
1780 |
+
/**
|
1781 |
+
* Serializes this builder to API-compatible JSON data.
|
1782 |
+
*
|
1783 |
+
* @remarks
|
1784 |
+
* This method runs validations on the data before serializing it.
|
1785 |
+
* As such, it may throw an error if the data is invalid.
|
1786 |
+
*/
|
1787 |
+
toJSON(): RESTPostAPIChatInputApplicationCommandsJSONBody;
|
1788 |
+
}
|
1789 |
+
interface SlashCommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions {
|
1790 |
+
}
|
1791 |
+
/**
|
1792 |
+
* An interface specifically for slash command subcommands.
|
1793 |
+
*/
|
1794 |
+
interface SlashCommandSubcommandsOnlyBuilder extends Omit<SlashCommandBuilder, Exclude<keyof SharedSlashCommandOptions, 'options'>> {
|
1795 |
+
}
|
1796 |
+
/**
|
1797 |
+
* An interface specifically for slash command options.
|
1798 |
+
*/
|
1799 |
+
interface SlashCommandOptionsOnlyBuilder extends SharedNameAndDescription, SharedSlashCommandOptions, Pick<SlashCommandBuilder, 'toJSON'> {
|
1800 |
+
}
|
1801 |
+
/**
|
1802 |
+
* An interface that ensures the `toJSON()` call will return something
|
1803 |
+
* that can be serialized into API-compatible data.
|
1804 |
+
*/
|
1805 |
+
interface ToAPIApplicationCommandOptions {
|
1806 |
+
toJSON(): APIApplicationCommandOption;
|
1807 |
+
}
|
1808 |
+
|
1809 |
+
declare function validateName$1(name: unknown): asserts name is string;
|
1810 |
+
declare function validateDescription(description: unknown): asserts description is string;
|
1811 |
+
declare function validateLocale(locale: unknown): Locale;
|
1812 |
+
declare function validateMaxOptionsLength(options: unknown): asserts options is ToAPIApplicationCommandOptions[];
|
1813 |
+
declare function validateRequiredParameters$1(name: string, description: string, options: ToAPIApplicationCommandOptions[]): void;
|
1814 |
+
declare function validateDefaultPermission$1(value: unknown): asserts value is boolean;
|
1815 |
+
declare function validateRequired(required: unknown): asserts required is boolean;
|
1816 |
+
declare function validateChoicesLength(amountAdding: number, choices?: APIApplicationCommandOptionChoice[]): void;
|
1817 |
+
declare function assertReturnOfBuilder<ReturnType extends ApplicationCommandOptionBase | SlashCommandSubcommandBuilder | SlashCommandSubcommandGroupBuilder>(input: unknown, ExpectedInstanceOf: new () => ReturnType): asserts input is ReturnType;
|
1818 |
+
declare const localizationMapPredicate: _sapphire_shapeshift.UnionValidator<_sapphire_shapeshift.UndefinedToOptional<Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "sv-SE" | "th" | "tr" | "uk" | "vi", string | null>>> | null | undefined>;
|
1819 |
+
declare function validateLocalizationMap(value: unknown): asserts value is LocalizationMap;
|
1820 |
+
declare function validateDMPermission$1(value: unknown): asserts value is boolean | null | undefined;
|
1821 |
+
declare function validateDefaultMemberPermissions$1(permissions: unknown): string | null | undefined;
|
1822 |
+
declare function validateNSFW(value: unknown): asserts value is boolean;
|
1823 |
+
|
1824 |
+
declare const Assertions$1_assertReturnOfBuilder: typeof assertReturnOfBuilder;
|
1825 |
+
declare const Assertions$1_localizationMapPredicate: typeof localizationMapPredicate;
|
1826 |
+
declare const Assertions$1_validateChoicesLength: typeof validateChoicesLength;
|
1827 |
+
declare const Assertions$1_validateDescription: typeof validateDescription;
|
1828 |
+
declare const Assertions$1_validateLocale: typeof validateLocale;
|
1829 |
+
declare const Assertions$1_validateLocalizationMap: typeof validateLocalizationMap;
|
1830 |
+
declare const Assertions$1_validateMaxOptionsLength: typeof validateMaxOptionsLength;
|
1831 |
+
declare const Assertions$1_validateNSFW: typeof validateNSFW;
|
1832 |
+
declare const Assertions$1_validateRequired: typeof validateRequired;
|
1833 |
+
declare namespace Assertions$1 {
|
1834 |
+
export {
|
1835 |
+
Assertions$1_assertReturnOfBuilder as assertReturnOfBuilder,
|
1836 |
+
Assertions$1_localizationMapPredicate as localizationMapPredicate,
|
1837 |
+
Assertions$1_validateChoicesLength as validateChoicesLength,
|
1838 |
+
validateDMPermission$1 as validateDMPermission,
|
1839 |
+
validateDefaultMemberPermissions$1 as validateDefaultMemberPermissions,
|
1840 |
+
validateDefaultPermission$1 as validateDefaultPermission,
|
1841 |
+
Assertions$1_validateDescription as validateDescription,
|
1842 |
+
Assertions$1_validateLocale as validateLocale,
|
1843 |
+
Assertions$1_validateLocalizationMap as validateLocalizationMap,
|
1844 |
+
Assertions$1_validateMaxOptionsLength as validateMaxOptionsLength,
|
1845 |
+
Assertions$1_validateNSFW as validateNSFW,
|
1846 |
+
validateName$1 as validateName,
|
1847 |
+
Assertions$1_validateRequired as validateRequired,
|
1848 |
+
validateRequiredParameters$1 as validateRequiredParameters,
|
1849 |
+
};
|
1850 |
+
}
|
1851 |
+
|
1852 |
+
/**
|
1853 |
+
* The type a context menu command can be.
|
1854 |
+
*/
|
1855 |
+
type ContextMenuCommandType = ApplicationCommandType.Message | ApplicationCommandType.User;
|
1856 |
+
/**
|
1857 |
+
* A builder that creates API-compatible JSON data for context menu commands.
|
1858 |
+
*/
|
1859 |
+
declare class ContextMenuCommandBuilder {
|
1860 |
+
/**
|
1861 |
+
* The name of this command.
|
1862 |
+
*/
|
1863 |
+
readonly name: string;
|
1864 |
+
/**
|
1865 |
+
* The name localizations of this command.
|
1866 |
+
*/
|
1867 |
+
readonly name_localizations?: LocalizationMap;
|
1868 |
+
/**
|
1869 |
+
* The type of this command.
|
1870 |
+
*/
|
1871 |
+
readonly type: ContextMenuCommandType;
|
1872 |
+
/**
|
1873 |
+
* Whether this command is enabled by default when the application is added to a guild.
|
1874 |
+
*
|
1875 |
+
* @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
|
1876 |
+
*/
|
1877 |
+
readonly default_permission: boolean | undefined;
|
1878 |
+
/**
|
1879 |
+
* The set of permissions represented as a bit set for the command.
|
1880 |
+
*/
|
1881 |
+
readonly default_member_permissions: Permissions | null | undefined;
|
1882 |
+
/**
|
1883 |
+
* Indicates whether the command is available in direct messages with the application.
|
1884 |
+
*
|
1885 |
+
* @remarks
|
1886 |
+
* By default, commands are visible. This property is only for global commands.
|
1887 |
+
*/
|
1888 |
+
readonly dm_permission: boolean | undefined;
|
1889 |
+
/**
|
1890 |
+
* Sets the name of this command.
|
1891 |
+
*
|
1892 |
+
* @param name - The name to use
|
1893 |
+
*/
|
1894 |
+
setName(name: string): this;
|
1895 |
+
/**
|
1896 |
+
* Sets the type of this command.
|
1897 |
+
*
|
1898 |
+
* @param type - The type to use
|
1899 |
+
*/
|
1900 |
+
setType(type: ContextMenuCommandType): this;
|
1901 |
+
/**
|
1902 |
+
* Sets whether the command is enabled by default when the application is added to a guild.
|
1903 |
+
*
|
1904 |
+
* @remarks
|
1905 |
+
* If set to `false`, you will have to later `PUT` the permissions for this command.
|
1906 |
+
* @param value - Whether to enable this command by default
|
1907 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
1908 |
+
* @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
|
1909 |
+
*/
|
1910 |
+
setDefaultPermission(value: boolean): this;
|
1911 |
+
/**
|
1912 |
+
* Sets the default permissions a member should have in order to run this command.
|
1913 |
+
*
|
1914 |
+
* @remarks
|
1915 |
+
* You can set this to `'0'` to disable the command by default.
|
1916 |
+
* @param permissions - The permissions bit field to set
|
1917 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
1918 |
+
*/
|
1919 |
+
setDefaultMemberPermissions(permissions: Permissions | bigint | number | null | undefined): this;
|
1920 |
+
/**
|
1921 |
+
* Sets if the command is available in direct messages with the application.
|
1922 |
+
*
|
1923 |
+
* @remarks
|
1924 |
+
* By default, commands are visible. This method is only for global commands.
|
1925 |
+
* @param enabled - Whether the command should be enabled in direct messages
|
1926 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
1927 |
+
*/
|
1928 |
+
setDMPermission(enabled: boolean | null | undefined): this;
|
1929 |
+
/**
|
1930 |
+
* Sets a name localization for this command.
|
1931 |
+
*
|
1932 |
+
* @param locale - The locale to set
|
1933 |
+
* @param localizedName - The localized name for the given `locale`
|
1934 |
+
*/
|
1935 |
+
setNameLocalization(locale: LocaleString, localizedName: string | null): this;
|
1936 |
+
/**
|
1937 |
+
* Sets the name localizations for this command.
|
1938 |
+
*
|
1939 |
+
* @param localizedNames - The object of localized names to set
|
1940 |
+
*/
|
1941 |
+
setNameLocalizations(localizedNames: LocalizationMap | null): this;
|
1942 |
+
/**
|
1943 |
+
* Serializes this builder to API-compatible JSON data.
|
1944 |
+
*
|
1945 |
+
* @remarks
|
1946 |
+
* This method runs validations on the data before serializing it.
|
1947 |
+
* As such, it may throw an error if the data is invalid.
|
1948 |
+
*/
|
1949 |
+
toJSON(): RESTPostAPIContextMenuApplicationCommandsJSONBody;
|
1950 |
+
}
|
1951 |
+
|
1952 |
+
declare function validateDefaultPermission(value: unknown): asserts value is boolean;
|
1953 |
+
declare function validateName(name: unknown): asserts name is string;
|
1954 |
+
declare function validateType(type: unknown): asserts type is ContextMenuCommandType;
|
1955 |
+
declare function validateRequiredParameters(name: string, type: number): void;
|
1956 |
+
declare function validateDMPermission(value: unknown): asserts value is boolean | null | undefined;
|
1957 |
+
declare function validateDefaultMemberPermissions(permissions: unknown): string | null | undefined;
|
1958 |
+
|
1959 |
+
declare const Assertions_validateDMPermission: typeof validateDMPermission;
|
1960 |
+
declare const Assertions_validateDefaultMemberPermissions: typeof validateDefaultMemberPermissions;
|
1961 |
+
declare const Assertions_validateDefaultPermission: typeof validateDefaultPermission;
|
1962 |
+
declare const Assertions_validateName: typeof validateName;
|
1963 |
+
declare const Assertions_validateRequiredParameters: typeof validateRequiredParameters;
|
1964 |
+
declare const Assertions_validateType: typeof validateType;
|
1965 |
+
declare namespace Assertions {
|
1966 |
+
export {
|
1967 |
+
Assertions_validateDMPermission as validateDMPermission,
|
1968 |
+
Assertions_validateDefaultMemberPermissions as validateDefaultMemberPermissions,
|
1969 |
+
Assertions_validateDefaultPermission as validateDefaultPermission,
|
1970 |
+
Assertions_validateName as validateName,
|
1971 |
+
Assertions_validateRequiredParameters as validateRequiredParameters,
|
1972 |
+
Assertions_validateType as validateType,
|
1973 |
+
};
|
1974 |
+
}
|
1975 |
+
|
1976 |
+
/**
|
1977 |
+
* Calculates the length of the embed.
|
1978 |
+
*
|
1979 |
+
* @param data - The embed data to check
|
1980 |
+
*/
|
1981 |
+
declare function embedLength(data: APIEmbed): number;
|
1982 |
+
|
1983 |
+
/**
|
1984 |
+
* Enables validators.
|
1985 |
+
*
|
1986 |
+
* @returns Whether validation is occurring.
|
1987 |
+
*/
|
1988 |
+
declare function enableValidators(): boolean;
|
1989 |
+
/**
|
1990 |
+
* Disables validators.
|
1991 |
+
*
|
1992 |
+
* @returns Whether validation is occurring.
|
1993 |
+
*/
|
1994 |
+
declare function disableValidators(): boolean;
|
1995 |
+
/**
|
1996 |
+
* Checks whether validation is occurring.
|
1997 |
+
*/
|
1998 |
+
declare function isValidationEnabled(): boolean;
|
1999 |
+
|
2000 |
+
/**
|
2001 |
+
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/builders#readme | @discordjs/builders} version
|
2002 |
+
* that you are currently using.
|
2003 |
+
*
|
2004 |
+
* @privateRemarks This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild.
|
2005 |
+
*/
|
2006 |
+
declare const version: string;
|
2007 |
+
|
2008 |
+
export { ActionRowBuilder, AnyAPIActionRowComponent, AnyComponentBuilder, ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionAllowedChannelTypes, ApplicationCommandOptionBase, ApplicationCommandOptionChannelTypesMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin, BaseSelectMenuBuilder, ButtonBuilder, ChannelSelectMenuBuilder, Assertions$4 as ComponentAssertions, ComponentBuilder, Assertions as ContextMenuCommandAssertions, ContextMenuCommandBuilder, ContextMenuCommandType, Assertions$5 as EmbedAssertions, EmbedAuthorData, EmbedAuthorOptions, EmbedBuilder, EmbedFooterData, EmbedFooterOptions, EmbedImageData, IconData, MappedComponentTypes, MentionableSelectMenuBuilder, MessageActionRowComponentBuilder, MessageComponentBuilder, ModalActionRowComponentBuilder, Assertions$2 as ModalAssertions, ModalBuilder, ModalComponentBuilder, RGBTuple, RestOrArray, RoleSelectMenuBuilder, StringSelectMenuBuilder as SelectMenuBuilder, StringSelectMenuOptionBuilder as SelectMenuOptionBuilder, SharedNameAndDescription, SharedSlashCommandOptions, Assertions$1 as SlashCommandAssertions, SlashCommandAttachmentOption, SlashCommandBooleanOption, SlashCommandBuilder, SlashCommandChannelOption, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandOptionsOnlyBuilder, SlashCommandRoleOption, SlashCommandStringOption, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder, SlashCommandUserOption, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, Assertions$3 as TextInputAssertions, TextInputBuilder, ToAPIApplicationCommandOptions, UserSelectMenuBuilder, createComponentBuilder, disableValidators, embedLength, enableValidators, isValidationEnabled, normalizeArray, version };
|
node_modules/@discordjs/builders/dist/index.js
ADDED
@@ -0,0 +1,2763 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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4 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6 |
+
var __getProtoOf = Object.getPrototypeOf;
|
7 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8 |
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
9 |
+
var __export = (target, all) => {
|
10 |
+
for (var name in all)
|
11 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
12 |
+
};
|
13 |
+
var __copyProps = (to, from, except, desc) => {
|
14 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
15 |
+
for (let key of __getOwnPropNames(from))
|
16 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
17 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
18 |
+
}
|
19 |
+
return to;
|
20 |
+
};
|
21 |
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
22 |
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
23 |
+
// If the importer is in node compatibility mode or this is not an ESM
|
24 |
+
// file that has been converted to a CommonJS file using a Babel-
|
25 |
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
26 |
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
27 |
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
28 |
+
mod
|
29 |
+
));
|
30 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
31 |
+
var __decorateClass = (decorators, target, key, kind) => {
|
32 |
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
33 |
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
34 |
+
if (decorator = decorators[i])
|
35 |
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
36 |
+
if (kind && result)
|
37 |
+
__defProp(target, key, result);
|
38 |
+
return result;
|
39 |
+
};
|
40 |
+
|
41 |
+
// src/index.ts
|
42 |
+
var src_exports = {};
|
43 |
+
__export(src_exports, {
|
44 |
+
ActionRowBuilder: () => ActionRowBuilder,
|
45 |
+
ApplicationCommandNumericOptionMinMaxValueMixin: () => ApplicationCommandNumericOptionMinMaxValueMixin,
|
46 |
+
ApplicationCommandOptionBase: () => ApplicationCommandOptionBase,
|
47 |
+
ApplicationCommandOptionChannelTypesMixin: () => ApplicationCommandOptionChannelTypesMixin,
|
48 |
+
ApplicationCommandOptionWithChoicesAndAutocompleteMixin: () => ApplicationCommandOptionWithChoicesAndAutocompleteMixin,
|
49 |
+
BaseSelectMenuBuilder: () => BaseSelectMenuBuilder,
|
50 |
+
ButtonBuilder: () => ButtonBuilder,
|
51 |
+
ChannelSelectMenuBuilder: () => ChannelSelectMenuBuilder,
|
52 |
+
ComponentAssertions: () => Assertions_exports2,
|
53 |
+
ComponentBuilder: () => ComponentBuilder,
|
54 |
+
ContextMenuCommandAssertions: () => Assertions_exports6,
|
55 |
+
ContextMenuCommandBuilder: () => ContextMenuCommandBuilder,
|
56 |
+
EmbedAssertions: () => Assertions_exports,
|
57 |
+
EmbedBuilder: () => EmbedBuilder,
|
58 |
+
MentionableSelectMenuBuilder: () => MentionableSelectMenuBuilder,
|
59 |
+
ModalAssertions: () => Assertions_exports4,
|
60 |
+
ModalBuilder: () => ModalBuilder,
|
61 |
+
RoleSelectMenuBuilder: () => RoleSelectMenuBuilder,
|
62 |
+
SelectMenuBuilder: () => StringSelectMenuBuilder,
|
63 |
+
SelectMenuOptionBuilder: () => StringSelectMenuOptionBuilder,
|
64 |
+
SharedNameAndDescription: () => SharedNameAndDescription,
|
65 |
+
SharedSlashCommandOptions: () => SharedSlashCommandOptions,
|
66 |
+
SlashCommandAssertions: () => Assertions_exports5,
|
67 |
+
SlashCommandAttachmentOption: () => SlashCommandAttachmentOption,
|
68 |
+
SlashCommandBooleanOption: () => SlashCommandBooleanOption,
|
69 |
+
SlashCommandBuilder: () => SlashCommandBuilder,
|
70 |
+
SlashCommandChannelOption: () => SlashCommandChannelOption,
|
71 |
+
SlashCommandIntegerOption: () => SlashCommandIntegerOption,
|
72 |
+
SlashCommandMentionableOption: () => SlashCommandMentionableOption,
|
73 |
+
SlashCommandNumberOption: () => SlashCommandNumberOption,
|
74 |
+
SlashCommandRoleOption: () => SlashCommandRoleOption,
|
75 |
+
SlashCommandStringOption: () => SlashCommandStringOption,
|
76 |
+
SlashCommandSubcommandBuilder: () => SlashCommandSubcommandBuilder,
|
77 |
+
SlashCommandSubcommandGroupBuilder: () => SlashCommandSubcommandGroupBuilder,
|
78 |
+
SlashCommandUserOption: () => SlashCommandUserOption,
|
79 |
+
StringSelectMenuBuilder: () => StringSelectMenuBuilder,
|
80 |
+
StringSelectMenuOptionBuilder: () => StringSelectMenuOptionBuilder,
|
81 |
+
TextInputAssertions: () => Assertions_exports3,
|
82 |
+
TextInputBuilder: () => TextInputBuilder,
|
83 |
+
UserSelectMenuBuilder: () => UserSelectMenuBuilder,
|
84 |
+
createComponentBuilder: () => createComponentBuilder,
|
85 |
+
disableValidators: () => disableValidators,
|
86 |
+
embedLength: () => embedLength,
|
87 |
+
enableValidators: () => enableValidators,
|
88 |
+
isValidationEnabled: () => isValidationEnabled,
|
89 |
+
normalizeArray: () => normalizeArray,
|
90 |
+
version: () => version
|
91 |
+
});
|
92 |
+
module.exports = __toCommonJS(src_exports);
|
93 |
+
|
94 |
+
// src/messages/embed/Assertions.ts
|
95 |
+
var Assertions_exports = {};
|
96 |
+
__export(Assertions_exports, {
|
97 |
+
RGBPredicate: () => RGBPredicate,
|
98 |
+
authorNamePredicate: () => authorNamePredicate,
|
99 |
+
colorPredicate: () => colorPredicate,
|
100 |
+
descriptionPredicate: () => descriptionPredicate,
|
101 |
+
embedAuthorPredicate: () => embedAuthorPredicate,
|
102 |
+
embedFieldPredicate: () => embedFieldPredicate,
|
103 |
+
embedFieldsArrayPredicate: () => embedFieldsArrayPredicate,
|
104 |
+
embedFooterPredicate: () => embedFooterPredicate,
|
105 |
+
fieldInlinePredicate: () => fieldInlinePredicate,
|
106 |
+
fieldLengthPredicate: () => fieldLengthPredicate,
|
107 |
+
fieldNamePredicate: () => fieldNamePredicate,
|
108 |
+
fieldValuePredicate: () => fieldValuePredicate,
|
109 |
+
footerTextPredicate: () => footerTextPredicate,
|
110 |
+
imageURLPredicate: () => imageURLPredicate,
|
111 |
+
timestampPredicate: () => timestampPredicate,
|
112 |
+
titlePredicate: () => titlePredicate,
|
113 |
+
urlPredicate: () => urlPredicate,
|
114 |
+
validateFieldLength: () => validateFieldLength
|
115 |
+
});
|
116 |
+
var import_shapeshift = require("@sapphire/shapeshift");
|
117 |
+
|
118 |
+
// src/util/validation.ts
|
119 |
+
var validate = true;
|
120 |
+
function enableValidators() {
|
121 |
+
return validate = true;
|
122 |
+
}
|
123 |
+
__name(enableValidators, "enableValidators");
|
124 |
+
function disableValidators() {
|
125 |
+
return validate = false;
|
126 |
+
}
|
127 |
+
__name(disableValidators, "disableValidators");
|
128 |
+
function isValidationEnabled() {
|
129 |
+
return validate;
|
130 |
+
}
|
131 |
+
__name(isValidationEnabled, "isValidationEnabled");
|
132 |
+
|
133 |
+
// src/messages/embed/Assertions.ts
|
134 |
+
var fieldNamePredicate = import_shapeshift.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(256).setValidationEnabled(isValidationEnabled);
|
135 |
+
var fieldValuePredicate = import_shapeshift.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(1024).setValidationEnabled(isValidationEnabled);
|
136 |
+
var fieldInlinePredicate = import_shapeshift.s.boolean.optional;
|
137 |
+
var embedFieldPredicate = import_shapeshift.s.object({
|
138 |
+
name: fieldNamePredicate,
|
139 |
+
value: fieldValuePredicate,
|
140 |
+
inline: fieldInlinePredicate
|
141 |
+
}).setValidationEnabled(isValidationEnabled);
|
142 |
+
var embedFieldsArrayPredicate = embedFieldPredicate.array.setValidationEnabled(isValidationEnabled);
|
143 |
+
var fieldLengthPredicate = import_shapeshift.s.number.lessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
|
144 |
+
function validateFieldLength(amountAdding, fields) {
|
145 |
+
fieldLengthPredicate.parse((fields?.length ?? 0) + amountAdding);
|
146 |
+
}
|
147 |
+
__name(validateFieldLength, "validateFieldLength");
|
148 |
+
var authorNamePredicate = fieldNamePredicate.nullable.setValidationEnabled(isValidationEnabled);
|
149 |
+
var imageURLPredicate = import_shapeshift.s.string.url({
|
150 |
+
allowedProtocols: ["http:", "https:", "attachment:"]
|
151 |
+
}).nullish.setValidationEnabled(isValidationEnabled);
|
152 |
+
var urlPredicate = import_shapeshift.s.string.url({
|
153 |
+
allowedProtocols: ["http:", "https:"]
|
154 |
+
}).nullish.setValidationEnabled(isValidationEnabled);
|
155 |
+
var embedAuthorPredicate = import_shapeshift.s.object({
|
156 |
+
name: authorNamePredicate,
|
157 |
+
iconURL: imageURLPredicate,
|
158 |
+
url: urlPredicate
|
159 |
+
}).setValidationEnabled(isValidationEnabled);
|
160 |
+
var RGBPredicate = import_shapeshift.s.number.int.greaterThanOrEqual(0).lessThanOrEqual(255).setValidationEnabled(isValidationEnabled);
|
161 |
+
var colorPredicate = import_shapeshift.s.number.int.greaterThanOrEqual(0).lessThanOrEqual(16777215).or(import_shapeshift.s.tuple([RGBPredicate, RGBPredicate, RGBPredicate])).nullable.setValidationEnabled(isValidationEnabled);
|
162 |
+
var descriptionPredicate = import_shapeshift.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(4096).nullable.setValidationEnabled(isValidationEnabled);
|
163 |
+
var footerTextPredicate = import_shapeshift.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(2048).nullable.setValidationEnabled(isValidationEnabled);
|
164 |
+
var embedFooterPredicate = import_shapeshift.s.object({
|
165 |
+
text: footerTextPredicate,
|
166 |
+
iconURL: imageURLPredicate
|
167 |
+
}).setValidationEnabled(isValidationEnabled);
|
168 |
+
var timestampPredicate = import_shapeshift.s.union(import_shapeshift.s.number, import_shapeshift.s.date).nullable.setValidationEnabled(isValidationEnabled);
|
169 |
+
var titlePredicate = fieldNamePredicate.nullable.setValidationEnabled(isValidationEnabled);
|
170 |
+
|
171 |
+
// src/util/normalizeArray.ts
|
172 |
+
function normalizeArray(arr) {
|
173 |
+
if (Array.isArray(arr[0]))
|
174 |
+
return arr[0];
|
175 |
+
return arr;
|
176 |
+
}
|
177 |
+
__name(normalizeArray, "normalizeArray");
|
178 |
+
|
179 |
+
// src/messages/embed/Embed.ts
|
180 |
+
var EmbedBuilder = class {
|
181 |
+
static {
|
182 |
+
__name(this, "EmbedBuilder");
|
183 |
+
}
|
184 |
+
/**
|
185 |
+
* The API data associated with this embed.
|
186 |
+
*/
|
187 |
+
data;
|
188 |
+
/**
|
189 |
+
* Creates a new embed from API data.
|
190 |
+
*
|
191 |
+
* @param data - The API data to create this embed with
|
192 |
+
*/
|
193 |
+
constructor(data = {}) {
|
194 |
+
this.data = { ...data };
|
195 |
+
if (data.timestamp)
|
196 |
+
this.data.timestamp = new Date(data.timestamp).toISOString();
|
197 |
+
}
|
198 |
+
/**
|
199 |
+
* Appends fields to the embed.
|
200 |
+
*
|
201 |
+
* @remarks
|
202 |
+
* This method accepts either an array of fields or a variable number of field parameters.
|
203 |
+
* The maximum amount of fields that can be added is 25.
|
204 |
+
* @example
|
205 |
+
* Using an array:
|
206 |
+
* ```ts
|
207 |
+
* const fields: APIEmbedField[] = ...;
|
208 |
+
* const embed = new EmbedBuilder()
|
209 |
+
* .addFields(fields);
|
210 |
+
* ```
|
211 |
+
* @example
|
212 |
+
* Using rest parameters (variadic):
|
213 |
+
* ```ts
|
214 |
+
* const embed = new EmbedBuilder()
|
215 |
+
* .addFields(
|
216 |
+
* { name: 'Field 1', value: 'Value 1' },
|
217 |
+
* { name: 'Field 2', value: 'Value 2' },
|
218 |
+
* );
|
219 |
+
* ```
|
220 |
+
* @param fields - The fields to add
|
221 |
+
*/
|
222 |
+
addFields(...fields) {
|
223 |
+
const normalizedFields = normalizeArray(fields);
|
224 |
+
validateFieldLength(normalizedFields.length, this.data.fields);
|
225 |
+
embedFieldsArrayPredicate.parse(normalizedFields);
|
226 |
+
if (this.data.fields)
|
227 |
+
this.data.fields.push(...normalizedFields);
|
228 |
+
else
|
229 |
+
this.data.fields = normalizedFields;
|
230 |
+
return this;
|
231 |
+
}
|
232 |
+
/**
|
233 |
+
* Removes, replaces, or inserts fields for this embed.
|
234 |
+
*
|
235 |
+
* @remarks
|
236 |
+
* This method behaves similarly
|
237 |
+
* to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
238 |
+
* The maximum amount of fields that can be added is 25.
|
239 |
+
*
|
240 |
+
* It's useful for modifying and adjusting order of the already-existing fields of an embed.
|
241 |
+
* @example
|
242 |
+
* Remove the first field:
|
243 |
+
* ```ts
|
244 |
+
* embed.spliceFields(0, 1);
|
245 |
+
* ```
|
246 |
+
* @example
|
247 |
+
* Remove the first n fields:
|
248 |
+
* ```ts
|
249 |
+
* const n = 4;
|
250 |
+
* embed.spliceFields(0, n);
|
251 |
+
* ```
|
252 |
+
* @example
|
253 |
+
* Remove the last field:
|
254 |
+
* ```ts
|
255 |
+
* embed.spliceFields(-1, 1);
|
256 |
+
* ```
|
257 |
+
* @param index - The index to start at
|
258 |
+
* @param deleteCount - The number of fields to remove
|
259 |
+
* @param fields - The replacing field objects
|
260 |
+
*/
|
261 |
+
spliceFields(index, deleteCount, ...fields) {
|
262 |
+
validateFieldLength(fields.length - deleteCount, this.data.fields);
|
263 |
+
embedFieldsArrayPredicate.parse(fields);
|
264 |
+
if (this.data.fields)
|
265 |
+
this.data.fields.splice(index, deleteCount, ...fields);
|
266 |
+
else
|
267 |
+
this.data.fields = fields;
|
268 |
+
return this;
|
269 |
+
}
|
270 |
+
/**
|
271 |
+
* Sets the fields for this embed.
|
272 |
+
*
|
273 |
+
* @remarks
|
274 |
+
* This method is an alias for {@link EmbedBuilder.spliceFields}. More specifically,
|
275 |
+
* it splices the entire array of fields, replacing them with the provided fields.
|
276 |
+
*
|
277 |
+
* You can set a maximum of 25 fields.
|
278 |
+
* @param fields - The fields to set
|
279 |
+
*/
|
280 |
+
setFields(...fields) {
|
281 |
+
this.spliceFields(0, this.data.fields?.length ?? 0, ...normalizeArray(fields));
|
282 |
+
return this;
|
283 |
+
}
|
284 |
+
/**
|
285 |
+
* Sets the author of this embed.
|
286 |
+
*
|
287 |
+
* @param options - The options to use
|
288 |
+
*/
|
289 |
+
setAuthor(options) {
|
290 |
+
if (options === null) {
|
291 |
+
this.data.author = void 0;
|
292 |
+
return this;
|
293 |
+
}
|
294 |
+
embedAuthorPredicate.parse(options);
|
295 |
+
this.data.author = { name: options.name, url: options.url, icon_url: options.iconURL };
|
296 |
+
return this;
|
297 |
+
}
|
298 |
+
/**
|
299 |
+
* Sets the color of this embed.
|
300 |
+
*
|
301 |
+
* @param color - The color to use
|
302 |
+
*/
|
303 |
+
setColor(color) {
|
304 |
+
colorPredicate.parse(color);
|
305 |
+
if (Array.isArray(color)) {
|
306 |
+
const [red, green, blue] = color;
|
307 |
+
this.data.color = (red << 16) + (green << 8) + blue;
|
308 |
+
return this;
|
309 |
+
}
|
310 |
+
this.data.color = color ?? void 0;
|
311 |
+
return this;
|
312 |
+
}
|
313 |
+
/**
|
314 |
+
* Sets the description of this embed.
|
315 |
+
*
|
316 |
+
* @param description - The description to use
|
317 |
+
*/
|
318 |
+
setDescription(description) {
|
319 |
+
descriptionPredicate.parse(description);
|
320 |
+
this.data.description = description ?? void 0;
|
321 |
+
return this;
|
322 |
+
}
|
323 |
+
/**
|
324 |
+
* Sets the footer of this embed.
|
325 |
+
*
|
326 |
+
* @param options - The footer to use
|
327 |
+
*/
|
328 |
+
setFooter(options) {
|
329 |
+
if (options === null) {
|
330 |
+
this.data.footer = void 0;
|
331 |
+
return this;
|
332 |
+
}
|
333 |
+
embedFooterPredicate.parse(options);
|
334 |
+
this.data.footer = { text: options.text, icon_url: options.iconURL };
|
335 |
+
return this;
|
336 |
+
}
|
337 |
+
/**
|
338 |
+
* Sets the image of this embed.
|
339 |
+
*
|
340 |
+
* @param url - The image URL to use
|
341 |
+
*/
|
342 |
+
setImage(url) {
|
343 |
+
imageURLPredicate.parse(url);
|
344 |
+
this.data.image = url ? { url } : void 0;
|
345 |
+
return this;
|
346 |
+
}
|
347 |
+
/**
|
348 |
+
* Sets the thumbnail of this embed.
|
349 |
+
*
|
350 |
+
* @param url - The thumbnail URL to use
|
351 |
+
*/
|
352 |
+
setThumbnail(url) {
|
353 |
+
imageURLPredicate.parse(url);
|
354 |
+
this.data.thumbnail = url ? { url } : void 0;
|
355 |
+
return this;
|
356 |
+
}
|
357 |
+
/**
|
358 |
+
* Sets the timestamp of this embed.
|
359 |
+
*
|
360 |
+
* @param timestamp - The timestamp or date to use
|
361 |
+
*/
|
362 |
+
setTimestamp(timestamp = Date.now()) {
|
363 |
+
timestampPredicate.parse(timestamp);
|
364 |
+
this.data.timestamp = timestamp ? new Date(timestamp).toISOString() : void 0;
|
365 |
+
return this;
|
366 |
+
}
|
367 |
+
/**
|
368 |
+
* Sets the title for this embed.
|
369 |
+
*
|
370 |
+
* @param title - The title to use
|
371 |
+
*/
|
372 |
+
setTitle(title) {
|
373 |
+
titlePredicate.parse(title);
|
374 |
+
this.data.title = title ?? void 0;
|
375 |
+
return this;
|
376 |
+
}
|
377 |
+
/**
|
378 |
+
* Sets the URL of this embed.
|
379 |
+
*
|
380 |
+
* @param url - The URL to use
|
381 |
+
*/
|
382 |
+
setURL(url) {
|
383 |
+
urlPredicate.parse(url);
|
384 |
+
this.data.url = url ?? void 0;
|
385 |
+
return this;
|
386 |
+
}
|
387 |
+
/**
|
388 |
+
* Serializes this builder to API-compatible JSON data.
|
389 |
+
*
|
390 |
+
* @remarks
|
391 |
+
* This method runs validations on the data before serializing it.
|
392 |
+
* As such, it may throw an error if the data is invalid.
|
393 |
+
*/
|
394 |
+
toJSON() {
|
395 |
+
return { ...this.data };
|
396 |
+
}
|
397 |
+
};
|
398 |
+
|
399 |
+
// src/index.ts
|
400 |
+
__reExport(src_exports, require("@discordjs/formatters"), module.exports);
|
401 |
+
|
402 |
+
// src/components/Assertions.ts
|
403 |
+
var Assertions_exports2 = {};
|
404 |
+
__export(Assertions_exports2, {
|
405 |
+
buttonLabelValidator: () => buttonLabelValidator,
|
406 |
+
buttonStyleValidator: () => buttonStyleValidator,
|
407 |
+
channelTypesValidator: () => channelTypesValidator,
|
408 |
+
customIdValidator: () => customIdValidator,
|
409 |
+
defaultValidator: () => defaultValidator,
|
410 |
+
disabledValidator: () => disabledValidator,
|
411 |
+
emojiValidator: () => emojiValidator,
|
412 |
+
jsonOptionValidator: () => jsonOptionValidator,
|
413 |
+
labelValueDescriptionValidator: () => labelValueDescriptionValidator,
|
414 |
+
minMaxValidator: () => minMaxValidator,
|
415 |
+
optionValidator: () => optionValidator,
|
416 |
+
optionsLengthValidator: () => optionsLengthValidator,
|
417 |
+
optionsValidator: () => optionsValidator,
|
418 |
+
placeholderValidator: () => placeholderValidator,
|
419 |
+
urlValidator: () => urlValidator,
|
420 |
+
validateRequiredButtonParameters: () => validateRequiredButtonParameters,
|
421 |
+
validateRequiredSelectMenuOptionParameters: () => validateRequiredSelectMenuOptionParameters,
|
422 |
+
validateRequiredSelectMenuParameters: () => validateRequiredSelectMenuParameters
|
423 |
+
});
|
424 |
+
var import_shapeshift2 = require("@sapphire/shapeshift");
|
425 |
+
var import_v10 = require("discord-api-types/v10");
|
426 |
+
|
427 |
+
// src/components/selectMenu/StringSelectMenuOption.ts
|
428 |
+
var StringSelectMenuOptionBuilder = class {
|
429 |
+
/**
|
430 |
+
* Creates a new string select menu option from API data.
|
431 |
+
*
|
432 |
+
* @param data - The API data to create this string select menu option with
|
433 |
+
* @example
|
434 |
+
* Creating a string select menu option from an API data object:
|
435 |
+
* ```ts
|
436 |
+
* const selectMenuOption = new SelectMenuOptionBuilder({
|
437 |
+
* label: 'catchy label',
|
438 |
+
* value: '1',
|
439 |
+
* });
|
440 |
+
* ```
|
441 |
+
* @example
|
442 |
+
* Creating a string select menu option using setters and API data:
|
443 |
+
* ```ts
|
444 |
+
* const selectMenuOption = new SelectMenuOptionBuilder({
|
445 |
+
* default: true,
|
446 |
+
* value: '1',
|
447 |
+
* })
|
448 |
+
* .setLabel('woah');
|
449 |
+
* ```
|
450 |
+
*/
|
451 |
+
constructor(data = {}) {
|
452 |
+
this.data = data;
|
453 |
+
}
|
454 |
+
static {
|
455 |
+
__name(this, "StringSelectMenuOptionBuilder");
|
456 |
+
}
|
457 |
+
/**
|
458 |
+
* Sets the label for this option.
|
459 |
+
*
|
460 |
+
* @param label - The label to use
|
461 |
+
*/
|
462 |
+
setLabel(label) {
|
463 |
+
this.data.label = labelValueDescriptionValidator.parse(label);
|
464 |
+
return this;
|
465 |
+
}
|
466 |
+
/**
|
467 |
+
* Sets the value for this option.
|
468 |
+
*
|
469 |
+
* @param value - The value to use
|
470 |
+
*/
|
471 |
+
setValue(value) {
|
472 |
+
this.data.value = labelValueDescriptionValidator.parse(value);
|
473 |
+
return this;
|
474 |
+
}
|
475 |
+
/**
|
476 |
+
* Sets the description for this option.
|
477 |
+
*
|
478 |
+
* @param description - The description to use
|
479 |
+
*/
|
480 |
+
setDescription(description) {
|
481 |
+
this.data.description = labelValueDescriptionValidator.parse(description);
|
482 |
+
return this;
|
483 |
+
}
|
484 |
+
/**
|
485 |
+
* Sets whether this option is selected by default.
|
486 |
+
*
|
487 |
+
* @param isDefault - Whether this option is selected by default
|
488 |
+
*/
|
489 |
+
setDefault(isDefault = true) {
|
490 |
+
this.data.default = defaultValidator.parse(isDefault);
|
491 |
+
return this;
|
492 |
+
}
|
493 |
+
/**
|
494 |
+
* Sets the emoji to display for this option.
|
495 |
+
*
|
496 |
+
* @param emoji - The emoji to use
|
497 |
+
*/
|
498 |
+
setEmoji(emoji) {
|
499 |
+
this.data.emoji = emojiValidator.parse(emoji);
|
500 |
+
return this;
|
501 |
+
}
|
502 |
+
/**
|
503 |
+
* {@inheritDoc BaseSelectMenuBuilder.toJSON}
|
504 |
+
*/
|
505 |
+
toJSON() {
|
506 |
+
validateRequiredSelectMenuOptionParameters(this.data.label, this.data.value);
|
507 |
+
return {
|
508 |
+
...this.data
|
509 |
+
};
|
510 |
+
}
|
511 |
+
};
|
512 |
+
|
513 |
+
// src/components/Assertions.ts
|
514 |
+
var customIdValidator = import_shapeshift2.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
|
515 |
+
var emojiValidator = import_shapeshift2.s.object({
|
516 |
+
id: import_shapeshift2.s.string,
|
517 |
+
name: import_shapeshift2.s.string,
|
518 |
+
animated: import_shapeshift2.s.boolean
|
519 |
+
}).partial.strict.setValidationEnabled(isValidationEnabled);
|
520 |
+
var disabledValidator = import_shapeshift2.s.boolean;
|
521 |
+
var buttonLabelValidator = import_shapeshift2.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(80).setValidationEnabled(isValidationEnabled);
|
522 |
+
var buttonStyleValidator = import_shapeshift2.s.nativeEnum(import_v10.ButtonStyle);
|
523 |
+
var placeholderValidator = import_shapeshift2.s.string.lengthLessThanOrEqual(150).setValidationEnabled(isValidationEnabled);
|
524 |
+
var minMaxValidator = import_shapeshift2.s.number.int.greaterThanOrEqual(0).lessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
|
525 |
+
var labelValueDescriptionValidator = import_shapeshift2.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
|
526 |
+
var jsonOptionValidator = import_shapeshift2.s.object({
|
527 |
+
label: labelValueDescriptionValidator,
|
528 |
+
value: labelValueDescriptionValidator,
|
529 |
+
description: labelValueDescriptionValidator.optional,
|
530 |
+
emoji: emojiValidator.optional,
|
531 |
+
default: import_shapeshift2.s.boolean.optional
|
532 |
+
}).setValidationEnabled(isValidationEnabled);
|
533 |
+
var optionValidator = import_shapeshift2.s.instance(StringSelectMenuOptionBuilder).setValidationEnabled(isValidationEnabled);
|
534 |
+
var optionsValidator = optionValidator.array.lengthGreaterThanOrEqual(0).setValidationEnabled(isValidationEnabled);
|
535 |
+
var optionsLengthValidator = import_shapeshift2.s.number.int.greaterThanOrEqual(0).lessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
|
536 |
+
function validateRequiredSelectMenuParameters(options, customId) {
|
537 |
+
customIdValidator.parse(customId);
|
538 |
+
optionsValidator.parse(options);
|
539 |
+
}
|
540 |
+
__name(validateRequiredSelectMenuParameters, "validateRequiredSelectMenuParameters");
|
541 |
+
var defaultValidator = import_shapeshift2.s.boolean;
|
542 |
+
function validateRequiredSelectMenuOptionParameters(label, value) {
|
543 |
+
labelValueDescriptionValidator.parse(label);
|
544 |
+
labelValueDescriptionValidator.parse(value);
|
545 |
+
}
|
546 |
+
__name(validateRequiredSelectMenuOptionParameters, "validateRequiredSelectMenuOptionParameters");
|
547 |
+
var channelTypesValidator = import_shapeshift2.s.nativeEnum(import_v10.ChannelType).array.setValidationEnabled(isValidationEnabled);
|
548 |
+
var urlValidator = import_shapeshift2.s.string.url({
|
549 |
+
allowedProtocols: ["http:", "https:", "discord:"]
|
550 |
+
}).setValidationEnabled(isValidationEnabled);
|
551 |
+
function validateRequiredButtonParameters(style, label, emoji, customId, url) {
|
552 |
+
if (url && customId) {
|
553 |
+
throw new RangeError("URL and custom id are mutually exclusive");
|
554 |
+
}
|
555 |
+
if (!label && !emoji) {
|
556 |
+
throw new RangeError("Buttons must have a label and/or an emoji");
|
557 |
+
}
|
558 |
+
if (style === import_v10.ButtonStyle.Link) {
|
559 |
+
if (!url) {
|
560 |
+
throw new RangeError("Link buttons must have a url");
|
561 |
+
}
|
562 |
+
} else if (url) {
|
563 |
+
throw new RangeError("Non-link buttons cannot have a url");
|
564 |
+
}
|
565 |
+
}
|
566 |
+
__name(validateRequiredButtonParameters, "validateRequiredButtonParameters");
|
567 |
+
|
568 |
+
// src/components/ActionRow.ts
|
569 |
+
var import_v1011 = require("discord-api-types/v10");
|
570 |
+
|
571 |
+
// src/components/Component.ts
|
572 |
+
var ComponentBuilder = class {
|
573 |
+
static {
|
574 |
+
__name(this, "ComponentBuilder");
|
575 |
+
}
|
576 |
+
/**
|
577 |
+
* The API data associated with this component.
|
578 |
+
*/
|
579 |
+
data;
|
580 |
+
/**
|
581 |
+
* Constructs a new kind of component.
|
582 |
+
*
|
583 |
+
* @param data - The data to construct a component out of
|
584 |
+
*/
|
585 |
+
constructor(data) {
|
586 |
+
this.data = data;
|
587 |
+
}
|
588 |
+
};
|
589 |
+
|
590 |
+
// src/components/Components.ts
|
591 |
+
var import_v1010 = require("discord-api-types/v10");
|
592 |
+
|
593 |
+
// src/components/button/Button.ts
|
594 |
+
var import_v102 = require("discord-api-types/v10");
|
595 |
+
var ButtonBuilder = class extends ComponentBuilder {
|
596 |
+
static {
|
597 |
+
__name(this, "ButtonBuilder");
|
598 |
+
}
|
599 |
+
/**
|
600 |
+
* Creates a new button from API data.
|
601 |
+
*
|
602 |
+
* @param data - The API data to create this button with
|
603 |
+
* @example
|
604 |
+
* Creating a button from an API data object:
|
605 |
+
* ```ts
|
606 |
+
* const button = new ButtonBuilder({
|
607 |
+
* custom_id: 'a cool button',
|
608 |
+
* style: ButtonStyle.Primary,
|
609 |
+
* label: 'Click Me',
|
610 |
+
* emoji: {
|
611 |
+
* name: 'smile',
|
612 |
+
* id: '123456789012345678',
|
613 |
+
* },
|
614 |
+
* });
|
615 |
+
* ```
|
616 |
+
* @example
|
617 |
+
* Creating a button using setters and API data:
|
618 |
+
* ```ts
|
619 |
+
* const button = new ButtonBuilder({
|
620 |
+
* style: ButtonStyle.Secondary,
|
621 |
+
* label: 'Click Me',
|
622 |
+
* })
|
623 |
+
* .setEmoji({ name: '🙂' })
|
624 |
+
* .setCustomId('another cool button');
|
625 |
+
* ```
|
626 |
+
*/
|
627 |
+
constructor(data) {
|
628 |
+
super({ type: import_v102.ComponentType.Button, ...data });
|
629 |
+
}
|
630 |
+
/**
|
631 |
+
* Sets the style of this button.
|
632 |
+
*
|
633 |
+
* @param style - The style to use
|
634 |
+
*/
|
635 |
+
setStyle(style) {
|
636 |
+
this.data.style = buttonStyleValidator.parse(style);
|
637 |
+
return this;
|
638 |
+
}
|
639 |
+
/**
|
640 |
+
* Sets the URL for this button.
|
641 |
+
*
|
642 |
+
* @remarks
|
643 |
+
* This method is only available to buttons using the `Link` button style.
|
644 |
+
* Only three types of URL schemes are currently supported: `https://`, `http://`, and `discord://`.
|
645 |
+
* @param url - The URL to use
|
646 |
+
*/
|
647 |
+
setURL(url) {
|
648 |
+
this.data.url = urlValidator.parse(url);
|
649 |
+
return this;
|
650 |
+
}
|
651 |
+
/**
|
652 |
+
* Sets the custom id for this button.
|
653 |
+
*
|
654 |
+
* @remarks
|
655 |
+
* This method is only applicable to buttons that are not using the `Link` button style.
|
656 |
+
* @param customId - The custom id to use
|
657 |
+
*/
|
658 |
+
setCustomId(customId) {
|
659 |
+
this.data.custom_id = customIdValidator.parse(customId);
|
660 |
+
return this;
|
661 |
+
}
|
662 |
+
/**
|
663 |
+
* Sets the emoji to display on this button.
|
664 |
+
*
|
665 |
+
* @param emoji - The emoji to use
|
666 |
+
*/
|
667 |
+
setEmoji(emoji) {
|
668 |
+
this.data.emoji = emojiValidator.parse(emoji);
|
669 |
+
return this;
|
670 |
+
}
|
671 |
+
/**
|
672 |
+
* Sets whether this button is disabled.
|
673 |
+
*
|
674 |
+
* @param disabled - Whether to disable this button
|
675 |
+
*/
|
676 |
+
setDisabled(disabled = true) {
|
677 |
+
this.data.disabled = disabledValidator.parse(disabled);
|
678 |
+
return this;
|
679 |
+
}
|
680 |
+
/**
|
681 |
+
* Sets the label for this button.
|
682 |
+
*
|
683 |
+
* @param label - The label to use
|
684 |
+
*/
|
685 |
+
setLabel(label) {
|
686 |
+
this.data.label = buttonLabelValidator.parse(label);
|
687 |
+
return this;
|
688 |
+
}
|
689 |
+
/**
|
690 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
691 |
+
*/
|
692 |
+
toJSON() {
|
693 |
+
validateRequiredButtonParameters(
|
694 |
+
this.data.style,
|
695 |
+
this.data.label,
|
696 |
+
this.data.emoji,
|
697 |
+
this.data.custom_id,
|
698 |
+
this.data.url
|
699 |
+
);
|
700 |
+
return {
|
701 |
+
...this.data
|
702 |
+
};
|
703 |
+
}
|
704 |
+
};
|
705 |
+
|
706 |
+
// src/components/selectMenu/ChannelSelectMenu.ts
|
707 |
+
var import_v103 = require("discord-api-types/v10");
|
708 |
+
|
709 |
+
// src/components/selectMenu/BaseSelectMenu.ts
|
710 |
+
var BaseSelectMenuBuilder = class extends ComponentBuilder {
|
711 |
+
static {
|
712 |
+
__name(this, "BaseSelectMenuBuilder");
|
713 |
+
}
|
714 |
+
/**
|
715 |
+
* Sets the placeholder for this select menu.
|
716 |
+
*
|
717 |
+
* @param placeholder - The placeholder to use
|
718 |
+
*/
|
719 |
+
setPlaceholder(placeholder) {
|
720 |
+
this.data.placeholder = placeholderValidator.parse(placeholder);
|
721 |
+
return this;
|
722 |
+
}
|
723 |
+
/**
|
724 |
+
* Sets the minimum values that must be selected in the select menu.
|
725 |
+
*
|
726 |
+
* @param minValues - The minimum values that must be selected
|
727 |
+
*/
|
728 |
+
setMinValues(minValues) {
|
729 |
+
this.data.min_values = minMaxValidator.parse(minValues);
|
730 |
+
return this;
|
731 |
+
}
|
732 |
+
/**
|
733 |
+
* Sets the maximum values that must be selected in the select menu.
|
734 |
+
*
|
735 |
+
* @param maxValues - The maximum values that must be selected
|
736 |
+
*/
|
737 |
+
setMaxValues(maxValues) {
|
738 |
+
this.data.max_values = minMaxValidator.parse(maxValues);
|
739 |
+
return this;
|
740 |
+
}
|
741 |
+
/**
|
742 |
+
* Sets the custom id for this select menu.
|
743 |
+
*
|
744 |
+
* @param customId - The custom id to use
|
745 |
+
*/
|
746 |
+
setCustomId(customId) {
|
747 |
+
this.data.custom_id = customIdValidator.parse(customId);
|
748 |
+
return this;
|
749 |
+
}
|
750 |
+
/**
|
751 |
+
* Sets whether this select menu is disabled.
|
752 |
+
*
|
753 |
+
* @param disabled - Whether this select menu is disabled
|
754 |
+
*/
|
755 |
+
setDisabled(disabled = true) {
|
756 |
+
this.data.disabled = disabledValidator.parse(disabled);
|
757 |
+
return this;
|
758 |
+
}
|
759 |
+
/**
|
760 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
761 |
+
*/
|
762 |
+
toJSON() {
|
763 |
+
customIdValidator.parse(this.data.custom_id);
|
764 |
+
return {
|
765 |
+
...this.data
|
766 |
+
};
|
767 |
+
}
|
768 |
+
};
|
769 |
+
|
770 |
+
// src/components/selectMenu/ChannelSelectMenu.ts
|
771 |
+
var ChannelSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
772 |
+
static {
|
773 |
+
__name(this, "ChannelSelectMenuBuilder");
|
774 |
+
}
|
775 |
+
/**
|
776 |
+
* Creates a new select menu from API data.
|
777 |
+
*
|
778 |
+
* @param data - The API data to create this select menu with
|
779 |
+
* @example
|
780 |
+
* Creating a select menu from an API data object:
|
781 |
+
* ```ts
|
782 |
+
* const selectMenu = new ChannelSelectMenuBuilder({
|
783 |
+
* custom_id: 'a cool select menu',
|
784 |
+
* placeholder: 'select an option',
|
785 |
+
* max_values: 2,
|
786 |
+
* });
|
787 |
+
* ```
|
788 |
+
* @example
|
789 |
+
* Creating a select menu using setters and API data:
|
790 |
+
* ```ts
|
791 |
+
* const selectMenu = new ChannelSelectMenuBuilder({
|
792 |
+
* custom_id: 'a cool select menu',
|
793 |
+
* })
|
794 |
+
* .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
|
795 |
+
* .setMinValues(2);
|
796 |
+
* ```
|
797 |
+
*/
|
798 |
+
constructor(data) {
|
799 |
+
super({ ...data, type: import_v103.ComponentType.ChannelSelect });
|
800 |
+
}
|
801 |
+
/**
|
802 |
+
* Adds channel types to this select menu.
|
803 |
+
*
|
804 |
+
* @param types - The channel types to use
|
805 |
+
*/
|
806 |
+
addChannelTypes(...types) {
|
807 |
+
const normalizedTypes = normalizeArray(types);
|
808 |
+
this.data.channel_types ??= [];
|
809 |
+
this.data.channel_types.push(...channelTypesValidator.parse(normalizedTypes));
|
810 |
+
return this;
|
811 |
+
}
|
812 |
+
/**
|
813 |
+
* Sets channel types for this select menu.
|
814 |
+
*
|
815 |
+
* @param types - The channel types to use
|
816 |
+
*/
|
817 |
+
setChannelTypes(...types) {
|
818 |
+
const normalizedTypes = normalizeArray(types);
|
819 |
+
this.data.channel_types ??= [];
|
820 |
+
this.data.channel_types.splice(0, this.data.channel_types.length, ...channelTypesValidator.parse(normalizedTypes));
|
821 |
+
return this;
|
822 |
+
}
|
823 |
+
/**
|
824 |
+
* Adds default channels to this auto populated select menu.
|
825 |
+
*
|
826 |
+
* @param channels - The channels to add
|
827 |
+
*/
|
828 |
+
addDefaultChannels(...channels) {
|
829 |
+
const normalizedValues = normalizeArray(channels);
|
830 |
+
optionsLengthValidator.parse((this.data.default_values?.length ?? 0) + normalizedValues.length);
|
831 |
+
this.data.default_values ??= [];
|
832 |
+
this.data.default_values.push(
|
833 |
+
...normalizedValues.map((id) => ({
|
834 |
+
id,
|
835 |
+
type: import_v103.SelectMenuDefaultValueType.Channel
|
836 |
+
}))
|
837 |
+
);
|
838 |
+
return this;
|
839 |
+
}
|
840 |
+
/**
|
841 |
+
* Sets default channels to this auto populated select menu.
|
842 |
+
*
|
843 |
+
* @param channels - The channels to set
|
844 |
+
*/
|
845 |
+
setDefaultChannels(...channels) {
|
846 |
+
const normalizedValues = normalizeArray(channels);
|
847 |
+
optionsLengthValidator.parse(normalizedValues.length);
|
848 |
+
this.data.default_values = normalizedValues.map((id) => ({
|
849 |
+
id,
|
850 |
+
type: import_v103.SelectMenuDefaultValueType.Channel
|
851 |
+
}));
|
852 |
+
return this;
|
853 |
+
}
|
854 |
+
/**
|
855 |
+
* {@inheritDoc BaseSelectMenuBuilder.toJSON}
|
856 |
+
*/
|
857 |
+
toJSON() {
|
858 |
+
customIdValidator.parse(this.data.custom_id);
|
859 |
+
return {
|
860 |
+
...this.data
|
861 |
+
};
|
862 |
+
}
|
863 |
+
};
|
864 |
+
|
865 |
+
// src/components/selectMenu/MentionableSelectMenu.ts
|
866 |
+
var import_v104 = require("discord-api-types/v10");
|
867 |
+
var MentionableSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
868 |
+
static {
|
869 |
+
__name(this, "MentionableSelectMenuBuilder");
|
870 |
+
}
|
871 |
+
/**
|
872 |
+
* Creates a new select menu from API data.
|
873 |
+
*
|
874 |
+
* @param data - The API data to create this select menu with
|
875 |
+
* @example
|
876 |
+
* Creating a select menu from an API data object:
|
877 |
+
* ```ts
|
878 |
+
* const selectMenu = new MentionableSelectMenuBuilder({
|
879 |
+
* custom_id: 'a cool select menu',
|
880 |
+
* placeholder: 'select an option',
|
881 |
+
* max_values: 2,
|
882 |
+
* });
|
883 |
+
* ```
|
884 |
+
* @example
|
885 |
+
* Creating a select menu using setters and API data:
|
886 |
+
* ```ts
|
887 |
+
* const selectMenu = new MentionableSelectMenuBuilder({
|
888 |
+
* custom_id: 'a cool select menu',
|
889 |
+
* })
|
890 |
+
* .setMinValues(1);
|
891 |
+
* ```
|
892 |
+
*/
|
893 |
+
constructor(data) {
|
894 |
+
super({ ...data, type: import_v104.ComponentType.MentionableSelect });
|
895 |
+
}
|
896 |
+
/**
|
897 |
+
* Adds default roles to this auto populated select menu.
|
898 |
+
*
|
899 |
+
* @param roles - The roles to add
|
900 |
+
*/
|
901 |
+
addDefaultRoles(...roles) {
|
902 |
+
const normalizedValues = normalizeArray(roles);
|
903 |
+
optionsLengthValidator.parse((this.data.default_values?.length ?? 0) + normalizedValues.length);
|
904 |
+
this.data.default_values ??= [];
|
905 |
+
this.data.default_values.push(
|
906 |
+
...normalizedValues.map((id) => ({
|
907 |
+
id,
|
908 |
+
type: import_v104.SelectMenuDefaultValueType.Role
|
909 |
+
}))
|
910 |
+
);
|
911 |
+
return this;
|
912 |
+
}
|
913 |
+
/**
|
914 |
+
* Adds default users to this auto populated select menu.
|
915 |
+
*
|
916 |
+
* @param users - The users to add
|
917 |
+
*/
|
918 |
+
addDefaultUsers(...users) {
|
919 |
+
const normalizedValues = normalizeArray(users);
|
920 |
+
optionsLengthValidator.parse((this.data.default_values?.length ?? 0) + normalizedValues.length);
|
921 |
+
this.data.default_values ??= [];
|
922 |
+
this.data.default_values.push(
|
923 |
+
...normalizedValues.map((id) => ({
|
924 |
+
id,
|
925 |
+
type: import_v104.SelectMenuDefaultValueType.User
|
926 |
+
}))
|
927 |
+
);
|
928 |
+
return this;
|
929 |
+
}
|
930 |
+
/**
|
931 |
+
* Adds default values to this auto populated select menu.
|
932 |
+
*
|
933 |
+
* @param values - The values to add
|
934 |
+
*/
|
935 |
+
addDefaultValues(...values) {
|
936 |
+
const normalizedValues = normalizeArray(values);
|
937 |
+
optionsLengthValidator.parse((this.data.default_values?.length ?? 0) + normalizedValues.length);
|
938 |
+
this.data.default_values ??= [];
|
939 |
+
this.data.default_values.push(...normalizedValues);
|
940 |
+
return this;
|
941 |
+
}
|
942 |
+
/**
|
943 |
+
* Sets default values to this auto populated select menu.
|
944 |
+
*
|
945 |
+
* @param values - The values to set
|
946 |
+
*/
|
947 |
+
setDefaultValues(...values) {
|
948 |
+
const normalizedValues = normalizeArray(values);
|
949 |
+
optionsLengthValidator.parse(normalizedValues.length);
|
950 |
+
this.data.default_values = normalizedValues.slice();
|
951 |
+
return this;
|
952 |
+
}
|
953 |
+
};
|
954 |
+
|
955 |
+
// src/components/selectMenu/RoleSelectMenu.ts
|
956 |
+
var import_v105 = require("discord-api-types/v10");
|
957 |
+
var RoleSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
958 |
+
static {
|
959 |
+
__name(this, "RoleSelectMenuBuilder");
|
960 |
+
}
|
961 |
+
/**
|
962 |
+
* Creates a new select menu from API data.
|
963 |
+
*
|
964 |
+
* @param data - The API data to create this select menu with
|
965 |
+
* @example
|
966 |
+
* Creating a select menu from an API data object:
|
967 |
+
* ```ts
|
968 |
+
* const selectMenu = new RoleSelectMenuBuilder({
|
969 |
+
* custom_id: 'a cool select menu',
|
970 |
+
* placeholder: 'select an option',
|
971 |
+
* max_values: 2,
|
972 |
+
* });
|
973 |
+
* ```
|
974 |
+
* @example
|
975 |
+
* Creating a select menu using setters and API data:
|
976 |
+
* ```ts
|
977 |
+
* const selectMenu = new RoleSelectMenuBuilder({
|
978 |
+
* custom_id: 'a cool select menu',
|
979 |
+
* })
|
980 |
+
* .setMinValues(1);
|
981 |
+
* ```
|
982 |
+
*/
|
983 |
+
constructor(data) {
|
984 |
+
super({ ...data, type: import_v105.ComponentType.RoleSelect });
|
985 |
+
}
|
986 |
+
/**
|
987 |
+
* Adds default roles to this auto populated select menu.
|
988 |
+
*
|
989 |
+
* @param roles - The roles to add
|
990 |
+
*/
|
991 |
+
addDefaultRoles(...roles) {
|
992 |
+
const normalizedValues = normalizeArray(roles);
|
993 |
+
optionsLengthValidator.parse((this.data.default_values?.length ?? 0) + normalizedValues.length);
|
994 |
+
this.data.default_values ??= [];
|
995 |
+
this.data.default_values.push(
|
996 |
+
...normalizedValues.map((id) => ({
|
997 |
+
id,
|
998 |
+
type: import_v105.SelectMenuDefaultValueType.Role
|
999 |
+
}))
|
1000 |
+
);
|
1001 |
+
return this;
|
1002 |
+
}
|
1003 |
+
/**
|
1004 |
+
* Sets default roles to this auto populated select menu.
|
1005 |
+
*
|
1006 |
+
* @param roles - The roles to set
|
1007 |
+
*/
|
1008 |
+
setDefaultRoles(...roles) {
|
1009 |
+
const normalizedValues = normalizeArray(roles);
|
1010 |
+
optionsLengthValidator.parse(normalizedValues.length);
|
1011 |
+
this.data.default_values = normalizedValues.map((id) => ({
|
1012 |
+
id,
|
1013 |
+
type: import_v105.SelectMenuDefaultValueType.Role
|
1014 |
+
}));
|
1015 |
+
return this;
|
1016 |
+
}
|
1017 |
+
};
|
1018 |
+
|
1019 |
+
// src/components/selectMenu/StringSelectMenu.ts
|
1020 |
+
var import_v106 = require("discord-api-types/v10");
|
1021 |
+
var StringSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
1022 |
+
static {
|
1023 |
+
__name(this, "StringSelectMenuBuilder");
|
1024 |
+
}
|
1025 |
+
/**
|
1026 |
+
* The options within this select menu.
|
1027 |
+
*/
|
1028 |
+
options;
|
1029 |
+
/**
|
1030 |
+
* Creates a new select menu from API data.
|
1031 |
+
*
|
1032 |
+
* @param data - The API data to create this select menu with
|
1033 |
+
* @example
|
1034 |
+
* Creating a select menu from an API data object:
|
1035 |
+
* ```ts
|
1036 |
+
* const selectMenu = new StringSelectMenuBuilder({
|
1037 |
+
* custom_id: 'a cool select menu',
|
1038 |
+
* placeholder: 'select an option',
|
1039 |
+
* max_values: 2,
|
1040 |
+
* options: [
|
1041 |
+
* { label: 'option 1', value: '1' },
|
1042 |
+
* { label: 'option 2', value: '2' },
|
1043 |
+
* { label: 'option 3', value: '3' },
|
1044 |
+
* ],
|
1045 |
+
* });
|
1046 |
+
* ```
|
1047 |
+
* @example
|
1048 |
+
* Creating a select menu using setters and API data:
|
1049 |
+
* ```ts
|
1050 |
+
* const selectMenu = new StringSelectMenuBuilder({
|
1051 |
+
* custom_id: 'a cool select menu',
|
1052 |
+
* })
|
1053 |
+
* .setMinValues(1)
|
1054 |
+
* .addOptions({
|
1055 |
+
* label: 'Catchy',
|
1056 |
+
* value: 'catch',
|
1057 |
+
* });
|
1058 |
+
* ```
|
1059 |
+
*/
|
1060 |
+
constructor(data) {
|
1061 |
+
const { options, ...initData } = data ?? {};
|
1062 |
+
super({ ...initData, type: import_v106.ComponentType.StringSelect });
|
1063 |
+
this.options = options?.map((option) => new StringSelectMenuOptionBuilder(option)) ?? [];
|
1064 |
+
}
|
1065 |
+
/**
|
1066 |
+
* Adds options to this select menu.
|
1067 |
+
*
|
1068 |
+
* @param options - The options to add
|
1069 |
+
*/
|
1070 |
+
addOptions(...options) {
|
1071 |
+
const normalizedOptions = normalizeArray(options);
|
1072 |
+
optionsLengthValidator.parse(this.options.length + normalizedOptions.length);
|
1073 |
+
this.options.push(
|
1074 |
+
...normalizedOptions.map(
|
1075 |
+
(normalizedOption) => normalizedOption instanceof StringSelectMenuOptionBuilder ? normalizedOption : new StringSelectMenuOptionBuilder(jsonOptionValidator.parse(normalizedOption))
|
1076 |
+
)
|
1077 |
+
);
|
1078 |
+
return this;
|
1079 |
+
}
|
1080 |
+
/**
|
1081 |
+
* Sets the options for this select menu.
|
1082 |
+
*
|
1083 |
+
* @param options - The options to set
|
1084 |
+
*/
|
1085 |
+
setOptions(...options) {
|
1086 |
+
return this.spliceOptions(0, this.options.length, ...options);
|
1087 |
+
}
|
1088 |
+
/**
|
1089 |
+
* Removes, replaces, or inserts options for this select menu.
|
1090 |
+
*
|
1091 |
+
* @remarks
|
1092 |
+
* This method behaves similarly
|
1093 |
+
* to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | Array.prototype.splice()}.
|
1094 |
+
* It's useful for modifying and adjusting the order of existing options.
|
1095 |
+
* @example
|
1096 |
+
* Remove the first option:
|
1097 |
+
* ```ts
|
1098 |
+
* selectMenu.spliceOptions(0, 1);
|
1099 |
+
* ```
|
1100 |
+
* @example
|
1101 |
+
* Remove the first n option:
|
1102 |
+
* ```ts
|
1103 |
+
* const n = 4;
|
1104 |
+
* selectMenu.spliceOptions(0, n);
|
1105 |
+
* ```
|
1106 |
+
* @example
|
1107 |
+
* Remove the last option:
|
1108 |
+
* ```ts
|
1109 |
+
* selectMenu.spliceOptions(-1, 1);
|
1110 |
+
* ```
|
1111 |
+
* @param index - The index to start at
|
1112 |
+
* @param deleteCount - The number of options to remove
|
1113 |
+
* @param options - The replacing option objects or builders
|
1114 |
+
*/
|
1115 |
+
spliceOptions(index, deleteCount, ...options) {
|
1116 |
+
const normalizedOptions = normalizeArray(options);
|
1117 |
+
const clone = [...this.options];
|
1118 |
+
clone.splice(
|
1119 |
+
index,
|
1120 |
+
deleteCount,
|
1121 |
+
...normalizedOptions.map(
|
1122 |
+
(normalizedOption) => normalizedOption instanceof StringSelectMenuOptionBuilder ? normalizedOption : new StringSelectMenuOptionBuilder(jsonOptionValidator.parse(normalizedOption))
|
1123 |
+
)
|
1124 |
+
);
|
1125 |
+
optionsLengthValidator.parse(clone.length);
|
1126 |
+
this.options.splice(0, this.options.length, ...clone);
|
1127 |
+
return this;
|
1128 |
+
}
|
1129 |
+
/**
|
1130 |
+
* {@inheritDoc BaseSelectMenuBuilder.toJSON}
|
1131 |
+
*/
|
1132 |
+
toJSON() {
|
1133 |
+
validateRequiredSelectMenuParameters(this.options, this.data.custom_id);
|
1134 |
+
return {
|
1135 |
+
...this.data,
|
1136 |
+
options: this.options.map((option) => option.toJSON())
|
1137 |
+
};
|
1138 |
+
}
|
1139 |
+
};
|
1140 |
+
|
1141 |
+
// src/components/selectMenu/UserSelectMenu.ts
|
1142 |
+
var import_v107 = require("discord-api-types/v10");
|
1143 |
+
var UserSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
1144 |
+
static {
|
1145 |
+
__name(this, "UserSelectMenuBuilder");
|
1146 |
+
}
|
1147 |
+
/**
|
1148 |
+
* Creates a new select menu from API data.
|
1149 |
+
*
|
1150 |
+
* @param data - The API data to create this select menu with
|
1151 |
+
* @example
|
1152 |
+
* Creating a select menu from an API data object:
|
1153 |
+
* ```ts
|
1154 |
+
* const selectMenu = new UserSelectMenuBuilder({
|
1155 |
+
* custom_id: 'a cool select menu',
|
1156 |
+
* placeholder: 'select an option',
|
1157 |
+
* max_values: 2,
|
1158 |
+
* });
|
1159 |
+
* ```
|
1160 |
+
* @example
|
1161 |
+
* Creating a select menu using setters and API data:
|
1162 |
+
* ```ts
|
1163 |
+
* const selectMenu = new UserSelectMenuBuilder({
|
1164 |
+
* custom_id: 'a cool select menu',
|
1165 |
+
* })
|
1166 |
+
* .setMinValues(1);
|
1167 |
+
* ```
|
1168 |
+
*/
|
1169 |
+
constructor(data) {
|
1170 |
+
super({ ...data, type: import_v107.ComponentType.UserSelect });
|
1171 |
+
}
|
1172 |
+
/**
|
1173 |
+
* Adds default users to this auto populated select menu.
|
1174 |
+
*
|
1175 |
+
* @param users - The users to add
|
1176 |
+
*/
|
1177 |
+
addDefaultUsers(...users) {
|
1178 |
+
const normalizedValues = normalizeArray(users);
|
1179 |
+
optionsLengthValidator.parse((this.data.default_values?.length ?? 0) + normalizedValues.length);
|
1180 |
+
this.data.default_values ??= [];
|
1181 |
+
this.data.default_values.push(
|
1182 |
+
...normalizedValues.map((id) => ({
|
1183 |
+
id,
|
1184 |
+
type: import_v107.SelectMenuDefaultValueType.User
|
1185 |
+
}))
|
1186 |
+
);
|
1187 |
+
return this;
|
1188 |
+
}
|
1189 |
+
/**
|
1190 |
+
* Sets default users to this auto populated select menu.
|
1191 |
+
*
|
1192 |
+
* @param users - The users to set
|
1193 |
+
*/
|
1194 |
+
setDefaultUsers(...users) {
|
1195 |
+
const normalizedValues = normalizeArray(users);
|
1196 |
+
optionsLengthValidator.parse(normalizedValues.length);
|
1197 |
+
this.data.default_values = normalizedValues.map((id) => ({
|
1198 |
+
id,
|
1199 |
+
type: import_v107.SelectMenuDefaultValueType.User
|
1200 |
+
}));
|
1201 |
+
return this;
|
1202 |
+
}
|
1203 |
+
};
|
1204 |
+
|
1205 |
+
// src/components/textInput/TextInput.ts
|
1206 |
+
var import_util = require("@discordjs/util");
|
1207 |
+
var import_v109 = require("discord-api-types/v10");
|
1208 |
+
var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
|
1209 |
+
|
1210 |
+
// src/components/textInput/Assertions.ts
|
1211 |
+
var Assertions_exports3 = {};
|
1212 |
+
__export(Assertions_exports3, {
|
1213 |
+
labelValidator: () => labelValidator,
|
1214 |
+
maxLengthValidator: () => maxLengthValidator,
|
1215 |
+
minLengthValidator: () => minLengthValidator,
|
1216 |
+
placeholderValidator: () => placeholderValidator2,
|
1217 |
+
requiredValidator: () => requiredValidator,
|
1218 |
+
textInputStyleValidator: () => textInputStyleValidator,
|
1219 |
+
validateRequiredParameters: () => validateRequiredParameters,
|
1220 |
+
valueValidator: () => valueValidator
|
1221 |
+
});
|
1222 |
+
var import_shapeshift3 = require("@sapphire/shapeshift");
|
1223 |
+
var import_v108 = require("discord-api-types/v10");
|
1224 |
+
var textInputStyleValidator = import_shapeshift3.s.nativeEnum(import_v108.TextInputStyle);
|
1225 |
+
var minLengthValidator = import_shapeshift3.s.number.int.greaterThanOrEqual(0).lessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
1226 |
+
var maxLengthValidator = import_shapeshift3.s.number.int.greaterThanOrEqual(1).lessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
1227 |
+
var requiredValidator = import_shapeshift3.s.boolean;
|
1228 |
+
var valueValidator = import_shapeshift3.s.string.lengthLessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
1229 |
+
var placeholderValidator2 = import_shapeshift3.s.string.lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
|
1230 |
+
var labelValidator = import_shapeshift3.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(45).setValidationEnabled(isValidationEnabled);
|
1231 |
+
function validateRequiredParameters(customId, style, label) {
|
1232 |
+
customIdValidator.parse(customId);
|
1233 |
+
textInputStyleValidator.parse(style);
|
1234 |
+
labelValidator.parse(label);
|
1235 |
+
}
|
1236 |
+
__name(validateRequiredParameters, "validateRequiredParameters");
|
1237 |
+
|
1238 |
+
// src/components/textInput/TextInput.ts
|
1239 |
+
var TextInputBuilder = class extends ComponentBuilder {
|
1240 |
+
static {
|
1241 |
+
__name(this, "TextInputBuilder");
|
1242 |
+
}
|
1243 |
+
/**
|
1244 |
+
* Creates a new text input from API data.
|
1245 |
+
*
|
1246 |
+
* @param data - The API data to create this text input with
|
1247 |
+
* @example
|
1248 |
+
* Creating a select menu option from an API data object:
|
1249 |
+
* ```ts
|
1250 |
+
* const textInput = new TextInputBuilder({
|
1251 |
+
* custom_id: 'a cool select menu',
|
1252 |
+
* label: 'Type something',
|
1253 |
+
* style: TextInputStyle.Short,
|
1254 |
+
* });
|
1255 |
+
* ```
|
1256 |
+
* @example
|
1257 |
+
* Creating a select menu option using setters and API data:
|
1258 |
+
* ```ts
|
1259 |
+
* const textInput = new TextInputBuilder({
|
1260 |
+
* label: 'Type something else',
|
1261 |
+
* })
|
1262 |
+
* .setCustomId('woah')
|
1263 |
+
* .setStyle(TextInputStyle.Paragraph);
|
1264 |
+
* ```
|
1265 |
+
*/
|
1266 |
+
constructor(data) {
|
1267 |
+
super({ type: import_v109.ComponentType.TextInput, ...data });
|
1268 |
+
}
|
1269 |
+
/**
|
1270 |
+
* Sets the custom id for this text input.
|
1271 |
+
*
|
1272 |
+
* @param customId - The custom id to use
|
1273 |
+
*/
|
1274 |
+
setCustomId(customId) {
|
1275 |
+
this.data.custom_id = customIdValidator.parse(customId);
|
1276 |
+
return this;
|
1277 |
+
}
|
1278 |
+
/**
|
1279 |
+
* Sets the label for this text input.
|
1280 |
+
*
|
1281 |
+
* @param label - The label to use
|
1282 |
+
*/
|
1283 |
+
setLabel(label) {
|
1284 |
+
this.data.label = labelValidator.parse(label);
|
1285 |
+
return this;
|
1286 |
+
}
|
1287 |
+
/**
|
1288 |
+
* Sets the style for this text input.
|
1289 |
+
*
|
1290 |
+
* @param style - The style to use
|
1291 |
+
*/
|
1292 |
+
setStyle(style) {
|
1293 |
+
this.data.style = textInputStyleValidator.parse(style);
|
1294 |
+
return this;
|
1295 |
+
}
|
1296 |
+
/**
|
1297 |
+
* Sets the minimum length of text for this text input.
|
1298 |
+
*
|
1299 |
+
* @param minLength - The minimum length of text for this text input
|
1300 |
+
*/
|
1301 |
+
setMinLength(minLength) {
|
1302 |
+
this.data.min_length = minLengthValidator.parse(minLength);
|
1303 |
+
return this;
|
1304 |
+
}
|
1305 |
+
/**
|
1306 |
+
* Sets the maximum length of text for this text input.
|
1307 |
+
*
|
1308 |
+
* @param maxLength - The maximum length of text for this text input
|
1309 |
+
*/
|
1310 |
+
setMaxLength(maxLength) {
|
1311 |
+
this.data.max_length = maxLengthValidator.parse(maxLength);
|
1312 |
+
return this;
|
1313 |
+
}
|
1314 |
+
/**
|
1315 |
+
* Sets the placeholder for this text input.
|
1316 |
+
*
|
1317 |
+
* @param placeholder - The placeholder to use
|
1318 |
+
*/
|
1319 |
+
setPlaceholder(placeholder) {
|
1320 |
+
this.data.placeholder = placeholderValidator2.parse(placeholder);
|
1321 |
+
return this;
|
1322 |
+
}
|
1323 |
+
/**
|
1324 |
+
* Sets the value for this text input.
|
1325 |
+
*
|
1326 |
+
* @param value - The value to use
|
1327 |
+
*/
|
1328 |
+
setValue(value) {
|
1329 |
+
this.data.value = valueValidator.parse(value);
|
1330 |
+
return this;
|
1331 |
+
}
|
1332 |
+
/**
|
1333 |
+
* Sets whether this text input is required.
|
1334 |
+
*
|
1335 |
+
* @param required - Whether this text input is required
|
1336 |
+
*/
|
1337 |
+
setRequired(required = true) {
|
1338 |
+
this.data.required = requiredValidator.parse(required);
|
1339 |
+
return this;
|
1340 |
+
}
|
1341 |
+
/**
|
1342 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
1343 |
+
*/
|
1344 |
+
toJSON() {
|
1345 |
+
validateRequiredParameters(this.data.custom_id, this.data.style, this.data.label);
|
1346 |
+
return {
|
1347 |
+
...this.data
|
1348 |
+
};
|
1349 |
+
}
|
1350 |
+
/**
|
1351 |
+
* {@inheritDoc Equatable.equals}
|
1352 |
+
*/
|
1353 |
+
equals(other) {
|
1354 |
+
if ((0, import_util.isJSONEncodable)(other)) {
|
1355 |
+
return (0, import_fast_deep_equal.default)(other.toJSON(), this.data);
|
1356 |
+
}
|
1357 |
+
return (0, import_fast_deep_equal.default)(other, this.data);
|
1358 |
+
}
|
1359 |
+
};
|
1360 |
+
|
1361 |
+
// src/components/Components.ts
|
1362 |
+
function createComponentBuilder(data) {
|
1363 |
+
if (data instanceof ComponentBuilder) {
|
1364 |
+
return data;
|
1365 |
+
}
|
1366 |
+
switch (data.type) {
|
1367 |
+
case import_v1010.ComponentType.ActionRow:
|
1368 |
+
return new ActionRowBuilder(data);
|
1369 |
+
case import_v1010.ComponentType.Button:
|
1370 |
+
return new ButtonBuilder(data);
|
1371 |
+
case import_v1010.ComponentType.StringSelect:
|
1372 |
+
return new StringSelectMenuBuilder(data);
|
1373 |
+
case import_v1010.ComponentType.TextInput:
|
1374 |
+
return new TextInputBuilder(data);
|
1375 |
+
case import_v1010.ComponentType.UserSelect:
|
1376 |
+
return new UserSelectMenuBuilder(data);
|
1377 |
+
case import_v1010.ComponentType.RoleSelect:
|
1378 |
+
return new RoleSelectMenuBuilder(data);
|
1379 |
+
case import_v1010.ComponentType.MentionableSelect:
|
1380 |
+
return new MentionableSelectMenuBuilder(data);
|
1381 |
+
case import_v1010.ComponentType.ChannelSelect:
|
1382 |
+
return new ChannelSelectMenuBuilder(data);
|
1383 |
+
default:
|
1384 |
+
throw new Error(`Cannot properly serialize component type: ${data.type}`);
|
1385 |
+
}
|
1386 |
+
}
|
1387 |
+
__name(createComponentBuilder, "createComponentBuilder");
|
1388 |
+
|
1389 |
+
// src/components/ActionRow.ts
|
1390 |
+
var ActionRowBuilder = class extends ComponentBuilder {
|
1391 |
+
static {
|
1392 |
+
__name(this, "ActionRowBuilder");
|
1393 |
+
}
|
1394 |
+
/**
|
1395 |
+
* The components within this action row.
|
1396 |
+
*/
|
1397 |
+
components;
|
1398 |
+
/**
|
1399 |
+
* Creates a new action row from API data.
|
1400 |
+
*
|
1401 |
+
* @param data - The API data to create this action row with
|
1402 |
+
* @example
|
1403 |
+
* Creating an action row from an API data object:
|
1404 |
+
* ```ts
|
1405 |
+
* const actionRow = new ActionRowBuilder({
|
1406 |
+
* components: [
|
1407 |
+
* {
|
1408 |
+
* custom_id: "custom id",
|
1409 |
+
* label: "Type something",
|
1410 |
+
* style: TextInputStyle.Short,
|
1411 |
+
* type: ComponentType.TextInput,
|
1412 |
+
* },
|
1413 |
+
* ],
|
1414 |
+
* });
|
1415 |
+
* ```
|
1416 |
+
* @example
|
1417 |
+
* Creating an action row using setters and API data:
|
1418 |
+
* ```ts
|
1419 |
+
* const actionRow = new ActionRowBuilder({
|
1420 |
+
* components: [
|
1421 |
+
* {
|
1422 |
+
* custom_id: "custom id",
|
1423 |
+
* label: "Click me",
|
1424 |
+
* style: ButtonStyle.Primary,
|
1425 |
+
* type: ComponentType.Button,
|
1426 |
+
* },
|
1427 |
+
* ],
|
1428 |
+
* })
|
1429 |
+
* .addComponents(button2, button3);
|
1430 |
+
* ```
|
1431 |
+
*/
|
1432 |
+
constructor({ components, ...data } = {}) {
|
1433 |
+
super({ type: import_v1011.ComponentType.ActionRow, ...data });
|
1434 |
+
this.components = components?.map((component) => createComponentBuilder(component)) ?? [];
|
1435 |
+
}
|
1436 |
+
/**
|
1437 |
+
* Adds components to this action row.
|
1438 |
+
*
|
1439 |
+
* @param components - The components to add
|
1440 |
+
*/
|
1441 |
+
addComponents(...components) {
|
1442 |
+
this.components.push(...normalizeArray(components));
|
1443 |
+
return this;
|
1444 |
+
}
|
1445 |
+
/**
|
1446 |
+
* Sets components for this action row.
|
1447 |
+
*
|
1448 |
+
* @param components - The components to set
|
1449 |
+
*/
|
1450 |
+
setComponents(...components) {
|
1451 |
+
this.components.splice(0, this.components.length, ...normalizeArray(components));
|
1452 |
+
return this;
|
1453 |
+
}
|
1454 |
+
/**
|
1455 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
1456 |
+
*/
|
1457 |
+
toJSON() {
|
1458 |
+
return {
|
1459 |
+
...this.data,
|
1460 |
+
components: this.components.map((component) => component.toJSON())
|
1461 |
+
};
|
1462 |
+
}
|
1463 |
+
};
|
1464 |
+
|
1465 |
+
// src/interactions/modals/Assertions.ts
|
1466 |
+
var Assertions_exports4 = {};
|
1467 |
+
__export(Assertions_exports4, {
|
1468 |
+
componentsValidator: () => componentsValidator,
|
1469 |
+
titleValidator: () => titleValidator,
|
1470 |
+
validateRequiredParameters: () => validateRequiredParameters2
|
1471 |
+
});
|
1472 |
+
var import_shapeshift4 = require("@sapphire/shapeshift");
|
1473 |
+
var titleValidator = import_shapeshift4.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(45).setValidationEnabled(isValidationEnabled);
|
1474 |
+
var componentsValidator = import_shapeshift4.s.instance(ActionRowBuilder).array.lengthGreaterThanOrEqual(1).setValidationEnabled(isValidationEnabled);
|
1475 |
+
function validateRequiredParameters2(customId, title, components) {
|
1476 |
+
customIdValidator.parse(customId);
|
1477 |
+
titleValidator.parse(title);
|
1478 |
+
componentsValidator.parse(components);
|
1479 |
+
}
|
1480 |
+
__name(validateRequiredParameters2, "validateRequiredParameters");
|
1481 |
+
|
1482 |
+
// src/interactions/modals/Modal.ts
|
1483 |
+
var ModalBuilder = class {
|
1484 |
+
static {
|
1485 |
+
__name(this, "ModalBuilder");
|
1486 |
+
}
|
1487 |
+
/**
|
1488 |
+
* The API data associated with this modal.
|
1489 |
+
*/
|
1490 |
+
data;
|
1491 |
+
/**
|
1492 |
+
* The components within this modal.
|
1493 |
+
*/
|
1494 |
+
components = [];
|
1495 |
+
/**
|
1496 |
+
* Creates a new modal from API data.
|
1497 |
+
*
|
1498 |
+
* @param data - The API data to create this modal with
|
1499 |
+
*/
|
1500 |
+
constructor({ components, ...data } = {}) {
|
1501 |
+
this.data = { ...data };
|
1502 |
+
this.components = components?.map((component) => createComponentBuilder(component)) ?? [];
|
1503 |
+
}
|
1504 |
+
/**
|
1505 |
+
* Sets the title of this modal.
|
1506 |
+
*
|
1507 |
+
* @param title - The title to use
|
1508 |
+
*/
|
1509 |
+
setTitle(title) {
|
1510 |
+
this.data.title = titleValidator.parse(title);
|
1511 |
+
return this;
|
1512 |
+
}
|
1513 |
+
/**
|
1514 |
+
* Sets the custom id of this modal.
|
1515 |
+
*
|
1516 |
+
* @param customId - The custom id to use
|
1517 |
+
*/
|
1518 |
+
setCustomId(customId) {
|
1519 |
+
this.data.custom_id = customIdValidator.parse(customId);
|
1520 |
+
return this;
|
1521 |
+
}
|
1522 |
+
/**
|
1523 |
+
* Adds components to this modal.
|
1524 |
+
*
|
1525 |
+
* @param components - The components to add
|
1526 |
+
*/
|
1527 |
+
addComponents(...components) {
|
1528 |
+
this.components.push(
|
1529 |
+
...normalizeArray(components).map(
|
1530 |
+
(component) => component instanceof ActionRowBuilder ? component : new ActionRowBuilder(component)
|
1531 |
+
)
|
1532 |
+
);
|
1533 |
+
return this;
|
1534 |
+
}
|
1535 |
+
/**
|
1536 |
+
* Sets components for this modal.
|
1537 |
+
*
|
1538 |
+
* @param components - The components to set
|
1539 |
+
*/
|
1540 |
+
setComponents(...components) {
|
1541 |
+
this.components.splice(0, this.components.length, ...normalizeArray(components));
|
1542 |
+
return this;
|
1543 |
+
}
|
1544 |
+
/**
|
1545 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
1546 |
+
*/
|
1547 |
+
toJSON() {
|
1548 |
+
validateRequiredParameters2(this.data.custom_id, this.data.title, this.components);
|
1549 |
+
return {
|
1550 |
+
...this.data,
|
1551 |
+
components: this.components.map((component) => component.toJSON())
|
1552 |
+
};
|
1553 |
+
}
|
1554 |
+
};
|
1555 |
+
|
1556 |
+
// src/interactions/slashCommands/Assertions.ts
|
1557 |
+
var Assertions_exports5 = {};
|
1558 |
+
__export(Assertions_exports5, {
|
1559 |
+
assertReturnOfBuilder: () => assertReturnOfBuilder,
|
1560 |
+
localizationMapPredicate: () => localizationMapPredicate,
|
1561 |
+
validateChoicesLength: () => validateChoicesLength,
|
1562 |
+
validateDMPermission: () => validateDMPermission,
|
1563 |
+
validateDefaultMemberPermissions: () => validateDefaultMemberPermissions,
|
1564 |
+
validateDefaultPermission: () => validateDefaultPermission,
|
1565 |
+
validateDescription: () => validateDescription,
|
1566 |
+
validateLocale: () => validateLocale,
|
1567 |
+
validateLocalizationMap: () => validateLocalizationMap,
|
1568 |
+
validateMaxOptionsLength: () => validateMaxOptionsLength,
|
1569 |
+
validateNSFW: () => validateNSFW,
|
1570 |
+
validateName: () => validateName,
|
1571 |
+
validateRequired: () => validateRequired,
|
1572 |
+
validateRequiredParameters: () => validateRequiredParameters3
|
1573 |
+
});
|
1574 |
+
var import_shapeshift5 = require("@sapphire/shapeshift");
|
1575 |
+
var import_v1012 = require("discord-api-types/v10");
|
1576 |
+
var namePredicate = import_shapeshift5.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(32).regex(/^[\p{Ll}\p{Lm}\p{Lo}\p{N}\p{sc=Devanagari}\p{sc=Thai}_-]+$/u).setValidationEnabled(isValidationEnabled);
|
1577 |
+
function validateName(name) {
|
1578 |
+
namePredicate.parse(name);
|
1579 |
+
}
|
1580 |
+
__name(validateName, "validateName");
|
1581 |
+
var descriptionPredicate2 = import_shapeshift5.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
|
1582 |
+
var localePredicate = import_shapeshift5.s.nativeEnum(import_v1012.Locale);
|
1583 |
+
function validateDescription(description) {
|
1584 |
+
descriptionPredicate2.parse(description);
|
1585 |
+
}
|
1586 |
+
__name(validateDescription, "validateDescription");
|
1587 |
+
var maxArrayLengthPredicate = import_shapeshift5.s.unknown.array.lengthLessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
|
1588 |
+
function validateLocale(locale) {
|
1589 |
+
return localePredicate.parse(locale);
|
1590 |
+
}
|
1591 |
+
__name(validateLocale, "validateLocale");
|
1592 |
+
function validateMaxOptionsLength(options) {
|
1593 |
+
maxArrayLengthPredicate.parse(options);
|
1594 |
+
}
|
1595 |
+
__name(validateMaxOptionsLength, "validateMaxOptionsLength");
|
1596 |
+
function validateRequiredParameters3(name, description, options) {
|
1597 |
+
validateName(name);
|
1598 |
+
validateDescription(description);
|
1599 |
+
validateMaxOptionsLength(options);
|
1600 |
+
}
|
1601 |
+
__name(validateRequiredParameters3, "validateRequiredParameters");
|
1602 |
+
var booleanPredicate = import_shapeshift5.s.boolean;
|
1603 |
+
function validateDefaultPermission(value) {
|
1604 |
+
booleanPredicate.parse(value);
|
1605 |
+
}
|
1606 |
+
__name(validateDefaultPermission, "validateDefaultPermission");
|
1607 |
+
function validateRequired(required) {
|
1608 |
+
booleanPredicate.parse(required);
|
1609 |
+
}
|
1610 |
+
__name(validateRequired, "validateRequired");
|
1611 |
+
var choicesLengthPredicate = import_shapeshift5.s.number.lessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
|
1612 |
+
function validateChoicesLength(amountAdding, choices) {
|
1613 |
+
choicesLengthPredicate.parse((choices?.length ?? 0) + amountAdding);
|
1614 |
+
}
|
1615 |
+
__name(validateChoicesLength, "validateChoicesLength");
|
1616 |
+
function assertReturnOfBuilder(input, ExpectedInstanceOf) {
|
1617 |
+
import_shapeshift5.s.instance(ExpectedInstanceOf).parse(input);
|
1618 |
+
}
|
1619 |
+
__name(assertReturnOfBuilder, "assertReturnOfBuilder");
|
1620 |
+
var localizationMapPredicate = import_shapeshift5.s.object(Object.fromEntries(Object.values(import_v1012.Locale).map((locale) => [locale, import_shapeshift5.s.string.nullish]))).strict.nullish.setValidationEnabled(isValidationEnabled);
|
1621 |
+
function validateLocalizationMap(value) {
|
1622 |
+
localizationMapPredicate.parse(value);
|
1623 |
+
}
|
1624 |
+
__name(validateLocalizationMap, "validateLocalizationMap");
|
1625 |
+
var dmPermissionPredicate = import_shapeshift5.s.boolean.nullish;
|
1626 |
+
function validateDMPermission(value) {
|
1627 |
+
dmPermissionPredicate.parse(value);
|
1628 |
+
}
|
1629 |
+
__name(validateDMPermission, "validateDMPermission");
|
1630 |
+
var memberPermissionPredicate = import_shapeshift5.s.union(
|
1631 |
+
import_shapeshift5.s.bigint.transform((value) => value.toString()),
|
1632 |
+
import_shapeshift5.s.number.safeInt.transform((value) => value.toString()),
|
1633 |
+
import_shapeshift5.s.string.regex(/^\d+$/)
|
1634 |
+
).nullish;
|
1635 |
+
function validateDefaultMemberPermissions(permissions) {
|
1636 |
+
return memberPermissionPredicate.parse(permissions);
|
1637 |
+
}
|
1638 |
+
__name(validateDefaultMemberPermissions, "validateDefaultMemberPermissions");
|
1639 |
+
function validateNSFW(value) {
|
1640 |
+
booleanPredicate.parse(value);
|
1641 |
+
}
|
1642 |
+
__name(validateNSFW, "validateNSFW");
|
1643 |
+
|
1644 |
+
// src/interactions/slashCommands/SlashCommandBuilder.ts
|
1645 |
+
var import_ts_mixer6 = require("ts-mixer");
|
1646 |
+
|
1647 |
+
// src/interactions/slashCommands/SlashCommandSubcommands.ts
|
1648 |
+
var import_v1024 = require("discord-api-types/v10");
|
1649 |
+
var import_ts_mixer5 = require("ts-mixer");
|
1650 |
+
|
1651 |
+
// src/interactions/slashCommands/mixins/NameAndDescription.ts
|
1652 |
+
var SharedNameAndDescription = class {
|
1653 |
+
static {
|
1654 |
+
__name(this, "SharedNameAndDescription");
|
1655 |
+
}
|
1656 |
+
/**
|
1657 |
+
* The name of this command.
|
1658 |
+
*/
|
1659 |
+
name;
|
1660 |
+
/**
|
1661 |
+
* The name localizations of this command.
|
1662 |
+
*/
|
1663 |
+
name_localizations;
|
1664 |
+
/**
|
1665 |
+
* The description of this command.
|
1666 |
+
*/
|
1667 |
+
description;
|
1668 |
+
/**
|
1669 |
+
* The description localizations of this command.
|
1670 |
+
*/
|
1671 |
+
description_localizations;
|
1672 |
+
/**
|
1673 |
+
* Sets the name of this command.
|
1674 |
+
*
|
1675 |
+
* @param name - The name to use
|
1676 |
+
*/
|
1677 |
+
setName(name) {
|
1678 |
+
validateName(name);
|
1679 |
+
Reflect.set(this, "name", name);
|
1680 |
+
return this;
|
1681 |
+
}
|
1682 |
+
/**
|
1683 |
+
* Sets the description of this command.
|
1684 |
+
*
|
1685 |
+
* @param description - The description to use
|
1686 |
+
*/
|
1687 |
+
setDescription(description) {
|
1688 |
+
validateDescription(description);
|
1689 |
+
Reflect.set(this, "description", description);
|
1690 |
+
return this;
|
1691 |
+
}
|
1692 |
+
/**
|
1693 |
+
* Sets a name localization for this command.
|
1694 |
+
*
|
1695 |
+
* @param locale - The locale to set
|
1696 |
+
* @param localizedName - The localized name for the given `locale`
|
1697 |
+
*/
|
1698 |
+
setNameLocalization(locale, localizedName) {
|
1699 |
+
if (!this.name_localizations) {
|
1700 |
+
Reflect.set(this, "name_localizations", {});
|
1701 |
+
}
|
1702 |
+
const parsedLocale = validateLocale(locale);
|
1703 |
+
if (localizedName === null) {
|
1704 |
+
this.name_localizations[parsedLocale] = null;
|
1705 |
+
return this;
|
1706 |
+
}
|
1707 |
+
validateName(localizedName);
|
1708 |
+
this.name_localizations[parsedLocale] = localizedName;
|
1709 |
+
return this;
|
1710 |
+
}
|
1711 |
+
/**
|
1712 |
+
* Sets the name localizations for this command.
|
1713 |
+
*
|
1714 |
+
* @param localizedNames - The object of localized names to set
|
1715 |
+
*/
|
1716 |
+
setNameLocalizations(localizedNames) {
|
1717 |
+
if (localizedNames === null) {
|
1718 |
+
Reflect.set(this, "name_localizations", null);
|
1719 |
+
return this;
|
1720 |
+
}
|
1721 |
+
Reflect.set(this, "name_localizations", {});
|
1722 |
+
for (const args of Object.entries(localizedNames)) {
|
1723 |
+
this.setNameLocalization(...args);
|
1724 |
+
}
|
1725 |
+
return this;
|
1726 |
+
}
|
1727 |
+
/**
|
1728 |
+
* Sets a description localization for this command.
|
1729 |
+
*
|
1730 |
+
* @param locale - The locale to set
|
1731 |
+
* @param localizedDescription - The localized description for the given locale
|
1732 |
+
*/
|
1733 |
+
setDescriptionLocalization(locale, localizedDescription) {
|
1734 |
+
if (!this.description_localizations) {
|
1735 |
+
Reflect.set(this, "description_localizations", {});
|
1736 |
+
}
|
1737 |
+
const parsedLocale = validateLocale(locale);
|
1738 |
+
if (localizedDescription === null) {
|
1739 |
+
this.description_localizations[parsedLocale] = null;
|
1740 |
+
return this;
|
1741 |
+
}
|
1742 |
+
validateDescription(localizedDescription);
|
1743 |
+
this.description_localizations[parsedLocale] = localizedDescription;
|
1744 |
+
return this;
|
1745 |
+
}
|
1746 |
+
/**
|
1747 |
+
* Sets the description localizations for this command.
|
1748 |
+
*
|
1749 |
+
* @param localizedDescriptions - The object of localized descriptions to set
|
1750 |
+
*/
|
1751 |
+
setDescriptionLocalizations(localizedDescriptions) {
|
1752 |
+
if (localizedDescriptions === null) {
|
1753 |
+
Reflect.set(this, "description_localizations", null);
|
1754 |
+
return this;
|
1755 |
+
}
|
1756 |
+
Reflect.set(this, "description_localizations", {});
|
1757 |
+
for (const args of Object.entries(localizedDescriptions)) {
|
1758 |
+
this.setDescriptionLocalization(...args);
|
1759 |
+
}
|
1760 |
+
return this;
|
1761 |
+
}
|
1762 |
+
};
|
1763 |
+
|
1764 |
+
// src/interactions/slashCommands/options/attachment.ts
|
1765 |
+
var import_v1013 = require("discord-api-types/v10");
|
1766 |
+
|
1767 |
+
// src/interactions/slashCommands/mixins/ApplicationCommandOptionBase.ts
|
1768 |
+
var ApplicationCommandOptionBase = class extends SharedNameAndDescription {
|
1769 |
+
static {
|
1770 |
+
__name(this, "ApplicationCommandOptionBase");
|
1771 |
+
}
|
1772 |
+
/**
|
1773 |
+
* Whether this option is required.
|
1774 |
+
*
|
1775 |
+
* @defaultValue `false`
|
1776 |
+
*/
|
1777 |
+
required = false;
|
1778 |
+
/**
|
1779 |
+
* Sets whether this option is required.
|
1780 |
+
*
|
1781 |
+
* @param required - Whether this option should be required
|
1782 |
+
*/
|
1783 |
+
setRequired(required) {
|
1784 |
+
validateRequired(required);
|
1785 |
+
Reflect.set(this, "required", required);
|
1786 |
+
return this;
|
1787 |
+
}
|
1788 |
+
/**
|
1789 |
+
* This method runs required validators on this builder.
|
1790 |
+
*/
|
1791 |
+
runRequiredValidations() {
|
1792 |
+
validateRequiredParameters3(this.name, this.description, []);
|
1793 |
+
validateLocalizationMap(this.name_localizations);
|
1794 |
+
validateLocalizationMap(this.description_localizations);
|
1795 |
+
validateRequired(this.required);
|
1796 |
+
}
|
1797 |
+
};
|
1798 |
+
|
1799 |
+
// src/interactions/slashCommands/options/attachment.ts
|
1800 |
+
var SlashCommandAttachmentOption = class extends ApplicationCommandOptionBase {
|
1801 |
+
static {
|
1802 |
+
__name(this, "SlashCommandAttachmentOption");
|
1803 |
+
}
|
1804 |
+
/**
|
1805 |
+
* The type of this option.
|
1806 |
+
*/
|
1807 |
+
type = import_v1013.ApplicationCommandOptionType.Attachment;
|
1808 |
+
/**
|
1809 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1810 |
+
*/
|
1811 |
+
toJSON() {
|
1812 |
+
this.runRequiredValidations();
|
1813 |
+
return { ...this };
|
1814 |
+
}
|
1815 |
+
};
|
1816 |
+
|
1817 |
+
// src/interactions/slashCommands/options/boolean.ts
|
1818 |
+
var import_v1014 = require("discord-api-types/v10");
|
1819 |
+
var SlashCommandBooleanOption = class extends ApplicationCommandOptionBase {
|
1820 |
+
static {
|
1821 |
+
__name(this, "SlashCommandBooleanOption");
|
1822 |
+
}
|
1823 |
+
/**
|
1824 |
+
* The type of this option.
|
1825 |
+
*/
|
1826 |
+
type = import_v1014.ApplicationCommandOptionType.Boolean;
|
1827 |
+
/**
|
1828 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1829 |
+
*/
|
1830 |
+
toJSON() {
|
1831 |
+
this.runRequiredValidations();
|
1832 |
+
return { ...this };
|
1833 |
+
}
|
1834 |
+
};
|
1835 |
+
|
1836 |
+
// src/interactions/slashCommands/options/channel.ts
|
1837 |
+
var import_v1016 = require("discord-api-types/v10");
|
1838 |
+
var import_ts_mixer = require("ts-mixer");
|
1839 |
+
|
1840 |
+
// src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts
|
1841 |
+
var import_shapeshift6 = require("@sapphire/shapeshift");
|
1842 |
+
var import_v1015 = require("discord-api-types/v10");
|
1843 |
+
var allowedChannelTypes = [
|
1844 |
+
import_v1015.ChannelType.GuildText,
|
1845 |
+
import_v1015.ChannelType.GuildVoice,
|
1846 |
+
import_v1015.ChannelType.GuildCategory,
|
1847 |
+
import_v1015.ChannelType.GuildAnnouncement,
|
1848 |
+
import_v1015.ChannelType.AnnouncementThread,
|
1849 |
+
import_v1015.ChannelType.PublicThread,
|
1850 |
+
import_v1015.ChannelType.PrivateThread,
|
1851 |
+
import_v1015.ChannelType.GuildStageVoice,
|
1852 |
+
import_v1015.ChannelType.GuildForum,
|
1853 |
+
import_v1015.ChannelType.GuildMedia
|
1854 |
+
];
|
1855 |
+
var channelTypesPredicate = import_shapeshift6.s.array(import_shapeshift6.s.union(...allowedChannelTypes.map((type) => import_shapeshift6.s.literal(type))));
|
1856 |
+
var ApplicationCommandOptionChannelTypesMixin = class {
|
1857 |
+
static {
|
1858 |
+
__name(this, "ApplicationCommandOptionChannelTypesMixin");
|
1859 |
+
}
|
1860 |
+
/**
|
1861 |
+
* The channel types of this option.
|
1862 |
+
*/
|
1863 |
+
channel_types;
|
1864 |
+
/**
|
1865 |
+
* Adds channel types to this option.
|
1866 |
+
*
|
1867 |
+
* @param channelTypes - The channel types
|
1868 |
+
*/
|
1869 |
+
addChannelTypes(...channelTypes) {
|
1870 |
+
if (this.channel_types === void 0) {
|
1871 |
+
Reflect.set(this, "channel_types", []);
|
1872 |
+
}
|
1873 |
+
this.channel_types.push(...channelTypesPredicate.parse(channelTypes));
|
1874 |
+
return this;
|
1875 |
+
}
|
1876 |
+
};
|
1877 |
+
|
1878 |
+
// src/interactions/slashCommands/options/channel.ts
|
1879 |
+
var SlashCommandChannelOption = class extends ApplicationCommandOptionBase {
|
1880 |
+
/**
|
1881 |
+
* The type of this option.
|
1882 |
+
*/
|
1883 |
+
type = import_v1016.ApplicationCommandOptionType.Channel;
|
1884 |
+
/**
|
1885 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1886 |
+
*/
|
1887 |
+
toJSON() {
|
1888 |
+
this.runRequiredValidations();
|
1889 |
+
return { ...this };
|
1890 |
+
}
|
1891 |
+
};
|
1892 |
+
__name(SlashCommandChannelOption, "SlashCommandChannelOption");
|
1893 |
+
SlashCommandChannelOption = __decorateClass([
|
1894 |
+
(0, import_ts_mixer.mix)(ApplicationCommandOptionChannelTypesMixin)
|
1895 |
+
], SlashCommandChannelOption);
|
1896 |
+
|
1897 |
+
// src/interactions/slashCommands/options/integer.ts
|
1898 |
+
var import_shapeshift8 = require("@sapphire/shapeshift");
|
1899 |
+
var import_v1018 = require("discord-api-types/v10");
|
1900 |
+
var import_ts_mixer2 = require("ts-mixer");
|
1901 |
+
|
1902 |
+
// src/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.ts
|
1903 |
+
var ApplicationCommandNumericOptionMinMaxValueMixin = class {
|
1904 |
+
static {
|
1905 |
+
__name(this, "ApplicationCommandNumericOptionMinMaxValueMixin");
|
1906 |
+
}
|
1907 |
+
/**
|
1908 |
+
* The maximum value of this option.
|
1909 |
+
*/
|
1910 |
+
max_value;
|
1911 |
+
/**
|
1912 |
+
* The minimum value of this option.
|
1913 |
+
*/
|
1914 |
+
min_value;
|
1915 |
+
};
|
1916 |
+
|
1917 |
+
// src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts
|
1918 |
+
var import_shapeshift7 = require("@sapphire/shapeshift");
|
1919 |
+
var import_v1017 = require("discord-api-types/v10");
|
1920 |
+
var stringPredicate = import_shapeshift7.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100);
|
1921 |
+
var numberPredicate = import_shapeshift7.s.number.greaterThan(Number.NEGATIVE_INFINITY).lessThan(Number.POSITIVE_INFINITY);
|
1922 |
+
var choicesPredicate = import_shapeshift7.s.object({
|
1923 |
+
name: stringPredicate,
|
1924 |
+
name_localizations: localizationMapPredicate,
|
1925 |
+
value: import_shapeshift7.s.union(stringPredicate, numberPredicate)
|
1926 |
+
}).array;
|
1927 |
+
var booleanPredicate2 = import_shapeshift7.s.boolean;
|
1928 |
+
var ApplicationCommandOptionWithChoicesAndAutocompleteMixin = class {
|
1929 |
+
static {
|
1930 |
+
__name(this, "ApplicationCommandOptionWithChoicesAndAutocompleteMixin");
|
1931 |
+
}
|
1932 |
+
/**
|
1933 |
+
* The choices of this option.
|
1934 |
+
*/
|
1935 |
+
choices;
|
1936 |
+
/**
|
1937 |
+
* Whether this option utilizes autocomplete.
|
1938 |
+
*/
|
1939 |
+
autocomplete;
|
1940 |
+
/**
|
1941 |
+
* The type of this option.
|
1942 |
+
*
|
1943 |
+
* @privateRemarks Since this is present and this is a mixin, this is needed.
|
1944 |
+
*/
|
1945 |
+
type;
|
1946 |
+
/**
|
1947 |
+
* Adds multiple choices to this option.
|
1948 |
+
*
|
1949 |
+
* @param choices - The choices to add
|
1950 |
+
*/
|
1951 |
+
addChoices(...choices) {
|
1952 |
+
if (choices.length > 0 && this.autocomplete) {
|
1953 |
+
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
|
1954 |
+
}
|
1955 |
+
choicesPredicate.parse(choices);
|
1956 |
+
if (this.choices === void 0) {
|
1957 |
+
Reflect.set(this, "choices", []);
|
1958 |
+
}
|
1959 |
+
validateChoicesLength(choices.length, this.choices);
|
1960 |
+
for (const { name, name_localizations, value } of choices) {
|
1961 |
+
if (this.type === import_v1017.ApplicationCommandOptionType.String) {
|
1962 |
+
stringPredicate.parse(value);
|
1963 |
+
} else {
|
1964 |
+
numberPredicate.parse(value);
|
1965 |
+
}
|
1966 |
+
this.choices.push({ name, name_localizations, value });
|
1967 |
+
}
|
1968 |
+
return this;
|
1969 |
+
}
|
1970 |
+
/**
|
1971 |
+
* Sets multiple choices for this option.
|
1972 |
+
*
|
1973 |
+
* @param choices - The choices to set
|
1974 |
+
*/
|
1975 |
+
setChoices(...choices) {
|
1976 |
+
if (choices.length > 0 && this.autocomplete) {
|
1977 |
+
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
|
1978 |
+
}
|
1979 |
+
choicesPredicate.parse(choices);
|
1980 |
+
Reflect.set(this, "choices", []);
|
1981 |
+
this.addChoices(...choices);
|
1982 |
+
return this;
|
1983 |
+
}
|
1984 |
+
/**
|
1985 |
+
* Whether this option uses autocomplete.
|
1986 |
+
*
|
1987 |
+
* @param autocomplete - Whether this option should use autocomplete
|
1988 |
+
*/
|
1989 |
+
setAutocomplete(autocomplete) {
|
1990 |
+
booleanPredicate2.parse(autocomplete);
|
1991 |
+
if (autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {
|
1992 |
+
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
|
1993 |
+
}
|
1994 |
+
Reflect.set(this, "autocomplete", autocomplete);
|
1995 |
+
return this;
|
1996 |
+
}
|
1997 |
+
};
|
1998 |
+
|
1999 |
+
// src/interactions/slashCommands/options/integer.ts
|
2000 |
+
var numberValidator = import_shapeshift8.s.number.int;
|
2001 |
+
var SlashCommandIntegerOption = class extends ApplicationCommandOptionBase {
|
2002 |
+
/**
|
2003 |
+
* The type of this option.
|
2004 |
+
*/
|
2005 |
+
type = import_v1018.ApplicationCommandOptionType.Integer;
|
2006 |
+
/**
|
2007 |
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}
|
2008 |
+
*/
|
2009 |
+
setMaxValue(max) {
|
2010 |
+
numberValidator.parse(max);
|
2011 |
+
Reflect.set(this, "max_value", max);
|
2012 |
+
return this;
|
2013 |
+
}
|
2014 |
+
/**
|
2015 |
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMinValue}
|
2016 |
+
*/
|
2017 |
+
setMinValue(min) {
|
2018 |
+
numberValidator.parse(min);
|
2019 |
+
Reflect.set(this, "min_value", min);
|
2020 |
+
return this;
|
2021 |
+
}
|
2022 |
+
/**
|
2023 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
2024 |
+
*/
|
2025 |
+
toJSON() {
|
2026 |
+
this.runRequiredValidations();
|
2027 |
+
if (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {
|
2028 |
+
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
|
2029 |
+
}
|
2030 |
+
return { ...this };
|
2031 |
+
}
|
2032 |
+
};
|
2033 |
+
__name(SlashCommandIntegerOption, "SlashCommandIntegerOption");
|
2034 |
+
SlashCommandIntegerOption = __decorateClass([
|
2035 |
+
(0, import_ts_mixer2.mix)(ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin)
|
2036 |
+
], SlashCommandIntegerOption);
|
2037 |
+
|
2038 |
+
// src/interactions/slashCommands/options/mentionable.ts
|
2039 |
+
var import_v1019 = require("discord-api-types/v10");
|
2040 |
+
var SlashCommandMentionableOption = class extends ApplicationCommandOptionBase {
|
2041 |
+
static {
|
2042 |
+
__name(this, "SlashCommandMentionableOption");
|
2043 |
+
}
|
2044 |
+
/**
|
2045 |
+
* The type of this option.
|
2046 |
+
*/
|
2047 |
+
type = import_v1019.ApplicationCommandOptionType.Mentionable;
|
2048 |
+
/**
|
2049 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
2050 |
+
*/
|
2051 |
+
toJSON() {
|
2052 |
+
this.runRequiredValidations();
|
2053 |
+
return { ...this };
|
2054 |
+
}
|
2055 |
+
};
|
2056 |
+
|
2057 |
+
// src/interactions/slashCommands/options/number.ts
|
2058 |
+
var import_shapeshift9 = require("@sapphire/shapeshift");
|
2059 |
+
var import_v1020 = require("discord-api-types/v10");
|
2060 |
+
var import_ts_mixer3 = require("ts-mixer");
|
2061 |
+
var numberValidator2 = import_shapeshift9.s.number;
|
2062 |
+
var SlashCommandNumberOption = class extends ApplicationCommandOptionBase {
|
2063 |
+
/**
|
2064 |
+
* The type of this option.
|
2065 |
+
*/
|
2066 |
+
type = import_v1020.ApplicationCommandOptionType.Number;
|
2067 |
+
/**
|
2068 |
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}
|
2069 |
+
*/
|
2070 |
+
setMaxValue(max) {
|
2071 |
+
numberValidator2.parse(max);
|
2072 |
+
Reflect.set(this, "max_value", max);
|
2073 |
+
return this;
|
2074 |
+
}
|
2075 |
+
/**
|
2076 |
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMinValue}
|
2077 |
+
*/
|
2078 |
+
setMinValue(min) {
|
2079 |
+
numberValidator2.parse(min);
|
2080 |
+
Reflect.set(this, "min_value", min);
|
2081 |
+
return this;
|
2082 |
+
}
|
2083 |
+
/**
|
2084 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
2085 |
+
*/
|
2086 |
+
toJSON() {
|
2087 |
+
this.runRequiredValidations();
|
2088 |
+
if (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {
|
2089 |
+
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
|
2090 |
+
}
|
2091 |
+
return { ...this };
|
2092 |
+
}
|
2093 |
+
};
|
2094 |
+
__name(SlashCommandNumberOption, "SlashCommandNumberOption");
|
2095 |
+
SlashCommandNumberOption = __decorateClass([
|
2096 |
+
(0, import_ts_mixer3.mix)(ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin)
|
2097 |
+
], SlashCommandNumberOption);
|
2098 |
+
|
2099 |
+
// src/interactions/slashCommands/options/role.ts
|
2100 |
+
var import_v1021 = require("discord-api-types/v10");
|
2101 |
+
var SlashCommandRoleOption = class extends ApplicationCommandOptionBase {
|
2102 |
+
static {
|
2103 |
+
__name(this, "SlashCommandRoleOption");
|
2104 |
+
}
|
2105 |
+
/**
|
2106 |
+
* The type of this option.
|
2107 |
+
*/
|
2108 |
+
type = import_v1021.ApplicationCommandOptionType.Role;
|
2109 |
+
/**
|
2110 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
2111 |
+
*/
|
2112 |
+
toJSON() {
|
2113 |
+
this.runRequiredValidations();
|
2114 |
+
return { ...this };
|
2115 |
+
}
|
2116 |
+
};
|
2117 |
+
|
2118 |
+
// src/interactions/slashCommands/options/string.ts
|
2119 |
+
var import_shapeshift10 = require("@sapphire/shapeshift");
|
2120 |
+
var import_v1022 = require("discord-api-types/v10");
|
2121 |
+
var import_ts_mixer4 = require("ts-mixer");
|
2122 |
+
var minLengthValidator2 = import_shapeshift10.s.number.greaterThanOrEqual(0).lessThanOrEqual(6e3);
|
2123 |
+
var maxLengthValidator2 = import_shapeshift10.s.number.greaterThanOrEqual(1).lessThanOrEqual(6e3);
|
2124 |
+
var SlashCommandStringOption = class extends ApplicationCommandOptionBase {
|
2125 |
+
/**
|
2126 |
+
* The type of this option.
|
2127 |
+
*/
|
2128 |
+
type = import_v1022.ApplicationCommandOptionType.String;
|
2129 |
+
/**
|
2130 |
+
* The maximum length of this option.
|
2131 |
+
*/
|
2132 |
+
max_length;
|
2133 |
+
/**
|
2134 |
+
* The minimum length of this option.
|
2135 |
+
*/
|
2136 |
+
min_length;
|
2137 |
+
/**
|
2138 |
+
* Sets the maximum length of this string option.
|
2139 |
+
*
|
2140 |
+
* @param max - The maximum length this option can be
|
2141 |
+
*/
|
2142 |
+
setMaxLength(max) {
|
2143 |
+
maxLengthValidator2.parse(max);
|
2144 |
+
Reflect.set(this, "max_length", max);
|
2145 |
+
return this;
|
2146 |
+
}
|
2147 |
+
/**
|
2148 |
+
* Sets the minimum length of this string option.
|
2149 |
+
*
|
2150 |
+
* @param min - The minimum length this option can be
|
2151 |
+
*/
|
2152 |
+
setMinLength(min) {
|
2153 |
+
minLengthValidator2.parse(min);
|
2154 |
+
Reflect.set(this, "min_length", min);
|
2155 |
+
return this;
|
2156 |
+
}
|
2157 |
+
/**
|
2158 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
2159 |
+
*/
|
2160 |
+
toJSON() {
|
2161 |
+
this.runRequiredValidations();
|
2162 |
+
if (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {
|
2163 |
+
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
|
2164 |
+
}
|
2165 |
+
return { ...this };
|
2166 |
+
}
|
2167 |
+
};
|
2168 |
+
__name(SlashCommandStringOption, "SlashCommandStringOption");
|
2169 |
+
SlashCommandStringOption = __decorateClass([
|
2170 |
+
(0, import_ts_mixer4.mix)(ApplicationCommandOptionWithChoicesAndAutocompleteMixin)
|
2171 |
+
], SlashCommandStringOption);
|
2172 |
+
|
2173 |
+
// src/interactions/slashCommands/options/user.ts
|
2174 |
+
var import_v1023 = require("discord-api-types/v10");
|
2175 |
+
var SlashCommandUserOption = class extends ApplicationCommandOptionBase {
|
2176 |
+
static {
|
2177 |
+
__name(this, "SlashCommandUserOption");
|
2178 |
+
}
|
2179 |
+
/**
|
2180 |
+
* The type of this option.
|
2181 |
+
*/
|
2182 |
+
type = import_v1023.ApplicationCommandOptionType.User;
|
2183 |
+
/**
|
2184 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
2185 |
+
*/
|
2186 |
+
toJSON() {
|
2187 |
+
this.runRequiredValidations();
|
2188 |
+
return { ...this };
|
2189 |
+
}
|
2190 |
+
};
|
2191 |
+
|
2192 |
+
// src/interactions/slashCommands/mixins/SharedSlashCommandOptions.ts
|
2193 |
+
var SharedSlashCommandOptions = class {
|
2194 |
+
static {
|
2195 |
+
__name(this, "SharedSlashCommandOptions");
|
2196 |
+
}
|
2197 |
+
options;
|
2198 |
+
/**
|
2199 |
+
* Adds a boolean option.
|
2200 |
+
*
|
2201 |
+
* @param input - A function that returns an option builder or an already built builder
|
2202 |
+
*/
|
2203 |
+
addBooleanOption(input) {
|
2204 |
+
return this._sharedAddOptionMethod(input, SlashCommandBooleanOption);
|
2205 |
+
}
|
2206 |
+
/**
|
2207 |
+
* Adds a user option.
|
2208 |
+
*
|
2209 |
+
* @param input - A function that returns an option builder or an already built builder
|
2210 |
+
*/
|
2211 |
+
addUserOption(input) {
|
2212 |
+
return this._sharedAddOptionMethod(input, SlashCommandUserOption);
|
2213 |
+
}
|
2214 |
+
/**
|
2215 |
+
* Adds a channel option.
|
2216 |
+
*
|
2217 |
+
* @param input - A function that returns an option builder or an already built builder
|
2218 |
+
*/
|
2219 |
+
addChannelOption(input) {
|
2220 |
+
return this._sharedAddOptionMethod(input, SlashCommandChannelOption);
|
2221 |
+
}
|
2222 |
+
/**
|
2223 |
+
* Adds a role option.
|
2224 |
+
*
|
2225 |
+
* @param input - A function that returns an option builder or an already built builder
|
2226 |
+
*/
|
2227 |
+
addRoleOption(input) {
|
2228 |
+
return this._sharedAddOptionMethod(input, SlashCommandRoleOption);
|
2229 |
+
}
|
2230 |
+
/**
|
2231 |
+
* Adds an attachment option.
|
2232 |
+
*
|
2233 |
+
* @param input - A function that returns an option builder or an already built builder
|
2234 |
+
*/
|
2235 |
+
addAttachmentOption(input) {
|
2236 |
+
return this._sharedAddOptionMethod(input, SlashCommandAttachmentOption);
|
2237 |
+
}
|
2238 |
+
/**
|
2239 |
+
* Adds a mentionable option.
|
2240 |
+
*
|
2241 |
+
* @param input - A function that returns an option builder or an already built builder
|
2242 |
+
*/
|
2243 |
+
addMentionableOption(input) {
|
2244 |
+
return this._sharedAddOptionMethod(input, SlashCommandMentionableOption);
|
2245 |
+
}
|
2246 |
+
/**
|
2247 |
+
* Adds a string option.
|
2248 |
+
*
|
2249 |
+
* @param input - A function that returns an option builder or an already built builder
|
2250 |
+
*/
|
2251 |
+
addStringOption(input) {
|
2252 |
+
return this._sharedAddOptionMethod(input, SlashCommandStringOption);
|
2253 |
+
}
|
2254 |
+
/**
|
2255 |
+
* Adds an integer option.
|
2256 |
+
*
|
2257 |
+
* @param input - A function that returns an option builder or an already built builder
|
2258 |
+
*/
|
2259 |
+
addIntegerOption(input) {
|
2260 |
+
return this._sharedAddOptionMethod(input, SlashCommandIntegerOption);
|
2261 |
+
}
|
2262 |
+
/**
|
2263 |
+
* Adds a number option.
|
2264 |
+
*
|
2265 |
+
* @param input - A function that returns an option builder or an already built builder
|
2266 |
+
*/
|
2267 |
+
addNumberOption(input) {
|
2268 |
+
return this._sharedAddOptionMethod(input, SlashCommandNumberOption);
|
2269 |
+
}
|
2270 |
+
/**
|
2271 |
+
* Where the actual adding magic happens. ✨
|
2272 |
+
*
|
2273 |
+
* @param input - The input. What else?
|
2274 |
+
* @param Instance - The instance of whatever is being added
|
2275 |
+
* @internal
|
2276 |
+
*/
|
2277 |
+
_sharedAddOptionMethod(input, Instance) {
|
2278 |
+
const { options } = this;
|
2279 |
+
validateMaxOptionsLength(options);
|
2280 |
+
const result = typeof input === "function" ? input(new Instance()) : input;
|
2281 |
+
assertReturnOfBuilder(result, Instance);
|
2282 |
+
options.push(result);
|
2283 |
+
return this;
|
2284 |
+
}
|
2285 |
+
};
|
2286 |
+
|
2287 |
+
// src/interactions/slashCommands/SlashCommandSubcommands.ts
|
2288 |
+
var SlashCommandSubcommandGroupBuilder = class {
|
2289 |
+
/**
|
2290 |
+
* The name of this subcommand group.
|
2291 |
+
*/
|
2292 |
+
name = void 0;
|
2293 |
+
/**
|
2294 |
+
* The description of this subcommand group.
|
2295 |
+
*/
|
2296 |
+
description = void 0;
|
2297 |
+
/**
|
2298 |
+
* The subcommands within this subcommand group.
|
2299 |
+
*/
|
2300 |
+
options = [];
|
2301 |
+
/**
|
2302 |
+
* Adds a new subcommand to this group.
|
2303 |
+
*
|
2304 |
+
* @param input - A function that returns a subcommand builder or an already built builder
|
2305 |
+
*/
|
2306 |
+
addSubcommand(input) {
|
2307 |
+
const { options } = this;
|
2308 |
+
validateMaxOptionsLength(options);
|
2309 |
+
const result = typeof input === "function" ? input(new SlashCommandSubcommandBuilder()) : input;
|
2310 |
+
assertReturnOfBuilder(result, SlashCommandSubcommandBuilder);
|
2311 |
+
options.push(result);
|
2312 |
+
return this;
|
2313 |
+
}
|
2314 |
+
/**
|
2315 |
+
* Serializes this builder to API-compatible JSON data.
|
2316 |
+
*
|
2317 |
+
* @remarks
|
2318 |
+
* This method runs validations on the data before serializing it.
|
2319 |
+
* As such, it may throw an error if the data is invalid.
|
2320 |
+
*/
|
2321 |
+
toJSON() {
|
2322 |
+
validateRequiredParameters3(this.name, this.description, this.options);
|
2323 |
+
return {
|
2324 |
+
type: import_v1024.ApplicationCommandOptionType.SubcommandGroup,
|
2325 |
+
name: this.name,
|
2326 |
+
name_localizations: this.name_localizations,
|
2327 |
+
description: this.description,
|
2328 |
+
description_localizations: this.description_localizations,
|
2329 |
+
options: this.options.map((option) => option.toJSON())
|
2330 |
+
};
|
2331 |
+
}
|
2332 |
+
};
|
2333 |
+
__name(SlashCommandSubcommandGroupBuilder, "SlashCommandSubcommandGroupBuilder");
|
2334 |
+
SlashCommandSubcommandGroupBuilder = __decorateClass([
|
2335 |
+
(0, import_ts_mixer5.mix)(SharedNameAndDescription)
|
2336 |
+
], SlashCommandSubcommandGroupBuilder);
|
2337 |
+
var SlashCommandSubcommandBuilder = class {
|
2338 |
+
/**
|
2339 |
+
* The name of this subcommand.
|
2340 |
+
*/
|
2341 |
+
name = void 0;
|
2342 |
+
/**
|
2343 |
+
* The description of this subcommand.
|
2344 |
+
*/
|
2345 |
+
description = void 0;
|
2346 |
+
/**
|
2347 |
+
* The options within this subcommand.
|
2348 |
+
*/
|
2349 |
+
options = [];
|
2350 |
+
/**
|
2351 |
+
* Serializes this builder to API-compatible JSON data.
|
2352 |
+
*
|
2353 |
+
* @remarks
|
2354 |
+
* This method runs validations on the data before serializing it.
|
2355 |
+
* As such, it may throw an error if the data is invalid.
|
2356 |
+
*/
|
2357 |
+
toJSON() {
|
2358 |
+
validateRequiredParameters3(this.name, this.description, this.options);
|
2359 |
+
return {
|
2360 |
+
type: import_v1024.ApplicationCommandOptionType.Subcommand,
|
2361 |
+
name: this.name,
|
2362 |
+
name_localizations: this.name_localizations,
|
2363 |
+
description: this.description,
|
2364 |
+
description_localizations: this.description_localizations,
|
2365 |
+
options: this.options.map((option) => option.toJSON())
|
2366 |
+
};
|
2367 |
+
}
|
2368 |
+
};
|
2369 |
+
__name(SlashCommandSubcommandBuilder, "SlashCommandSubcommandBuilder");
|
2370 |
+
SlashCommandSubcommandBuilder = __decorateClass([
|
2371 |
+
(0, import_ts_mixer5.mix)(SharedNameAndDescription, SharedSlashCommandOptions)
|
2372 |
+
], SlashCommandSubcommandBuilder);
|
2373 |
+
|
2374 |
+
// src/interactions/slashCommands/SlashCommandBuilder.ts
|
2375 |
+
var SlashCommandBuilder = class {
|
2376 |
+
/**
|
2377 |
+
* The name of this command.
|
2378 |
+
*/
|
2379 |
+
name = void 0;
|
2380 |
+
/**
|
2381 |
+
* The name localizations of this command.
|
2382 |
+
*/
|
2383 |
+
name_localizations;
|
2384 |
+
/**
|
2385 |
+
* The description of this command.
|
2386 |
+
*/
|
2387 |
+
description = void 0;
|
2388 |
+
/**
|
2389 |
+
* The description localizations of this command.
|
2390 |
+
*/
|
2391 |
+
description_localizations;
|
2392 |
+
/**
|
2393 |
+
* The options of this command.
|
2394 |
+
*/
|
2395 |
+
options = [];
|
2396 |
+
/**
|
2397 |
+
* Whether this command is enabled by default when the application is added to a guild.
|
2398 |
+
*
|
2399 |
+
* @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
|
2400 |
+
*/
|
2401 |
+
default_permission = void 0;
|
2402 |
+
/**
|
2403 |
+
* The set of permissions represented as a bit set for the command.
|
2404 |
+
*/
|
2405 |
+
default_member_permissions = void 0;
|
2406 |
+
/**
|
2407 |
+
* Indicates whether the command is available in direct messages with the application.
|
2408 |
+
*
|
2409 |
+
* @remarks
|
2410 |
+
* By default, commands are visible. This property is only for global commands.
|
2411 |
+
*/
|
2412 |
+
dm_permission = void 0;
|
2413 |
+
/**
|
2414 |
+
* Whether this command is NSFW.
|
2415 |
+
*/
|
2416 |
+
nsfw = void 0;
|
2417 |
+
/**
|
2418 |
+
* Sets whether the command is enabled by default when the application is added to a guild.
|
2419 |
+
*
|
2420 |
+
* @remarks
|
2421 |
+
* If set to `false`, you will have to later `PUT` the permissions for this command.
|
2422 |
+
* @param value - Whether or not to enable this command by default
|
2423 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
2424 |
+
* @deprecated Use {@link SlashCommandBuilder.setDefaultMemberPermissions} or {@link SlashCommandBuilder.setDMPermission} instead.
|
2425 |
+
*/
|
2426 |
+
setDefaultPermission(value) {
|
2427 |
+
validateDefaultPermission(value);
|
2428 |
+
Reflect.set(this, "default_permission", value);
|
2429 |
+
return this;
|
2430 |
+
}
|
2431 |
+
/**
|
2432 |
+
* Sets the default permissions a member should have in order to run the command.
|
2433 |
+
*
|
2434 |
+
* @remarks
|
2435 |
+
* You can set this to `'0'` to disable the command by default.
|
2436 |
+
* @param permissions - The permissions bit field to set
|
2437 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
2438 |
+
*/
|
2439 |
+
setDefaultMemberPermissions(permissions) {
|
2440 |
+
const permissionValue = validateDefaultMemberPermissions(permissions);
|
2441 |
+
Reflect.set(this, "default_member_permissions", permissionValue);
|
2442 |
+
return this;
|
2443 |
+
}
|
2444 |
+
/**
|
2445 |
+
* Sets if the command is available in direct messages with the application.
|
2446 |
+
*
|
2447 |
+
* @remarks
|
2448 |
+
* By default, commands are visible. This method is only for global commands.
|
2449 |
+
* @param enabled - Whether the command should be enabled in direct messages
|
2450 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
2451 |
+
*/
|
2452 |
+
setDMPermission(enabled) {
|
2453 |
+
validateDMPermission(enabled);
|
2454 |
+
Reflect.set(this, "dm_permission", enabled);
|
2455 |
+
return this;
|
2456 |
+
}
|
2457 |
+
/**
|
2458 |
+
* Sets whether this command is NSFW.
|
2459 |
+
*
|
2460 |
+
* @param nsfw - Whether this command is NSFW
|
2461 |
+
*/
|
2462 |
+
setNSFW(nsfw = true) {
|
2463 |
+
validateNSFW(nsfw);
|
2464 |
+
Reflect.set(this, "nsfw", nsfw);
|
2465 |
+
return this;
|
2466 |
+
}
|
2467 |
+
/**
|
2468 |
+
* Adds a new subcommand group to this command.
|
2469 |
+
*
|
2470 |
+
* @param input - A function that returns a subcommand group builder or an already built builder
|
2471 |
+
*/
|
2472 |
+
addSubcommandGroup(input) {
|
2473 |
+
const { options } = this;
|
2474 |
+
validateMaxOptionsLength(options);
|
2475 |
+
const result = typeof input === "function" ? input(new SlashCommandSubcommandGroupBuilder()) : input;
|
2476 |
+
assertReturnOfBuilder(result, SlashCommandSubcommandGroupBuilder);
|
2477 |
+
options.push(result);
|
2478 |
+
return this;
|
2479 |
+
}
|
2480 |
+
/**
|
2481 |
+
* Adds a new subcommand to this command.
|
2482 |
+
*
|
2483 |
+
* @param input - A function that returns a subcommand builder or an already built builder
|
2484 |
+
*/
|
2485 |
+
addSubcommand(input) {
|
2486 |
+
const { options } = this;
|
2487 |
+
validateMaxOptionsLength(options);
|
2488 |
+
const result = typeof input === "function" ? input(new SlashCommandSubcommandBuilder()) : input;
|
2489 |
+
assertReturnOfBuilder(result, SlashCommandSubcommandBuilder);
|
2490 |
+
options.push(result);
|
2491 |
+
return this;
|
2492 |
+
}
|
2493 |
+
/**
|
2494 |
+
* Serializes this builder to API-compatible JSON data.
|
2495 |
+
*
|
2496 |
+
* @remarks
|
2497 |
+
* This method runs validations on the data before serializing it.
|
2498 |
+
* As such, it may throw an error if the data is invalid.
|
2499 |
+
*/
|
2500 |
+
toJSON() {
|
2501 |
+
validateRequiredParameters3(this.name, this.description, this.options);
|
2502 |
+
validateLocalizationMap(this.name_localizations);
|
2503 |
+
validateLocalizationMap(this.description_localizations);
|
2504 |
+
return {
|
2505 |
+
...this,
|
2506 |
+
options: this.options.map((option) => option.toJSON())
|
2507 |
+
};
|
2508 |
+
}
|
2509 |
+
};
|
2510 |
+
__name(SlashCommandBuilder, "SlashCommandBuilder");
|
2511 |
+
SlashCommandBuilder = __decorateClass([
|
2512 |
+
(0, import_ts_mixer6.mix)(SharedSlashCommandOptions, SharedNameAndDescription)
|
2513 |
+
], SlashCommandBuilder);
|
2514 |
+
|
2515 |
+
// src/interactions/contextMenuCommands/Assertions.ts
|
2516 |
+
var Assertions_exports6 = {};
|
2517 |
+
__export(Assertions_exports6, {
|
2518 |
+
validateDMPermission: () => validateDMPermission2,
|
2519 |
+
validateDefaultMemberPermissions: () => validateDefaultMemberPermissions2,
|
2520 |
+
validateDefaultPermission: () => validateDefaultPermission2,
|
2521 |
+
validateName: () => validateName2,
|
2522 |
+
validateRequiredParameters: () => validateRequiredParameters4,
|
2523 |
+
validateType: () => validateType
|
2524 |
+
});
|
2525 |
+
var import_shapeshift11 = require("@sapphire/shapeshift");
|
2526 |
+
var import_v1025 = require("discord-api-types/v10");
|
2527 |
+
var namePredicate2 = import_shapeshift11.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(32).regex(/^( *[\p{P}\p{L}\p{N}\p{sc=Devanagari}\p{sc=Thai}]+ *)+$/u).setValidationEnabled(isValidationEnabled);
|
2528 |
+
var typePredicate = import_shapeshift11.s.union(import_shapeshift11.s.literal(import_v1025.ApplicationCommandType.User), import_shapeshift11.s.literal(import_v1025.ApplicationCommandType.Message)).setValidationEnabled(isValidationEnabled);
|
2529 |
+
var booleanPredicate3 = import_shapeshift11.s.boolean;
|
2530 |
+
function validateDefaultPermission2(value) {
|
2531 |
+
booleanPredicate3.parse(value);
|
2532 |
+
}
|
2533 |
+
__name(validateDefaultPermission2, "validateDefaultPermission");
|
2534 |
+
function validateName2(name) {
|
2535 |
+
namePredicate2.parse(name);
|
2536 |
+
}
|
2537 |
+
__name(validateName2, "validateName");
|
2538 |
+
function validateType(type) {
|
2539 |
+
typePredicate.parse(type);
|
2540 |
+
}
|
2541 |
+
__name(validateType, "validateType");
|
2542 |
+
function validateRequiredParameters4(name, type) {
|
2543 |
+
validateName2(name);
|
2544 |
+
validateType(type);
|
2545 |
+
}
|
2546 |
+
__name(validateRequiredParameters4, "validateRequiredParameters");
|
2547 |
+
var dmPermissionPredicate2 = import_shapeshift11.s.boolean.nullish;
|
2548 |
+
function validateDMPermission2(value) {
|
2549 |
+
dmPermissionPredicate2.parse(value);
|
2550 |
+
}
|
2551 |
+
__name(validateDMPermission2, "validateDMPermission");
|
2552 |
+
var memberPermissionPredicate2 = import_shapeshift11.s.union(
|
2553 |
+
import_shapeshift11.s.bigint.transform((value) => value.toString()),
|
2554 |
+
import_shapeshift11.s.number.safeInt.transform((value) => value.toString()),
|
2555 |
+
import_shapeshift11.s.string.regex(/^\d+$/)
|
2556 |
+
).nullish;
|
2557 |
+
function validateDefaultMemberPermissions2(permissions) {
|
2558 |
+
return memberPermissionPredicate2.parse(permissions);
|
2559 |
+
}
|
2560 |
+
__name(validateDefaultMemberPermissions2, "validateDefaultMemberPermissions");
|
2561 |
+
|
2562 |
+
// src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts
|
2563 |
+
var ContextMenuCommandBuilder = class {
|
2564 |
+
static {
|
2565 |
+
__name(this, "ContextMenuCommandBuilder");
|
2566 |
+
}
|
2567 |
+
/**
|
2568 |
+
* The name of this command.
|
2569 |
+
*/
|
2570 |
+
name = void 0;
|
2571 |
+
/**
|
2572 |
+
* The name localizations of this command.
|
2573 |
+
*/
|
2574 |
+
name_localizations;
|
2575 |
+
/**
|
2576 |
+
* The type of this command.
|
2577 |
+
*/
|
2578 |
+
type = void 0;
|
2579 |
+
/**
|
2580 |
+
* Whether this command is enabled by default when the application is added to a guild.
|
2581 |
+
*
|
2582 |
+
* @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
|
2583 |
+
*/
|
2584 |
+
default_permission = void 0;
|
2585 |
+
/**
|
2586 |
+
* The set of permissions represented as a bit set for the command.
|
2587 |
+
*/
|
2588 |
+
default_member_permissions = void 0;
|
2589 |
+
/**
|
2590 |
+
* Indicates whether the command is available in direct messages with the application.
|
2591 |
+
*
|
2592 |
+
* @remarks
|
2593 |
+
* By default, commands are visible. This property is only for global commands.
|
2594 |
+
*/
|
2595 |
+
dm_permission = void 0;
|
2596 |
+
/**
|
2597 |
+
* Sets the name of this command.
|
2598 |
+
*
|
2599 |
+
* @param name - The name to use
|
2600 |
+
*/
|
2601 |
+
setName(name) {
|
2602 |
+
validateName2(name);
|
2603 |
+
Reflect.set(this, "name", name);
|
2604 |
+
return this;
|
2605 |
+
}
|
2606 |
+
/**
|
2607 |
+
* Sets the type of this command.
|
2608 |
+
*
|
2609 |
+
* @param type - The type to use
|
2610 |
+
*/
|
2611 |
+
setType(type) {
|
2612 |
+
validateType(type);
|
2613 |
+
Reflect.set(this, "type", type);
|
2614 |
+
return this;
|
2615 |
+
}
|
2616 |
+
/**
|
2617 |
+
* Sets whether the command is enabled by default when the application is added to a guild.
|
2618 |
+
*
|
2619 |
+
* @remarks
|
2620 |
+
* If set to `false`, you will have to later `PUT` the permissions for this command.
|
2621 |
+
* @param value - Whether to enable this command by default
|
2622 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
2623 |
+
* @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
|
2624 |
+
*/
|
2625 |
+
setDefaultPermission(value) {
|
2626 |
+
validateDefaultPermission2(value);
|
2627 |
+
Reflect.set(this, "default_permission", value);
|
2628 |
+
return this;
|
2629 |
+
}
|
2630 |
+
/**
|
2631 |
+
* Sets the default permissions a member should have in order to run this command.
|
2632 |
+
*
|
2633 |
+
* @remarks
|
2634 |
+
* You can set this to `'0'` to disable the command by default.
|
2635 |
+
* @param permissions - The permissions bit field to set
|
2636 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
2637 |
+
*/
|
2638 |
+
setDefaultMemberPermissions(permissions) {
|
2639 |
+
const permissionValue = validateDefaultMemberPermissions2(permissions);
|
2640 |
+
Reflect.set(this, "default_member_permissions", permissionValue);
|
2641 |
+
return this;
|
2642 |
+
}
|
2643 |
+
/**
|
2644 |
+
* Sets if the command is available in direct messages with the application.
|
2645 |
+
*
|
2646 |
+
* @remarks
|
2647 |
+
* By default, commands are visible. This method is only for global commands.
|
2648 |
+
* @param enabled - Whether the command should be enabled in direct messages
|
2649 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
2650 |
+
*/
|
2651 |
+
setDMPermission(enabled) {
|
2652 |
+
validateDMPermission2(enabled);
|
2653 |
+
Reflect.set(this, "dm_permission", enabled);
|
2654 |
+
return this;
|
2655 |
+
}
|
2656 |
+
/**
|
2657 |
+
* Sets a name localization for this command.
|
2658 |
+
*
|
2659 |
+
* @param locale - The locale to set
|
2660 |
+
* @param localizedName - The localized name for the given `locale`
|
2661 |
+
*/
|
2662 |
+
setNameLocalization(locale, localizedName) {
|
2663 |
+
if (!this.name_localizations) {
|
2664 |
+
Reflect.set(this, "name_localizations", {});
|
2665 |
+
}
|
2666 |
+
const parsedLocale = validateLocale(locale);
|
2667 |
+
if (localizedName === null) {
|
2668 |
+
this.name_localizations[parsedLocale] = null;
|
2669 |
+
return this;
|
2670 |
+
}
|
2671 |
+
validateName2(localizedName);
|
2672 |
+
this.name_localizations[parsedLocale] = localizedName;
|
2673 |
+
return this;
|
2674 |
+
}
|
2675 |
+
/**
|
2676 |
+
* Sets the name localizations for this command.
|
2677 |
+
*
|
2678 |
+
* @param localizedNames - The object of localized names to set
|
2679 |
+
*/
|
2680 |
+
setNameLocalizations(localizedNames) {
|
2681 |
+
if (localizedNames === null) {
|
2682 |
+
Reflect.set(this, "name_localizations", null);
|
2683 |
+
return this;
|
2684 |
+
}
|
2685 |
+
Reflect.set(this, "name_localizations", {});
|
2686 |
+
for (const args of Object.entries(localizedNames))
|
2687 |
+
this.setNameLocalization(...args);
|
2688 |
+
return this;
|
2689 |
+
}
|
2690 |
+
/**
|
2691 |
+
* Serializes this builder to API-compatible JSON data.
|
2692 |
+
*
|
2693 |
+
* @remarks
|
2694 |
+
* This method runs validations on the data before serializing it.
|
2695 |
+
* As such, it may throw an error if the data is invalid.
|
2696 |
+
*/
|
2697 |
+
toJSON() {
|
2698 |
+
validateRequiredParameters4(this.name, this.type);
|
2699 |
+
validateLocalizationMap(this.name_localizations);
|
2700 |
+
return { ...this };
|
2701 |
+
}
|
2702 |
+
};
|
2703 |
+
|
2704 |
+
// src/util/componentUtil.ts
|
2705 |
+
function embedLength(data) {
|
2706 |
+
return (data.title?.length ?? 0) + (data.description?.length ?? 0) + (data.fields?.reduce((prev, curr) => prev + curr.name.length + curr.value.length, 0) ?? 0) + (data.footer?.text.length ?? 0) + (data.author?.name.length ?? 0);
|
2707 |
+
}
|
2708 |
+
__name(embedLength, "embedLength");
|
2709 |
+
|
2710 |
+
// src/index.ts
|
2711 |
+
var version = "1.7.0";
|
2712 |
+
// Annotate the CommonJS export names for ESM import in node:
|
2713 |
+
0 && (module.exports = {
|
2714 |
+
ActionRowBuilder,
|
2715 |
+
ApplicationCommandNumericOptionMinMaxValueMixin,
|
2716 |
+
ApplicationCommandOptionBase,
|
2717 |
+
ApplicationCommandOptionChannelTypesMixin,
|
2718 |
+
ApplicationCommandOptionWithChoicesAndAutocompleteMixin,
|
2719 |
+
BaseSelectMenuBuilder,
|
2720 |
+
ButtonBuilder,
|
2721 |
+
ChannelSelectMenuBuilder,
|
2722 |
+
ComponentAssertions,
|
2723 |
+
ComponentBuilder,
|
2724 |
+
ContextMenuCommandAssertions,
|
2725 |
+
ContextMenuCommandBuilder,
|
2726 |
+
EmbedAssertions,
|
2727 |
+
EmbedBuilder,
|
2728 |
+
MentionableSelectMenuBuilder,
|
2729 |
+
ModalAssertions,
|
2730 |
+
ModalBuilder,
|
2731 |
+
RoleSelectMenuBuilder,
|
2732 |
+
SelectMenuBuilder,
|
2733 |
+
SelectMenuOptionBuilder,
|
2734 |
+
SharedNameAndDescription,
|
2735 |
+
SharedSlashCommandOptions,
|
2736 |
+
SlashCommandAssertions,
|
2737 |
+
SlashCommandAttachmentOption,
|
2738 |
+
SlashCommandBooleanOption,
|
2739 |
+
SlashCommandBuilder,
|
2740 |
+
SlashCommandChannelOption,
|
2741 |
+
SlashCommandIntegerOption,
|
2742 |
+
SlashCommandMentionableOption,
|
2743 |
+
SlashCommandNumberOption,
|
2744 |
+
SlashCommandRoleOption,
|
2745 |
+
SlashCommandStringOption,
|
2746 |
+
SlashCommandSubcommandBuilder,
|
2747 |
+
SlashCommandSubcommandGroupBuilder,
|
2748 |
+
SlashCommandUserOption,
|
2749 |
+
StringSelectMenuBuilder,
|
2750 |
+
StringSelectMenuOptionBuilder,
|
2751 |
+
TextInputAssertions,
|
2752 |
+
TextInputBuilder,
|
2753 |
+
UserSelectMenuBuilder,
|
2754 |
+
createComponentBuilder,
|
2755 |
+
disableValidators,
|
2756 |
+
embedLength,
|
2757 |
+
enableValidators,
|
2758 |
+
isValidationEnabled,
|
2759 |
+
normalizeArray,
|
2760 |
+
version,
|
2761 |
+
...require("@discordjs/formatters")
|
2762 |
+
});
|
2763 |
+
//# sourceMappingURL=index.js.map
|
node_modules/@discordjs/builders/dist/index.js.map
ADDED
The diff for this file is too large to render.
See raw diff
|
|
node_modules/@discordjs/builders/dist/index.mjs
ADDED
@@ -0,0 +1,2703 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var __defProp = Object.defineProperty;
|
2 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3 |
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
4 |
+
var __export = (target, all) => {
|
5 |
+
for (var name in all)
|
6 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
7 |
+
};
|
8 |
+
var __decorateClass = (decorators, target, key, kind) => {
|
9 |
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
10 |
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
11 |
+
if (decorator = decorators[i])
|
12 |
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
13 |
+
if (kind && result)
|
14 |
+
__defProp(target, key, result);
|
15 |
+
return result;
|
16 |
+
};
|
17 |
+
|
18 |
+
// src/messages/embed/Assertions.ts
|
19 |
+
var Assertions_exports = {};
|
20 |
+
__export(Assertions_exports, {
|
21 |
+
RGBPredicate: () => RGBPredicate,
|
22 |
+
authorNamePredicate: () => authorNamePredicate,
|
23 |
+
colorPredicate: () => colorPredicate,
|
24 |
+
descriptionPredicate: () => descriptionPredicate,
|
25 |
+
embedAuthorPredicate: () => embedAuthorPredicate,
|
26 |
+
embedFieldPredicate: () => embedFieldPredicate,
|
27 |
+
embedFieldsArrayPredicate: () => embedFieldsArrayPredicate,
|
28 |
+
embedFooterPredicate: () => embedFooterPredicate,
|
29 |
+
fieldInlinePredicate: () => fieldInlinePredicate,
|
30 |
+
fieldLengthPredicate: () => fieldLengthPredicate,
|
31 |
+
fieldNamePredicate: () => fieldNamePredicate,
|
32 |
+
fieldValuePredicate: () => fieldValuePredicate,
|
33 |
+
footerTextPredicate: () => footerTextPredicate,
|
34 |
+
imageURLPredicate: () => imageURLPredicate,
|
35 |
+
timestampPredicate: () => timestampPredicate,
|
36 |
+
titlePredicate: () => titlePredicate,
|
37 |
+
urlPredicate: () => urlPredicate,
|
38 |
+
validateFieldLength: () => validateFieldLength
|
39 |
+
});
|
40 |
+
import { s } from "@sapphire/shapeshift";
|
41 |
+
|
42 |
+
// src/util/validation.ts
|
43 |
+
var validate = true;
|
44 |
+
function enableValidators() {
|
45 |
+
return validate = true;
|
46 |
+
}
|
47 |
+
__name(enableValidators, "enableValidators");
|
48 |
+
function disableValidators() {
|
49 |
+
return validate = false;
|
50 |
+
}
|
51 |
+
__name(disableValidators, "disableValidators");
|
52 |
+
function isValidationEnabled() {
|
53 |
+
return validate;
|
54 |
+
}
|
55 |
+
__name(isValidationEnabled, "isValidationEnabled");
|
56 |
+
|
57 |
+
// src/messages/embed/Assertions.ts
|
58 |
+
var fieldNamePredicate = s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(256).setValidationEnabled(isValidationEnabled);
|
59 |
+
var fieldValuePredicate = s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(1024).setValidationEnabled(isValidationEnabled);
|
60 |
+
var fieldInlinePredicate = s.boolean.optional;
|
61 |
+
var embedFieldPredicate = s.object({
|
62 |
+
name: fieldNamePredicate,
|
63 |
+
value: fieldValuePredicate,
|
64 |
+
inline: fieldInlinePredicate
|
65 |
+
}).setValidationEnabled(isValidationEnabled);
|
66 |
+
var embedFieldsArrayPredicate = embedFieldPredicate.array.setValidationEnabled(isValidationEnabled);
|
67 |
+
var fieldLengthPredicate = s.number.lessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
|
68 |
+
function validateFieldLength(amountAdding, fields) {
|
69 |
+
fieldLengthPredicate.parse((fields?.length ?? 0) + amountAdding);
|
70 |
+
}
|
71 |
+
__name(validateFieldLength, "validateFieldLength");
|
72 |
+
var authorNamePredicate = fieldNamePredicate.nullable.setValidationEnabled(isValidationEnabled);
|
73 |
+
var imageURLPredicate = s.string.url({
|
74 |
+
allowedProtocols: ["http:", "https:", "attachment:"]
|
75 |
+
}).nullish.setValidationEnabled(isValidationEnabled);
|
76 |
+
var urlPredicate = s.string.url({
|
77 |
+
allowedProtocols: ["http:", "https:"]
|
78 |
+
}).nullish.setValidationEnabled(isValidationEnabled);
|
79 |
+
var embedAuthorPredicate = s.object({
|
80 |
+
name: authorNamePredicate,
|
81 |
+
iconURL: imageURLPredicate,
|
82 |
+
url: urlPredicate
|
83 |
+
}).setValidationEnabled(isValidationEnabled);
|
84 |
+
var RGBPredicate = s.number.int.greaterThanOrEqual(0).lessThanOrEqual(255).setValidationEnabled(isValidationEnabled);
|
85 |
+
var colorPredicate = s.number.int.greaterThanOrEqual(0).lessThanOrEqual(16777215).or(s.tuple([RGBPredicate, RGBPredicate, RGBPredicate])).nullable.setValidationEnabled(isValidationEnabled);
|
86 |
+
var descriptionPredicate = s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(4096).nullable.setValidationEnabled(isValidationEnabled);
|
87 |
+
var footerTextPredicate = s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(2048).nullable.setValidationEnabled(isValidationEnabled);
|
88 |
+
var embedFooterPredicate = s.object({
|
89 |
+
text: footerTextPredicate,
|
90 |
+
iconURL: imageURLPredicate
|
91 |
+
}).setValidationEnabled(isValidationEnabled);
|
92 |
+
var timestampPredicate = s.union(s.number, s.date).nullable.setValidationEnabled(isValidationEnabled);
|
93 |
+
var titlePredicate = fieldNamePredicate.nullable.setValidationEnabled(isValidationEnabled);
|
94 |
+
|
95 |
+
// src/util/normalizeArray.ts
|
96 |
+
function normalizeArray(arr) {
|
97 |
+
if (Array.isArray(arr[0]))
|
98 |
+
return arr[0];
|
99 |
+
return arr;
|
100 |
+
}
|
101 |
+
__name(normalizeArray, "normalizeArray");
|
102 |
+
|
103 |
+
// src/messages/embed/Embed.ts
|
104 |
+
var EmbedBuilder = class {
|
105 |
+
static {
|
106 |
+
__name(this, "EmbedBuilder");
|
107 |
+
}
|
108 |
+
/**
|
109 |
+
* The API data associated with this embed.
|
110 |
+
*/
|
111 |
+
data;
|
112 |
+
/**
|
113 |
+
* Creates a new embed from API data.
|
114 |
+
*
|
115 |
+
* @param data - The API data to create this embed with
|
116 |
+
*/
|
117 |
+
constructor(data = {}) {
|
118 |
+
this.data = { ...data };
|
119 |
+
if (data.timestamp)
|
120 |
+
this.data.timestamp = new Date(data.timestamp).toISOString();
|
121 |
+
}
|
122 |
+
/**
|
123 |
+
* Appends fields to the embed.
|
124 |
+
*
|
125 |
+
* @remarks
|
126 |
+
* This method accepts either an array of fields or a variable number of field parameters.
|
127 |
+
* The maximum amount of fields that can be added is 25.
|
128 |
+
* @example
|
129 |
+
* Using an array:
|
130 |
+
* ```ts
|
131 |
+
* const fields: APIEmbedField[] = ...;
|
132 |
+
* const embed = new EmbedBuilder()
|
133 |
+
* .addFields(fields);
|
134 |
+
* ```
|
135 |
+
* @example
|
136 |
+
* Using rest parameters (variadic):
|
137 |
+
* ```ts
|
138 |
+
* const embed = new EmbedBuilder()
|
139 |
+
* .addFields(
|
140 |
+
* { name: 'Field 1', value: 'Value 1' },
|
141 |
+
* { name: 'Field 2', value: 'Value 2' },
|
142 |
+
* );
|
143 |
+
* ```
|
144 |
+
* @param fields - The fields to add
|
145 |
+
*/
|
146 |
+
addFields(...fields) {
|
147 |
+
const normalizedFields = normalizeArray(fields);
|
148 |
+
validateFieldLength(normalizedFields.length, this.data.fields);
|
149 |
+
embedFieldsArrayPredicate.parse(normalizedFields);
|
150 |
+
if (this.data.fields)
|
151 |
+
this.data.fields.push(...normalizedFields);
|
152 |
+
else
|
153 |
+
this.data.fields = normalizedFields;
|
154 |
+
return this;
|
155 |
+
}
|
156 |
+
/**
|
157 |
+
* Removes, replaces, or inserts fields for this embed.
|
158 |
+
*
|
159 |
+
* @remarks
|
160 |
+
* This method behaves similarly
|
161 |
+
* to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
162 |
+
* The maximum amount of fields that can be added is 25.
|
163 |
+
*
|
164 |
+
* It's useful for modifying and adjusting order of the already-existing fields of an embed.
|
165 |
+
* @example
|
166 |
+
* Remove the first field:
|
167 |
+
* ```ts
|
168 |
+
* embed.spliceFields(0, 1);
|
169 |
+
* ```
|
170 |
+
* @example
|
171 |
+
* Remove the first n fields:
|
172 |
+
* ```ts
|
173 |
+
* const n = 4;
|
174 |
+
* embed.spliceFields(0, n);
|
175 |
+
* ```
|
176 |
+
* @example
|
177 |
+
* Remove the last field:
|
178 |
+
* ```ts
|
179 |
+
* embed.spliceFields(-1, 1);
|
180 |
+
* ```
|
181 |
+
* @param index - The index to start at
|
182 |
+
* @param deleteCount - The number of fields to remove
|
183 |
+
* @param fields - The replacing field objects
|
184 |
+
*/
|
185 |
+
spliceFields(index, deleteCount, ...fields) {
|
186 |
+
validateFieldLength(fields.length - deleteCount, this.data.fields);
|
187 |
+
embedFieldsArrayPredicate.parse(fields);
|
188 |
+
if (this.data.fields)
|
189 |
+
this.data.fields.splice(index, deleteCount, ...fields);
|
190 |
+
else
|
191 |
+
this.data.fields = fields;
|
192 |
+
return this;
|
193 |
+
}
|
194 |
+
/**
|
195 |
+
* Sets the fields for this embed.
|
196 |
+
*
|
197 |
+
* @remarks
|
198 |
+
* This method is an alias for {@link EmbedBuilder.spliceFields}. More specifically,
|
199 |
+
* it splices the entire array of fields, replacing them with the provided fields.
|
200 |
+
*
|
201 |
+
* You can set a maximum of 25 fields.
|
202 |
+
* @param fields - The fields to set
|
203 |
+
*/
|
204 |
+
setFields(...fields) {
|
205 |
+
this.spliceFields(0, this.data.fields?.length ?? 0, ...normalizeArray(fields));
|
206 |
+
return this;
|
207 |
+
}
|
208 |
+
/**
|
209 |
+
* Sets the author of this embed.
|
210 |
+
*
|
211 |
+
* @param options - The options to use
|
212 |
+
*/
|
213 |
+
setAuthor(options) {
|
214 |
+
if (options === null) {
|
215 |
+
this.data.author = void 0;
|
216 |
+
return this;
|
217 |
+
}
|
218 |
+
embedAuthorPredicate.parse(options);
|
219 |
+
this.data.author = { name: options.name, url: options.url, icon_url: options.iconURL };
|
220 |
+
return this;
|
221 |
+
}
|
222 |
+
/**
|
223 |
+
* Sets the color of this embed.
|
224 |
+
*
|
225 |
+
* @param color - The color to use
|
226 |
+
*/
|
227 |
+
setColor(color) {
|
228 |
+
colorPredicate.parse(color);
|
229 |
+
if (Array.isArray(color)) {
|
230 |
+
const [red, green, blue] = color;
|
231 |
+
this.data.color = (red << 16) + (green << 8) + blue;
|
232 |
+
return this;
|
233 |
+
}
|
234 |
+
this.data.color = color ?? void 0;
|
235 |
+
return this;
|
236 |
+
}
|
237 |
+
/**
|
238 |
+
* Sets the description of this embed.
|
239 |
+
*
|
240 |
+
* @param description - The description to use
|
241 |
+
*/
|
242 |
+
setDescription(description) {
|
243 |
+
descriptionPredicate.parse(description);
|
244 |
+
this.data.description = description ?? void 0;
|
245 |
+
return this;
|
246 |
+
}
|
247 |
+
/**
|
248 |
+
* Sets the footer of this embed.
|
249 |
+
*
|
250 |
+
* @param options - The footer to use
|
251 |
+
*/
|
252 |
+
setFooter(options) {
|
253 |
+
if (options === null) {
|
254 |
+
this.data.footer = void 0;
|
255 |
+
return this;
|
256 |
+
}
|
257 |
+
embedFooterPredicate.parse(options);
|
258 |
+
this.data.footer = { text: options.text, icon_url: options.iconURL };
|
259 |
+
return this;
|
260 |
+
}
|
261 |
+
/**
|
262 |
+
* Sets the image of this embed.
|
263 |
+
*
|
264 |
+
* @param url - The image URL to use
|
265 |
+
*/
|
266 |
+
setImage(url) {
|
267 |
+
imageURLPredicate.parse(url);
|
268 |
+
this.data.image = url ? { url } : void 0;
|
269 |
+
return this;
|
270 |
+
}
|
271 |
+
/**
|
272 |
+
* Sets the thumbnail of this embed.
|
273 |
+
*
|
274 |
+
* @param url - The thumbnail URL to use
|
275 |
+
*/
|
276 |
+
setThumbnail(url) {
|
277 |
+
imageURLPredicate.parse(url);
|
278 |
+
this.data.thumbnail = url ? { url } : void 0;
|
279 |
+
return this;
|
280 |
+
}
|
281 |
+
/**
|
282 |
+
* Sets the timestamp of this embed.
|
283 |
+
*
|
284 |
+
* @param timestamp - The timestamp or date to use
|
285 |
+
*/
|
286 |
+
setTimestamp(timestamp = Date.now()) {
|
287 |
+
timestampPredicate.parse(timestamp);
|
288 |
+
this.data.timestamp = timestamp ? new Date(timestamp).toISOString() : void 0;
|
289 |
+
return this;
|
290 |
+
}
|
291 |
+
/**
|
292 |
+
* Sets the title for this embed.
|
293 |
+
*
|
294 |
+
* @param title - The title to use
|
295 |
+
*/
|
296 |
+
setTitle(title) {
|
297 |
+
titlePredicate.parse(title);
|
298 |
+
this.data.title = title ?? void 0;
|
299 |
+
return this;
|
300 |
+
}
|
301 |
+
/**
|
302 |
+
* Sets the URL of this embed.
|
303 |
+
*
|
304 |
+
* @param url - The URL to use
|
305 |
+
*/
|
306 |
+
setURL(url) {
|
307 |
+
urlPredicate.parse(url);
|
308 |
+
this.data.url = url ?? void 0;
|
309 |
+
return this;
|
310 |
+
}
|
311 |
+
/**
|
312 |
+
* Serializes this builder to API-compatible JSON data.
|
313 |
+
*
|
314 |
+
* @remarks
|
315 |
+
* This method runs validations on the data before serializing it.
|
316 |
+
* As such, it may throw an error if the data is invalid.
|
317 |
+
*/
|
318 |
+
toJSON() {
|
319 |
+
return { ...this.data };
|
320 |
+
}
|
321 |
+
};
|
322 |
+
|
323 |
+
// src/index.ts
|
324 |
+
export * from "@discordjs/formatters";
|
325 |
+
|
326 |
+
// src/components/Assertions.ts
|
327 |
+
var Assertions_exports2 = {};
|
328 |
+
__export(Assertions_exports2, {
|
329 |
+
buttonLabelValidator: () => buttonLabelValidator,
|
330 |
+
buttonStyleValidator: () => buttonStyleValidator,
|
331 |
+
channelTypesValidator: () => channelTypesValidator,
|
332 |
+
customIdValidator: () => customIdValidator,
|
333 |
+
defaultValidator: () => defaultValidator,
|
334 |
+
disabledValidator: () => disabledValidator,
|
335 |
+
emojiValidator: () => emojiValidator,
|
336 |
+
jsonOptionValidator: () => jsonOptionValidator,
|
337 |
+
labelValueDescriptionValidator: () => labelValueDescriptionValidator,
|
338 |
+
minMaxValidator: () => minMaxValidator,
|
339 |
+
optionValidator: () => optionValidator,
|
340 |
+
optionsLengthValidator: () => optionsLengthValidator,
|
341 |
+
optionsValidator: () => optionsValidator,
|
342 |
+
placeholderValidator: () => placeholderValidator,
|
343 |
+
urlValidator: () => urlValidator,
|
344 |
+
validateRequiredButtonParameters: () => validateRequiredButtonParameters,
|
345 |
+
validateRequiredSelectMenuOptionParameters: () => validateRequiredSelectMenuOptionParameters,
|
346 |
+
validateRequiredSelectMenuParameters: () => validateRequiredSelectMenuParameters
|
347 |
+
});
|
348 |
+
import { s as s2 } from "@sapphire/shapeshift";
|
349 |
+
import { ButtonStyle, ChannelType } from "discord-api-types/v10";
|
350 |
+
|
351 |
+
// src/components/selectMenu/StringSelectMenuOption.ts
|
352 |
+
var StringSelectMenuOptionBuilder = class {
|
353 |
+
/**
|
354 |
+
* Creates a new string select menu option from API data.
|
355 |
+
*
|
356 |
+
* @param data - The API data to create this string select menu option with
|
357 |
+
* @example
|
358 |
+
* Creating a string select menu option from an API data object:
|
359 |
+
* ```ts
|
360 |
+
* const selectMenuOption = new SelectMenuOptionBuilder({
|
361 |
+
* label: 'catchy label',
|
362 |
+
* value: '1',
|
363 |
+
* });
|
364 |
+
* ```
|
365 |
+
* @example
|
366 |
+
* Creating a string select menu option using setters and API data:
|
367 |
+
* ```ts
|
368 |
+
* const selectMenuOption = new SelectMenuOptionBuilder({
|
369 |
+
* default: true,
|
370 |
+
* value: '1',
|
371 |
+
* })
|
372 |
+
* .setLabel('woah');
|
373 |
+
* ```
|
374 |
+
*/
|
375 |
+
constructor(data = {}) {
|
376 |
+
this.data = data;
|
377 |
+
}
|
378 |
+
static {
|
379 |
+
__name(this, "StringSelectMenuOptionBuilder");
|
380 |
+
}
|
381 |
+
/**
|
382 |
+
* Sets the label for this option.
|
383 |
+
*
|
384 |
+
* @param label - The label to use
|
385 |
+
*/
|
386 |
+
setLabel(label) {
|
387 |
+
this.data.label = labelValueDescriptionValidator.parse(label);
|
388 |
+
return this;
|
389 |
+
}
|
390 |
+
/**
|
391 |
+
* Sets the value for this option.
|
392 |
+
*
|
393 |
+
* @param value - The value to use
|
394 |
+
*/
|
395 |
+
setValue(value) {
|
396 |
+
this.data.value = labelValueDescriptionValidator.parse(value);
|
397 |
+
return this;
|
398 |
+
}
|
399 |
+
/**
|
400 |
+
* Sets the description for this option.
|
401 |
+
*
|
402 |
+
* @param description - The description to use
|
403 |
+
*/
|
404 |
+
setDescription(description) {
|
405 |
+
this.data.description = labelValueDescriptionValidator.parse(description);
|
406 |
+
return this;
|
407 |
+
}
|
408 |
+
/**
|
409 |
+
* Sets whether this option is selected by default.
|
410 |
+
*
|
411 |
+
* @param isDefault - Whether this option is selected by default
|
412 |
+
*/
|
413 |
+
setDefault(isDefault = true) {
|
414 |
+
this.data.default = defaultValidator.parse(isDefault);
|
415 |
+
return this;
|
416 |
+
}
|
417 |
+
/**
|
418 |
+
* Sets the emoji to display for this option.
|
419 |
+
*
|
420 |
+
* @param emoji - The emoji to use
|
421 |
+
*/
|
422 |
+
setEmoji(emoji) {
|
423 |
+
this.data.emoji = emojiValidator.parse(emoji);
|
424 |
+
return this;
|
425 |
+
}
|
426 |
+
/**
|
427 |
+
* {@inheritDoc BaseSelectMenuBuilder.toJSON}
|
428 |
+
*/
|
429 |
+
toJSON() {
|
430 |
+
validateRequiredSelectMenuOptionParameters(this.data.label, this.data.value);
|
431 |
+
return {
|
432 |
+
...this.data
|
433 |
+
};
|
434 |
+
}
|
435 |
+
};
|
436 |
+
|
437 |
+
// src/components/Assertions.ts
|
438 |
+
var customIdValidator = s2.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
|
439 |
+
var emojiValidator = s2.object({
|
440 |
+
id: s2.string,
|
441 |
+
name: s2.string,
|
442 |
+
animated: s2.boolean
|
443 |
+
}).partial.strict.setValidationEnabled(isValidationEnabled);
|
444 |
+
var disabledValidator = s2.boolean;
|
445 |
+
var buttonLabelValidator = s2.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(80).setValidationEnabled(isValidationEnabled);
|
446 |
+
var buttonStyleValidator = s2.nativeEnum(ButtonStyle);
|
447 |
+
var placeholderValidator = s2.string.lengthLessThanOrEqual(150).setValidationEnabled(isValidationEnabled);
|
448 |
+
var minMaxValidator = s2.number.int.greaterThanOrEqual(0).lessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
|
449 |
+
var labelValueDescriptionValidator = s2.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
|
450 |
+
var jsonOptionValidator = s2.object({
|
451 |
+
label: labelValueDescriptionValidator,
|
452 |
+
value: labelValueDescriptionValidator,
|
453 |
+
description: labelValueDescriptionValidator.optional,
|
454 |
+
emoji: emojiValidator.optional,
|
455 |
+
default: s2.boolean.optional
|
456 |
+
}).setValidationEnabled(isValidationEnabled);
|
457 |
+
var optionValidator = s2.instance(StringSelectMenuOptionBuilder).setValidationEnabled(isValidationEnabled);
|
458 |
+
var optionsValidator = optionValidator.array.lengthGreaterThanOrEqual(0).setValidationEnabled(isValidationEnabled);
|
459 |
+
var optionsLengthValidator = s2.number.int.greaterThanOrEqual(0).lessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
|
460 |
+
function validateRequiredSelectMenuParameters(options, customId) {
|
461 |
+
customIdValidator.parse(customId);
|
462 |
+
optionsValidator.parse(options);
|
463 |
+
}
|
464 |
+
__name(validateRequiredSelectMenuParameters, "validateRequiredSelectMenuParameters");
|
465 |
+
var defaultValidator = s2.boolean;
|
466 |
+
function validateRequiredSelectMenuOptionParameters(label, value) {
|
467 |
+
labelValueDescriptionValidator.parse(label);
|
468 |
+
labelValueDescriptionValidator.parse(value);
|
469 |
+
}
|
470 |
+
__name(validateRequiredSelectMenuOptionParameters, "validateRequiredSelectMenuOptionParameters");
|
471 |
+
var channelTypesValidator = s2.nativeEnum(ChannelType).array.setValidationEnabled(isValidationEnabled);
|
472 |
+
var urlValidator = s2.string.url({
|
473 |
+
allowedProtocols: ["http:", "https:", "discord:"]
|
474 |
+
}).setValidationEnabled(isValidationEnabled);
|
475 |
+
function validateRequiredButtonParameters(style, label, emoji, customId, url) {
|
476 |
+
if (url && customId) {
|
477 |
+
throw new RangeError("URL and custom id are mutually exclusive");
|
478 |
+
}
|
479 |
+
if (!label && !emoji) {
|
480 |
+
throw new RangeError("Buttons must have a label and/or an emoji");
|
481 |
+
}
|
482 |
+
if (style === ButtonStyle.Link) {
|
483 |
+
if (!url) {
|
484 |
+
throw new RangeError("Link buttons must have a url");
|
485 |
+
}
|
486 |
+
} else if (url) {
|
487 |
+
throw new RangeError("Non-link buttons cannot have a url");
|
488 |
+
}
|
489 |
+
}
|
490 |
+
__name(validateRequiredButtonParameters, "validateRequiredButtonParameters");
|
491 |
+
|
492 |
+
// src/components/ActionRow.ts
|
493 |
+
import {
|
494 |
+
ComponentType as ComponentType9
|
495 |
+
} from "discord-api-types/v10";
|
496 |
+
|
497 |
+
// src/components/Component.ts
|
498 |
+
var ComponentBuilder = class {
|
499 |
+
static {
|
500 |
+
__name(this, "ComponentBuilder");
|
501 |
+
}
|
502 |
+
/**
|
503 |
+
* The API data associated with this component.
|
504 |
+
*/
|
505 |
+
data;
|
506 |
+
/**
|
507 |
+
* Constructs a new kind of component.
|
508 |
+
*
|
509 |
+
* @param data - The data to construct a component out of
|
510 |
+
*/
|
511 |
+
constructor(data) {
|
512 |
+
this.data = data;
|
513 |
+
}
|
514 |
+
};
|
515 |
+
|
516 |
+
// src/components/Components.ts
|
517 |
+
import { ComponentType as ComponentType8 } from "discord-api-types/v10";
|
518 |
+
|
519 |
+
// src/components/button/Button.ts
|
520 |
+
import {
|
521 |
+
ComponentType
|
522 |
+
} from "discord-api-types/v10";
|
523 |
+
var ButtonBuilder = class extends ComponentBuilder {
|
524 |
+
static {
|
525 |
+
__name(this, "ButtonBuilder");
|
526 |
+
}
|
527 |
+
/**
|
528 |
+
* Creates a new button from API data.
|
529 |
+
*
|
530 |
+
* @param data - The API data to create this button with
|
531 |
+
* @example
|
532 |
+
* Creating a button from an API data object:
|
533 |
+
* ```ts
|
534 |
+
* const button = new ButtonBuilder({
|
535 |
+
* custom_id: 'a cool button',
|
536 |
+
* style: ButtonStyle.Primary,
|
537 |
+
* label: 'Click Me',
|
538 |
+
* emoji: {
|
539 |
+
* name: 'smile',
|
540 |
+
* id: '123456789012345678',
|
541 |
+
* },
|
542 |
+
* });
|
543 |
+
* ```
|
544 |
+
* @example
|
545 |
+
* Creating a button using setters and API data:
|
546 |
+
* ```ts
|
547 |
+
* const button = new ButtonBuilder({
|
548 |
+
* style: ButtonStyle.Secondary,
|
549 |
+
* label: 'Click Me',
|
550 |
+
* })
|
551 |
+
* .setEmoji({ name: '🙂' })
|
552 |
+
* .setCustomId('another cool button');
|
553 |
+
* ```
|
554 |
+
*/
|
555 |
+
constructor(data) {
|
556 |
+
super({ type: ComponentType.Button, ...data });
|
557 |
+
}
|
558 |
+
/**
|
559 |
+
* Sets the style of this button.
|
560 |
+
*
|
561 |
+
* @param style - The style to use
|
562 |
+
*/
|
563 |
+
setStyle(style) {
|
564 |
+
this.data.style = buttonStyleValidator.parse(style);
|
565 |
+
return this;
|
566 |
+
}
|
567 |
+
/**
|
568 |
+
* Sets the URL for this button.
|
569 |
+
*
|
570 |
+
* @remarks
|
571 |
+
* This method is only available to buttons using the `Link` button style.
|
572 |
+
* Only three types of URL schemes are currently supported: `https://`, `http://`, and `discord://`.
|
573 |
+
* @param url - The URL to use
|
574 |
+
*/
|
575 |
+
setURL(url) {
|
576 |
+
this.data.url = urlValidator.parse(url);
|
577 |
+
return this;
|
578 |
+
}
|
579 |
+
/**
|
580 |
+
* Sets the custom id for this button.
|
581 |
+
*
|
582 |
+
* @remarks
|
583 |
+
* This method is only applicable to buttons that are not using the `Link` button style.
|
584 |
+
* @param customId - The custom id to use
|
585 |
+
*/
|
586 |
+
setCustomId(customId) {
|
587 |
+
this.data.custom_id = customIdValidator.parse(customId);
|
588 |
+
return this;
|
589 |
+
}
|
590 |
+
/**
|
591 |
+
* Sets the emoji to display on this button.
|
592 |
+
*
|
593 |
+
* @param emoji - The emoji to use
|
594 |
+
*/
|
595 |
+
setEmoji(emoji) {
|
596 |
+
this.data.emoji = emojiValidator.parse(emoji);
|
597 |
+
return this;
|
598 |
+
}
|
599 |
+
/**
|
600 |
+
* Sets whether this button is disabled.
|
601 |
+
*
|
602 |
+
* @param disabled - Whether to disable this button
|
603 |
+
*/
|
604 |
+
setDisabled(disabled = true) {
|
605 |
+
this.data.disabled = disabledValidator.parse(disabled);
|
606 |
+
return this;
|
607 |
+
}
|
608 |
+
/**
|
609 |
+
* Sets the label for this button.
|
610 |
+
*
|
611 |
+
* @param label - The label to use
|
612 |
+
*/
|
613 |
+
setLabel(label) {
|
614 |
+
this.data.label = buttonLabelValidator.parse(label);
|
615 |
+
return this;
|
616 |
+
}
|
617 |
+
/**
|
618 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
619 |
+
*/
|
620 |
+
toJSON() {
|
621 |
+
validateRequiredButtonParameters(
|
622 |
+
this.data.style,
|
623 |
+
this.data.label,
|
624 |
+
this.data.emoji,
|
625 |
+
this.data.custom_id,
|
626 |
+
this.data.url
|
627 |
+
);
|
628 |
+
return {
|
629 |
+
...this.data
|
630 |
+
};
|
631 |
+
}
|
632 |
+
};
|
633 |
+
|
634 |
+
// src/components/selectMenu/ChannelSelectMenu.ts
|
635 |
+
import {
|
636 |
+
ComponentType as ComponentType2,
|
637 |
+
SelectMenuDefaultValueType
|
638 |
+
} from "discord-api-types/v10";
|
639 |
+
|
640 |
+
// src/components/selectMenu/BaseSelectMenu.ts
|
641 |
+
var BaseSelectMenuBuilder = class extends ComponentBuilder {
|
642 |
+
static {
|
643 |
+
__name(this, "BaseSelectMenuBuilder");
|
644 |
+
}
|
645 |
+
/**
|
646 |
+
* Sets the placeholder for this select menu.
|
647 |
+
*
|
648 |
+
* @param placeholder - The placeholder to use
|
649 |
+
*/
|
650 |
+
setPlaceholder(placeholder) {
|
651 |
+
this.data.placeholder = placeholderValidator.parse(placeholder);
|
652 |
+
return this;
|
653 |
+
}
|
654 |
+
/**
|
655 |
+
* Sets the minimum values that must be selected in the select menu.
|
656 |
+
*
|
657 |
+
* @param minValues - The minimum values that must be selected
|
658 |
+
*/
|
659 |
+
setMinValues(minValues) {
|
660 |
+
this.data.min_values = minMaxValidator.parse(minValues);
|
661 |
+
return this;
|
662 |
+
}
|
663 |
+
/**
|
664 |
+
* Sets the maximum values that must be selected in the select menu.
|
665 |
+
*
|
666 |
+
* @param maxValues - The maximum values that must be selected
|
667 |
+
*/
|
668 |
+
setMaxValues(maxValues) {
|
669 |
+
this.data.max_values = minMaxValidator.parse(maxValues);
|
670 |
+
return this;
|
671 |
+
}
|
672 |
+
/**
|
673 |
+
* Sets the custom id for this select menu.
|
674 |
+
*
|
675 |
+
* @param customId - The custom id to use
|
676 |
+
*/
|
677 |
+
setCustomId(customId) {
|
678 |
+
this.data.custom_id = customIdValidator.parse(customId);
|
679 |
+
return this;
|
680 |
+
}
|
681 |
+
/**
|
682 |
+
* Sets whether this select menu is disabled.
|
683 |
+
*
|
684 |
+
* @param disabled - Whether this select menu is disabled
|
685 |
+
*/
|
686 |
+
setDisabled(disabled = true) {
|
687 |
+
this.data.disabled = disabledValidator.parse(disabled);
|
688 |
+
return this;
|
689 |
+
}
|
690 |
+
/**
|
691 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
692 |
+
*/
|
693 |
+
toJSON() {
|
694 |
+
customIdValidator.parse(this.data.custom_id);
|
695 |
+
return {
|
696 |
+
...this.data
|
697 |
+
};
|
698 |
+
}
|
699 |
+
};
|
700 |
+
|
701 |
+
// src/components/selectMenu/ChannelSelectMenu.ts
|
702 |
+
var ChannelSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
703 |
+
static {
|
704 |
+
__name(this, "ChannelSelectMenuBuilder");
|
705 |
+
}
|
706 |
+
/**
|
707 |
+
* Creates a new select menu from API data.
|
708 |
+
*
|
709 |
+
* @param data - The API data to create this select menu with
|
710 |
+
* @example
|
711 |
+
* Creating a select menu from an API data object:
|
712 |
+
* ```ts
|
713 |
+
* const selectMenu = new ChannelSelectMenuBuilder({
|
714 |
+
* custom_id: 'a cool select menu',
|
715 |
+
* placeholder: 'select an option',
|
716 |
+
* max_values: 2,
|
717 |
+
* });
|
718 |
+
* ```
|
719 |
+
* @example
|
720 |
+
* Creating a select menu using setters and API data:
|
721 |
+
* ```ts
|
722 |
+
* const selectMenu = new ChannelSelectMenuBuilder({
|
723 |
+
* custom_id: 'a cool select menu',
|
724 |
+
* })
|
725 |
+
* .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
|
726 |
+
* .setMinValues(2);
|
727 |
+
* ```
|
728 |
+
*/
|
729 |
+
constructor(data) {
|
730 |
+
super({ ...data, type: ComponentType2.ChannelSelect });
|
731 |
+
}
|
732 |
+
/**
|
733 |
+
* Adds channel types to this select menu.
|
734 |
+
*
|
735 |
+
* @param types - The channel types to use
|
736 |
+
*/
|
737 |
+
addChannelTypes(...types) {
|
738 |
+
const normalizedTypes = normalizeArray(types);
|
739 |
+
this.data.channel_types ??= [];
|
740 |
+
this.data.channel_types.push(...channelTypesValidator.parse(normalizedTypes));
|
741 |
+
return this;
|
742 |
+
}
|
743 |
+
/**
|
744 |
+
* Sets channel types for this select menu.
|
745 |
+
*
|
746 |
+
* @param types - The channel types to use
|
747 |
+
*/
|
748 |
+
setChannelTypes(...types) {
|
749 |
+
const normalizedTypes = normalizeArray(types);
|
750 |
+
this.data.channel_types ??= [];
|
751 |
+
this.data.channel_types.splice(0, this.data.channel_types.length, ...channelTypesValidator.parse(normalizedTypes));
|
752 |
+
return this;
|
753 |
+
}
|
754 |
+
/**
|
755 |
+
* Adds default channels to this auto populated select menu.
|
756 |
+
*
|
757 |
+
* @param channels - The channels to add
|
758 |
+
*/
|
759 |
+
addDefaultChannels(...channels) {
|
760 |
+
const normalizedValues = normalizeArray(channels);
|
761 |
+
optionsLengthValidator.parse((this.data.default_values?.length ?? 0) + normalizedValues.length);
|
762 |
+
this.data.default_values ??= [];
|
763 |
+
this.data.default_values.push(
|
764 |
+
...normalizedValues.map((id) => ({
|
765 |
+
id,
|
766 |
+
type: SelectMenuDefaultValueType.Channel
|
767 |
+
}))
|
768 |
+
);
|
769 |
+
return this;
|
770 |
+
}
|
771 |
+
/**
|
772 |
+
* Sets default channels to this auto populated select menu.
|
773 |
+
*
|
774 |
+
* @param channels - The channels to set
|
775 |
+
*/
|
776 |
+
setDefaultChannels(...channels) {
|
777 |
+
const normalizedValues = normalizeArray(channels);
|
778 |
+
optionsLengthValidator.parse(normalizedValues.length);
|
779 |
+
this.data.default_values = normalizedValues.map((id) => ({
|
780 |
+
id,
|
781 |
+
type: SelectMenuDefaultValueType.Channel
|
782 |
+
}));
|
783 |
+
return this;
|
784 |
+
}
|
785 |
+
/**
|
786 |
+
* {@inheritDoc BaseSelectMenuBuilder.toJSON}
|
787 |
+
*/
|
788 |
+
toJSON() {
|
789 |
+
customIdValidator.parse(this.data.custom_id);
|
790 |
+
return {
|
791 |
+
...this.data
|
792 |
+
};
|
793 |
+
}
|
794 |
+
};
|
795 |
+
|
796 |
+
// src/components/selectMenu/MentionableSelectMenu.ts
|
797 |
+
import {
|
798 |
+
ComponentType as ComponentType3,
|
799 |
+
SelectMenuDefaultValueType as SelectMenuDefaultValueType2
|
800 |
+
} from "discord-api-types/v10";
|
801 |
+
var MentionableSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
802 |
+
static {
|
803 |
+
__name(this, "MentionableSelectMenuBuilder");
|
804 |
+
}
|
805 |
+
/**
|
806 |
+
* Creates a new select menu from API data.
|
807 |
+
*
|
808 |
+
* @param data - The API data to create this select menu with
|
809 |
+
* @example
|
810 |
+
* Creating a select menu from an API data object:
|
811 |
+
* ```ts
|
812 |
+
* const selectMenu = new MentionableSelectMenuBuilder({
|
813 |
+
* custom_id: 'a cool select menu',
|
814 |
+
* placeholder: 'select an option',
|
815 |
+
* max_values: 2,
|
816 |
+
* });
|
817 |
+
* ```
|
818 |
+
* @example
|
819 |
+
* Creating a select menu using setters and API data:
|
820 |
+
* ```ts
|
821 |
+
* const selectMenu = new MentionableSelectMenuBuilder({
|
822 |
+
* custom_id: 'a cool select menu',
|
823 |
+
* })
|
824 |
+
* .setMinValues(1);
|
825 |
+
* ```
|
826 |
+
*/
|
827 |
+
constructor(data) {
|
828 |
+
super({ ...data, type: ComponentType3.MentionableSelect });
|
829 |
+
}
|
830 |
+
/**
|
831 |
+
* Adds default roles to this auto populated select menu.
|
832 |
+
*
|
833 |
+
* @param roles - The roles to add
|
834 |
+
*/
|
835 |
+
addDefaultRoles(...roles) {
|
836 |
+
const normalizedValues = normalizeArray(roles);
|
837 |
+
optionsLengthValidator.parse((this.data.default_values?.length ?? 0) + normalizedValues.length);
|
838 |
+
this.data.default_values ??= [];
|
839 |
+
this.data.default_values.push(
|
840 |
+
...normalizedValues.map((id) => ({
|
841 |
+
id,
|
842 |
+
type: SelectMenuDefaultValueType2.Role
|
843 |
+
}))
|
844 |
+
);
|
845 |
+
return this;
|
846 |
+
}
|
847 |
+
/**
|
848 |
+
* Adds default users to this auto populated select menu.
|
849 |
+
*
|
850 |
+
* @param users - The users to add
|
851 |
+
*/
|
852 |
+
addDefaultUsers(...users) {
|
853 |
+
const normalizedValues = normalizeArray(users);
|
854 |
+
optionsLengthValidator.parse((this.data.default_values?.length ?? 0) + normalizedValues.length);
|
855 |
+
this.data.default_values ??= [];
|
856 |
+
this.data.default_values.push(
|
857 |
+
...normalizedValues.map((id) => ({
|
858 |
+
id,
|
859 |
+
type: SelectMenuDefaultValueType2.User
|
860 |
+
}))
|
861 |
+
);
|
862 |
+
return this;
|
863 |
+
}
|
864 |
+
/**
|
865 |
+
* Adds default values to this auto populated select menu.
|
866 |
+
*
|
867 |
+
* @param values - The values to add
|
868 |
+
*/
|
869 |
+
addDefaultValues(...values) {
|
870 |
+
const normalizedValues = normalizeArray(values);
|
871 |
+
optionsLengthValidator.parse((this.data.default_values?.length ?? 0) + normalizedValues.length);
|
872 |
+
this.data.default_values ??= [];
|
873 |
+
this.data.default_values.push(...normalizedValues);
|
874 |
+
return this;
|
875 |
+
}
|
876 |
+
/**
|
877 |
+
* Sets default values to this auto populated select menu.
|
878 |
+
*
|
879 |
+
* @param values - The values to set
|
880 |
+
*/
|
881 |
+
setDefaultValues(...values) {
|
882 |
+
const normalizedValues = normalizeArray(values);
|
883 |
+
optionsLengthValidator.parse(normalizedValues.length);
|
884 |
+
this.data.default_values = normalizedValues.slice();
|
885 |
+
return this;
|
886 |
+
}
|
887 |
+
};
|
888 |
+
|
889 |
+
// src/components/selectMenu/RoleSelectMenu.ts
|
890 |
+
import {
|
891 |
+
ComponentType as ComponentType4,
|
892 |
+
SelectMenuDefaultValueType as SelectMenuDefaultValueType3
|
893 |
+
} from "discord-api-types/v10";
|
894 |
+
var RoleSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
895 |
+
static {
|
896 |
+
__name(this, "RoleSelectMenuBuilder");
|
897 |
+
}
|
898 |
+
/**
|
899 |
+
* Creates a new select menu from API data.
|
900 |
+
*
|
901 |
+
* @param data - The API data to create this select menu with
|
902 |
+
* @example
|
903 |
+
* Creating a select menu from an API data object:
|
904 |
+
* ```ts
|
905 |
+
* const selectMenu = new RoleSelectMenuBuilder({
|
906 |
+
* custom_id: 'a cool select menu',
|
907 |
+
* placeholder: 'select an option',
|
908 |
+
* max_values: 2,
|
909 |
+
* });
|
910 |
+
* ```
|
911 |
+
* @example
|
912 |
+
* Creating a select menu using setters and API data:
|
913 |
+
* ```ts
|
914 |
+
* const selectMenu = new RoleSelectMenuBuilder({
|
915 |
+
* custom_id: 'a cool select menu',
|
916 |
+
* })
|
917 |
+
* .setMinValues(1);
|
918 |
+
* ```
|
919 |
+
*/
|
920 |
+
constructor(data) {
|
921 |
+
super({ ...data, type: ComponentType4.RoleSelect });
|
922 |
+
}
|
923 |
+
/**
|
924 |
+
* Adds default roles to this auto populated select menu.
|
925 |
+
*
|
926 |
+
* @param roles - The roles to add
|
927 |
+
*/
|
928 |
+
addDefaultRoles(...roles) {
|
929 |
+
const normalizedValues = normalizeArray(roles);
|
930 |
+
optionsLengthValidator.parse((this.data.default_values?.length ?? 0) + normalizedValues.length);
|
931 |
+
this.data.default_values ??= [];
|
932 |
+
this.data.default_values.push(
|
933 |
+
...normalizedValues.map((id) => ({
|
934 |
+
id,
|
935 |
+
type: SelectMenuDefaultValueType3.Role
|
936 |
+
}))
|
937 |
+
);
|
938 |
+
return this;
|
939 |
+
}
|
940 |
+
/**
|
941 |
+
* Sets default roles to this auto populated select menu.
|
942 |
+
*
|
943 |
+
* @param roles - The roles to set
|
944 |
+
*/
|
945 |
+
setDefaultRoles(...roles) {
|
946 |
+
const normalizedValues = normalizeArray(roles);
|
947 |
+
optionsLengthValidator.parse(normalizedValues.length);
|
948 |
+
this.data.default_values = normalizedValues.map((id) => ({
|
949 |
+
id,
|
950 |
+
type: SelectMenuDefaultValueType3.Role
|
951 |
+
}));
|
952 |
+
return this;
|
953 |
+
}
|
954 |
+
};
|
955 |
+
|
956 |
+
// src/components/selectMenu/StringSelectMenu.ts
|
957 |
+
import { ComponentType as ComponentType5 } from "discord-api-types/v10";
|
958 |
+
var StringSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
959 |
+
static {
|
960 |
+
__name(this, "StringSelectMenuBuilder");
|
961 |
+
}
|
962 |
+
/**
|
963 |
+
* The options within this select menu.
|
964 |
+
*/
|
965 |
+
options;
|
966 |
+
/**
|
967 |
+
* Creates a new select menu from API data.
|
968 |
+
*
|
969 |
+
* @param data - The API data to create this select menu with
|
970 |
+
* @example
|
971 |
+
* Creating a select menu from an API data object:
|
972 |
+
* ```ts
|
973 |
+
* const selectMenu = new StringSelectMenuBuilder({
|
974 |
+
* custom_id: 'a cool select menu',
|
975 |
+
* placeholder: 'select an option',
|
976 |
+
* max_values: 2,
|
977 |
+
* options: [
|
978 |
+
* { label: 'option 1', value: '1' },
|
979 |
+
* { label: 'option 2', value: '2' },
|
980 |
+
* { label: 'option 3', value: '3' },
|
981 |
+
* ],
|
982 |
+
* });
|
983 |
+
* ```
|
984 |
+
* @example
|
985 |
+
* Creating a select menu using setters and API data:
|
986 |
+
* ```ts
|
987 |
+
* const selectMenu = new StringSelectMenuBuilder({
|
988 |
+
* custom_id: 'a cool select menu',
|
989 |
+
* })
|
990 |
+
* .setMinValues(1)
|
991 |
+
* .addOptions({
|
992 |
+
* label: 'Catchy',
|
993 |
+
* value: 'catch',
|
994 |
+
* });
|
995 |
+
* ```
|
996 |
+
*/
|
997 |
+
constructor(data) {
|
998 |
+
const { options, ...initData } = data ?? {};
|
999 |
+
super({ ...initData, type: ComponentType5.StringSelect });
|
1000 |
+
this.options = options?.map((option) => new StringSelectMenuOptionBuilder(option)) ?? [];
|
1001 |
+
}
|
1002 |
+
/**
|
1003 |
+
* Adds options to this select menu.
|
1004 |
+
*
|
1005 |
+
* @param options - The options to add
|
1006 |
+
*/
|
1007 |
+
addOptions(...options) {
|
1008 |
+
const normalizedOptions = normalizeArray(options);
|
1009 |
+
optionsLengthValidator.parse(this.options.length + normalizedOptions.length);
|
1010 |
+
this.options.push(
|
1011 |
+
...normalizedOptions.map(
|
1012 |
+
(normalizedOption) => normalizedOption instanceof StringSelectMenuOptionBuilder ? normalizedOption : new StringSelectMenuOptionBuilder(jsonOptionValidator.parse(normalizedOption))
|
1013 |
+
)
|
1014 |
+
);
|
1015 |
+
return this;
|
1016 |
+
}
|
1017 |
+
/**
|
1018 |
+
* Sets the options for this select menu.
|
1019 |
+
*
|
1020 |
+
* @param options - The options to set
|
1021 |
+
*/
|
1022 |
+
setOptions(...options) {
|
1023 |
+
return this.spliceOptions(0, this.options.length, ...options);
|
1024 |
+
}
|
1025 |
+
/**
|
1026 |
+
* Removes, replaces, or inserts options for this select menu.
|
1027 |
+
*
|
1028 |
+
* @remarks
|
1029 |
+
* This method behaves similarly
|
1030 |
+
* to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | Array.prototype.splice()}.
|
1031 |
+
* It's useful for modifying and adjusting the order of existing options.
|
1032 |
+
* @example
|
1033 |
+
* Remove the first option:
|
1034 |
+
* ```ts
|
1035 |
+
* selectMenu.spliceOptions(0, 1);
|
1036 |
+
* ```
|
1037 |
+
* @example
|
1038 |
+
* Remove the first n option:
|
1039 |
+
* ```ts
|
1040 |
+
* const n = 4;
|
1041 |
+
* selectMenu.spliceOptions(0, n);
|
1042 |
+
* ```
|
1043 |
+
* @example
|
1044 |
+
* Remove the last option:
|
1045 |
+
* ```ts
|
1046 |
+
* selectMenu.spliceOptions(-1, 1);
|
1047 |
+
* ```
|
1048 |
+
* @param index - The index to start at
|
1049 |
+
* @param deleteCount - The number of options to remove
|
1050 |
+
* @param options - The replacing option objects or builders
|
1051 |
+
*/
|
1052 |
+
spliceOptions(index, deleteCount, ...options) {
|
1053 |
+
const normalizedOptions = normalizeArray(options);
|
1054 |
+
const clone = [...this.options];
|
1055 |
+
clone.splice(
|
1056 |
+
index,
|
1057 |
+
deleteCount,
|
1058 |
+
...normalizedOptions.map(
|
1059 |
+
(normalizedOption) => normalizedOption instanceof StringSelectMenuOptionBuilder ? normalizedOption : new StringSelectMenuOptionBuilder(jsonOptionValidator.parse(normalizedOption))
|
1060 |
+
)
|
1061 |
+
);
|
1062 |
+
optionsLengthValidator.parse(clone.length);
|
1063 |
+
this.options.splice(0, this.options.length, ...clone);
|
1064 |
+
return this;
|
1065 |
+
}
|
1066 |
+
/**
|
1067 |
+
* {@inheritDoc BaseSelectMenuBuilder.toJSON}
|
1068 |
+
*/
|
1069 |
+
toJSON() {
|
1070 |
+
validateRequiredSelectMenuParameters(this.options, this.data.custom_id);
|
1071 |
+
return {
|
1072 |
+
...this.data,
|
1073 |
+
options: this.options.map((option) => option.toJSON())
|
1074 |
+
};
|
1075 |
+
}
|
1076 |
+
};
|
1077 |
+
|
1078 |
+
// src/components/selectMenu/UserSelectMenu.ts
|
1079 |
+
import {
|
1080 |
+
ComponentType as ComponentType6,
|
1081 |
+
SelectMenuDefaultValueType as SelectMenuDefaultValueType4
|
1082 |
+
} from "discord-api-types/v10";
|
1083 |
+
var UserSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
1084 |
+
static {
|
1085 |
+
__name(this, "UserSelectMenuBuilder");
|
1086 |
+
}
|
1087 |
+
/**
|
1088 |
+
* Creates a new select menu from API data.
|
1089 |
+
*
|
1090 |
+
* @param data - The API data to create this select menu with
|
1091 |
+
* @example
|
1092 |
+
* Creating a select menu from an API data object:
|
1093 |
+
* ```ts
|
1094 |
+
* const selectMenu = new UserSelectMenuBuilder({
|
1095 |
+
* custom_id: 'a cool select menu',
|
1096 |
+
* placeholder: 'select an option',
|
1097 |
+
* max_values: 2,
|
1098 |
+
* });
|
1099 |
+
* ```
|
1100 |
+
* @example
|
1101 |
+
* Creating a select menu using setters and API data:
|
1102 |
+
* ```ts
|
1103 |
+
* const selectMenu = new UserSelectMenuBuilder({
|
1104 |
+
* custom_id: 'a cool select menu',
|
1105 |
+
* })
|
1106 |
+
* .setMinValues(1);
|
1107 |
+
* ```
|
1108 |
+
*/
|
1109 |
+
constructor(data) {
|
1110 |
+
super({ ...data, type: ComponentType6.UserSelect });
|
1111 |
+
}
|
1112 |
+
/**
|
1113 |
+
* Adds default users to this auto populated select menu.
|
1114 |
+
*
|
1115 |
+
* @param users - The users to add
|
1116 |
+
*/
|
1117 |
+
addDefaultUsers(...users) {
|
1118 |
+
const normalizedValues = normalizeArray(users);
|
1119 |
+
optionsLengthValidator.parse((this.data.default_values?.length ?? 0) + normalizedValues.length);
|
1120 |
+
this.data.default_values ??= [];
|
1121 |
+
this.data.default_values.push(
|
1122 |
+
...normalizedValues.map((id) => ({
|
1123 |
+
id,
|
1124 |
+
type: SelectMenuDefaultValueType4.User
|
1125 |
+
}))
|
1126 |
+
);
|
1127 |
+
return this;
|
1128 |
+
}
|
1129 |
+
/**
|
1130 |
+
* Sets default users to this auto populated select menu.
|
1131 |
+
*
|
1132 |
+
* @param users - The users to set
|
1133 |
+
*/
|
1134 |
+
setDefaultUsers(...users) {
|
1135 |
+
const normalizedValues = normalizeArray(users);
|
1136 |
+
optionsLengthValidator.parse(normalizedValues.length);
|
1137 |
+
this.data.default_values = normalizedValues.map((id) => ({
|
1138 |
+
id,
|
1139 |
+
type: SelectMenuDefaultValueType4.User
|
1140 |
+
}));
|
1141 |
+
return this;
|
1142 |
+
}
|
1143 |
+
};
|
1144 |
+
|
1145 |
+
// src/components/textInput/TextInput.ts
|
1146 |
+
import { isJSONEncodable } from "@discordjs/util";
|
1147 |
+
import { ComponentType as ComponentType7 } from "discord-api-types/v10";
|
1148 |
+
import isEqual from "fast-deep-equal";
|
1149 |
+
|
1150 |
+
// src/components/textInput/Assertions.ts
|
1151 |
+
var Assertions_exports3 = {};
|
1152 |
+
__export(Assertions_exports3, {
|
1153 |
+
labelValidator: () => labelValidator,
|
1154 |
+
maxLengthValidator: () => maxLengthValidator,
|
1155 |
+
minLengthValidator: () => minLengthValidator,
|
1156 |
+
placeholderValidator: () => placeholderValidator2,
|
1157 |
+
requiredValidator: () => requiredValidator,
|
1158 |
+
textInputStyleValidator: () => textInputStyleValidator,
|
1159 |
+
validateRequiredParameters: () => validateRequiredParameters,
|
1160 |
+
valueValidator: () => valueValidator
|
1161 |
+
});
|
1162 |
+
import { s as s3 } from "@sapphire/shapeshift";
|
1163 |
+
import { TextInputStyle } from "discord-api-types/v10";
|
1164 |
+
var textInputStyleValidator = s3.nativeEnum(TextInputStyle);
|
1165 |
+
var minLengthValidator = s3.number.int.greaterThanOrEqual(0).lessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
1166 |
+
var maxLengthValidator = s3.number.int.greaterThanOrEqual(1).lessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
1167 |
+
var requiredValidator = s3.boolean;
|
1168 |
+
var valueValidator = s3.string.lengthLessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
1169 |
+
var placeholderValidator2 = s3.string.lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
|
1170 |
+
var labelValidator = s3.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(45).setValidationEnabled(isValidationEnabled);
|
1171 |
+
function validateRequiredParameters(customId, style, label) {
|
1172 |
+
customIdValidator.parse(customId);
|
1173 |
+
textInputStyleValidator.parse(style);
|
1174 |
+
labelValidator.parse(label);
|
1175 |
+
}
|
1176 |
+
__name(validateRequiredParameters, "validateRequiredParameters");
|
1177 |
+
|
1178 |
+
// src/components/textInput/TextInput.ts
|
1179 |
+
var TextInputBuilder = class extends ComponentBuilder {
|
1180 |
+
static {
|
1181 |
+
__name(this, "TextInputBuilder");
|
1182 |
+
}
|
1183 |
+
/**
|
1184 |
+
* Creates a new text input from API data.
|
1185 |
+
*
|
1186 |
+
* @param data - The API data to create this text input with
|
1187 |
+
* @example
|
1188 |
+
* Creating a select menu option from an API data object:
|
1189 |
+
* ```ts
|
1190 |
+
* const textInput = new TextInputBuilder({
|
1191 |
+
* custom_id: 'a cool select menu',
|
1192 |
+
* label: 'Type something',
|
1193 |
+
* style: TextInputStyle.Short,
|
1194 |
+
* });
|
1195 |
+
* ```
|
1196 |
+
* @example
|
1197 |
+
* Creating a select menu option using setters and API data:
|
1198 |
+
* ```ts
|
1199 |
+
* const textInput = new TextInputBuilder({
|
1200 |
+
* label: 'Type something else',
|
1201 |
+
* })
|
1202 |
+
* .setCustomId('woah')
|
1203 |
+
* .setStyle(TextInputStyle.Paragraph);
|
1204 |
+
* ```
|
1205 |
+
*/
|
1206 |
+
constructor(data) {
|
1207 |
+
super({ type: ComponentType7.TextInput, ...data });
|
1208 |
+
}
|
1209 |
+
/**
|
1210 |
+
* Sets the custom id for this text input.
|
1211 |
+
*
|
1212 |
+
* @param customId - The custom id to use
|
1213 |
+
*/
|
1214 |
+
setCustomId(customId) {
|
1215 |
+
this.data.custom_id = customIdValidator.parse(customId);
|
1216 |
+
return this;
|
1217 |
+
}
|
1218 |
+
/**
|
1219 |
+
* Sets the label for this text input.
|
1220 |
+
*
|
1221 |
+
* @param label - The label to use
|
1222 |
+
*/
|
1223 |
+
setLabel(label) {
|
1224 |
+
this.data.label = labelValidator.parse(label);
|
1225 |
+
return this;
|
1226 |
+
}
|
1227 |
+
/**
|
1228 |
+
* Sets the style for this text input.
|
1229 |
+
*
|
1230 |
+
* @param style - The style to use
|
1231 |
+
*/
|
1232 |
+
setStyle(style) {
|
1233 |
+
this.data.style = textInputStyleValidator.parse(style);
|
1234 |
+
return this;
|
1235 |
+
}
|
1236 |
+
/**
|
1237 |
+
* Sets the minimum length of text for this text input.
|
1238 |
+
*
|
1239 |
+
* @param minLength - The minimum length of text for this text input
|
1240 |
+
*/
|
1241 |
+
setMinLength(minLength) {
|
1242 |
+
this.data.min_length = minLengthValidator.parse(minLength);
|
1243 |
+
return this;
|
1244 |
+
}
|
1245 |
+
/**
|
1246 |
+
* Sets the maximum length of text for this text input.
|
1247 |
+
*
|
1248 |
+
* @param maxLength - The maximum length of text for this text input
|
1249 |
+
*/
|
1250 |
+
setMaxLength(maxLength) {
|
1251 |
+
this.data.max_length = maxLengthValidator.parse(maxLength);
|
1252 |
+
return this;
|
1253 |
+
}
|
1254 |
+
/**
|
1255 |
+
* Sets the placeholder for this text input.
|
1256 |
+
*
|
1257 |
+
* @param placeholder - The placeholder to use
|
1258 |
+
*/
|
1259 |
+
setPlaceholder(placeholder) {
|
1260 |
+
this.data.placeholder = placeholderValidator2.parse(placeholder);
|
1261 |
+
return this;
|
1262 |
+
}
|
1263 |
+
/**
|
1264 |
+
* Sets the value for this text input.
|
1265 |
+
*
|
1266 |
+
* @param value - The value to use
|
1267 |
+
*/
|
1268 |
+
setValue(value) {
|
1269 |
+
this.data.value = valueValidator.parse(value);
|
1270 |
+
return this;
|
1271 |
+
}
|
1272 |
+
/**
|
1273 |
+
* Sets whether this text input is required.
|
1274 |
+
*
|
1275 |
+
* @param required - Whether this text input is required
|
1276 |
+
*/
|
1277 |
+
setRequired(required = true) {
|
1278 |
+
this.data.required = requiredValidator.parse(required);
|
1279 |
+
return this;
|
1280 |
+
}
|
1281 |
+
/**
|
1282 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
1283 |
+
*/
|
1284 |
+
toJSON() {
|
1285 |
+
validateRequiredParameters(this.data.custom_id, this.data.style, this.data.label);
|
1286 |
+
return {
|
1287 |
+
...this.data
|
1288 |
+
};
|
1289 |
+
}
|
1290 |
+
/**
|
1291 |
+
* {@inheritDoc Equatable.equals}
|
1292 |
+
*/
|
1293 |
+
equals(other) {
|
1294 |
+
if (isJSONEncodable(other)) {
|
1295 |
+
return isEqual(other.toJSON(), this.data);
|
1296 |
+
}
|
1297 |
+
return isEqual(other, this.data);
|
1298 |
+
}
|
1299 |
+
};
|
1300 |
+
|
1301 |
+
// src/components/Components.ts
|
1302 |
+
function createComponentBuilder(data) {
|
1303 |
+
if (data instanceof ComponentBuilder) {
|
1304 |
+
return data;
|
1305 |
+
}
|
1306 |
+
switch (data.type) {
|
1307 |
+
case ComponentType8.ActionRow:
|
1308 |
+
return new ActionRowBuilder(data);
|
1309 |
+
case ComponentType8.Button:
|
1310 |
+
return new ButtonBuilder(data);
|
1311 |
+
case ComponentType8.StringSelect:
|
1312 |
+
return new StringSelectMenuBuilder(data);
|
1313 |
+
case ComponentType8.TextInput:
|
1314 |
+
return new TextInputBuilder(data);
|
1315 |
+
case ComponentType8.UserSelect:
|
1316 |
+
return new UserSelectMenuBuilder(data);
|
1317 |
+
case ComponentType8.RoleSelect:
|
1318 |
+
return new RoleSelectMenuBuilder(data);
|
1319 |
+
case ComponentType8.MentionableSelect:
|
1320 |
+
return new MentionableSelectMenuBuilder(data);
|
1321 |
+
case ComponentType8.ChannelSelect:
|
1322 |
+
return new ChannelSelectMenuBuilder(data);
|
1323 |
+
default:
|
1324 |
+
throw new Error(`Cannot properly serialize component type: ${data.type}`);
|
1325 |
+
}
|
1326 |
+
}
|
1327 |
+
__name(createComponentBuilder, "createComponentBuilder");
|
1328 |
+
|
1329 |
+
// src/components/ActionRow.ts
|
1330 |
+
var ActionRowBuilder = class extends ComponentBuilder {
|
1331 |
+
static {
|
1332 |
+
__name(this, "ActionRowBuilder");
|
1333 |
+
}
|
1334 |
+
/**
|
1335 |
+
* The components within this action row.
|
1336 |
+
*/
|
1337 |
+
components;
|
1338 |
+
/**
|
1339 |
+
* Creates a new action row from API data.
|
1340 |
+
*
|
1341 |
+
* @param data - The API data to create this action row with
|
1342 |
+
* @example
|
1343 |
+
* Creating an action row from an API data object:
|
1344 |
+
* ```ts
|
1345 |
+
* const actionRow = new ActionRowBuilder({
|
1346 |
+
* components: [
|
1347 |
+
* {
|
1348 |
+
* custom_id: "custom id",
|
1349 |
+
* label: "Type something",
|
1350 |
+
* style: TextInputStyle.Short,
|
1351 |
+
* type: ComponentType.TextInput,
|
1352 |
+
* },
|
1353 |
+
* ],
|
1354 |
+
* });
|
1355 |
+
* ```
|
1356 |
+
* @example
|
1357 |
+
* Creating an action row using setters and API data:
|
1358 |
+
* ```ts
|
1359 |
+
* const actionRow = new ActionRowBuilder({
|
1360 |
+
* components: [
|
1361 |
+
* {
|
1362 |
+
* custom_id: "custom id",
|
1363 |
+
* label: "Click me",
|
1364 |
+
* style: ButtonStyle.Primary,
|
1365 |
+
* type: ComponentType.Button,
|
1366 |
+
* },
|
1367 |
+
* ],
|
1368 |
+
* })
|
1369 |
+
* .addComponents(button2, button3);
|
1370 |
+
* ```
|
1371 |
+
*/
|
1372 |
+
constructor({ components, ...data } = {}) {
|
1373 |
+
super({ type: ComponentType9.ActionRow, ...data });
|
1374 |
+
this.components = components?.map((component) => createComponentBuilder(component)) ?? [];
|
1375 |
+
}
|
1376 |
+
/**
|
1377 |
+
* Adds components to this action row.
|
1378 |
+
*
|
1379 |
+
* @param components - The components to add
|
1380 |
+
*/
|
1381 |
+
addComponents(...components) {
|
1382 |
+
this.components.push(...normalizeArray(components));
|
1383 |
+
return this;
|
1384 |
+
}
|
1385 |
+
/**
|
1386 |
+
* Sets components for this action row.
|
1387 |
+
*
|
1388 |
+
* @param components - The components to set
|
1389 |
+
*/
|
1390 |
+
setComponents(...components) {
|
1391 |
+
this.components.splice(0, this.components.length, ...normalizeArray(components));
|
1392 |
+
return this;
|
1393 |
+
}
|
1394 |
+
/**
|
1395 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
1396 |
+
*/
|
1397 |
+
toJSON() {
|
1398 |
+
return {
|
1399 |
+
...this.data,
|
1400 |
+
components: this.components.map((component) => component.toJSON())
|
1401 |
+
};
|
1402 |
+
}
|
1403 |
+
};
|
1404 |
+
|
1405 |
+
// src/interactions/modals/Assertions.ts
|
1406 |
+
var Assertions_exports4 = {};
|
1407 |
+
__export(Assertions_exports4, {
|
1408 |
+
componentsValidator: () => componentsValidator,
|
1409 |
+
titleValidator: () => titleValidator,
|
1410 |
+
validateRequiredParameters: () => validateRequiredParameters2
|
1411 |
+
});
|
1412 |
+
import { s as s4 } from "@sapphire/shapeshift";
|
1413 |
+
var titleValidator = s4.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(45).setValidationEnabled(isValidationEnabled);
|
1414 |
+
var componentsValidator = s4.instance(ActionRowBuilder).array.lengthGreaterThanOrEqual(1).setValidationEnabled(isValidationEnabled);
|
1415 |
+
function validateRequiredParameters2(customId, title, components) {
|
1416 |
+
customIdValidator.parse(customId);
|
1417 |
+
titleValidator.parse(title);
|
1418 |
+
componentsValidator.parse(components);
|
1419 |
+
}
|
1420 |
+
__name(validateRequiredParameters2, "validateRequiredParameters");
|
1421 |
+
|
1422 |
+
// src/interactions/modals/Modal.ts
|
1423 |
+
var ModalBuilder = class {
|
1424 |
+
static {
|
1425 |
+
__name(this, "ModalBuilder");
|
1426 |
+
}
|
1427 |
+
/**
|
1428 |
+
* The API data associated with this modal.
|
1429 |
+
*/
|
1430 |
+
data;
|
1431 |
+
/**
|
1432 |
+
* The components within this modal.
|
1433 |
+
*/
|
1434 |
+
components = [];
|
1435 |
+
/**
|
1436 |
+
* Creates a new modal from API data.
|
1437 |
+
*
|
1438 |
+
* @param data - The API data to create this modal with
|
1439 |
+
*/
|
1440 |
+
constructor({ components, ...data } = {}) {
|
1441 |
+
this.data = { ...data };
|
1442 |
+
this.components = components?.map((component) => createComponentBuilder(component)) ?? [];
|
1443 |
+
}
|
1444 |
+
/**
|
1445 |
+
* Sets the title of this modal.
|
1446 |
+
*
|
1447 |
+
* @param title - The title to use
|
1448 |
+
*/
|
1449 |
+
setTitle(title) {
|
1450 |
+
this.data.title = titleValidator.parse(title);
|
1451 |
+
return this;
|
1452 |
+
}
|
1453 |
+
/**
|
1454 |
+
* Sets the custom id of this modal.
|
1455 |
+
*
|
1456 |
+
* @param customId - The custom id to use
|
1457 |
+
*/
|
1458 |
+
setCustomId(customId) {
|
1459 |
+
this.data.custom_id = customIdValidator.parse(customId);
|
1460 |
+
return this;
|
1461 |
+
}
|
1462 |
+
/**
|
1463 |
+
* Adds components to this modal.
|
1464 |
+
*
|
1465 |
+
* @param components - The components to add
|
1466 |
+
*/
|
1467 |
+
addComponents(...components) {
|
1468 |
+
this.components.push(
|
1469 |
+
...normalizeArray(components).map(
|
1470 |
+
(component) => component instanceof ActionRowBuilder ? component : new ActionRowBuilder(component)
|
1471 |
+
)
|
1472 |
+
);
|
1473 |
+
return this;
|
1474 |
+
}
|
1475 |
+
/**
|
1476 |
+
* Sets components for this modal.
|
1477 |
+
*
|
1478 |
+
* @param components - The components to set
|
1479 |
+
*/
|
1480 |
+
setComponents(...components) {
|
1481 |
+
this.components.splice(0, this.components.length, ...normalizeArray(components));
|
1482 |
+
return this;
|
1483 |
+
}
|
1484 |
+
/**
|
1485 |
+
* {@inheritDoc ComponentBuilder.toJSON}
|
1486 |
+
*/
|
1487 |
+
toJSON() {
|
1488 |
+
validateRequiredParameters2(this.data.custom_id, this.data.title, this.components);
|
1489 |
+
return {
|
1490 |
+
...this.data,
|
1491 |
+
components: this.components.map((component) => component.toJSON())
|
1492 |
+
};
|
1493 |
+
}
|
1494 |
+
};
|
1495 |
+
|
1496 |
+
// src/interactions/slashCommands/Assertions.ts
|
1497 |
+
var Assertions_exports5 = {};
|
1498 |
+
__export(Assertions_exports5, {
|
1499 |
+
assertReturnOfBuilder: () => assertReturnOfBuilder,
|
1500 |
+
localizationMapPredicate: () => localizationMapPredicate,
|
1501 |
+
validateChoicesLength: () => validateChoicesLength,
|
1502 |
+
validateDMPermission: () => validateDMPermission,
|
1503 |
+
validateDefaultMemberPermissions: () => validateDefaultMemberPermissions,
|
1504 |
+
validateDefaultPermission: () => validateDefaultPermission,
|
1505 |
+
validateDescription: () => validateDescription,
|
1506 |
+
validateLocale: () => validateLocale,
|
1507 |
+
validateLocalizationMap: () => validateLocalizationMap,
|
1508 |
+
validateMaxOptionsLength: () => validateMaxOptionsLength,
|
1509 |
+
validateNSFW: () => validateNSFW,
|
1510 |
+
validateName: () => validateName,
|
1511 |
+
validateRequired: () => validateRequired,
|
1512 |
+
validateRequiredParameters: () => validateRequiredParameters3
|
1513 |
+
});
|
1514 |
+
import { s as s5 } from "@sapphire/shapeshift";
|
1515 |
+
import { Locale } from "discord-api-types/v10";
|
1516 |
+
var namePredicate = s5.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(32).regex(/^[\p{Ll}\p{Lm}\p{Lo}\p{N}\p{sc=Devanagari}\p{sc=Thai}_-]+$/u).setValidationEnabled(isValidationEnabled);
|
1517 |
+
function validateName(name) {
|
1518 |
+
namePredicate.parse(name);
|
1519 |
+
}
|
1520 |
+
__name(validateName, "validateName");
|
1521 |
+
var descriptionPredicate2 = s5.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
|
1522 |
+
var localePredicate = s5.nativeEnum(Locale);
|
1523 |
+
function validateDescription(description) {
|
1524 |
+
descriptionPredicate2.parse(description);
|
1525 |
+
}
|
1526 |
+
__name(validateDescription, "validateDescription");
|
1527 |
+
var maxArrayLengthPredicate = s5.unknown.array.lengthLessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
|
1528 |
+
function validateLocale(locale) {
|
1529 |
+
return localePredicate.parse(locale);
|
1530 |
+
}
|
1531 |
+
__name(validateLocale, "validateLocale");
|
1532 |
+
function validateMaxOptionsLength(options) {
|
1533 |
+
maxArrayLengthPredicate.parse(options);
|
1534 |
+
}
|
1535 |
+
__name(validateMaxOptionsLength, "validateMaxOptionsLength");
|
1536 |
+
function validateRequiredParameters3(name, description, options) {
|
1537 |
+
validateName(name);
|
1538 |
+
validateDescription(description);
|
1539 |
+
validateMaxOptionsLength(options);
|
1540 |
+
}
|
1541 |
+
__name(validateRequiredParameters3, "validateRequiredParameters");
|
1542 |
+
var booleanPredicate = s5.boolean;
|
1543 |
+
function validateDefaultPermission(value) {
|
1544 |
+
booleanPredicate.parse(value);
|
1545 |
+
}
|
1546 |
+
__name(validateDefaultPermission, "validateDefaultPermission");
|
1547 |
+
function validateRequired(required) {
|
1548 |
+
booleanPredicate.parse(required);
|
1549 |
+
}
|
1550 |
+
__name(validateRequired, "validateRequired");
|
1551 |
+
var choicesLengthPredicate = s5.number.lessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
|
1552 |
+
function validateChoicesLength(amountAdding, choices) {
|
1553 |
+
choicesLengthPredicate.parse((choices?.length ?? 0) + amountAdding);
|
1554 |
+
}
|
1555 |
+
__name(validateChoicesLength, "validateChoicesLength");
|
1556 |
+
function assertReturnOfBuilder(input, ExpectedInstanceOf) {
|
1557 |
+
s5.instance(ExpectedInstanceOf).parse(input);
|
1558 |
+
}
|
1559 |
+
__name(assertReturnOfBuilder, "assertReturnOfBuilder");
|
1560 |
+
var localizationMapPredicate = s5.object(Object.fromEntries(Object.values(Locale).map((locale) => [locale, s5.string.nullish]))).strict.nullish.setValidationEnabled(isValidationEnabled);
|
1561 |
+
function validateLocalizationMap(value) {
|
1562 |
+
localizationMapPredicate.parse(value);
|
1563 |
+
}
|
1564 |
+
__name(validateLocalizationMap, "validateLocalizationMap");
|
1565 |
+
var dmPermissionPredicate = s5.boolean.nullish;
|
1566 |
+
function validateDMPermission(value) {
|
1567 |
+
dmPermissionPredicate.parse(value);
|
1568 |
+
}
|
1569 |
+
__name(validateDMPermission, "validateDMPermission");
|
1570 |
+
var memberPermissionPredicate = s5.union(
|
1571 |
+
s5.bigint.transform((value) => value.toString()),
|
1572 |
+
s5.number.safeInt.transform((value) => value.toString()),
|
1573 |
+
s5.string.regex(/^\d+$/)
|
1574 |
+
).nullish;
|
1575 |
+
function validateDefaultMemberPermissions(permissions) {
|
1576 |
+
return memberPermissionPredicate.parse(permissions);
|
1577 |
+
}
|
1578 |
+
__name(validateDefaultMemberPermissions, "validateDefaultMemberPermissions");
|
1579 |
+
function validateNSFW(value) {
|
1580 |
+
booleanPredicate.parse(value);
|
1581 |
+
}
|
1582 |
+
__name(validateNSFW, "validateNSFW");
|
1583 |
+
|
1584 |
+
// src/interactions/slashCommands/SlashCommandBuilder.ts
|
1585 |
+
import { mix as mix6 } from "ts-mixer";
|
1586 |
+
|
1587 |
+
// src/interactions/slashCommands/SlashCommandSubcommands.ts
|
1588 |
+
import {
|
1589 |
+
ApplicationCommandOptionType as ApplicationCommandOptionType11
|
1590 |
+
} from "discord-api-types/v10";
|
1591 |
+
import { mix as mix5 } from "ts-mixer";
|
1592 |
+
|
1593 |
+
// src/interactions/slashCommands/mixins/NameAndDescription.ts
|
1594 |
+
var SharedNameAndDescription = class {
|
1595 |
+
static {
|
1596 |
+
__name(this, "SharedNameAndDescription");
|
1597 |
+
}
|
1598 |
+
/**
|
1599 |
+
* The name of this command.
|
1600 |
+
*/
|
1601 |
+
name;
|
1602 |
+
/**
|
1603 |
+
* The name localizations of this command.
|
1604 |
+
*/
|
1605 |
+
name_localizations;
|
1606 |
+
/**
|
1607 |
+
* The description of this command.
|
1608 |
+
*/
|
1609 |
+
description;
|
1610 |
+
/**
|
1611 |
+
* The description localizations of this command.
|
1612 |
+
*/
|
1613 |
+
description_localizations;
|
1614 |
+
/**
|
1615 |
+
* Sets the name of this command.
|
1616 |
+
*
|
1617 |
+
* @param name - The name to use
|
1618 |
+
*/
|
1619 |
+
setName(name) {
|
1620 |
+
validateName(name);
|
1621 |
+
Reflect.set(this, "name", name);
|
1622 |
+
return this;
|
1623 |
+
}
|
1624 |
+
/**
|
1625 |
+
* Sets the description of this command.
|
1626 |
+
*
|
1627 |
+
* @param description - The description to use
|
1628 |
+
*/
|
1629 |
+
setDescription(description) {
|
1630 |
+
validateDescription(description);
|
1631 |
+
Reflect.set(this, "description", description);
|
1632 |
+
return this;
|
1633 |
+
}
|
1634 |
+
/**
|
1635 |
+
* Sets a name localization for this command.
|
1636 |
+
*
|
1637 |
+
* @param locale - The locale to set
|
1638 |
+
* @param localizedName - The localized name for the given `locale`
|
1639 |
+
*/
|
1640 |
+
setNameLocalization(locale, localizedName) {
|
1641 |
+
if (!this.name_localizations) {
|
1642 |
+
Reflect.set(this, "name_localizations", {});
|
1643 |
+
}
|
1644 |
+
const parsedLocale = validateLocale(locale);
|
1645 |
+
if (localizedName === null) {
|
1646 |
+
this.name_localizations[parsedLocale] = null;
|
1647 |
+
return this;
|
1648 |
+
}
|
1649 |
+
validateName(localizedName);
|
1650 |
+
this.name_localizations[parsedLocale] = localizedName;
|
1651 |
+
return this;
|
1652 |
+
}
|
1653 |
+
/**
|
1654 |
+
* Sets the name localizations for this command.
|
1655 |
+
*
|
1656 |
+
* @param localizedNames - The object of localized names to set
|
1657 |
+
*/
|
1658 |
+
setNameLocalizations(localizedNames) {
|
1659 |
+
if (localizedNames === null) {
|
1660 |
+
Reflect.set(this, "name_localizations", null);
|
1661 |
+
return this;
|
1662 |
+
}
|
1663 |
+
Reflect.set(this, "name_localizations", {});
|
1664 |
+
for (const args of Object.entries(localizedNames)) {
|
1665 |
+
this.setNameLocalization(...args);
|
1666 |
+
}
|
1667 |
+
return this;
|
1668 |
+
}
|
1669 |
+
/**
|
1670 |
+
* Sets a description localization for this command.
|
1671 |
+
*
|
1672 |
+
* @param locale - The locale to set
|
1673 |
+
* @param localizedDescription - The localized description for the given locale
|
1674 |
+
*/
|
1675 |
+
setDescriptionLocalization(locale, localizedDescription) {
|
1676 |
+
if (!this.description_localizations) {
|
1677 |
+
Reflect.set(this, "description_localizations", {});
|
1678 |
+
}
|
1679 |
+
const parsedLocale = validateLocale(locale);
|
1680 |
+
if (localizedDescription === null) {
|
1681 |
+
this.description_localizations[parsedLocale] = null;
|
1682 |
+
return this;
|
1683 |
+
}
|
1684 |
+
validateDescription(localizedDescription);
|
1685 |
+
this.description_localizations[parsedLocale] = localizedDescription;
|
1686 |
+
return this;
|
1687 |
+
}
|
1688 |
+
/**
|
1689 |
+
* Sets the description localizations for this command.
|
1690 |
+
*
|
1691 |
+
* @param localizedDescriptions - The object of localized descriptions to set
|
1692 |
+
*/
|
1693 |
+
setDescriptionLocalizations(localizedDescriptions) {
|
1694 |
+
if (localizedDescriptions === null) {
|
1695 |
+
Reflect.set(this, "description_localizations", null);
|
1696 |
+
return this;
|
1697 |
+
}
|
1698 |
+
Reflect.set(this, "description_localizations", {});
|
1699 |
+
for (const args of Object.entries(localizedDescriptions)) {
|
1700 |
+
this.setDescriptionLocalization(...args);
|
1701 |
+
}
|
1702 |
+
return this;
|
1703 |
+
}
|
1704 |
+
};
|
1705 |
+
|
1706 |
+
// src/interactions/slashCommands/options/attachment.ts
|
1707 |
+
import { ApplicationCommandOptionType } from "discord-api-types/v10";
|
1708 |
+
|
1709 |
+
// src/interactions/slashCommands/mixins/ApplicationCommandOptionBase.ts
|
1710 |
+
var ApplicationCommandOptionBase = class extends SharedNameAndDescription {
|
1711 |
+
static {
|
1712 |
+
__name(this, "ApplicationCommandOptionBase");
|
1713 |
+
}
|
1714 |
+
/**
|
1715 |
+
* Whether this option is required.
|
1716 |
+
*
|
1717 |
+
* @defaultValue `false`
|
1718 |
+
*/
|
1719 |
+
required = false;
|
1720 |
+
/**
|
1721 |
+
* Sets whether this option is required.
|
1722 |
+
*
|
1723 |
+
* @param required - Whether this option should be required
|
1724 |
+
*/
|
1725 |
+
setRequired(required) {
|
1726 |
+
validateRequired(required);
|
1727 |
+
Reflect.set(this, "required", required);
|
1728 |
+
return this;
|
1729 |
+
}
|
1730 |
+
/**
|
1731 |
+
* This method runs required validators on this builder.
|
1732 |
+
*/
|
1733 |
+
runRequiredValidations() {
|
1734 |
+
validateRequiredParameters3(this.name, this.description, []);
|
1735 |
+
validateLocalizationMap(this.name_localizations);
|
1736 |
+
validateLocalizationMap(this.description_localizations);
|
1737 |
+
validateRequired(this.required);
|
1738 |
+
}
|
1739 |
+
};
|
1740 |
+
|
1741 |
+
// src/interactions/slashCommands/options/attachment.ts
|
1742 |
+
var SlashCommandAttachmentOption = class extends ApplicationCommandOptionBase {
|
1743 |
+
static {
|
1744 |
+
__name(this, "SlashCommandAttachmentOption");
|
1745 |
+
}
|
1746 |
+
/**
|
1747 |
+
* The type of this option.
|
1748 |
+
*/
|
1749 |
+
type = ApplicationCommandOptionType.Attachment;
|
1750 |
+
/**
|
1751 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1752 |
+
*/
|
1753 |
+
toJSON() {
|
1754 |
+
this.runRequiredValidations();
|
1755 |
+
return { ...this };
|
1756 |
+
}
|
1757 |
+
};
|
1758 |
+
|
1759 |
+
// src/interactions/slashCommands/options/boolean.ts
|
1760 |
+
import { ApplicationCommandOptionType as ApplicationCommandOptionType2 } from "discord-api-types/v10";
|
1761 |
+
var SlashCommandBooleanOption = class extends ApplicationCommandOptionBase {
|
1762 |
+
static {
|
1763 |
+
__name(this, "SlashCommandBooleanOption");
|
1764 |
+
}
|
1765 |
+
/**
|
1766 |
+
* The type of this option.
|
1767 |
+
*/
|
1768 |
+
type = ApplicationCommandOptionType2.Boolean;
|
1769 |
+
/**
|
1770 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1771 |
+
*/
|
1772 |
+
toJSON() {
|
1773 |
+
this.runRequiredValidations();
|
1774 |
+
return { ...this };
|
1775 |
+
}
|
1776 |
+
};
|
1777 |
+
|
1778 |
+
// src/interactions/slashCommands/options/channel.ts
|
1779 |
+
import { ApplicationCommandOptionType as ApplicationCommandOptionType3 } from "discord-api-types/v10";
|
1780 |
+
import { mix } from "ts-mixer";
|
1781 |
+
|
1782 |
+
// src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts
|
1783 |
+
import { s as s6 } from "@sapphire/shapeshift";
|
1784 |
+
import { ChannelType as ChannelType2 } from "discord-api-types/v10";
|
1785 |
+
var allowedChannelTypes = [
|
1786 |
+
ChannelType2.GuildText,
|
1787 |
+
ChannelType2.GuildVoice,
|
1788 |
+
ChannelType2.GuildCategory,
|
1789 |
+
ChannelType2.GuildAnnouncement,
|
1790 |
+
ChannelType2.AnnouncementThread,
|
1791 |
+
ChannelType2.PublicThread,
|
1792 |
+
ChannelType2.PrivateThread,
|
1793 |
+
ChannelType2.GuildStageVoice,
|
1794 |
+
ChannelType2.GuildForum,
|
1795 |
+
ChannelType2.GuildMedia
|
1796 |
+
];
|
1797 |
+
var channelTypesPredicate = s6.array(s6.union(...allowedChannelTypes.map((type) => s6.literal(type))));
|
1798 |
+
var ApplicationCommandOptionChannelTypesMixin = class {
|
1799 |
+
static {
|
1800 |
+
__name(this, "ApplicationCommandOptionChannelTypesMixin");
|
1801 |
+
}
|
1802 |
+
/**
|
1803 |
+
* The channel types of this option.
|
1804 |
+
*/
|
1805 |
+
channel_types;
|
1806 |
+
/**
|
1807 |
+
* Adds channel types to this option.
|
1808 |
+
*
|
1809 |
+
* @param channelTypes - The channel types
|
1810 |
+
*/
|
1811 |
+
addChannelTypes(...channelTypes) {
|
1812 |
+
if (this.channel_types === void 0) {
|
1813 |
+
Reflect.set(this, "channel_types", []);
|
1814 |
+
}
|
1815 |
+
this.channel_types.push(...channelTypesPredicate.parse(channelTypes));
|
1816 |
+
return this;
|
1817 |
+
}
|
1818 |
+
};
|
1819 |
+
|
1820 |
+
// src/interactions/slashCommands/options/channel.ts
|
1821 |
+
var SlashCommandChannelOption = class extends ApplicationCommandOptionBase {
|
1822 |
+
/**
|
1823 |
+
* The type of this option.
|
1824 |
+
*/
|
1825 |
+
type = ApplicationCommandOptionType3.Channel;
|
1826 |
+
/**
|
1827 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1828 |
+
*/
|
1829 |
+
toJSON() {
|
1830 |
+
this.runRequiredValidations();
|
1831 |
+
return { ...this };
|
1832 |
+
}
|
1833 |
+
};
|
1834 |
+
__name(SlashCommandChannelOption, "SlashCommandChannelOption");
|
1835 |
+
SlashCommandChannelOption = __decorateClass([
|
1836 |
+
mix(ApplicationCommandOptionChannelTypesMixin)
|
1837 |
+
], SlashCommandChannelOption);
|
1838 |
+
|
1839 |
+
// src/interactions/slashCommands/options/integer.ts
|
1840 |
+
import { s as s8 } from "@sapphire/shapeshift";
|
1841 |
+
import { ApplicationCommandOptionType as ApplicationCommandOptionType5 } from "discord-api-types/v10";
|
1842 |
+
import { mix as mix2 } from "ts-mixer";
|
1843 |
+
|
1844 |
+
// src/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.ts
|
1845 |
+
var ApplicationCommandNumericOptionMinMaxValueMixin = class {
|
1846 |
+
static {
|
1847 |
+
__name(this, "ApplicationCommandNumericOptionMinMaxValueMixin");
|
1848 |
+
}
|
1849 |
+
/**
|
1850 |
+
* The maximum value of this option.
|
1851 |
+
*/
|
1852 |
+
max_value;
|
1853 |
+
/**
|
1854 |
+
* The minimum value of this option.
|
1855 |
+
*/
|
1856 |
+
min_value;
|
1857 |
+
};
|
1858 |
+
|
1859 |
+
// src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts
|
1860 |
+
import { s as s7 } from "@sapphire/shapeshift";
|
1861 |
+
import { ApplicationCommandOptionType as ApplicationCommandOptionType4 } from "discord-api-types/v10";
|
1862 |
+
var stringPredicate = s7.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100);
|
1863 |
+
var numberPredicate = s7.number.greaterThan(Number.NEGATIVE_INFINITY).lessThan(Number.POSITIVE_INFINITY);
|
1864 |
+
var choicesPredicate = s7.object({
|
1865 |
+
name: stringPredicate,
|
1866 |
+
name_localizations: localizationMapPredicate,
|
1867 |
+
value: s7.union(stringPredicate, numberPredicate)
|
1868 |
+
}).array;
|
1869 |
+
var booleanPredicate2 = s7.boolean;
|
1870 |
+
var ApplicationCommandOptionWithChoicesAndAutocompleteMixin = class {
|
1871 |
+
static {
|
1872 |
+
__name(this, "ApplicationCommandOptionWithChoicesAndAutocompleteMixin");
|
1873 |
+
}
|
1874 |
+
/**
|
1875 |
+
* The choices of this option.
|
1876 |
+
*/
|
1877 |
+
choices;
|
1878 |
+
/**
|
1879 |
+
* Whether this option utilizes autocomplete.
|
1880 |
+
*/
|
1881 |
+
autocomplete;
|
1882 |
+
/**
|
1883 |
+
* The type of this option.
|
1884 |
+
*
|
1885 |
+
* @privateRemarks Since this is present and this is a mixin, this is needed.
|
1886 |
+
*/
|
1887 |
+
type;
|
1888 |
+
/**
|
1889 |
+
* Adds multiple choices to this option.
|
1890 |
+
*
|
1891 |
+
* @param choices - The choices to add
|
1892 |
+
*/
|
1893 |
+
addChoices(...choices) {
|
1894 |
+
if (choices.length > 0 && this.autocomplete) {
|
1895 |
+
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
|
1896 |
+
}
|
1897 |
+
choicesPredicate.parse(choices);
|
1898 |
+
if (this.choices === void 0) {
|
1899 |
+
Reflect.set(this, "choices", []);
|
1900 |
+
}
|
1901 |
+
validateChoicesLength(choices.length, this.choices);
|
1902 |
+
for (const { name, name_localizations, value } of choices) {
|
1903 |
+
if (this.type === ApplicationCommandOptionType4.String) {
|
1904 |
+
stringPredicate.parse(value);
|
1905 |
+
} else {
|
1906 |
+
numberPredicate.parse(value);
|
1907 |
+
}
|
1908 |
+
this.choices.push({ name, name_localizations, value });
|
1909 |
+
}
|
1910 |
+
return this;
|
1911 |
+
}
|
1912 |
+
/**
|
1913 |
+
* Sets multiple choices for this option.
|
1914 |
+
*
|
1915 |
+
* @param choices - The choices to set
|
1916 |
+
*/
|
1917 |
+
setChoices(...choices) {
|
1918 |
+
if (choices.length > 0 && this.autocomplete) {
|
1919 |
+
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
|
1920 |
+
}
|
1921 |
+
choicesPredicate.parse(choices);
|
1922 |
+
Reflect.set(this, "choices", []);
|
1923 |
+
this.addChoices(...choices);
|
1924 |
+
return this;
|
1925 |
+
}
|
1926 |
+
/**
|
1927 |
+
* Whether this option uses autocomplete.
|
1928 |
+
*
|
1929 |
+
* @param autocomplete - Whether this option should use autocomplete
|
1930 |
+
*/
|
1931 |
+
setAutocomplete(autocomplete) {
|
1932 |
+
booleanPredicate2.parse(autocomplete);
|
1933 |
+
if (autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {
|
1934 |
+
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
|
1935 |
+
}
|
1936 |
+
Reflect.set(this, "autocomplete", autocomplete);
|
1937 |
+
return this;
|
1938 |
+
}
|
1939 |
+
};
|
1940 |
+
|
1941 |
+
// src/interactions/slashCommands/options/integer.ts
|
1942 |
+
var numberValidator = s8.number.int;
|
1943 |
+
var SlashCommandIntegerOption = class extends ApplicationCommandOptionBase {
|
1944 |
+
/**
|
1945 |
+
* The type of this option.
|
1946 |
+
*/
|
1947 |
+
type = ApplicationCommandOptionType5.Integer;
|
1948 |
+
/**
|
1949 |
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}
|
1950 |
+
*/
|
1951 |
+
setMaxValue(max) {
|
1952 |
+
numberValidator.parse(max);
|
1953 |
+
Reflect.set(this, "max_value", max);
|
1954 |
+
return this;
|
1955 |
+
}
|
1956 |
+
/**
|
1957 |
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMinValue}
|
1958 |
+
*/
|
1959 |
+
setMinValue(min) {
|
1960 |
+
numberValidator.parse(min);
|
1961 |
+
Reflect.set(this, "min_value", min);
|
1962 |
+
return this;
|
1963 |
+
}
|
1964 |
+
/**
|
1965 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1966 |
+
*/
|
1967 |
+
toJSON() {
|
1968 |
+
this.runRequiredValidations();
|
1969 |
+
if (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {
|
1970 |
+
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
|
1971 |
+
}
|
1972 |
+
return { ...this };
|
1973 |
+
}
|
1974 |
+
};
|
1975 |
+
__name(SlashCommandIntegerOption, "SlashCommandIntegerOption");
|
1976 |
+
SlashCommandIntegerOption = __decorateClass([
|
1977 |
+
mix2(ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin)
|
1978 |
+
], SlashCommandIntegerOption);
|
1979 |
+
|
1980 |
+
// src/interactions/slashCommands/options/mentionable.ts
|
1981 |
+
import { ApplicationCommandOptionType as ApplicationCommandOptionType6 } from "discord-api-types/v10";
|
1982 |
+
var SlashCommandMentionableOption = class extends ApplicationCommandOptionBase {
|
1983 |
+
static {
|
1984 |
+
__name(this, "SlashCommandMentionableOption");
|
1985 |
+
}
|
1986 |
+
/**
|
1987 |
+
* The type of this option.
|
1988 |
+
*/
|
1989 |
+
type = ApplicationCommandOptionType6.Mentionable;
|
1990 |
+
/**
|
1991 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
1992 |
+
*/
|
1993 |
+
toJSON() {
|
1994 |
+
this.runRequiredValidations();
|
1995 |
+
return { ...this };
|
1996 |
+
}
|
1997 |
+
};
|
1998 |
+
|
1999 |
+
// src/interactions/slashCommands/options/number.ts
|
2000 |
+
import { s as s9 } from "@sapphire/shapeshift";
|
2001 |
+
import { ApplicationCommandOptionType as ApplicationCommandOptionType7 } from "discord-api-types/v10";
|
2002 |
+
import { mix as mix3 } from "ts-mixer";
|
2003 |
+
var numberValidator2 = s9.number;
|
2004 |
+
var SlashCommandNumberOption = class extends ApplicationCommandOptionBase {
|
2005 |
+
/**
|
2006 |
+
* The type of this option.
|
2007 |
+
*/
|
2008 |
+
type = ApplicationCommandOptionType7.Number;
|
2009 |
+
/**
|
2010 |
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}
|
2011 |
+
*/
|
2012 |
+
setMaxValue(max) {
|
2013 |
+
numberValidator2.parse(max);
|
2014 |
+
Reflect.set(this, "max_value", max);
|
2015 |
+
return this;
|
2016 |
+
}
|
2017 |
+
/**
|
2018 |
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMinValue}
|
2019 |
+
*/
|
2020 |
+
setMinValue(min) {
|
2021 |
+
numberValidator2.parse(min);
|
2022 |
+
Reflect.set(this, "min_value", min);
|
2023 |
+
return this;
|
2024 |
+
}
|
2025 |
+
/**
|
2026 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
2027 |
+
*/
|
2028 |
+
toJSON() {
|
2029 |
+
this.runRequiredValidations();
|
2030 |
+
if (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {
|
2031 |
+
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
|
2032 |
+
}
|
2033 |
+
return { ...this };
|
2034 |
+
}
|
2035 |
+
};
|
2036 |
+
__name(SlashCommandNumberOption, "SlashCommandNumberOption");
|
2037 |
+
SlashCommandNumberOption = __decorateClass([
|
2038 |
+
mix3(ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin)
|
2039 |
+
], SlashCommandNumberOption);
|
2040 |
+
|
2041 |
+
// src/interactions/slashCommands/options/role.ts
|
2042 |
+
import { ApplicationCommandOptionType as ApplicationCommandOptionType8 } from "discord-api-types/v10";
|
2043 |
+
var SlashCommandRoleOption = class extends ApplicationCommandOptionBase {
|
2044 |
+
static {
|
2045 |
+
__name(this, "SlashCommandRoleOption");
|
2046 |
+
}
|
2047 |
+
/**
|
2048 |
+
* The type of this option.
|
2049 |
+
*/
|
2050 |
+
type = ApplicationCommandOptionType8.Role;
|
2051 |
+
/**
|
2052 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
2053 |
+
*/
|
2054 |
+
toJSON() {
|
2055 |
+
this.runRequiredValidations();
|
2056 |
+
return { ...this };
|
2057 |
+
}
|
2058 |
+
};
|
2059 |
+
|
2060 |
+
// src/interactions/slashCommands/options/string.ts
|
2061 |
+
import { s as s10 } from "@sapphire/shapeshift";
|
2062 |
+
import { ApplicationCommandOptionType as ApplicationCommandOptionType9 } from "discord-api-types/v10";
|
2063 |
+
import { mix as mix4 } from "ts-mixer";
|
2064 |
+
var minLengthValidator2 = s10.number.greaterThanOrEqual(0).lessThanOrEqual(6e3);
|
2065 |
+
var maxLengthValidator2 = s10.number.greaterThanOrEqual(1).lessThanOrEqual(6e3);
|
2066 |
+
var SlashCommandStringOption = class extends ApplicationCommandOptionBase {
|
2067 |
+
/**
|
2068 |
+
* The type of this option.
|
2069 |
+
*/
|
2070 |
+
type = ApplicationCommandOptionType9.String;
|
2071 |
+
/**
|
2072 |
+
* The maximum length of this option.
|
2073 |
+
*/
|
2074 |
+
max_length;
|
2075 |
+
/**
|
2076 |
+
* The minimum length of this option.
|
2077 |
+
*/
|
2078 |
+
min_length;
|
2079 |
+
/**
|
2080 |
+
* Sets the maximum length of this string option.
|
2081 |
+
*
|
2082 |
+
* @param max - The maximum length this option can be
|
2083 |
+
*/
|
2084 |
+
setMaxLength(max) {
|
2085 |
+
maxLengthValidator2.parse(max);
|
2086 |
+
Reflect.set(this, "max_length", max);
|
2087 |
+
return this;
|
2088 |
+
}
|
2089 |
+
/**
|
2090 |
+
* Sets the minimum length of this string option.
|
2091 |
+
*
|
2092 |
+
* @param min - The minimum length this option can be
|
2093 |
+
*/
|
2094 |
+
setMinLength(min) {
|
2095 |
+
minLengthValidator2.parse(min);
|
2096 |
+
Reflect.set(this, "min_length", min);
|
2097 |
+
return this;
|
2098 |
+
}
|
2099 |
+
/**
|
2100 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
2101 |
+
*/
|
2102 |
+
toJSON() {
|
2103 |
+
this.runRequiredValidations();
|
2104 |
+
if (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {
|
2105 |
+
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
|
2106 |
+
}
|
2107 |
+
return { ...this };
|
2108 |
+
}
|
2109 |
+
};
|
2110 |
+
__name(SlashCommandStringOption, "SlashCommandStringOption");
|
2111 |
+
SlashCommandStringOption = __decorateClass([
|
2112 |
+
mix4(ApplicationCommandOptionWithChoicesAndAutocompleteMixin)
|
2113 |
+
], SlashCommandStringOption);
|
2114 |
+
|
2115 |
+
// src/interactions/slashCommands/options/user.ts
|
2116 |
+
import { ApplicationCommandOptionType as ApplicationCommandOptionType10 } from "discord-api-types/v10";
|
2117 |
+
var SlashCommandUserOption = class extends ApplicationCommandOptionBase {
|
2118 |
+
static {
|
2119 |
+
__name(this, "SlashCommandUserOption");
|
2120 |
+
}
|
2121 |
+
/**
|
2122 |
+
* The type of this option.
|
2123 |
+
*/
|
2124 |
+
type = ApplicationCommandOptionType10.User;
|
2125 |
+
/**
|
2126 |
+
* {@inheritDoc ApplicationCommandOptionBase.toJSON}
|
2127 |
+
*/
|
2128 |
+
toJSON() {
|
2129 |
+
this.runRequiredValidations();
|
2130 |
+
return { ...this };
|
2131 |
+
}
|
2132 |
+
};
|
2133 |
+
|
2134 |
+
// src/interactions/slashCommands/mixins/SharedSlashCommandOptions.ts
|
2135 |
+
var SharedSlashCommandOptions = class {
|
2136 |
+
static {
|
2137 |
+
__name(this, "SharedSlashCommandOptions");
|
2138 |
+
}
|
2139 |
+
options;
|
2140 |
+
/**
|
2141 |
+
* Adds a boolean option.
|
2142 |
+
*
|
2143 |
+
* @param input - A function that returns an option builder or an already built builder
|
2144 |
+
*/
|
2145 |
+
addBooleanOption(input) {
|
2146 |
+
return this._sharedAddOptionMethod(input, SlashCommandBooleanOption);
|
2147 |
+
}
|
2148 |
+
/**
|
2149 |
+
* Adds a user option.
|
2150 |
+
*
|
2151 |
+
* @param input - A function that returns an option builder or an already built builder
|
2152 |
+
*/
|
2153 |
+
addUserOption(input) {
|
2154 |
+
return this._sharedAddOptionMethod(input, SlashCommandUserOption);
|
2155 |
+
}
|
2156 |
+
/**
|
2157 |
+
* Adds a channel option.
|
2158 |
+
*
|
2159 |
+
* @param input - A function that returns an option builder or an already built builder
|
2160 |
+
*/
|
2161 |
+
addChannelOption(input) {
|
2162 |
+
return this._sharedAddOptionMethod(input, SlashCommandChannelOption);
|
2163 |
+
}
|
2164 |
+
/**
|
2165 |
+
* Adds a role option.
|
2166 |
+
*
|
2167 |
+
* @param input - A function that returns an option builder or an already built builder
|
2168 |
+
*/
|
2169 |
+
addRoleOption(input) {
|
2170 |
+
return this._sharedAddOptionMethod(input, SlashCommandRoleOption);
|
2171 |
+
}
|
2172 |
+
/**
|
2173 |
+
* Adds an attachment option.
|
2174 |
+
*
|
2175 |
+
* @param input - A function that returns an option builder or an already built builder
|
2176 |
+
*/
|
2177 |
+
addAttachmentOption(input) {
|
2178 |
+
return this._sharedAddOptionMethod(input, SlashCommandAttachmentOption);
|
2179 |
+
}
|
2180 |
+
/**
|
2181 |
+
* Adds a mentionable option.
|
2182 |
+
*
|
2183 |
+
* @param input - A function that returns an option builder or an already built builder
|
2184 |
+
*/
|
2185 |
+
addMentionableOption(input) {
|
2186 |
+
return this._sharedAddOptionMethod(input, SlashCommandMentionableOption);
|
2187 |
+
}
|
2188 |
+
/**
|
2189 |
+
* Adds a string option.
|
2190 |
+
*
|
2191 |
+
* @param input - A function that returns an option builder or an already built builder
|
2192 |
+
*/
|
2193 |
+
addStringOption(input) {
|
2194 |
+
return this._sharedAddOptionMethod(input, SlashCommandStringOption);
|
2195 |
+
}
|
2196 |
+
/**
|
2197 |
+
* Adds an integer option.
|
2198 |
+
*
|
2199 |
+
* @param input - A function that returns an option builder or an already built builder
|
2200 |
+
*/
|
2201 |
+
addIntegerOption(input) {
|
2202 |
+
return this._sharedAddOptionMethod(input, SlashCommandIntegerOption);
|
2203 |
+
}
|
2204 |
+
/**
|
2205 |
+
* Adds a number option.
|
2206 |
+
*
|
2207 |
+
* @param input - A function that returns an option builder or an already built builder
|
2208 |
+
*/
|
2209 |
+
addNumberOption(input) {
|
2210 |
+
return this._sharedAddOptionMethod(input, SlashCommandNumberOption);
|
2211 |
+
}
|
2212 |
+
/**
|
2213 |
+
* Where the actual adding magic happens. ✨
|
2214 |
+
*
|
2215 |
+
* @param input - The input. What else?
|
2216 |
+
* @param Instance - The instance of whatever is being added
|
2217 |
+
* @internal
|
2218 |
+
*/
|
2219 |
+
_sharedAddOptionMethod(input, Instance) {
|
2220 |
+
const { options } = this;
|
2221 |
+
validateMaxOptionsLength(options);
|
2222 |
+
const result = typeof input === "function" ? input(new Instance()) : input;
|
2223 |
+
assertReturnOfBuilder(result, Instance);
|
2224 |
+
options.push(result);
|
2225 |
+
return this;
|
2226 |
+
}
|
2227 |
+
};
|
2228 |
+
|
2229 |
+
// src/interactions/slashCommands/SlashCommandSubcommands.ts
|
2230 |
+
var SlashCommandSubcommandGroupBuilder = class {
|
2231 |
+
/**
|
2232 |
+
* The name of this subcommand group.
|
2233 |
+
*/
|
2234 |
+
name = void 0;
|
2235 |
+
/**
|
2236 |
+
* The description of this subcommand group.
|
2237 |
+
*/
|
2238 |
+
description = void 0;
|
2239 |
+
/**
|
2240 |
+
* The subcommands within this subcommand group.
|
2241 |
+
*/
|
2242 |
+
options = [];
|
2243 |
+
/**
|
2244 |
+
* Adds a new subcommand to this group.
|
2245 |
+
*
|
2246 |
+
* @param input - A function that returns a subcommand builder or an already built builder
|
2247 |
+
*/
|
2248 |
+
addSubcommand(input) {
|
2249 |
+
const { options } = this;
|
2250 |
+
validateMaxOptionsLength(options);
|
2251 |
+
const result = typeof input === "function" ? input(new SlashCommandSubcommandBuilder()) : input;
|
2252 |
+
assertReturnOfBuilder(result, SlashCommandSubcommandBuilder);
|
2253 |
+
options.push(result);
|
2254 |
+
return this;
|
2255 |
+
}
|
2256 |
+
/**
|
2257 |
+
* Serializes this builder to API-compatible JSON data.
|
2258 |
+
*
|
2259 |
+
* @remarks
|
2260 |
+
* This method runs validations on the data before serializing it.
|
2261 |
+
* As such, it may throw an error if the data is invalid.
|
2262 |
+
*/
|
2263 |
+
toJSON() {
|
2264 |
+
validateRequiredParameters3(this.name, this.description, this.options);
|
2265 |
+
return {
|
2266 |
+
type: ApplicationCommandOptionType11.SubcommandGroup,
|
2267 |
+
name: this.name,
|
2268 |
+
name_localizations: this.name_localizations,
|
2269 |
+
description: this.description,
|
2270 |
+
description_localizations: this.description_localizations,
|
2271 |
+
options: this.options.map((option) => option.toJSON())
|
2272 |
+
};
|
2273 |
+
}
|
2274 |
+
};
|
2275 |
+
__name(SlashCommandSubcommandGroupBuilder, "SlashCommandSubcommandGroupBuilder");
|
2276 |
+
SlashCommandSubcommandGroupBuilder = __decorateClass([
|
2277 |
+
mix5(SharedNameAndDescription)
|
2278 |
+
], SlashCommandSubcommandGroupBuilder);
|
2279 |
+
var SlashCommandSubcommandBuilder = class {
|
2280 |
+
/**
|
2281 |
+
* The name of this subcommand.
|
2282 |
+
*/
|
2283 |
+
name = void 0;
|
2284 |
+
/**
|
2285 |
+
* The description of this subcommand.
|
2286 |
+
*/
|
2287 |
+
description = void 0;
|
2288 |
+
/**
|
2289 |
+
* The options within this subcommand.
|
2290 |
+
*/
|
2291 |
+
options = [];
|
2292 |
+
/**
|
2293 |
+
* Serializes this builder to API-compatible JSON data.
|
2294 |
+
*
|
2295 |
+
* @remarks
|
2296 |
+
* This method runs validations on the data before serializing it.
|
2297 |
+
* As such, it may throw an error if the data is invalid.
|
2298 |
+
*/
|
2299 |
+
toJSON() {
|
2300 |
+
validateRequiredParameters3(this.name, this.description, this.options);
|
2301 |
+
return {
|
2302 |
+
type: ApplicationCommandOptionType11.Subcommand,
|
2303 |
+
name: this.name,
|
2304 |
+
name_localizations: this.name_localizations,
|
2305 |
+
description: this.description,
|
2306 |
+
description_localizations: this.description_localizations,
|
2307 |
+
options: this.options.map((option) => option.toJSON())
|
2308 |
+
};
|
2309 |
+
}
|
2310 |
+
};
|
2311 |
+
__name(SlashCommandSubcommandBuilder, "SlashCommandSubcommandBuilder");
|
2312 |
+
SlashCommandSubcommandBuilder = __decorateClass([
|
2313 |
+
mix5(SharedNameAndDescription, SharedSlashCommandOptions)
|
2314 |
+
], SlashCommandSubcommandBuilder);
|
2315 |
+
|
2316 |
+
// src/interactions/slashCommands/SlashCommandBuilder.ts
|
2317 |
+
var SlashCommandBuilder = class {
|
2318 |
+
/**
|
2319 |
+
* The name of this command.
|
2320 |
+
*/
|
2321 |
+
name = void 0;
|
2322 |
+
/**
|
2323 |
+
* The name localizations of this command.
|
2324 |
+
*/
|
2325 |
+
name_localizations;
|
2326 |
+
/**
|
2327 |
+
* The description of this command.
|
2328 |
+
*/
|
2329 |
+
description = void 0;
|
2330 |
+
/**
|
2331 |
+
* The description localizations of this command.
|
2332 |
+
*/
|
2333 |
+
description_localizations;
|
2334 |
+
/**
|
2335 |
+
* The options of this command.
|
2336 |
+
*/
|
2337 |
+
options = [];
|
2338 |
+
/**
|
2339 |
+
* Whether this command is enabled by default when the application is added to a guild.
|
2340 |
+
*
|
2341 |
+
* @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
|
2342 |
+
*/
|
2343 |
+
default_permission = void 0;
|
2344 |
+
/**
|
2345 |
+
* The set of permissions represented as a bit set for the command.
|
2346 |
+
*/
|
2347 |
+
default_member_permissions = void 0;
|
2348 |
+
/**
|
2349 |
+
* Indicates whether the command is available in direct messages with the application.
|
2350 |
+
*
|
2351 |
+
* @remarks
|
2352 |
+
* By default, commands are visible. This property is only for global commands.
|
2353 |
+
*/
|
2354 |
+
dm_permission = void 0;
|
2355 |
+
/**
|
2356 |
+
* Whether this command is NSFW.
|
2357 |
+
*/
|
2358 |
+
nsfw = void 0;
|
2359 |
+
/**
|
2360 |
+
* Sets whether the command is enabled by default when the application is added to a guild.
|
2361 |
+
*
|
2362 |
+
* @remarks
|
2363 |
+
* If set to `false`, you will have to later `PUT` the permissions for this command.
|
2364 |
+
* @param value - Whether or not to enable this command by default
|
2365 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
2366 |
+
* @deprecated Use {@link SlashCommandBuilder.setDefaultMemberPermissions} or {@link SlashCommandBuilder.setDMPermission} instead.
|
2367 |
+
*/
|
2368 |
+
setDefaultPermission(value) {
|
2369 |
+
validateDefaultPermission(value);
|
2370 |
+
Reflect.set(this, "default_permission", value);
|
2371 |
+
return this;
|
2372 |
+
}
|
2373 |
+
/**
|
2374 |
+
* Sets the default permissions a member should have in order to run the command.
|
2375 |
+
*
|
2376 |
+
* @remarks
|
2377 |
+
* You can set this to `'0'` to disable the command by default.
|
2378 |
+
* @param permissions - The permissions bit field to set
|
2379 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
2380 |
+
*/
|
2381 |
+
setDefaultMemberPermissions(permissions) {
|
2382 |
+
const permissionValue = validateDefaultMemberPermissions(permissions);
|
2383 |
+
Reflect.set(this, "default_member_permissions", permissionValue);
|
2384 |
+
return this;
|
2385 |
+
}
|
2386 |
+
/**
|
2387 |
+
* Sets if the command is available in direct messages with the application.
|
2388 |
+
*
|
2389 |
+
* @remarks
|
2390 |
+
* By default, commands are visible. This method is only for global commands.
|
2391 |
+
* @param enabled - Whether the command should be enabled in direct messages
|
2392 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
2393 |
+
*/
|
2394 |
+
setDMPermission(enabled) {
|
2395 |
+
validateDMPermission(enabled);
|
2396 |
+
Reflect.set(this, "dm_permission", enabled);
|
2397 |
+
return this;
|
2398 |
+
}
|
2399 |
+
/**
|
2400 |
+
* Sets whether this command is NSFW.
|
2401 |
+
*
|
2402 |
+
* @param nsfw - Whether this command is NSFW
|
2403 |
+
*/
|
2404 |
+
setNSFW(nsfw = true) {
|
2405 |
+
validateNSFW(nsfw);
|
2406 |
+
Reflect.set(this, "nsfw", nsfw);
|
2407 |
+
return this;
|
2408 |
+
}
|
2409 |
+
/**
|
2410 |
+
* Adds a new subcommand group to this command.
|
2411 |
+
*
|
2412 |
+
* @param input - A function that returns a subcommand group builder or an already built builder
|
2413 |
+
*/
|
2414 |
+
addSubcommandGroup(input) {
|
2415 |
+
const { options } = this;
|
2416 |
+
validateMaxOptionsLength(options);
|
2417 |
+
const result = typeof input === "function" ? input(new SlashCommandSubcommandGroupBuilder()) : input;
|
2418 |
+
assertReturnOfBuilder(result, SlashCommandSubcommandGroupBuilder);
|
2419 |
+
options.push(result);
|
2420 |
+
return this;
|
2421 |
+
}
|
2422 |
+
/**
|
2423 |
+
* Adds a new subcommand to this command.
|
2424 |
+
*
|
2425 |
+
* @param input - A function that returns a subcommand builder or an already built builder
|
2426 |
+
*/
|
2427 |
+
addSubcommand(input) {
|
2428 |
+
const { options } = this;
|
2429 |
+
validateMaxOptionsLength(options);
|
2430 |
+
const result = typeof input === "function" ? input(new SlashCommandSubcommandBuilder()) : input;
|
2431 |
+
assertReturnOfBuilder(result, SlashCommandSubcommandBuilder);
|
2432 |
+
options.push(result);
|
2433 |
+
return this;
|
2434 |
+
}
|
2435 |
+
/**
|
2436 |
+
* Serializes this builder to API-compatible JSON data.
|
2437 |
+
*
|
2438 |
+
* @remarks
|
2439 |
+
* This method runs validations on the data before serializing it.
|
2440 |
+
* As such, it may throw an error if the data is invalid.
|
2441 |
+
*/
|
2442 |
+
toJSON() {
|
2443 |
+
validateRequiredParameters3(this.name, this.description, this.options);
|
2444 |
+
validateLocalizationMap(this.name_localizations);
|
2445 |
+
validateLocalizationMap(this.description_localizations);
|
2446 |
+
return {
|
2447 |
+
...this,
|
2448 |
+
options: this.options.map((option) => option.toJSON())
|
2449 |
+
};
|
2450 |
+
}
|
2451 |
+
};
|
2452 |
+
__name(SlashCommandBuilder, "SlashCommandBuilder");
|
2453 |
+
SlashCommandBuilder = __decorateClass([
|
2454 |
+
mix6(SharedSlashCommandOptions, SharedNameAndDescription)
|
2455 |
+
], SlashCommandBuilder);
|
2456 |
+
|
2457 |
+
// src/interactions/contextMenuCommands/Assertions.ts
|
2458 |
+
var Assertions_exports6 = {};
|
2459 |
+
__export(Assertions_exports6, {
|
2460 |
+
validateDMPermission: () => validateDMPermission2,
|
2461 |
+
validateDefaultMemberPermissions: () => validateDefaultMemberPermissions2,
|
2462 |
+
validateDefaultPermission: () => validateDefaultPermission2,
|
2463 |
+
validateName: () => validateName2,
|
2464 |
+
validateRequiredParameters: () => validateRequiredParameters4,
|
2465 |
+
validateType: () => validateType
|
2466 |
+
});
|
2467 |
+
import { s as s11 } from "@sapphire/shapeshift";
|
2468 |
+
import { ApplicationCommandType } from "discord-api-types/v10";
|
2469 |
+
var namePredicate2 = s11.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(32).regex(/^( *[\p{P}\p{L}\p{N}\p{sc=Devanagari}\p{sc=Thai}]+ *)+$/u).setValidationEnabled(isValidationEnabled);
|
2470 |
+
var typePredicate = s11.union(s11.literal(ApplicationCommandType.User), s11.literal(ApplicationCommandType.Message)).setValidationEnabled(isValidationEnabled);
|
2471 |
+
var booleanPredicate3 = s11.boolean;
|
2472 |
+
function validateDefaultPermission2(value) {
|
2473 |
+
booleanPredicate3.parse(value);
|
2474 |
+
}
|
2475 |
+
__name(validateDefaultPermission2, "validateDefaultPermission");
|
2476 |
+
function validateName2(name) {
|
2477 |
+
namePredicate2.parse(name);
|
2478 |
+
}
|
2479 |
+
__name(validateName2, "validateName");
|
2480 |
+
function validateType(type) {
|
2481 |
+
typePredicate.parse(type);
|
2482 |
+
}
|
2483 |
+
__name(validateType, "validateType");
|
2484 |
+
function validateRequiredParameters4(name, type) {
|
2485 |
+
validateName2(name);
|
2486 |
+
validateType(type);
|
2487 |
+
}
|
2488 |
+
__name(validateRequiredParameters4, "validateRequiredParameters");
|
2489 |
+
var dmPermissionPredicate2 = s11.boolean.nullish;
|
2490 |
+
function validateDMPermission2(value) {
|
2491 |
+
dmPermissionPredicate2.parse(value);
|
2492 |
+
}
|
2493 |
+
__name(validateDMPermission2, "validateDMPermission");
|
2494 |
+
var memberPermissionPredicate2 = s11.union(
|
2495 |
+
s11.bigint.transform((value) => value.toString()),
|
2496 |
+
s11.number.safeInt.transform((value) => value.toString()),
|
2497 |
+
s11.string.regex(/^\d+$/)
|
2498 |
+
).nullish;
|
2499 |
+
function validateDefaultMemberPermissions2(permissions) {
|
2500 |
+
return memberPermissionPredicate2.parse(permissions);
|
2501 |
+
}
|
2502 |
+
__name(validateDefaultMemberPermissions2, "validateDefaultMemberPermissions");
|
2503 |
+
|
2504 |
+
// src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts
|
2505 |
+
var ContextMenuCommandBuilder = class {
|
2506 |
+
static {
|
2507 |
+
__name(this, "ContextMenuCommandBuilder");
|
2508 |
+
}
|
2509 |
+
/**
|
2510 |
+
* The name of this command.
|
2511 |
+
*/
|
2512 |
+
name = void 0;
|
2513 |
+
/**
|
2514 |
+
* The name localizations of this command.
|
2515 |
+
*/
|
2516 |
+
name_localizations;
|
2517 |
+
/**
|
2518 |
+
* The type of this command.
|
2519 |
+
*/
|
2520 |
+
type = void 0;
|
2521 |
+
/**
|
2522 |
+
* Whether this command is enabled by default when the application is added to a guild.
|
2523 |
+
*
|
2524 |
+
* @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
|
2525 |
+
*/
|
2526 |
+
default_permission = void 0;
|
2527 |
+
/**
|
2528 |
+
* The set of permissions represented as a bit set for the command.
|
2529 |
+
*/
|
2530 |
+
default_member_permissions = void 0;
|
2531 |
+
/**
|
2532 |
+
* Indicates whether the command is available in direct messages with the application.
|
2533 |
+
*
|
2534 |
+
* @remarks
|
2535 |
+
* By default, commands are visible. This property is only for global commands.
|
2536 |
+
*/
|
2537 |
+
dm_permission = void 0;
|
2538 |
+
/**
|
2539 |
+
* Sets the name of this command.
|
2540 |
+
*
|
2541 |
+
* @param name - The name to use
|
2542 |
+
*/
|
2543 |
+
setName(name) {
|
2544 |
+
validateName2(name);
|
2545 |
+
Reflect.set(this, "name", name);
|
2546 |
+
return this;
|
2547 |
+
}
|
2548 |
+
/**
|
2549 |
+
* Sets the type of this command.
|
2550 |
+
*
|
2551 |
+
* @param type - The type to use
|
2552 |
+
*/
|
2553 |
+
setType(type) {
|
2554 |
+
validateType(type);
|
2555 |
+
Reflect.set(this, "type", type);
|
2556 |
+
return this;
|
2557 |
+
}
|
2558 |
+
/**
|
2559 |
+
* Sets whether the command is enabled by default when the application is added to a guild.
|
2560 |
+
*
|
2561 |
+
* @remarks
|
2562 |
+
* If set to `false`, you will have to later `PUT` the permissions for this command.
|
2563 |
+
* @param value - Whether to enable this command by default
|
2564 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
2565 |
+
* @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
|
2566 |
+
*/
|
2567 |
+
setDefaultPermission(value) {
|
2568 |
+
validateDefaultPermission2(value);
|
2569 |
+
Reflect.set(this, "default_permission", value);
|
2570 |
+
return this;
|
2571 |
+
}
|
2572 |
+
/**
|
2573 |
+
* Sets the default permissions a member should have in order to run this command.
|
2574 |
+
*
|
2575 |
+
* @remarks
|
2576 |
+
* You can set this to `'0'` to disable the command by default.
|
2577 |
+
* @param permissions - The permissions bit field to set
|
2578 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
2579 |
+
*/
|
2580 |
+
setDefaultMemberPermissions(permissions) {
|
2581 |
+
const permissionValue = validateDefaultMemberPermissions2(permissions);
|
2582 |
+
Reflect.set(this, "default_member_permissions", permissionValue);
|
2583 |
+
return this;
|
2584 |
+
}
|
2585 |
+
/**
|
2586 |
+
* Sets if the command is available in direct messages with the application.
|
2587 |
+
*
|
2588 |
+
* @remarks
|
2589 |
+
* By default, commands are visible. This method is only for global commands.
|
2590 |
+
* @param enabled - Whether the command should be enabled in direct messages
|
2591 |
+
* @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
|
2592 |
+
*/
|
2593 |
+
setDMPermission(enabled) {
|
2594 |
+
validateDMPermission2(enabled);
|
2595 |
+
Reflect.set(this, "dm_permission", enabled);
|
2596 |
+
return this;
|
2597 |
+
}
|
2598 |
+
/**
|
2599 |
+
* Sets a name localization for this command.
|
2600 |
+
*
|
2601 |
+
* @param locale - The locale to set
|
2602 |
+
* @param localizedName - The localized name for the given `locale`
|
2603 |
+
*/
|
2604 |
+
setNameLocalization(locale, localizedName) {
|
2605 |
+
if (!this.name_localizations) {
|
2606 |
+
Reflect.set(this, "name_localizations", {});
|
2607 |
+
}
|
2608 |
+
const parsedLocale = validateLocale(locale);
|
2609 |
+
if (localizedName === null) {
|
2610 |
+
this.name_localizations[parsedLocale] = null;
|
2611 |
+
return this;
|
2612 |
+
}
|
2613 |
+
validateName2(localizedName);
|
2614 |
+
this.name_localizations[parsedLocale] = localizedName;
|
2615 |
+
return this;
|
2616 |
+
}
|
2617 |
+
/**
|
2618 |
+
* Sets the name localizations for this command.
|
2619 |
+
*
|
2620 |
+
* @param localizedNames - The object of localized names to set
|
2621 |
+
*/
|
2622 |
+
setNameLocalizations(localizedNames) {
|
2623 |
+
if (localizedNames === null) {
|
2624 |
+
Reflect.set(this, "name_localizations", null);
|
2625 |
+
return this;
|
2626 |
+
}
|
2627 |
+
Reflect.set(this, "name_localizations", {});
|
2628 |
+
for (const args of Object.entries(localizedNames))
|
2629 |
+
this.setNameLocalization(...args);
|
2630 |
+
return this;
|
2631 |
+
}
|
2632 |
+
/**
|
2633 |
+
* Serializes this builder to API-compatible JSON data.
|
2634 |
+
*
|
2635 |
+
* @remarks
|
2636 |
+
* This method runs validations on the data before serializing it.
|
2637 |
+
* As such, it may throw an error if the data is invalid.
|
2638 |
+
*/
|
2639 |
+
toJSON() {
|
2640 |
+
validateRequiredParameters4(this.name, this.type);
|
2641 |
+
validateLocalizationMap(this.name_localizations);
|
2642 |
+
return { ...this };
|
2643 |
+
}
|
2644 |
+
};
|
2645 |
+
|
2646 |
+
// src/util/componentUtil.ts
|
2647 |
+
function embedLength(data) {
|
2648 |
+
return (data.title?.length ?? 0) + (data.description?.length ?? 0) + (data.fields?.reduce((prev, curr) => prev + curr.name.length + curr.value.length, 0) ?? 0) + (data.footer?.text.length ?? 0) + (data.author?.name.length ?? 0);
|
2649 |
+
}
|
2650 |
+
__name(embedLength, "embedLength");
|
2651 |
+
|
2652 |
+
// src/index.ts
|
2653 |
+
var version = "1.7.0";
|
2654 |
+
export {
|
2655 |
+
ActionRowBuilder,
|
2656 |
+
ApplicationCommandNumericOptionMinMaxValueMixin,
|
2657 |
+
ApplicationCommandOptionBase,
|
2658 |
+
ApplicationCommandOptionChannelTypesMixin,
|
2659 |
+
ApplicationCommandOptionWithChoicesAndAutocompleteMixin,
|
2660 |
+
BaseSelectMenuBuilder,
|
2661 |
+
ButtonBuilder,
|
2662 |
+
ChannelSelectMenuBuilder,
|
2663 |
+
Assertions_exports2 as ComponentAssertions,
|
2664 |
+
ComponentBuilder,
|
2665 |
+
Assertions_exports6 as ContextMenuCommandAssertions,
|
2666 |
+
ContextMenuCommandBuilder,
|
2667 |
+
Assertions_exports as EmbedAssertions,
|
2668 |
+
EmbedBuilder,
|
2669 |
+
MentionableSelectMenuBuilder,
|
2670 |
+
Assertions_exports4 as ModalAssertions,
|
2671 |
+
ModalBuilder,
|
2672 |
+
RoleSelectMenuBuilder,
|
2673 |
+
StringSelectMenuBuilder as SelectMenuBuilder,
|
2674 |
+
StringSelectMenuOptionBuilder as SelectMenuOptionBuilder,
|
2675 |
+
SharedNameAndDescription,
|
2676 |
+
SharedSlashCommandOptions,
|
2677 |
+
Assertions_exports5 as SlashCommandAssertions,
|
2678 |
+
SlashCommandAttachmentOption,
|
2679 |
+
SlashCommandBooleanOption,
|
2680 |
+
SlashCommandBuilder,
|
2681 |
+
SlashCommandChannelOption,
|
2682 |
+
SlashCommandIntegerOption,
|
2683 |
+
SlashCommandMentionableOption,
|
2684 |
+
SlashCommandNumberOption,
|
2685 |
+
SlashCommandRoleOption,
|
2686 |
+
SlashCommandStringOption,
|
2687 |
+
SlashCommandSubcommandBuilder,
|
2688 |
+
SlashCommandSubcommandGroupBuilder,
|
2689 |
+
SlashCommandUserOption,
|
2690 |
+
StringSelectMenuBuilder,
|
2691 |
+
StringSelectMenuOptionBuilder,
|
2692 |
+
Assertions_exports3 as TextInputAssertions,
|
2693 |
+
TextInputBuilder,
|
2694 |
+
UserSelectMenuBuilder,
|
2695 |
+
createComponentBuilder,
|
2696 |
+
disableValidators,
|
2697 |
+
embedLength,
|
2698 |
+
enableValidators,
|
2699 |
+
isValidationEnabled,
|
2700 |
+
normalizeArray,
|
2701 |
+
version
|
2702 |
+
};
|
2703 |
+
//# sourceMappingURL=index.mjs.map
|
node_modules/@discordjs/builders/dist/index.mjs.map
ADDED
The diff for this file is too large to render.
See raw diff
|
|
node_modules/@discordjs/builders/package.json
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$schema": "https://json.schemastore.org/package.json",
|
3 |
+
"name": "@discordjs/builders",
|
4 |
+
"version": "1.7.0",
|
5 |
+
"description": "A set of builders that you can use when creating your bot",
|
6 |
+
"exports": {
|
7 |
+
".": {
|
8 |
+
"require": {
|
9 |
+
"types": "./dist/index.d.ts",
|
10 |
+
"default": "./dist/index.js"
|
11 |
+
},
|
12 |
+
"import": {
|
13 |
+
"types": "./dist/index.d.mts",
|
14 |
+
"default": "./dist/index.mjs"
|
15 |
+
}
|
16 |
+
}
|
17 |
+
},
|
18 |
+
"main": "./dist/index.js",
|
19 |
+
"module": "./dist/index.mjs",
|
20 |
+
"types": "./dist/index.d.ts",
|
21 |
+
"directories": {
|
22 |
+
"lib": "src",
|
23 |
+
"test": "__tests__"
|
24 |
+
},
|
25 |
+
"files": [
|
26 |
+
"dist"
|
27 |
+
],
|
28 |
+
"contributors": [
|
29 |
+
"Vlad Frangu <kingdgrizzle@gmail.com>",
|
30 |
+
"Crawl <icrawltogo@gmail.com>",
|
31 |
+
"Amish Shah <amishshah.2k@gmail.com>",
|
32 |
+
"SpaceEEC <spaceeec@yahoo.com>",
|
33 |
+
"Aura Román <kyradiscord@gmail.com>"
|
34 |
+
],
|
35 |
+
"license": "Apache-2.0",
|
36 |
+
"keywords": [
|
37 |
+
"discord",
|
38 |
+
"api",
|
39 |
+
"bot",
|
40 |
+
"client",
|
41 |
+
"node",
|
42 |
+
"discordapp",
|
43 |
+
"discordjs"
|
44 |
+
],
|
45 |
+
"repository": {
|
46 |
+
"type": "git",
|
47 |
+
"url": "https://github.com/discordjs/discord.js.git",
|
48 |
+
"directory": "packages/builders"
|
49 |
+
},
|
50 |
+
"bugs": {
|
51 |
+
"url": "https://github.com/discordjs/discord.js/issues"
|
52 |
+
},
|
53 |
+
"homepage": "https://discord.js.org",
|
54 |
+
"dependencies": {
|
55 |
+
"@sapphire/shapeshift": "^3.9.3",
|
56 |
+
"discord-api-types": "0.37.61",
|
57 |
+
"fast-deep-equal": "^3.1.3",
|
58 |
+
"ts-mixer": "^6.0.3",
|
59 |
+
"tslib": "^2.6.2",
|
60 |
+
"@discordjs/formatters": "^0.3.3",
|
61 |
+
"@discordjs/util": "^1.0.2"
|
62 |
+
},
|
63 |
+
"devDependencies": {
|
64 |
+
"@favware/cliff-jumper": "^2.2.1",
|
65 |
+
"@types/node": "16.18.60",
|
66 |
+
"@vitest/coverage-v8": "^0.34.6",
|
67 |
+
"cross-env": "^7.0.3",
|
68 |
+
"downlevel-dts": "^0.11.0",
|
69 |
+
"esbuild-plugin-version-injector": "^1.2.1",
|
70 |
+
"eslint": "^8.53.0",
|
71 |
+
"eslint-config-neon": "^0.1.57",
|
72 |
+
"eslint-formatter-pretty": "^5.0.0",
|
73 |
+
"prettier": "^3.0.3",
|
74 |
+
"tsup": "^7.2.0",
|
75 |
+
"turbo": "^1.10.17-canary.0",
|
76 |
+
"typescript": "^5.2.2",
|
77 |
+
"vitest": "^0.34.6",
|
78 |
+
"@discordjs/api-extractor": "^7.38.1"
|
79 |
+
},
|
80 |
+
"engines": {
|
81 |
+
"node": ">=16.11.0"
|
82 |
+
},
|
83 |
+
"publishConfig": {
|
84 |
+
"access": "public"
|
85 |
+
},
|
86 |
+
"scripts": {
|
87 |
+
"test": "vitest run",
|
88 |
+
"build": "tsc --noEmit && tsup",
|
89 |
+
"build:docs": "tsc -p tsconfig.docs.json && downlevel-dts ./dist-docs ./dist-docs",
|
90 |
+
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
91 |
+
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
92 |
+
"fmt": "pnpm run format",
|
93 |
+
"docs": "pnpm run build:docs && api-extractor run --local",
|
94 |
+
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/builders/*'",
|
95 |
+
"release": "cliff-jumper"
|
96 |
+
}
|
97 |
+
}
|
node_modules/@discordjs/collection/CHANGELOG.md
ADDED
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Changelog
|
2 |
+
|
3 |
+
All notable changes to this project will be documented in this file.
|
4 |
+
|
5 |
+
# [@discordjs/collection@1.5.3](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.5.2...@discordjs/collection@1.5.3) - (2023-08-17)
|
6 |
+
|
7 |
+
## Documentation
|
8 |
+
|
9 |
+
- Update Node.js requirement to 16.11.0 (#9764) ([188877c](https://github.com/discordjs/discord.js/commit/188877c50af70f0d5cffb246620fa277435c6ce6))
|
10 |
+
|
11 |
+
# [@discordjs/collection@1.5.2](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.5.1...@discordjs/collection@1.5.2) - (2023-07-31)
|
12 |
+
|
13 |
+
## Refactor
|
14 |
+
|
15 |
+
- **collection:** Reduce `reduce`'s code (#9581) ([b85a3f2](https://github.com/discordjs/discord.js/commit/b85a3f2ddee8fc5974749b95fc07389a03093df2))
|
16 |
+
|
17 |
+
# [@discordjs/collection@1.5.1](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.5.0...@discordjs/collection@1.5.1) - (2023-05-01)
|
18 |
+
|
19 |
+
## Bug Fixes
|
20 |
+
|
21 |
+
- Fix external links (#9313) ([a7425c2](https://github.com/discordjs/discord.js/commit/a7425c29c4f23f1b31f4c6a463107ca9eb7fd7e2))
|
22 |
+
|
23 |
+
## Documentation
|
24 |
+
|
25 |
+
- Generate static imports for types with api-extractor ([98a76db](https://github.com/discordjs/discord.js/commit/98a76db482879f79d6bb2fb2e5fc65ac2c34e2d9))
|
26 |
+
|
27 |
+
# [@discordjs/collection@1.5.2](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.5.1...@discordjs/collection@1.5.2) - (2023-07-31)
|
28 |
+
|
29 |
+
## Refactor
|
30 |
+
|
31 |
+
- **collection:** Reduce `reduce`'s code (#9581) ([b85a3f2](https://github.com/discordjs/discord.js/commit/b85a3f2ddee8fc5974749b95fc07389a03093df2))
|
32 |
+
|
33 |
+
# [@discordjs/collection@1.5.1](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.5.0...@discordjs/collection@1.5.1) - (2023-05-01)
|
34 |
+
|
35 |
+
## Bug Fixes
|
36 |
+
|
37 |
+
- Fix external links (#9313) ([a7425c2](https://github.com/discordjs/discord.js/commit/a7425c29c4f23f1b31f4c6a463107ca9eb7fd7e2))
|
38 |
+
|
39 |
+
## Documentation
|
40 |
+
|
41 |
+
- Generate static imports for types with api-extractor ([98a76db](https://github.com/discordjs/discord.js/commit/98a76db482879f79d6bb2fb2e5fc65ac2c34e2d9))
|
42 |
+
|
43 |
+
# [@discordjs/collection@1.5.1](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.5.0...@discordjs/collection@1.5.1) - (2023-05-01)
|
44 |
+
|
45 |
+
## Bug Fixes
|
46 |
+
|
47 |
+
- Fix external links (#9313) ([a7425c2](https://github.com/discordjs/discord.js/commit/a7425c29c4f23f1b31f4c6a463107ca9eb7fd7e2))
|
48 |
+
|
49 |
+
## Documentation
|
50 |
+
|
51 |
+
- Generate static imports for types with api-extractor ([98a76db](https://github.com/discordjs/discord.js/commit/98a76db482879f79d6bb2fb2e5fc65ac2c34e2d9))
|
52 |
+
|
53 |
+
# [@discordjs/collection@1.5.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.4.0...@discordjs/collection@1.5.0) - (2023-04-01)
|
54 |
+
|
55 |
+
## Bug Fixes
|
56 |
+
|
57 |
+
- **scripts:** Accessing tsComment ([d8d5f31](https://github.com/discordjs/discord.js/commit/d8d5f31d3927fd1de62f1fa3a1a6e454243ad87b))
|
58 |
+
|
59 |
+
## Features
|
60 |
+
|
61 |
+
- **website:** Render syntax and mdx on the server (#9086) ([ee5169e](https://github.com/discordjs/discord.js/commit/ee5169e0aadd7bbfcd752aae614ec0f69602b68b))
|
62 |
+
|
63 |
+
## Refactor
|
64 |
+
|
65 |
+
- **collection:** Fix/silence linter warnings (#9266) ([d6f4e60](https://github.com/discordjs/discord.js/commit/d6f4e60efd1a1796fc84dbbfbac4f9790e480a1c))
|
66 |
+
|
67 |
+
# [@discordjs/collection@1.4.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.3.0...@discordjs/collection@1.4.0) - (2023-03-12)
|
68 |
+
|
69 |
+
## Documentation
|
70 |
+
|
71 |
+
- Fix version export (#9049) ([8b70f49](https://github.com/discordjs/discord.js/commit/8b70f497a1207e30edebdecd12b926c981c13d28))
|
72 |
+
|
73 |
+
## Features
|
74 |
+
|
75 |
+
- **website:** Add support for source file links (#9048) ([f6506e9](https://github.com/discordjs/discord.js/commit/f6506e99c496683ee0ab67db0726b105b929af38))
|
76 |
+
|
77 |
+
## Refactor
|
78 |
+
|
79 |
+
- Compare with `undefined` directly (#9191) ([869153c](https://github.com/discordjs/discord.js/commit/869153c3fdf155783e7c0ecebd3627b087c3a026))
|
80 |
+
|
81 |
+
# [@discordjs/collection@1.3.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.2.0...@discordjs/collection@1.3.0) - (2022-11-28)
|
82 |
+
|
83 |
+
## Bug Fixes
|
84 |
+
|
85 |
+
- Pin @types/node version ([9d8179c](https://github.com/discordjs/discord.js/commit/9d8179c6a78e1c7f9976f852804055964d5385d4))
|
86 |
+
|
87 |
+
## Features
|
88 |
+
|
89 |
+
- Add `Collection#subtract()` (#8393) ([291f36c](https://github.com/discordjs/discord.js/commit/291f36cd736b5dea058145a1335bf7c78ec1d81d))
|
90 |
+
|
91 |
+
# [@discordjs/collection@1.2.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.1.0...@discordjs/collection@1.2.0) - (2022-10-08)
|
92 |
+
|
93 |
+
## Bug Fixes
|
94 |
+
|
95 |
+
- Footer / sidebar / deprecation alert ([ba3e0ed](https://github.com/discordjs/discord.js/commit/ba3e0ed348258fe8e51eefb4aa7379a1230616a9))
|
96 |
+
|
97 |
+
## Documentation
|
98 |
+
|
99 |
+
- Change name (#8604) ([dd5a089](https://github.com/discordjs/discord.js/commit/dd5a08944c258a847fc4377f1d5e953264ab47d0))
|
100 |
+
- Remove xml tag from collection#find (#8550) ([4032457](https://github.com/discordjs/discord.js/commit/40324574ebea9894cadcc967e0db0e4e21d62768))
|
101 |
+
|
102 |
+
## Features
|
103 |
+
|
104 |
+
- Web-components (#8715) ([0ac3e76](https://github.com/discordjs/discord.js/commit/0ac3e766bd9dbdeb106483fa4bb085d74de346a2))
|
105 |
+
|
106 |
+
## Refactor
|
107 |
+
|
108 |
+
- Website components (#8600) ([c334157](https://github.com/discordjs/discord.js/commit/c3341570d983aea9ecc419979d5a01de658c9d67))
|
109 |
+
- Use `eslint-config-neon` for packages. (#8579) ([edadb9f](https://github.com/discordjs/discord.js/commit/edadb9fe5dfd9ff51a3cfc9b25cb242d3f9f5241))
|
110 |
+
|
111 |
+
## Typings
|
112 |
+
|
113 |
+
- **Collection:** Make fn return type unknown (#8676) ([822b7f2](https://github.com/discordjs/discord.js/commit/822b7f234af053c8f917b0a998b82abfccd33801))
|
114 |
+
|
115 |
+
# [@discordjs/collection@1.1.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@1.0.1...@discordjs/collection@1.1.0) - (2022-08-22)
|
116 |
+
|
117 |
+
## Bug Fixes
|
118 |
+
|
119 |
+
- Use proper format for `@link` text (#8384) ([2655639](https://github.com/discordjs/discord.js/commit/26556390a3800e954974a00c1328ff47d3e67e9a))
|
120 |
+
|
121 |
+
## Documentation
|
122 |
+
|
123 |
+
- Fence examples in codeblocks ([193b252](https://github.com/discordjs/discord.js/commit/193b252672440a860318d3c2968aedd9cb88e0ce))
|
124 |
+
- Use link tags (#8382) ([5494791](https://github.com/discordjs/discord.js/commit/549479131318c659f86f0eb18578d597e22522d3))
|
125 |
+
|
126 |
+
## Features
|
127 |
+
|
128 |
+
- **website:** Show `constructor` information (#8540) ([e42fd16](https://github.com/discordjs/discord.js/commit/e42fd1636973b10dd7ed6fb4280ee1a4a8f82007))
|
129 |
+
- **website:** Show descriptions for `@typeParam` blocks (#8523) ([e475b63](https://github.com/discordjs/discord.js/commit/e475b63f257f6261d73cb89fee9ecbcdd84e2a6b))
|
130 |
+
|
131 |
+
## Refactor
|
132 |
+
|
133 |
+
- **website:** Adjust typography (#8503) ([0f83402](https://github.com/discordjs/discord.js/commit/0f834029850d2448981596cf082ff59917018d66))
|
134 |
+
- Docs design (#8487) ([4ab1d09](https://github.com/discordjs/discord.js/commit/4ab1d09997a18879a9eb9bda39df6f15aa22557e))
|
135 |
+
|
136 |
+
# [@discordjs/collection@0.8.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@0.7.0...@discordjs/collection@0.8.0) - (2022-07-17)
|
137 |
+
|
138 |
+
## Bug Fixes
|
139 |
+
|
140 |
+
- **Collection:** Make error messages consistent (#8224) ([5bd6b28](https://github.com/discordjs/discord.js/commit/5bd6b28b3ebfced1cb9d23e83bd7c0def7a12404))
|
141 |
+
- Check for function type (#8064) ([3bb9c0e](https://github.com/discordjs/discord.js/commit/3bb9c0e5c37311044ff41761b572ac4f91cda57c))
|
142 |
+
|
143 |
+
## Documentation
|
144 |
+
|
145 |
+
- Add codecov coverage badge to readmes (#8226) ([f6db285](https://github.com/discordjs/discord.js/commit/f6db285c073898a749fe4591cbd4463d1896daf5))
|
146 |
+
|
147 |
+
## Features
|
148 |
+
|
149 |
+
- Codecov (#8219) ([f10f4cd](https://github.com/discordjs/discord.js/commit/f10f4cdcd88ca6be7ec735ed3a415ba13da83db0))
|
150 |
+
- **docgen:** Update typedoc ([b3346f4](https://github.com/discordjs/discord.js/commit/b3346f4b9b3d4f96443506643d4631dc1c6d7b21))
|
151 |
+
- Website (#8043) ([127931d](https://github.com/discordjs/discord.js/commit/127931d1df7a2a5c27923c2f2151dbf3824e50cc))
|
152 |
+
- **docgen:** Typescript support ([3279b40](https://github.com/discordjs/discord.js/commit/3279b40912e6aa61507bedb7db15a2b8668de44b))
|
153 |
+
- Docgen package (#8029) ([8b979c0](https://github.com/discordjs/discord.js/commit/8b979c0245c42fd824d8e98745ee869f5360fc86))
|
154 |
+
- Use vitest instead of jest for more speed ([8d8e6c0](https://github.com/discordjs/discord.js/commit/8d8e6c03decd7352a2aa180f6e5bc1a13602539b))
|
155 |
+
- Add scripts package for locally used scripts ([f2ae1f9](https://github.com/discordjs/discord.js/commit/f2ae1f9348bfd893332a9060f71a8a5f272a1b8b))
|
156 |
+
|
157 |
+
## Refactor
|
158 |
+
|
159 |
+
- **collection:** Remove `default` property (#8055) ([c8f1690](https://github.com/discordjs/discord.js/commit/c8f1690896f55f06e05a83704262783cfc2bb91d))
|
160 |
+
- **collection:** Remove default export (#8053) ([16810f3](https://github.com/discordjs/discord.js/commit/16810f3e410bf35ed7e6e7412d517ea74c792c5d))
|
161 |
+
- Move all the config files to root (#8033) ([769ea0b](https://github.com/discordjs/discord.js/commit/769ea0bfe78c4f1d413c6b397c604ffe91e39c6a))
|
162 |
+
|
163 |
+
## Testing
|
164 |
+
|
165 |
+
- **collection:** Improve coverage (#8222) ([a51f721](https://github.com/discordjs/discord.js/commit/a51f7215eca67a0f46fba8b2d706f7ec6f6dc228))
|
166 |
+
|
167 |
+
# [@discordjs/collection@0.7.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@0.6.0...@discordjs/collection@0.7.0) - (2022-06-04)
|
168 |
+
|
169 |
+
## Styling
|
170 |
+
|
171 |
+
- Cleanup tests and tsup configs ([6b8ef20](https://github.com/discordjs/discord.js/commit/6b8ef20cb3af5b5cfd176dd0aa0a1a1e98551629))
|
172 |
+
|
173 |
+
# [@discordjs/collection@0.6.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@0.5.0...@discordjs/collection@0.6.0) - (2022-04-17)
|
174 |
+
|
175 |
+
## Features
|
176 |
+
|
177 |
+
- Add support for module: NodeNext in TS and ESM (#7598) ([8f1986a](https://github.com/discordjs/discord.js/commit/8f1986a6aa98365e09b00e84ad5f9f354ab61f3d))
|
178 |
+
- **builders:** Add attachment command option type (#7203) ([ae0f35f](https://github.com/discordjs/discord.js/commit/ae0f35f51d68dfa5a7dc43d161ef9365171debdb))
|
179 |
+
- **Collection:** Add merging functions (#7299) ([e4bd07b](https://github.com/discordjs/discord.js/commit/e4bd07b2394f227ea06b72eb6999de9ab3127b25))
|
180 |
+
|
181 |
+
# [@discordjs/collection@0.5.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@0.4.0...@discordjs/collection@0.5.0) - (2022-01-24)
|
182 |
+
|
183 |
+
## Refactor
|
184 |
+
|
185 |
+
- Make `intersect` perform a true intersection (#7211) ([d8efba2](https://github.com/discordjs/discord.js/commit/d8efba24e09aa2a8dbf028fc57a561a56e7833fd))
|
186 |
+
|
187 |
+
## Typings
|
188 |
+
|
189 |
+
- Add `ReadonlyCollection` (#7245) ([db25f52](https://github.com/discordjs/discord.js/commit/db25f529b26d7c819c1c42ad3e26c2263ea2da0e))
|
190 |
+
- **Collection:** Union types on `intersect` and `difference` (#7196) ([1f9b922](https://github.com/discordjs/discord.js/commit/1f9b9225f2066e9cc66c3355417139fd25cc403c))
|
node_modules/@discordjs/collection/LICENSE
ADDED
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Apache License
|
2 |
+
Version 2.0, January 2004
|
3 |
+
http://www.apache.org/licenses/
|
4 |
+
|
5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6 |
+
|
7 |
+
1. Definitions.
|
8 |
+
|
9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
11 |
+
|
12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13 |
+
the copyright owner that is granting the License.
|
14 |
+
|
15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
16 |
+
other entities that control, are controlled by, or are under common
|
17 |
+
control with that entity. For the purposes of this definition,
|
18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
19 |
+
direction or management of such entity, whether by contract or
|
20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22 |
+
|
23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24 |
+
exercising permissions granted by this License.
|
25 |
+
|
26 |
+
"Source" form shall mean the preferred form for making modifications,
|
27 |
+
including but not limited to software source code, documentation
|
28 |
+
source, and configuration files.
|
29 |
+
|
30 |
+
"Object" form shall mean any form resulting from mechanical
|
31 |
+
transformation or translation of a Source form, including but
|
32 |
+
not limited to compiled object code, generated documentation,
|
33 |
+
and conversions to other media types.
|
34 |
+
|
35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
36 |
+
Object form, made available under the License, as indicated by a
|
37 |
+
copyright notice that is included in or attached to the work
|
38 |
+
(an example is provided in the Appendix below).
|
39 |
+
|
40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41 |
+
form, that is based on (or derived from) the Work and for which the
|
42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
44 |
+
of this License, Derivative Works shall not include works that remain
|
45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46 |
+
the Work and Derivative Works thereof.
|
47 |
+
|
48 |
+
"Contribution" shall mean any work of authorship, including
|
49 |
+
the original version of the Work and any modifications or additions
|
50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
54 |
+
means any form of electronic, verbal, or written communication sent
|
55 |
+
to the Licensor or its representatives, including but not limited to
|
56 |
+
communication on electronic mailing lists, source code control systems,
|
57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
59 |
+
excluding communication that is conspicuously marked or otherwise
|
60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
61 |
+
|
62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
64 |
+
subsequently incorporated within the Work.
|
65 |
+
|
66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
71 |
+
Work and such Derivative Works in Source or Object form.
|
72 |
+
|
73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76 |
+
(except as stated in this section) patent license to make, have made,
|
77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78 |
+
where such license applies only to those patent claims licensable
|
79 |
+
by such Contributor that are necessarily infringed by their
|
80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
82 |
+
institute patent litigation against any entity (including a
|
83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84 |
+
or a Contribution incorporated within the Work constitutes direct
|
85 |
+
or contributory patent infringement, then any patent licenses
|
86 |
+
granted to You under this License for that Work shall terminate
|
87 |
+
as of the date such litigation is filed.
|
88 |
+
|
89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
90 |
+
Work or Derivative Works thereof in any medium, with or without
|
91 |
+
modifications, and in Source or Object form, provided that You
|
92 |
+
meet the following conditions:
|
93 |
+
|
94 |
+
(a) You must give any other recipients of the Work or
|
95 |
+
Derivative Works a copy of this License; and
|
96 |
+
|
97 |
+
(b) You must cause any modified files to carry prominent notices
|
98 |
+
stating that You changed the files; and
|
99 |
+
|
100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
101 |
+
that You distribute, all copyright, patent, trademark, and
|
102 |
+
attribution notices from the Source form of the Work,
|
103 |
+
excluding those notices that do not pertain to any part of
|
104 |
+
the Derivative Works; and
|
105 |
+
|
106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107 |
+
distribution, then any Derivative Works that You distribute must
|
108 |
+
include a readable copy of the attribution notices contained
|
109 |
+
within such NOTICE file, excluding those notices that do not
|
110 |
+
pertain to any part of the Derivative Works, in at least one
|
111 |
+
of the following places: within a NOTICE text file distributed
|
112 |
+
as part of the Derivative Works; within the Source form or
|
113 |
+
documentation, if provided along with the Derivative Works; or,
|
114 |
+
within a display generated by the Derivative Works, if and
|
115 |
+
wherever such third-party notices normally appear. The contents
|
116 |
+
of the NOTICE file are for informational purposes only and
|
117 |
+
do not modify the License. You may add Your own attribution
|
118 |
+
notices within Derivative Works that You distribute, alongside
|
119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
120 |
+
that such additional attribution notices cannot be construed
|
121 |
+
as modifying the License.
|
122 |
+
|
123 |
+
You may add Your own copyright statement to Your modifications and
|
124 |
+
may provide additional or different license terms and conditions
|
125 |
+
for use, reproduction, or distribution of Your modifications, or
|
126 |
+
for any such Derivative Works as a whole, provided Your use,
|
127 |
+
reproduction, and distribution of the Work otherwise complies with
|
128 |
+
the conditions stated in this License.
|
129 |
+
|
130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
132 |
+
by You to the Licensor shall be under the terms and conditions of
|
133 |
+
this License, without any additional terms or conditions.
|
134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135 |
+
the terms of any separate license agreement you may have executed
|
136 |
+
with Licensor regarding such Contributions.
|
137 |
+
|
138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
140 |
+
except as required for reasonable and customary use in describing the
|
141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
142 |
+
|
143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144 |
+
agreed to in writing, Licensor provides the Work (and each
|
145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147 |
+
implied, including, without limitation, any warranties or conditions
|
148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150 |
+
appropriateness of using or redistributing the Work and assume any
|
151 |
+
risks associated with Your exercise of permissions under this License.
|
152 |
+
|
153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
154 |
+
whether in tort (including negligence), contract, or otherwise,
|
155 |
+
unless required by applicable law (such as deliberate and grossly
|
156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157 |
+
liable to You for damages, including any direct, indirect, special,
|
158 |
+
incidental, or consequential damages of any character arising as a
|
159 |
+
result of this License or out of the use or inability to use the
|
160 |
+
Work (including but not limited to damages for loss of goodwill,
|
161 |
+
work stoppage, computer failure or malfunction, or any and all
|
162 |
+
other commercial damages or losses), even if such Contributor
|
163 |
+
has been advised of the possibility of such damages.
|
164 |
+
|
165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168 |
+
or other liability obligations and/or rights consistent with this
|
169 |
+
License. However, in accepting such obligations, You may act only
|
170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171 |
+
of any other Contributor, and only if You agree to indemnify,
|
172 |
+
defend, and hold each Contributor harmless for any liability
|
173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
174 |
+
of your accepting any such warranty or additional liability.
|
175 |
+
|
176 |
+
END OF TERMS AND CONDITIONS
|
177 |
+
|
178 |
+
Copyright 2021 Noel Buechler
|
179 |
+
Copyright 2015 Amish Shah
|
180 |
+
|
181 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
182 |
+
you may not use this file except in compliance with the License.
|
183 |
+
You may obtain a copy of the License at
|
184 |
+
|
185 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
186 |
+
|
187 |
+
Unless required by applicable law or agreed to in writing, software
|
188 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
189 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
190 |
+
See the License for the specific language governing permissions and
|
191 |
+
limitations under the License.
|
node_modules/@discordjs/collection/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div align="center">
|
2 |
+
<br />
|
3 |
+
<p>
|
4 |
+
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
|
5 |
+
</p>
|
6 |
+
<br />
|
7 |
+
<p>
|
8 |
+
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
|
9 |
+
<a href="https://www.npmjs.com/package/@discordjs/collection"><img src="https://img.shields.io/npm/v/@discordjs/collection.svg?maxAge=3600" alt="npm version" /></a>
|
10 |
+
<a href="https://www.npmjs.com/package/@discordjs/collection"><img src="https://img.shields.io/npm/dt/@discordjs/collection.svg?maxAge=3600" alt="npm downloads" /></a>
|
11 |
+
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
|
12 |
+
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=collection" alt="Code coverage" /></a>
|
13 |
+
</p>
|
14 |
+
<p>
|
15 |
+
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
16 |
+
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
|
17 |
+
</p>
|
18 |
+
</div>
|
19 |
+
|
20 |
+
## About
|
21 |
+
|
22 |
+
`@discordjs/collection` is a powerful utility data structure used in discord.js.
|
23 |
+
|
24 |
+
## Installation
|
25 |
+
|
26 |
+
**Node.js 16.11.0 or newer is required.**
|
27 |
+
|
28 |
+
```sh
|
29 |
+
npm install @discordjs/collection
|
30 |
+
yarn add @discordjs/collection
|
31 |
+
pnpm add @discordjs/collection
|
32 |
+
```
|
33 |
+
|
34 |
+
## Links
|
35 |
+
|
36 |
+
- [Website][website] ([source][website-source])
|
37 |
+
- [Documentation][documentation]
|
38 |
+
- [Guide][guide] ([source][guide-source])
|
39 |
+
Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
|
40 |
+
- [discord.js Discord server][discord]
|
41 |
+
- [Discord API Discord server][discord-api]
|
42 |
+
- [GitHub][source]
|
43 |
+
- [npm][npm]
|
44 |
+
- [Related libraries][related-libs]
|
45 |
+
|
46 |
+
## Contributing
|
47 |
+
|
48 |
+
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
|
49 |
+
[documentation][documentation].
|
50 |
+
See [the contribution guide][contributing] if you'd like to submit a PR.
|
51 |
+
|
52 |
+
## Help
|
53 |
+
|
54 |
+
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][discord].
|
55 |
+
|
56 |
+
[website]: https://discord.js.org
|
57 |
+
[website-source]: https://github.com/discordjs/discord.js/tree/main/apps/website
|
58 |
+
[documentation]: https://discord.js.org/docs/packages/collection/stable
|
59 |
+
[guide]: https://discordjs.guide/
|
60 |
+
[guide-source]: https://github.com/discordjs/guide
|
61 |
+
[guide-update]: https://discordjs.guide/additional-info/changes-in-v14.html
|
62 |
+
[discord]: https://discord.gg/djs
|
63 |
+
[discord-api]: https://discord.gg/discord-api
|
64 |
+
[source]: https://github.com/discordjs/discord.js/tree/main/packages/collection
|
65 |
+
[npm]: https://www.npmjs.com/package/@discordjs/collection
|
66 |
+
[related-libs]: https://discord.com/developers/docs/topics/community-resources#libraries
|
67 |
+
[contributing]: https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md
|
node_modules/@discordjs/collection/dist/index.d.mts
ADDED
@@ -0,0 +1,457 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @internal
|
3 |
+
*/
|
4 |
+
interface CollectionConstructor {
|
5 |
+
new (): Collection<unknown, unknown>;
|
6 |
+
new <K, V>(entries?: readonly (readonly [K, V])[] | null): Collection<K, V>;
|
7 |
+
new <K, V>(iterable: Iterable<readonly [K, V]>): Collection<K, V>;
|
8 |
+
readonly prototype: Collection<unknown, unknown>;
|
9 |
+
readonly [Symbol.species]: CollectionConstructor;
|
10 |
+
}
|
11 |
+
/**
|
12 |
+
* Represents an immutable version of a collection
|
13 |
+
*/
|
14 |
+
type ReadonlyCollection<K, V> = Omit<Collection<K, V>, 'delete' | 'ensure' | 'forEach' | 'get' | 'reverse' | 'set' | 'sort' | 'sweep'> & ReadonlyMap<K, V>;
|
15 |
+
/**
|
16 |
+
* Separate interface for the constructor so that emitted js does not have a constructor that overwrites itself
|
17 |
+
*
|
18 |
+
* @internal
|
19 |
+
*/
|
20 |
+
interface Collection<K, V> extends Map<K, V> {
|
21 |
+
constructor: CollectionConstructor;
|
22 |
+
}
|
23 |
+
/**
|
24 |
+
* A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has
|
25 |
+
* an ID, for significantly improved performance and ease-of-use.
|
26 |
+
*
|
27 |
+
* @typeParam K - The key type this collection holds
|
28 |
+
* @typeParam V - The value type this collection holds
|
29 |
+
*/
|
30 |
+
declare class Collection<K, V> extends Map<K, V> {
|
31 |
+
/**
|
32 |
+
* Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.
|
33 |
+
*
|
34 |
+
* @param key - The key to get if it exists, or set otherwise
|
35 |
+
* @param defaultValueGenerator - A function that generates the default value
|
36 |
+
* @example
|
37 |
+
* ```ts
|
38 |
+
* collection.ensure(guildId, () => defaultGuildConfig);
|
39 |
+
* ```
|
40 |
+
*/
|
41 |
+
ensure(key: K, defaultValueGenerator: (key: K, collection: this) => V): V;
|
42 |
+
/**
|
43 |
+
* Checks if all of the elements exist in the collection.
|
44 |
+
*
|
45 |
+
* @param keys - The keys of the elements to check for
|
46 |
+
* @returns `true` if all of the elements exist, `false` if at least one does not exist.
|
47 |
+
*/
|
48 |
+
hasAll(...keys: K[]): boolean;
|
49 |
+
/**
|
50 |
+
* Checks if any of the elements exist in the collection.
|
51 |
+
*
|
52 |
+
* @param keys - The keys of the elements to check for
|
53 |
+
* @returns `true` if any of the elements exist, `false` if none exist.
|
54 |
+
*/
|
55 |
+
hasAny(...keys: K[]): boolean;
|
56 |
+
/**
|
57 |
+
* Obtains the first value(s) in this collection.
|
58 |
+
*
|
59 |
+
* @param amount - Amount of values to obtain from the beginning
|
60 |
+
* @returns A single value if no amount is provided or an array of values, starting from the end if amount is negative
|
61 |
+
*/
|
62 |
+
first(): V | undefined;
|
63 |
+
first(amount: number): V[];
|
64 |
+
/**
|
65 |
+
* Obtains the first key(s) in this collection.
|
66 |
+
*
|
67 |
+
* @param amount - Amount of keys to obtain from the beginning
|
68 |
+
* @returns A single key if no amount is provided or an array of keys, starting from the end if
|
69 |
+
* amount is negative
|
70 |
+
*/
|
71 |
+
firstKey(): K | undefined;
|
72 |
+
firstKey(amount: number): K[];
|
73 |
+
/**
|
74 |
+
* Obtains the last value(s) in this collection.
|
75 |
+
*
|
76 |
+
* @param amount - Amount of values to obtain from the end
|
77 |
+
* @returns A single value if no amount is provided or an array of values, starting from the start if
|
78 |
+
* amount is negative
|
79 |
+
*/
|
80 |
+
last(): V | undefined;
|
81 |
+
last(amount: number): V[];
|
82 |
+
/**
|
83 |
+
* Obtains the last key(s) in this collection.
|
84 |
+
*
|
85 |
+
* @param amount - Amount of keys to obtain from the end
|
86 |
+
* @returns A single key if no amount is provided or an array of keys, starting from the start if
|
87 |
+
* amount is negative
|
88 |
+
*/
|
89 |
+
lastKey(): K | undefined;
|
90 |
+
lastKey(amount: number): K[];
|
91 |
+
/**
|
92 |
+
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
93 |
+
* Returns the item at a given index, allowing for positive and negative integers.
|
94 |
+
* Negative integers count back from the last item in the collection.
|
95 |
+
*
|
96 |
+
* @param index - The index of the element to obtain
|
97 |
+
*/
|
98 |
+
at(index: number): V | undefined;
|
99 |
+
/**
|
100 |
+
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
101 |
+
* Returns the key at a given index, allowing for positive and negative integers.
|
102 |
+
* Negative integers count back from the last item in the collection.
|
103 |
+
*
|
104 |
+
* @param index - The index of the key to obtain
|
105 |
+
*/
|
106 |
+
keyAt(index: number): K | undefined;
|
107 |
+
/**
|
108 |
+
* Obtains unique random value(s) from this collection.
|
109 |
+
*
|
110 |
+
* @param amount - Amount of values to obtain randomly
|
111 |
+
* @returns A single value if no amount is provided or an array of values
|
112 |
+
*/
|
113 |
+
random(): V | undefined;
|
114 |
+
random(amount: number): V[];
|
115 |
+
/**
|
116 |
+
* Obtains unique random key(s) from this collection.
|
117 |
+
*
|
118 |
+
* @param amount - Amount of keys to obtain randomly
|
119 |
+
* @returns A single key if no amount is provided or an array
|
120 |
+
*/
|
121 |
+
randomKey(): K | undefined;
|
122 |
+
randomKey(amount: number): K[];
|
123 |
+
/**
|
124 |
+
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}
|
125 |
+
* but returns a Collection instead of an Array.
|
126 |
+
*/
|
127 |
+
reverse(): this;
|
128 |
+
/**
|
129 |
+
* Searches for a single item where the given function returns a truthy value. This behaves like
|
130 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find | Array.find()}.
|
131 |
+
* All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you
|
132 |
+
* should use the `get` method. See
|
133 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get | MDN} for details.
|
134 |
+
*
|
135 |
+
* @param fn - The function to test with (should return boolean)
|
136 |
+
* @param thisArg - Value to use as `this` when executing function
|
137 |
+
* @example
|
138 |
+
* ```ts
|
139 |
+
* collection.find(user => user.username === 'Bob');
|
140 |
+
* ```
|
141 |
+
*/
|
142 |
+
find<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): V2 | undefined;
|
143 |
+
find(fn: (value: V, key: K, collection: this) => unknown): V | undefined;
|
144 |
+
find<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): V2 | undefined;
|
145 |
+
find<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): V | undefined;
|
146 |
+
/**
|
147 |
+
* Searches for the key of a single item where the given function returns a truthy value. This behaves like
|
148 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex | Array.findIndex()},
|
149 |
+
* but returns the key rather than the positional index.
|
150 |
+
*
|
151 |
+
* @param fn - The function to test with (should return boolean)
|
152 |
+
* @param thisArg - Value to use as `this` when executing function
|
153 |
+
* @example
|
154 |
+
* ```ts
|
155 |
+
* collection.findKey(user => user.username === 'Bob');
|
156 |
+
* ```
|
157 |
+
*/
|
158 |
+
findKey<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): K2 | undefined;
|
159 |
+
findKey(fn: (value: V, key: K, collection: this) => unknown): K | undefined;
|
160 |
+
findKey<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): K2 | undefined;
|
161 |
+
findKey<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): K | undefined;
|
162 |
+
/**
|
163 |
+
* Removes items that satisfy the provided filter function.
|
164 |
+
*
|
165 |
+
* @param fn - Function used to test (should return a boolean)
|
166 |
+
* @param thisArg - Value to use as `this` when executing function
|
167 |
+
* @returns The number of removed entries
|
168 |
+
*/
|
169 |
+
sweep(fn: (value: V, key: K, collection: this) => unknown): number;
|
170 |
+
sweep<T>(fn: (this: T, value: V, key: K, collection: this) => unknown, thisArg: T): number;
|
171 |
+
/**
|
172 |
+
* Identical to
|
173 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter | Array.filter()},
|
174 |
+
* but returns a Collection instead of an Array.
|
175 |
+
*
|
176 |
+
* @param fn - The function to test with (should return boolean)
|
177 |
+
* @param thisArg - Value to use as `this` when executing function
|
178 |
+
* @example
|
179 |
+
* ```ts
|
180 |
+
* collection.filter(user => user.username === 'Bob');
|
181 |
+
* ```
|
182 |
+
*/
|
183 |
+
filter<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): Collection<K2, V>;
|
184 |
+
filter<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): Collection<K, V2>;
|
185 |
+
filter(fn: (value: V, key: K, collection: this) => unknown): Collection<K, V>;
|
186 |
+
filter<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): Collection<K2, V>;
|
187 |
+
filter<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): Collection<K, V2>;
|
188 |
+
filter<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): Collection<K, V>;
|
189 |
+
/**
|
190 |
+
* Partitions the collection into two collections where the first collection
|
191 |
+
* contains the items that passed and the second contains the items that failed.
|
192 |
+
*
|
193 |
+
* @param fn - Function used to test (should return a boolean)
|
194 |
+
* @param thisArg - Value to use as `this` when executing function
|
195 |
+
* @example
|
196 |
+
* ```ts
|
197 |
+
* const [big, small] = collection.partition(guild => guild.memberCount > 250);
|
198 |
+
* ```
|
199 |
+
*/
|
200 |
+
partition<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): [Collection<K2, V>, Collection<Exclude<K, K2>, V>];
|
201 |
+
partition<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): [Collection<K, V2>, Collection<K, Exclude<V, V2>>];
|
202 |
+
partition(fn: (value: V, key: K, collection: this) => unknown): [Collection<K, V>, Collection<K, V>];
|
203 |
+
partition<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): [Collection<K2, V>, Collection<Exclude<K, K2>, V>];
|
204 |
+
partition<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): [Collection<K, V2>, Collection<K, Exclude<V, V2>>];
|
205 |
+
partition<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): [Collection<K, V>, Collection<K, V>];
|
206 |
+
/**
|
207 |
+
* Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to
|
208 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | Array.flatMap()}.
|
209 |
+
*
|
210 |
+
* @param fn - Function that produces a new Collection
|
211 |
+
* @param thisArg - Value to use as `this` when executing function
|
212 |
+
* @example
|
213 |
+
* ```ts
|
214 |
+
* collection.flatMap(guild => guild.members.cache);
|
215 |
+
* ```
|
216 |
+
*/
|
217 |
+
flatMap<T>(fn: (value: V, key: K, collection: this) => Collection<K, T>): Collection<K, T>;
|
218 |
+
flatMap<T, This>(fn: (this: This, value: V, key: K, collection: this) => Collection<K, T>, thisArg: This): Collection<K, T>;
|
219 |
+
/**
|
220 |
+
* Maps each item to another value into an array. Identical in behavior to
|
221 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.
|
222 |
+
*
|
223 |
+
* @param fn - Function that produces an element of the new array, taking three arguments
|
224 |
+
* @param thisArg - Value to use as `this` when executing function
|
225 |
+
* @example
|
226 |
+
* ```ts
|
227 |
+
* collection.map(user => user.tag);
|
228 |
+
* ```
|
229 |
+
*/
|
230 |
+
map<T>(fn: (value: V, key: K, collection: this) => T): T[];
|
231 |
+
map<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): T[];
|
232 |
+
/**
|
233 |
+
* Maps each item to another value into a collection. Identical in behavior to
|
234 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.
|
235 |
+
*
|
236 |
+
* @param fn - Function that produces an element of the new collection, taking three arguments
|
237 |
+
* @param thisArg - Value to use as `this` when executing function
|
238 |
+
* @example
|
239 |
+
* ```ts
|
240 |
+
* collection.mapValues(user => user.tag);
|
241 |
+
* ```
|
242 |
+
*/
|
243 |
+
mapValues<T>(fn: (value: V, key: K, collection: this) => T): Collection<K, T>;
|
244 |
+
mapValues<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): Collection<K, T>;
|
245 |
+
/**
|
246 |
+
* Checks if there exists an item that passes a test. Identical in behavior to
|
247 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some | Array.some()}.
|
248 |
+
*
|
249 |
+
* @param fn - Function used to test (should return a boolean)
|
250 |
+
* @param thisArg - Value to use as `this` when executing function
|
251 |
+
* @example
|
252 |
+
* ```ts
|
253 |
+
* collection.some(user => user.discriminator === '0000');
|
254 |
+
* ```
|
255 |
+
*/
|
256 |
+
some(fn: (value: V, key: K, collection: this) => unknown): boolean;
|
257 |
+
some<T>(fn: (this: T, value: V, key: K, collection: this) => unknown, thisArg: T): boolean;
|
258 |
+
/**
|
259 |
+
* Checks if all items passes a test. Identical in behavior to
|
260 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every | Array.every()}.
|
261 |
+
*
|
262 |
+
* @param fn - Function used to test (should return a boolean)
|
263 |
+
* @param thisArg - Value to use as `this` when executing function
|
264 |
+
* @example
|
265 |
+
* ```ts
|
266 |
+
* collection.every(user => !user.bot);
|
267 |
+
* ```
|
268 |
+
*/
|
269 |
+
every<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): this is Collection<K2, V>;
|
270 |
+
every<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): this is Collection<K, V2>;
|
271 |
+
every(fn: (value: V, key: K, collection: this) => unknown): boolean;
|
272 |
+
every<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): this is Collection<K2, V>;
|
273 |
+
every<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): this is Collection<K, V2>;
|
274 |
+
every<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): boolean;
|
275 |
+
/**
|
276 |
+
* Applies a function to produce a single value. Identical in behavior to
|
277 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.
|
278 |
+
*
|
279 |
+
* @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
|
280 |
+
* and `collection`
|
281 |
+
* @param initialValue - Starting value for the accumulator
|
282 |
+
* @example
|
283 |
+
* ```ts
|
284 |
+
* collection.reduce((acc, guild) => acc + guild.memberCount, 0);
|
285 |
+
* ```
|
286 |
+
*/
|
287 |
+
reduce<T = V>(fn: (accumulator: T, value: V, key: K, collection: this) => T, initialValue?: T): T;
|
288 |
+
/**
|
289 |
+
* Identical to
|
290 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach | Map.forEach()},
|
291 |
+
* but returns the collection instead of undefined.
|
292 |
+
*
|
293 |
+
* @param fn - Function to execute for each element
|
294 |
+
* @param thisArg - Value to use as `this` when executing function
|
295 |
+
* @example
|
296 |
+
* ```ts
|
297 |
+
* collection
|
298 |
+
* .each(user => console.log(user.username))
|
299 |
+
* .filter(user => user.bot)
|
300 |
+
* .each(user => console.log(user.username));
|
301 |
+
* ```
|
302 |
+
*/
|
303 |
+
each(fn: (value: V, key: K, collection: this) => void): this;
|
304 |
+
each<T>(fn: (this: T, value: V, key: K, collection: this) => void, thisArg: T): this;
|
305 |
+
/**
|
306 |
+
* Runs a function on the collection and returns the collection.
|
307 |
+
*
|
308 |
+
* @param fn - Function to execute
|
309 |
+
* @param thisArg - Value to use as `this` when executing function
|
310 |
+
* @example
|
311 |
+
* ```ts
|
312 |
+
* collection
|
313 |
+
* .tap(coll => console.log(coll.size))
|
314 |
+
* .filter(user => user.bot)
|
315 |
+
* .tap(coll => console.log(coll.size))
|
316 |
+
* ```
|
317 |
+
*/
|
318 |
+
tap(fn: (collection: this) => void): this;
|
319 |
+
tap<T>(fn: (this: T, collection: this) => void, thisArg: T): this;
|
320 |
+
/**
|
321 |
+
* Creates an identical shallow copy of this collection.
|
322 |
+
*
|
323 |
+
* @example
|
324 |
+
* ```ts
|
325 |
+
* const newColl = someColl.clone();
|
326 |
+
* ```
|
327 |
+
*/
|
328 |
+
clone(): Collection<K, V>;
|
329 |
+
/**
|
330 |
+
* Combines this collection with others into a new collection. None of the source collections are modified.
|
331 |
+
*
|
332 |
+
* @param collections - Collections to merge
|
333 |
+
* @example
|
334 |
+
* ```ts
|
335 |
+
* const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
|
336 |
+
* ```
|
337 |
+
*/
|
338 |
+
concat(...collections: ReadonlyCollection<K, V>[]): Collection<K, V>;
|
339 |
+
/**
|
340 |
+
* Checks if this collection shares identical items with another.
|
341 |
+
* This is different to checking for equality using equal-signs, because
|
342 |
+
* the collections may be different objects, but contain the same data.
|
343 |
+
*
|
344 |
+
* @param collection - Collection to compare with
|
345 |
+
* @returns Whether the collections have identical contents
|
346 |
+
*/
|
347 |
+
equals(collection: ReadonlyCollection<K, V>): boolean;
|
348 |
+
/**
|
349 |
+
* The sort method sorts the items of a collection in place and returns it.
|
350 |
+
* The sort is not necessarily stable in Node 10 or older.
|
351 |
+
* The default sort order is according to string Unicode code points.
|
352 |
+
*
|
353 |
+
* @param compareFunction - Specifies a function that defines the sort order.
|
354 |
+
* If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element.
|
355 |
+
* @example
|
356 |
+
* ```ts
|
357 |
+
* collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
358 |
+
* ```
|
359 |
+
*/
|
360 |
+
sort(compareFunction?: Comparator<K, V>): this;
|
361 |
+
/**
|
362 |
+
* The intersect method returns a new structure containing items where the keys and values are present in both original structures.
|
363 |
+
*
|
364 |
+
* @param other - The other Collection to filter against
|
365 |
+
*/
|
366 |
+
intersect<T>(other: ReadonlyCollection<K, T>): Collection<K, T>;
|
367 |
+
/**
|
368 |
+
* The subtract method returns a new structure containing items where the keys and values of the original structure are not present in the other.
|
369 |
+
*
|
370 |
+
* @param other - The other Collection to filter against
|
371 |
+
*/
|
372 |
+
subtract<T>(other: ReadonlyCollection<K, T>): Collection<K, V>;
|
373 |
+
/**
|
374 |
+
* The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.
|
375 |
+
*
|
376 |
+
* @param other - The other Collection to filter against
|
377 |
+
*/
|
378 |
+
difference<T>(other: ReadonlyCollection<K, T>): Collection<K, T | V>;
|
379 |
+
/**
|
380 |
+
* Merges two Collections together into a new Collection.
|
381 |
+
*
|
382 |
+
* @param other - The other Collection to merge with
|
383 |
+
* @param whenInSelf - Function getting the result if the entry only exists in this Collection
|
384 |
+
* @param whenInOther - Function getting the result if the entry only exists in the other Collection
|
385 |
+
* @param whenInBoth - Function getting the result if the entry exists in both Collections
|
386 |
+
* @example
|
387 |
+
* ```ts
|
388 |
+
* // Sums up the entries in two collections.
|
389 |
+
* coll.merge(
|
390 |
+
* other,
|
391 |
+
* x => ({ keep: true, value: x }),
|
392 |
+
* y => ({ keep: true, value: y }),
|
393 |
+
* (x, y) => ({ keep: true, value: x + y }),
|
394 |
+
* );
|
395 |
+
* ```
|
396 |
+
* @example
|
397 |
+
* ```ts
|
398 |
+
* // Intersects two collections in a left-biased manner.
|
399 |
+
* coll.merge(
|
400 |
+
* other,
|
401 |
+
* x => ({ keep: false }),
|
402 |
+
* y => ({ keep: false }),
|
403 |
+
* (x, _) => ({ keep: true, value: x }),
|
404 |
+
* );
|
405 |
+
* ```
|
406 |
+
*/
|
407 |
+
merge<T, R>(other: ReadonlyCollection<K, T>, whenInSelf: (value: V, key: K) => Keep<R>, whenInOther: (valueOther: T, key: K) => Keep<R>, whenInBoth: (value: V, valueOther: T, key: K) => Keep<R>): Collection<K, R>;
|
408 |
+
/**
|
409 |
+
* The sorted method sorts the items of a collection and returns it.
|
410 |
+
* The sort is not necessarily stable in Node 10 or older.
|
411 |
+
* The default sort order is according to string Unicode code points.
|
412 |
+
*
|
413 |
+
* @param compareFunction - Specifies a function that defines the sort order.
|
414 |
+
* If omitted, the collection is sorted according to each character's Unicode code point value,
|
415 |
+
* according to the string conversion of each element.
|
416 |
+
* @example
|
417 |
+
* ```ts
|
418 |
+
* collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
419 |
+
* ```
|
420 |
+
*/
|
421 |
+
sorted(compareFunction?: Comparator<K, V>): Collection<K, V>;
|
422 |
+
toJSON(): V[];
|
423 |
+
private static defaultSort;
|
424 |
+
/**
|
425 |
+
* Creates a Collection from a list of entries.
|
426 |
+
*
|
427 |
+
* @param entries - The list of entries
|
428 |
+
* @param combine - Function to combine an existing entry with a new one
|
429 |
+
* @example
|
430 |
+
* ```ts
|
431 |
+
* Collection.combineEntries([["a", 1], ["b", 2], ["a", 2]], (x, y) => x + y);
|
432 |
+
* // returns Collection { "a" => 3, "b" => 2 }
|
433 |
+
* ```
|
434 |
+
*/
|
435 |
+
static combineEntries<K, V>(entries: Iterable<[K, V]>, combine: (firstValue: V, secondValue: V, key: K) => V): Collection<K, V>;
|
436 |
+
}
|
437 |
+
/**
|
438 |
+
* @internal
|
439 |
+
*/
|
440 |
+
type Keep<V> = {
|
441 |
+
keep: false;
|
442 |
+
} | {
|
443 |
+
keep: true;
|
444 |
+
value: V;
|
445 |
+
};
|
446 |
+
/**
|
447 |
+
* @internal
|
448 |
+
*/
|
449 |
+
type Comparator<K, V> = (firstValue: V, secondValue: V, firstKey: K, secondKey: K) => number;
|
450 |
+
|
451 |
+
/**
|
452 |
+
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/collection/#readme | @discordjs/collection} version
|
453 |
+
* that you are currently using.
|
454 |
+
*/
|
455 |
+
declare const version: string;
|
456 |
+
|
457 |
+
export { Collection, CollectionConstructor, Comparator, Keep, ReadonlyCollection, version };
|
node_modules/@discordjs/collection/dist/index.d.ts
ADDED
@@ -0,0 +1,457 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @internal
|
3 |
+
*/
|
4 |
+
interface CollectionConstructor {
|
5 |
+
new (): Collection<unknown, unknown>;
|
6 |
+
new <K, V>(entries?: readonly (readonly [K, V])[] | null): Collection<K, V>;
|
7 |
+
new <K, V>(iterable: Iterable<readonly [K, V]>): Collection<K, V>;
|
8 |
+
readonly prototype: Collection<unknown, unknown>;
|
9 |
+
readonly [Symbol.species]: CollectionConstructor;
|
10 |
+
}
|
11 |
+
/**
|
12 |
+
* Represents an immutable version of a collection
|
13 |
+
*/
|
14 |
+
type ReadonlyCollection<K, V> = Omit<Collection<K, V>, 'delete' | 'ensure' | 'forEach' | 'get' | 'reverse' | 'set' | 'sort' | 'sweep'> & ReadonlyMap<K, V>;
|
15 |
+
/**
|
16 |
+
* Separate interface for the constructor so that emitted js does not have a constructor that overwrites itself
|
17 |
+
*
|
18 |
+
* @internal
|
19 |
+
*/
|
20 |
+
interface Collection<K, V> extends Map<K, V> {
|
21 |
+
constructor: CollectionConstructor;
|
22 |
+
}
|
23 |
+
/**
|
24 |
+
* A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has
|
25 |
+
* an ID, for significantly improved performance and ease-of-use.
|
26 |
+
*
|
27 |
+
* @typeParam K - The key type this collection holds
|
28 |
+
* @typeParam V - The value type this collection holds
|
29 |
+
*/
|
30 |
+
declare class Collection<K, V> extends Map<K, V> {
|
31 |
+
/**
|
32 |
+
* Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.
|
33 |
+
*
|
34 |
+
* @param key - The key to get if it exists, or set otherwise
|
35 |
+
* @param defaultValueGenerator - A function that generates the default value
|
36 |
+
* @example
|
37 |
+
* ```ts
|
38 |
+
* collection.ensure(guildId, () => defaultGuildConfig);
|
39 |
+
* ```
|
40 |
+
*/
|
41 |
+
ensure(key: K, defaultValueGenerator: (key: K, collection: this) => V): V;
|
42 |
+
/**
|
43 |
+
* Checks if all of the elements exist in the collection.
|
44 |
+
*
|
45 |
+
* @param keys - The keys of the elements to check for
|
46 |
+
* @returns `true` if all of the elements exist, `false` if at least one does not exist.
|
47 |
+
*/
|
48 |
+
hasAll(...keys: K[]): boolean;
|
49 |
+
/**
|
50 |
+
* Checks if any of the elements exist in the collection.
|
51 |
+
*
|
52 |
+
* @param keys - The keys of the elements to check for
|
53 |
+
* @returns `true` if any of the elements exist, `false` if none exist.
|
54 |
+
*/
|
55 |
+
hasAny(...keys: K[]): boolean;
|
56 |
+
/**
|
57 |
+
* Obtains the first value(s) in this collection.
|
58 |
+
*
|
59 |
+
* @param amount - Amount of values to obtain from the beginning
|
60 |
+
* @returns A single value if no amount is provided or an array of values, starting from the end if amount is negative
|
61 |
+
*/
|
62 |
+
first(): V | undefined;
|
63 |
+
first(amount: number): V[];
|
64 |
+
/**
|
65 |
+
* Obtains the first key(s) in this collection.
|
66 |
+
*
|
67 |
+
* @param amount - Amount of keys to obtain from the beginning
|
68 |
+
* @returns A single key if no amount is provided or an array of keys, starting from the end if
|
69 |
+
* amount is negative
|
70 |
+
*/
|
71 |
+
firstKey(): K | undefined;
|
72 |
+
firstKey(amount: number): K[];
|
73 |
+
/**
|
74 |
+
* Obtains the last value(s) in this collection.
|
75 |
+
*
|
76 |
+
* @param amount - Amount of values to obtain from the end
|
77 |
+
* @returns A single value if no amount is provided or an array of values, starting from the start if
|
78 |
+
* amount is negative
|
79 |
+
*/
|
80 |
+
last(): V | undefined;
|
81 |
+
last(amount: number): V[];
|
82 |
+
/**
|
83 |
+
* Obtains the last key(s) in this collection.
|
84 |
+
*
|
85 |
+
* @param amount - Amount of keys to obtain from the end
|
86 |
+
* @returns A single key if no amount is provided or an array of keys, starting from the start if
|
87 |
+
* amount is negative
|
88 |
+
*/
|
89 |
+
lastKey(): K | undefined;
|
90 |
+
lastKey(amount: number): K[];
|
91 |
+
/**
|
92 |
+
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
93 |
+
* Returns the item at a given index, allowing for positive and negative integers.
|
94 |
+
* Negative integers count back from the last item in the collection.
|
95 |
+
*
|
96 |
+
* @param index - The index of the element to obtain
|
97 |
+
*/
|
98 |
+
at(index: number): V | undefined;
|
99 |
+
/**
|
100 |
+
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
101 |
+
* Returns the key at a given index, allowing for positive and negative integers.
|
102 |
+
* Negative integers count back from the last item in the collection.
|
103 |
+
*
|
104 |
+
* @param index - The index of the key to obtain
|
105 |
+
*/
|
106 |
+
keyAt(index: number): K | undefined;
|
107 |
+
/**
|
108 |
+
* Obtains unique random value(s) from this collection.
|
109 |
+
*
|
110 |
+
* @param amount - Amount of values to obtain randomly
|
111 |
+
* @returns A single value if no amount is provided or an array of values
|
112 |
+
*/
|
113 |
+
random(): V | undefined;
|
114 |
+
random(amount: number): V[];
|
115 |
+
/**
|
116 |
+
* Obtains unique random key(s) from this collection.
|
117 |
+
*
|
118 |
+
* @param amount - Amount of keys to obtain randomly
|
119 |
+
* @returns A single key if no amount is provided or an array
|
120 |
+
*/
|
121 |
+
randomKey(): K | undefined;
|
122 |
+
randomKey(amount: number): K[];
|
123 |
+
/**
|
124 |
+
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}
|
125 |
+
* but returns a Collection instead of an Array.
|
126 |
+
*/
|
127 |
+
reverse(): this;
|
128 |
+
/**
|
129 |
+
* Searches for a single item where the given function returns a truthy value. This behaves like
|
130 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find | Array.find()}.
|
131 |
+
* All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you
|
132 |
+
* should use the `get` method. See
|
133 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get | MDN} for details.
|
134 |
+
*
|
135 |
+
* @param fn - The function to test with (should return boolean)
|
136 |
+
* @param thisArg - Value to use as `this` when executing function
|
137 |
+
* @example
|
138 |
+
* ```ts
|
139 |
+
* collection.find(user => user.username === 'Bob');
|
140 |
+
* ```
|
141 |
+
*/
|
142 |
+
find<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): V2 | undefined;
|
143 |
+
find(fn: (value: V, key: K, collection: this) => unknown): V | undefined;
|
144 |
+
find<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): V2 | undefined;
|
145 |
+
find<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): V | undefined;
|
146 |
+
/**
|
147 |
+
* Searches for the key of a single item where the given function returns a truthy value. This behaves like
|
148 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex | Array.findIndex()},
|
149 |
+
* but returns the key rather than the positional index.
|
150 |
+
*
|
151 |
+
* @param fn - The function to test with (should return boolean)
|
152 |
+
* @param thisArg - Value to use as `this` when executing function
|
153 |
+
* @example
|
154 |
+
* ```ts
|
155 |
+
* collection.findKey(user => user.username === 'Bob');
|
156 |
+
* ```
|
157 |
+
*/
|
158 |
+
findKey<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): K2 | undefined;
|
159 |
+
findKey(fn: (value: V, key: K, collection: this) => unknown): K | undefined;
|
160 |
+
findKey<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): K2 | undefined;
|
161 |
+
findKey<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): K | undefined;
|
162 |
+
/**
|
163 |
+
* Removes items that satisfy the provided filter function.
|
164 |
+
*
|
165 |
+
* @param fn - Function used to test (should return a boolean)
|
166 |
+
* @param thisArg - Value to use as `this` when executing function
|
167 |
+
* @returns The number of removed entries
|
168 |
+
*/
|
169 |
+
sweep(fn: (value: V, key: K, collection: this) => unknown): number;
|
170 |
+
sweep<T>(fn: (this: T, value: V, key: K, collection: this) => unknown, thisArg: T): number;
|
171 |
+
/**
|
172 |
+
* Identical to
|
173 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter | Array.filter()},
|
174 |
+
* but returns a Collection instead of an Array.
|
175 |
+
*
|
176 |
+
* @param fn - The function to test with (should return boolean)
|
177 |
+
* @param thisArg - Value to use as `this` when executing function
|
178 |
+
* @example
|
179 |
+
* ```ts
|
180 |
+
* collection.filter(user => user.username === 'Bob');
|
181 |
+
* ```
|
182 |
+
*/
|
183 |
+
filter<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): Collection<K2, V>;
|
184 |
+
filter<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): Collection<K, V2>;
|
185 |
+
filter(fn: (value: V, key: K, collection: this) => unknown): Collection<K, V>;
|
186 |
+
filter<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): Collection<K2, V>;
|
187 |
+
filter<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): Collection<K, V2>;
|
188 |
+
filter<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): Collection<K, V>;
|
189 |
+
/**
|
190 |
+
* Partitions the collection into two collections where the first collection
|
191 |
+
* contains the items that passed and the second contains the items that failed.
|
192 |
+
*
|
193 |
+
* @param fn - Function used to test (should return a boolean)
|
194 |
+
* @param thisArg - Value to use as `this` when executing function
|
195 |
+
* @example
|
196 |
+
* ```ts
|
197 |
+
* const [big, small] = collection.partition(guild => guild.memberCount > 250);
|
198 |
+
* ```
|
199 |
+
*/
|
200 |
+
partition<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): [Collection<K2, V>, Collection<Exclude<K, K2>, V>];
|
201 |
+
partition<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): [Collection<K, V2>, Collection<K, Exclude<V, V2>>];
|
202 |
+
partition(fn: (value: V, key: K, collection: this) => unknown): [Collection<K, V>, Collection<K, V>];
|
203 |
+
partition<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): [Collection<K2, V>, Collection<Exclude<K, K2>, V>];
|
204 |
+
partition<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): [Collection<K, V2>, Collection<K, Exclude<V, V2>>];
|
205 |
+
partition<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): [Collection<K, V>, Collection<K, V>];
|
206 |
+
/**
|
207 |
+
* Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to
|
208 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | Array.flatMap()}.
|
209 |
+
*
|
210 |
+
* @param fn - Function that produces a new Collection
|
211 |
+
* @param thisArg - Value to use as `this` when executing function
|
212 |
+
* @example
|
213 |
+
* ```ts
|
214 |
+
* collection.flatMap(guild => guild.members.cache);
|
215 |
+
* ```
|
216 |
+
*/
|
217 |
+
flatMap<T>(fn: (value: V, key: K, collection: this) => Collection<K, T>): Collection<K, T>;
|
218 |
+
flatMap<T, This>(fn: (this: This, value: V, key: K, collection: this) => Collection<K, T>, thisArg: This): Collection<K, T>;
|
219 |
+
/**
|
220 |
+
* Maps each item to another value into an array. Identical in behavior to
|
221 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.
|
222 |
+
*
|
223 |
+
* @param fn - Function that produces an element of the new array, taking three arguments
|
224 |
+
* @param thisArg - Value to use as `this` when executing function
|
225 |
+
* @example
|
226 |
+
* ```ts
|
227 |
+
* collection.map(user => user.tag);
|
228 |
+
* ```
|
229 |
+
*/
|
230 |
+
map<T>(fn: (value: V, key: K, collection: this) => T): T[];
|
231 |
+
map<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): T[];
|
232 |
+
/**
|
233 |
+
* Maps each item to another value into a collection. Identical in behavior to
|
234 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.
|
235 |
+
*
|
236 |
+
* @param fn - Function that produces an element of the new collection, taking three arguments
|
237 |
+
* @param thisArg - Value to use as `this` when executing function
|
238 |
+
* @example
|
239 |
+
* ```ts
|
240 |
+
* collection.mapValues(user => user.tag);
|
241 |
+
* ```
|
242 |
+
*/
|
243 |
+
mapValues<T>(fn: (value: V, key: K, collection: this) => T): Collection<K, T>;
|
244 |
+
mapValues<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): Collection<K, T>;
|
245 |
+
/**
|
246 |
+
* Checks if there exists an item that passes a test. Identical in behavior to
|
247 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some | Array.some()}.
|
248 |
+
*
|
249 |
+
* @param fn - Function used to test (should return a boolean)
|
250 |
+
* @param thisArg - Value to use as `this` when executing function
|
251 |
+
* @example
|
252 |
+
* ```ts
|
253 |
+
* collection.some(user => user.discriminator === '0000');
|
254 |
+
* ```
|
255 |
+
*/
|
256 |
+
some(fn: (value: V, key: K, collection: this) => unknown): boolean;
|
257 |
+
some<T>(fn: (this: T, value: V, key: K, collection: this) => unknown, thisArg: T): boolean;
|
258 |
+
/**
|
259 |
+
* Checks if all items passes a test. Identical in behavior to
|
260 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every | Array.every()}.
|
261 |
+
*
|
262 |
+
* @param fn - Function used to test (should return a boolean)
|
263 |
+
* @param thisArg - Value to use as `this` when executing function
|
264 |
+
* @example
|
265 |
+
* ```ts
|
266 |
+
* collection.every(user => !user.bot);
|
267 |
+
* ```
|
268 |
+
*/
|
269 |
+
every<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): this is Collection<K2, V>;
|
270 |
+
every<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): this is Collection<K, V2>;
|
271 |
+
every(fn: (value: V, key: K, collection: this) => unknown): boolean;
|
272 |
+
every<This, K2 extends K>(fn: (this: This, value: V, key: K, collection: this) => key is K2, thisArg: This): this is Collection<K2, V>;
|
273 |
+
every<This, V2 extends V>(fn: (this: This, value: V, key: K, collection: this) => value is V2, thisArg: This): this is Collection<K, V2>;
|
274 |
+
every<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): boolean;
|
275 |
+
/**
|
276 |
+
* Applies a function to produce a single value. Identical in behavior to
|
277 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.
|
278 |
+
*
|
279 |
+
* @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
|
280 |
+
* and `collection`
|
281 |
+
* @param initialValue - Starting value for the accumulator
|
282 |
+
* @example
|
283 |
+
* ```ts
|
284 |
+
* collection.reduce((acc, guild) => acc + guild.memberCount, 0);
|
285 |
+
* ```
|
286 |
+
*/
|
287 |
+
reduce<T = V>(fn: (accumulator: T, value: V, key: K, collection: this) => T, initialValue?: T): T;
|
288 |
+
/**
|
289 |
+
* Identical to
|
290 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach | Map.forEach()},
|
291 |
+
* but returns the collection instead of undefined.
|
292 |
+
*
|
293 |
+
* @param fn - Function to execute for each element
|
294 |
+
* @param thisArg - Value to use as `this` when executing function
|
295 |
+
* @example
|
296 |
+
* ```ts
|
297 |
+
* collection
|
298 |
+
* .each(user => console.log(user.username))
|
299 |
+
* .filter(user => user.bot)
|
300 |
+
* .each(user => console.log(user.username));
|
301 |
+
* ```
|
302 |
+
*/
|
303 |
+
each(fn: (value: V, key: K, collection: this) => void): this;
|
304 |
+
each<T>(fn: (this: T, value: V, key: K, collection: this) => void, thisArg: T): this;
|
305 |
+
/**
|
306 |
+
* Runs a function on the collection and returns the collection.
|
307 |
+
*
|
308 |
+
* @param fn - Function to execute
|
309 |
+
* @param thisArg - Value to use as `this` when executing function
|
310 |
+
* @example
|
311 |
+
* ```ts
|
312 |
+
* collection
|
313 |
+
* .tap(coll => console.log(coll.size))
|
314 |
+
* .filter(user => user.bot)
|
315 |
+
* .tap(coll => console.log(coll.size))
|
316 |
+
* ```
|
317 |
+
*/
|
318 |
+
tap(fn: (collection: this) => void): this;
|
319 |
+
tap<T>(fn: (this: T, collection: this) => void, thisArg: T): this;
|
320 |
+
/**
|
321 |
+
* Creates an identical shallow copy of this collection.
|
322 |
+
*
|
323 |
+
* @example
|
324 |
+
* ```ts
|
325 |
+
* const newColl = someColl.clone();
|
326 |
+
* ```
|
327 |
+
*/
|
328 |
+
clone(): Collection<K, V>;
|
329 |
+
/**
|
330 |
+
* Combines this collection with others into a new collection. None of the source collections are modified.
|
331 |
+
*
|
332 |
+
* @param collections - Collections to merge
|
333 |
+
* @example
|
334 |
+
* ```ts
|
335 |
+
* const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
|
336 |
+
* ```
|
337 |
+
*/
|
338 |
+
concat(...collections: ReadonlyCollection<K, V>[]): Collection<K, V>;
|
339 |
+
/**
|
340 |
+
* Checks if this collection shares identical items with another.
|
341 |
+
* This is different to checking for equality using equal-signs, because
|
342 |
+
* the collections may be different objects, but contain the same data.
|
343 |
+
*
|
344 |
+
* @param collection - Collection to compare with
|
345 |
+
* @returns Whether the collections have identical contents
|
346 |
+
*/
|
347 |
+
equals(collection: ReadonlyCollection<K, V>): boolean;
|
348 |
+
/**
|
349 |
+
* The sort method sorts the items of a collection in place and returns it.
|
350 |
+
* The sort is not necessarily stable in Node 10 or older.
|
351 |
+
* The default sort order is according to string Unicode code points.
|
352 |
+
*
|
353 |
+
* @param compareFunction - Specifies a function that defines the sort order.
|
354 |
+
* If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element.
|
355 |
+
* @example
|
356 |
+
* ```ts
|
357 |
+
* collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
358 |
+
* ```
|
359 |
+
*/
|
360 |
+
sort(compareFunction?: Comparator<K, V>): this;
|
361 |
+
/**
|
362 |
+
* The intersect method returns a new structure containing items where the keys and values are present in both original structures.
|
363 |
+
*
|
364 |
+
* @param other - The other Collection to filter against
|
365 |
+
*/
|
366 |
+
intersect<T>(other: ReadonlyCollection<K, T>): Collection<K, T>;
|
367 |
+
/**
|
368 |
+
* The subtract method returns a new structure containing items where the keys and values of the original structure are not present in the other.
|
369 |
+
*
|
370 |
+
* @param other - The other Collection to filter against
|
371 |
+
*/
|
372 |
+
subtract<T>(other: ReadonlyCollection<K, T>): Collection<K, V>;
|
373 |
+
/**
|
374 |
+
* The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.
|
375 |
+
*
|
376 |
+
* @param other - The other Collection to filter against
|
377 |
+
*/
|
378 |
+
difference<T>(other: ReadonlyCollection<K, T>): Collection<K, T | V>;
|
379 |
+
/**
|
380 |
+
* Merges two Collections together into a new Collection.
|
381 |
+
*
|
382 |
+
* @param other - The other Collection to merge with
|
383 |
+
* @param whenInSelf - Function getting the result if the entry only exists in this Collection
|
384 |
+
* @param whenInOther - Function getting the result if the entry only exists in the other Collection
|
385 |
+
* @param whenInBoth - Function getting the result if the entry exists in both Collections
|
386 |
+
* @example
|
387 |
+
* ```ts
|
388 |
+
* // Sums up the entries in two collections.
|
389 |
+
* coll.merge(
|
390 |
+
* other,
|
391 |
+
* x => ({ keep: true, value: x }),
|
392 |
+
* y => ({ keep: true, value: y }),
|
393 |
+
* (x, y) => ({ keep: true, value: x + y }),
|
394 |
+
* );
|
395 |
+
* ```
|
396 |
+
* @example
|
397 |
+
* ```ts
|
398 |
+
* // Intersects two collections in a left-biased manner.
|
399 |
+
* coll.merge(
|
400 |
+
* other,
|
401 |
+
* x => ({ keep: false }),
|
402 |
+
* y => ({ keep: false }),
|
403 |
+
* (x, _) => ({ keep: true, value: x }),
|
404 |
+
* );
|
405 |
+
* ```
|
406 |
+
*/
|
407 |
+
merge<T, R>(other: ReadonlyCollection<K, T>, whenInSelf: (value: V, key: K) => Keep<R>, whenInOther: (valueOther: T, key: K) => Keep<R>, whenInBoth: (value: V, valueOther: T, key: K) => Keep<R>): Collection<K, R>;
|
408 |
+
/**
|
409 |
+
* The sorted method sorts the items of a collection and returns it.
|
410 |
+
* The sort is not necessarily stable in Node 10 or older.
|
411 |
+
* The default sort order is according to string Unicode code points.
|
412 |
+
*
|
413 |
+
* @param compareFunction - Specifies a function that defines the sort order.
|
414 |
+
* If omitted, the collection is sorted according to each character's Unicode code point value,
|
415 |
+
* according to the string conversion of each element.
|
416 |
+
* @example
|
417 |
+
* ```ts
|
418 |
+
* collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
419 |
+
* ```
|
420 |
+
*/
|
421 |
+
sorted(compareFunction?: Comparator<K, V>): Collection<K, V>;
|
422 |
+
toJSON(): V[];
|
423 |
+
private static defaultSort;
|
424 |
+
/**
|
425 |
+
* Creates a Collection from a list of entries.
|
426 |
+
*
|
427 |
+
* @param entries - The list of entries
|
428 |
+
* @param combine - Function to combine an existing entry with a new one
|
429 |
+
* @example
|
430 |
+
* ```ts
|
431 |
+
* Collection.combineEntries([["a", 1], ["b", 2], ["a", 2]], (x, y) => x + y);
|
432 |
+
* // returns Collection { "a" => 3, "b" => 2 }
|
433 |
+
* ```
|
434 |
+
*/
|
435 |
+
static combineEntries<K, V>(entries: Iterable<[K, V]>, combine: (firstValue: V, secondValue: V, key: K) => V): Collection<K, V>;
|
436 |
+
}
|
437 |
+
/**
|
438 |
+
* @internal
|
439 |
+
*/
|
440 |
+
type Keep<V> = {
|
441 |
+
keep: false;
|
442 |
+
} | {
|
443 |
+
keep: true;
|
444 |
+
value: V;
|
445 |
+
};
|
446 |
+
/**
|
447 |
+
* @internal
|
448 |
+
*/
|
449 |
+
type Comparator<K, V> = (firstValue: V, secondValue: V, firstKey: K, secondKey: K) => number;
|
450 |
+
|
451 |
+
/**
|
452 |
+
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/collection/#readme | @discordjs/collection} version
|
453 |
+
* that you are currently using.
|
454 |
+
*/
|
455 |
+
declare const version: string;
|
456 |
+
|
457 |
+
export { Collection, CollectionConstructor, Comparator, Keep, ReadonlyCollection, version };
|
node_modules/@discordjs/collection/dist/index.js
ADDED
@@ -0,0 +1,543 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
var __defProp = Object.defineProperty;
|
3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6 |
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
7 |
+
var __export = (target, all) => {
|
8 |
+
for (var name in all)
|
9 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
10 |
+
};
|
11 |
+
var __copyProps = (to, from, except, desc) => {
|
12 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
13 |
+
for (let key of __getOwnPropNames(from))
|
14 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16 |
+
}
|
17 |
+
return to;
|
18 |
+
};
|
19 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
20 |
+
|
21 |
+
// src/index.ts
|
22 |
+
var src_exports = {};
|
23 |
+
__export(src_exports, {
|
24 |
+
Collection: () => Collection,
|
25 |
+
version: () => version
|
26 |
+
});
|
27 |
+
module.exports = __toCommonJS(src_exports);
|
28 |
+
|
29 |
+
// src/collection.ts
|
30 |
+
var Collection = class _Collection extends Map {
|
31 |
+
static {
|
32 |
+
__name(this, "Collection");
|
33 |
+
}
|
34 |
+
/**
|
35 |
+
* Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.
|
36 |
+
*
|
37 |
+
* @param key - The key to get if it exists, or set otherwise
|
38 |
+
* @param defaultValueGenerator - A function that generates the default value
|
39 |
+
* @example
|
40 |
+
* ```ts
|
41 |
+
* collection.ensure(guildId, () => defaultGuildConfig);
|
42 |
+
* ```
|
43 |
+
*/
|
44 |
+
ensure(key, defaultValueGenerator) {
|
45 |
+
if (this.has(key))
|
46 |
+
return this.get(key);
|
47 |
+
if (typeof defaultValueGenerator !== "function")
|
48 |
+
throw new TypeError(`${defaultValueGenerator} is not a function`);
|
49 |
+
const defaultValue = defaultValueGenerator(key, this);
|
50 |
+
this.set(key, defaultValue);
|
51 |
+
return defaultValue;
|
52 |
+
}
|
53 |
+
/**
|
54 |
+
* Checks if all of the elements exist in the collection.
|
55 |
+
*
|
56 |
+
* @param keys - The keys of the elements to check for
|
57 |
+
* @returns `true` if all of the elements exist, `false` if at least one does not exist.
|
58 |
+
*/
|
59 |
+
hasAll(...keys) {
|
60 |
+
return keys.every((key) => super.has(key));
|
61 |
+
}
|
62 |
+
/**
|
63 |
+
* Checks if any of the elements exist in the collection.
|
64 |
+
*
|
65 |
+
* @param keys - The keys of the elements to check for
|
66 |
+
* @returns `true` if any of the elements exist, `false` if none exist.
|
67 |
+
*/
|
68 |
+
hasAny(...keys) {
|
69 |
+
return keys.some((key) => super.has(key));
|
70 |
+
}
|
71 |
+
first(amount) {
|
72 |
+
if (amount === void 0)
|
73 |
+
return this.values().next().value;
|
74 |
+
if (amount < 0)
|
75 |
+
return this.last(amount * -1);
|
76 |
+
amount = Math.min(this.size, amount);
|
77 |
+
const iter = this.values();
|
78 |
+
return Array.from({ length: amount }, () => iter.next().value);
|
79 |
+
}
|
80 |
+
firstKey(amount) {
|
81 |
+
if (amount === void 0)
|
82 |
+
return this.keys().next().value;
|
83 |
+
if (amount < 0)
|
84 |
+
return this.lastKey(amount * -1);
|
85 |
+
amount = Math.min(this.size, amount);
|
86 |
+
const iter = this.keys();
|
87 |
+
return Array.from({ length: amount }, () => iter.next().value);
|
88 |
+
}
|
89 |
+
last(amount) {
|
90 |
+
const arr = [...this.values()];
|
91 |
+
if (amount === void 0)
|
92 |
+
return arr[arr.length - 1];
|
93 |
+
if (amount < 0)
|
94 |
+
return this.first(amount * -1);
|
95 |
+
if (!amount)
|
96 |
+
return [];
|
97 |
+
return arr.slice(-amount);
|
98 |
+
}
|
99 |
+
lastKey(amount) {
|
100 |
+
const arr = [...this.keys()];
|
101 |
+
if (amount === void 0)
|
102 |
+
return arr[arr.length - 1];
|
103 |
+
if (amount < 0)
|
104 |
+
return this.firstKey(amount * -1);
|
105 |
+
if (!amount)
|
106 |
+
return [];
|
107 |
+
return arr.slice(-amount);
|
108 |
+
}
|
109 |
+
/**
|
110 |
+
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
111 |
+
* Returns the item at a given index, allowing for positive and negative integers.
|
112 |
+
* Negative integers count back from the last item in the collection.
|
113 |
+
*
|
114 |
+
* @param index - The index of the element to obtain
|
115 |
+
*/
|
116 |
+
at(index) {
|
117 |
+
index = Math.floor(index);
|
118 |
+
const arr = [...this.values()];
|
119 |
+
return arr.at(index);
|
120 |
+
}
|
121 |
+
/**
|
122 |
+
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
123 |
+
* Returns the key at a given index, allowing for positive and negative integers.
|
124 |
+
* Negative integers count back from the last item in the collection.
|
125 |
+
*
|
126 |
+
* @param index - The index of the key to obtain
|
127 |
+
*/
|
128 |
+
keyAt(index) {
|
129 |
+
index = Math.floor(index);
|
130 |
+
const arr = [...this.keys()];
|
131 |
+
return arr.at(index);
|
132 |
+
}
|
133 |
+
random(amount) {
|
134 |
+
const arr = [...this.values()];
|
135 |
+
if (amount === void 0)
|
136 |
+
return arr[Math.floor(Math.random() * arr.length)];
|
137 |
+
if (!arr.length || !amount)
|
138 |
+
return [];
|
139 |
+
return Array.from(
|
140 |
+
{ length: Math.min(amount, arr.length) },
|
141 |
+
() => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]
|
142 |
+
);
|
143 |
+
}
|
144 |
+
randomKey(amount) {
|
145 |
+
const arr = [...this.keys()];
|
146 |
+
if (amount === void 0)
|
147 |
+
return arr[Math.floor(Math.random() * arr.length)];
|
148 |
+
if (!arr.length || !amount)
|
149 |
+
return [];
|
150 |
+
return Array.from(
|
151 |
+
{ length: Math.min(amount, arr.length) },
|
152 |
+
() => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]
|
153 |
+
);
|
154 |
+
}
|
155 |
+
/**
|
156 |
+
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}
|
157 |
+
* but returns a Collection instead of an Array.
|
158 |
+
*/
|
159 |
+
reverse() {
|
160 |
+
const entries = [...this.entries()].reverse();
|
161 |
+
this.clear();
|
162 |
+
for (const [key, value] of entries)
|
163 |
+
this.set(key, value);
|
164 |
+
return this;
|
165 |
+
}
|
166 |
+
find(fn, thisArg) {
|
167 |
+
if (typeof fn !== "function")
|
168 |
+
throw new TypeError(`${fn} is not a function`);
|
169 |
+
if (thisArg !== void 0)
|
170 |
+
fn = fn.bind(thisArg);
|
171 |
+
for (const [key, val] of this) {
|
172 |
+
if (fn(val, key, this))
|
173 |
+
return val;
|
174 |
+
}
|
175 |
+
return void 0;
|
176 |
+
}
|
177 |
+
findKey(fn, thisArg) {
|
178 |
+
if (typeof fn !== "function")
|
179 |
+
throw new TypeError(`${fn} is not a function`);
|
180 |
+
if (thisArg !== void 0)
|
181 |
+
fn = fn.bind(thisArg);
|
182 |
+
for (const [key, val] of this) {
|
183 |
+
if (fn(val, key, this))
|
184 |
+
return key;
|
185 |
+
}
|
186 |
+
return void 0;
|
187 |
+
}
|
188 |
+
sweep(fn, thisArg) {
|
189 |
+
if (typeof fn !== "function")
|
190 |
+
throw new TypeError(`${fn} is not a function`);
|
191 |
+
if (thisArg !== void 0)
|
192 |
+
fn = fn.bind(thisArg);
|
193 |
+
const previousSize = this.size;
|
194 |
+
for (const [key, val] of this) {
|
195 |
+
if (fn(val, key, this))
|
196 |
+
this.delete(key);
|
197 |
+
}
|
198 |
+
return previousSize - this.size;
|
199 |
+
}
|
200 |
+
filter(fn, thisArg) {
|
201 |
+
if (typeof fn !== "function")
|
202 |
+
throw new TypeError(`${fn} is not a function`);
|
203 |
+
if (thisArg !== void 0)
|
204 |
+
fn = fn.bind(thisArg);
|
205 |
+
const results = new this.constructor[Symbol.species]();
|
206 |
+
for (const [key, val] of this) {
|
207 |
+
if (fn(val, key, this))
|
208 |
+
results.set(key, val);
|
209 |
+
}
|
210 |
+
return results;
|
211 |
+
}
|
212 |
+
partition(fn, thisArg) {
|
213 |
+
if (typeof fn !== "function")
|
214 |
+
throw new TypeError(`${fn} is not a function`);
|
215 |
+
if (thisArg !== void 0)
|
216 |
+
fn = fn.bind(thisArg);
|
217 |
+
const results = [
|
218 |
+
new this.constructor[Symbol.species](),
|
219 |
+
new this.constructor[Symbol.species]()
|
220 |
+
];
|
221 |
+
for (const [key, val] of this) {
|
222 |
+
if (fn(val, key, this)) {
|
223 |
+
results[0].set(key, val);
|
224 |
+
} else {
|
225 |
+
results[1].set(key, val);
|
226 |
+
}
|
227 |
+
}
|
228 |
+
return results;
|
229 |
+
}
|
230 |
+
flatMap(fn, thisArg) {
|
231 |
+
const collections = this.map(fn, thisArg);
|
232 |
+
return new this.constructor[Symbol.species]().concat(...collections);
|
233 |
+
}
|
234 |
+
map(fn, thisArg) {
|
235 |
+
if (typeof fn !== "function")
|
236 |
+
throw new TypeError(`${fn} is not a function`);
|
237 |
+
if (thisArg !== void 0)
|
238 |
+
fn = fn.bind(thisArg);
|
239 |
+
const iter = this.entries();
|
240 |
+
return Array.from({ length: this.size }, () => {
|
241 |
+
const [key, value] = iter.next().value;
|
242 |
+
return fn(value, key, this);
|
243 |
+
});
|
244 |
+
}
|
245 |
+
mapValues(fn, thisArg) {
|
246 |
+
if (typeof fn !== "function")
|
247 |
+
throw new TypeError(`${fn} is not a function`);
|
248 |
+
if (thisArg !== void 0)
|
249 |
+
fn = fn.bind(thisArg);
|
250 |
+
const coll = new this.constructor[Symbol.species]();
|
251 |
+
for (const [key, val] of this)
|
252 |
+
coll.set(key, fn(val, key, this));
|
253 |
+
return coll;
|
254 |
+
}
|
255 |
+
some(fn, thisArg) {
|
256 |
+
if (typeof fn !== "function")
|
257 |
+
throw new TypeError(`${fn} is not a function`);
|
258 |
+
if (thisArg !== void 0)
|
259 |
+
fn = fn.bind(thisArg);
|
260 |
+
for (const [key, val] of this) {
|
261 |
+
if (fn(val, key, this))
|
262 |
+
return true;
|
263 |
+
}
|
264 |
+
return false;
|
265 |
+
}
|
266 |
+
every(fn, thisArg) {
|
267 |
+
if (typeof fn !== "function")
|
268 |
+
throw new TypeError(`${fn} is not a function`);
|
269 |
+
if (thisArg !== void 0)
|
270 |
+
fn = fn.bind(thisArg);
|
271 |
+
for (const [key, val] of this) {
|
272 |
+
if (!fn(val, key, this))
|
273 |
+
return false;
|
274 |
+
}
|
275 |
+
return true;
|
276 |
+
}
|
277 |
+
/**
|
278 |
+
* Applies a function to produce a single value. Identical in behavior to
|
279 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.
|
280 |
+
*
|
281 |
+
* @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
|
282 |
+
* and `collection`
|
283 |
+
* @param initialValue - Starting value for the accumulator
|
284 |
+
* @example
|
285 |
+
* ```ts
|
286 |
+
* collection.reduce((acc, guild) => acc + guild.memberCount, 0);
|
287 |
+
* ```
|
288 |
+
*/
|
289 |
+
reduce(fn, initialValue) {
|
290 |
+
if (typeof fn !== "function")
|
291 |
+
throw new TypeError(`${fn} is not a function`);
|
292 |
+
let accumulator;
|
293 |
+
const iterator = this.entries();
|
294 |
+
if (initialValue === void 0) {
|
295 |
+
if (this.size === 0)
|
296 |
+
throw new TypeError("Reduce of empty collection with no initial value");
|
297 |
+
accumulator = iterator.next().value[1];
|
298 |
+
} else {
|
299 |
+
accumulator = initialValue;
|
300 |
+
}
|
301 |
+
for (const [key, value] of iterator) {
|
302 |
+
accumulator = fn(accumulator, value, key, this);
|
303 |
+
}
|
304 |
+
return accumulator;
|
305 |
+
}
|
306 |
+
each(fn, thisArg) {
|
307 |
+
if (typeof fn !== "function")
|
308 |
+
throw new TypeError(`${fn} is not a function`);
|
309 |
+
if (thisArg !== void 0)
|
310 |
+
fn = fn.bind(thisArg);
|
311 |
+
for (const [key, value] of this) {
|
312 |
+
fn(value, key, this);
|
313 |
+
}
|
314 |
+
return this;
|
315 |
+
}
|
316 |
+
tap(fn, thisArg) {
|
317 |
+
if (typeof fn !== "function")
|
318 |
+
throw new TypeError(`${fn} is not a function`);
|
319 |
+
if (thisArg !== void 0)
|
320 |
+
fn = fn.bind(thisArg);
|
321 |
+
fn(this);
|
322 |
+
return this;
|
323 |
+
}
|
324 |
+
/**
|
325 |
+
* Creates an identical shallow copy of this collection.
|
326 |
+
*
|
327 |
+
* @example
|
328 |
+
* ```ts
|
329 |
+
* const newColl = someColl.clone();
|
330 |
+
* ```
|
331 |
+
*/
|
332 |
+
clone() {
|
333 |
+
return new this.constructor[Symbol.species](this);
|
334 |
+
}
|
335 |
+
/**
|
336 |
+
* Combines this collection with others into a new collection. None of the source collections are modified.
|
337 |
+
*
|
338 |
+
* @param collections - Collections to merge
|
339 |
+
* @example
|
340 |
+
* ```ts
|
341 |
+
* const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
|
342 |
+
* ```
|
343 |
+
*/
|
344 |
+
concat(...collections) {
|
345 |
+
const newColl = this.clone();
|
346 |
+
for (const coll of collections) {
|
347 |
+
for (const [key, val] of coll)
|
348 |
+
newColl.set(key, val);
|
349 |
+
}
|
350 |
+
return newColl;
|
351 |
+
}
|
352 |
+
/**
|
353 |
+
* Checks if this collection shares identical items with another.
|
354 |
+
* This is different to checking for equality using equal-signs, because
|
355 |
+
* the collections may be different objects, but contain the same data.
|
356 |
+
*
|
357 |
+
* @param collection - Collection to compare with
|
358 |
+
* @returns Whether the collections have identical contents
|
359 |
+
*/
|
360 |
+
equals(collection) {
|
361 |
+
if (!collection)
|
362 |
+
return false;
|
363 |
+
if (this === collection)
|
364 |
+
return true;
|
365 |
+
if (this.size !== collection.size)
|
366 |
+
return false;
|
367 |
+
for (const [key, value] of this) {
|
368 |
+
if (!collection.has(key) || value !== collection.get(key)) {
|
369 |
+
return false;
|
370 |
+
}
|
371 |
+
}
|
372 |
+
return true;
|
373 |
+
}
|
374 |
+
/**
|
375 |
+
* The sort method sorts the items of a collection in place and returns it.
|
376 |
+
* The sort is not necessarily stable in Node 10 or older.
|
377 |
+
* The default sort order is according to string Unicode code points.
|
378 |
+
*
|
379 |
+
* @param compareFunction - Specifies a function that defines the sort order.
|
380 |
+
* If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element.
|
381 |
+
* @example
|
382 |
+
* ```ts
|
383 |
+
* collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
384 |
+
* ```
|
385 |
+
*/
|
386 |
+
sort(compareFunction = _Collection.defaultSort) {
|
387 |
+
const entries = [...this.entries()];
|
388 |
+
entries.sort((a, b) => compareFunction(a[1], b[1], a[0], b[0]));
|
389 |
+
super.clear();
|
390 |
+
for (const [key, value] of entries) {
|
391 |
+
super.set(key, value);
|
392 |
+
}
|
393 |
+
return this;
|
394 |
+
}
|
395 |
+
/**
|
396 |
+
* The intersect method returns a new structure containing items where the keys and values are present in both original structures.
|
397 |
+
*
|
398 |
+
* @param other - The other Collection to filter against
|
399 |
+
*/
|
400 |
+
intersect(other) {
|
401 |
+
const coll = new this.constructor[Symbol.species]();
|
402 |
+
for (const [key, value] of other) {
|
403 |
+
if (this.has(key) && Object.is(value, this.get(key))) {
|
404 |
+
coll.set(key, value);
|
405 |
+
}
|
406 |
+
}
|
407 |
+
return coll;
|
408 |
+
}
|
409 |
+
/**
|
410 |
+
* The subtract method returns a new structure containing items where the keys and values of the original structure are not present in the other.
|
411 |
+
*
|
412 |
+
* @param other - The other Collection to filter against
|
413 |
+
*/
|
414 |
+
subtract(other) {
|
415 |
+
const coll = new this.constructor[Symbol.species]();
|
416 |
+
for (const [key, value] of this) {
|
417 |
+
if (!other.has(key) || !Object.is(value, other.get(key))) {
|
418 |
+
coll.set(key, value);
|
419 |
+
}
|
420 |
+
}
|
421 |
+
return coll;
|
422 |
+
}
|
423 |
+
/**
|
424 |
+
* The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.
|
425 |
+
*
|
426 |
+
* @param other - The other Collection to filter against
|
427 |
+
*/
|
428 |
+
difference(other) {
|
429 |
+
const coll = new this.constructor[Symbol.species]();
|
430 |
+
for (const [key, value] of other) {
|
431 |
+
if (!this.has(key))
|
432 |
+
coll.set(key, value);
|
433 |
+
}
|
434 |
+
for (const [key, value] of this) {
|
435 |
+
if (!other.has(key))
|
436 |
+
coll.set(key, value);
|
437 |
+
}
|
438 |
+
return coll;
|
439 |
+
}
|
440 |
+
/**
|
441 |
+
* Merges two Collections together into a new Collection.
|
442 |
+
*
|
443 |
+
* @param other - The other Collection to merge with
|
444 |
+
* @param whenInSelf - Function getting the result if the entry only exists in this Collection
|
445 |
+
* @param whenInOther - Function getting the result if the entry only exists in the other Collection
|
446 |
+
* @param whenInBoth - Function getting the result if the entry exists in both Collections
|
447 |
+
* @example
|
448 |
+
* ```ts
|
449 |
+
* // Sums up the entries in two collections.
|
450 |
+
* coll.merge(
|
451 |
+
* other,
|
452 |
+
* x => ({ keep: true, value: x }),
|
453 |
+
* y => ({ keep: true, value: y }),
|
454 |
+
* (x, y) => ({ keep: true, value: x + y }),
|
455 |
+
* );
|
456 |
+
* ```
|
457 |
+
* @example
|
458 |
+
* ```ts
|
459 |
+
* // Intersects two collections in a left-biased manner.
|
460 |
+
* coll.merge(
|
461 |
+
* other,
|
462 |
+
* x => ({ keep: false }),
|
463 |
+
* y => ({ keep: false }),
|
464 |
+
* (x, _) => ({ keep: true, value: x }),
|
465 |
+
* );
|
466 |
+
* ```
|
467 |
+
*/
|
468 |
+
merge(other, whenInSelf, whenInOther, whenInBoth) {
|
469 |
+
const coll = new this.constructor[Symbol.species]();
|
470 |
+
const keys = /* @__PURE__ */ new Set([...this.keys(), ...other.keys()]);
|
471 |
+
for (const key of keys) {
|
472 |
+
const hasInSelf = this.has(key);
|
473 |
+
const hasInOther = other.has(key);
|
474 |
+
if (hasInSelf && hasInOther) {
|
475 |
+
const result = whenInBoth(this.get(key), other.get(key), key);
|
476 |
+
if (result.keep)
|
477 |
+
coll.set(key, result.value);
|
478 |
+
} else if (hasInSelf) {
|
479 |
+
const result = whenInSelf(this.get(key), key);
|
480 |
+
if (result.keep)
|
481 |
+
coll.set(key, result.value);
|
482 |
+
} else if (hasInOther) {
|
483 |
+
const result = whenInOther(other.get(key), key);
|
484 |
+
if (result.keep)
|
485 |
+
coll.set(key, result.value);
|
486 |
+
}
|
487 |
+
}
|
488 |
+
return coll;
|
489 |
+
}
|
490 |
+
/**
|
491 |
+
* The sorted method sorts the items of a collection and returns it.
|
492 |
+
* The sort is not necessarily stable in Node 10 or older.
|
493 |
+
* The default sort order is according to string Unicode code points.
|
494 |
+
*
|
495 |
+
* @param compareFunction - Specifies a function that defines the sort order.
|
496 |
+
* If omitted, the collection is sorted according to each character's Unicode code point value,
|
497 |
+
* according to the string conversion of each element.
|
498 |
+
* @example
|
499 |
+
* ```ts
|
500 |
+
* collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
501 |
+
* ```
|
502 |
+
*/
|
503 |
+
sorted(compareFunction = _Collection.defaultSort) {
|
504 |
+
return new this.constructor[Symbol.species](this).sort((av, bv, ak, bk) => compareFunction(av, bv, ak, bk));
|
505 |
+
}
|
506 |
+
toJSON() {
|
507 |
+
return [...this.values()];
|
508 |
+
}
|
509 |
+
static defaultSort(firstValue, secondValue) {
|
510 |
+
return Number(firstValue > secondValue) || Number(firstValue === secondValue) - 1;
|
511 |
+
}
|
512 |
+
/**
|
513 |
+
* Creates a Collection from a list of entries.
|
514 |
+
*
|
515 |
+
* @param entries - The list of entries
|
516 |
+
* @param combine - Function to combine an existing entry with a new one
|
517 |
+
* @example
|
518 |
+
* ```ts
|
519 |
+
* Collection.combineEntries([["a", 1], ["b", 2], ["a", 2]], (x, y) => x + y);
|
520 |
+
* // returns Collection { "a" => 3, "b" => 2 }
|
521 |
+
* ```
|
522 |
+
*/
|
523 |
+
static combineEntries(entries, combine) {
|
524 |
+
const coll = new _Collection();
|
525 |
+
for (const [key, value] of entries) {
|
526 |
+
if (coll.has(key)) {
|
527 |
+
coll.set(key, combine(coll.get(key), value, key));
|
528 |
+
} else {
|
529 |
+
coll.set(key, value);
|
530 |
+
}
|
531 |
+
}
|
532 |
+
return coll;
|
533 |
+
}
|
534 |
+
};
|
535 |
+
|
536 |
+
// src/index.ts
|
537 |
+
var version = "1.5.3";
|
538 |
+
// Annotate the CommonJS export names for ESM import in node:
|
539 |
+
0 && (module.exports = {
|
540 |
+
Collection,
|
541 |
+
version
|
542 |
+
});
|
543 |
+
//# sourceMappingURL=index.js.map
|
node_modules/@discordjs/collection/dist/index.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"sources":["../src/index.ts","../src/collection.ts"],"sourcesContent":["export * from './collection.js';\n\n/**\n * The {@link https://github.com/discordjs/discord.js/blob/main/packages/collection/#readme | @discordjs/collection} version\n * that you are currently using.\n */\n// This needs to explicitly be `string` so it is not typed as a \"const string\" that gets injected by esbuild\nexport const version = '1.5.3' as string;\n","/* eslint-disable no-param-reassign */\n/**\n * @internal\n */\nexport interface CollectionConstructor {\n\tnew (): Collection<unknown, unknown>;\n\tnew <K, V>(entries?: readonly (readonly [K, V])[] | null): Collection<K, V>;\n\tnew <K, V>(iterable: Iterable<readonly [K, V]>): Collection<K, V>;\n\treadonly prototype: Collection<unknown, unknown>;\n\treadonly [Symbol.species]: CollectionConstructor;\n}\n\n/**\n * Represents an immutable version of a collection\n */\nexport type ReadonlyCollection<K, V> = Omit<\n\tCollection<K, V>,\n\t'delete' | 'ensure' | 'forEach' | 'get' | 'reverse' | 'set' | 'sort' | 'sweep'\n> &\n\tReadonlyMap<K, V>;\n\n/**\n * Separate interface for the constructor so that emitted js does not have a constructor that overwrites itself\n *\n * @internal\n */\nexport interface Collection<K, V> extends Map<K, V> {\n\tconstructor: CollectionConstructor;\n}\n\n/**\n * A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has\n * an ID, for significantly improved performance and ease-of-use.\n *\n * @typeParam K - The key type this collection holds\n * @typeParam V - The value type this collection holds\n */\nexport class Collection<K, V> extends Map<K, V> {\n\t/**\n\t * Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.\n\t *\n\t * @param key - The key to get if it exists, or set otherwise\n\t * @param defaultValueGenerator - A function that generates the default value\n\t * @example\n\t * ```ts\n\t * collection.ensure(guildId, () => defaultGuildConfig);\n\t * ```\n\t */\n\tpublic ensure(key: K, defaultValueGenerator: (key: K, collection: this) => V): V {\n\t\tif (this.has(key)) return this.get(key)!;\n\t\tif (typeof defaultValueGenerator !== 'function') throw new TypeError(`${defaultValueGenerator} is not a function`);\n\t\tconst defaultValue = defaultValueGenerator(key, this);\n\t\tthis.set(key, defaultValue);\n\t\treturn defaultValue;\n\t}\n\n\t/**\n\t * Checks if all of the elements exist in the collection.\n\t *\n\t * @param keys - The keys of the elements to check for\n\t * @returns `true` if all of the elements exist, `false` if at least one does not exist.\n\t */\n\tpublic hasAll(...keys: K[]) {\n\t\treturn keys.every((key) => super.has(key));\n\t}\n\n\t/**\n\t * Checks if any of the elements exist in the collection.\n\t *\n\t * @param keys - The keys of the elements to check for\n\t * @returns `true` if any of the elements exist, `false` if none exist.\n\t */\n\tpublic hasAny(...keys: K[]) {\n\t\treturn keys.some((key) => super.has(key));\n\t}\n\n\t/**\n\t * Obtains the first value(s) in this collection.\n\t *\n\t * @param amount - Amount of values to obtain from the beginning\n\t * @returns A single value if no amount is provided or an array of values, starting from the end if amount is negative\n\t */\n\tpublic first(): V | undefined;\n\tpublic first(amount: number): V[];\n\tpublic first(amount?: number): V | V[] | undefined {\n\t\tif (amount === undefined) return this.values().next().value;\n\t\tif (amount < 0) return this.last(amount * -1);\n\t\tamount = Math.min(this.size, amount);\n\t\tconst iter = this.values();\n\t\treturn Array.from({ length: amount }, (): V => iter.next().value);\n\t}\n\n\t/**\n\t * Obtains the first key(s) in this collection.\n\t *\n\t * @param amount - Amount of keys to obtain from the beginning\n\t * @returns A single key if no amount is provided or an array of keys, starting from the end if\n\t * amount is negative\n\t */\n\tpublic firstKey(): K | undefined;\n\tpublic firstKey(amount: number): K[];\n\tpublic firstKey(amount?: number): K | K[] | undefined {\n\t\tif (amount === undefined) return this.keys().next().value;\n\t\tif (amount < 0) return this.lastKey(amount * -1);\n\t\tamount = Math.min(this.size, amount);\n\t\tconst iter = this.keys();\n\t\treturn Array.from({ length: amount }, (): K => iter.next().value);\n\t}\n\n\t/**\n\t * Obtains the last value(s) in this collection.\n\t *\n\t * @param amount - Amount of values to obtain from the end\n\t * @returns A single value if no amount is provided or an array of values, starting from the start if\n\t * amount is negative\n\t */\n\tpublic last(): V | undefined;\n\tpublic last(amount: number): V[];\n\tpublic last(amount?: number): V | V[] | undefined {\n\t\tconst arr = [...this.values()];\n\t\tif (amount === undefined) return arr[arr.length - 1];\n\t\tif (amount < 0) return this.first(amount * -1);\n\t\tif (!amount) return [];\n\t\treturn arr.slice(-amount);\n\t}\n\n\t/**\n\t * Obtains the last key(s) in this collection.\n\t *\n\t * @param amount - Amount of keys to obtain from the end\n\t * @returns A single key if no amount is provided or an array of keys, starting from the start if\n\t * amount is negative\n\t */\n\tpublic lastKey(): K | undefined;\n\tpublic lastKey(amount: number): K[];\n\tpublic lastKey(amount?: number): K | K[] | undefined {\n\t\tconst arr = [...this.keys()];\n\t\tif (amount === undefined) return arr[arr.length - 1];\n\t\tif (amount < 0) return this.firstKey(amount * -1);\n\t\tif (!amount) return [];\n\t\treturn arr.slice(-amount);\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.\n\t * Returns the item at a given index, allowing for positive and negative integers.\n\t * Negative integers count back from the last item in the collection.\n\t *\n\t * @param index - The index of the element to obtain\n\t */\n\tpublic at(index: number) {\n\t\tindex = Math.floor(index);\n\t\tconst arr = [...this.values()];\n\t\treturn arr.at(index);\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.\n\t * Returns the key at a given index, allowing for positive and negative integers.\n\t * Negative integers count back from the last item in the collection.\n\t *\n\t * @param index - The index of the key to obtain\n\t */\n\tpublic keyAt(index: number) {\n\t\tindex = Math.floor(index);\n\t\tconst arr = [...this.keys()];\n\t\treturn arr.at(index);\n\t}\n\n\t/**\n\t * Obtains unique random value(s) from this collection.\n\t *\n\t * @param amount - Amount of values to obtain randomly\n\t * @returns A single value if no amount is provided or an array of values\n\t */\n\tpublic random(): V | undefined;\n\tpublic random(amount: number): V[];\n\tpublic random(amount?: number): V | V[] | undefined {\n\t\tconst arr = [...this.values()];\n\t\tif (amount === undefined) return arr[Math.floor(Math.random() * arr.length)];\n\t\tif (!arr.length || !amount) return [];\n\t\treturn Array.from(\n\t\t\t{ length: Math.min(amount, arr.length) },\n\t\t\t(): V => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]!,\n\t\t);\n\t}\n\n\t/**\n\t * Obtains unique random key(s) from this collection.\n\t *\n\t * @param amount - Amount of keys to obtain randomly\n\t * @returns A single key if no amount is provided or an array\n\t */\n\tpublic randomKey(): K | undefined;\n\tpublic randomKey(amount: number): K[];\n\tpublic randomKey(amount?: number): K | K[] | undefined {\n\t\tconst arr = [...this.keys()];\n\t\tif (amount === undefined) return arr[Math.floor(Math.random() * arr.length)];\n\t\tif (!arr.length || !amount) return [];\n\t\treturn Array.from(\n\t\t\t{ length: Math.min(amount, arr.length) },\n\t\t\t(): K => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]!,\n\t\t);\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}\n\t * but returns a Collection instead of an Array.\n\t */\n\tpublic reverse() {\n\t\tconst entries = [...this.entries()].reverse();\n\t\tthis.clear();\n\t\tfor (const [key, value] of entries) this.set(key, value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Searches for a single item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find | Array.find()}.\n\t * All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you\n\t * should use the `get` method. See\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get | MDN} for details.\n\t *\n\t * @param fn - The function to test with (should return boolean)\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection.find(user => user.username === 'Bob');\n\t * ```\n\t */\n\tpublic find<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): V2 | undefined;\n\tpublic find(fn: (value: V, key: K, collection: this) => unknown): V | undefined;\n\tpublic find<This, V2 extends V>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => value is V2,\n\t\tthisArg: This,\n\t): V2 | undefined;\n\tpublic find<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): V | undefined;\n\tpublic find(fn: (value: V, key: K, collection: this) => unknown, thisArg?: unknown): V | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) return val;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Searches for the key of a single item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex | Array.findIndex()},\n\t * but returns the key rather than the positional index.\n\t *\n\t * @param fn - The function to test with (should return boolean)\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection.findKey(user => user.username === 'Bob');\n\t * ```\n\t */\n\tpublic findKey<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): K2 | undefined;\n\tpublic findKey(fn: (value: V, key: K, collection: this) => unknown): K | undefined;\n\tpublic findKey<This, K2 extends K>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => key is K2,\n\t\tthisArg: This,\n\t): K2 | undefined;\n\tpublic findKey<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): K | undefined;\n\tpublic findKey(fn: (value: V, key: K, collection: this) => unknown, thisArg?: unknown): K | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) return key;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Removes items that satisfy the provided filter function.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @returns The number of removed entries\n\t */\n\tpublic sweep(fn: (value: V, key: K, collection: this) => unknown): number;\n\tpublic sweep<T>(fn: (this: T, value: V, key: K, collection: this) => unknown, thisArg: T): number;\n\tpublic sweep(fn: (value: V, key: K, collection: this) => unknown, thisArg?: unknown): number {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst previousSize = this.size;\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) this.delete(key);\n\t\t}\n\n\t\treturn previousSize - this.size;\n\t}\n\n\t/**\n\t * Identical to\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter | Array.filter()},\n\t * but returns a Collection instead of an Array.\n\t *\n\t * @param fn - The function to test with (should return boolean)\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection.filter(user => user.username === 'Bob');\n\t * ```\n\t */\n\tpublic filter<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): Collection<K2, V>;\n\tpublic filter<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): Collection<K, V2>;\n\tpublic filter(fn: (value: V, key: K, collection: this) => unknown): Collection<K, V>;\n\tpublic filter<This, K2 extends K>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => key is K2,\n\t\tthisArg: This,\n\t): Collection<K2, V>;\n\tpublic filter<This, V2 extends V>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => value is V2,\n\t\tthisArg: This,\n\t): Collection<K, V2>;\n\tpublic filter<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): Collection<K, V>;\n\tpublic filter(fn: (value: V, key: K, collection: this) => unknown, thisArg?: unknown): Collection<K, V> {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst results = new this.constructor[Symbol.species]<K, V>();\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) results.set(key, val);\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Partitions the collection into two collections where the first collection\n\t * contains the items that passed and the second contains the items that failed.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * const [big, small] = collection.partition(guild => guild.memberCount > 250);\n\t * ```\n\t */\n\tpublic partition<K2 extends K>(\n\t\tfn: (value: V, key: K, collection: this) => key is K2,\n\t): [Collection<K2, V>, Collection<Exclude<K, K2>, V>];\n\tpublic partition<V2 extends V>(\n\t\tfn: (value: V, key: K, collection: this) => value is V2,\n\t): [Collection<K, V2>, Collection<K, Exclude<V, V2>>];\n\tpublic partition(fn: (value: V, key: K, collection: this) => unknown): [Collection<K, V>, Collection<K, V>];\n\tpublic partition<This, K2 extends K>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => key is K2,\n\t\tthisArg: This,\n\t): [Collection<K2, V>, Collection<Exclude<K, K2>, V>];\n\tpublic partition<This, V2 extends V>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => value is V2,\n\t\tthisArg: This,\n\t): [Collection<K, V2>, Collection<K, Exclude<V, V2>>];\n\tpublic partition<This>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => unknown,\n\t\tthisArg: This,\n\t): [Collection<K, V>, Collection<K, V>];\n\tpublic partition(\n\t\tfn: (value: V, key: K, collection: this) => unknown,\n\t\tthisArg?: unknown,\n\t): [Collection<K, V>, Collection<K, V>] {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst results: [Collection<K, V>, Collection<K, V>] = [\n\t\t\tnew this.constructor[Symbol.species]<K, V>(),\n\t\t\tnew this.constructor[Symbol.species]<K, V>(),\n\t\t];\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) {\n\t\t\t\tresults[0].set(key, val);\n\t\t\t} else {\n\t\t\t\tresults[1].set(key, val);\n\t\t\t}\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | Array.flatMap()}.\n\t *\n\t * @param fn - Function that produces a new Collection\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection.flatMap(guild => guild.members.cache);\n\t * ```\n\t */\n\tpublic flatMap<T>(fn: (value: V, key: K, collection: this) => Collection<K, T>): Collection<K, T>;\n\tpublic flatMap<T, This>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => Collection<K, T>,\n\t\tthisArg: This,\n\t): Collection<K, T>;\n\tpublic flatMap<T>(fn: (value: V, key: K, collection: this) => Collection<K, T>, thisArg?: unknown): Collection<K, T> {\n\t\t// eslint-disable-next-line unicorn/no-array-method-this-argument\n\t\tconst collections = this.map(fn, thisArg);\n\t\treturn new this.constructor[Symbol.species]<K, T>().concat(...collections);\n\t}\n\n\t/**\n\t * Maps each item to another value into an array. Identical in behavior to\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.\n\t *\n\t * @param fn - Function that produces an element of the new array, taking three arguments\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection.map(user => user.tag);\n\t * ```\n\t */\n\tpublic map<T>(fn: (value: V, key: K, collection: this) => T): T[];\n\tpublic map<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): T[];\n\tpublic map<T>(fn: (value: V, key: K, collection: this) => T, thisArg?: unknown): T[] {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst iter = this.entries();\n\t\treturn Array.from({ length: this.size }, (): T => {\n\t\t\tconst [key, value] = iter.next().value;\n\t\t\treturn fn(value, key, this);\n\t\t});\n\t}\n\n\t/**\n\t * Maps each item to another value into a collection. Identical in behavior to\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.\n\t *\n\t * @param fn - Function that produces an element of the new collection, taking three arguments\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection.mapValues(user => user.tag);\n\t * ```\n\t */\n\tpublic mapValues<T>(fn: (value: V, key: K, collection: this) => T): Collection<K, T>;\n\tpublic mapValues<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): Collection<K, T>;\n\tpublic mapValues<T>(fn: (value: V, key: K, collection: this) => T, thisArg?: unknown): Collection<K, T> {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst coll = new this.constructor[Symbol.species]<K, T>();\n\t\tfor (const [key, val] of this) coll.set(key, fn(val, key, this));\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Checks if there exists an item that passes a test. Identical in behavior to\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some | Array.some()}.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection.some(user => user.discriminator === '0000');\n\t * ```\n\t */\n\tpublic some(fn: (value: V, key: K, collection: this) => unknown): boolean;\n\tpublic some<T>(fn: (this: T, value: V, key: K, collection: this) => unknown, thisArg: T): boolean;\n\tpublic some(fn: (value: V, key: K, collection: this) => unknown, thisArg?: unknown): boolean {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) return true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Checks if all items passes a test. Identical in behavior to\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every | Array.every()}.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection.every(user => !user.bot);\n\t * ```\n\t */\n\tpublic every<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): this is Collection<K2, V>;\n\tpublic every<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): this is Collection<K, V2>;\n\tpublic every(fn: (value: V, key: K, collection: this) => unknown): boolean;\n\tpublic every<This, K2 extends K>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => key is K2,\n\t\tthisArg: This,\n\t): this is Collection<K2, V>;\n\tpublic every<This, V2 extends V>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => value is V2,\n\t\tthisArg: This,\n\t): this is Collection<K, V2>;\n\tpublic every<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): boolean;\n\tpublic every(fn: (value: V, key: K, collection: this) => unknown, thisArg?: unknown): boolean {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const [key, val] of this) {\n\t\t\tif (!fn(val, key, this)) return false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Applies a function to produce a single value. Identical in behavior to\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.\n\t *\n\t * @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,\n\t * and `collection`\n\t * @param initialValue - Starting value for the accumulator\n\t * @example\n\t * ```ts\n\t * collection.reduce((acc, guild) => acc + guild.memberCount, 0);\n\t * ```\n\t */\n\tpublic reduce<T = V>(fn: (accumulator: T, value: V, key: K, collection: this) => T, initialValue?: T): T {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tlet accumulator!: T;\n\n\t\tconst iterator = this.entries();\n\t\tif (initialValue === undefined) {\n\t\t\tif (this.size === 0) throw new TypeError('Reduce of empty collection with no initial value');\n\t\t\taccumulator = iterator.next().value[1];\n\t\t} else {\n\t\t\taccumulator = initialValue;\n\t\t}\n\n\t\tfor (const [key, value] of iterator) {\n\t\t\taccumulator = fn(accumulator, value, key, this);\n\t\t}\n\n\t\treturn accumulator;\n\t}\n\n\t/**\n\t * Identical to\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach | Map.forEach()},\n\t * but returns the collection instead of undefined.\n\t *\n\t * @param fn - Function to execute for each element\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection\n\t * .each(user => console.log(user.username))\n\t * .filter(user => user.bot)\n\t * .each(user => console.log(user.username));\n\t * ```\n\t */\n\tpublic each(fn: (value: V, key: K, collection: this) => void): this;\n\tpublic each<T>(fn: (this: T, value: V, key: K, collection: this) => void, thisArg: T): this;\n\tpublic each(fn: (value: V, key: K, collection: this) => void, thisArg?: unknown): this {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\n\t\tfor (const [key, value] of this) {\n\t\t\tfn(value, key, this);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Runs a function on the collection and returns the collection.\n\t *\n\t * @param fn - Function to execute\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection\n\t * .tap(coll => console.log(coll.size))\n\t * .filter(user => user.bot)\n\t * .tap(coll => console.log(coll.size))\n\t * ```\n\t */\n\tpublic tap(fn: (collection: this) => void): this;\n\tpublic tap<T>(fn: (this: T, collection: this) => void, thisArg: T): this;\n\tpublic tap(fn: (collection: this) => void, thisArg?: unknown): this {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfn(this);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Creates an identical shallow copy of this collection.\n\t *\n\t * @example\n\t * ```ts\n\t * const newColl = someColl.clone();\n\t * ```\n\t */\n\tpublic clone(): Collection<K, V> {\n\t\treturn new this.constructor[Symbol.species](this);\n\t}\n\n\t/**\n\t * Combines this collection with others into a new collection. None of the source collections are modified.\n\t *\n\t * @param collections - Collections to merge\n\t * @example\n\t * ```ts\n\t * const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);\n\t * ```\n\t */\n\tpublic concat(...collections: ReadonlyCollection<K, V>[]) {\n\t\tconst newColl = this.clone();\n\t\tfor (const coll of collections) {\n\t\t\tfor (const [key, val] of coll) newColl.set(key, val);\n\t\t}\n\n\t\treturn newColl;\n\t}\n\n\t/**\n\t * Checks if this collection shares identical items with another.\n\t * This is different to checking for equality using equal-signs, because\n\t * the collections may be different objects, but contain the same data.\n\t *\n\t * @param collection - Collection to compare with\n\t * @returns Whether the collections have identical contents\n\t */\n\tpublic equals(collection: ReadonlyCollection<K, V>) {\n\t\tif (!collection) return false; // runtime check\n\t\tif (this === collection) return true;\n\t\tif (this.size !== collection.size) return false;\n\t\tfor (const [key, value] of this) {\n\t\t\tif (!collection.has(key) || value !== collection.get(key)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * The sort method sorts the items of a collection in place and returns it.\n\t * The sort is not necessarily stable in Node 10 or older.\n\t * The default sort order is according to string Unicode code points.\n\t *\n\t * @param compareFunction - Specifies a function that defines the sort order.\n\t * If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element.\n\t * @example\n\t * ```ts\n\t * collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);\n\t * ```\n\t */\n\tpublic sort(compareFunction: Comparator<K, V> = Collection.defaultSort) {\n\t\tconst entries = [...this.entries()];\n\t\tentries.sort((a, b): number => compareFunction(a[1], b[1], a[0], b[0]));\n\n\t\t// Perform clean-up\n\t\tsuper.clear();\n\n\t\t// Set the new entries\n\t\tfor (const [key, value] of entries) {\n\t\t\tsuper.set(key, value);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * The intersect method returns a new structure containing items where the keys and values are present in both original structures.\n\t *\n\t * @param other - The other Collection to filter against\n\t */\n\tpublic intersect<T>(other: ReadonlyCollection<K, T>): Collection<K, T> {\n\t\tconst coll = new this.constructor[Symbol.species]<K, T>();\n\t\tfor (const [key, value] of other) {\n\t\t\tif (this.has(key) && Object.is(value, this.get(key))) {\n\t\t\t\tcoll.set(key, value);\n\t\t\t}\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * The subtract method returns a new structure containing items where the keys and values of the original structure are not present in the other.\n\t *\n\t * @param other - The other Collection to filter against\n\t */\n\tpublic subtract<T>(other: ReadonlyCollection<K, T>): Collection<K, V> {\n\t\tconst coll = new this.constructor[Symbol.species]<K, V>();\n\t\tfor (const [key, value] of this) {\n\t\t\tif (!other.has(key) || !Object.is(value, other.get(key))) {\n\t\t\t\tcoll.set(key, value);\n\t\t\t}\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.\n\t *\n\t * @param other - The other Collection to filter against\n\t */\n\tpublic difference<T>(other: ReadonlyCollection<K, T>): Collection<K, T | V> {\n\t\tconst coll = new this.constructor[Symbol.species]<K, T | V>();\n\t\tfor (const [key, value] of other) {\n\t\t\tif (!this.has(key)) coll.set(key, value);\n\t\t}\n\n\t\tfor (const [key, value] of this) {\n\t\t\tif (!other.has(key)) coll.set(key, value);\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Merges two Collections together into a new Collection.\n\t *\n\t * @param other - The other Collection to merge with\n\t * @param whenInSelf - Function getting the result if the entry only exists in this Collection\n\t * @param whenInOther - Function getting the result if the entry only exists in the other Collection\n\t * @param whenInBoth - Function getting the result if the entry exists in both Collections\n\t * @example\n\t * ```ts\n\t * // Sums up the entries in two collections.\n\t * coll.merge(\n\t * other,\n\t * x => ({ keep: true, value: x }),\n\t * y => ({ keep: true, value: y }),\n\t * (x, y) => ({ keep: true, value: x + y }),\n\t * );\n\t * ```\n\t * @example\n\t * ```ts\n\t * // Intersects two collections in a left-biased manner.\n\t * coll.merge(\n\t * other,\n\t * x => ({ keep: false }),\n\t * y => ({ keep: false }),\n\t * (x, _) => ({ keep: true, value: x }),\n\t * );\n\t * ```\n\t */\n\tpublic merge<T, R>(\n\t\tother: ReadonlyCollection<K, T>,\n\t\twhenInSelf: (value: V, key: K) => Keep<R>,\n\t\twhenInOther: (valueOther: T, key: K) => Keep<R>,\n\t\twhenInBoth: (value: V, valueOther: T, key: K) => Keep<R>,\n\t): Collection<K, R> {\n\t\tconst coll = new this.constructor[Symbol.species]<K, R>();\n\t\tconst keys = new Set([...this.keys(), ...other.keys()]);\n\n\t\tfor (const key of keys) {\n\t\t\tconst hasInSelf = this.has(key);\n\t\t\tconst hasInOther = other.has(key);\n\n\t\t\tif (hasInSelf && hasInOther) {\n\t\t\t\tconst result = whenInBoth(this.get(key)!, other.get(key)!, key);\n\t\t\t\tif (result.keep) coll.set(key, result.value);\n\t\t\t} else if (hasInSelf) {\n\t\t\t\tconst result = whenInSelf(this.get(key)!, key);\n\t\t\t\tif (result.keep) coll.set(key, result.value);\n\t\t\t} else if (hasInOther) {\n\t\t\t\tconst result = whenInOther(other.get(key)!, key);\n\t\t\t\tif (result.keep) coll.set(key, result.value);\n\t\t\t}\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * The sorted method sorts the items of a collection and returns it.\n\t * The sort is not necessarily stable in Node 10 or older.\n\t * The default sort order is according to string Unicode code points.\n\t *\n\t * @param compareFunction - Specifies a function that defines the sort order.\n\t * If omitted, the collection is sorted according to each character's Unicode code point value,\n\t * according to the string conversion of each element.\n\t * @example\n\t * ```ts\n\t * collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);\n\t * ```\n\t */\n\tpublic sorted(compareFunction: Comparator<K, V> = Collection.defaultSort) {\n\t\treturn new this.constructor[Symbol.species](this).sort((av, bv, ak, bk) => compareFunction(av, bv, ak, bk));\n\t}\n\n\tpublic toJSON() {\n\t\t// toJSON is called recursively by JSON.stringify.\n\t\treturn [...this.values()];\n\t}\n\n\tprivate static defaultSort<V>(firstValue: V, secondValue: V): number {\n\t\treturn Number(firstValue > secondValue) || Number(firstValue === secondValue) - 1;\n\t}\n\n\t/**\n\t * Creates a Collection from a list of entries.\n\t *\n\t * @param entries - The list of entries\n\t * @param combine - Function to combine an existing entry with a new one\n\t * @example\n\t * ```ts\n\t * Collection.combineEntries([[\"a\", 1], [\"b\", 2], [\"a\", 2]], (x, y) => x + y);\n\t * // returns Collection { \"a\" => 3, \"b\" => 2 }\n\t * ```\n\t */\n\tpublic static combineEntries<K, V>(\n\t\tentries: Iterable<[K, V]>,\n\t\tcombine: (firstValue: V, secondValue: V, key: K) => V,\n\t): Collection<K, V> {\n\t\tconst coll = new Collection<K, V>();\n\t\tfor (const [key, value] of entries) {\n\t\t\tif (coll.has(key)) {\n\t\t\t\tcoll.set(key, combine(coll.get(key)!, value, key));\n\t\t\t} else {\n\t\t\t\tcoll.set(key, value);\n\t\t\t}\n\t\t}\n\n\t\treturn coll;\n\t}\n}\n\n/**\n * @internal\n */\nexport type Keep<V> = { keep: false } | { keep: true; value: V };\n\n/**\n * @internal\n */\nexport type Comparator<K, V> = (firstValue: V, secondValue: V, firstKey: K, secondKey: K) => number;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACqCO,IAAM,aAAN,MAAM,oBAAyB,IAAU;AAAA,EArChD,OAqCgD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWxC,OAAO,KAAQ,uBAA2D;AAChF,QAAI,KAAK,IAAI,GAAG;AAAG,aAAO,KAAK,IAAI,GAAG;AACtC,QAAI,OAAO,0BAA0B;AAAY,YAAM,IAAI,UAAU,GAAG,qBAAqB,oBAAoB;AACjH,UAAM,eAAe,sBAAsB,KAAK,IAAI;AACpD,SAAK,IAAI,KAAK,YAAY;AAC1B,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,UAAU,MAAW;AAC3B,WAAO,KAAK,MAAM,CAAC,QAAQ,MAAM,IAAI,GAAG,CAAC;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,UAAU,MAAW;AAC3B,WAAO,KAAK,KAAK,CAAC,QAAQ,MAAM,IAAI,GAAG,CAAC;AAAA,EACzC;AAAA,EAUO,MAAM,QAAsC;AAClD,QAAI,WAAW;AAAW,aAAO,KAAK,OAAO,EAAE,KAAK,EAAE;AACtD,QAAI,SAAS;AAAG,aAAO,KAAK,KAAK,SAAS,EAAE;AAC5C,aAAS,KAAK,IAAI,KAAK,MAAM,MAAM;AACnC,UAAM,OAAO,KAAK,OAAO;AACzB,WAAO,MAAM,KAAK,EAAE,QAAQ,OAAO,GAAG,MAAS,KAAK,KAAK,EAAE,KAAK;AAAA,EACjE;AAAA,EAWO,SAAS,QAAsC;AACrD,QAAI,WAAW;AAAW,aAAO,KAAK,KAAK,EAAE,KAAK,EAAE;AACpD,QAA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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var __defProp = Object.defineProperty;
|
2 |
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
3 |
+
|
4 |
+
// src/collection.ts
|
5 |
+
var Collection = class _Collection extends Map {
|
6 |
+
static {
|
7 |
+
__name(this, "Collection");
|
8 |
+
}
|
9 |
+
/**
|
10 |
+
* Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.
|
11 |
+
*
|
12 |
+
* @param key - The key to get if it exists, or set otherwise
|
13 |
+
* @param defaultValueGenerator - A function that generates the default value
|
14 |
+
* @example
|
15 |
+
* ```ts
|
16 |
+
* collection.ensure(guildId, () => defaultGuildConfig);
|
17 |
+
* ```
|
18 |
+
*/
|
19 |
+
ensure(key, defaultValueGenerator) {
|
20 |
+
if (this.has(key))
|
21 |
+
return this.get(key);
|
22 |
+
if (typeof defaultValueGenerator !== "function")
|
23 |
+
throw new TypeError(`${defaultValueGenerator} is not a function`);
|
24 |
+
const defaultValue = defaultValueGenerator(key, this);
|
25 |
+
this.set(key, defaultValue);
|
26 |
+
return defaultValue;
|
27 |
+
}
|
28 |
+
/**
|
29 |
+
* Checks if all of the elements exist in the collection.
|
30 |
+
*
|
31 |
+
* @param keys - The keys of the elements to check for
|
32 |
+
* @returns `true` if all of the elements exist, `false` if at least one does not exist.
|
33 |
+
*/
|
34 |
+
hasAll(...keys) {
|
35 |
+
return keys.every((key) => super.has(key));
|
36 |
+
}
|
37 |
+
/**
|
38 |
+
* Checks if any of the elements exist in the collection.
|
39 |
+
*
|
40 |
+
* @param keys - The keys of the elements to check for
|
41 |
+
* @returns `true` if any of the elements exist, `false` if none exist.
|
42 |
+
*/
|
43 |
+
hasAny(...keys) {
|
44 |
+
return keys.some((key) => super.has(key));
|
45 |
+
}
|
46 |
+
first(amount) {
|
47 |
+
if (amount === void 0)
|
48 |
+
return this.values().next().value;
|
49 |
+
if (amount < 0)
|
50 |
+
return this.last(amount * -1);
|
51 |
+
amount = Math.min(this.size, amount);
|
52 |
+
const iter = this.values();
|
53 |
+
return Array.from({ length: amount }, () => iter.next().value);
|
54 |
+
}
|
55 |
+
firstKey(amount) {
|
56 |
+
if (amount === void 0)
|
57 |
+
return this.keys().next().value;
|
58 |
+
if (amount < 0)
|
59 |
+
return this.lastKey(amount * -1);
|
60 |
+
amount = Math.min(this.size, amount);
|
61 |
+
const iter = this.keys();
|
62 |
+
return Array.from({ length: amount }, () => iter.next().value);
|
63 |
+
}
|
64 |
+
last(amount) {
|
65 |
+
const arr = [...this.values()];
|
66 |
+
if (amount === void 0)
|
67 |
+
return arr[arr.length - 1];
|
68 |
+
if (amount < 0)
|
69 |
+
return this.first(amount * -1);
|
70 |
+
if (!amount)
|
71 |
+
return [];
|
72 |
+
return arr.slice(-amount);
|
73 |
+
}
|
74 |
+
lastKey(amount) {
|
75 |
+
const arr = [...this.keys()];
|
76 |
+
if (amount === void 0)
|
77 |
+
return arr[arr.length - 1];
|
78 |
+
if (amount < 0)
|
79 |
+
return this.firstKey(amount * -1);
|
80 |
+
if (!amount)
|
81 |
+
return [];
|
82 |
+
return arr.slice(-amount);
|
83 |
+
}
|
84 |
+
/**
|
85 |
+
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
86 |
+
* Returns the item at a given index, allowing for positive and negative integers.
|
87 |
+
* Negative integers count back from the last item in the collection.
|
88 |
+
*
|
89 |
+
* @param index - The index of the element to obtain
|
90 |
+
*/
|
91 |
+
at(index) {
|
92 |
+
index = Math.floor(index);
|
93 |
+
const arr = [...this.values()];
|
94 |
+
return arr.at(index);
|
95 |
+
}
|
96 |
+
/**
|
97 |
+
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
|
98 |
+
* Returns the key at a given index, allowing for positive and negative integers.
|
99 |
+
* Negative integers count back from the last item in the collection.
|
100 |
+
*
|
101 |
+
* @param index - The index of the key to obtain
|
102 |
+
*/
|
103 |
+
keyAt(index) {
|
104 |
+
index = Math.floor(index);
|
105 |
+
const arr = [...this.keys()];
|
106 |
+
return arr.at(index);
|
107 |
+
}
|
108 |
+
random(amount) {
|
109 |
+
const arr = [...this.values()];
|
110 |
+
if (amount === void 0)
|
111 |
+
return arr[Math.floor(Math.random() * arr.length)];
|
112 |
+
if (!arr.length || !amount)
|
113 |
+
return [];
|
114 |
+
return Array.from(
|
115 |
+
{ length: Math.min(amount, arr.length) },
|
116 |
+
() => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]
|
117 |
+
);
|
118 |
+
}
|
119 |
+
randomKey(amount) {
|
120 |
+
const arr = [...this.keys()];
|
121 |
+
if (amount === void 0)
|
122 |
+
return arr[Math.floor(Math.random() * arr.length)];
|
123 |
+
if (!arr.length || !amount)
|
124 |
+
return [];
|
125 |
+
return Array.from(
|
126 |
+
{ length: Math.min(amount, arr.length) },
|
127 |
+
() => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]
|
128 |
+
);
|
129 |
+
}
|
130 |
+
/**
|
131 |
+
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}
|
132 |
+
* but returns a Collection instead of an Array.
|
133 |
+
*/
|
134 |
+
reverse() {
|
135 |
+
const entries = [...this.entries()].reverse();
|
136 |
+
this.clear();
|
137 |
+
for (const [key, value] of entries)
|
138 |
+
this.set(key, value);
|
139 |
+
return this;
|
140 |
+
}
|
141 |
+
find(fn, thisArg) {
|
142 |
+
if (typeof fn !== "function")
|
143 |
+
throw new TypeError(`${fn} is not a function`);
|
144 |
+
if (thisArg !== void 0)
|
145 |
+
fn = fn.bind(thisArg);
|
146 |
+
for (const [key, val] of this) {
|
147 |
+
if (fn(val, key, this))
|
148 |
+
return val;
|
149 |
+
}
|
150 |
+
return void 0;
|
151 |
+
}
|
152 |
+
findKey(fn, thisArg) {
|
153 |
+
if (typeof fn !== "function")
|
154 |
+
throw new TypeError(`${fn} is not a function`);
|
155 |
+
if (thisArg !== void 0)
|
156 |
+
fn = fn.bind(thisArg);
|
157 |
+
for (const [key, val] of this) {
|
158 |
+
if (fn(val, key, this))
|
159 |
+
return key;
|
160 |
+
}
|
161 |
+
return void 0;
|
162 |
+
}
|
163 |
+
sweep(fn, thisArg) {
|
164 |
+
if (typeof fn !== "function")
|
165 |
+
throw new TypeError(`${fn} is not a function`);
|
166 |
+
if (thisArg !== void 0)
|
167 |
+
fn = fn.bind(thisArg);
|
168 |
+
const previousSize = this.size;
|
169 |
+
for (const [key, val] of this) {
|
170 |
+
if (fn(val, key, this))
|
171 |
+
this.delete(key);
|
172 |
+
}
|
173 |
+
return previousSize - this.size;
|
174 |
+
}
|
175 |
+
filter(fn, thisArg) {
|
176 |
+
if (typeof fn !== "function")
|
177 |
+
throw new TypeError(`${fn} is not a function`);
|
178 |
+
if (thisArg !== void 0)
|
179 |
+
fn = fn.bind(thisArg);
|
180 |
+
const results = new this.constructor[Symbol.species]();
|
181 |
+
for (const [key, val] of this) {
|
182 |
+
if (fn(val, key, this))
|
183 |
+
results.set(key, val);
|
184 |
+
}
|
185 |
+
return results;
|
186 |
+
}
|
187 |
+
partition(fn, thisArg) {
|
188 |
+
if (typeof fn !== "function")
|
189 |
+
throw new TypeError(`${fn} is not a function`);
|
190 |
+
if (thisArg !== void 0)
|
191 |
+
fn = fn.bind(thisArg);
|
192 |
+
const results = [
|
193 |
+
new this.constructor[Symbol.species](),
|
194 |
+
new this.constructor[Symbol.species]()
|
195 |
+
];
|
196 |
+
for (const [key, val] of this) {
|
197 |
+
if (fn(val, key, this)) {
|
198 |
+
results[0].set(key, val);
|
199 |
+
} else {
|
200 |
+
results[1].set(key, val);
|
201 |
+
}
|
202 |
+
}
|
203 |
+
return results;
|
204 |
+
}
|
205 |
+
flatMap(fn, thisArg) {
|
206 |
+
const collections = this.map(fn, thisArg);
|
207 |
+
return new this.constructor[Symbol.species]().concat(...collections);
|
208 |
+
}
|
209 |
+
map(fn, thisArg) {
|
210 |
+
if (typeof fn !== "function")
|
211 |
+
throw new TypeError(`${fn} is not a function`);
|
212 |
+
if (thisArg !== void 0)
|
213 |
+
fn = fn.bind(thisArg);
|
214 |
+
const iter = this.entries();
|
215 |
+
return Array.from({ length: this.size }, () => {
|
216 |
+
const [key, value] = iter.next().value;
|
217 |
+
return fn(value, key, this);
|
218 |
+
});
|
219 |
+
}
|
220 |
+
mapValues(fn, thisArg) {
|
221 |
+
if (typeof fn !== "function")
|
222 |
+
throw new TypeError(`${fn} is not a function`);
|
223 |
+
if (thisArg !== void 0)
|
224 |
+
fn = fn.bind(thisArg);
|
225 |
+
const coll = new this.constructor[Symbol.species]();
|
226 |
+
for (const [key, val] of this)
|
227 |
+
coll.set(key, fn(val, key, this));
|
228 |
+
return coll;
|
229 |
+
}
|
230 |
+
some(fn, thisArg) {
|
231 |
+
if (typeof fn !== "function")
|
232 |
+
throw new TypeError(`${fn} is not a function`);
|
233 |
+
if (thisArg !== void 0)
|
234 |
+
fn = fn.bind(thisArg);
|
235 |
+
for (const [key, val] of this) {
|
236 |
+
if (fn(val, key, this))
|
237 |
+
return true;
|
238 |
+
}
|
239 |
+
return false;
|
240 |
+
}
|
241 |
+
every(fn, thisArg) {
|
242 |
+
if (typeof fn !== "function")
|
243 |
+
throw new TypeError(`${fn} is not a function`);
|
244 |
+
if (thisArg !== void 0)
|
245 |
+
fn = fn.bind(thisArg);
|
246 |
+
for (const [key, val] of this) {
|
247 |
+
if (!fn(val, key, this))
|
248 |
+
return false;
|
249 |
+
}
|
250 |
+
return true;
|
251 |
+
}
|
252 |
+
/**
|
253 |
+
* Applies a function to produce a single value. Identical in behavior to
|
254 |
+
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.
|
255 |
+
*
|
256 |
+
* @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
|
257 |
+
* and `collection`
|
258 |
+
* @param initialValue - Starting value for the accumulator
|
259 |
+
* @example
|
260 |
+
* ```ts
|
261 |
+
* collection.reduce((acc, guild) => acc + guild.memberCount, 0);
|
262 |
+
* ```
|
263 |
+
*/
|
264 |
+
reduce(fn, initialValue) {
|
265 |
+
if (typeof fn !== "function")
|
266 |
+
throw new TypeError(`${fn} is not a function`);
|
267 |
+
let accumulator;
|
268 |
+
const iterator = this.entries();
|
269 |
+
if (initialValue === void 0) {
|
270 |
+
if (this.size === 0)
|
271 |
+
throw new TypeError("Reduce of empty collection with no initial value");
|
272 |
+
accumulator = iterator.next().value[1];
|
273 |
+
} else {
|
274 |
+
accumulator = initialValue;
|
275 |
+
}
|
276 |
+
for (const [key, value] of iterator) {
|
277 |
+
accumulator = fn(accumulator, value, key, this);
|
278 |
+
}
|
279 |
+
return accumulator;
|
280 |
+
}
|
281 |
+
each(fn, thisArg) {
|
282 |
+
if (typeof fn !== "function")
|
283 |
+
throw new TypeError(`${fn} is not a function`);
|
284 |
+
if (thisArg !== void 0)
|
285 |
+
fn = fn.bind(thisArg);
|
286 |
+
for (const [key, value] of this) {
|
287 |
+
fn(value, key, this);
|
288 |
+
}
|
289 |
+
return this;
|
290 |
+
}
|
291 |
+
tap(fn, thisArg) {
|
292 |
+
if (typeof fn !== "function")
|
293 |
+
throw new TypeError(`${fn} is not a function`);
|
294 |
+
if (thisArg !== void 0)
|
295 |
+
fn = fn.bind(thisArg);
|
296 |
+
fn(this);
|
297 |
+
return this;
|
298 |
+
}
|
299 |
+
/**
|
300 |
+
* Creates an identical shallow copy of this collection.
|
301 |
+
*
|
302 |
+
* @example
|
303 |
+
* ```ts
|
304 |
+
* const newColl = someColl.clone();
|
305 |
+
* ```
|
306 |
+
*/
|
307 |
+
clone() {
|
308 |
+
return new this.constructor[Symbol.species](this);
|
309 |
+
}
|
310 |
+
/**
|
311 |
+
* Combines this collection with others into a new collection. None of the source collections are modified.
|
312 |
+
*
|
313 |
+
* @param collections - Collections to merge
|
314 |
+
* @example
|
315 |
+
* ```ts
|
316 |
+
* const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);
|
317 |
+
* ```
|
318 |
+
*/
|
319 |
+
concat(...collections) {
|
320 |
+
const newColl = this.clone();
|
321 |
+
for (const coll of collections) {
|
322 |
+
for (const [key, val] of coll)
|
323 |
+
newColl.set(key, val);
|
324 |
+
}
|
325 |
+
return newColl;
|
326 |
+
}
|
327 |
+
/**
|
328 |
+
* Checks if this collection shares identical items with another.
|
329 |
+
* This is different to checking for equality using equal-signs, because
|
330 |
+
* the collections may be different objects, but contain the same data.
|
331 |
+
*
|
332 |
+
* @param collection - Collection to compare with
|
333 |
+
* @returns Whether the collections have identical contents
|
334 |
+
*/
|
335 |
+
equals(collection) {
|
336 |
+
if (!collection)
|
337 |
+
return false;
|
338 |
+
if (this === collection)
|
339 |
+
return true;
|
340 |
+
if (this.size !== collection.size)
|
341 |
+
return false;
|
342 |
+
for (const [key, value] of this) {
|
343 |
+
if (!collection.has(key) || value !== collection.get(key)) {
|
344 |
+
return false;
|
345 |
+
}
|
346 |
+
}
|
347 |
+
return true;
|
348 |
+
}
|
349 |
+
/**
|
350 |
+
* The sort method sorts the items of a collection in place and returns it.
|
351 |
+
* The sort is not necessarily stable in Node 10 or older.
|
352 |
+
* The default sort order is according to string Unicode code points.
|
353 |
+
*
|
354 |
+
* @param compareFunction - Specifies a function that defines the sort order.
|
355 |
+
* If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element.
|
356 |
+
* @example
|
357 |
+
* ```ts
|
358 |
+
* collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
359 |
+
* ```
|
360 |
+
*/
|
361 |
+
sort(compareFunction = _Collection.defaultSort) {
|
362 |
+
const entries = [...this.entries()];
|
363 |
+
entries.sort((a, b) => compareFunction(a[1], b[1], a[0], b[0]));
|
364 |
+
super.clear();
|
365 |
+
for (const [key, value] of entries) {
|
366 |
+
super.set(key, value);
|
367 |
+
}
|
368 |
+
return this;
|
369 |
+
}
|
370 |
+
/**
|
371 |
+
* The intersect method returns a new structure containing items where the keys and values are present in both original structures.
|
372 |
+
*
|
373 |
+
* @param other - The other Collection to filter against
|
374 |
+
*/
|
375 |
+
intersect(other) {
|
376 |
+
const coll = new this.constructor[Symbol.species]();
|
377 |
+
for (const [key, value] of other) {
|
378 |
+
if (this.has(key) && Object.is(value, this.get(key))) {
|
379 |
+
coll.set(key, value);
|
380 |
+
}
|
381 |
+
}
|
382 |
+
return coll;
|
383 |
+
}
|
384 |
+
/**
|
385 |
+
* The subtract method returns a new structure containing items where the keys and values of the original structure are not present in the other.
|
386 |
+
*
|
387 |
+
* @param other - The other Collection to filter against
|
388 |
+
*/
|
389 |
+
subtract(other) {
|
390 |
+
const coll = new this.constructor[Symbol.species]();
|
391 |
+
for (const [key, value] of this) {
|
392 |
+
if (!other.has(key) || !Object.is(value, other.get(key))) {
|
393 |
+
coll.set(key, value);
|
394 |
+
}
|
395 |
+
}
|
396 |
+
return coll;
|
397 |
+
}
|
398 |
+
/**
|
399 |
+
* The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.
|
400 |
+
*
|
401 |
+
* @param other - The other Collection to filter against
|
402 |
+
*/
|
403 |
+
difference(other) {
|
404 |
+
const coll = new this.constructor[Symbol.species]();
|
405 |
+
for (const [key, value] of other) {
|
406 |
+
if (!this.has(key))
|
407 |
+
coll.set(key, value);
|
408 |
+
}
|
409 |
+
for (const [key, value] of this) {
|
410 |
+
if (!other.has(key))
|
411 |
+
coll.set(key, value);
|
412 |
+
}
|
413 |
+
return coll;
|
414 |
+
}
|
415 |
+
/**
|
416 |
+
* Merges two Collections together into a new Collection.
|
417 |
+
*
|
418 |
+
* @param other - The other Collection to merge with
|
419 |
+
* @param whenInSelf - Function getting the result if the entry only exists in this Collection
|
420 |
+
* @param whenInOther - Function getting the result if the entry only exists in the other Collection
|
421 |
+
* @param whenInBoth - Function getting the result if the entry exists in both Collections
|
422 |
+
* @example
|
423 |
+
* ```ts
|
424 |
+
* // Sums up the entries in two collections.
|
425 |
+
* coll.merge(
|
426 |
+
* other,
|
427 |
+
* x => ({ keep: true, value: x }),
|
428 |
+
* y => ({ keep: true, value: y }),
|
429 |
+
* (x, y) => ({ keep: true, value: x + y }),
|
430 |
+
* );
|
431 |
+
* ```
|
432 |
+
* @example
|
433 |
+
* ```ts
|
434 |
+
* // Intersects two collections in a left-biased manner.
|
435 |
+
* coll.merge(
|
436 |
+
* other,
|
437 |
+
* x => ({ keep: false }),
|
438 |
+
* y => ({ keep: false }),
|
439 |
+
* (x, _) => ({ keep: true, value: x }),
|
440 |
+
* );
|
441 |
+
* ```
|
442 |
+
*/
|
443 |
+
merge(other, whenInSelf, whenInOther, whenInBoth) {
|
444 |
+
const coll = new this.constructor[Symbol.species]();
|
445 |
+
const keys = /* @__PURE__ */ new Set([...this.keys(), ...other.keys()]);
|
446 |
+
for (const key of keys) {
|
447 |
+
const hasInSelf = this.has(key);
|
448 |
+
const hasInOther = other.has(key);
|
449 |
+
if (hasInSelf && hasInOther) {
|
450 |
+
const result = whenInBoth(this.get(key), other.get(key), key);
|
451 |
+
if (result.keep)
|
452 |
+
coll.set(key, result.value);
|
453 |
+
} else if (hasInSelf) {
|
454 |
+
const result = whenInSelf(this.get(key), key);
|
455 |
+
if (result.keep)
|
456 |
+
coll.set(key, result.value);
|
457 |
+
} else if (hasInOther) {
|
458 |
+
const result = whenInOther(other.get(key), key);
|
459 |
+
if (result.keep)
|
460 |
+
coll.set(key, result.value);
|
461 |
+
}
|
462 |
+
}
|
463 |
+
return coll;
|
464 |
+
}
|
465 |
+
/**
|
466 |
+
* The sorted method sorts the items of a collection and returns it.
|
467 |
+
* The sort is not necessarily stable in Node 10 or older.
|
468 |
+
* The default sort order is according to string Unicode code points.
|
469 |
+
*
|
470 |
+
* @param compareFunction - Specifies a function that defines the sort order.
|
471 |
+
* If omitted, the collection is sorted according to each character's Unicode code point value,
|
472 |
+
* according to the string conversion of each element.
|
473 |
+
* @example
|
474 |
+
* ```ts
|
475 |
+
* collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);
|
476 |
+
* ```
|
477 |
+
*/
|
478 |
+
sorted(compareFunction = _Collection.defaultSort) {
|
479 |
+
return new this.constructor[Symbol.species](this).sort((av, bv, ak, bk) => compareFunction(av, bv, ak, bk));
|
480 |
+
}
|
481 |
+
toJSON() {
|
482 |
+
return [...this.values()];
|
483 |
+
}
|
484 |
+
static defaultSort(firstValue, secondValue) {
|
485 |
+
return Number(firstValue > secondValue) || Number(firstValue === secondValue) - 1;
|
486 |
+
}
|
487 |
+
/**
|
488 |
+
* Creates a Collection from a list of entries.
|
489 |
+
*
|
490 |
+
* @param entries - The list of entries
|
491 |
+
* @param combine - Function to combine an existing entry with a new one
|
492 |
+
* @example
|
493 |
+
* ```ts
|
494 |
+
* Collection.combineEntries([["a", 1], ["b", 2], ["a", 2]], (x, y) => x + y);
|
495 |
+
* // returns Collection { "a" => 3, "b" => 2 }
|
496 |
+
* ```
|
497 |
+
*/
|
498 |
+
static combineEntries(entries, combine) {
|
499 |
+
const coll = new _Collection();
|
500 |
+
for (const [key, value] of entries) {
|
501 |
+
if (coll.has(key)) {
|
502 |
+
coll.set(key, combine(coll.get(key), value, key));
|
503 |
+
} else {
|
504 |
+
coll.set(key, value);
|
505 |
+
}
|
506 |
+
}
|
507 |
+
return coll;
|
508 |
+
}
|
509 |
+
};
|
510 |
+
|
511 |
+
// src/index.ts
|
512 |
+
var version = "1.5.3";
|
513 |
+
export {
|
514 |
+
Collection,
|
515 |
+
version
|
516 |
+
};
|
517 |
+
//# sourceMappingURL=index.mjs.map
|
node_modules/@discordjs/collection/dist/index.mjs.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"sources":["../src/collection.ts","../src/index.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\n/**\n * @internal\n */\nexport interface CollectionConstructor {\n\tnew (): Collection<unknown, unknown>;\n\tnew <K, V>(entries?: readonly (readonly [K, V])[] | null): Collection<K, V>;\n\tnew <K, V>(iterable: Iterable<readonly [K, V]>): Collection<K, V>;\n\treadonly prototype: Collection<unknown, unknown>;\n\treadonly [Symbol.species]: CollectionConstructor;\n}\n\n/**\n * Represents an immutable version of a collection\n */\nexport type ReadonlyCollection<K, V> = Omit<\n\tCollection<K, V>,\n\t'delete' | 'ensure' | 'forEach' | 'get' | 'reverse' | 'set' | 'sort' | 'sweep'\n> &\n\tReadonlyMap<K, V>;\n\n/**\n * Separate interface for the constructor so that emitted js does not have a constructor that overwrites itself\n *\n * @internal\n */\nexport interface Collection<K, V> extends Map<K, V> {\n\tconstructor: CollectionConstructor;\n}\n\n/**\n * A Map with additional utility methods. This is used throughout discord.js rather than Arrays for anything that has\n * an ID, for significantly improved performance and ease-of-use.\n *\n * @typeParam K - The key type this collection holds\n * @typeParam V - The value type this collection holds\n */\nexport class Collection<K, V> extends Map<K, V> {\n\t/**\n\t * Obtains the value of the given key if it exists, otherwise sets and returns the value provided by the default value generator.\n\t *\n\t * @param key - The key to get if it exists, or set otherwise\n\t * @param defaultValueGenerator - A function that generates the default value\n\t * @example\n\t * ```ts\n\t * collection.ensure(guildId, () => defaultGuildConfig);\n\t * ```\n\t */\n\tpublic ensure(key: K, defaultValueGenerator: (key: K, collection: this) => V): V {\n\t\tif (this.has(key)) return this.get(key)!;\n\t\tif (typeof defaultValueGenerator !== 'function') throw new TypeError(`${defaultValueGenerator} is not a function`);\n\t\tconst defaultValue = defaultValueGenerator(key, this);\n\t\tthis.set(key, defaultValue);\n\t\treturn defaultValue;\n\t}\n\n\t/**\n\t * Checks if all of the elements exist in the collection.\n\t *\n\t * @param keys - The keys of the elements to check for\n\t * @returns `true` if all of the elements exist, `false` if at least one does not exist.\n\t */\n\tpublic hasAll(...keys: K[]) {\n\t\treturn keys.every((key) => super.has(key));\n\t}\n\n\t/**\n\t * Checks if any of the elements exist in the collection.\n\t *\n\t * @param keys - The keys of the elements to check for\n\t * @returns `true` if any of the elements exist, `false` if none exist.\n\t */\n\tpublic hasAny(...keys: K[]) {\n\t\treturn keys.some((key) => super.has(key));\n\t}\n\n\t/**\n\t * Obtains the first value(s) in this collection.\n\t *\n\t * @param amount - Amount of values to obtain from the beginning\n\t * @returns A single value if no amount is provided or an array of values, starting from the end if amount is negative\n\t */\n\tpublic first(): V | undefined;\n\tpublic first(amount: number): V[];\n\tpublic first(amount?: number): V | V[] | undefined {\n\t\tif (amount === undefined) return this.values().next().value;\n\t\tif (amount < 0) return this.last(amount * -1);\n\t\tamount = Math.min(this.size, amount);\n\t\tconst iter = this.values();\n\t\treturn Array.from({ length: amount }, (): V => iter.next().value);\n\t}\n\n\t/**\n\t * Obtains the first key(s) in this collection.\n\t *\n\t * @param amount - Amount of keys to obtain from the beginning\n\t * @returns A single key if no amount is provided or an array of keys, starting from the end if\n\t * amount is negative\n\t */\n\tpublic firstKey(): K | undefined;\n\tpublic firstKey(amount: number): K[];\n\tpublic firstKey(amount?: number): K | K[] | undefined {\n\t\tif (amount === undefined) return this.keys().next().value;\n\t\tif (amount < 0) return this.lastKey(amount * -1);\n\t\tamount = Math.min(this.size, amount);\n\t\tconst iter = this.keys();\n\t\treturn Array.from({ length: amount }, (): K => iter.next().value);\n\t}\n\n\t/**\n\t * Obtains the last value(s) in this collection.\n\t *\n\t * @param amount - Amount of values to obtain from the end\n\t * @returns A single value if no amount is provided or an array of values, starting from the start if\n\t * amount is negative\n\t */\n\tpublic last(): V | undefined;\n\tpublic last(amount: number): V[];\n\tpublic last(amount?: number): V | V[] | undefined {\n\t\tconst arr = [...this.values()];\n\t\tif (amount === undefined) return arr[arr.length - 1];\n\t\tif (amount < 0) return this.first(amount * -1);\n\t\tif (!amount) return [];\n\t\treturn arr.slice(-amount);\n\t}\n\n\t/**\n\t * Obtains the last key(s) in this collection.\n\t *\n\t * @param amount - Amount of keys to obtain from the end\n\t * @returns A single key if no amount is provided or an array of keys, starting from the start if\n\t * amount is negative\n\t */\n\tpublic lastKey(): K | undefined;\n\tpublic lastKey(amount: number): K[];\n\tpublic lastKey(amount?: number): K | K[] | undefined {\n\t\tconst arr = [...this.keys()];\n\t\tif (amount === undefined) return arr[arr.length - 1];\n\t\tif (amount < 0) return this.firstKey(amount * -1);\n\t\tif (!amount) return [];\n\t\treturn arr.slice(-amount);\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.\n\t * Returns the item at a given index, allowing for positive and negative integers.\n\t * Negative integers count back from the last item in the collection.\n\t *\n\t * @param index - The index of the element to obtain\n\t */\n\tpublic at(index: number) {\n\t\tindex = Math.floor(index);\n\t\tconst arr = [...this.values()];\n\t\treturn arr.at(index);\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.\n\t * Returns the key at a given index, allowing for positive and negative integers.\n\t * Negative integers count back from the last item in the collection.\n\t *\n\t * @param index - The index of the key to obtain\n\t */\n\tpublic keyAt(index: number) {\n\t\tindex = Math.floor(index);\n\t\tconst arr = [...this.keys()];\n\t\treturn arr.at(index);\n\t}\n\n\t/**\n\t * Obtains unique random value(s) from this collection.\n\t *\n\t * @param amount - Amount of values to obtain randomly\n\t * @returns A single value if no amount is provided or an array of values\n\t */\n\tpublic random(): V | undefined;\n\tpublic random(amount: number): V[];\n\tpublic random(amount?: number): V | V[] | undefined {\n\t\tconst arr = [...this.values()];\n\t\tif (amount === undefined) return arr[Math.floor(Math.random() * arr.length)];\n\t\tif (!arr.length || !amount) return [];\n\t\treturn Array.from(\n\t\t\t{ length: Math.min(amount, arr.length) },\n\t\t\t(): V => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]!,\n\t\t);\n\t}\n\n\t/**\n\t * Obtains unique random key(s) from this collection.\n\t *\n\t * @param amount - Amount of keys to obtain randomly\n\t * @returns A single key if no amount is provided or an array\n\t */\n\tpublic randomKey(): K | undefined;\n\tpublic randomKey(amount: number): K[];\n\tpublic randomKey(amount?: number): K | K[] | undefined {\n\t\tconst arr = [...this.keys()];\n\t\tif (amount === undefined) return arr[Math.floor(Math.random() * arr.length)];\n\t\tif (!arr.length || !amount) return [];\n\t\treturn Array.from(\n\t\t\t{ length: Math.min(amount, arr.length) },\n\t\t\t(): K => arr.splice(Math.floor(Math.random() * arr.length), 1)[0]!,\n\t\t);\n\t}\n\n\t/**\n\t * Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}\n\t * but returns a Collection instead of an Array.\n\t */\n\tpublic reverse() {\n\t\tconst entries = [...this.entries()].reverse();\n\t\tthis.clear();\n\t\tfor (const [key, value] of entries) this.set(key, value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Searches for a single item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find | Array.find()}.\n\t * All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you\n\t * should use the `get` method. See\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get | MDN} for details.\n\t *\n\t * @param fn - The function to test with (should return boolean)\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection.find(user => user.username === 'Bob');\n\t * ```\n\t */\n\tpublic find<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): V2 | undefined;\n\tpublic find(fn: (value: V, key: K, collection: this) => unknown): V | undefined;\n\tpublic find<This, V2 extends V>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => value is V2,\n\t\tthisArg: This,\n\t): V2 | undefined;\n\tpublic find<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): V | undefined;\n\tpublic find(fn: (value: V, key: K, collection: this) => unknown, thisArg?: unknown): V | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) return val;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Searches for the key of a single item where the given function returns a truthy value. This behaves like\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex | Array.findIndex()},\n\t * but returns the key rather than the positional index.\n\t *\n\t * @param fn - The function to test with (should return boolean)\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection.findKey(user => user.username === 'Bob');\n\t * ```\n\t */\n\tpublic findKey<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): K2 | undefined;\n\tpublic findKey(fn: (value: V, key: K, collection: this) => unknown): K | undefined;\n\tpublic findKey<This, K2 extends K>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => key is K2,\n\t\tthisArg: This,\n\t): K2 | undefined;\n\tpublic findKey<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): K | undefined;\n\tpublic findKey(fn: (value: V, key: K, collection: this) => unknown, thisArg?: unknown): K | undefined {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) return key;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Removes items that satisfy the provided filter function.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @returns The number of removed entries\n\t */\n\tpublic sweep(fn: (value: V, key: K, collection: this) => unknown): number;\n\tpublic sweep<T>(fn: (this: T, value: V, key: K, collection: this) => unknown, thisArg: T): number;\n\tpublic sweep(fn: (value: V, key: K, collection: this) => unknown, thisArg?: unknown): number {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst previousSize = this.size;\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) this.delete(key);\n\t\t}\n\n\t\treturn previousSize - this.size;\n\t}\n\n\t/**\n\t * Identical to\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter | Array.filter()},\n\t * but returns a Collection instead of an Array.\n\t *\n\t * @param fn - The function to test with (should return boolean)\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection.filter(user => user.username === 'Bob');\n\t * ```\n\t */\n\tpublic filter<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): Collection<K2, V>;\n\tpublic filter<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): Collection<K, V2>;\n\tpublic filter(fn: (value: V, key: K, collection: this) => unknown): Collection<K, V>;\n\tpublic filter<This, K2 extends K>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => key is K2,\n\t\tthisArg: This,\n\t): Collection<K2, V>;\n\tpublic filter<This, V2 extends V>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => value is V2,\n\t\tthisArg: This,\n\t): Collection<K, V2>;\n\tpublic filter<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): Collection<K, V>;\n\tpublic filter(fn: (value: V, key: K, collection: this) => unknown, thisArg?: unknown): Collection<K, V> {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst results = new this.constructor[Symbol.species]<K, V>();\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) results.set(key, val);\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Partitions the collection into two collections where the first collection\n\t * contains the items that passed and the second contains the items that failed.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * const [big, small] = collection.partition(guild => guild.memberCount > 250);\n\t * ```\n\t */\n\tpublic partition<K2 extends K>(\n\t\tfn: (value: V, key: K, collection: this) => key is K2,\n\t): [Collection<K2, V>, Collection<Exclude<K, K2>, V>];\n\tpublic partition<V2 extends V>(\n\t\tfn: (value: V, key: K, collection: this) => value is V2,\n\t): [Collection<K, V2>, Collection<K, Exclude<V, V2>>];\n\tpublic partition(fn: (value: V, key: K, collection: this) => unknown): [Collection<K, V>, Collection<K, V>];\n\tpublic partition<This, K2 extends K>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => key is K2,\n\t\tthisArg: This,\n\t): [Collection<K2, V>, Collection<Exclude<K, K2>, V>];\n\tpublic partition<This, V2 extends V>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => value is V2,\n\t\tthisArg: This,\n\t): [Collection<K, V2>, Collection<K, Exclude<V, V2>>];\n\tpublic partition<This>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => unknown,\n\t\tthisArg: This,\n\t): [Collection<K, V>, Collection<K, V>];\n\tpublic partition(\n\t\tfn: (value: V, key: K, collection: this) => unknown,\n\t\tthisArg?: unknown,\n\t): [Collection<K, V>, Collection<K, V>] {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst results: [Collection<K, V>, Collection<K, V>] = [\n\t\t\tnew this.constructor[Symbol.species]<K, V>(),\n\t\t\tnew this.constructor[Symbol.species]<K, V>(),\n\t\t];\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) {\n\t\t\t\tresults[0].set(key, val);\n\t\t\t} else {\n\t\t\t\tresults[1].set(key, val);\n\t\t\t}\n\t\t}\n\n\t\treturn results;\n\t}\n\n\t/**\n\t * Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | Array.flatMap()}.\n\t *\n\t * @param fn - Function that produces a new Collection\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection.flatMap(guild => guild.members.cache);\n\t * ```\n\t */\n\tpublic flatMap<T>(fn: (value: V, key: K, collection: this) => Collection<K, T>): Collection<K, T>;\n\tpublic flatMap<T, This>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => Collection<K, T>,\n\t\tthisArg: This,\n\t): Collection<K, T>;\n\tpublic flatMap<T>(fn: (value: V, key: K, collection: this) => Collection<K, T>, thisArg?: unknown): Collection<K, T> {\n\t\t// eslint-disable-next-line unicorn/no-array-method-this-argument\n\t\tconst collections = this.map(fn, thisArg);\n\t\treturn new this.constructor[Symbol.species]<K, T>().concat(...collections);\n\t}\n\n\t/**\n\t * Maps each item to another value into an array. Identical in behavior to\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.\n\t *\n\t * @param fn - Function that produces an element of the new array, taking three arguments\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection.map(user => user.tag);\n\t * ```\n\t */\n\tpublic map<T>(fn: (value: V, key: K, collection: this) => T): T[];\n\tpublic map<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): T[];\n\tpublic map<T>(fn: (value: V, key: K, collection: this) => T, thisArg?: unknown): T[] {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst iter = this.entries();\n\t\treturn Array.from({ length: this.size }, (): T => {\n\t\t\tconst [key, value] = iter.next().value;\n\t\t\treturn fn(value, key, this);\n\t\t});\n\t}\n\n\t/**\n\t * Maps each item to another value into a collection. Identical in behavior to\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.\n\t *\n\t * @param fn - Function that produces an element of the new collection, taking three arguments\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection.mapValues(user => user.tag);\n\t * ```\n\t */\n\tpublic mapValues<T>(fn: (value: V, key: K, collection: this) => T): Collection<K, T>;\n\tpublic mapValues<This, T>(fn: (this: This, value: V, key: K, collection: this) => T, thisArg: This): Collection<K, T>;\n\tpublic mapValues<T>(fn: (value: V, key: K, collection: this) => T, thisArg?: unknown): Collection<K, T> {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tconst coll = new this.constructor[Symbol.species]<K, T>();\n\t\tfor (const [key, val] of this) coll.set(key, fn(val, key, this));\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Checks if there exists an item that passes a test. Identical in behavior to\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some | Array.some()}.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection.some(user => user.discriminator === '0000');\n\t * ```\n\t */\n\tpublic some(fn: (value: V, key: K, collection: this) => unknown): boolean;\n\tpublic some<T>(fn: (this: T, value: V, key: K, collection: this) => unknown, thisArg: T): boolean;\n\tpublic some(fn: (value: V, key: K, collection: this) => unknown, thisArg?: unknown): boolean {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const [key, val] of this) {\n\t\t\tif (fn(val, key, this)) return true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Checks if all items passes a test. Identical in behavior to\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every | Array.every()}.\n\t *\n\t * @param fn - Function used to test (should return a boolean)\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection.every(user => !user.bot);\n\t * ```\n\t */\n\tpublic every<K2 extends K>(fn: (value: V, key: K, collection: this) => key is K2): this is Collection<K2, V>;\n\tpublic every<V2 extends V>(fn: (value: V, key: K, collection: this) => value is V2): this is Collection<K, V2>;\n\tpublic every(fn: (value: V, key: K, collection: this) => unknown): boolean;\n\tpublic every<This, K2 extends K>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => key is K2,\n\t\tthisArg: This,\n\t): this is Collection<K2, V>;\n\tpublic every<This, V2 extends V>(\n\t\tfn: (this: This, value: V, key: K, collection: this) => value is V2,\n\t\tthisArg: This,\n\t): this is Collection<K, V2>;\n\tpublic every<This>(fn: (this: This, value: V, key: K, collection: this) => unknown, thisArg: This): boolean;\n\tpublic every(fn: (value: V, key: K, collection: this) => unknown, thisArg?: unknown): boolean {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfor (const [key, val] of this) {\n\t\t\tif (!fn(val, key, this)) return false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Applies a function to produce a single value. Identical in behavior to\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.\n\t *\n\t * @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,\n\t * and `collection`\n\t * @param initialValue - Starting value for the accumulator\n\t * @example\n\t * ```ts\n\t * collection.reduce((acc, guild) => acc + guild.memberCount, 0);\n\t * ```\n\t */\n\tpublic reduce<T = V>(fn: (accumulator: T, value: V, key: K, collection: this) => T, initialValue?: T): T {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tlet accumulator!: T;\n\n\t\tconst iterator = this.entries();\n\t\tif (initialValue === undefined) {\n\t\t\tif (this.size === 0) throw new TypeError('Reduce of empty collection with no initial value');\n\t\t\taccumulator = iterator.next().value[1];\n\t\t} else {\n\t\t\taccumulator = initialValue;\n\t\t}\n\n\t\tfor (const [key, value] of iterator) {\n\t\t\taccumulator = fn(accumulator, value, key, this);\n\t\t}\n\n\t\treturn accumulator;\n\t}\n\n\t/**\n\t * Identical to\n\t * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach | Map.forEach()},\n\t * but returns the collection instead of undefined.\n\t *\n\t * @param fn - Function to execute for each element\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection\n\t * .each(user => console.log(user.username))\n\t * .filter(user => user.bot)\n\t * .each(user => console.log(user.username));\n\t * ```\n\t */\n\tpublic each(fn: (value: V, key: K, collection: this) => void): this;\n\tpublic each<T>(fn: (this: T, value: V, key: K, collection: this) => void, thisArg: T): this;\n\tpublic each(fn: (value: V, key: K, collection: this) => void, thisArg?: unknown): this {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\n\t\tfor (const [key, value] of this) {\n\t\t\tfn(value, key, this);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Runs a function on the collection and returns the collection.\n\t *\n\t * @param fn - Function to execute\n\t * @param thisArg - Value to use as `this` when executing function\n\t * @example\n\t * ```ts\n\t * collection\n\t * .tap(coll => console.log(coll.size))\n\t * .filter(user => user.bot)\n\t * .tap(coll => console.log(coll.size))\n\t * ```\n\t */\n\tpublic tap(fn: (collection: this) => void): this;\n\tpublic tap<T>(fn: (this: T, collection: this) => void, thisArg: T): this;\n\tpublic tap(fn: (collection: this) => void, thisArg?: unknown): this {\n\t\tif (typeof fn !== 'function') throw new TypeError(`${fn} is not a function`);\n\t\tif (thisArg !== undefined) fn = fn.bind(thisArg);\n\t\tfn(this);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Creates an identical shallow copy of this collection.\n\t *\n\t * @example\n\t * ```ts\n\t * const newColl = someColl.clone();\n\t * ```\n\t */\n\tpublic clone(): Collection<K, V> {\n\t\treturn new this.constructor[Symbol.species](this);\n\t}\n\n\t/**\n\t * Combines this collection with others into a new collection. None of the source collections are modified.\n\t *\n\t * @param collections - Collections to merge\n\t * @example\n\t * ```ts\n\t * const newColl = someColl.concat(someOtherColl, anotherColl, ohBoyAColl);\n\t * ```\n\t */\n\tpublic concat(...collections: ReadonlyCollection<K, V>[]) {\n\t\tconst newColl = this.clone();\n\t\tfor (const coll of collections) {\n\t\t\tfor (const [key, val] of coll) newColl.set(key, val);\n\t\t}\n\n\t\treturn newColl;\n\t}\n\n\t/**\n\t * Checks if this collection shares identical items with another.\n\t * This is different to checking for equality using equal-signs, because\n\t * the collections may be different objects, but contain the same data.\n\t *\n\t * @param collection - Collection to compare with\n\t * @returns Whether the collections have identical contents\n\t */\n\tpublic equals(collection: ReadonlyCollection<K, V>) {\n\t\tif (!collection) return false; // runtime check\n\t\tif (this === collection) return true;\n\t\tif (this.size !== collection.size) return false;\n\t\tfor (const [key, value] of this) {\n\t\t\tif (!collection.has(key) || value !== collection.get(key)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * The sort method sorts the items of a collection in place and returns it.\n\t * The sort is not necessarily stable in Node 10 or older.\n\t * The default sort order is according to string Unicode code points.\n\t *\n\t * @param compareFunction - Specifies a function that defines the sort order.\n\t * If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each element.\n\t * @example\n\t * ```ts\n\t * collection.sort((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);\n\t * ```\n\t */\n\tpublic sort(compareFunction: Comparator<K, V> = Collection.defaultSort) {\n\t\tconst entries = [...this.entries()];\n\t\tentries.sort((a, b): number => compareFunction(a[1], b[1], a[0], b[0]));\n\n\t\t// Perform clean-up\n\t\tsuper.clear();\n\n\t\t// Set the new entries\n\t\tfor (const [key, value] of entries) {\n\t\t\tsuper.set(key, value);\n\t\t}\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * The intersect method returns a new structure containing items where the keys and values are present in both original structures.\n\t *\n\t * @param other - The other Collection to filter against\n\t */\n\tpublic intersect<T>(other: ReadonlyCollection<K, T>): Collection<K, T> {\n\t\tconst coll = new this.constructor[Symbol.species]<K, T>();\n\t\tfor (const [key, value] of other) {\n\t\t\tif (this.has(key) && Object.is(value, this.get(key))) {\n\t\t\t\tcoll.set(key, value);\n\t\t\t}\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * The subtract method returns a new structure containing items where the keys and values of the original structure are not present in the other.\n\t *\n\t * @param other - The other Collection to filter against\n\t */\n\tpublic subtract<T>(other: ReadonlyCollection<K, T>): Collection<K, V> {\n\t\tconst coll = new this.constructor[Symbol.species]<K, V>();\n\t\tfor (const [key, value] of this) {\n\t\t\tif (!other.has(key) || !Object.is(value, other.get(key))) {\n\t\t\t\tcoll.set(key, value);\n\t\t\t}\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * The difference method returns a new structure containing items where the key is present in one of the original structures but not the other.\n\t *\n\t * @param other - The other Collection to filter against\n\t */\n\tpublic difference<T>(other: ReadonlyCollection<K, T>): Collection<K, T | V> {\n\t\tconst coll = new this.constructor[Symbol.species]<K, T | V>();\n\t\tfor (const [key, value] of other) {\n\t\t\tif (!this.has(key)) coll.set(key, value);\n\t\t}\n\n\t\tfor (const [key, value] of this) {\n\t\t\tif (!other.has(key)) coll.set(key, value);\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * Merges two Collections together into a new Collection.\n\t *\n\t * @param other - The other Collection to merge with\n\t * @param whenInSelf - Function getting the result if the entry only exists in this Collection\n\t * @param whenInOther - Function getting the result if the entry only exists in the other Collection\n\t * @param whenInBoth - Function getting the result if the entry exists in both Collections\n\t * @example\n\t * ```ts\n\t * // Sums up the entries in two collections.\n\t * coll.merge(\n\t * other,\n\t * x => ({ keep: true, value: x }),\n\t * y => ({ keep: true, value: y }),\n\t * (x, y) => ({ keep: true, value: x + y }),\n\t * );\n\t * ```\n\t * @example\n\t * ```ts\n\t * // Intersects two collections in a left-biased manner.\n\t * coll.merge(\n\t * other,\n\t * x => ({ keep: false }),\n\t * y => ({ keep: false }),\n\t * (x, _) => ({ keep: true, value: x }),\n\t * );\n\t * ```\n\t */\n\tpublic merge<T, R>(\n\t\tother: ReadonlyCollection<K, T>,\n\t\twhenInSelf: (value: V, key: K) => Keep<R>,\n\t\twhenInOther: (valueOther: T, key: K) => Keep<R>,\n\t\twhenInBoth: (value: V, valueOther: T, key: K) => Keep<R>,\n\t): Collection<K, R> {\n\t\tconst coll = new this.constructor[Symbol.species]<K, R>();\n\t\tconst keys = new Set([...this.keys(), ...other.keys()]);\n\n\t\tfor (const key of keys) {\n\t\t\tconst hasInSelf = this.has(key);\n\t\t\tconst hasInOther = other.has(key);\n\n\t\t\tif (hasInSelf && hasInOther) {\n\t\t\t\tconst result = whenInBoth(this.get(key)!, other.get(key)!, key);\n\t\t\t\tif (result.keep) coll.set(key, result.value);\n\t\t\t} else if (hasInSelf) {\n\t\t\t\tconst result = whenInSelf(this.get(key)!, key);\n\t\t\t\tif (result.keep) coll.set(key, result.value);\n\t\t\t} else if (hasInOther) {\n\t\t\t\tconst result = whenInOther(other.get(key)!, key);\n\t\t\t\tif (result.keep) coll.set(key, result.value);\n\t\t\t}\n\t\t}\n\n\t\treturn coll;\n\t}\n\n\t/**\n\t * The sorted method sorts the items of a collection and returns it.\n\t * The sort is not necessarily stable in Node 10 or older.\n\t * The default sort order is according to string Unicode code points.\n\t *\n\t * @param compareFunction - Specifies a function that defines the sort order.\n\t * If omitted, the collection is sorted according to each character's Unicode code point value,\n\t * according to the string conversion of each element.\n\t * @example\n\t * ```ts\n\t * collection.sorted((userA, userB) => userA.createdTimestamp - userB.createdTimestamp);\n\t * ```\n\t */\n\tpublic sorted(compareFunction: Comparator<K, V> = Collection.defaultSort) {\n\t\treturn new this.constructor[Symbol.species](this).sort((av, bv, ak, bk) => compareFunction(av, bv, ak, bk));\n\t}\n\n\tpublic toJSON() {\n\t\t// toJSON is called recursively by JSON.stringify.\n\t\treturn [...this.values()];\n\t}\n\n\tprivate static defaultSort<V>(firstValue: V, secondValue: V): number {\n\t\treturn Number(firstValue > secondValue) || Number(firstValue === secondValue) - 1;\n\t}\n\n\t/**\n\t * Creates a Collection from a list of entries.\n\t *\n\t * @param entries - The list of entries\n\t * @param combine - Function to combine an existing entry with a new one\n\t * @example\n\t * ```ts\n\t * Collection.combineEntries([[\"a\", 1], [\"b\", 2], [\"a\", 2]], (x, y) => x + y);\n\t * // returns Collection { \"a\" => 3, \"b\" => 2 }\n\t * ```\n\t */\n\tpublic static combineEntries<K, V>(\n\t\tentries: Iterable<[K, V]>,\n\t\tcombine: (firstValue: V, secondValue: V, key: K) => V,\n\t): Collection<K, V> {\n\t\tconst coll = new Collection<K, V>();\n\t\tfor (const [key, value] of entries) {\n\t\t\tif (coll.has(key)) {\n\t\t\t\tcoll.set(key, combine(coll.get(key)!, value, key));\n\t\t\t} else {\n\t\t\t\tcoll.set(key, value);\n\t\t\t}\n\t\t}\n\n\t\treturn coll;\n\t}\n}\n\n/**\n * @internal\n */\nexport type Keep<V> = { keep: false } | { keep: true; value: V };\n\n/**\n * @internal\n */\nexport type Comparator<K, V> = (firstValue: V, secondValue: V, firstKey: K, secondKey: K) => number;\n","export * from './collection.js';\n\n/**\n * The {@link https://github.com/discordjs/discord.js/blob/main/packages/collection/#readme | @discordjs/collection} version\n * that you are currently using.\n */\n// This needs to explicitly be `string` so it is not typed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AAClC,eAAW,CAAC,KAAK,KAAK,KAAK,SAAS;AACnC,UAAI,KAAK,IAAI,GAAG,GAAG;AAClB,aAAK,IAAI,KAAK,QAAQ,KAAK,IAAI,GAAG,GAAI,OAAO,GAAG,CAAC;AAAA,MAClD,OAAO;AACN,aAAK,IAAI,KAAK,KAAK;AAAA,MACpB;AAAA,IACD;AAEA,WAAO;AAAA,EACR;AACD;;;AC9yBO,IAAM,UAAU;","names":[]}
|
node_modules/@discordjs/collection/package.json
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@discordjs/collection",
|
3 |
+
"version": "1.5.3",
|
4 |
+
"description": "Utility data structure used in discord.js",
|
5 |
+
"scripts": {
|
6 |
+
"test": "vitest run",
|
7 |
+
"build": "tsup",
|
8 |
+
"build:docs": "tsc -p tsconfig.docs.json",
|
9 |
+
"lint": "prettier --check . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --format=pretty",
|
10 |
+
"format": "prettier --write . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --fix --format=pretty",
|
11 |
+
"fmt": "yarn format",
|
12 |
+
"docs": "yarn build:docs && api-extractor run --local && api-extractor run --local --config ./api-extractor-docs.json",
|
13 |
+
"prepack": "yarn lint && yarn test && yarn build",
|
14 |
+
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/collection/*'",
|
15 |
+
"release": "cliff-jumper"
|
16 |
+
},
|
17 |
+
"main": "./dist/index.js",
|
18 |
+
"module": "./dist/index.mjs",
|
19 |
+
"types": "./dist/index.d.ts",
|
20 |
+
"exports": {
|
21 |
+
"types": "./dist/index.d.ts",
|
22 |
+
"import": "./dist/index.mjs",
|
23 |
+
"require": "./dist/index.js"
|
24 |
+
},
|
25 |
+
"directories": {
|
26 |
+
"lib": "src",
|
27 |
+
"test": "__tests__"
|
28 |
+
},
|
29 |
+
"files": [
|
30 |
+
"dist"
|
31 |
+
],
|
32 |
+
"contributors": [
|
33 |
+
"Crawl <icrawltogo@gmail.com>",
|
34 |
+
"Amish Shah <amishshah.2k@gmail.com>",
|
35 |
+
"SpaceEEC <spaceeec@yahoo.com>",
|
36 |
+
"Vlad Frangu <kingdgrizzle@gmail.com>",
|
37 |
+
"Aura Román <kyradiscord@gmail.com>"
|
38 |
+
],
|
39 |
+
"license": "Apache-2.0",
|
40 |
+
"keywords": [
|
41 |
+
"map",
|
42 |
+
"collection",
|
43 |
+
"utility"
|
44 |
+
],
|
45 |
+
"repository": {
|
46 |
+
"type": "git",
|
47 |
+
"url": "https://github.com/discordjs/discord.js.git",
|
48 |
+
"directory": "packages/collection"
|
49 |
+
},
|
50 |
+
"bugs": {
|
51 |
+
"url": "https://github.com/discordjs/discord.js/issues"
|
52 |
+
},
|
53 |
+
"homepage": "https://discord.js.org",
|
54 |
+
"devDependencies": {
|
55 |
+
"@favware/cliff-jumper": "^2.1.1",
|
56 |
+
"@microsoft/api-extractor": "^7.36.4",
|
57 |
+
"@types/node": "16.18.40",
|
58 |
+
"@vitest/coverage-v8": "^0.34.2",
|
59 |
+
"cross-env": "^7.0.3",
|
60 |
+
"esbuild-plugin-version-injector": "^1.2.0",
|
61 |
+
"eslint": "^8.47.0",
|
62 |
+
"eslint-config-neon": "^0.1.47",
|
63 |
+
"eslint-formatter-pretty": "^5.0.0",
|
64 |
+
"prettier": "^2.8.8",
|
65 |
+
"tsup": "^7.2.0",
|
66 |
+
"turbo": "^1.10.12",
|
67 |
+
"typescript": "^5.1.6",
|
68 |
+
"vitest": "^0.34.2"
|
69 |
+
},
|
70 |
+
"engines": {
|
71 |
+
"node": ">=16.11.0"
|
72 |
+
},
|
73 |
+
"publishConfig": {
|
74 |
+
"access": "public"
|
75 |
+
}
|
76 |
+
}
|
node_modules/@discordjs/formatters/LICENSE
ADDED
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Apache License
|
2 |
+
Version 2.0, January 2004
|
3 |
+
http://www.apache.org/licenses/
|
4 |
+
|
5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6 |
+
|
7 |
+
1. Definitions.
|
8 |
+
|
9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
11 |
+
|
12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13 |
+
the copyright owner that is granting the License.
|
14 |
+
|
15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
16 |
+
other entities that control, are controlled by, or are under common
|
17 |
+
control with that entity. For the purposes of this definition,
|
18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
19 |
+
direction or management of such entity, whether by contract or
|
20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22 |
+
|
23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24 |
+
exercising permissions granted by this License.
|
25 |
+
|
26 |
+
"Source" form shall mean the preferred form for making modifications,
|
27 |
+
including but not limited to software source code, documentation
|
28 |
+
source, and configuration files.
|
29 |
+
|
30 |
+
"Object" form shall mean any form resulting from mechanical
|
31 |
+
transformation or translation of a Source form, including but
|
32 |
+
not limited to compiled object code, generated documentation,
|
33 |
+
and conversions to other media types.
|
34 |
+
|
35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
36 |
+
Object form, made available under the License, as indicated by a
|
37 |
+
copyright notice that is included in or attached to the work
|
38 |
+
(an example is provided in the Appendix below).
|
39 |
+
|
40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41 |
+
form, that is based on (or derived from) the Work and for which the
|
42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
44 |
+
of this License, Derivative Works shall not include works that remain
|
45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46 |
+
the Work and Derivative Works thereof.
|
47 |
+
|
48 |
+
"Contribution" shall mean any work of authorship, including
|
49 |
+
the original version of the Work and any modifications or additions
|
50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
54 |
+
means any form of electronic, verbal, or written communication sent
|
55 |
+
to the Licensor or its representatives, including but not limited to
|
56 |
+
communication on electronic mailing lists, source code control systems,
|
57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
59 |
+
excluding communication that is conspicuously marked or otherwise
|
60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
61 |
+
|
62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
64 |
+
subsequently incorporated within the Work.
|
65 |
+
|
66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
71 |
+
Work and such Derivative Works in Source or Object form.
|
72 |
+
|
73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76 |
+
(except as stated in this section) patent license to make, have made,
|
77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78 |
+
where such license applies only to those patent claims licensable
|
79 |
+
by such Contributor that are necessarily infringed by their
|
80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
82 |
+
institute patent litigation against any entity (including a
|
83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84 |
+
or a Contribution incorporated within the Work constitutes direct
|
85 |
+
or contributory patent infringement, then any patent licenses
|
86 |
+
granted to You under this License for that Work shall terminate
|
87 |
+
as of the date such litigation is filed.
|
88 |
+
|
89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
90 |
+
Work or Derivative Works thereof in any medium, with or without
|
91 |
+
modifications, and in Source or Object form, provided that You
|
92 |
+
meet the following conditions:
|
93 |
+
|
94 |
+
(a) You must give any other recipients of the Work or
|
95 |
+
Derivative Works a copy of this License; and
|
96 |
+
|
97 |
+
(b) You must cause any modified files to carry prominent notices
|
98 |
+
stating that You changed the files; and
|
99 |
+
|
100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
101 |
+
that You distribute, all copyright, patent, trademark, and
|
102 |
+
attribution notices from the Source form of the Work,
|
103 |
+
excluding those notices that do not pertain to any part of
|
104 |
+
the Derivative Works; and
|
105 |
+
|
106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107 |
+
distribution, then any Derivative Works that You distribute must
|
108 |
+
include a readable copy of the attribution notices contained
|
109 |
+
within such NOTICE file, excluding those notices that do not
|
110 |
+
pertain to any part of the Derivative Works, in at least one
|
111 |
+
of the following places: within a NOTICE text file distributed
|
112 |
+
as part of the Derivative Works; within the Source form or
|
113 |
+
documentation, if provided along with the Derivative Works; or,
|
114 |
+
within a display generated by the Derivative Works, if and
|
115 |
+
wherever such third-party notices normally appear. The contents
|
116 |
+
of the NOTICE file are for informational purposes only and
|
117 |
+
do not modify the License. You may add Your own attribution
|
118 |
+
notices within Derivative Works that You distribute, alongside
|
119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
120 |
+
that such additional attribution notices cannot be construed
|
121 |
+
as modifying the License.
|
122 |
+
|
123 |
+
You may add Your own copyright statement to Your modifications and
|
124 |
+
may provide additional or different license terms and conditions
|
125 |
+
for use, reproduction, or distribution of Your modifications, or
|
126 |
+
for any such Derivative Works as a whole, provided Your use,
|
127 |
+
reproduction, and distribution of the Work otherwise complies with
|
128 |
+
the conditions stated in this License.
|
129 |
+
|
130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
132 |
+
by You to the Licensor shall be under the terms and conditions of
|
133 |
+
this License, without any additional terms or conditions.
|
134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135 |
+
the terms of any separate license agreement you may have executed
|
136 |
+
with Licensor regarding such Contributions.
|
137 |
+
|
138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
140 |
+
except as required for reasonable and customary use in describing the
|
141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
142 |
+
|
143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144 |
+
agreed to in writing, Licensor provides the Work (and each
|
145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147 |
+
implied, including, without limitation, any warranties or conditions
|
148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150 |
+
appropriateness of using or redistributing the Work and assume any
|
151 |
+
risks associated with Your exercise of permissions under this License.
|
152 |
+
|
153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
154 |
+
whether in tort (including negligence), contract, or otherwise,
|
155 |
+
unless required by applicable law (such as deliberate and grossly
|
156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157 |
+
liable to You for damages, including any direct, indirect, special,
|
158 |
+
incidental, or consequential damages of any character arising as a
|
159 |
+
result of this License or out of the use or inability to use the
|
160 |
+
Work (including but not limited to damages for loss of goodwill,
|
161 |
+
work stoppage, computer failure or malfunction, or any and all
|
162 |
+
other commercial damages or losses), even if such Contributor
|
163 |
+
has been advised of the possibility of such damages.
|
164 |
+
|
165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168 |
+
or other liability obligations and/or rights consistent with this
|
169 |
+
License. However, in accepting such obligations, You may act only
|
170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171 |
+
of any other Contributor, and only if You agree to indemnify,
|
172 |
+
defend, and hold each Contributor harmless for any liability
|
173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
174 |
+
of your accepting any such warranty or additional liability.
|
175 |
+
|
176 |
+
END OF TERMS AND CONDITIONS
|
177 |
+
|
178 |
+
Copyright 2021 Noel Buechler
|
179 |
+
Copyright 2021 Vlad Frangu
|
180 |
+
|
181 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
182 |
+
you may not use this file except in compliance with the License.
|
183 |
+
You may obtain a copy of the License at
|
184 |
+
|
185 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
186 |
+
|
187 |
+
Unless required by applicable law or agreed to in writing, software
|
188 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
189 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
190 |
+
See the License for the specific language governing permissions and
|
191 |
+
limitations under the License.
|
node_modules/@discordjs/formatters/README.md
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div align="center">
|
2 |
+
<br />
|
3 |
+
<p>
|
4 |
+
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
|
5 |
+
</p>
|
6 |
+
<br />
|
7 |
+
<p>
|
8 |
+
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
|
9 |
+
<a href="https://www.npmjs.com/package/@discordjs/formatters"><img src="https://img.shields.io/npm/v/@discordjs/formatters.svg?maxAge=3600" alt="npm version" /></a>
|
10 |
+
<a href="https://www.npmjs.com/package/@discordjs/formatters"><img src="https://img.shields.io/npm/dt/@discordjs/formatters.svg?maxAge=3600" alt="npm downloads" /></a>
|
11 |
+
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
|
12 |
+
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=formatters" alt="Code coverage" /></a>
|
13 |
+
</p>
|
14 |
+
<p>
|
15 |
+
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
16 |
+
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
|
17 |
+
</p>
|
18 |
+
</div>
|
19 |
+
|
20 |
+
## About
|
21 |
+
|
22 |
+
`@discordjs/formatters` is a collection of functions for formatting strings to be used on Discord.
|
23 |
+
|
24 |
+
## Installation
|
25 |
+
|
26 |
+
**Node.js 16.11.0 or newer is required.**
|
27 |
+
|
28 |
+
```sh
|
29 |
+
npm install @discordjs/formatters
|
30 |
+
yarn add @discordjs/formatters
|
31 |
+
pnpm add @discordjs/formatters
|
32 |
+
bun add @discordjs/formatters
|
33 |
+
```
|
34 |
+
|
35 |
+
## Example usage
|
36 |
+
|
37 |
+
````ts
|
38 |
+
import { codeBlock } from '@discordjs/formatters';
|
39 |
+
|
40 |
+
const formattedCode = codeBlock('hello world!');
|
41 |
+
console.log(formattedCode);
|
42 |
+
|
43 |
+
// Prints:
|
44 |
+
// ```
|
45 |
+
// hello world!
|
46 |
+
// ```
|
47 |
+
````
|
48 |
+
|
49 |
+
## Links
|
50 |
+
|
51 |
+
- [Website][website] ([source][website-source])
|
52 |
+
- [Documentation][documentation]
|
53 |
+
- [Guide][guide] ([source][guide-source])
|
54 |
+
Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
|
55 |
+
- [discord.js Discord server][discord]
|
56 |
+
- [Discord API Discord server][discord-api]
|
57 |
+
- [GitHub][source]
|
58 |
+
- [npm][npm]
|
59 |
+
- [Related libraries][related-libs]
|
60 |
+
|
61 |
+
## Contributing
|
62 |
+
|
63 |
+
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
|
64 |
+
[documentation][documentation].
|
65 |
+
See [the contribution guide][contributing] if you'd like to submit a PR.
|
66 |
+
|
67 |
+
## Help
|
68 |
+
|
69 |
+
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][discord].
|
70 |
+
|
71 |
+
[website]: https://discord.js.org
|
72 |
+
[website-source]: https://github.com/discordjs/discord.js/tree/main/apps/website
|
73 |
+
[documentation]: https://discord.js.org/docs/packages/formatters/stable
|
74 |
+
[guide]: https://discordjs.guide/
|
75 |
+
[guide-source]: https://github.com/discordjs/guide
|
76 |
+
[guide-update]: https://discordjs.guide/additional-info/changes-in-v14.html
|
77 |
+
[discord]: https://discord.gg/djs
|
78 |
+
[discord-api]: https://discord.gg/discord-api
|
79 |
+
[source]: https://github.com/discordjs/discord.js/tree/main/packages/formatters
|
80 |
+
[npm]: https://www.npmjs.com/package/@discordjs/formatters
|
81 |
+
[related-libs]: https://discord.com/developers/docs/topics/community-resources#libraries
|
82 |
+
[contributing]: https://github.com/disc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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { URL } from 'node:url';
|
2 |
+
import { Snowflake } from 'discord-api-types/globals';
|
3 |
+
|
4 |
+
/**
|
5 |
+
* The options that affect what will be escaped.
|
6 |
+
*/
|
7 |
+
interface EscapeMarkdownOptions {
|
8 |
+
/**
|
9 |
+
* Whether to escape bold text.
|
10 |
+
*
|
11 |
+
* @defaultValue `true`
|
12 |
+
*/
|
13 |
+
bold?: boolean;
|
14 |
+
/**
|
15 |
+
* Whether to escape bulleted lists.
|
16 |
+
*
|
17 |
+
* @defaultValue `false`
|
18 |
+
*/
|
19 |
+
bulletedList?: boolean;
|
20 |
+
/**
|
21 |
+
* Whether to escape code blocks.
|
22 |
+
*
|
23 |
+
* @defaultValue `true`
|
24 |
+
*/
|
25 |
+
codeBlock?: boolean;
|
26 |
+
/**
|
27 |
+
* Whether to escape text inside code blocks.
|
28 |
+
*
|
29 |
+
* @defaultValue `true`
|
30 |
+
*/
|
31 |
+
codeBlockContent?: boolean;
|
32 |
+
/**
|
33 |
+
* Whether to escape `\`.
|
34 |
+
*
|
35 |
+
* @defaultValue `true`
|
36 |
+
*/
|
37 |
+
escape?: boolean;
|
38 |
+
/**
|
39 |
+
* Whether to escape headings.
|
40 |
+
*
|
41 |
+
* @defaultValue `false`
|
42 |
+
*/
|
43 |
+
heading?: boolean;
|
44 |
+
/**
|
45 |
+
* Whether to escape inline code.
|
46 |
+
*
|
47 |
+
* @defaultValue `true`
|
48 |
+
*/
|
49 |
+
inlineCode?: boolean;
|
50 |
+
/**
|
51 |
+
* Whether to escape text inside inline code.
|
52 |
+
*
|
53 |
+
* @defaultValue `true`
|
54 |
+
*/
|
55 |
+
inlineCodeContent?: boolean;
|
56 |
+
/**
|
57 |
+
* Whether to escape italics.
|
58 |
+
*
|
59 |
+
* @defaultValue `true`
|
60 |
+
*/
|
61 |
+
italic?: boolean;
|
62 |
+
/**
|
63 |
+
* Whether to escape masked links.
|
64 |
+
*
|
65 |
+
* @defaultValue `false`
|
66 |
+
*/
|
67 |
+
maskedLink?: boolean;
|
68 |
+
/**
|
69 |
+
* Whether to escape numbered lists.
|
70 |
+
*
|
71 |
+
* @defaultValue `false`
|
72 |
+
*/
|
73 |
+
numberedList?: boolean;
|
74 |
+
/**
|
75 |
+
* Whether to escape spoilers.
|
76 |
+
*
|
77 |
+
* @defaultValue `true`
|
78 |
+
*/
|
79 |
+
spoiler?: boolean;
|
80 |
+
/**
|
81 |
+
* Whether to escape strikethroughs.
|
82 |
+
*
|
83 |
+
* @defaultValue `true`
|
84 |
+
*/
|
85 |
+
strikethrough?: boolean;
|
86 |
+
/**
|
87 |
+
* Whether to escape underlines.
|
88 |
+
*
|
89 |
+
* @defaultValue `true`
|
90 |
+
*/
|
91 |
+
underline?: boolean;
|
92 |
+
}
|
93 |
+
/**
|
94 |
+
* Escapes any Discord-flavored markdown in a string.
|
95 |
+
*
|
96 |
+
* @param text - Content to escape
|
97 |
+
* @param options - Options for escaping the markdown
|
98 |
+
*/
|
99 |
+
declare function escapeMarkdown(text: string, options?: EscapeMarkdownOptions): string;
|
100 |
+
/**
|
101 |
+
* Escapes code block markdown in a string.
|
102 |
+
*
|
103 |
+
* @param text - Content to escape
|
104 |
+
*/
|
105 |
+
declare function escapeCodeBlock(text: string): string;
|
106 |
+
/**
|
107 |
+
* Escapes inline code markdown in a string.
|
108 |
+
*
|
109 |
+
* @param text - Content to escape
|
110 |
+
*/
|
111 |
+
declare function escapeInlineCode(text: string): string;
|
112 |
+
/**
|
113 |
+
* Escapes italic markdown in a string.
|
114 |
+
*
|
115 |
+
* @param text - Content to escape
|
116 |
+
*/
|
117 |
+
declare function escapeItalic(text: string): string;
|
118 |
+
/**
|
119 |
+
* Escapes bold markdown in a string.
|
120 |
+
*
|
121 |
+
* @param text - Content to escape
|
122 |
+
*/
|
123 |
+
declare function escapeBold(text: string): string;
|
124 |
+
/**
|
125 |
+
* Escapes underline markdown in a string.
|
126 |
+
*
|
127 |
+
* @param text - Content to escape
|
128 |
+
*/
|
129 |
+
declare function escapeUnderline(text: string): string;
|
130 |
+
/**
|
131 |
+
* Escapes strikethrough markdown in a string.
|
132 |
+
*
|
133 |
+
* @param text - Content to escape
|
134 |
+
*/
|
135 |
+
declare function escapeStrikethrough(text: string): string;
|
136 |
+
/**
|
137 |
+
* Escapes spoiler markdown in a string.
|
138 |
+
*
|
139 |
+
* @param text - Content to escape
|
140 |
+
*/
|
141 |
+
declare function escapeSpoiler(text: string): string;
|
142 |
+
/**
|
143 |
+
* Escapes escape characters in a string.
|
144 |
+
*
|
145 |
+
* @param text - Content to escape
|
146 |
+
*/
|
147 |
+
declare function escapeEscape(text: string): string;
|
148 |
+
/**
|
149 |
+
* Escapes heading characters in a string.
|
150 |
+
*
|
151 |
+
* @param text - Content to escape
|
152 |
+
*/
|
153 |
+
declare function escapeHeading(text: string): string;
|
154 |
+
/**
|
155 |
+
* Escapes bulleted list characters in a string.
|
156 |
+
*
|
157 |
+
* @param text - Content to escape
|
158 |
+
*/
|
159 |
+
declare function escapeBulletedList(text: string): string;
|
160 |
+
/**
|
161 |
+
* Escapes numbered list characters in a string.
|
162 |
+
*
|
163 |
+
* @param text - Content to escape
|
164 |
+
*/
|
165 |
+
declare function escapeNumberedList(text: string): string;
|
166 |
+
/**
|
167 |
+
* Escapes masked link characters in a string.
|
168 |
+
*
|
169 |
+
* @param text - Content to escape
|
170 |
+
*/
|
171 |
+
declare function escapeMaskedLink(text: string): string;
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Wraps the content inside a code block with no language.
|
175 |
+
*
|
176 |
+
* @typeParam Content - This is inferred by the supplied content
|
177 |
+
* @param content - The content to wrap
|
178 |
+
*/
|
179 |
+
declare function codeBlock<Content extends string>(content: Content): `\`\`\`\n${Content}\n\`\`\``;
|
180 |
+
/**
|
181 |
+
* Wraps the content inside a code block with the specified language.
|
182 |
+
*
|
183 |
+
* @typeParam Language - This is inferred by the supplied language
|
184 |
+
* @typeParam Content - This is inferred by the supplied content
|
185 |
+
* @param language - The language for the code block
|
186 |
+
* @param content - The content to wrap
|
187 |
+
*/
|
188 |
+
declare function codeBlock<Language extends string, Content extends string>(language: Language, content: Content): `\`\`\`${Language}\n${Content}\n\`\`\``;
|
189 |
+
/**
|
190 |
+
* Wraps the content inside \`backticks\` which formats it as inline code.
|
191 |
+
*
|
192 |
+
* @typeParam Content - This is inferred by the supplied content
|
193 |
+
* @param content - The content to wrap
|
194 |
+
*/
|
195 |
+
declare function inlineCode<Content extends string>(content: Content): `\`${Content}\``;
|
196 |
+
/**
|
197 |
+
* Formats the content into italic text.
|
198 |
+
*
|
199 |
+
* @typeParam Content - This is inferred by the supplied content
|
200 |
+
* @param content - The content to wrap
|
201 |
+
*/
|
202 |
+
declare function italic<Content extends string>(content: Content): `_${Content}_`;
|
203 |
+
/**
|
204 |
+
* Formats the content into bold text.
|
205 |
+
*
|
206 |
+
* @typeParam Content - This is inferred by the supplied content
|
207 |
+
* @param content - The content to wrap
|
208 |
+
*/
|
209 |
+
declare function bold<Content extends string>(content: Content): `**${Content}**`;
|
210 |
+
/**
|
211 |
+
* Formats the content into underscored text.
|
212 |
+
*
|
213 |
+
* @typeParam Content - This is inferred by the supplied content
|
214 |
+
* @param content - The content to wrap
|
215 |
+
*/
|
216 |
+
declare function underscore<Content extends string>(content: Content): `__${Content}__`;
|
217 |
+
/**
|
218 |
+
* Formats the content into strike-through text.
|
219 |
+
*
|
220 |
+
* @typeParam Content - This is inferred by the supplied content
|
221 |
+
* @param content - The content to wrap
|
222 |
+
*/
|
223 |
+
declare function strikethrough<Content extends string>(content: Content): `~~${Content}~~`;
|
224 |
+
/**
|
225 |
+
* Formats the content into a quote.
|
226 |
+
*
|
227 |
+
* @remarks This needs to be at the start of the line for Discord to format it.
|
228 |
+
* @typeParam Content - This is inferred by the supplied content
|
229 |
+
* @param content - The content to wrap
|
230 |
+
*/
|
231 |
+
declare function quote<Content extends string>(content: Content): `> ${Content}`;
|
232 |
+
/**
|
233 |
+
* Formats the content into a block quote.
|
234 |
+
*
|
235 |
+
* @remarks This needs to be at the start of the line for Discord to format it.
|
236 |
+
* @typeParam Content - This is inferred by the supplied content
|
237 |
+
* @param content - The content to wrap
|
238 |
+
*/
|
239 |
+
declare function blockQuote<Content extends string>(content: Content): `>>> ${Content}`;
|
240 |
+
/**
|
241 |
+
* Wraps the URL into `<>` which stops it from embedding.
|
242 |
+
*
|
243 |
+
* @typeParam Content - This is inferred by the supplied content
|
244 |
+
* @param url - The URL to wrap
|
245 |
+
*/
|
246 |
+
declare function hideLinkEmbed<Content extends string>(url: Content): `<${Content}>`;
|
247 |
+
/**
|
248 |
+
* Wraps the URL into `<>` which stops it from embedding.
|
249 |
+
*
|
250 |
+
* @param url - The URL to wrap
|
251 |
+
*/
|
252 |
+
declare function hideLinkEmbed(url: URL): `<${string}>`;
|
253 |
+
/**
|
254 |
+
* Formats the content and the URL into a masked URL.
|
255 |
+
*
|
256 |
+
* @typeParam Content - This is inferred by the supplied content
|
257 |
+
* @param content - The content to display
|
258 |
+
* @param url - The URL the content links to
|
259 |
+
*/
|
260 |
+
declare function hyperlink<Content extends string>(content: Content, url: URL): `[${Content}](${string})`;
|
261 |
+
/**
|
262 |
+
* Formats the content and the URL into a masked URL.
|
263 |
+
*
|
264 |
+
* @typeParam Content - This is inferred by the supplied content
|
265 |
+
* @typeParam Url - This is inferred by the supplied URL
|
266 |
+
* @param content - The content to display
|
267 |
+
* @param url - The URL the content links to
|
268 |
+
*/
|
269 |
+
declare function hyperlink<Content extends string, Url extends string>(content: Content, url: Url): `[${Content}](${Url})`;
|
270 |
+
/**
|
271 |
+
* Formats the content and the URL into a masked URL with a custom tooltip.
|
272 |
+
*
|
273 |
+
* @typeParam Content - This is inferred by the supplied content
|
274 |
+
* @typeParam Title - This is inferred by the supplied title
|
275 |
+
* @param content - The content to display
|
276 |
+
* @param url - The URL the content links to
|
277 |
+
* @param title - The title shown when hovering on the masked link
|
278 |
+
*/
|
279 |
+
declare function hyperlink<Content extends string, Title extends string>(content: Content, url: URL, title: Title): `[${Content}](${string} "${Title}")`;
|
280 |
+
/**
|
281 |
+
* Formats the content and the URL into a masked URL with a custom tooltip.
|
282 |
+
*
|
283 |
+
* @typeParam Content - This is inferred by the supplied content
|
284 |
+
* @typeParam Url - This is inferred by the supplied URL
|
285 |
+
* @typeParam Title - This is inferred by the supplied title
|
286 |
+
* @param content - The content to display
|
287 |
+
* @param url - The URL the content links to
|
288 |
+
* @param title - The title shown when hovering on the masked link
|
289 |
+
*/
|
290 |
+
declare function hyperlink<Content extends string, Url extends string, Title extends string>(content: Content, url: Url, title: Title): `[${Content}](${Url} "${Title}")`;
|
291 |
+
/**
|
292 |
+
* Formats the content into a spoiler.
|
293 |
+
*
|
294 |
+
* @typeParam Content - This is inferred by the supplied content
|
295 |
+
* @param content - The content to wrap
|
296 |
+
*/
|
297 |
+
declare function spoiler<Content extends string>(content: Content): `||${Content}||`;
|
298 |
+
/**
|
299 |
+
* Formats a user id into a user mention.
|
300 |
+
*
|
301 |
+
* @typeParam UserId - This is inferred by the supplied user id
|
302 |
+
* @param userId - The user id to format
|
303 |
+
*/
|
304 |
+
declare function userMention<UserId extends Snowflake>(userId: UserId): `<@${UserId}>`;
|
305 |
+
/**
|
306 |
+
* Formats a channel id into a channel mention.
|
307 |
+
*
|
308 |
+
* @typeParam ChannelId - This is inferred by the supplied channel id
|
309 |
+
* @param channelId - The channel id to format
|
310 |
+
*/
|
311 |
+
declare function channelMention<ChannelId extends Snowflake>(channelId: ChannelId): `<#${ChannelId}>`;
|
312 |
+
/**
|
313 |
+
* Formats a role id into a role mention.
|
314 |
+
*
|
315 |
+
* @typeParam RoleId - This is inferred by the supplied role id
|
316 |
+
* @param roleId - The role id to format
|
317 |
+
*/
|
318 |
+
declare function roleMention<RoleId extends Snowflake>(roleId: RoleId): `<@&${RoleId}>`;
|
319 |
+
/**
|
320 |
+
* Formats an application command name, subcommand group name, subcommand name, and id into an application command mention.
|
321 |
+
*
|
322 |
+
* @typeParam CommandName - This is inferred by the supplied command name
|
323 |
+
* @typeParam SubcommandGroupName - This is inferred by the supplied subcommand group name
|
324 |
+
* @typeParam SubcommandName - This is inferred by the supplied subcommand name
|
325 |
+
* @typeParam CommandId - This is inferred by the supplied command id
|
326 |
+
* @param commandName - The application command name to format
|
327 |
+
* @param subcommandGroupName - The subcommand group name to format
|
328 |
+
* @param subcommandName - The subcommand name to format
|
329 |
+
* @param commandId - The application command id to format
|
330 |
+
*/
|
331 |
+
declare function chatInputApplicationCommandMention<CommandName extends string, SubcommandGroupName extends string, SubcommandName extends string, CommandId extends Snowflake>(commandName: CommandName, subcommandGroupName: SubcommandGroupName, subcommandName: SubcommandName, commandId: CommandId): `</${CommandName} ${SubcommandGroupName} ${SubcommandName}:${CommandId}>`;
|
332 |
+
/**
|
333 |
+
* Formats an application command name, subcommand name, and id into an application command mention.
|
334 |
+
*
|
335 |
+
* @typeParam CommandName - This is inferred by the supplied command name
|
336 |
+
* @typeParam SubcommandName - This is inferred by the supplied subcommand name
|
337 |
+
* @typeParam CommandId - This is inferred by the supplied command id
|
338 |
+
* @param commandName - The application command name to format
|
339 |
+
* @param subcommandName - The subcommand name to format
|
340 |
+
* @param commandId - The application command id to format
|
341 |
+
*/
|
342 |
+
declare function chatInputApplicationCommandMention<CommandName extends string, SubcommandName extends string, CommandId extends Snowflake>(commandName: CommandName, subcommandName: SubcommandName, commandId: CommandId): `</${CommandName} ${SubcommandName}:${CommandId}>`;
|
343 |
+
/**
|
344 |
+
* Formats an application command name and id into an application command mention.
|
345 |
+
*
|
346 |
+
* @typeParam CommandName - This is inferred by the supplied command name
|
347 |
+
* @typeParam CommandId - This is inferred by the supplied command id
|
348 |
+
* @param commandName - The application command name to format
|
349 |
+
* @param commandId - The application command id to format
|
350 |
+
*/
|
351 |
+
declare function chatInputApplicationCommandMention<CommandName extends string, CommandId extends Snowflake>(commandName: CommandName, commandId: CommandId): `</${CommandName}:${CommandId}>`;
|
352 |
+
/**
|
353 |
+
* Formats a non-animated emoji id into a fully qualified emoji identifier.
|
354 |
+
*
|
355 |
+
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
356 |
+
* @param emojiId - The emoji id to format
|
357 |
+
*/
|
358 |
+
declare function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: false): `<:_:${EmojiId}>`;
|
359 |
+
/**
|
360 |
+
* Formats an animated emoji id into a fully qualified emoji identifier.
|
361 |
+
*
|
362 |
+
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
363 |
+
* @param emojiId - The emoji id to format
|
364 |
+
* @param animated - Whether the emoji is animated
|
365 |
+
*/
|
366 |
+
declare function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: true): `<a:_:${EmojiId}>`;
|
367 |
+
/**
|
368 |
+
* Formats an emoji id into a fully qualified emoji identifier.
|
369 |
+
*
|
370 |
+
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
371 |
+
* @param emojiId - The emoji id to format
|
372 |
+
* @param animated - Whether the emoji is animated
|
373 |
+
*/
|
374 |
+
declare function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: boolean): `<:_:${EmojiId}>` | `<a:_:${EmojiId}>`;
|
375 |
+
/**
|
376 |
+
* Formats a channel link for a direct message channel.
|
377 |
+
*
|
378 |
+
* @typeParam ChannelId - This is inferred by the supplied channel id
|
379 |
+
* @param channelId - The channel's id
|
380 |
+
*/
|
381 |
+
declare function channelLink<ChannelId extends Snowflake>(channelId: ChannelId): `https://discord.com/channels/@me/${ChannelId}`;
|
382 |
+
/**
|
383 |
+
* Formats a channel link for a guild channel.
|
384 |
+
*
|
385 |
+
* @typeParam ChannelId - This is inferred by the supplied channel id
|
386 |
+
* @typeParam GuildId - This is inferred by the supplied guild id
|
387 |
+
* @param channelId - The channel's id
|
388 |
+
* @param guildId - The guild's id
|
389 |
+
*/
|
390 |
+
declare function channelLink<ChannelId extends Snowflake, GuildId extends Snowflake>(channelId: ChannelId, guildId: GuildId): `https://discord.com/channels/${GuildId}/${ChannelId}`;
|
391 |
+
/**
|
392 |
+
* Formats a message link for a direct message channel.
|
393 |
+
*
|
394 |
+
* @typeParam ChannelId - This is inferred by the supplied channel id
|
395 |
+
* @typeParam MessageId - This is inferred by the supplied message id
|
396 |
+
* @param channelId - The channel's id
|
397 |
+
* @param messageId - The message's id
|
398 |
+
*/
|
399 |
+
declare function messageLink<ChannelId extends Snowflake, MessageId extends Snowflake>(channelId: ChannelId, messageId: MessageId): `https://discord.com/channels/@me/${ChannelId}/${MessageId}`;
|
400 |
+
/**
|
401 |
+
* Formats a message link for a guild channel.
|
402 |
+
*
|
403 |
+
* @typeParam ChannelId - This is inferred by the supplied channel id
|
404 |
+
* @typeParam MessageId - This is inferred by the supplied message id
|
405 |
+
* @typeParam GuildId - This is inferred by the supplied guild id
|
406 |
+
* @param channelId - The channel's id
|
407 |
+
* @param messageId - The message's id
|
408 |
+
* @param guildId - The guild's id
|
409 |
+
*/
|
410 |
+
declare function messageLink<ChannelId extends Snowflake, MessageId extends Snowflake, GuildId extends Snowflake>(channelId: ChannelId, messageId: MessageId, guildId: GuildId): `https://discord.com/channels/${GuildId}/${ChannelId}/${MessageId}`;
|
411 |
+
/**
|
412 |
+
* The heading levels for expanded markdown.
|
413 |
+
*/
|
414 |
+
declare enum HeadingLevel {
|
415 |
+
/**
|
416 |
+
* The first heading level.
|
417 |
+
*/
|
418 |
+
One = 1,
|
419 |
+
/**
|
420 |
+
* The second heading level.
|
421 |
+
*/
|
422 |
+
Two = 2,
|
423 |
+
/**
|
424 |
+
* The third heading level.
|
425 |
+
*/
|
426 |
+
Three = 3
|
427 |
+
}
|
428 |
+
/**
|
429 |
+
* Formats the content into a heading level.
|
430 |
+
*
|
431 |
+
* @typeParam Content - This is inferred by the supplied content
|
432 |
+
* @param content - The content to wrap
|
433 |
+
* @param level - The heading level
|
434 |
+
*/
|
435 |
+
declare function heading<Content extends string>(content: Content, level?: HeadingLevel.One): `# ${Content}`;
|
436 |
+
/**
|
437 |
+
* Formats the content into a heading level.
|
438 |
+
*
|
439 |
+
* @typeParam Content - This is inferred by the supplied content
|
440 |
+
* @param content - The content to wrap
|
441 |
+
* @param level - The heading level
|
442 |
+
*/
|
443 |
+
declare function heading<Content extends string>(content: Content, level: HeadingLevel.Two): `## ${Content}`;
|
444 |
+
/**
|
445 |
+
* Formats the content into a heading level.
|
446 |
+
*
|
447 |
+
* @typeParam Content - This is inferred by the supplied content
|
448 |
+
* @param content - The content to wrap
|
449 |
+
* @param level - The heading level
|
450 |
+
*/
|
451 |
+
declare function heading<Content extends string>(content: Content, level: HeadingLevel.Three): `### ${Content}`;
|
452 |
+
/**
|
453 |
+
* A type that recursively traverses into arrays.
|
454 |
+
*/
|
455 |
+
type RecursiveArray<ItemType> = readonly (ItemType | RecursiveArray<ItemType>)[];
|
456 |
+
/**
|
457 |
+
* Formats the elements in the array to an ordered list.
|
458 |
+
*
|
459 |
+
* @param list - The array of elements to list
|
460 |
+
* @param startNumber - The starting number for the list
|
461 |
+
*/
|
462 |
+
declare function orderedList(list: RecursiveArray<string>, startNumber?: number): string;
|
463 |
+
/**
|
464 |
+
* Formats the elements in the array to an unordered list.
|
465 |
+
*
|
466 |
+
* @param list - The array of elements to list
|
467 |
+
*/
|
468 |
+
declare function unorderedList(list: RecursiveArray<string>): string;
|
469 |
+
/**
|
470 |
+
* Formats a date into a short date-time string.
|
471 |
+
*
|
472 |
+
* @param date - The date to format. Defaults to the current time
|
473 |
+
*/
|
474 |
+
declare function time(date?: Date): `<t:${bigint}>`;
|
475 |
+
/**
|
476 |
+
* Formats a date given a format style.
|
477 |
+
*
|
478 |
+
* @typeParam Style - This is inferred by the supplied {@link TimestampStylesString}
|
479 |
+
* @param date - The date to format
|
480 |
+
* @param style - The style to use
|
481 |
+
*/
|
482 |
+
declare function time<Style extends TimestampStylesString>(date: Date, style: Style): `<t:${bigint}:${Style}>`;
|
483 |
+
/**
|
484 |
+
* Formats the given timestamp into a short date-time string.
|
485 |
+
*
|
486 |
+
* @typeParam Seconds - This is inferred by the supplied timestamp
|
487 |
+
* @param seconds - A Unix timestamp in seconds
|
488 |
+
*/
|
489 |
+
declare function time<Seconds extends number>(seconds: Seconds): `<t:${Seconds}>`;
|
490 |
+
/**
|
491 |
+
* Formats the given timestamp into a short date-time string.
|
492 |
+
*
|
493 |
+
* @typeParam Seconds - This is inferred by the supplied timestamp
|
494 |
+
* @typeParam Style - This is inferred by the supplied {@link TimestampStylesString}
|
495 |
+
* @param seconds - A Unix timestamp in seconds
|
496 |
+
* @param style - The style to use
|
497 |
+
*/
|
498 |
+
declare function time<Seconds extends number, Style extends TimestampStylesString>(seconds: Seconds, style: Style): `<t:${Seconds}:${Style}>`;
|
499 |
+
/**
|
500 |
+
* The {@link https://discord.com/developers/docs/reference#message-formatting-timestamp-styles | message formatting timestamp styles}
|
501 |
+
* supported by Discord.
|
502 |
+
*/
|
503 |
+
declare const TimestampStyles: {
|
504 |
+
/**
|
505 |
+
* Short time format, consisting of hours and minutes.
|
506 |
+
*
|
507 |
+
* @example `16:20`
|
508 |
+
*/
|
509 |
+
readonly ShortTime: "t";
|
510 |
+
/**
|
511 |
+
* Long time format, consisting of hours, minutes, and seconds.
|
512 |
+
*
|
513 |
+
* @example `16:20:30`
|
514 |
+
*/
|
515 |
+
readonly LongTime: "T";
|
516 |
+
/**
|
517 |
+
* Short date format, consisting of day, month, and year.
|
518 |
+
*
|
519 |
+
* @example `20/04/2021`
|
520 |
+
*/
|
521 |
+
readonly ShortDate: "d";
|
522 |
+
/**
|
523 |
+
* Long date format, consisting of day, month, and year.
|
524 |
+
*
|
525 |
+
* @example `20 April 2021`
|
526 |
+
*/
|
527 |
+
readonly LongDate: "D";
|
528 |
+
/**
|
529 |
+
* Short date-time format, consisting of short date and short time formats.
|
530 |
+
*
|
531 |
+
* @example `20 April 2021 16:20`
|
532 |
+
*/
|
533 |
+
readonly ShortDateTime: "f";
|
534 |
+
/**
|
535 |
+
* Long date-time format, consisting of long date and short time formats.
|
536 |
+
*
|
537 |
+
* @example `Tuesday, 20 April 2021 16:20`
|
538 |
+
*/
|
539 |
+
readonly LongDateTime: "F";
|
540 |
+
/**
|
541 |
+
* Relative time format, consisting of a relative duration format.
|
542 |
+
*
|
543 |
+
* @example `2 months ago`
|
544 |
+
*/
|
545 |
+
readonly RelativeTime: "R";
|
546 |
+
};
|
547 |
+
/**
|
548 |
+
* The possible {@link TimestampStyles} values.
|
549 |
+
*/
|
550 |
+
type TimestampStylesString = (typeof TimestampStyles)[keyof typeof TimestampStyles];
|
551 |
+
/**
|
552 |
+
* All the available faces from Discord's native slash commands.
|
553 |
+
*/
|
554 |
+
declare enum Faces {
|
555 |
+
/**
|
556 |
+
* `¯\_(ツ)_/¯`
|
557 |
+
*/
|
558 |
+
Shrug = "\u00AF_(\u30C4)_/\u00AF",
|
559 |
+
/**
|
560 |
+
* `(╯°□°)╯︵ ┻━┻`
|
561 |
+
*/
|
562 |
+
Tableflip = "(\u256F\u00B0\u25A1\u00B0)\u256F\uFE35 \u253B\u2501\u253B",
|
563 |
+
/**
|
564 |
+
* `┬─┬ノ( º _ ºノ)`
|
565 |
+
*/
|
566 |
+
Unflip = "\u252C\u2500\u252C\u30CE( \u00BA _ \u00BA\u30CE)"
|
567 |
+
}
|
568 |
+
/**
|
569 |
+
* All the available guild navigation mentions.
|
570 |
+
*/
|
571 |
+
declare enum GuildNavigationMentions {
|
572 |
+
/**
|
573 |
+
* Browse Channels tab.
|
574 |
+
*/
|
575 |
+
Browse = "<id:browse>",
|
576 |
+
/**
|
577 |
+
* Customize tab with the server's {@link https://discord.com/developers/docs/resources/guild#guild-onboarding-object | onboarding prompts}.
|
578 |
+
*/
|
579 |
+
Customize = "<id:customize>",
|
580 |
+
/**
|
581 |
+
* {@link https://support.discord.com/hc/articles/13497665141655 | Server Guide} tab.
|
582 |
+
*/
|
583 |
+
Guide = "<id:guide>"
|
584 |
+
}
|
585 |
+
|
586 |
+
export { EscapeMarkdownOptions, Faces, GuildNavigationMentions, HeadingLevel, RecursiveArray, TimestampStyles, TimestampStylesString, blockQuote, bold, channelLink, channelMention, chatInputApplicationCommandMention, codeBlock, escapeBold, escapeBulletedList, escapeCodeBlock, escapeEscape, escapeHeading, escapeInlineCode, escapeItalic, escapeMarkdown, escapeMaskedLink, escapeNumberedList, escapeSpoiler, escapeStrikethrough, escapeUnderline, formatEmoji, heading, hideLinkEmbed, hyperlink, inlineCode, italic, messageLink, orderedList, quote, roleMention, spoiler, strikethrough, time, underscore, unorderedList, userMention };
|
node_modules/@discordjs/formatters/dist/index.d.ts
ADDED
@@ -0,0 +1,586 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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**
|
5 |
+
* The options that affect what will be escaped.
|
6 |
+
*/
|
7 |
+
interface EscapeMarkdownOptions {
|
8 |
+
/**
|
9 |
+
* Whether to escape bold text.
|
10 |
+
*
|
11 |
+
* @defaultValue `true`
|
12 |
+
*/
|
13 |
+
bold?: boolean;
|
14 |
+
/**
|
15 |
+
* Whether to escape bulleted lists.
|
16 |
+
*
|
17 |
+
* @defaultValue `false`
|
18 |
+
*/
|
19 |
+
bulletedList?: boolean;
|
20 |
+
/**
|
21 |
+
* Whether to escape code blocks.
|
22 |
+
*
|
23 |
+
* @defaultValue `true`
|
24 |
+
*/
|
25 |
+
codeBlock?: boolean;
|
26 |
+
/**
|
27 |
+
* Whether to escape text inside code blocks.
|
28 |
+
*
|
29 |
+
* @defaultValue `true`
|
30 |
+
*/
|
31 |
+
codeBlockContent?: boolean;
|
32 |
+
/**
|
33 |
+
* Whether to escape `\`.
|
34 |
+
*
|
35 |
+
* @defaultValue `true`
|
36 |
+
*/
|
37 |
+
escape?: boolean;
|
38 |
+
/**
|
39 |
+
* Whether to escape headings.
|
40 |
+
*
|
41 |
+
* @defaultValue `false`
|
42 |
+
*/
|
43 |
+
heading?: boolean;
|
44 |
+
/**
|
45 |
+
* Whether to escape inline code.
|
46 |
+
*
|
47 |
+
* @defaultValue `true`
|
48 |
+
*/
|
49 |
+
inlineCode?: boolean;
|
50 |
+
/**
|
51 |
+
* Whether to escape text inside inline code.
|
52 |
+
*
|
53 |
+
* @defaultValue `true`
|
54 |
+
*/
|
55 |
+
inlineCodeContent?: boolean;
|
56 |
+
/**
|
57 |
+
* Whether to escape italics.
|
58 |
+
*
|
59 |
+
* @defaultValue `true`
|
60 |
+
*/
|
61 |
+
italic?: boolean;
|
62 |
+
/**
|
63 |
+
* Whether to escape masked links.
|
64 |
+
*
|
65 |
+
* @defaultValue `false`
|
66 |
+
*/
|
67 |
+
maskedLink?: boolean;
|
68 |
+
/**
|
69 |
+
* Whether to escape numbered lists.
|
70 |
+
*
|
71 |
+
* @defaultValue `false`
|
72 |
+
*/
|
73 |
+
numberedList?: boolean;
|
74 |
+
/**
|
75 |
+
* Whether to escape spoilers.
|
76 |
+
*
|
77 |
+
* @defaultValue `true`
|
78 |
+
*/
|
79 |
+
spoiler?: boolean;
|
80 |
+
/**
|
81 |
+
* Whether to escape strikethroughs.
|
82 |
+
*
|
83 |
+
* @defaultValue `true`
|
84 |
+
*/
|
85 |
+
strikethrough?: boolean;
|
86 |
+
/**
|
87 |
+
* Whether to escape underlines.
|
88 |
+
*
|
89 |
+
* @defaultValue `true`
|
90 |
+
*/
|
91 |
+
underline?: boolean;
|
92 |
+
}
|
93 |
+
/**
|
94 |
+
* Escapes any Discord-flavored markdown in a string.
|
95 |
+
*
|
96 |
+
* @param text - Content to escape
|
97 |
+
* @param options - Options for escaping the markdown
|
98 |
+
*/
|
99 |
+
declare function escapeMarkdown(text: string, options?: EscapeMarkdownOptions): string;
|
100 |
+
/**
|
101 |
+
* Escapes code block markdown in a string.
|
102 |
+
*
|
103 |
+
* @param text - Content to escape
|
104 |
+
*/
|
105 |
+
declare function escapeCodeBlock(text: string): string;
|
106 |
+
/**
|
107 |
+
* Escapes inline code markdown in a string.
|
108 |
+
*
|
109 |
+
* @param text - Content to escape
|
110 |
+
*/
|
111 |
+
declare function escapeInlineCode(text: string): string;
|
112 |
+
/**
|
113 |
+
* Escapes italic markdown in a string.
|
114 |
+
*
|
115 |
+
* @param text - Content to escape
|
116 |
+
*/
|
117 |
+
declare function escapeItalic(text: string): string;
|
118 |
+
/**
|
119 |
+
* Escapes bold markdown in a string.
|
120 |
+
*
|
121 |
+
* @param text - Content to escape
|
122 |
+
*/
|
123 |
+
declare function escapeBold(text: string): string;
|
124 |
+
/**
|
125 |
+
* Escapes underline markdown in a string.
|
126 |
+
*
|
127 |
+
* @param text - Content to escape
|
128 |
+
*/
|
129 |
+
declare function escapeUnderline(text: string): string;
|
130 |
+
/**
|
131 |
+
* Escapes strikethrough markdown in a string.
|
132 |
+
*
|
133 |
+
* @param text - Content to escape
|
134 |
+
*/
|
135 |
+
declare function escapeStrikethrough(text: string): string;
|
136 |
+
/**
|
137 |
+
* Escapes spoiler markdown in a string.
|
138 |
+
*
|
139 |
+
* @param text - Content to escape
|
140 |
+
*/
|
141 |
+
declare function escapeSpoiler(text: string): string;
|
142 |
+
/**
|
143 |
+
* Escapes escape characters in a string.
|
144 |
+
*
|
145 |
+
* @param text - Content to escape
|
146 |
+
*/
|
147 |
+
declare function escapeEscape(text: string): string;
|
148 |
+
/**
|
149 |
+
* Escapes heading characters in a string.
|
150 |
+
*
|
151 |
+
* @param text - Content to escape
|
152 |
+
*/
|
153 |
+
declare function escapeHeading(text: string): string;
|
154 |
+
/**
|
155 |
+
* Escapes bulleted list characters in a string.
|
156 |
+
*
|
157 |
+
* @param text - Content to escape
|
158 |
+
*/
|
159 |
+
declare function escapeBulletedList(text: string): string;
|
160 |
+
/**
|
161 |
+
* Escapes numbered list characters in a string.
|
162 |
+
*
|
163 |
+
* @param text - Content to escape
|
164 |
+
*/
|
165 |
+
declare function escapeNumberedList(text: string): string;
|
166 |
+
/**
|
167 |
+
* Escapes masked link characters in a string.
|
168 |
+
*
|
169 |
+
* @param text - Content to escape
|
170 |
+
*/
|
171 |
+
declare function escapeMaskedLink(text: string): string;
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Wraps the content inside a code block with no language.
|
175 |
+
*
|
176 |
+
* @typeParam Content - This is inferred by the supplied content
|
177 |
+
* @param content - The content to wrap
|
178 |
+
*/
|
179 |
+
declare function codeBlock<Content extends string>(content: Content): `\`\`\`\n${Content}\n\`\`\``;
|
180 |
+
/**
|
181 |
+
* Wraps the content inside a code block with the specified language.
|
182 |
+
*
|
183 |
+
* @typeParam Language - This is inferred by the supplied language
|
184 |
+
* @typeParam Content - This is inferred by the supplied content
|
185 |
+
* @param language - The language for the code block
|
186 |
+
* @param content - The content to wrap
|
187 |
+
*/
|
188 |
+
declare function codeBlock<Language extends string, Content extends string>(language: Language, content: Content): `\`\`\`${Language}\n${Content}\n\`\`\``;
|
189 |
+
/**
|
190 |
+
* Wraps the content inside \`backticks\` which formats it as inline code.
|
191 |
+
*
|
192 |
+
* @typeParam Content - This is inferred by the supplied content
|
193 |
+
* @param content - The content to wrap
|
194 |
+
*/
|
195 |
+
declare function inlineCode<Content extends string>(content: Content): `\`${Content}\``;
|
196 |
+
/**
|
197 |
+
* Formats the content into italic text.
|
198 |
+
*
|
199 |
+
* @typeParam Content - This is inferred by the supplied content
|
200 |
+
* @param content - The content to wrap
|
201 |
+
*/
|
202 |
+
declare function italic<Content extends string>(content: Content): `_${Content}_`;
|
203 |
+
/**
|
204 |
+
* Formats the content into bold text.
|
205 |
+
*
|
206 |
+
* @typeParam Content - This is inferred by the supplied content
|
207 |
+
* @param content - The content to wrap
|
208 |
+
*/
|
209 |
+
declare function bold<Content extends string>(content: Content): `**${Content}**`;
|
210 |
+
/**
|
211 |
+
* Formats the content into underscored text.
|
212 |
+
*
|
213 |
+
* @typeParam Content - This is inferred by the supplied content
|
214 |
+
* @param content - The content to wrap
|
215 |
+
*/
|
216 |
+
declare function underscore<Content extends string>(content: Content): `__${Content}__`;
|
217 |
+
/**
|
218 |
+
* Formats the content into strike-through text.
|
219 |
+
*
|
220 |
+
* @typeParam Content - This is inferred by the supplied content
|
221 |
+
* @param content - The content to wrap
|
222 |
+
*/
|
223 |
+
declare function strikethrough<Content extends string>(content: Content): `~~${Content}~~`;
|
224 |
+
/**
|
225 |
+
* Formats the content into a quote.
|
226 |
+
*
|
227 |
+
* @remarks This needs to be at the start of the line for Discord to format it.
|
228 |
+
* @typeParam Content - This is inferred by the supplied content
|
229 |
+
* @param content - The content to wrap
|
230 |
+
*/
|
231 |
+
declare function quote<Content extends string>(content: Content): `> ${Content}`;
|
232 |
+
/**
|
233 |
+
* Formats the content into a block quote.
|
234 |
+
*
|
235 |
+
* @remarks This needs to be at the start of the line for Discord to format it.
|
236 |
+
* @typeParam Content - This is inferred by the supplied content
|
237 |
+
* @param content - The content to wrap
|
238 |
+
*/
|
239 |
+
declare function blockQuote<Content extends string>(content: Content): `>>> ${Content}`;
|
240 |
+
/**
|
241 |
+
* Wraps the URL into `<>` which stops it from embedding.
|
242 |
+
*
|
243 |
+
* @typeParam Content - This is inferred by the supplied content
|
244 |
+
* @param url - The URL to wrap
|
245 |
+
*/
|
246 |
+
declare function hideLinkEmbed<Content extends string>(url: Content): `<${Content}>`;
|
247 |
+
/**
|
248 |
+
* Wraps the URL into `<>` which stops it from embedding.
|
249 |
+
*
|
250 |
+
* @param url - The URL to wrap
|
251 |
+
*/
|
252 |
+
declare function hideLinkEmbed(url: URL): `<${string}>`;
|
253 |
+
/**
|
254 |
+
* Formats the content and the URL into a masked URL.
|
255 |
+
*
|
256 |
+
* @typeParam Content - This is inferred by the supplied content
|
257 |
+
* @param content - The content to display
|
258 |
+
* @param url - The URL the content links to
|
259 |
+
*/
|
260 |
+
declare function hyperlink<Content extends string>(content: Content, url: URL): `[${Content}](${string})`;
|
261 |
+
/**
|
262 |
+
* Formats the content and the URL into a masked URL.
|
263 |
+
*
|
264 |
+
* @typeParam Content - This is inferred by the supplied content
|
265 |
+
* @typeParam Url - This is inferred by the supplied URL
|
266 |
+
* @param content - The content to display
|
267 |
+
* @param url - The URL the content links to
|
268 |
+
*/
|
269 |
+
declare function hyperlink<Content extends string, Url extends string>(content: Content, url: Url): `[${Content}](${Url})`;
|
270 |
+
/**
|
271 |
+
* Formats the content and the URL into a masked URL with a custom tooltip.
|
272 |
+
*
|
273 |
+
* @typeParam Content - This is inferred by the supplied content
|
274 |
+
* @typeParam Title - This is inferred by the supplied title
|
275 |
+
* @param content - The content to display
|
276 |
+
* @param url - The URL the content links to
|
277 |
+
* @param title - The title shown when hovering on the masked link
|
278 |
+
*/
|
279 |
+
declare function hyperlink<Content extends string, Title extends string>(content: Content, url: URL, title: Title): `[${Content}](${string} "${Title}")`;
|
280 |
+
/**
|
281 |
+
* Formats the content and the URL into a masked URL with a custom tooltip.
|
282 |
+
*
|
283 |
+
* @typeParam Content - This is inferred by the supplied content
|
284 |
+
* @typeParam Url - This is inferred by the supplied URL
|
285 |
+
* @typeParam Title - This is inferred by the supplied title
|
286 |
+
* @param content - The content to display
|
287 |
+
* @param url - The URL the content links to
|
288 |
+
* @param title - The title shown when hovering on the masked link
|
289 |
+
*/
|
290 |
+
declare function hyperlink<Content extends string, Url extends string, Title extends string>(content: Content, url: Url, title: Title): `[${Content}](${Url} "${Title}")`;
|
291 |
+
/**
|
292 |
+
* Formats the content into a spoiler.
|
293 |
+
*
|
294 |
+
* @typeParam Content - This is inferred by the supplied content
|
295 |
+
* @param content - The content to wrap
|
296 |
+
*/
|
297 |
+
declare function spoiler<Content extends string>(content: Content): `||${Content}||`;
|
298 |
+
/**
|
299 |
+
* Formats a user id into a user mention.
|
300 |
+
*
|
301 |
+
* @typeParam UserId - This is inferred by the supplied user id
|
302 |
+
* @param userId - The user id to format
|
303 |
+
*/
|
304 |
+
declare function userMention<UserId extends Snowflake>(userId: UserId): `<@${UserId}>`;
|
305 |
+
/**
|
306 |
+
* Formats a channel id into a channel mention.
|
307 |
+
*
|
308 |
+
* @typeParam ChannelId - This is inferred by the supplied channel id
|
309 |
+
* @param channelId - The channel id to format
|
310 |
+
*/
|
311 |
+
declare function channelMention<ChannelId extends Snowflake>(channelId: ChannelId): `<#${ChannelId}>`;
|
312 |
+
/**
|
313 |
+
* Formats a role id into a role mention.
|
314 |
+
*
|
315 |
+
* @typeParam RoleId - This is inferred by the supplied role id
|
316 |
+
* @param roleId - The role id to format
|
317 |
+
*/
|
318 |
+
declare function roleMention<RoleId extends Snowflake>(roleId: RoleId): `<@&${RoleId}>`;
|
319 |
+
/**
|
320 |
+
* Formats an application command name, subcommand group name, subcommand name, and id into an application command mention.
|
321 |
+
*
|
322 |
+
* @typeParam CommandName - This is inferred by the supplied command name
|
323 |
+
* @typeParam SubcommandGroupName - This is inferred by the supplied subcommand group name
|
324 |
+
* @typeParam SubcommandName - This is inferred by the supplied subcommand name
|
325 |
+
* @typeParam CommandId - This is inferred by the supplied command id
|
326 |
+
* @param commandName - The application command name to format
|
327 |
+
* @param subcommandGroupName - The subcommand group name to format
|
328 |
+
* @param subcommandName - The subcommand name to format
|
329 |
+
* @param commandId - The application command id to format
|
330 |
+
*/
|
331 |
+
declare function chatInputApplicationCommandMention<CommandName extends string, SubcommandGroupName extends string, SubcommandName extends string, CommandId extends Snowflake>(commandName: CommandName, subcommandGroupName: SubcommandGroupName, subcommandName: SubcommandName, commandId: CommandId): `</${CommandName} ${SubcommandGroupName} ${SubcommandName}:${CommandId}>`;
|
332 |
+
/**
|
333 |
+
* Formats an application command name, subcommand name, and id into an application command mention.
|
334 |
+
*
|
335 |
+
* @typeParam CommandName - This is inferred by the supplied command name
|
336 |
+
* @typeParam SubcommandName - This is inferred by the supplied subcommand name
|
337 |
+
* @typeParam CommandId - This is inferred by the supplied command id
|
338 |
+
* @param commandName - The application command name to format
|
339 |
+
* @param subcommandName - The subcommand name to format
|
340 |
+
* @param commandId - The application command id to format
|
341 |
+
*/
|
342 |
+
declare function chatInputApplicationCommandMention<CommandName extends string, SubcommandName extends string, CommandId extends Snowflake>(commandName: CommandName, subcommandName: SubcommandName, commandId: CommandId): `</${CommandName} ${SubcommandName}:${CommandId}>`;
|
343 |
+
/**
|
344 |
+
* Formats an application command name and id into an application command mention.
|
345 |
+
*
|
346 |
+
* @typeParam CommandName - This is inferred by the supplied command name
|
347 |
+
* @typeParam CommandId - This is inferred by the supplied command id
|
348 |
+
* @param commandName - The application command name to format
|
349 |
+
* @param commandId - The application command id to format
|
350 |
+
*/
|
351 |
+
declare function chatInputApplicationCommandMention<CommandName extends string, CommandId extends Snowflake>(commandName: CommandName, commandId: CommandId): `</${CommandName}:${CommandId}>`;
|
352 |
+
/**
|
353 |
+
* Formats a non-animated emoji id into a fully qualified emoji identifier.
|
354 |
+
*
|
355 |
+
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
356 |
+
* @param emojiId - The emoji id to format
|
357 |
+
*/
|
358 |
+
declare function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: false): `<:_:${EmojiId}>`;
|
359 |
+
/**
|
360 |
+
* Formats an animated emoji id into a fully qualified emoji identifier.
|
361 |
+
*
|
362 |
+
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
363 |
+
* @param emojiId - The emoji id to format
|
364 |
+
* @param animated - Whether the emoji is animated
|
365 |
+
*/
|
366 |
+
declare function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: true): `<a:_:${EmojiId}>`;
|
367 |
+
/**
|
368 |
+
* Formats an emoji id into a fully qualified emoji identifier.
|
369 |
+
*
|
370 |
+
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
371 |
+
* @param emojiId - The emoji id to format
|
372 |
+
* @param animated - Whether the emoji is animated
|
373 |
+
*/
|
374 |
+
declare function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: boolean): `<:_:${EmojiId}>` | `<a:_:${EmojiId}>`;
|
375 |
+
/**
|
376 |
+
* Formats a channel link for a direct message channel.
|
377 |
+
*
|
378 |
+
* @typeParam ChannelId - This is inferred by the supplied channel id
|
379 |
+
* @param channelId - The channel's id
|
380 |
+
*/
|
381 |
+
declare function channelLink<ChannelId extends Snowflake>(channelId: ChannelId): `https://discord.com/channels/@me/${ChannelId}`;
|
382 |
+
/**
|
383 |
+
* Formats a channel link for a guild channel.
|
384 |
+
*
|
385 |
+
* @typeParam ChannelId - This is inferred by the supplied channel id
|
386 |
+
* @typeParam GuildId - This is inferred by the supplied guild id
|
387 |
+
* @param channelId - The channel's id
|
388 |
+
* @param guildId - The guild's id
|
389 |
+
*/
|
390 |
+
declare function channelLink<ChannelId extends Snowflake, GuildId extends Snowflake>(channelId: ChannelId, guildId: GuildId): `https://discord.com/channels/${GuildId}/${ChannelId}`;
|
391 |
+
/**
|
392 |
+
* Formats a message link for a direct message channel.
|
393 |
+
*
|
394 |
+
* @typeParam ChannelId - This is inferred by the supplied channel id
|
395 |
+
* @typeParam MessageId - This is inferred by the supplied message id
|
396 |
+
* @param channelId - The channel's id
|
397 |
+
* @param messageId - The message's id
|
398 |
+
*/
|
399 |
+
declare function messageLink<ChannelId extends Snowflake, MessageId extends Snowflake>(channelId: ChannelId, messageId: MessageId): `https://discord.com/channels/@me/${ChannelId}/${MessageId}`;
|
400 |
+
/**
|
401 |
+
* Formats a message link for a guild channel.
|
402 |
+
*
|
403 |
+
* @typeParam ChannelId - This is inferred by the supplied channel id
|
404 |
+
* @typeParam MessageId - This is inferred by the supplied message id
|
405 |
+
* @typeParam GuildId - This is inferred by the supplied guild id
|
406 |
+
* @param channelId - The channel's id
|
407 |
+
* @param messageId - The message's id
|
408 |
+
* @param guildId - The guild's id
|
409 |
+
*/
|
410 |
+
declare function messageLink<ChannelId extends Snowflake, MessageId extends Snowflake, GuildId extends Snowflake>(channelId: ChannelId, messageId: MessageId, guildId: GuildId): `https://discord.com/channels/${GuildId}/${ChannelId}/${MessageId}`;
|
411 |
+
/**
|
412 |
+
* The heading levels for expanded markdown.
|
413 |
+
*/
|
414 |
+
declare enum HeadingLevel {
|
415 |
+
/**
|
416 |
+
* The first heading level.
|
417 |
+
*/
|
418 |
+
One = 1,
|
419 |
+
/**
|
420 |
+
* The second heading level.
|
421 |
+
*/
|
422 |
+
Two = 2,
|
423 |
+
/**
|
424 |
+
* The third heading level.
|
425 |
+
*/
|
426 |
+
Three = 3
|
427 |
+
}
|
428 |
+
/**
|
429 |
+
* Formats the content into a heading level.
|
430 |
+
*
|
431 |
+
* @typeParam Content - This is inferred by the supplied content
|
432 |
+
* @param content - The content to wrap
|
433 |
+
* @param level - The heading level
|
434 |
+
*/
|
435 |
+
declare function heading<Content extends string>(content: Content, level?: HeadingLevel.One): `# ${Content}`;
|
436 |
+
/**
|
437 |
+
* Formats the content into a heading level.
|
438 |
+
*
|
439 |
+
* @typeParam Content - This is inferred by the supplied content
|
440 |
+
* @param content - The content to wrap
|
441 |
+
* @param level - The heading level
|
442 |
+
*/
|
443 |
+
declare function heading<Content extends string>(content: Content, level: HeadingLevel.Two): `## ${Content}`;
|
444 |
+
/**
|
445 |
+
* Formats the content into a heading level.
|
446 |
+
*
|
447 |
+
* @typeParam Content - This is inferred by the supplied content
|
448 |
+
* @param content - The content to wrap
|
449 |
+
* @param level - The heading level
|
450 |
+
*/
|
451 |
+
declare function heading<Content extends string>(content: Content, level: HeadingLevel.Three): `### ${Content}`;
|
452 |
+
/**
|
453 |
+
* A type that recursively traverses into arrays.
|
454 |
+
*/
|
455 |
+
type RecursiveArray<ItemType> = readonly (ItemType | RecursiveArray<ItemType>)[];
|
456 |
+
/**
|
457 |
+
* Formats the elements in the array to an ordered list.
|
458 |
+
*
|
459 |
+
* @param list - The array of elements to list
|
460 |
+
* @param startNumber - The starting number for the list
|
461 |
+
*/
|
462 |
+
declare function orderedList(list: RecursiveArray<string>, startNumber?: number): string;
|
463 |
+
/**
|
464 |
+
* Formats the elements in the array to an unordered list.
|
465 |
+
*
|
466 |
+
* @param list - The array of elements to list
|
467 |
+
*/
|
468 |
+
declare function unorderedList(list: RecursiveArray<string>): string;
|
469 |
+
/**
|
470 |
+
* Formats a date into a short date-time string.
|
471 |
+
*
|
472 |
+
* @param date - The date to format. Defaults to the current time
|
473 |
+
*/
|
474 |
+
declare function time(date?: Date): `<t:${bigint}>`;
|
475 |
+
/**
|
476 |
+
* Formats a date given a format style.
|
477 |
+
*
|
478 |
+
* @typeParam Style - This is inferred by the supplied {@link TimestampStylesString}
|
479 |
+
* @param date - The date to format
|
480 |
+
* @param style - The style to use
|
481 |
+
*/
|
482 |
+
declare function time<Style extends TimestampStylesString>(date: Date, style: Style): `<t:${bigint}:${Style}>`;
|
483 |
+
/**
|
484 |
+
* Formats the given timestamp into a short date-time string.
|
485 |
+
*
|
486 |
+
* @typeParam Seconds - This is inferred by the supplied timestamp
|
487 |
+
* @param seconds - A Unix timestamp in seconds
|
488 |
+
*/
|
489 |
+
declare function time<Seconds extends number>(seconds: Seconds): `<t:${Seconds}>`;
|
490 |
+
/**
|
491 |
+
* Formats the given timestamp into a short date-time string.
|
492 |
+
*
|
493 |
+
* @typeParam Seconds - This is inferred by the supplied timestamp
|
494 |
+
* @typeParam Style - This is inferred by the supplied {@link TimestampStylesString}
|
495 |
+
* @param seconds - A Unix timestamp in seconds
|
496 |
+
* @param style - The style to use
|
497 |
+
*/
|
498 |
+
declare function time<Seconds extends number, Style extends TimestampStylesString>(seconds: Seconds, style: Style): `<t:${Seconds}:${Style}>`;
|
499 |
+
/**
|
500 |
+
* The {@link https://discord.com/developers/docs/reference#message-formatting-timestamp-styles | message formatting timestamp styles}
|
501 |
+
* supported by Discord.
|
502 |
+
*/
|
503 |
+
declare const TimestampStyles: {
|
504 |
+
/**
|
505 |
+
* Short time format, consisting of hours and minutes.
|
506 |
+
*
|
507 |
+
* @example `16:20`
|
508 |
+
*/
|
509 |
+
readonly ShortTime: "t";
|
510 |
+
/**
|
511 |
+
* Long time format, consisting of hours, minutes, and seconds.
|
512 |
+
*
|
513 |
+
* @example `16:20:30`
|
514 |
+
*/
|
515 |
+
readonly LongTime: "T";
|
516 |
+
/**
|
517 |
+
* Short date format, consisting of day, month, and year.
|
518 |
+
*
|
519 |
+
* @example `20/04/2021`
|
520 |
+
*/
|
521 |
+
readonly ShortDate: "d";
|
522 |
+
/**
|
523 |
+
* Long date format, consisting of day, month, and year.
|
524 |
+
*
|
525 |
+
* @example `20 April 2021`
|
526 |
+
*/
|
527 |
+
readonly LongDate: "D";
|
528 |
+
/**
|
529 |
+
* Short date-time format, consisting of short date and short time formats.
|
530 |
+
*
|
531 |
+
* @example `20 April 2021 16:20`
|
532 |
+
*/
|
533 |
+
readonly ShortDateTime: "f";
|
534 |
+
/**
|
535 |
+
* Long date-time format, consisting of long date and short time formats.
|
536 |
+
*
|
537 |
+
* @example `Tuesday, 20 April 2021 16:20`
|
538 |
+
*/
|
539 |
+
readonly LongDateTime: "F";
|
540 |
+
/**
|
541 |
+
* Relative time format, consisting of a relative duration format.
|
542 |
+
*
|
543 |
+
* @example `2 months ago`
|
544 |
+
*/
|
545 |
+
readonly RelativeTime: "R";
|
546 |
+
};
|
547 |
+
/**
|
548 |
+
* The possible {@link TimestampStyles} values.
|
549 |
+
*/
|
550 |
+
type TimestampStylesString = (typeof TimestampStyles)[keyof typeof TimestampStyles];
|
551 |
+
/**
|
552 |
+
* All the available faces from Discord's native slash commands.
|
553 |
+
*/
|
554 |
+
declare enum Faces {
|
555 |
+
/**
|
556 |
+
* `¯\_(ツ)_/¯`
|
557 |
+
*/
|
558 |
+
Shrug = "\u00AF_(\u30C4)_/\u00AF",
|
559 |
+
/**
|
560 |
+
* `(╯°□°)╯︵ ┻━┻`
|
561 |
+
*/
|
562 |
+
Tableflip = "(\u256F\u00B0\u25A1\u00B0)\u256F\uFE35 \u253B\u2501\u253B",
|
563 |
+
/**
|
564 |
+
* `┬─┬ノ( º _ ºノ)`
|
565 |
+
*/
|
566 |
+
Unflip = "\u252C\u2500\u252C\u30CE( \u00BA _ \u00BA\u30CE)"
|
567 |
+
}
|
568 |
+
/**
|
569 |
+
* All the available guild navigation mentions.
|
570 |
+
*/
|
571 |
+
declare enum GuildNavigationMentions {
|
572 |
+
/**
|
573 |
+
* Browse Channels tab.
|
574 |
+
*/
|
575 |
+
Browse = "<id:browse>",
|
576 |
+
/**
|
577 |
+
* Customize tab with the server's {@link https://discord.com/developers/docs/resources/guild#guild-onboarding-object | onboarding prompts}.
|
578 |
+
*/
|
579 |
+
Customize = "<id:customize>",
|
580 |
+
/**
|
581 |
+
* {@link https://support.discord.com/hc/articles/13497665141655 | Server Guide} tab.
|
582 |
+
*/
|
583 |
+
Guide = "<id:guide>"
|
584 |
+
}
|
585 |
+
|
586 |
+
export { EscapeMarkdownOptions, Faces, GuildNavigationMentions, HeadingLevel, RecursiveArray, TimestampStyles, TimestampStylesString, blockQuote, bold, channelLink, channelMention, chatInputApplicationCommandMention, codeBlock, escapeBold, escapeBulletedList, escapeCodeBlock, escapeEscape, escapeHeading, escapeInlineCode, escapeItalic, escapeMarkdown, escapeMaskedLink, escapeNumberedList, escapeSpoiler, escapeStrikethrough, escapeUnderline, formatEmoji, heading, hideLinkEmbed, hyperlink, inlineCode, italic, messageLink, orderedList, quote, roleMention, spoiler, strikethrough, time, underscore, unorderedList, userMention };
|
node_modules/@discordjs/formatters/dist/index.js
ADDED
@@ -0,0 +1,441 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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ptor;
|
4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6 |
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
7 |
+
var __export = (target, all) => {
|
8 |
+
for (var name in all)
|
9 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
10 |
+
};
|
11 |
+
var __copyProps = (to, from, except, desc) => {
|
12 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
13 |
+
for (let key of __getOwnPropNames(from))
|
14 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16 |
+
}
|
17 |
+
return to;
|
18 |
+
};
|
19 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
20 |
+
|
21 |
+
// src/index.ts
|
22 |
+
var src_exports = {};
|
23 |
+
__export(src_exports, {
|
24 |
+
Faces: () => Faces,
|
25 |
+
GuildNavigationMentions: () => GuildNavigationMentions,
|
26 |
+
HeadingLevel: () => HeadingLevel,
|
27 |
+
TimestampStyles: () => TimestampStyles,
|
28 |
+
blockQuote: () => blockQuote,
|
29 |
+
bold: () => bold,
|
30 |
+
channelLink: () => channelLink,
|
31 |
+
channelMention: () => channelMention,
|
32 |
+
chatInputApplicationCommandMention: () => chatInputApplicationCommandMention,
|
33 |
+
codeBlock: () => codeBlock,
|
34 |
+
escapeBold: () => escapeBold,
|
35 |
+
escapeBulletedList: () => escapeBulletedList,
|
36 |
+
escapeCodeBlock: () => escapeCodeBlock,
|
37 |
+
escapeEscape: () => escapeEscape,
|
38 |
+
escapeHeading: () => escapeHeading,
|
39 |
+
escapeInlineCode: () => escapeInlineCode,
|
40 |
+
escapeItalic: () => escapeItalic,
|
41 |
+
escapeMarkdown: () => escapeMarkdown,
|
42 |
+
escapeMaskedLink: () => escapeMaskedLink,
|
43 |
+
escapeNumberedList: () => escapeNumberedList,
|
44 |
+
escapeSpoiler: () => escapeSpoiler,
|
45 |
+
escapeStrikethrough: () => escapeStrikethrough,
|
46 |
+
escapeUnderline: () => escapeUnderline,
|
47 |
+
formatEmoji: () => formatEmoji,
|
48 |
+
heading: () => heading,
|
49 |
+
hideLinkEmbed: () => hideLinkEmbed,
|
50 |
+
hyperlink: () => hyperlink,
|
51 |
+
inlineCode: () => inlineCode,
|
52 |
+
italic: () => italic,
|
53 |
+
messageLink: () => messageLink,
|
54 |
+
orderedList: () => orderedList,
|
55 |
+
quote: () => quote,
|
56 |
+
roleMention: () => roleMention,
|
57 |
+
spoiler: () => spoiler,
|
58 |
+
strikethrough: () => strikethrough,
|
59 |
+
time: () => time,
|
60 |
+
underscore: () => underscore,
|
61 |
+
unorderedList: () => unorderedList,
|
62 |
+
userMention: () => userMention
|
63 |
+
});
|
64 |
+
module.exports = __toCommonJS(src_exports);
|
65 |
+
|
66 |
+
// src/escapers.ts
|
67 |
+
function escapeMarkdown(text, options = {}) {
|
68 |
+
const {
|
69 |
+
codeBlock: codeBlock2 = true,
|
70 |
+
inlineCode: inlineCode2 = true,
|
71 |
+
bold: bold2 = true,
|
72 |
+
italic: italic2 = true,
|
73 |
+
underline = true,
|
74 |
+
strikethrough: strikethrough2 = true,
|
75 |
+
spoiler: spoiler2 = true,
|
76 |
+
codeBlockContent = true,
|
77 |
+
inlineCodeContent = true,
|
78 |
+
escape = true,
|
79 |
+
heading: heading2 = false,
|
80 |
+
bulletedList = false,
|
81 |
+
numberedList = false,
|
82 |
+
maskedLink = false
|
83 |
+
} = options;
|
84 |
+
if (!codeBlockContent) {
|
85 |
+
return text.split("```").map((subString, index, array) => {
|
86 |
+
if (index % 2 && index !== array.length - 1)
|
87 |
+
return subString;
|
88 |
+
return escapeMarkdown(subString, {
|
89 |
+
inlineCode: inlineCode2,
|
90 |
+
bold: bold2,
|
91 |
+
italic: italic2,
|
92 |
+
underline,
|
93 |
+
strikethrough: strikethrough2,
|
94 |
+
spoiler: spoiler2,
|
95 |
+
inlineCodeContent,
|
96 |
+
escape,
|
97 |
+
heading: heading2,
|
98 |
+
bulletedList,
|
99 |
+
numberedList,
|
100 |
+
maskedLink
|
101 |
+
});
|
102 |
+
}).join(codeBlock2 ? "\\`\\`\\`" : "```");
|
103 |
+
}
|
104 |
+
if (!inlineCodeContent) {
|
105 |
+
return text.split(/(?<=^|[^`])`(?=[^`]|$)/g).map((subString, index, array) => {
|
106 |
+
if (index % 2 && index !== array.length - 1)
|
107 |
+
return subString;
|
108 |
+
return escapeMarkdown(subString, {
|
109 |
+
codeBlock: codeBlock2,
|
110 |
+
bold: bold2,
|
111 |
+
italic: italic2,
|
112 |
+
underline,
|
113 |
+
strikethrough: strikethrough2,
|
114 |
+
spoiler: spoiler2,
|
115 |
+
escape,
|
116 |
+
heading: heading2,
|
117 |
+
bulletedList,
|
118 |
+
numberedList,
|
119 |
+
maskedLink
|
120 |
+
});
|
121 |
+
}).join(inlineCode2 ? "\\`" : "`");
|
122 |
+
}
|
123 |
+
let res = text;
|
124 |
+
if (escape)
|
125 |
+
res = escapeEscape(res);
|
126 |
+
if (inlineCode2)
|
127 |
+
res = escapeInlineCode(res);
|
128 |
+
if (codeBlock2)
|
129 |
+
res = escapeCodeBlock(res);
|
130 |
+
if (italic2)
|
131 |
+
res = escapeItalic(res);
|
132 |
+
if (bold2)
|
133 |
+
res = escapeBold(res);
|
134 |
+
if (underline)
|
135 |
+
res = escapeUnderline(res);
|
136 |
+
if (strikethrough2)
|
137 |
+
res = escapeStrikethrough(res);
|
138 |
+
if (spoiler2)
|
139 |
+
res = escapeSpoiler(res);
|
140 |
+
if (heading2)
|
141 |
+
res = escapeHeading(res);
|
142 |
+
if (bulletedList)
|
143 |
+
res = escapeBulletedList(res);
|
144 |
+
if (numberedList)
|
145 |
+
res = escapeNumberedList(res);
|
146 |
+
if (maskedLink)
|
147 |
+
res = escapeMaskedLink(res);
|
148 |
+
return res;
|
149 |
+
}
|
150 |
+
__name(escapeMarkdown, "escapeMarkdown");
|
151 |
+
function escapeCodeBlock(text) {
|
152 |
+
return text.replaceAll("```", "\\`\\`\\`");
|
153 |
+
}
|
154 |
+
__name(escapeCodeBlock, "escapeCodeBlock");
|
155 |
+
function escapeInlineCode(text) {
|
156 |
+
return text.replaceAll(/(?<=^|[^`])``?(?=[^`]|$)/g, (match) => match.length === 2 ? "\\`\\`" : "\\`");
|
157 |
+
}
|
158 |
+
__name(escapeInlineCode, "escapeInlineCode");
|
159 |
+
function escapeItalic(text) {
|
160 |
+
let idx = 0;
|
161 |
+
const newText = text.replaceAll(/(?<=^|[^*])\*([^*]|\*\*|$)/g, (_, match) => {
|
162 |
+
if (match === "**")
|
163 |
+
return ++idx % 2 ? `\\*${match}` : `${match}\\*`;
|
164 |
+
return `\\*${match}`;
|
165 |
+
});
|
166 |
+
idx = 0;
|
167 |
+
return newText.replaceAll(/(?<=^|[^_])(?<!<a?:.+)_(?!:\d+>)([^_]|__|$)/g, (_, match) => {
|
168 |
+
if (match === "__")
|
169 |
+
return ++idx % 2 ? `\\_${match}` : `${match}\\_`;
|
170 |
+
return `\\_${match}`;
|
171 |
+
});
|
172 |
+
}
|
173 |
+
__name(escapeItalic, "escapeItalic");
|
174 |
+
function escapeBold(text) {
|
175 |
+
let idx = 0;
|
176 |
+
return text.replaceAll(/\*\*(\*)?/g, (_, match) => {
|
177 |
+
if (match)
|
178 |
+
return ++idx % 2 ? `${match}\\*\\*` : `\\*\\*${match}`;
|
179 |
+
return "\\*\\*";
|
180 |
+
});
|
181 |
+
}
|
182 |
+
__name(escapeBold, "escapeBold");
|
183 |
+
function escapeUnderline(text) {
|
184 |
+
let idx = 0;
|
185 |
+
return text.replaceAll(/(?<!<a?:.+)__(_)?(?!:\d+>)/g, (_, match) => {
|
186 |
+
if (match)
|
187 |
+
return ++idx % 2 ? `${match}\\_\\_` : `\\_\\_${match}`;
|
188 |
+
return "\\_\\_";
|
189 |
+
});
|
190 |
+
}
|
191 |
+
__name(escapeUnderline, "escapeUnderline");
|
192 |
+
function escapeStrikethrough(text) {
|
193 |
+
return text.replaceAll("~~", "\\~\\~");
|
194 |
+
}
|
195 |
+
__name(escapeStrikethrough, "escapeStrikethrough");
|
196 |
+
function escapeSpoiler(text) {
|
197 |
+
return text.replaceAll("||", "\\|\\|");
|
198 |
+
}
|
199 |
+
__name(escapeSpoiler, "escapeSpoiler");
|
200 |
+
function escapeEscape(text) {
|
201 |
+
return text.replaceAll("\\", "\\\\");
|
202 |
+
}
|
203 |
+
__name(escapeEscape, "escapeEscape");
|
204 |
+
function escapeHeading(text) {
|
205 |
+
return text.replaceAll(/^( {0,2})([*-] )?( *)(#{1,3} )/gm, "$1$2$3\\$4");
|
206 |
+
}
|
207 |
+
__name(escapeHeading, "escapeHeading");
|
208 |
+
function escapeBulletedList(text) {
|
209 |
+
return text.replaceAll(/^( *)([*-])( +)/gm, "$1\\$2$3");
|
210 |
+
}
|
211 |
+
__name(escapeBulletedList, "escapeBulletedList");
|
212 |
+
function escapeNumberedList(text) {
|
213 |
+
return text.replaceAll(/^( *\d+)\./gm, "$1\\.");
|
214 |
+
}
|
215 |
+
__name(escapeNumberedList, "escapeNumberedList");
|
216 |
+
function escapeMaskedLink(text) {
|
217 |
+
return text.replaceAll(/\[.+]\(.+\)/gm, "\\$&");
|
218 |
+
}
|
219 |
+
__name(escapeMaskedLink, "escapeMaskedLink");
|
220 |
+
|
221 |
+
// src/formatters.ts
|
222 |
+
function codeBlock(language, content) {
|
223 |
+
return content === void 0 ? `\`\`\`
|
224 |
+
${language}
|
225 |
+
\`\`\`` : `\`\`\`${language}
|
226 |
+
${content}
|
227 |
+
\`\`\``;
|
228 |
+
}
|
229 |
+
__name(codeBlock, "codeBlock");
|
230 |
+
function inlineCode(content) {
|
231 |
+
return `\`${content}\``;
|
232 |
+
}
|
233 |
+
__name(inlineCode, "inlineCode");
|
234 |
+
function italic(content) {
|
235 |
+
return `_${content}_`;
|
236 |
+
}
|
237 |
+
__name(italic, "italic");
|
238 |
+
function bold(content) {
|
239 |
+
return `**${content}**`;
|
240 |
+
}
|
241 |
+
__name(bold, "bold");
|
242 |
+
function underscore(content) {
|
243 |
+
return `__${content}__`;
|
244 |
+
}
|
245 |
+
__name(underscore, "underscore");
|
246 |
+
function strikethrough(content) {
|
247 |
+
return `~~${content}~~`;
|
248 |
+
}
|
249 |
+
__name(strikethrough, "strikethrough");
|
250 |
+
function quote(content) {
|
251 |
+
return `> ${content}`;
|
252 |
+
}
|
253 |
+
__name(quote, "quote");
|
254 |
+
function blockQuote(content) {
|
255 |
+
return `>>> ${content}`;
|
256 |
+
}
|
257 |
+
__name(blockQuote, "blockQuote");
|
258 |
+
function hideLinkEmbed(url) {
|
259 |
+
return `<${url}>`;
|
260 |
+
}
|
261 |
+
__name(hideLinkEmbed, "hideLinkEmbed");
|
262 |
+
function hyperlink(content, url, title) {
|
263 |
+
return title ? `[${content}](${url} "${title}")` : `[${content}](${url})`;
|
264 |
+
}
|
265 |
+
__name(hyperlink, "hyperlink");
|
266 |
+
function spoiler(content) {
|
267 |
+
return `||${content}||`;
|
268 |
+
}
|
269 |
+
__name(spoiler, "spoiler");
|
270 |
+
function userMention(userId) {
|
271 |
+
return `<@${userId}>`;
|
272 |
+
}
|
273 |
+
__name(userMention, "userMention");
|
274 |
+
function channelMention(channelId) {
|
275 |
+
return `<#${channelId}>`;
|
276 |
+
}
|
277 |
+
__name(channelMention, "channelMention");
|
278 |
+
function roleMention(roleId) {
|
279 |
+
return `<@&${roleId}>`;
|
280 |
+
}
|
281 |
+
__name(roleMention, "roleMention");
|
282 |
+
function chatInputApplicationCommandMention(commandName, subcommandGroupName, subcommandName, commandId) {
|
283 |
+
if (commandId !== void 0) {
|
284 |
+
return `</${commandName} ${subcommandGroupName} ${subcommandName}:${commandId}>`;
|
285 |
+
}
|
286 |
+
if (subcommandName !== void 0) {
|
287 |
+
return `</${commandName} ${subcommandGroupName}:${subcommandName}>`;
|
288 |
+
}
|
289 |
+
return `</${commandName}:${subcommandGroupName}>`;
|
290 |
+
}
|
291 |
+
__name(chatInputApplicationCommandMention, "chatInputApplicationCommandMention");
|
292 |
+
function formatEmoji(emojiId, animated = false) {
|
293 |
+
return `<${animated ? "a" : ""}:_:${emojiId}>`;
|
294 |
+
}
|
295 |
+
__name(formatEmoji, "formatEmoji");
|
296 |
+
function channelLink(channelId, guildId) {
|
297 |
+
return `https://discord.com/channels/${guildId ?? "@me"}/${channelId}`;
|
298 |
+
}
|
299 |
+
__name(channelLink, "channelLink");
|
300 |
+
function messageLink(channelId, messageId, guildId) {
|
301 |
+
return `${guildId === void 0 ? channelLink(channelId) : channelLink(channelId, guildId)}/${messageId}`;
|
302 |
+
}
|
303 |
+
__name(messageLink, "messageLink");
|
304 |
+
var HeadingLevel = /* @__PURE__ */ ((HeadingLevel2) => {
|
305 |
+
HeadingLevel2[HeadingLevel2["One"] = 1] = "One";
|
306 |
+
HeadingLevel2[HeadingLevel2["Two"] = 2] = "Two";
|
307 |
+
HeadingLevel2[HeadingLevel2["Three"] = 3] = "Three";
|
308 |
+
return HeadingLevel2;
|
309 |
+
})(HeadingLevel || {});
|
310 |
+
function heading(content, level) {
|
311 |
+
switch (level) {
|
312 |
+
case 3 /* Three */:
|
313 |
+
return `### ${content}`;
|
314 |
+
case 2 /* Two */:
|
315 |
+
return `## ${content}`;
|
316 |
+
default:
|
317 |
+
return `# ${content}`;
|
318 |
+
}
|
319 |
+
}
|
320 |
+
__name(heading, "heading");
|
321 |
+
function listCallback(element, startNumber, depth = 0) {
|
322 |
+
if (Array.isArray(element)) {
|
323 |
+
return element.map((element2) => listCallback(element2, startNumber, depth + 1)).join("\n");
|
324 |
+
}
|
325 |
+
return `${" ".repeat(depth - 1)}${startNumber ? `${startNumber}.` : "-"} ${element}`;
|
326 |
+
}
|
327 |
+
__name(listCallback, "listCallback");
|
328 |
+
function orderedList(list, startNumber = 1) {
|
329 |
+
return listCallback(list, Math.max(startNumber, 1));
|
330 |
+
}
|
331 |
+
__name(orderedList, "orderedList");
|
332 |
+
function unorderedList(list) {
|
333 |
+
return listCallback(list);
|
334 |
+
}
|
335 |
+
__name(unorderedList, "unorderedList");
|
336 |
+
function time(timeOrSeconds, style) {
|
337 |
+
if (typeof timeOrSeconds !== "number") {
|
338 |
+
timeOrSeconds = Math.floor((timeOrSeconds?.getTime() ?? Date.now()) / 1e3);
|
339 |
+
}
|
340 |
+
return typeof style === "string" ? `<t:${timeOrSeconds}:${style}>` : `<t:${timeOrSeconds}>`;
|
341 |
+
}
|
342 |
+
__name(time, "time");
|
343 |
+
var TimestampStyles = {
|
344 |
+
/**
|
345 |
+
* Short time format, consisting of hours and minutes.
|
346 |
+
*
|
347 |
+
* @example `16:20`
|
348 |
+
*/
|
349 |
+
ShortTime: "t",
|
350 |
+
/**
|
351 |
+
* Long time format, consisting of hours, minutes, and seconds.
|
352 |
+
*
|
353 |
+
* @example `16:20:30`
|
354 |
+
*/
|
355 |
+
LongTime: "T",
|
356 |
+
/**
|
357 |
+
* Short date format, consisting of day, month, and year.
|
358 |
+
*
|
359 |
+
* @example `20/04/2021`
|
360 |
+
*/
|
361 |
+
ShortDate: "d",
|
362 |
+
/**
|
363 |
+
* Long date format, consisting of day, month, and year.
|
364 |
+
*
|
365 |
+
* @example `20 April 2021`
|
366 |
+
*/
|
367 |
+
LongDate: "D",
|
368 |
+
/**
|
369 |
+
* Short date-time format, consisting of short date and short time formats.
|
370 |
+
*
|
371 |
+
* @example `20 April 2021 16:20`
|
372 |
+
*/
|
373 |
+
ShortDateTime: "f",
|
374 |
+
/**
|
375 |
+
* Long date-time format, consisting of long date and short time formats.
|
376 |
+
*
|
377 |
+
* @example `Tuesday, 20 April 2021 16:20`
|
378 |
+
*/
|
379 |
+
LongDateTime: "F",
|
380 |
+
/**
|
381 |
+
* Relative time format, consisting of a relative duration format.
|
382 |
+
*
|
383 |
+
* @example `2 months ago`
|
384 |
+
*/
|
385 |
+
RelativeTime: "R"
|
386 |
+
};
|
387 |
+
var Faces = /* @__PURE__ */ ((Faces2) => {
|
388 |
+
Faces2["Shrug"] = "\xAF_(\u30C4)_/\xAF";
|
389 |
+
Faces2["Tableflip"] = "(\u256F\xB0\u25A1\xB0)\u256F\uFE35 \u253B\u2501\u253B";
|
390 |
+
Faces2["Unflip"] = "\u252C\u2500\u252C\u30CE( \xBA _ \xBA\u30CE)";
|
391 |
+
return Faces2;
|
392 |
+
})(Faces || {});
|
393 |
+
var GuildNavigationMentions = /* @__PURE__ */ ((GuildNavigationMentions2) => {
|
394 |
+
GuildNavigationMentions2["Browse"] = "<id:browse>";
|
395 |
+
GuildNavigationMentions2["Customize"] = "<id:customize>";
|
396 |
+
GuildNavigationMentions2["Guide"] = "<id:guide>";
|
397 |
+
return GuildNavigationMentions2;
|
398 |
+
})(GuildNavigationMentions || {});
|
399 |
+
// Annotate the CommonJS export names for ESM import in node:
|
400 |
+
0 && (module.exports = {
|
401 |
+
Faces,
|
402 |
+
GuildNavigationMentions,
|
403 |
+
HeadingLevel,
|
404 |
+
TimestampStyles,
|
405 |
+
blockQuote,
|
406 |
+
bold,
|
407 |
+
channelLink,
|
408 |
+
channelMention,
|
409 |
+
chatInputApplicationCommandMention,
|
410 |
+
codeBlock,
|
411 |
+
escapeBold,
|
412 |
+
escapeBulletedList,
|
413 |
+
escapeCodeBlock,
|
414 |
+
escapeEscape,
|
415 |
+
escapeHeading,
|
416 |
+
escapeInlineCode,
|
417 |
+
escapeItalic,
|
418 |
+
escapeMarkdown,
|
419 |
+
escapeMaskedLink,
|
420 |
+
escapeNumberedList,
|
421 |
+
escapeSpoiler,
|
422 |
+
escapeStrikethrough,
|
423 |
+
escapeUnderline,
|
424 |
+
formatEmoji,
|
425 |
+
heading,
|
426 |
+
hideLinkEmbed,
|
427 |
+
hyperlink,
|
428 |
+
inlineCode,
|
429 |
+
italic,
|
430 |
+
messageLink,
|
431 |
+
orderedList,
|
432 |
+
quote,
|
433 |
+
roleMention,
|
434 |
+
spoiler,
|
435 |
+
strikethrough,
|
436 |
+
time,
|
437 |
+
underscore,
|
438 |
+
unorderedList,
|
439 |
+
userMention
|
440 |
+
});
|
441 |
+
//# sourceMappingURL=index.js.map
|
node_modules/@discordjs/formatters/dist/index.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"sources":["../src/index.ts","../src/escapers.ts","../src/formatters.ts"],"sourcesContent":["export * from './escapers.js';\nexport * from './formatters.js';\n","/* eslint-disable prefer-named-capture-group */\n\n/**\n * The options that affect what will be escaped.\n */\nexport interface EscapeMarkdownOptions {\n\t/**\n\t * Whether to escape bold text.\n\t *\n\t * @defaultValue `true`\n\t */\n\tbold?: boolean;\n\n\t/**\n\t * Whether to escape bulleted lists.\n\t *\n\t * @defaultValue `false`\n\t */\n\tbulletedList?: boolean;\n\n\t/**\n\t * Whether to escape code blocks.\n\t *\n\t * @defaultValue `true`\n\t */\n\tcodeBlock?: boolean;\n\n\t/**\n\t * Whether to escape text inside code blocks.\n\t *\n\t * @defaultValue `true`\n\t */\n\tcodeBlockContent?: boolean;\n\n\t/**\n\t * Whether to escape `\\`.\n\t *\n\t * @defaultValue `true`\n\t */\n\tescape?: boolean;\n\n\t/**\n\t * Whether to escape headings.\n\t *\n\t * @defaultValue `false`\n\t */\n\theading?: boolean;\n\n\t/**\n\t * Whether to escape inline code.\n\t *\n\t * @defaultValue `true`\n\t */\n\tinlineCode?: boolean;\n\n\t/**\n\t * Whether to escape text inside inline code.\n\t *\n\t * @defaultValue `true`\n\t */\n\tinlineCodeContent?: boolean;\n\t/**\n\t * Whether to escape italics.\n\t *\n\t * @defaultValue `true`\n\t */\n\titalic?: boolean;\n\n\t/**\n\t * Whether to escape masked links.\n\t *\n\t * @defaultValue `false`\n\t */\n\tmaskedLink?: boolean;\n\n\t/**\n\t * Whether to escape numbered lists.\n\t *\n\t * @defaultValue `false`\n\t */\n\tnumberedList?: boolean;\n\n\t/**\n\t * Whether to escape spoilers.\n\t *\n\t * @defaultValue `true`\n\t */\n\tspoiler?: boolean;\n\n\t/**\n\t * Whether to escape strikethroughs.\n\t *\n\t * @defaultValue `true`\n\t */\n\tstrikethrough?: boolean;\n\n\t/**\n\t * Whether to escape underlines.\n\t *\n\t * @defaultValue `true`\n\t */\n\tunderline?: boolean;\n}\n\n/**\n * Escapes any Discord-flavored markdown in a string.\n *\n * @param text - Content to escape\n * @param options - Options for escaping the markdown\n */\nexport function escapeMarkdown(text: string, options: EscapeMarkdownOptions = {}): string {\n\tconst {\n\t\tcodeBlock = true,\n\t\tinlineCode = true,\n\t\tbold = true,\n\t\titalic = true,\n\t\tunderline = true,\n\t\tstrikethrough = true,\n\t\tspoiler = true,\n\t\tcodeBlockContent = true,\n\t\tinlineCodeContent = true,\n\t\tescape = true,\n\t\theading = false,\n\t\tbulletedList = false,\n\t\tnumberedList = false,\n\t\tmaskedLink = false,\n\t} = options;\n\n\tif (!codeBlockContent) {\n\t\treturn text\n\t\t\t.split('```')\n\t\t\t.map((subString, index, array) => {\n\t\t\t\tif (index % 2 && index !== array.length - 1) return subString;\n\t\t\t\treturn escapeMarkdown(subString, {\n\t\t\t\t\tinlineCode,\n\t\t\t\t\tbold,\n\t\t\t\t\titalic,\n\t\t\t\t\tunderline,\n\t\t\t\t\tstrikethrough,\n\t\t\t\t\tspoiler,\n\t\t\t\t\tinlineCodeContent,\n\t\t\t\t\tescape,\n\t\t\t\t\theading,\n\t\t\t\t\tbulletedList,\n\t\t\t\t\tnumberedList,\n\t\t\t\t\tmaskedLink,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.join(codeBlock ? '\\\\`\\\\`\\\\`' : '```');\n\t}\n\n\tif (!inlineCodeContent) {\n\t\treturn text\n\t\t\t.split(/(?<=^|[^`])`(?=[^`]|$)/g)\n\t\t\t.map((subString, index, array) => {\n\t\t\t\tif (index % 2 && index !== array.length - 1) return subString;\n\t\t\t\treturn escapeMarkdown(subString, {\n\t\t\t\t\tcodeBlock,\n\t\t\t\t\tbold,\n\t\t\t\t\titalic,\n\t\t\t\t\tunderline,\n\t\t\t\t\tstrikethrough,\n\t\t\t\t\tspoiler,\n\t\t\t\t\tescape,\n\t\t\t\t\theading,\n\t\t\t\t\tbulletedList,\n\t\t\t\t\tnumberedList,\n\t\t\t\t\tmaskedLink,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.join(inlineCode ? '\\\\`' : '`');\n\t}\n\n\tlet res = text;\n\tif (escape) res = escapeEscape(res);\n\tif (inlineCode) res = escapeInlineCode(res);\n\tif (codeBlock) res = escapeCodeBlock(res);\n\tif (italic) res = escapeItalic(res);\n\tif (bold) res = escapeBold(res);\n\tif (underline) res = escapeUnderline(res);\n\tif (strikethrough) res = escapeStrikethrough(res);\n\tif (spoiler) res = escapeSpoiler(res);\n\tif (heading) res = escapeHeading(res);\n\tif (bulletedList) res = escapeBulletedList(res);\n\tif (numberedList) res = escapeNumberedList(res);\n\tif (maskedLink) res = escapeMaskedLink(res);\n\treturn res;\n}\n\n/**\n * Escapes code block markdown in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeCodeBlock(text: string): string {\n\treturn text.replaceAll('```', '\\\\`\\\\`\\\\`');\n}\n\n/**\n * Escapes inline code markdown in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeInlineCode(text: string): string {\n\treturn text.replaceAll(/(?<=^|[^`])``?(?=[^`]|$)/g, (match) => (match.length === 2 ? '\\\\`\\\\`' : '\\\\`'));\n}\n\n/**\n * Escapes italic markdown in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeItalic(text: string): string {\n\tlet idx = 0;\n\tconst newText = text.replaceAll(/(?<=^|[^*])\\*([^*]|\\*\\*|$)/g, (_, match) => {\n\t\tif (match === '**') return ++idx % 2 ? `\\\\*${match}` : `${match}\\\\*`;\n\t\treturn `\\\\*${match}`;\n\t});\n\tidx = 0;\n\treturn newText.replaceAll(/(?<=^|[^_])(?<!<a?:.+)_(?!:\\d+>)([^_]|__|$)/g, (_, match) => {\n\t\tif (match === '__') return ++idx % 2 ? `\\\\_${match}` : `${match}\\\\_`;\n\t\treturn `\\\\_${match}`;\n\t});\n}\n\n/**\n * Escapes bold markdown in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeBold(text: string): string {\n\tlet idx = 0;\n\treturn text.replaceAll(/\\*\\*(\\*)?/g, (_, match) => {\n\t\tif (match) return ++idx % 2 ? `${match}\\\\*\\\\*` : `\\\\*\\\\*${match}`;\n\t\treturn '\\\\*\\\\*';\n\t});\n}\n\n/**\n * Escapes underline markdown in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeUnderline(text: string): string {\n\tlet idx = 0;\n\treturn text.replaceAll(/(?<!<a?:.+)__(_)?(?!:\\d+>)/g, (_, match) => {\n\t\tif (match) return ++idx % 2 ? `${match}\\\\_\\\\_` : `\\\\_\\\\_${match}`;\n\t\treturn '\\\\_\\\\_';\n\t});\n}\n\n/**\n * Escapes strikethrough markdown in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeStrikethrough(text: string): string {\n\treturn text.replaceAll('~~', '\\\\~\\\\~');\n}\n\n/**\n * Escapes spoiler markdown in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeSpoiler(text: string): string {\n\treturn text.replaceAll('||', '\\\\|\\\\|');\n}\n\n/**\n * Escapes escape characters in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeEscape(text: string): string {\n\treturn text.replaceAll('\\\\', '\\\\\\\\');\n}\n\n/**\n * Escapes heading characters in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeHeading(text: string): string {\n\treturn text.replaceAll(/^( {0,2})([*-] )?( *)(#{1,3} )/gm, '$1$2$3\\\\$4');\n}\n\n/**\n * Escapes bulleted list characters in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeBulletedList(text: string): string {\n\treturn text.replaceAll(/^( *)([*-])( +)/gm, '$1\\\\$2$3');\n}\n\n/**\n * Escapes numbered list characters in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeNumberedList(text: string): string {\n\treturn text.replaceAll(/^( *\\d+)\\./gm, '$1\\\\.');\n}\n\n/**\n * Escapes masked link characters in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeMaskedLink(text: string): string {\n\treturn text.replaceAll(/\\[.+]\\(.+\\)/gm, '\\\\$&');\n}\n","import type { URL } from 'node:url';\nimport type { Snowflake } from 'discord-api-types/globals';\n\n/**\n * Wraps the content inside a code block with no language.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function codeBlock<Content extends string>(content: Content): `\\`\\`\\`\\n${Content}\\n\\`\\`\\``;\n\n/**\n * Wraps the content inside a code block with the specified language.\n *\n * @typeParam Language - This is inferred by the supplied language\n * @typeParam Content - This is inferred by the supplied content\n * @param language - The language for the code block\n * @param content - The content to wrap\n */\nexport function codeBlock<Language extends string, Content extends string>(\n\tlanguage: Language,\n\tcontent: Content,\n): `\\`\\`\\`${Language}\\n${Content}\\n\\`\\`\\``;\n\nexport function codeBlock(language: string, content?: string): string {\n\treturn content === undefined ? `\\`\\`\\`\\n${language}\\n\\`\\`\\`` : `\\`\\`\\`${language}\\n${content}\\n\\`\\`\\``;\n}\n\n/**\n * Wraps the content inside \\`backticks\\` which formats it as inline code.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function inlineCode<Content extends string>(content: Content): `\\`${Content}\\`` {\n\treturn `\\`${content}\\``;\n}\n\n/**\n * Formats the content into italic text.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function italic<Content extends string>(content: Content): `_${Content}_` {\n\treturn `_${content}_`;\n}\n\n/**\n * Formats the content into bold text.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function bold<Content extends string>(content: Content): `**${Content}**` {\n\treturn `**${content}**`;\n}\n\n/**\n * Formats the content into underscored text.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function underscore<Content extends string>(content: Content): `__${Content}__` {\n\treturn `__${content}__`;\n}\n\n/**\n * Formats the content into strike-through text.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function strikethrough<Content extends string>(content: Content): `~~${Content}~~` {\n\treturn `~~${content}~~`;\n}\n\n/**\n * Formats the content into a quote.\n *\n * @remarks This needs to be at the start of the line for Discord to format it.\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function quote<Content extends string>(content: Content): `> ${Content}` {\n\treturn `> ${content}`;\n}\n\n/**\n * Formats the content into a block quote.\n *\n * @remarks This needs to be at the start of the line for Discord to format it.\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function blockQuote<Content extends string>(content: Content): `>>> ${Content}` {\n\treturn `>>> ${content}`;\n}\n\n/**\n * Wraps the URL into `<>` which stops it from embedding.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param url - The URL to wrap\n */\nexport function hideLinkEmbed<Content extends string>(url: Content): `<${Content}>`;\n\n/**\n * Wraps the URL into `<>` which stops it from embedding.\n *\n * @param url - The URL to wrap\n */\nexport function hideLinkEmbed(url: URL): `<${string}>`;\n\nexport function hideLinkEmbed(url: URL | string) {\n\treturn `<${url}>`;\n}\n\n/**\n * Formats the content and the URL into a masked URL.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to display\n * @param url - The URL the content links to\n */\nexport function hyperlink<Content extends string>(content: Content, url: URL): `[${Content}](${string})`;\n\n/**\n * Formats the content and the URL into a masked URL.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @typeParam Url - This is inferred by the supplied URL\n * @param content - The content to display\n * @param url - The URL the content links to\n */\nexport function hyperlink<Content extends string, Url extends string>(\n\tcontent: Content,\n\turl: Url,\n): `[${Content}](${Url})`;\n\n/**\n * Formats the content and the URL into a masked URL with a custom tooltip.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @typeParam Title - This is inferred by the supplied title\n * @param content - The content to display\n * @param url - The URL the content links to\n * @param title - The title shown when hovering on the masked link\n */\nexport function hyperlink<Content extends string, Title extends string>(\n\tcontent: Content,\n\turl: URL,\n\ttitle: Title,\n): `[${Content}](${string} \"${Title}\")`;\n\n/**\n * Formats the content and the URL into a masked URL with a custom tooltip.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @typeParam Url - This is inferred by the supplied URL\n * @typeParam Title - This is inferred by the supplied title\n * @param content - The content to display\n * @param url - The URL the content links to\n * @param title - The title shown when hovering on the masked link\n */\nexport function hyperlink<Content extends string, Url extends string, Title extends string>(\n\tcontent: Content,\n\turl: Url,\n\ttitle: Title,\n): `[${Content}](${Url} \"${Title}\")`;\n\nexport function hyperlink(content: string, url: URL | string, title?: string) {\n\treturn title ? `[${content}](${url} \"${title}\")` : `[${content}](${url})`;\n}\n\n/**\n * Formats the content into a spoiler.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function spoiler<Content extends string>(content: Content): `||${Content}||` {\n\treturn `||${content}||`;\n}\n\n/**\n * Formats a user id into a user mention.\n *\n * @typeParam UserId - This is inferred by the supplied user id\n * @param userId - The user id to format\n */\nexport function userMention<UserId extends Snowflake>(userId: UserId): `<@${UserId}>` {\n\treturn `<@${userId}>`;\n}\n\n/**\n * Formats a channel id into a channel mention.\n *\n * @typeParam ChannelId - This is inferred by the supplied channel id\n * @param channelId - The channel id to format\n */\nexport function channelMention<ChannelId extends Snowflake>(channelId: ChannelId): `<#${ChannelId}>` {\n\treturn `<#${channelId}>`;\n}\n\n/**\n * Formats a role id into a role mention.\n *\n * @typeParam RoleId - This is inferred by the supplied role id\n * @param roleId - The role id to format\n */\nexport function roleMention<RoleId extends Snowflake>(roleId: RoleId): `<@&${RoleId}>` {\n\treturn `<@&${roleId}>`;\n}\n\n/**\n * Formats an application command name, subcommand group name, subcommand name, and id into an application command mention.\n *\n * @typeParam CommandName - This is inferred by the supplied command name\n * @typeParam SubcommandGroupName - This is inferred by the supplied subcommand group name\n * @typeParam SubcommandName - This is inferred by the supplied subcommand name\n * @typeParam CommandId - This is inferred by the supplied command id\n * @param commandName - The application command name to format\n * @param subcommandGroupName - The subcommand group name to format\n * @param subcommandName - The subcommand name to format\n * @param commandId - The application command id to format\n */\nexport function chatInputApplicationCommandMention<\n\tCommandName extends string,\n\tSubcommandGroupName extends string,\n\tSubcommandName extends string,\n\tCommandId extends Snowflake,\n>(\n\tcommandName: CommandName,\n\tsubcommandGroupName: SubcommandGroupName,\n\tsubcommandName: SubcommandName,\n\tcommandId: CommandId,\n): `</${CommandName} ${SubcommandGroupName} ${SubcommandName}:${CommandId}>`;\n\n/**\n * Formats an application command name, subcommand name, and id into an application command mention.\n *\n * @typeParam CommandName - This is inferred by the supplied command name\n * @typeParam SubcommandName - This is inferred by the supplied subcommand name\n * @typeParam CommandId - This is inferred by the supplied command id\n * @param commandName - The application command name to format\n * @param subcommandName - The subcommand name to format\n * @param commandId - The application command id to format\n */\nexport function chatInputApplicationCommandMention<\n\tCommandName extends string,\n\tSubcommandName extends string,\n\tCommandId extends Snowflake,\n>(\n\tcommandName: CommandName,\n\tsubcommandName: SubcommandName,\n\tcommandId: CommandId,\n): `</${CommandName} ${SubcommandName}:${CommandId}>`;\n\n/**\n * Formats an application command name and id into an application command mention.\n *\n * @typeParam CommandName - This is inferred by the supplied command name\n * @typeParam CommandId - This is inferred by the supplied command id\n * @param commandName - The application command name to format\n * @param commandId - The application command id to format\n */\nexport function chatInputApplicationCommandMention<CommandName extends string, CommandId extends Snowflake>(\n\tcommandName: CommandName,\n\tcommandId: CommandId,\n): `</${CommandName}:${CommandId}>`;\n\nexport function chatInputApplicationCommandMention<\n\tCommandName extends string,\n\tSubcommandGroupName extends Snowflake | string,\n\tSubcommandName extends Snowflake | string,\n\tCommandId extends Snowflake,\n>(\n\tcommandName: CommandName,\n\tsubcommandGroupName: SubcommandGroupName,\n\tsubcommandName?: SubcommandName,\n\tcommandId?: CommandId,\n):\n\t| `</${CommandName} ${SubcommandGroupName} ${SubcommandName}:${CommandId}>`\n\t| `</${CommandName} ${SubcommandGroupName}:${SubcommandName}>`\n\t| `</${CommandName}:${SubcommandGroupName}>` {\n\tif (commandId !== undefined) {\n\t\treturn `</${commandName} ${subcommandGroupName} ${subcommandName!}:${commandId}>`;\n\t}\n\n\tif (subcommandName !== undefined) {\n\t\treturn `</${commandName} ${subcommandGroupName}:${subcommandName}>`;\n\t}\n\n\treturn `</${commandName}:${subcommandGroupName}>`;\n}\n\n/**\n * Formats a non-animated emoji id into a fully qualified emoji identifier.\n *\n * @typeParam EmojiId - This is inferred by the supplied emoji id\n * @param emojiId - The emoji id to format\n */\nexport function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: false): `<:_:${EmojiId}>`;\n\n/**\n * Formats an animated emoji id into a fully qualified emoji identifier.\n *\n * @typeParam EmojiId - This is inferred by the supplied emoji id\n * @param emojiId - The emoji id to format\n * @param animated - Whether the emoji is animated\n */\nexport function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: true): `<a:_:${EmojiId}>`;\n\n/**\n * Formats an emoji id into a fully qualified emoji identifier.\n *\n * @typeParam EmojiId - This is inferred by the supplied emoji id\n * @param emojiId - The emoji id to format\n * @param animated - Whether the emoji is animated\n */\nexport function formatEmoji<EmojiId extends Snowflake>(\n\temojiId: EmojiId,\n\tanimated?: boolean,\n): `<:_:${EmojiId}>` | `<a:_:${EmojiId}>`;\n\nexport function formatEmoji<EmojiId extends Snowflake>(\n\temojiId: EmojiId,\n\tanimated = false,\n): `<:_:${EmojiId}>` | `<a:_:${EmojiId}>` {\n\treturn `<${animated ? 'a' : ''}:_:${emojiId}>`;\n}\n\n/**\n * Formats a channel link for a direct message channel.\n *\n * @typeParam ChannelId - This is inferred by the supplied channel id\n * @param channelId - The channel's id\n */\nexport function channelLink<ChannelId extends Snowflake>(\n\tchannelId: ChannelId,\n): `https://discord.com/channels/@me/${ChannelId}`;\n\n/**\n * Formats a channel link for a guild channel.\n *\n * @typeParam ChannelId - This is inferred by the supplied channel id\n * @typeParam GuildId - This is inferred by the supplied guild id\n * @param channelId - The channel's id\n * @param guildId - The guild's id\n */\nexport function channelLink<ChannelId extends Snowflake, GuildId extends Snowflake>(\n\tchannelId: ChannelId,\n\tguildId: GuildId,\n): `https://discord.com/channels/${GuildId}/${ChannelId}`;\n\nexport function channelLink<ChannelId extends Snowflake, GuildId extends Snowflake>(\n\tchannelId: ChannelId,\n\tguildId?: GuildId,\n): `https://discord.com/channels/@me/${ChannelId}` | `https://discord.com/channels/${GuildId}/${ChannelId}` {\n\treturn `https://discord.com/channels/${guildId ?? '@me'}/${channelId}`;\n}\n\n/**\n * Formats a message link for a direct message channel.\n *\n * @typeParam ChannelId - This is inferred by the supplied channel id\n * @typeParam MessageId - This is inferred by the supplied message id\n * @param channelId - The channel's id\n * @param messageId - The message's id\n */\nexport function messageLink<ChannelId extends Snowflake, MessageId extends Snowflake>(\n\tchannelId: ChannelId,\n\tmessageId: MessageId,\n): `https://discord.com/channels/@me/${ChannelId}/${MessageId}`;\n\n/**\n * Formats a message link for a guild channel.\n *\n * @typeParam ChannelId - This is inferred by the supplied channel id\n * @typeParam MessageId - This is inferred by the supplied message id\n * @typeParam GuildId - This is inferred by the supplied guild id\n * @param channelId - The channel's id\n * @param messageId - The message's id\n * @param guildId - The guild's id\n */\nexport function messageLink<ChannelId extends Snowflake, MessageId extends Snowflake, GuildId extends Snowflake>(\n\tchannelId: ChannelId,\n\tmessageId: MessageId,\n\tguildId: GuildId,\n): `https://discord.com/channels/${GuildId}/${ChannelId}/${MessageId}`;\n\nexport function messageLink<ChannelId extends Snowflake, MessageId extends Snowflake, GuildId extends Snowflake>(\n\tchannelId: ChannelId,\n\tmessageId: MessageId,\n\tguildId?: GuildId,\n):\n\t| `https://discord.com/channels/@me/${ChannelId}/${MessageId}`\n\t| `https://discord.com/channels/${GuildId}/${ChannelId}/${MessageId}` {\n\treturn `${guildId === undefined ? channelLink(channelId) : channelLink(channelId, guildId)}/${messageId}`;\n}\n\n/**\n * The heading levels for expanded markdown.\n */\nexport enum HeadingLevel {\n\t/**\n\t * The first heading level.\n\t */\n\tOne = 1,\n\t/**\n\t * The second heading level.\n\t */\n\tTwo,\n\t/**\n\t * The third heading level.\n\t */\n\tThree,\n}\n\n/**\n * Formats the content into a heading level.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n * @param level - The heading level\n */\nexport function heading<Content extends string>(content: Content, level?: HeadingLevel.One): `# ${Content}`;\n\n/**\n * Formats the content into a heading level.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n * @param level - The heading level\n */\nexport function heading<Content extends string>(content: Content, level: HeadingLevel.Two): `## ${Content}`;\n\n/**\n * Formats the content into a heading level.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n * @param level - The heading level\n */\nexport function heading<Content extends string>(content: Content, level: HeadingLevel.Three): `### ${Content}`;\n\nexport function heading(content: string, level?: HeadingLevel) {\n\tswitch (level) {\n\t\tcase HeadingLevel.Three:\n\t\t\treturn `### ${content}`;\n\t\tcase HeadingLevel.Two:\n\t\t\treturn `## ${content}`;\n\t\tdefault:\n\t\t\treturn `# ${content}`;\n\t}\n}\n\n/**\n * A type that recursively traverses into arrays.\n */\nexport type RecursiveArray<ItemType> = readonly (ItemType | RecursiveArray<ItemType>)[];\n\n/**\n * Callback function for list formatters.\n *\n * @internal\n */\nfunction listCallback(element: RecursiveArray<string>, startNumber?: number, depth = 0): string {\n\tif (Array.isArray(element)) {\n\t\treturn element.map((element) => listCallback(element, startNumber, depth + 1)).join('\\n');\n\t}\n\n\treturn `${' '.repeat(depth - 1)}${startNumber ? `${startNumber}.` : '-'} ${element}`;\n}\n\n/**\n * Formats the elements in the array to an ordered list.\n *\n * @param list - The array of elements to list\n * @param startNumber - The starting number for the list\n */\nexport function orderedList(list: RecursiveArray<string>, startNumber = 1): string {\n\treturn listCallback(list, Math.max(startNumber, 1));\n}\n\n/**\n * Formats the elements in the array to an unordered list.\n *\n * @param list - The array of elements to list\n */\nexport function unorderedList(list: RecursiveArray<string>): string {\n\treturn listCallback(list);\n}\n\n/**\n * Formats a date into a short date-time string.\n *\n * @param date - The date to format. Defaults to the current time\n */\nexport function time(date?: Date): `<t:${bigint}>`;\n\n/**\n * Formats a date given a format style.\n *\n * @typeParam Style - This is inferred by the supplied {@link TimestampStylesString}\n * @param date - The date to format\n * @param style - The style to use\n */\nexport function time<Style extends TimestampStylesString>(date: Date, style: Style): `<t:${bigint}:${Style}>`;\n\n/**\n * Formats the given timestamp into a short date-time string.\n *\n * @typeParam Seconds - This is inferred by the supplied timestamp\n * @param seconds - A Unix timestamp in seconds\n */\nexport function time<Seconds extends number>(seconds: Seconds): `<t:${Seconds}>`;\n\n/**\n * Formats the given timestamp into a short date-time string.\n *\n * @typeParam Seconds - This is inferred by the supplied timestamp\n * @typeParam Style - This is inferred by the supplied {@link TimestampStylesString}\n * @param seconds - A Unix timestamp in seconds\n * @param style - The style to use\n */\nexport function time<Seconds extends number, Style extends TimestampStylesString>(\n\tseconds: Seconds,\n\tstyle: Style,\n): `<t:${Seconds}:${Style}>`;\n\nexport function time(timeOrSeconds?: Date | number, style?: TimestampStylesString): string {\n\tif (typeof timeOrSeconds !== 'number') {\n\t\t// eslint-disable-next-line no-param-reassign\n\t\ttimeOrSeconds = Math.floor((timeOrSeconds?.getTime() ?? Date.now()) / 1_000);\n\t}\n\n\treturn typeof style === 'string' ? `<t:${timeOrSeconds}:${style}>` : `<t:${timeOrSeconds}>`;\n}\n\n/**\n * The {@link https://discord.com/developers/docs/reference#message-formatting-timestamp-styles | message formatting timestamp styles}\n * supported by Discord.\n */\nexport const TimestampStyles = {\n\t/**\n\t * Short time format, consisting of hours and minutes.\n\t *\n\t * @example `16:20`\n\t */\n\tShortTime: 't',\n\n\t/**\n\t * Long time format, consisting of hours, minutes, and seconds.\n\t *\n\t * @example `16:20:30`\n\t */\n\tLongTime: 'T',\n\n\t/**\n\t * Short date format, consisting of day, month, and year.\n\t *\n\t * @example `20/04/2021`\n\t */\n\tShortDate: 'd',\n\n\t/**\n\t * Long date format, consisting of day, month, and year.\n\t *\n\t * @example `20 April 2021`\n\t */\n\tLongDate: 'D',\n\n\t/**\n\t * Short date-time format, consisting of short date and short time formats.\n\t *\n\t * @example `20 April 2021 16:20`\n\t */\n\tShortDateTime: 'f',\n\n\t/**\n\t * Long date-time format, consisting of long date and short time formats.\n\t *\n\t * @example `Tuesday, 20 April 2021 16:20`\n\t */\n\tLongDateTime: 'F',\n\n\t/**\n\t * Relative time format, consisting of a relative duration format.\n\t *\n\t * @example `2 months ago`\n\t */\n\tRelativeTime: 'R',\n} as const satisfies Record<string, string>;\n\n/**\n * The possible {@link TimestampStyles} values.\n */\nexport type TimestampStylesString = (typeof TimestampStyles)[keyof typeof TimestampStyles];\n\n// prettier-ignore\n/**\n * All the available faces from Discord's native slash commands.\n */\nexport enum Faces {\n\t/**\n\t * `¯\\_(ツ)_/¯`\n\t */\n\t// eslint-disable-next-line no-useless-escape\n\tShrug = '¯\\_(ツ)_/¯',\n\n\t/**\n\t * `(╯°□°)╯︵ ┻━┻`\n\t */\n\tTableflip = '(╯°□°)╯︵ ┻━┻',\n\n\t/**\n\t * `┬─┬ノ( º _ ºノ)`\n\t */\n\tUnflip = '┬─┬ノ( º _ ºノ)',\n}\n\n/**\n * All the available guild navigation mentions.\n */\nexport enum GuildNavigationMentions {\n\t/**\n\t * Browse Channels tab.\n\t */\n\tBrowse = '<id:browse>',\n\t/**\n\t * Customize tab with the server's {@link https://discord.com/developers/docs/resources/guild#guild-onboarding-object | onboarding prompts}.\n\t */\n\tCustomize = '<id:customize>',\n\t/**\n\t * {@link https://support.discord.com/hc/articles/13497665141655 | Server Guide} tab.\n\t */\n\tGuide = '<id:guide>',\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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;AAAA;AAAA;AAAA;AAAA,EAOX,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOV,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOX,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOV,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOf,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOd,cAAc;AACf;AAWO,IAAK,QAAL,kBAAKC,WAAL;AAKN,EAAAA,OAAA,WAAQ;AAKR,EAAAA,OAAA,eAAY;AAKZ,EAAAA,OAAA,YAAS;AAfE,SAAAA;AAAA,GAAA;AAqBL,IAAK,0BAAL,kBAAKC,6BAAL;AAIN,EAAAA,yBAAA,YAAS;AAIT,EAAAA,yBAAA,eAAY;AAIZ,EAAAA,yBAAA,WAAQ;AAZG,SAAAA;AAAA,GAAA;","names":["codeBlock","inlineCode","bold","italic","strikethrough","spoiler","heading","HeadingLevel","element","Faces","GuildNavigationMentions"]}
|
node_modules/@discordjs/formatters/dist/index.mjs
ADDED
@@ -0,0 +1,378 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var __defProp = Object.defineProperty;
|
2 |
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
3 |
+
|
4 |
+
// src/escapers.ts
|
5 |
+
function escapeMarkdown(text, options = {}) {
|
6 |
+
const {
|
7 |
+
codeBlock: codeBlock2 = true,
|
8 |
+
inlineCode: inlineCode2 = true,
|
9 |
+
bold: bold2 = true,
|
10 |
+
italic: italic2 = true,
|
11 |
+
underline = true,
|
12 |
+
strikethrough: strikethrough2 = true,
|
13 |
+
spoiler: spoiler2 = true,
|
14 |
+
codeBlockContent = true,
|
15 |
+
inlineCodeContent = true,
|
16 |
+
escape = true,
|
17 |
+
heading: heading2 = false,
|
18 |
+
bulletedList = false,
|
19 |
+
numberedList = false,
|
20 |
+
maskedLink = false
|
21 |
+
} = options;
|
22 |
+
if (!codeBlockContent) {
|
23 |
+
return text.split("```").map((subString, index, array) => {
|
24 |
+
if (index % 2 && index !== array.length - 1)
|
25 |
+
return subString;
|
26 |
+
return escapeMarkdown(subString, {
|
27 |
+
inlineCode: inlineCode2,
|
28 |
+
bold: bold2,
|
29 |
+
italic: italic2,
|
30 |
+
underline,
|
31 |
+
strikethrough: strikethrough2,
|
32 |
+
spoiler: spoiler2,
|
33 |
+
inlineCodeContent,
|
34 |
+
escape,
|
35 |
+
heading: heading2,
|
36 |
+
bulletedList,
|
37 |
+
numberedList,
|
38 |
+
maskedLink
|
39 |
+
});
|
40 |
+
}).join(codeBlock2 ? "\\`\\`\\`" : "```");
|
41 |
+
}
|
42 |
+
if (!inlineCodeContent) {
|
43 |
+
return text.split(/(?<=^|[^`])`(?=[^`]|$)/g).map((subString, index, array) => {
|
44 |
+
if (index % 2 && index !== array.length - 1)
|
45 |
+
return subString;
|
46 |
+
return escapeMarkdown(subString, {
|
47 |
+
codeBlock: codeBlock2,
|
48 |
+
bold: bold2,
|
49 |
+
italic: italic2,
|
50 |
+
underline,
|
51 |
+
strikethrough: strikethrough2,
|
52 |
+
spoiler: spoiler2,
|
53 |
+
escape,
|
54 |
+
heading: heading2,
|
55 |
+
bulletedList,
|
56 |
+
numberedList,
|
57 |
+
maskedLink
|
58 |
+
});
|
59 |
+
}).join(inlineCode2 ? "\\`" : "`");
|
60 |
+
}
|
61 |
+
let res = text;
|
62 |
+
if (escape)
|
63 |
+
res = escapeEscape(res);
|
64 |
+
if (inlineCode2)
|
65 |
+
res = escapeInlineCode(res);
|
66 |
+
if (codeBlock2)
|
67 |
+
res = escapeCodeBlock(res);
|
68 |
+
if (italic2)
|
69 |
+
res = escapeItalic(res);
|
70 |
+
if (bold2)
|
71 |
+
res = escapeBold(res);
|
72 |
+
if (underline)
|
73 |
+
res = escapeUnderline(res);
|
74 |
+
if (strikethrough2)
|
75 |
+
res = escapeStrikethrough(res);
|
76 |
+
if (spoiler2)
|
77 |
+
res = escapeSpoiler(res);
|
78 |
+
if (heading2)
|
79 |
+
res = escapeHeading(res);
|
80 |
+
if (bulletedList)
|
81 |
+
res = escapeBulletedList(res);
|
82 |
+
if (numberedList)
|
83 |
+
res = escapeNumberedList(res);
|
84 |
+
if (maskedLink)
|
85 |
+
res = escapeMaskedLink(res);
|
86 |
+
return res;
|
87 |
+
}
|
88 |
+
__name(escapeMarkdown, "escapeMarkdown");
|
89 |
+
function escapeCodeBlock(text) {
|
90 |
+
return text.replaceAll("```", "\\`\\`\\`");
|
91 |
+
}
|
92 |
+
__name(escapeCodeBlock, "escapeCodeBlock");
|
93 |
+
function escapeInlineCode(text) {
|
94 |
+
return text.replaceAll(/(?<=^|[^`])``?(?=[^`]|$)/g, (match) => match.length === 2 ? "\\`\\`" : "\\`");
|
95 |
+
}
|
96 |
+
__name(escapeInlineCode, "escapeInlineCode");
|
97 |
+
function escapeItalic(text) {
|
98 |
+
let idx = 0;
|
99 |
+
const newText = text.replaceAll(/(?<=^|[^*])\*([^*]|\*\*|$)/g, (_, match) => {
|
100 |
+
if (match === "**")
|
101 |
+
return ++idx % 2 ? `\\*${match}` : `${match}\\*`;
|
102 |
+
return `\\*${match}`;
|
103 |
+
});
|
104 |
+
idx = 0;
|
105 |
+
return newText.replaceAll(/(?<=^|[^_])(?<!<a?:.+)_(?!:\d+>)([^_]|__|$)/g, (_, match) => {
|
106 |
+
if (match === "__")
|
107 |
+
return ++idx % 2 ? `\\_${match}` : `${match}\\_`;
|
108 |
+
return `\\_${match}`;
|
109 |
+
});
|
110 |
+
}
|
111 |
+
__name(escapeItalic, "escapeItalic");
|
112 |
+
function escapeBold(text) {
|
113 |
+
let idx = 0;
|
114 |
+
return text.replaceAll(/\*\*(\*)?/g, (_, match) => {
|
115 |
+
if (match)
|
116 |
+
return ++idx % 2 ? `${match}\\*\\*` : `\\*\\*${match}`;
|
117 |
+
return "\\*\\*";
|
118 |
+
});
|
119 |
+
}
|
120 |
+
__name(escapeBold, "escapeBold");
|
121 |
+
function escapeUnderline(text) {
|
122 |
+
let idx = 0;
|
123 |
+
return text.replaceAll(/(?<!<a?:.+)__(_)?(?!:\d+>)/g, (_, match) => {
|
124 |
+
if (match)
|
125 |
+
return ++idx % 2 ? `${match}\\_\\_` : `\\_\\_${match}`;
|
126 |
+
return "\\_\\_";
|
127 |
+
});
|
128 |
+
}
|
129 |
+
__name(escapeUnderline, "escapeUnderline");
|
130 |
+
function escapeStrikethrough(text) {
|
131 |
+
return text.replaceAll("~~", "\\~\\~");
|
132 |
+
}
|
133 |
+
__name(escapeStrikethrough, "escapeStrikethrough");
|
134 |
+
function escapeSpoiler(text) {
|
135 |
+
return text.replaceAll("||", "\\|\\|");
|
136 |
+
}
|
137 |
+
__name(escapeSpoiler, "escapeSpoiler");
|
138 |
+
function escapeEscape(text) {
|
139 |
+
return text.replaceAll("\\", "\\\\");
|
140 |
+
}
|
141 |
+
__name(escapeEscape, "escapeEscape");
|
142 |
+
function escapeHeading(text) {
|
143 |
+
return text.replaceAll(/^( {0,2})([*-] )?( *)(#{1,3} )/gm, "$1$2$3\\$4");
|
144 |
+
}
|
145 |
+
__name(escapeHeading, "escapeHeading");
|
146 |
+
function escapeBulletedList(text) {
|
147 |
+
return text.replaceAll(/^( *)([*-])( +)/gm, "$1\\$2$3");
|
148 |
+
}
|
149 |
+
__name(escapeBulletedList, "escapeBulletedList");
|
150 |
+
function escapeNumberedList(text) {
|
151 |
+
return text.replaceAll(/^( *\d+)\./gm, "$1\\.");
|
152 |
+
}
|
153 |
+
__name(escapeNumberedList, "escapeNumberedList");
|
154 |
+
function escapeMaskedLink(text) {
|
155 |
+
return text.replaceAll(/\[.+]\(.+\)/gm, "\\$&");
|
156 |
+
}
|
157 |
+
__name(escapeMaskedLink, "escapeMaskedLink");
|
158 |
+
|
159 |
+
// src/formatters.ts
|
160 |
+
function codeBlock(language, content) {
|
161 |
+
return content === void 0 ? `\`\`\`
|
162 |
+
${language}
|
163 |
+
\`\`\`` : `\`\`\`${language}
|
164 |
+
${content}
|
165 |
+
\`\`\``;
|
166 |
+
}
|
167 |
+
__name(codeBlock, "codeBlock");
|
168 |
+
function inlineCode(content) {
|
169 |
+
return `\`${content}\``;
|
170 |
+
}
|
171 |
+
__name(inlineCode, "inlineCode");
|
172 |
+
function italic(content) {
|
173 |
+
return `_${content}_`;
|
174 |
+
}
|
175 |
+
__name(italic, "italic");
|
176 |
+
function bold(content) {
|
177 |
+
return `**${content}**`;
|
178 |
+
}
|
179 |
+
__name(bold, "bold");
|
180 |
+
function underscore(content) {
|
181 |
+
return `__${content}__`;
|
182 |
+
}
|
183 |
+
__name(underscore, "underscore");
|
184 |
+
function strikethrough(content) {
|
185 |
+
return `~~${content}~~`;
|
186 |
+
}
|
187 |
+
__name(strikethrough, "strikethrough");
|
188 |
+
function quote(content) {
|
189 |
+
return `> ${content}`;
|
190 |
+
}
|
191 |
+
__name(quote, "quote");
|
192 |
+
function blockQuote(content) {
|
193 |
+
return `>>> ${content}`;
|
194 |
+
}
|
195 |
+
__name(blockQuote, "blockQuote");
|
196 |
+
function hideLinkEmbed(url) {
|
197 |
+
return `<${url}>`;
|
198 |
+
}
|
199 |
+
__name(hideLinkEmbed, "hideLinkEmbed");
|
200 |
+
function hyperlink(content, url, title) {
|
201 |
+
return title ? `[${content}](${url} "${title}")` : `[${content}](${url})`;
|
202 |
+
}
|
203 |
+
__name(hyperlink, "hyperlink");
|
204 |
+
function spoiler(content) {
|
205 |
+
return `||${content}||`;
|
206 |
+
}
|
207 |
+
__name(spoiler, "spoiler");
|
208 |
+
function userMention(userId) {
|
209 |
+
return `<@${userId}>`;
|
210 |
+
}
|
211 |
+
__name(userMention, "userMention");
|
212 |
+
function channelMention(channelId) {
|
213 |
+
return `<#${channelId}>`;
|
214 |
+
}
|
215 |
+
__name(channelMention, "channelMention");
|
216 |
+
function roleMention(roleId) {
|
217 |
+
return `<@&${roleId}>`;
|
218 |
+
}
|
219 |
+
__name(roleMention, "roleMention");
|
220 |
+
function chatInputApplicationCommandMention(commandName, subcommandGroupName, subcommandName, commandId) {
|
221 |
+
if (commandId !== void 0) {
|
222 |
+
return `</${commandName} ${subcommandGroupName} ${subcommandName}:${commandId}>`;
|
223 |
+
}
|
224 |
+
if (subcommandName !== void 0) {
|
225 |
+
return `</${commandName} ${subcommandGroupName}:${subcommandName}>`;
|
226 |
+
}
|
227 |
+
return `</${commandName}:${subcommandGroupName}>`;
|
228 |
+
}
|
229 |
+
__name(chatInputApplicationCommandMention, "chatInputApplicationCommandMention");
|
230 |
+
function formatEmoji(emojiId, animated = false) {
|
231 |
+
return `<${animated ? "a" : ""}:_:${emojiId}>`;
|
232 |
+
}
|
233 |
+
__name(formatEmoji, "formatEmoji");
|
234 |
+
function channelLink(channelId, guildId) {
|
235 |
+
return `https://discord.com/channels/${guildId ?? "@me"}/${channelId}`;
|
236 |
+
}
|
237 |
+
__name(channelLink, "channelLink");
|
238 |
+
function messageLink(channelId, messageId, guildId) {
|
239 |
+
return `${guildId === void 0 ? channelLink(channelId) : channelLink(channelId, guildId)}/${messageId}`;
|
240 |
+
}
|
241 |
+
__name(messageLink, "messageLink");
|
242 |
+
var HeadingLevel = /* @__PURE__ */ ((HeadingLevel2) => {
|
243 |
+
HeadingLevel2[HeadingLevel2["One"] = 1] = "One";
|
244 |
+
HeadingLevel2[HeadingLevel2["Two"] = 2] = "Two";
|
245 |
+
HeadingLevel2[HeadingLevel2["Three"] = 3] = "Three";
|
246 |
+
return HeadingLevel2;
|
247 |
+
})(HeadingLevel || {});
|
248 |
+
function heading(content, level) {
|
249 |
+
switch (level) {
|
250 |
+
case 3 /* Three */:
|
251 |
+
return `### ${content}`;
|
252 |
+
case 2 /* Two */:
|
253 |
+
return `## ${content}`;
|
254 |
+
default:
|
255 |
+
return `# ${content}`;
|
256 |
+
}
|
257 |
+
}
|
258 |
+
__name(heading, "heading");
|
259 |
+
function listCallback(element, startNumber, depth = 0) {
|
260 |
+
if (Array.isArray(element)) {
|
261 |
+
return element.map((element2) => listCallback(element2, startNumber, depth + 1)).join("\n");
|
262 |
+
}
|
263 |
+
return `${" ".repeat(depth - 1)}${startNumber ? `${startNumber}.` : "-"} ${element}`;
|
264 |
+
}
|
265 |
+
__name(listCallback, "listCallback");
|
266 |
+
function orderedList(list, startNumber = 1) {
|
267 |
+
return listCallback(list, Math.max(startNumber, 1));
|
268 |
+
}
|
269 |
+
__name(orderedList, "orderedList");
|
270 |
+
function unorderedList(list) {
|
271 |
+
return listCallback(list);
|
272 |
+
}
|
273 |
+
__name(unorderedList, "unorderedList");
|
274 |
+
function time(timeOrSeconds, style) {
|
275 |
+
if (typeof timeOrSeconds !== "number") {
|
276 |
+
timeOrSeconds = Math.floor((timeOrSeconds?.getTime() ?? Date.now()) / 1e3);
|
277 |
+
}
|
278 |
+
return typeof style === "string" ? `<t:${timeOrSeconds}:${style}>` : `<t:${timeOrSeconds}>`;
|
279 |
+
}
|
280 |
+
__name(time, "time");
|
281 |
+
var TimestampStyles = {
|
282 |
+
/**
|
283 |
+
* Short time format, consisting of hours and minutes.
|
284 |
+
*
|
285 |
+
* @example `16:20`
|
286 |
+
*/
|
287 |
+
ShortTime: "t",
|
288 |
+
/**
|
289 |
+
* Long time format, consisting of hours, minutes, and seconds.
|
290 |
+
*
|
291 |
+
* @example `16:20:30`
|
292 |
+
*/
|
293 |
+
LongTime: "T",
|
294 |
+
/**
|
295 |
+
* Short date format, consisting of day, month, and year.
|
296 |
+
*
|
297 |
+
* @example `20/04/2021`
|
298 |
+
*/
|
299 |
+
ShortDate: "d",
|
300 |
+
/**
|
301 |
+
* Long date format, consisting of day, month, and year.
|
302 |
+
*
|
303 |
+
* @example `20 April 2021`
|
304 |
+
*/
|
305 |
+
LongDate: "D",
|
306 |
+
/**
|
307 |
+
* Short date-time format, consisting of short date and short time formats.
|
308 |
+
*
|
309 |
+
* @example `20 April 2021 16:20`
|
310 |
+
*/
|
311 |
+
ShortDateTime: "f",
|
312 |
+
/**
|
313 |
+
* Long date-time format, consisting of long date and short time formats.
|
314 |
+
*
|
315 |
+
* @example `Tuesday, 20 April 2021 16:20`
|
316 |
+
*/
|
317 |
+
LongDateTime: "F",
|
318 |
+
/**
|
319 |
+
* Relative time format, consisting of a relative duration format.
|
320 |
+
*
|
321 |
+
* @example `2 months ago`
|
322 |
+
*/
|
323 |
+
RelativeTime: "R"
|
324 |
+
};
|
325 |
+
var Faces = /* @__PURE__ */ ((Faces2) => {
|
326 |
+
Faces2["Shrug"] = "\xAF_(\u30C4)_/\xAF";
|
327 |
+
Faces2["Tableflip"] = "(\u256F\xB0\u25A1\xB0)\u256F\uFE35 \u253B\u2501\u253B";
|
328 |
+
Faces2["Unflip"] = "\u252C\u2500\u252C\u30CE( \xBA _ \xBA\u30CE)";
|
329 |
+
return Faces2;
|
330 |
+
})(Faces || {});
|
331 |
+
var GuildNavigationMentions = /* @__PURE__ */ ((GuildNavigationMentions2) => {
|
332 |
+
GuildNavigationMentions2["Browse"] = "<id:browse>";
|
333 |
+
GuildNavigationMentions2["Customize"] = "<id:customize>";
|
334 |
+
GuildNavigationMentions2["Guide"] = "<id:guide>";
|
335 |
+
return GuildNavigationMentions2;
|
336 |
+
})(GuildNavigationMentions || {});
|
337 |
+
export {
|
338 |
+
Faces,
|
339 |
+
GuildNavigationMentions,
|
340 |
+
HeadingLevel,
|
341 |
+
TimestampStyles,
|
342 |
+
blockQuote,
|
343 |
+
bold,
|
344 |
+
channelLink,
|
345 |
+
channelMention,
|
346 |
+
chatInputApplicationCommandMention,
|
347 |
+
codeBlock,
|
348 |
+
escapeBold,
|
349 |
+
escapeBulletedList,
|
350 |
+
escapeCodeBlock,
|
351 |
+
escapeEscape,
|
352 |
+
escapeHeading,
|
353 |
+
escapeInlineCode,
|
354 |
+
escapeItalic,
|
355 |
+
escapeMarkdown,
|
356 |
+
escapeMaskedLink,
|
357 |
+
escapeNumberedList,
|
358 |
+
escapeSpoiler,
|
359 |
+
escapeStrikethrough,
|
360 |
+
escapeUnderline,
|
361 |
+
formatEmoji,
|
362 |
+
heading,
|
363 |
+
hideLinkEmbed,
|
364 |
+
hyperlink,
|
365 |
+
inlineCode,
|
366 |
+
italic,
|
367 |
+
messageLink,
|
368 |
+
orderedList,
|
369 |
+
quote,
|
370 |
+
roleMention,
|
371 |
+
spoiler,
|
372 |
+
strikethrough,
|
373 |
+
time,
|
374 |
+
underscore,
|
375 |
+
unorderedList,
|
376 |
+
userMention
|
377 |
+
};
|
378 |
+
//# sourceMappingURL=index.mjs.map
|
node_modules/@discordjs/formatters/dist/index.mjs.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"sources":["../src/escapers.ts","../src/formatters.ts"],"sourcesContent":["/* eslint-disable prefer-named-capture-group */\n\n/**\n * The options that affect what will be escaped.\n */\nexport interface EscapeMarkdownOptions {\n\t/**\n\t * Whether to escape bold text.\n\t *\n\t * @defaultValue `true`\n\t */\n\tbold?: boolean;\n\n\t/**\n\t * Whether to escape bulleted lists.\n\t *\n\t * @defaultValue `false`\n\t */\n\tbulletedList?: boolean;\n\n\t/**\n\t * Whether to escape code blocks.\n\t *\n\t * @defaultValue `true`\n\t */\n\tcodeBlock?: boolean;\n\n\t/**\n\t * Whether to escape text inside code blocks.\n\t *\n\t * @defaultValue `true`\n\t */\n\tcodeBlockContent?: boolean;\n\n\t/**\n\t * Whether to escape `\\`.\n\t *\n\t * @defaultValue `true`\n\t */\n\tescape?: boolean;\n\n\t/**\n\t * Whether to escape headings.\n\t *\n\t * @defaultValue `false`\n\t */\n\theading?: boolean;\n\n\t/**\n\t * Whether to escape inline code.\n\t *\n\t * @defaultValue `true`\n\t */\n\tinlineCode?: boolean;\n\n\t/**\n\t * Whether to escape text inside inline code.\n\t *\n\t * @defaultValue `true`\n\t */\n\tinlineCodeContent?: boolean;\n\t/**\n\t * Whether to escape italics.\n\t *\n\t * @defaultValue `true`\n\t */\n\titalic?: boolean;\n\n\t/**\n\t * Whether to escape masked links.\n\t *\n\t * @defaultValue `false`\n\t */\n\tmaskedLink?: boolean;\n\n\t/**\n\t * Whether to escape numbered lists.\n\t *\n\t * @defaultValue `false`\n\t */\n\tnumberedList?: boolean;\n\n\t/**\n\t * Whether to escape spoilers.\n\t *\n\t * @defaultValue `true`\n\t */\n\tspoiler?: boolean;\n\n\t/**\n\t * Whether to escape strikethroughs.\n\t *\n\t * @defaultValue `true`\n\t */\n\tstrikethrough?: boolean;\n\n\t/**\n\t * Whether to escape underlines.\n\t *\n\t * @defaultValue `true`\n\t */\n\tunderline?: boolean;\n}\n\n/**\n * Escapes any Discord-flavored markdown in a string.\n *\n * @param text - Content to escape\n * @param options - Options for escaping the markdown\n */\nexport function escapeMarkdown(text: string, options: EscapeMarkdownOptions = {}): string {\n\tconst {\n\t\tcodeBlock = true,\n\t\tinlineCode = true,\n\t\tbold = true,\n\t\titalic = true,\n\t\tunderline = true,\n\t\tstrikethrough = true,\n\t\tspoiler = true,\n\t\tcodeBlockContent = true,\n\t\tinlineCodeContent = true,\n\t\tescape = true,\n\t\theading = false,\n\t\tbulletedList = false,\n\t\tnumberedList = false,\n\t\tmaskedLink = false,\n\t} = options;\n\n\tif (!codeBlockContent) {\n\t\treturn text\n\t\t\t.split('```')\n\t\t\t.map((subString, index, array) => {\n\t\t\t\tif (index % 2 && index !== array.length - 1) return subString;\n\t\t\t\treturn escapeMarkdown(subString, {\n\t\t\t\t\tinlineCode,\n\t\t\t\t\tbold,\n\t\t\t\t\titalic,\n\t\t\t\t\tunderline,\n\t\t\t\t\tstrikethrough,\n\t\t\t\t\tspoiler,\n\t\t\t\t\tinlineCodeContent,\n\t\t\t\t\tescape,\n\t\t\t\t\theading,\n\t\t\t\t\tbulletedList,\n\t\t\t\t\tnumberedList,\n\t\t\t\t\tmaskedLink,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.join(codeBlock ? '\\\\`\\\\`\\\\`' : '```');\n\t}\n\n\tif (!inlineCodeContent) {\n\t\treturn text\n\t\t\t.split(/(?<=^|[^`])`(?=[^`]|$)/g)\n\t\t\t.map((subString, index, array) => {\n\t\t\t\tif (index % 2 && index !== array.length - 1) return subString;\n\t\t\t\treturn escapeMarkdown(subString, {\n\t\t\t\t\tcodeBlock,\n\t\t\t\t\tbold,\n\t\t\t\t\titalic,\n\t\t\t\t\tunderline,\n\t\t\t\t\tstrikethrough,\n\t\t\t\t\tspoiler,\n\t\t\t\t\tescape,\n\t\t\t\t\theading,\n\t\t\t\t\tbulletedList,\n\t\t\t\t\tnumberedList,\n\t\t\t\t\tmaskedLink,\n\t\t\t\t});\n\t\t\t})\n\t\t\t.join(inlineCode ? '\\\\`' : '`');\n\t}\n\n\tlet res = text;\n\tif (escape) res = escapeEscape(res);\n\tif (inlineCode) res = escapeInlineCode(res);\n\tif (codeBlock) res = escapeCodeBlock(res);\n\tif (italic) res = escapeItalic(res);\n\tif (bold) res = escapeBold(res);\n\tif (underline) res = escapeUnderline(res);\n\tif (strikethrough) res = escapeStrikethrough(res);\n\tif (spoiler) res = escapeSpoiler(res);\n\tif (heading) res = escapeHeading(res);\n\tif (bulletedList) res = escapeBulletedList(res);\n\tif (numberedList) res = escapeNumberedList(res);\n\tif (maskedLink) res = escapeMaskedLink(res);\n\treturn res;\n}\n\n/**\n * Escapes code block markdown in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeCodeBlock(text: string): string {\n\treturn text.replaceAll('```', '\\\\`\\\\`\\\\`');\n}\n\n/**\n * Escapes inline code markdown in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeInlineCode(text: string): string {\n\treturn text.replaceAll(/(?<=^|[^`])``?(?=[^`]|$)/g, (match) => (match.length === 2 ? '\\\\`\\\\`' : '\\\\`'));\n}\n\n/**\n * Escapes italic markdown in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeItalic(text: string): string {\n\tlet idx = 0;\n\tconst newText = text.replaceAll(/(?<=^|[^*])\\*([^*]|\\*\\*|$)/g, (_, match) => {\n\t\tif (match === '**') return ++idx % 2 ? `\\\\*${match}` : `${match}\\\\*`;\n\t\treturn `\\\\*${match}`;\n\t});\n\tidx = 0;\n\treturn newText.replaceAll(/(?<=^|[^_])(?<!<a?:.+)_(?!:\\d+>)([^_]|__|$)/g, (_, match) => {\n\t\tif (match === '__') return ++idx % 2 ? `\\\\_${match}` : `${match}\\\\_`;\n\t\treturn `\\\\_${match}`;\n\t});\n}\n\n/**\n * Escapes bold markdown in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeBold(text: string): string {\n\tlet idx = 0;\n\treturn text.replaceAll(/\\*\\*(\\*)?/g, (_, match) => {\n\t\tif (match) return ++idx % 2 ? `${match}\\\\*\\\\*` : `\\\\*\\\\*${match}`;\n\t\treturn '\\\\*\\\\*';\n\t});\n}\n\n/**\n * Escapes underline markdown in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeUnderline(text: string): string {\n\tlet idx = 0;\n\treturn text.replaceAll(/(?<!<a?:.+)__(_)?(?!:\\d+>)/g, (_, match) => {\n\t\tif (match) return ++idx % 2 ? `${match}\\\\_\\\\_` : `\\\\_\\\\_${match}`;\n\t\treturn '\\\\_\\\\_';\n\t});\n}\n\n/**\n * Escapes strikethrough markdown in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeStrikethrough(text: string): string {\n\treturn text.replaceAll('~~', '\\\\~\\\\~');\n}\n\n/**\n * Escapes spoiler markdown in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeSpoiler(text: string): string {\n\treturn text.replaceAll('||', '\\\\|\\\\|');\n}\n\n/**\n * Escapes escape characters in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeEscape(text: string): string {\n\treturn text.replaceAll('\\\\', '\\\\\\\\');\n}\n\n/**\n * Escapes heading characters in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeHeading(text: string): string {\n\treturn text.replaceAll(/^( {0,2})([*-] )?( *)(#{1,3} )/gm, '$1$2$3\\\\$4');\n}\n\n/**\n * Escapes bulleted list characters in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeBulletedList(text: string): string {\n\treturn text.replaceAll(/^( *)([*-])( +)/gm, '$1\\\\$2$3');\n}\n\n/**\n * Escapes numbered list characters in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeNumberedList(text: string): string {\n\treturn text.replaceAll(/^( *\\d+)\\./gm, '$1\\\\.');\n}\n\n/**\n * Escapes masked link characters in a string.\n *\n * @param text - Content to escape\n */\nexport function escapeMaskedLink(text: string): string {\n\treturn text.replaceAll(/\\[.+]\\(.+\\)/gm, '\\\\$&');\n}\n","import type { URL } from 'node:url';\nimport type { Snowflake } from 'discord-api-types/globals';\n\n/**\n * Wraps the content inside a code block with no language.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function codeBlock<Content extends string>(content: Content): `\\`\\`\\`\\n${Content}\\n\\`\\`\\``;\n\n/**\n * Wraps the content inside a code block with the specified language.\n *\n * @typeParam Language - This is inferred by the supplied language\n * @typeParam Content - This is inferred by the supplied content\n * @param language - The language for the code block\n * @param content - The content to wrap\n */\nexport function codeBlock<Language extends string, Content extends string>(\n\tlanguage: Language,\n\tcontent: Content,\n): `\\`\\`\\`${Language}\\n${Content}\\n\\`\\`\\``;\n\nexport function codeBlock(language: string, content?: string): string {\n\treturn content === undefined ? `\\`\\`\\`\\n${language}\\n\\`\\`\\`` : `\\`\\`\\`${language}\\n${content}\\n\\`\\`\\``;\n}\n\n/**\n * Wraps the content inside \\`backticks\\` which formats it as inline code.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function inlineCode<Content extends string>(content: Content): `\\`${Content}\\`` {\n\treturn `\\`${content}\\``;\n}\n\n/**\n * Formats the content into italic text.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function italic<Content extends string>(content: Content): `_${Content}_` {\n\treturn `_${content}_`;\n}\n\n/**\n * Formats the content into bold text.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function bold<Content extends string>(content: Content): `**${Content}**` {\n\treturn `**${content}**`;\n}\n\n/**\n * Formats the content into underscored text.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function underscore<Content extends string>(content: Content): `__${Content}__` {\n\treturn `__${content}__`;\n}\n\n/**\n * Formats the content into strike-through text.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function strikethrough<Content extends string>(content: Content): `~~${Content}~~` {\n\treturn `~~${content}~~`;\n}\n\n/**\n * Formats the content into a quote.\n *\n * @remarks This needs to be at the start of the line for Discord to format it.\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function quote<Content extends string>(content: Content): `> ${Content}` {\n\treturn `> ${content}`;\n}\n\n/**\n * Formats the content into a block quote.\n *\n * @remarks This needs to be at the start of the line for Discord to format it.\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function blockQuote<Content extends string>(content: Content): `>>> ${Content}` {\n\treturn `>>> ${content}`;\n}\n\n/**\n * Wraps the URL into `<>` which stops it from embedding.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param url - The URL to wrap\n */\nexport function hideLinkEmbed<Content extends string>(url: Content): `<${Content}>`;\n\n/**\n * Wraps the URL into `<>` which stops it from embedding.\n *\n * @param url - The URL to wrap\n */\nexport function hideLinkEmbed(url: URL): `<${string}>`;\n\nexport function hideLinkEmbed(url: URL | string) {\n\treturn `<${url}>`;\n}\n\n/**\n * Formats the content and the URL into a masked URL.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to display\n * @param url - The URL the content links to\n */\nexport function hyperlink<Content extends string>(content: Content, url: URL): `[${Content}](${string})`;\n\n/**\n * Formats the content and the URL into a masked URL.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @typeParam Url - This is inferred by the supplied URL\n * @param content - The content to display\n * @param url - The URL the content links to\n */\nexport function hyperlink<Content extends string, Url extends string>(\n\tcontent: Content,\n\turl: Url,\n): `[${Content}](${Url})`;\n\n/**\n * Formats the content and the URL into a masked URL with a custom tooltip.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @typeParam Title - This is inferred by the supplied title\n * @param content - The content to display\n * @param url - The URL the content links to\n * @param title - The title shown when hovering on the masked link\n */\nexport function hyperlink<Content extends string, Title extends string>(\n\tcontent: Content,\n\turl: URL,\n\ttitle: Title,\n): `[${Content}](${string} \"${Title}\")`;\n\n/**\n * Formats the content and the URL into a masked URL with a custom tooltip.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @typeParam Url - This is inferred by the supplied URL\n * @typeParam Title - This is inferred by the supplied title\n * @param content - The content to display\n * @param url - The URL the content links to\n * @param title - The title shown when hovering on the masked link\n */\nexport function hyperlink<Content extends string, Url extends string, Title extends string>(\n\tcontent: Content,\n\turl: Url,\n\ttitle: Title,\n): `[${Content}](${Url} \"${Title}\")`;\n\nexport function hyperlink(content: string, url: URL | string, title?: string) {\n\treturn title ? `[${content}](${url} \"${title}\")` : `[${content}](${url})`;\n}\n\n/**\n * Formats the content into a spoiler.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function spoiler<Content extends string>(content: Content): `||${Content}||` {\n\treturn `||${content}||`;\n}\n\n/**\n * Formats a user id into a user mention.\n *\n * @typeParam UserId - This is inferred by the supplied user id\n * @param userId - The user id to format\n */\nexport function userMention<UserId extends Snowflake>(userId: UserId): `<@${UserId}>` {\n\treturn `<@${userId}>`;\n}\n\n/**\n * Formats a channel id into a channel mention.\n *\n * @typeParam ChannelId - This is inferred by the supplied channel id\n * @param channelId - The channel id to format\n */\nexport function channelMention<ChannelId extends Snowflake>(channelId: ChannelId): `<#${ChannelId}>` {\n\treturn `<#${channelId}>`;\n}\n\n/**\n * Formats a role id into a role mention.\n *\n * @typeParam RoleId - This is inferred by the supplied role id\n * @param roleId - The role id to format\n */\nexport function roleMention<RoleId extends Snowflake>(roleId: RoleId): `<@&${RoleId}>` {\n\treturn `<@&${roleId}>`;\n}\n\n/**\n * Formats an application command name, subcommand group name, subcommand name, and id into an application command mention.\n *\n * @typeParam CommandName - This is inferred by the supplied command name\n * @typeParam SubcommandGroupName - This is inferred by the supplied subcommand group name\n * @typeParam SubcommandName - This is inferred by the supplied subcommand name\n * @typeParam CommandId - This is inferred by the supplied command id\n * @param commandName - The application command name to format\n * @param subcommandGroupName - The subcommand group name to format\n * @param subcommandName - The subcommand name to format\n * @param commandId - The application command id to format\n */\nexport function chatInputApplicationCommandMention<\n\tCommandName extends string,\n\tSubcommandGroupName extends string,\n\tSubcommandName extends string,\n\tCommandId extends Snowflake,\n>(\n\tcommandName: CommandName,\n\tsubcommandGroupName: SubcommandGroupName,\n\tsubcommandName: SubcommandName,\n\tcommandId: CommandId,\n): `</${CommandName} ${SubcommandGroupName} ${SubcommandName}:${CommandId}>`;\n\n/**\n * Formats an application command name, subcommand name, and id into an application command mention.\n *\n * @typeParam CommandName - This is inferred by the supplied command name\n * @typeParam SubcommandName - This is inferred by the supplied subcommand name\n * @typeParam CommandId - This is inferred by the supplied command id\n * @param commandName - The application command name to format\n * @param subcommandName - The subcommand name to format\n * @param commandId - The application command id to format\n */\nexport function chatInputApplicationCommandMention<\n\tCommandName extends string,\n\tSubcommandName extends string,\n\tCommandId extends Snowflake,\n>(\n\tcommandName: CommandName,\n\tsubcommandName: SubcommandName,\n\tcommandId: CommandId,\n): `</${CommandName} ${SubcommandName}:${CommandId}>`;\n\n/**\n * Formats an application command name and id into an application command mention.\n *\n * @typeParam CommandName - This is inferred by the supplied command name\n * @typeParam CommandId - This is inferred by the supplied command id\n * @param commandName - The application command name to format\n * @param commandId - The application command id to format\n */\nexport function chatInputApplicationCommandMention<CommandName extends string, CommandId extends Snowflake>(\n\tcommandName: CommandName,\n\tcommandId: CommandId,\n): `</${CommandName}:${CommandId}>`;\n\nexport function chatInputApplicationCommandMention<\n\tCommandName extends string,\n\tSubcommandGroupName extends Snowflake | string,\n\tSubcommandName extends Snowflake | string,\n\tCommandId extends Snowflake,\n>(\n\tcommandName: CommandName,\n\tsubcommandGroupName: SubcommandGroupName,\n\tsubcommandName?: SubcommandName,\n\tcommandId?: CommandId,\n):\n\t| `</${CommandName} ${SubcommandGroupName} ${SubcommandName}:${CommandId}>`\n\t| `</${CommandName} ${SubcommandGroupName}:${SubcommandName}>`\n\t| `</${CommandName}:${SubcommandGroupName}>` {\n\tif (commandId !== undefined) {\n\t\treturn `</${commandName} ${subcommandGroupName} ${subcommandName!}:${commandId}>`;\n\t}\n\n\tif (subcommandName !== undefined) {\n\t\treturn `</${commandName} ${subcommandGroupName}:${subcommandName}>`;\n\t}\n\n\treturn `</${commandName}:${subcommandGroupName}>`;\n}\n\n/**\n * Formats a non-animated emoji id into a fully qualified emoji identifier.\n *\n * @typeParam EmojiId - This is inferred by the supplied emoji id\n * @param emojiId - The emoji id to format\n */\nexport function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: false): `<:_:${EmojiId}>`;\n\n/**\n * Formats an animated emoji id into a fully qualified emoji identifier.\n *\n * @typeParam EmojiId - This is inferred by the supplied emoji id\n * @param emojiId - The emoji id to format\n * @param animated - Whether the emoji is animated\n */\nexport function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: true): `<a:_:${EmojiId}>`;\n\n/**\n * Formats an emoji id into a fully qualified emoji identifier.\n *\n * @typeParam EmojiId - This is inferred by the supplied emoji id\n * @param emojiId - The emoji id to format\n * @param animated - Whether the emoji is animated\n */\nexport function formatEmoji<EmojiId extends Snowflake>(\n\temojiId: EmojiId,\n\tanimated?: boolean,\n): `<:_:${EmojiId}>` | `<a:_:${EmojiId}>`;\n\nexport function formatEmoji<EmojiId extends Snowflake>(\n\temojiId: EmojiId,\n\tanimated = false,\n): `<:_:${EmojiId}>` | `<a:_:${EmojiId}>` {\n\treturn `<${animated ? 'a' : ''}:_:${emojiId}>`;\n}\n\n/**\n * Formats a channel link for a direct message channel.\n *\n * @typeParam ChannelId - This is inferred by the supplied channel id\n * @param channelId - The channel's id\n */\nexport function channelLink<ChannelId extends Snowflake>(\n\tchannelId: ChannelId,\n): `https://discord.com/channels/@me/${ChannelId}`;\n\n/**\n * Formats a channel link for a guild channel.\n *\n * @typeParam ChannelId - This is inferred by the supplied channel id\n * @typeParam GuildId - This is inferred by the supplied guild id\n * @param channelId - The channel's id\n * @param guildId - The guild's id\n */\nexport function channelLink<ChannelId extends Snowflake, GuildId extends Snowflake>(\n\tchannelId: ChannelId,\n\tguildId: GuildId,\n): `https://discord.com/channels/${GuildId}/${ChannelId}`;\n\nexport function channelLink<ChannelId extends Snowflake, GuildId extends Snowflake>(\n\tchannelId: ChannelId,\n\tguildId?: GuildId,\n): `https://discord.com/channels/@me/${ChannelId}` | `https://discord.com/channels/${GuildId}/${ChannelId}` {\n\treturn `https://discord.com/channels/${guildId ?? '@me'}/${channelId}`;\n}\n\n/**\n * Formats a message link for a direct message channel.\n *\n * @typeParam ChannelId - This is inferred by the supplied channel id\n * @typeParam MessageId - This is inferred by the supplied message id\n * @param channelId - The channel's id\n * @param messageId - The message's id\n */\nexport function messageLink<ChannelId extends Snowflake, MessageId extends Snowflake>(\n\tchannelId: ChannelId,\n\tmessageId: MessageId,\n): `https://discord.com/channels/@me/${ChannelId}/${MessageId}`;\n\n/**\n * Formats a message link for a guild channel.\n *\n * @typeParam ChannelId - This is inferred by the supplied channel id\n * @typeParam MessageId - This is inferred by the supplied message id\n * @typeParam GuildId - This is inferred by the supplied guild id\n * @param channelId - The channel's id\n * @param messageId - The message's id\n * @param guildId - The guild's id\n */\nexport function messageLink<ChannelId extends Snowflake, MessageId extends Snowflake, GuildId extends Snowflake>(\n\tchannelId: ChannelId,\n\tmessageId: MessageId,\n\tguildId: GuildId,\n): `https://discord.com/channels/${GuildId}/${ChannelId}/${MessageId}`;\n\nexport function messageLink<ChannelId extends Snowflake, MessageId extends Snowflake, GuildId extends Snowflake>(\n\tchannelId: ChannelId,\n\tmessageId: MessageId,\n\tguildId?: GuildId,\n):\n\t| `https://discord.com/channels/@me/${ChannelId}/${MessageId}`\n\t| `https://discord.com/channels/${GuildId}/${ChannelId}/${MessageId}` {\n\treturn `${guildId === undefined ? channelLink(channelId) : channelLink(channelId, guildId)}/${messageId}`;\n}\n\n/**\n * The heading levels for expanded markdown.\n */\nexport enum HeadingLevel {\n\t/**\n\t * The first heading level.\n\t */\n\tOne = 1,\n\t/**\n\t * The second heading level.\n\t */\n\tTwo,\n\t/**\n\t * The third heading level.\n\t */\n\tThree,\n}\n\n/**\n * Formats the content into a heading level.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n * @param level - The heading level\n */\nexport function heading<Content extends string>(content: Content, level?: HeadingLevel.One): `# ${Content}`;\n\n/**\n * Formats the content into a heading level.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n * @param level - The heading level\n */\nexport function heading<Content extends string>(content: Content, level: HeadingLevel.Two): `## ${Content}`;\n\n/**\n * Formats the content into a heading level.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n * @param level - The heading level\n */\nexport function heading<Content extends string>(content: Content, level: HeadingLevel.Three): `### ${Content}`;\n\nexport function heading(content: string, level?: HeadingLevel) {\n\tswitch (level) {\n\t\tcase HeadingLevel.Three:\n\t\t\treturn `### ${content}`;\n\t\tcase HeadingLevel.Two:\n\t\t\treturn `## ${content}`;\n\t\tdefault:\n\t\t\treturn `# ${content}`;\n\t}\n}\n\n/**\n * A type that recursively traverses into arrays.\n */\nexport type RecursiveArray<ItemType> = readonly (ItemType | RecursiveArray<ItemType>)[];\n\n/**\n * Callback function for list formatters.\n *\n * @internal\n */\nfunction listCallback(element: RecursiveArray<string>, startNumber?: number, depth = 0): string {\n\tif (Array.isArray(element)) {\n\t\treturn element.map((element) => listCallback(element, startNumber, depth + 1)).join('\\n');\n\t}\n\n\treturn `${' '.repeat(depth - 1)}${startNumber ? `${startNumber}.` : '-'} ${element}`;\n}\n\n/**\n * Formats the elements in the array to an ordered list.\n *\n * @param list - The array of elements to list\n * @param startNumber - The starting number for the list\n */\nexport function orderedList(list: RecursiveArray<string>, startNumber = 1): string {\n\treturn listCallback(list, Math.max(startNumber, 1));\n}\n\n/**\n * Formats the elements in the array to an unordered list.\n *\n * @param list - The array of elements to list\n */\nexport function unorderedList(list: RecursiveArray<string>): string {\n\treturn listCallback(list);\n}\n\n/**\n * Formats a date into a short date-time string.\n *\n * @param date - The date to format. Defaults to the current time\n */\nexport function time(date?: Date): `<t:${bigint}>`;\n\n/**\n * Formats a date given a format style.\n *\n * @typeParam Style - This is inferred by the supplied {@link TimestampStylesString}\n * @param date - The date to format\n * @param style - The style to use\n */\nexport function time<Style extends TimestampStylesString>(date: Date, style: Style): `<t:${bigint}:${Style}>`;\n\n/**\n * Formats the given timestamp into a short date-time string.\n *\n * @typeParam Seconds - This is inferred by the supplied timestamp\n * @param seconds - A Unix timestamp in seconds\n */\nexport function time<Seconds extends number>(seconds: Seconds): `<t:${Seconds}>`;\n\n/**\n * Formats the given timestamp into a short date-time string.\n *\n * @typeParam Seconds - This is inferred by the supplied timestamp\n * @typeParam Style - This is inferred by the supplied {@link TimestampStylesString}\n * @param seconds - A Unix timestamp in seconds\n * @param style - The style to use\n */\nexport function time<Seconds extends number, Style extends TimestampStylesString>(\n\tseconds: Seconds,\n\tstyle: Style,\n): `<t:${Seconds}:${Style}>`;\n\nexport function time(timeOrSeconds?: Date | number, style?: TimestampStylesString): string {\n\tif (typeof timeOrSeconds !== 'number') {\n\t\t// eslint-disable-next-line no-param-reassign\n\t\ttimeOrSeconds = Math.floor((timeOrSeconds?.getTime() ?? Date.now()) / 1_000);\n\t}\n\n\treturn typeof style === 'string' ? `<t:${timeOrSeconds}:${style}>` : `<t:${timeOrSeconds}>`;\n}\n\n/**\n * The {@link https://discord.com/developers/docs/reference#message-formatting-timestamp-styles | message formatting timestamp styles}\n * supported by Discord.\n */\nexport const TimestampStyles = {\n\t/**\n\t * Short time format, consisting of hours and minutes.\n\t *\n\t * @example `16:20`\n\t */\n\tShortTime: 't',\n\n\t/**\n\t * Long time format, consisting of hours, minutes, and seconds.\n\t *\n\t * @example `16:20:30`\n\t */\n\tLongTime: 'T',\n\n\t/**\n\t * Short date format, consisting of day, month, and year.\n\t *\n\t * @example `20/04/2021`\n\t */\n\tShortDate: 'd',\n\n\t/**\n\t * Long date format, consisting of day, month, and year.\n\t *\n\t * @example `20 April 2021`\n\t */\n\tLongDate: 'D',\n\n\t/**\n\t * Short date-time format, consisting of short date and short time formats.\n\t *\n\t * @example `20 April 2021 16:20`\n\t */\n\tShortDateTime: 'f',\n\n\t/**\n\t * Long date-time format, consisting of long date and short time formats.\n\t *\n\t * @example `Tuesday, 20 April 2021 16:20`\n\t */\n\tLongDateTime: 'F',\n\n\t/**\n\t * Relative time format, consisting of a relative duration format.\n\t *\n\t * @example `2 months ago`\n\t */\n\tRelativeTime: 'R',\n} as const satisfies Record<string, string>;\n\n/**\n * The possible {@link TimestampStyles} values.\n */\nexport type TimestampStylesString = (typeof TimestampStyles)[keyof typeof TimestampStyles];\n\n// prettier-ignore\n/**\n * All the available faces from Discord's native slash commands.\n */\nexport enum Faces {\n\t/**\n\t * `¯\\_(ツ)_/¯`\n\t */\n\t// eslint-disable-next-line no-useless-escape\n\tShrug = '¯\\_(ツ)_/¯',\n\n\t/**\n\t * `(╯°□°)╯︵ ┻━┻`\n\t */\n\tTableflip = '(╯°□°)╯︵ ┻━┻',\n\n\t/**\n\t * `┬─┬ノ( º _ ºノ)`\n\t */\n\tUnflip = '┬─┬ノ( º _ ºノ)',\n}\n\n/**\n * All the available guild navigation mentions.\n */\nexport enum GuildNavigationMentions {\n\t/**\n\t * Browse Channels tab.\n\t */\n\tBrowse = '<id:browse>',\n\t/**\n\t * Customize tab with the server's {@link https://discord.com/developers/docs/resources/guild#guild-onboarding-object | onboarding prompts}.\n\t */\n\tCustomize = '<id:customize>',\n\t/**\n\t * {@link https://support.discord.com/hc/articles/13497665141655 | Server Guide} tab.\n\t */\n\tGuide = '<id:guide>',\n}\n"],"mappings":";;;;AA8GO,SAAS,eAAe,MAAc,UAAiC,CAAC,GAAW;AACzF,QAAM;AAAA,IACL,WAAAA,aAAY;AAAA,IACZ,YAAAC,cAAa;AAAA,IACb,MAAAC,QAAO;AAAA,IACP,QAAAC,UAAS;AAAA,IACT,YAAY;AAAA,IACZ,eAAAC,iBAAgB;AAAA,IAChB,SAAAC,WAAU;AAAA,IACV,mBAAmB;AAAA,IACnB,oBAAoB;AAAA,IACpB,SAAS;AAAA,IACT,SAAAC,WAAU;AAAA,IACV,eAAe;AAAA,IACf,eAAe;AAAA,IACf,aAAa;AAAA,EACd,IAAI;AAEJ,MAAI,CAAC,kBAAkB;AACtB,WAAO,KACL,MAAM,KAAK,EACX,IAAI,CAAC,WAAW,OAAO,UAAU;AACjC,UAAI,QAAQ,KAAK,UAAU,MAAM,SAAS;AAAG,eAAO;AACpD,aAAO,eAAe,WAAW;AAAA,QAChC,YAAAL;AAAA,QACA,MAAAC;AAAA,QACA,QAAAC;AAAA,QACA;AAAA,QACA,eAAAC;AAAA,QACA,SAAAC;AAAA,QACA;AAAA,QACA;AAAA,QACA,SAAAC;A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a,MAAM,KAAK,IAAI,aAAa,CAAC,CAAC;AACnD;AAFgB;AAST,SAAS,cAAc,MAAsC;AACnE,SAAO,aAAa,IAAI;AACzB;AAFgB;AAyCT,SAAS,KAAK,eAA+B,OAAuC;AAC1F,MAAI,OAAO,kBAAkB,UAAU;AAEtC,oBAAgB,KAAK,OAAO,eAAe,QAAQ,KAAK,KAAK,IAAI,KAAK,GAAK;AAAA,EAC5E;AAEA,SAAO,OAAO,UAAU,WAAW,MAAM,aAAa,IAAI,KAAK,MAAM,MAAM,aAAa;AACzF;AAPgB;AAaT,IAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM9B,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOX,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOV,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOX,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOV,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOf,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOd,cAAc;AACf;AAWO,IAAK,QAAL,kBAAKC,WAAL;AAKN,EAAAA,OAAA,WAAQ;AAKR,EAAAA,OAAA,eAAY;AAKZ,EAAAA,OAAA,YAAS;AAfE,SAAAA;AAAA,GAAA;AAqBL,IAAK,0BAAL,kBAAKC,6BAAL;AAIN,EAAAA,yBAAA,YAAS;AAIT,EAAAA,yBAAA,eAAY;AAIZ,EAAAA,yBAAA,WAAQ;AAZG,SAAAA;AAAA,GAAA;","names":["codeBlock","inlineCode","bold","italic","strikethrough","spoiler","heading","HeadingLevel","element","Faces","GuildNavigationMentions"]}
|
node_modules/@discordjs/formatters/package.json
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$schema": "https://json.schemastore.org/package.json",
|
3 |
+
"name": "@discordjs/formatters",
|
4 |
+
"version": "0.3.3",
|
5 |
+
"description": "A set of functions to format strings for Discord.",
|
6 |
+
"exports": {
|
7 |
+
".": {
|
8 |
+
"require": {
|
9 |
+
"types": "./dist/index.d.ts",
|
10 |
+
"default": "./dist/index.js"
|
11 |
+
},
|
12 |
+
"import": {
|
13 |
+
"types": "./dist/index.d.mts",
|
14 |
+
"default": "./dist/index.mjs"
|
15 |
+
}
|
16 |
+
}
|
17 |
+
},
|
18 |
+
"main": "./dist/index.js",
|
19 |
+
"module": "./dist/index.mjs",
|
20 |
+
"types": "./dist/index.d.ts",
|
21 |
+
"directories": {
|
22 |
+
"lib": "src",
|
23 |
+
"test": "__tests__"
|
24 |
+
},
|
25 |
+
"files": [
|
26 |
+
"dist"
|
27 |
+
],
|
28 |
+
"contributors": [
|
29 |
+
"Crawl <icrawltogo@gmail.com>",
|
30 |
+
"SpaceEEC <spaceeec@yahoo.com>",
|
31 |
+
"Vlad Frangu <kingdgrizzle@gmail.com>",
|
32 |
+
"Aura Román <kyradiscord@gmail.com>"
|
33 |
+
],
|
34 |
+
"license": "Apache-2.0",
|
35 |
+
"keywords": [],
|
36 |
+
"repository": {
|
37 |
+
"type": "git",
|
38 |
+
"url": "https://github.com/discordjs/discord.js.git",
|
39 |
+
"directory": "packages/formatters"
|
40 |
+
},
|
41 |
+
"bugs": {
|
42 |
+
"url": "https://github.com/discordjs/discord.js/issues"
|
43 |
+
},
|
44 |
+
"homepage": "https://discord.js.org",
|
45 |
+
"dependencies": {
|
46 |
+
"discord-api-types": "0.37.61"
|
47 |
+
},
|
48 |
+
"devDependencies": {
|
49 |
+
"@favware/cliff-jumper": "^2.2.1",
|
50 |
+
"@types/node": "16.18.60",
|
51 |
+
"@vitest/coverage-v8": "^0.34.6",
|
52 |
+
"cross-env": "^7.0.3",
|
53 |
+
"eslint": "^8.53.0",
|
54 |
+
"eslint-config-neon": "^0.1.57",
|
55 |
+
"eslint-formatter-pretty": "^5.0.0",
|
56 |
+
"prettier": "^3.0.3",
|
57 |
+
"tsup": "^7.2.0",
|
58 |
+
"turbo": "^1.10.17-canary.0",
|
59 |
+
"typescript": "^5.2.2",
|
60 |
+
"vitest": "^0.34.6",
|
61 |
+
"@discordjs/api-extractor": "^7.38.1"
|
62 |
+
},
|
63 |
+
"engines": {
|
64 |
+
"node": ">=16.11.0"
|
65 |
+
},
|
66 |
+
"publishConfig": {
|
67 |
+
"access": "public"
|
68 |
+
},
|
69 |
+
"scripts": {
|
70 |
+
"test": "vitest run",
|
71 |
+
"build": "tsc --noEmit && tsup",
|
72 |
+
"build:docs": "tsc -p tsconfig.docs.json",
|
73 |
+
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
74 |
+
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
75 |
+
"docs": "pnpm run build:docs && api-extractor run --local",
|
76 |
+
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/formatters/*'",
|
77 |
+
"release": "cliff-jumper"
|
78 |
+
}
|
79 |
+
}
|
node_modules/@discordjs/rest/LICENSE
ADDED
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Apache License
|
2 |
+
Version 2.0, January 2004
|
3 |
+
http://www.apache.org/licenses/
|
4 |
+
|
5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6 |
+
|
7 |
+
1. Definitions.
|
8 |
+
|
9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
11 |
+
|
12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13 |
+
the copyright owner that is granting the License.
|
14 |
+
|
15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
16 |
+
other entities that control, are controlled by, or are under common
|
17 |
+
control with that entity. For the purposes of this definition,
|
18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
19 |
+
direction or management of such entity, whether by contract or
|
20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22 |
+
|
23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24 |
+
exercising permissions granted by this License.
|
25 |
+
|
26 |
+
"Source" form shall mean the preferred form for making modifications,
|
27 |
+
including but not limited to software source code, documentation
|
28 |
+
source, and configuration files.
|
29 |
+
|
30 |
+
"Object" form shall mean any form resulting from mechanical
|
31 |
+
transformation or translation of a Source form, including but
|
32 |
+
not limited to compiled object code, generated documentation,
|
33 |
+
and conversions to other media types.
|
34 |
+
|
35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
36 |
+
Object form, made available under the License, as indicated by a
|
37 |
+
copyright notice that is included in or attached to the work
|
38 |
+
(an example is provided in the Appendix below).
|
39 |
+
|
40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41 |
+
form, that is based on (or derived from) the Work and for which the
|
42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
44 |
+
of this License, Derivative Works shall not include works that remain
|
45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46 |
+
the Work and Derivative Works thereof.
|
47 |
+
|
48 |
+
"Contribution" shall mean any work of authorship, including
|
49 |
+
the original version of the Work and any modifications or additions
|
50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
54 |
+
means any form of electronic, verbal, or written communication sent
|
55 |
+
to the Licensor or its representatives, including but not limited to
|
56 |
+
communication on electronic mailing lists, source code control systems,
|
57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
59 |
+
excluding communication that is conspicuously marked or otherwise
|
60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
61 |
+
|
62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
64 |
+
subsequently incorporated within the Work.
|
65 |
+
|
66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
71 |
+
Work and such Derivative Works in Source or Object form.
|
72 |
+
|
73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76 |
+
(except as stated in this section) patent license to make, have made,
|
77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78 |
+
where such license applies only to those patent claims licensable
|
79 |
+
by such Contributor that are necessarily infringed by their
|
80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
82 |
+
institute patent litigation against any entity (including a
|
83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84 |
+
or a Contribution incorporated within the Work constitutes direct
|
85 |
+
or contributory patent infringement, then any patent licenses
|
86 |
+
granted to You under this License for that Work shall terminate
|
87 |
+
as of the date such litigation is filed.
|
88 |
+
|
89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
90 |
+
Work or Derivative Works thereof in any medium, with or without
|
91 |
+
modifications, and in Source or Object form, provided that You
|
92 |
+
meet the following conditions:
|
93 |
+
|
94 |
+
(a) You must give any other recipients of the Work or
|
95 |
+
Derivative Works a copy of this License; and
|
96 |
+
|
97 |
+
(b) You must cause any modified files to carry prominent notices
|
98 |
+
stating that You changed the files; and
|
99 |
+
|
100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
101 |
+
that You distribute, all copyright, patent, trademark, and
|
102 |
+
attribution notices from the Source form of the Work,
|
103 |
+
excluding those notices that do not pertain to any part of
|
104 |
+
the Derivative Works; and
|
105 |
+
|
106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107 |
+
distribution, then any Derivative Works that You distribute must
|
108 |
+
include a readable copy of the attribution notices contained
|
109 |
+
within such NOTICE file, excluding those notices that do not
|
110 |
+
pertain to any part of the Derivative Works, in at least one
|
111 |
+
of the following places: within a NOTICE text file distributed
|
112 |
+
as part of the Derivative Works; within the Source form or
|
113 |
+
documentation, if provided along with the Derivative Works; or,
|
114 |
+
within a display generated by the Derivative Works, if and
|
115 |
+
wherever such third-party notices normally appear. The contents
|
116 |
+
of the NOTICE file are for informational purposes only and
|
117 |
+
do not modify the License. You may add Your own attribution
|
118 |
+
notices within Derivative Works that You distribute, alongside
|
119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
120 |
+
that such additional attribution notices cannot be construed
|
121 |
+
as modifying the License.
|
122 |
+
|
123 |
+
You may add Your own copyright statement to Your modifications and
|
124 |
+
may provide additional or different license terms and conditions
|
125 |
+
for use, reproduction, or distribution of Your modifications, or
|
126 |
+
for any such Derivative Works as a whole, provided Your use,
|
127 |
+
reproduction, and distribution of the Work otherwise complies with
|
128 |
+
the conditions stated in this License.
|
129 |
+
|
130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
132 |
+
by You to the Licensor shall be under the terms and conditions of
|
133 |
+
this License, without any additional terms or conditions.
|
134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135 |
+
the terms of any separate license agreement you may have executed
|
136 |
+
with Licensor regarding such Contributions.
|
137 |
+
|
138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
140 |
+
except as required for reasonable and customary use in describing the
|
141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
142 |
+
|
143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144 |
+
agreed to in writing, Licensor provides the Work (and each
|
145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147 |
+
implied, including, without limitation, any warranties or conditions
|
148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150 |
+
appropriateness of using or redistributing the Work and assume any
|
151 |
+
risks associated with Your exercise of permissions under this License.
|
152 |
+
|
153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
154 |
+
whether in tort (including negligence), contract, or otherwise,
|
155 |
+
unless required by applicable law (such as deliberate and grossly
|
156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157 |
+
liable to You for damages, including any direct, indirect, special,
|
158 |
+
incidental, or consequential damages of any character arising as a
|
159 |
+
result of this License or out of the use or inability to use the
|
160 |
+
Work (including but not limited to damages for loss of goodwill,
|
161 |
+
work stoppage, computer failure or malfunction, or any and all
|
162 |
+
other commercial damages or losses), even if such Contributor
|
163 |
+
has been advised of the possibility of such damages.
|
164 |
+
|
165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168 |
+
or other liability obligations and/or rights consistent with this
|
169 |
+
License. However, in accepting such obligations, You may act only
|
170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171 |
+
of any other Contributor, and only if You agree to indemnify,
|
172 |
+
defend, and hold each Contributor harmless for any liability
|
173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
174 |
+
of your accepting any such warranty or additional liability.
|
175 |
+
|
176 |
+
END OF TERMS AND CONDITIONS
|
177 |
+
|
178 |
+
Copyright 2021 Noel Buechler
|
179 |
+
Copyright 2021 Vlad Frangu
|
180 |
+
Copyright 2021 Aura Román
|
181 |
+
|
182 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
183 |
+
you may not use this file except in compliance with the License.
|
184 |
+
You may obtain a copy of the License at
|
185 |
+
|
186 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
187 |
+
|
188 |
+
Unless required by applicable law or agreed to in writing, software
|
189 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
190 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
191 |
+
See the License for the specific language governing permissions and
|
192 |
+
limitations under the License.
|
node_modules/@discordjs/rest/README.md
ADDED
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div align="center">
|
2 |
+
<br />
|
3 |
+
<p>
|
4 |
+
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
|
5 |
+
</p>
|
6 |
+
<br />
|
7 |
+
<p>
|
8 |
+
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
|
9 |
+
<a href="https://www.npmjs.com/package/@discordjs/rest"><img src="https://img.shields.io/npm/v/@discordjs/rest.svg?maxAge=3600" alt="npm version" /></a>
|
10 |
+
<a href="https://www.npmjs.com/package/@discordjs/rest"><img src="https://img.shields.io/npm/dt/@discordjs/rest.svg?maxAge=3600" alt="npm downloads" /></a>
|
11 |
+
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Tests status" /></a>
|
12 |
+
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=rest" alt="Code coverage" /></a>
|
13 |
+
</p>
|
14 |
+
<p>
|
15 |
+
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
16 |
+
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
|
17 |
+
</p>
|
18 |
+
</div>
|
19 |
+
|
20 |
+
## About
|
21 |
+
|
22 |
+
`@discordjs/rest` is a module that allows you to easily make REST requests to the Discord API.
|
23 |
+
|
24 |
+
## Installation
|
25 |
+
|
26 |
+
**Node.js 16.11.0 or newer is required.**
|
27 |
+
|
28 |
+
Note: native fetch (not recommended) is unavailable in this node version, either use a newer node version or use the more performant `undiciRequest` strategy (default)
|
29 |
+
|
30 |
+
```sh
|
31 |
+
npm install @discordjs/rest
|
32 |
+
yarn add @discordjs/rest
|
33 |
+
pnpm add @discordjs/rest
|
34 |
+
bun add @discordjs/rest
|
35 |
+
```
|
36 |
+
|
37 |
+
## Examples
|
38 |
+
|
39 |
+
Install all required dependencies:
|
40 |
+
|
41 |
+
```sh
|
42 |
+
npm install @discordjs/rest discord-api-types
|
43 |
+
yarn add @discordjs/rest discord-api-types
|
44 |
+
pnpm add @discordjs/rest discord-api-types
|
45 |
+
bun add @discordjs/rest discord-api-types
|
46 |
+
```
|
47 |
+
|
48 |
+
Send a basic message:
|
49 |
+
|
50 |
+
```js
|
51 |
+
import { REST } from '@discordjs/rest';
|
52 |
+
import { Routes } from 'discord-api-types/v10';
|
53 |
+
|
54 |
+
const rest = new REST({ version: '10' }).setToken(TOKEN);
|
55 |
+
|
56 |
+
try {
|
57 |
+
await rest.post(Routes.channelMessages(CHANNEL_ID), {
|
58 |
+
body: {
|
59 |
+
content: 'A message via REST!',
|
60 |
+
},
|
61 |
+
});
|
62 |
+
} catch (error) {
|
63 |
+
console.error(error);
|
64 |
+
}
|
65 |
+
```
|
66 |
+
|
67 |
+
Create a thread from an existing message to be archived after 60 minutes of inactivity:
|
68 |
+
|
69 |
+
```js
|
70 |
+
import { REST } from '@discordjs/rest';
|
71 |
+
import { Routes } from 'discord-api-types/v10';
|
72 |
+
|
73 |
+
const rest = new REST({ version: '10' }).setToken(TOKEN);
|
74 |
+
|
75 |
+
try {
|
76 |
+
await rest.post(Routes.threads(CHANNEL_ID, MESSAGE_ID), {
|
77 |
+
body: {
|
78 |
+
name: 'Thread',
|
79 |
+
auto_archive_duration: 60,
|
80 |
+
},
|
81 |
+
});
|
82 |
+
} catch (error) {
|
83 |
+
console.error(error);
|
84 |
+
}
|
85 |
+
```
|
86 |
+
|
87 |
+
Send a basic message in an edge environment:
|
88 |
+
|
89 |
+
```js
|
90 |
+
import { REST } from '@discordjs/rest';
|
91 |
+
import { Routes } from 'discord-api-types/v10';
|
92 |
+
|
93 |
+
const rest = new REST({ version: '10', makeRequest: fetch }).setToken(TOKEN);
|
94 |
+
|
95 |
+
try {
|
96 |
+
await rest.post(Routes.channelMessages(CHANNEL_ID), {
|
97 |
+
body: {
|
98 |
+
content: 'A message via REST from the edge!',
|
99 |
+
},
|
100 |
+
});
|
101 |
+
} catch (error) {
|
102 |
+
console.error(error);
|
103 |
+
}
|
104 |
+
```
|
105 |
+
|
106 |
+
## Links
|
107 |
+
|
108 |
+
- [Website][website] ([source][website-source])
|
109 |
+
- [Documentation][documentation]
|
110 |
+
- [Guide][guide] ([source][guide-source])
|
111 |
+
Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
|
112 |
+
- [discord.js Discord server][discord]
|
113 |
+
- [Discord API Discord server][discord-api]
|
114 |
+
- [GitHub][source]
|
115 |
+
- [npm][npm]
|
116 |
+
- [Related libraries][related-libs]
|
117 |
+
|
118 |
+
## Contributing
|
119 |
+
|
120 |
+
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
|
121 |
+
[documentation][documentation].
|
122 |
+
See [the contribution guide][contributing] if you'd like to submit a PR.
|
123 |
+
|
124 |
+
## Help
|
125 |
+
|
126 |
+
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][discord].
|
127 |
+
|
128 |
+
[website]: https://discord.js.org
|
129 |
+
[website-source]: https://github.com/discordjs/discord.js/tree/main/apps/website
|
130 |
+
[documentation]: https://discord.js.org/docs/packages/rest/stable
|
131 |
+
[guide]: https://discordjs.guide/
|
132 |
+
[guide-source]: https://github.com/discordjs/guide
|
133 |
+
[guide-update]: https://discordjs.guide/additional-info/changes-in-v14.html
|
134 |
+
[discord]: https://discord.gg/djs
|
135 |
+
[discord-api]: https://discord.gg/discord-api
|
136 |
+
[source]: https://github.com/discordjs/discord.js/tree/main/packages/rest
|
137 |
+
[npm]: https://www.npmjs.com/package/@discordjs/rest
|
138 |
+
[related-libs]: https://discord.com/developers/docs/topics/community-resources#libraries
|
139 |
+
[contributing]: https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md
|
node_modules/@discordjs/rest/dist/index.d.mts
ADDED
@@ -0,0 +1,901 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import * as url from 'url';
|
2 |
+
import { Snowflake } from 'discord-api-types/v10';
|
3 |
+
import { Readable } from 'node:stream';
|
4 |
+
import { ReadableStream } from 'node:stream/web';
|
5 |
+
import { Collection } from '@discordjs/collection';
|
6 |
+
import { Awaitable } from '@discordjs/util';
|
7 |
+
import * as undici from 'undici';
|
8 |
+
import { RequestInit, Dispatcher, Response, BodyInit, Agent } from 'undici';
|
9 |
+
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
10 |
+
|
11 |
+
interface IHandler {
|
12 |
+
/**
|
13 |
+
* The unique id of the handler
|
14 |
+
*/
|
15 |
+
readonly id: string;
|
16 |
+
/**
|
17 |
+
* If the bucket is currently inactive (no pending requests)
|
18 |
+
*/
|
19 |
+
get inactive(): boolean;
|
20 |
+
/**
|
21 |
+
* Queues a request to be sent
|
22 |
+
*
|
23 |
+
* @param routeId - The generalized api route with literal ids for major parameters
|
24 |
+
* @param url - The url to do the request on
|
25 |
+
* @param options - All the information needed to make a request
|
26 |
+
* @param requestData - Extra data from the user's request needed for errors and additional processing
|
27 |
+
*/
|
28 |
+
queueRequest(routeId: RouteData, url: string, options: RequestInit, requestData: HandlerRequestData): Promise<ResponseLike>;
|
29 |
+
}
|
30 |
+
|
31 |
+
interface RestEvents {
|
32 |
+
handlerSweep: [sweptHandlers: Collection<string, IHandler>];
|
33 |
+
hashSweep: [sweptHashes: Collection<string, HashData>];
|
34 |
+
invalidRequestWarning: [invalidRequestInfo: InvalidRequestWarningData];
|
35 |
+
rateLimited: [rateLimitInfo: RateLimitData];
|
36 |
+
response: [request: APIRequest, response: ResponseLike];
|
37 |
+
restDebug: [info: string];
|
38 |
+
}
|
39 |
+
type RestEventsMap = {
|
40 |
+
[K in keyof RestEvents]: RestEvents[K];
|
41 |
+
};
|
42 |
+
/**
|
43 |
+
* Options to be passed when creating the REST instance
|
44 |
+
*/
|
45 |
+
interface RESTOptions {
|
46 |
+
/**
|
47 |
+
* The agent to set globally
|
48 |
+
*/
|
49 |
+
agent: Dispatcher | null;
|
50 |
+
/**
|
51 |
+
* The base api path, without version
|
52 |
+
*
|
53 |
+
* @defaultValue `'https://discord.com/api'`
|
54 |
+
*/
|
55 |
+
api: string;
|
56 |
+
/**
|
57 |
+
* The authorization prefix to use for requests, useful if you want to use
|
58 |
+
* bearer tokens
|
59 |
+
*
|
60 |
+
* @defaultValue `'Bot'`
|
61 |
+
*/
|
62 |
+
authPrefix: 'Bearer' | 'Bot';
|
63 |
+
/**
|
64 |
+
* The cdn path
|
65 |
+
*
|
66 |
+
* @defaultValue `'https://cdn.discordapp.com'`
|
67 |
+
*/
|
68 |
+
cdn: string;
|
69 |
+
/**
|
70 |
+
* How many requests to allow sending per second (Infinity for unlimited, 50 for the standard global limit used by Discord)
|
71 |
+
*
|
72 |
+
* @defaultValue `50`
|
73 |
+
*/
|
74 |
+
globalRequestsPerSecond: number;
|
75 |
+
/**
|
76 |
+
* The amount of time in milliseconds that passes between each hash sweep. (defaults to 1h)
|
77 |
+
*
|
78 |
+
* @defaultValue `3_600_000`
|
79 |
+
*/
|
80 |
+
handlerSweepInterval: number;
|
81 |
+
/**
|
82 |
+
* The maximum amount of time a hash can exist in milliseconds without being hit with a request (defaults to 24h)
|
83 |
+
*
|
84 |
+
* @defaultValue `86_400_000`
|
85 |
+
*/
|
86 |
+
hashLifetime: number;
|
87 |
+
/**
|
88 |
+
* The amount of time in milliseconds that passes between each hash sweep. (defaults to 4h)
|
89 |
+
*
|
90 |
+
* @defaultValue `14_400_000`
|
91 |
+
*/
|
92 |
+
hashSweepInterval: number;
|
93 |
+
/**
|
94 |
+
* Additional headers to send for all API requests
|
95 |
+
*
|
96 |
+
* @defaultValue `{}`
|
97 |
+
*/
|
98 |
+
headers: Record<string, string>;
|
99 |
+
/**
|
100 |
+
* The number of invalid REST requests (those that return 401, 403, or 429) in a 10 minute window between emitted warnings (0 for no warnings).
|
101 |
+
* That is, if set to 500, warnings will be emitted at invalid request number 500, 1000, 1500, and so on.
|
102 |
+
*
|
103 |
+
* @defaultValue `0`
|
104 |
+
*/
|
105 |
+
invalidRequestWarningInterval: number;
|
106 |
+
/**
|
107 |
+
* The method called to perform the actual HTTP request given a url and web `fetch` options
|
108 |
+
* For example, to use global fetch, simply provide `makeRequest: fetch`
|
109 |
+
*/
|
110 |
+
makeRequest(url: string, init: RequestInit): Promise<ResponseLike>;
|
111 |
+
/**
|
112 |
+
* The extra offset to add to rate limits in milliseconds
|
113 |
+
*
|
114 |
+
* @defaultValue `50`
|
115 |
+
*/
|
116 |
+
offset: number;
|
117 |
+
/**
|
118 |
+
* Determines how rate limiting and pre-emptive throttling should be handled.
|
119 |
+
* When an array of strings, each element is treated as a prefix for the request route
|
120 |
+
* (e.g. `/channels` to match any route starting with `/channels` such as `/channels/:id/messages`)
|
121 |
+
* for which to throw {@link RateLimitError}s. All other request routes will be queued normally
|
122 |
+
*
|
123 |
+
* @defaultValue `null`
|
124 |
+
*/
|
125 |
+
rejectOnRateLimit: RateLimitQueueFilter | string[] | null;
|
126 |
+
/**
|
127 |
+
* The number of retries for errors with the 500 code, or errors
|
128 |
+
* that timeout
|
129 |
+
*
|
130 |
+
* @defaultValue `3`
|
131 |
+
*/
|
132 |
+
retries: number;
|
133 |
+
/**
|
134 |
+
* The time to wait in milliseconds before a request is aborted
|
135 |
+
*
|
136 |
+
* @defaultValue `15_000`
|
137 |
+
*/
|
138 |
+
timeout: number;
|
139 |
+
/**
|
140 |
+
* Extra information to add to the user agent
|
141 |
+
*
|
142 |
+
* @defaultValue DefaultUserAgentAppendix
|
143 |
+
*/
|
144 |
+
userAgentAppendix: string;
|
145 |
+
/**
|
146 |
+
* The version of the API to use
|
147 |
+
*
|
148 |
+
* @defaultValue `'10'`
|
149 |
+
*/
|
150 |
+
version: string;
|
151 |
+
}
|
152 |
+
/**
|
153 |
+
* Data emitted on `RESTEvents.RateLimited`
|
154 |
+
*/
|
155 |
+
interface RateLimitData {
|
156 |
+
/**
|
157 |
+
* Whether the rate limit that was reached was the global limit
|
158 |
+
*/
|
159 |
+
global: boolean;
|
160 |
+
/**
|
161 |
+
* The bucket hash for this request
|
162 |
+
*/
|
163 |
+
hash: string;
|
164 |
+
/**
|
165 |
+
* The amount of requests we can perform before locking requests
|
166 |
+
*/
|
167 |
+
limit: number;
|
168 |
+
/**
|
169 |
+
* The major parameter of the route
|
170 |
+
*
|
171 |
+
* For example, in `/channels/x`, this will be `x`.
|
172 |
+
* If there is no major parameter (e.g: `/bot/gateway`) this will be `global`.
|
173 |
+
*/
|
174 |
+
majorParameter: string;
|
175 |
+
/**
|
176 |
+
* The HTTP method being performed
|
177 |
+
*/
|
178 |
+
method: string;
|
179 |
+
/**
|
180 |
+
* The time, in milliseconds, that will need to pass before this specific request can be retried
|
181 |
+
*/
|
182 |
+
retryAfter: number;
|
183 |
+
/**
|
184 |
+
* The route being hit in this request
|
185 |
+
*/
|
186 |
+
route: string;
|
187 |
+
/**
|
188 |
+
* The scope of the rate limit that was hit.
|
189 |
+
*
|
190 |
+
* This can be `user` for rate limits that are per client, `global` for rate limits that affect all clients or `shared` for rate limits that
|
191 |
+
* are shared per resource.
|
192 |
+
*/
|
193 |
+
scope: 'global' | 'shared' | 'user';
|
194 |
+
/**
|
195 |
+
* The time, in milliseconds, that will need to pass before the sublimit lock for the route resets, and requests that fall under a sublimit
|
196 |
+
* can be retried
|
197 |
+
*
|
198 |
+
* This is only present on certain sublimits, and `0` otherwise
|
199 |
+
*/
|
200 |
+
sublimitTimeout: number;
|
201 |
+
/**
|
202 |
+
* The time, in milliseconds, until the route's request-lock is reset
|
203 |
+
*/
|
204 |
+
timeToReset: number;
|
205 |
+
/**
|
206 |
+
* The full URL for this request
|
207 |
+
*/
|
208 |
+
url: string;
|
209 |
+
}
|
210 |
+
/**
|
211 |
+
* A function that determines whether the rate limit hit should throw an Error
|
212 |
+
*/
|
213 |
+
type RateLimitQueueFilter = (rateLimitData: RateLimitData) => Awaitable<boolean>;
|
214 |
+
interface APIRequest {
|
215 |
+
/**
|
216 |
+
* The data that was used to form the body of this request
|
217 |
+
*/
|
218 |
+
data: HandlerRequestData;
|
219 |
+
/**
|
220 |
+
* The HTTP method used in this request
|
221 |
+
*/
|
222 |
+
method: string;
|
223 |
+
/**
|
224 |
+
* Additional HTTP options for this request
|
225 |
+
*/
|
226 |
+
options: RequestInit;
|
227 |
+
/**
|
228 |
+
* The full path used to make the request
|
229 |
+
*/
|
230 |
+
path: RouteLike;
|
231 |
+
/**
|
232 |
+
* The number of times this request has been attempted
|
233 |
+
*/
|
234 |
+
retries: number;
|
235 |
+
/**
|
236 |
+
* The API route identifying the ratelimit for this request
|
237 |
+
*/
|
238 |
+
route: string;
|
239 |
+
}
|
240 |
+
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | 'headers' | 'json' | 'ok' | 'status' | 'statusText' | 'text'> {
|
241 |
+
body: Readable | ReadableStream | null;
|
242 |
+
}
|
243 |
+
interface InvalidRequestWarningData {
|
244 |
+
/**
|
245 |
+
* Number of invalid requests that have been made in the window
|
246 |
+
*/
|
247 |
+
count: number;
|
248 |
+
/**
|
249 |
+
* Time in milliseconds remaining before the count resets
|
250 |
+
*/
|
251 |
+
remainingTime: number;
|
252 |
+
}
|
253 |
+
/**
|
254 |
+
* Represents a file to be added to the request
|
255 |
+
*/
|
256 |
+
interface RawFile {
|
257 |
+
/**
|
258 |
+
* Content-Type of the file
|
259 |
+
*/
|
260 |
+
contentType?: string;
|
261 |
+
/**
|
262 |
+
* The actual data for the file
|
263 |
+
*/
|
264 |
+
data: Buffer | Uint8Array | boolean | number | string;
|
265 |
+
/**
|
266 |
+
* An explicit key to use for key of the formdata field for this file.
|
267 |
+
* When not provided, the index of the file in the files array is used in the form `files[${index}]`.
|
268 |
+
* If you wish to alter the placeholder snowflake, you must provide this property in the same form (`files[${placeholder}]`)
|
269 |
+
*/
|
270 |
+
key?: string;
|
271 |
+
/**
|
272 |
+
* The name of the file
|
273 |
+
*/
|
274 |
+
name: string;
|
275 |
+
}
|
276 |
+
/**
|
277 |
+
* Represents possible data to be given to an endpoint
|
278 |
+
*/
|
279 |
+
interface RequestData {
|
280 |
+
/**
|
281 |
+
* Whether to append JSON data to form data instead of `payload_json` when sending files
|
282 |
+
*/
|
283 |
+
appendToFormData?: boolean;
|
284 |
+
/**
|
285 |
+
* If this request needs the `Authorization` header
|
286 |
+
*
|
287 |
+
* @defaultValue `true`
|
288 |
+
*/
|
289 |
+
auth?: boolean;
|
290 |
+
/**
|
291 |
+
* The authorization prefix to use for this request, useful if you use this with bearer tokens
|
292 |
+
*
|
293 |
+
* @defaultValue `'Bot'`
|
294 |
+
*/
|
295 |
+
authPrefix?: 'Bearer' | 'Bot';
|
296 |
+
/**
|
297 |
+
* The body to send to this request.
|
298 |
+
* If providing as BodyInit, set `passThroughBody: true`
|
299 |
+
*/
|
300 |
+
body?: BodyInit | unknown;
|
301 |
+
/**
|
302 |
+
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} to use for the request.
|
303 |
+
*/
|
304 |
+
dispatcher?: Agent;
|
305 |
+
/**
|
306 |
+
* Files to be attached to this request
|
307 |
+
*/
|
308 |
+
files?: RawFile[] | undefined;
|
309 |
+
/**
|
310 |
+
* Additional headers to add to this request
|
311 |
+
*/
|
312 |
+
headers?: Record<string, string>;
|
313 |
+
/**
|
314 |
+
* Whether to pass-through the body property directly to `fetch()`.
|
315 |
+
* <warn>This only applies when files is NOT present</warn>
|
316 |
+
*/
|
317 |
+
passThroughBody?: boolean;
|
318 |
+
/**
|
319 |
+
* Query string parameters to append to the called endpoint
|
320 |
+
*/
|
321 |
+
query?: URLSearchParams;
|
322 |
+
/**
|
323 |
+
* Reason to show in the audit logs
|
324 |
+
*/
|
325 |
+
reason?: string | undefined;
|
326 |
+
/**
|
327 |
+
* The signal to abort the queue entry or the REST call, where applicable
|
328 |
+
*/
|
329 |
+
signal?: AbortSignal | undefined;
|
330 |
+
/**
|
331 |
+
* If this request should be versioned
|
332 |
+
*
|
333 |
+
* @defaultValue `true`
|
334 |
+
*/
|
335 |
+
versioned?: boolean;
|
336 |
+
}
|
337 |
+
/**
|
338 |
+
* Possible headers for an API call
|
339 |
+
*/
|
340 |
+
interface RequestHeaders {
|
341 |
+
Authorization?: string;
|
342 |
+
'User-Agent': string;
|
343 |
+
'X-Audit-Log-Reason'?: string;
|
344 |
+
}
|
345 |
+
/**
|
346 |
+
* Possible API methods to be used when doing requests
|
347 |
+
*/
|
348 |
+
declare enum RequestMethod {
|
349 |
+
Delete = "DELETE",
|
350 |
+
Get = "GET",
|
351 |
+
Patch = "PATCH",
|
352 |
+
Post = "POST",
|
353 |
+
Put = "PUT"
|
354 |
+
}
|
355 |
+
type RouteLike = `/${string}`;
|
356 |
+
/**
|
357 |
+
* Internal request options
|
358 |
+
*
|
359 |
+
* @internal
|
360 |
+
*/
|
361 |
+
interface InternalRequest extends RequestData {
|
362 |
+
fullRoute: RouteLike;
|
363 |
+
method: RequestMethod;
|
364 |
+
}
|
365 |
+
type HandlerRequestData = Pick<InternalRequest, 'auth' | 'body' | 'files' | 'signal'>;
|
366 |
+
/**
|
367 |
+
* Parsed route data for an endpoint
|
368 |
+
*
|
369 |
+
* @internal
|
370 |
+
*/
|
371 |
+
interface RouteData {
|
372 |
+
bucketRoute: string;
|
373 |
+
majorParameter: string;
|
374 |
+
original: RouteLike;
|
375 |
+
}
|
376 |
+
/**
|
377 |
+
* Represents a hash and its associated fields
|
378 |
+
*
|
379 |
+
* @internal
|
380 |
+
*/
|
381 |
+
interface HashData {
|
382 |
+
lastAccess: number;
|
383 |
+
value: string;
|
384 |
+
}
|
385 |
+
|
386 |
+
declare const DefaultUserAgent: `DiscordBot (https://discord.js.org, ${string})`;
|
387 |
+
/**
|
388 |
+
* The default string to append onto the user agent.
|
389 |
+
*/
|
390 |
+
declare const DefaultUserAgentAppendix: string;
|
391 |
+
declare const DefaultRestOptions: {
|
392 |
+
readonly agent: null;
|
393 |
+
readonly api: "https://discord.com/api";
|
394 |
+
readonly authPrefix: "Bot";
|
395 |
+
readonly cdn: "https://cdn.discordapp.com";
|
396 |
+
readonly headers: {};
|
397 |
+
readonly invalidRequestWarningInterval: 0;
|
398 |
+
readonly globalRequestsPerSecond: 50;
|
399 |
+
readonly offset: 50;
|
400 |
+
readonly rejectOnRateLimit: null;
|
401 |
+
readonly retries: 3;
|
402 |
+
readonly timeout: 15000;
|
403 |
+
readonly userAgentAppendix: string;
|
404 |
+
readonly version: "10";
|
405 |
+
readonly hashSweepInterval: 14400000;
|
406 |
+
readonly hashLifetime: 86400000;
|
407 |
+
readonly handlerSweepInterval: 3600000;
|
408 |
+
readonly makeRequest: (url: string, init: undici.RequestInit) => Promise<ResponseLike>;
|
409 |
+
};
|
410 |
+
/**
|
411 |
+
* The events that the REST manager emits
|
412 |
+
*/
|
413 |
+
declare enum RESTEvents {
|
414 |
+
Debug = "restDebug",
|
415 |
+
HandlerSweep = "handlerSweep",
|
416 |
+
HashSweep = "hashSweep",
|
417 |
+
InvalidRequestWarning = "invalidRequestWarning",
|
418 |
+
RateLimited = "rateLimited",
|
419 |
+
Response = "response"
|
420 |
+
}
|
421 |
+
declare const ALLOWED_EXTENSIONS: readonly ["webp", "png", "jpg", "jpeg", "gif"];
|
422 |
+
declare const ALLOWED_STICKER_EXTENSIONS: readonly ["png", "json", "gif"];
|
423 |
+
declare const ALLOWED_SIZES: readonly [16, 32, 64, 128, 256, 512, 1024, 2048, 4096];
|
424 |
+
type ImageExtension = (typeof ALLOWED_EXTENSIONS)[number];
|
425 |
+
type StickerExtension = (typeof ALLOWED_STICKER_EXTENSIONS)[number];
|
426 |
+
type ImageSize = (typeof ALLOWED_SIZES)[number];
|
427 |
+
declare const OverwrittenMimeTypes: {
|
428 |
+
readonly 'image/apng': "image/png";
|
429 |
+
};
|
430 |
+
declare const BurstHandlerMajorIdKey = "burst";
|
431 |
+
/**
|
432 |
+
* Prefix for deprecation warnings.
|
433 |
+
*
|
434 |
+
* @internal
|
435 |
+
*/
|
436 |
+
declare const DEPRECATION_WARNING_PREFIX: "DeprecationWarning";
|
437 |
+
|
438 |
+
/**
|
439 |
+
* The options used for image URLs
|
440 |
+
*/
|
441 |
+
interface BaseImageURLOptions {
|
442 |
+
/**
|
443 |
+
* The extension to use for the image URL
|
444 |
+
*
|
445 |
+
* @defaultValue `'webp'`
|
446 |
+
*/
|
447 |
+
extension?: ImageExtension;
|
448 |
+
/**
|
449 |
+
* The size specified in the image URL
|
450 |
+
*/
|
451 |
+
size?: ImageSize;
|
452 |
+
}
|
453 |
+
/**
|
454 |
+
* The options used for image URLs with animated content
|
455 |
+
*/
|
456 |
+
interface ImageURLOptions extends BaseImageURLOptions {
|
457 |
+
/**
|
458 |
+
* Whether or not to prefer the static version of an image asset.
|
459 |
+
*/
|
460 |
+
forceStatic?: boolean;
|
461 |
+
}
|
462 |
+
/**
|
463 |
+
* The options to use when making a CDN URL
|
464 |
+
*/
|
465 |
+
interface MakeURLOptions {
|
466 |
+
/**
|
467 |
+
* The allowed extensions that can be used
|
468 |
+
*/
|
469 |
+
allowedExtensions?: readonly string[];
|
470 |
+
/**
|
471 |
+
* The extension to use for the image URL
|
472 |
+
*
|
473 |
+
* @defaultValue `'webp'`
|
474 |
+
*/
|
475 |
+
extension?: string | undefined;
|
476 |
+
/**
|
477 |
+
* The size specified in the image URL
|
478 |
+
*/
|
479 |
+
size?: ImageSize;
|
480 |
+
}
|
481 |
+
/**
|
482 |
+
* The CDN link builder
|
483 |
+
*/
|
484 |
+
declare class CDN {
|
485 |
+
private readonly base;
|
486 |
+
constructor(base?: string);
|
487 |
+
/**
|
488 |
+
* Generates an app asset URL for a client's asset.
|
489 |
+
*
|
490 |
+
* @param clientId - The client id that has the asset
|
491 |
+
* @param assetHash - The hash provided by Discord for this asset
|
492 |
+
* @param options - Optional options for the asset
|
493 |
+
*/
|
494 |
+
appAsset(clientId: string, assetHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
495 |
+
/**
|
496 |
+
* Generates an app icon URL for a client's icon.
|
497 |
+
*
|
498 |
+
* @param clientId - The client id that has the icon
|
499 |
+
* @param iconHash - The hash provided by Discord for this icon
|
500 |
+
* @param options - Optional options for the icon
|
501 |
+
*/
|
502 |
+
appIcon(clientId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
503 |
+
/**
|
504 |
+
* Generates an avatar URL, e.g. for a user or a webhook.
|
505 |
+
*
|
506 |
+
* @param id - The id that has the icon
|
507 |
+
* @param avatarHash - The hash provided by Discord for this avatar
|
508 |
+
* @param options - Optional options for the avatar
|
509 |
+
*/
|
510 |
+
avatar(id: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
511 |
+
/**
|
512 |
+
* Generates a user avatar decoration URL.
|
513 |
+
*
|
514 |
+
* @param userId - The id of the user
|
515 |
+
* @param userAvatarDecoration - The hash provided by Discord for this avatar decoration
|
516 |
+
* @param options - Optional options for the avatar decoration
|
517 |
+
*/
|
518 |
+
avatarDecoration(userId: string, userAvatarDecoration: string, options?: Readonly<BaseImageURLOptions>): string;
|
519 |
+
/**
|
520 |
+
* Generates a banner URL, e.g. for a user or a guild.
|
521 |
+
*
|
522 |
+
* @param id - The id that has the banner splash
|
523 |
+
* @param bannerHash - The hash provided by Discord for this banner
|
524 |
+
* @param options - Optional options for the banner
|
525 |
+
*/
|
526 |
+
banner(id: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
527 |
+
/**
|
528 |
+
* Generates an icon URL for a channel, e.g. a group DM.
|
529 |
+
*
|
530 |
+
* @param channelId - The channel id that has the icon
|
531 |
+
* @param iconHash - The hash provided by Discord for this channel
|
532 |
+
* @param options - Optional options for the icon
|
533 |
+
*/
|
534 |
+
channelIcon(channelId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
535 |
+
/**
|
536 |
+
* Generates a default avatar URL
|
537 |
+
*
|
538 |
+
* @param index - The default avatar index
|
539 |
+
* @remarks
|
540 |
+
* To calculate the index for a user do `(userId >> 22) % 6`,
|
541 |
+
* or `discriminator % 5` if they're using the legacy username system.
|
542 |
+
*/
|
543 |
+
defaultAvatar(index: number): string;
|
544 |
+
/**
|
545 |
+
* Generates a discovery splash URL for a guild's discovery splash.
|
546 |
+
*
|
547 |
+
* @param guildId - The guild id that has the discovery splash
|
548 |
+
* @param splashHash - The hash provided by Discord for this splash
|
549 |
+
* @param options - Optional options for the splash
|
550 |
+
*/
|
551 |
+
discoverySplash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
552 |
+
/**
|
553 |
+
* Generates an emoji's URL for an emoji.
|
554 |
+
*
|
555 |
+
* @param emojiId - The emoji id
|
556 |
+
* @param options - Optional options for the emoji
|
557 |
+
*/
|
558 |
+
emoji(emojiId: string, options?: Readonly<BaseImageURLOptions>): string;
|
559 |
+
/**
|
560 |
+
* Generates an emoji's URL for an emoji.
|
561 |
+
*
|
562 |
+
* @param emojiId - The emoji id
|
563 |
+
* @param extension - The extension of the emoji
|
564 |
+
* @deprecated This overload is deprecated. Pass an object containing the extension instead.
|
565 |
+
*/
|
566 |
+
emoji(emojiId: string, extension?: ImageExtension): string;
|
567 |
+
/**
|
568 |
+
* Generates a guild member avatar URL.
|
569 |
+
*
|
570 |
+
* @param guildId - The id of the guild
|
571 |
+
* @param userId - The id of the user
|
572 |
+
* @param avatarHash - The hash provided by Discord for this avatar
|
573 |
+
* @param options - Optional options for the avatar
|
574 |
+
*/
|
575 |
+
guildMemberAvatar(guildId: string, userId: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
576 |
+
/**
|
577 |
+
* Generates a guild member banner URL.
|
578 |
+
*
|
579 |
+
* @param guildId - The id of the guild
|
580 |
+
* @param userId - The id of the user
|
581 |
+
* @param bannerHash - The hash provided by Discord for this banner
|
582 |
+
* @param options - Optional options for the banner
|
583 |
+
*/
|
584 |
+
guildMemberBanner(guildId: string, userId: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
585 |
+
/**
|
586 |
+
* Generates an icon URL, e.g. for a guild.
|
587 |
+
*
|
588 |
+
* @param id - The id that has the icon splash
|
589 |
+
* @param iconHash - The hash provided by Discord for this icon
|
590 |
+
* @param options - Optional options for the icon
|
591 |
+
*/
|
592 |
+
icon(id: string, iconHash: string, options?: Readonly<ImageURLOptions>): string;
|
593 |
+
/**
|
594 |
+
* Generates a URL for the icon of a role
|
595 |
+
*
|
596 |
+
* @param roleId - The id of the role that has the icon
|
597 |
+
* @param roleIconHash - The hash provided by Discord for this role icon
|
598 |
+
* @param options - Optional options for the role icon
|
599 |
+
*/
|
600 |
+
roleIcon(roleId: string, roleIconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
601 |
+
/**
|
602 |
+
* Generates a guild invite splash URL for a guild's invite splash.
|
603 |
+
*
|
604 |
+
* @param guildId - The guild id that has the invite splash
|
605 |
+
* @param splashHash - The hash provided by Discord for this splash
|
606 |
+
* @param options - Optional options for the splash
|
607 |
+
*/
|
608 |
+
splash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
609 |
+
/**
|
610 |
+
* Generates a sticker URL.
|
611 |
+
*
|
612 |
+
* @param stickerId - The sticker id
|
613 |
+
* @param extension - The extension of the sticker
|
614 |
+
* @privateRemarks
|
615 |
+
* Stickers cannot have a `.webp` extension, so we default to a `.png`
|
616 |
+
*/
|
617 |
+
sticker(stickerId: string, extension?: StickerExtension): string;
|
618 |
+
/**
|
619 |
+
* Generates a sticker pack banner URL.
|
620 |
+
*
|
621 |
+
* @param bannerId - The banner id
|
622 |
+
* @param options - Optional options for the banner
|
623 |
+
*/
|
624 |
+
stickerPackBanner(bannerId: string, options?: Readonly<BaseImageURLOptions>): string;
|
625 |
+
/**
|
626 |
+
* Generates a team icon URL for a team's icon.
|
627 |
+
*
|
628 |
+
* @param teamId - The team id that has the icon
|
629 |
+
* @param iconHash - The hash provided by Discord for this icon
|
630 |
+
* @param options - Optional options for the icon
|
631 |
+
*/
|
632 |
+
teamIcon(teamId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
633 |
+
/**
|
634 |
+
* Generates a cover image for a guild scheduled event.
|
635 |
+
*
|
636 |
+
* @param scheduledEventId - The scheduled event id
|
637 |
+
* @param coverHash - The hash provided by discord for this cover image
|
638 |
+
* @param options - Optional options for the cover image
|
639 |
+
*/
|
640 |
+
guildScheduledEventCover(scheduledEventId: string, coverHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
641 |
+
/**
|
642 |
+
* Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
|
643 |
+
*
|
644 |
+
* @param route - The base cdn route
|
645 |
+
* @param hash - The hash provided by Discord for this icon
|
646 |
+
* @param options - Optional options for the link
|
647 |
+
*/
|
648 |
+
private dynamicMakeURL;
|
649 |
+
/**
|
650 |
+
* Constructs the URL for the resource
|
651 |
+
*
|
652 |
+
* @param route - The base cdn route
|
653 |
+
* @param options - The extension/size options for the link
|
654 |
+
*/
|
655 |
+
private makeURL;
|
656 |
+
}
|
657 |
+
|
658 |
+
interface DiscordErrorFieldInformation {
|
659 |
+
code: string;
|
660 |
+
message: string;
|
661 |
+
}
|
662 |
+
interface DiscordErrorGroupWrapper {
|
663 |
+
_errors: DiscordError[];
|
664 |
+
}
|
665 |
+
type DiscordError = DiscordErrorFieldInformation | DiscordErrorGroupWrapper | string | {
|
666 |
+
[k: string]: DiscordError;
|
667 |
+
};
|
668 |
+
interface DiscordErrorData {
|
669 |
+
code: number;
|
670 |
+
errors?: DiscordError;
|
671 |
+
message: string;
|
672 |
+
}
|
673 |
+
interface OAuthErrorData {
|
674 |
+
error: string;
|
675 |
+
error_description?: string;
|
676 |
+
}
|
677 |
+
interface RequestBody {
|
678 |
+
files: RawFile[] | undefined;
|
679 |
+
json: unknown | undefined;
|
680 |
+
}
|
681 |
+
/**
|
682 |
+
* Represents an API error returned by Discord
|
683 |
+
*/
|
684 |
+
declare class DiscordAPIError extends Error {
|
685 |
+
rawError: DiscordErrorData | OAuthErrorData;
|
686 |
+
code: number | string;
|
687 |
+
status: number;
|
688 |
+
method: string;
|
689 |
+
url: string;
|
690 |
+
requestBody: RequestBody;
|
691 |
+
/**
|
692 |
+
* @param rawError - The error reported by Discord
|
693 |
+
* @param code - The error code reported by Discord
|
694 |
+
* @param status - The status code of the response
|
695 |
+
* @param method - The method of the request that erred
|
696 |
+
* @param url - The url of the request that erred
|
697 |
+
* @param bodyData - The unparsed data for the request that errored
|
698 |
+
*/
|
699 |
+
constructor(rawError: DiscordErrorData | OAuthErrorData, code: number | string, status: number, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
|
700 |
+
/**
|
701 |
+
* The name of the error
|
702 |
+
*/
|
703 |
+
get name(): string;
|
704 |
+
private static getMessage;
|
705 |
+
private static flattenDiscordError;
|
706 |
+
}
|
707 |
+
|
708 |
+
/**
|
709 |
+
* Represents a HTTP error
|
710 |
+
*/
|
711 |
+
declare class HTTPError extends Error {
|
712 |
+
status: number;
|
713 |
+
method: string;
|
714 |
+
url: string;
|
715 |
+
requestBody: RequestBody;
|
716 |
+
name: string;
|
717 |
+
/**
|
718 |
+
* @param status - The status code of the response
|
719 |
+
* @param statusText - The status text of the response
|
720 |
+
* @param method - The method of the request that erred
|
721 |
+
* @param url - The url of the request that erred
|
722 |
+
* @param bodyData - The unparsed data for the request that errored
|
723 |
+
*/
|
724 |
+
constructor(status: number, statusText: string, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
|
725 |
+
}
|
726 |
+
|
727 |
+
declare class RateLimitError extends Error implements RateLimitData {
|
728 |
+
timeToReset: number;
|
729 |
+
limit: number;
|
730 |
+
method: string;
|
731 |
+
hash: string;
|
732 |
+
url: string;
|
733 |
+
route: string;
|
734 |
+
majorParameter: string;
|
735 |
+
global: boolean;
|
736 |
+
retryAfter: number;
|
737 |
+
sublimitTimeout: number;
|
738 |
+
scope: RateLimitData['scope'];
|
739 |
+
constructor({ timeToReset, limit, method, hash, url, route, majorParameter, global, retryAfter, sublimitTimeout, scope, }: RateLimitData);
|
740 |
+
/**
|
741 |
+
* The name of the error
|
742 |
+
*/
|
743 |
+
get name(): string;
|
744 |
+
}
|
745 |
+
|
746 |
+
/**
|
747 |
+
* Represents the class that manages handlers for endpoints
|
748 |
+
*/
|
749 |
+
declare class REST extends AsyncEventEmitter<RestEventsMap> {
|
750 |
+
#private;
|
751 |
+
/**
|
752 |
+
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} for all requests
|
753 |
+
* performed by this manager.
|
754 |
+
*/
|
755 |
+
agent: Dispatcher | null;
|
756 |
+
readonly cdn: CDN;
|
757 |
+
/**
|
758 |
+
* The number of requests remaining in the global bucket
|
759 |
+
*/
|
760 |
+
globalRemaining: number;
|
761 |
+
/**
|
762 |
+
* The promise used to wait out the global rate limit
|
763 |
+
*/
|
764 |
+
globalDelay: Promise<void> | null;
|
765 |
+
/**
|
766 |
+
* The timestamp at which the global bucket resets
|
767 |
+
*/
|
768 |
+
globalReset: number;
|
769 |
+
/**
|
770 |
+
* API bucket hashes that are cached from provided routes
|
771 |
+
*/
|
772 |
+
readonly hashes: Collection<string, HashData>;
|
773 |
+
/**
|
774 |
+
* Request handlers created from the bucket hash and the major parameters
|
775 |
+
*/
|
776 |
+
readonly handlers: Collection<string, IHandler>;
|
777 |
+
private hashTimer;
|
778 |
+
private handlerTimer;
|
779 |
+
readonly options: RESTOptions;
|
780 |
+
constructor(options?: Partial<RESTOptions>);
|
781 |
+
private setupSweepers;
|
782 |
+
/**
|
783 |
+
* Runs a get request from the api
|
784 |
+
*
|
785 |
+
* @param fullRoute - The full route to query
|
786 |
+
* @param options - Optional request options
|
787 |
+
*/
|
788 |
+
get(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
789 |
+
/**
|
790 |
+
* Runs a delete request from the api
|
791 |
+
*
|
792 |
+
* @param fullRoute - The full route to query
|
793 |
+
* @param options - Optional request options
|
794 |
+
*/
|
795 |
+
delete(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
796 |
+
/**
|
797 |
+
* Runs a post request from the api
|
798 |
+
*
|
799 |
+
* @param fullRoute - The full route to query
|
800 |
+
* @param options - Optional request options
|
801 |
+
*/
|
802 |
+
post(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
803 |
+
/**
|
804 |
+
* Runs a put request from the api
|
805 |
+
*
|
806 |
+
* @param fullRoute - The full route to query
|
807 |
+
* @param options - Optional request options
|
808 |
+
*/
|
809 |
+
put(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
810 |
+
/**
|
811 |
+
* Runs a patch request from the api
|
812 |
+
*
|
813 |
+
* @param fullRoute - The full route to query
|
814 |
+
* @param options - Optional request options
|
815 |
+
*/
|
816 |
+
patch(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
817 |
+
/**
|
818 |
+
* Runs a request from the api
|
819 |
+
*
|
820 |
+
* @param options - Request options
|
821 |
+
*/
|
822 |
+
request(options: InternalRequest): Promise<unknown>;
|
823 |
+
/**
|
824 |
+
* Sets the default agent to use for requests performed by this manager
|
825 |
+
*
|
826 |
+
* @param agent - The agent to use
|
827 |
+
*/
|
828 |
+
setAgent(agent: Dispatcher): this;
|
829 |
+
/**
|
830 |
+
* Sets the authorization token that should be used for requests
|
831 |
+
*
|
832 |
+
* @param token - The authorization token to use
|
833 |
+
*/
|
834 |
+
setToken(token: string): this;
|
835 |
+
/**
|
836 |
+
* Queues a request to be sent
|
837 |
+
*
|
838 |
+
* @param request - All the information needed to make a request
|
839 |
+
* @returns The response from the api request
|
840 |
+
*/
|
841 |
+
queueRequest(request: InternalRequest): Promise<ResponseLike>;
|
842 |
+
/**
|
843 |
+
* Creates a new rate limit handler from a hash, based on the hash and the major parameter
|
844 |
+
*
|
845 |
+
* @param hash - The hash for the route
|
846 |
+
* @param majorParameter - The major parameter for this handler
|
847 |
+
* @internal
|
848 |
+
*/
|
849 |
+
private createHandler;
|
850 |
+
/**
|
851 |
+
* Formats the request data to a usable format for fetch
|
852 |
+
*
|
853 |
+
* @param request - The request data
|
854 |
+
*/
|
855 |
+
private resolveRequest;
|
856 |
+
/**
|
857 |
+
* Stops the hash sweeping interval
|
858 |
+
*/
|
859 |
+
clearHashSweeper(): void;
|
860 |
+
/**
|
861 |
+
* Stops the request handler sweeping interval
|
862 |
+
*/
|
863 |
+
clearHandlerSweeper(): void;
|
864 |
+
/**
|
865 |
+
* Generates route data for an endpoint:method
|
866 |
+
*
|
867 |
+
* @param endpoint - The raw endpoint to generalize
|
868 |
+
* @param method - The HTTP method this endpoint is called without
|
869 |
+
* @internal
|
870 |
+
*/
|
871 |
+
private static generateRouteData;
|
872 |
+
}
|
873 |
+
|
874 |
+
/**
|
875 |
+
* Creates and populates an URLSearchParams instance from an object, stripping
|
876 |
+
* out null and undefined values, while also coercing non-strings to strings.
|
877 |
+
*
|
878 |
+
* @param options - The options to use
|
879 |
+
* @returns A populated URLSearchParams instance
|
880 |
+
*/
|
881 |
+
declare function makeURLSearchParams<OptionsType extends object>(options?: Readonly<OptionsType>): url.URLSearchParams;
|
882 |
+
/**
|
883 |
+
* Converts the response to usable data
|
884 |
+
*
|
885 |
+
* @param res - The fetch response
|
886 |
+
*/
|
887 |
+
declare function parseResponse(res: ResponseLike): Promise<unknown>;
|
888 |
+
/**
|
889 |
+
* Calculates the default avatar index for a given user id.
|
890 |
+
*
|
891 |
+
* @param userId - The user id to calculate the default avatar index for
|
892 |
+
*/
|
893 |
+
declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
|
894 |
+
|
895 |
+
/**
|
896 |
+
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/rest#readme | @discordjs/rest} version
|
897 |
+
* that you are currently using.
|
898 |
+
*/
|
899 |
+
declare const version: string;
|
900 |
+
|
901 |
+
export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, APIRequest, BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, DEPRECATION_WARNING_PREFIX, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, DiscordErrorData, HTTPError, HandlerRequestData, HashData, ImageExtension, ImageSize, ImageURLOptions, InternalRequest, InvalidRequestWarningData, MakeURLOptions, OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, RESTOptions, RateLimitData, RateLimitError, RateLimitQueueFilter, RawFile, RequestBody, RequestData, RequestHeaders, RequestMethod, ResponseLike, RestEvents, RestEventsMap, RouteData, RouteLike, StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
|
node_modules/@discordjs/rest/dist/index.d.ts
ADDED
@@ -0,0 +1,901 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import * as url from 'url';
|
2 |
+
import { Snowflake } from 'discord-api-types/v10';
|
3 |
+
import { Readable } from 'node:stream';
|
4 |
+
import { ReadableStream } from 'node:stream/web';
|
5 |
+
import { Collection } from '@discordjs/collection';
|
6 |
+
import { Awaitable } from '@discordjs/util';
|
7 |
+
import * as undici from 'undici';
|
8 |
+
import { RequestInit, Dispatcher, Response, BodyInit, Agent } from 'undici';
|
9 |
+
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
10 |
+
|
11 |
+
interface IHandler {
|
12 |
+
/**
|
13 |
+
* The unique id of the handler
|
14 |
+
*/
|
15 |
+
readonly id: string;
|
16 |
+
/**
|
17 |
+
* If the bucket is currently inactive (no pending requests)
|
18 |
+
*/
|
19 |
+
get inactive(): boolean;
|
20 |
+
/**
|
21 |
+
* Queues a request to be sent
|
22 |
+
*
|
23 |
+
* @param routeId - The generalized api route with literal ids for major parameters
|
24 |
+
* @param url - The url to do the request on
|
25 |
+
* @param options - All the information needed to make a request
|
26 |
+
* @param requestData - Extra data from the user's request needed for errors and additional processing
|
27 |
+
*/
|
28 |
+
queueRequest(routeId: RouteData, url: string, options: RequestInit, requestData: HandlerRequestData): Promise<ResponseLike>;
|
29 |
+
}
|
30 |
+
|
31 |
+
interface RestEvents {
|
32 |
+
handlerSweep: [sweptHandlers: Collection<string, IHandler>];
|
33 |
+
hashSweep: [sweptHashes: Collection<string, HashData>];
|
34 |
+
invalidRequestWarning: [invalidRequestInfo: InvalidRequestWarningData];
|
35 |
+
rateLimited: [rateLimitInfo: RateLimitData];
|
36 |
+
response: [request: APIRequest, response: ResponseLike];
|
37 |
+
restDebug: [info: string];
|
38 |
+
}
|
39 |
+
type RestEventsMap = {
|
40 |
+
[K in keyof RestEvents]: RestEvents[K];
|
41 |
+
};
|
42 |
+
/**
|
43 |
+
* Options to be passed when creating the REST instance
|
44 |
+
*/
|
45 |
+
interface RESTOptions {
|
46 |
+
/**
|
47 |
+
* The agent to set globally
|
48 |
+
*/
|
49 |
+
agent: Dispatcher | null;
|
50 |
+
/**
|
51 |
+
* The base api path, without version
|
52 |
+
*
|
53 |
+
* @defaultValue `'https://discord.com/api'`
|
54 |
+
*/
|
55 |
+
api: string;
|
56 |
+
/**
|
57 |
+
* The authorization prefix to use for requests, useful if you want to use
|
58 |
+
* bearer tokens
|
59 |
+
*
|
60 |
+
* @defaultValue `'Bot'`
|
61 |
+
*/
|
62 |
+
authPrefix: 'Bearer' | 'Bot';
|
63 |
+
/**
|
64 |
+
* The cdn path
|
65 |
+
*
|
66 |
+
* @defaultValue `'https://cdn.discordapp.com'`
|
67 |
+
*/
|
68 |
+
cdn: string;
|
69 |
+
/**
|
70 |
+
* How many requests to allow sending per second (Infinity for unlimited, 50 for the standard global limit used by Discord)
|
71 |
+
*
|
72 |
+
* @defaultValue `50`
|
73 |
+
*/
|
74 |
+
globalRequestsPerSecond: number;
|
75 |
+
/**
|
76 |
+
* The amount of time in milliseconds that passes between each hash sweep. (defaults to 1h)
|
77 |
+
*
|
78 |
+
* @defaultValue `3_600_000`
|
79 |
+
*/
|
80 |
+
handlerSweepInterval: number;
|
81 |
+
/**
|
82 |
+
* The maximum amount of time a hash can exist in milliseconds without being hit with a request (defaults to 24h)
|
83 |
+
*
|
84 |
+
* @defaultValue `86_400_000`
|
85 |
+
*/
|
86 |
+
hashLifetime: number;
|
87 |
+
/**
|
88 |
+
* The amount of time in milliseconds that passes between each hash sweep. (defaults to 4h)
|
89 |
+
*
|
90 |
+
* @defaultValue `14_400_000`
|
91 |
+
*/
|
92 |
+
hashSweepInterval: number;
|
93 |
+
/**
|
94 |
+
* Additional headers to send for all API requests
|
95 |
+
*
|
96 |
+
* @defaultValue `{}`
|
97 |
+
*/
|
98 |
+
headers: Record<string, string>;
|
99 |
+
/**
|
100 |
+
* The number of invalid REST requests (those that return 401, 403, or 429) in a 10 minute window between emitted warnings (0 for no warnings).
|
101 |
+
* That is, if set to 500, warnings will be emitted at invalid request number 500, 1000, 1500, and so on.
|
102 |
+
*
|
103 |
+
* @defaultValue `0`
|
104 |
+
*/
|
105 |
+
invalidRequestWarningInterval: number;
|
106 |
+
/**
|
107 |
+
* The method called to perform the actual HTTP request given a url and web `fetch` options
|
108 |
+
* For example, to use global fetch, simply provide `makeRequest: fetch`
|
109 |
+
*/
|
110 |
+
makeRequest(url: string, init: RequestInit): Promise<ResponseLike>;
|
111 |
+
/**
|
112 |
+
* The extra offset to add to rate limits in milliseconds
|
113 |
+
*
|
114 |
+
* @defaultValue `50`
|
115 |
+
*/
|
116 |
+
offset: number;
|
117 |
+
/**
|
118 |
+
* Determines how rate limiting and pre-emptive throttling should be handled.
|
119 |
+
* When an array of strings, each element is treated as a prefix for the request route
|
120 |
+
* (e.g. `/channels` to match any route starting with `/channels` such as `/channels/:id/messages`)
|
121 |
+
* for which to throw {@link RateLimitError}s. All other request routes will be queued normally
|
122 |
+
*
|
123 |
+
* @defaultValue `null`
|
124 |
+
*/
|
125 |
+
rejectOnRateLimit: RateLimitQueueFilter | string[] | null;
|
126 |
+
/**
|
127 |
+
* The number of retries for errors with the 500 code, or errors
|
128 |
+
* that timeout
|
129 |
+
*
|
130 |
+
* @defaultValue `3`
|
131 |
+
*/
|
132 |
+
retries: number;
|
133 |
+
/**
|
134 |
+
* The time to wait in milliseconds before a request is aborted
|
135 |
+
*
|
136 |
+
* @defaultValue `15_000`
|
137 |
+
*/
|
138 |
+
timeout: number;
|
139 |
+
/**
|
140 |
+
* Extra information to add to the user agent
|
141 |
+
*
|
142 |
+
* @defaultValue DefaultUserAgentAppendix
|
143 |
+
*/
|
144 |
+
userAgentAppendix: string;
|
145 |
+
/**
|
146 |
+
* The version of the API to use
|
147 |
+
*
|
148 |
+
* @defaultValue `'10'`
|
149 |
+
*/
|
150 |
+
version: string;
|
151 |
+
}
|
152 |
+
/**
|
153 |
+
* Data emitted on `RESTEvents.RateLimited`
|
154 |
+
*/
|
155 |
+
interface RateLimitData {
|
156 |
+
/**
|
157 |
+
* Whether the rate limit that was reached was the global limit
|
158 |
+
*/
|
159 |
+
global: boolean;
|
160 |
+
/**
|
161 |
+
* The bucket hash for this request
|
162 |
+
*/
|
163 |
+
hash: string;
|
164 |
+
/**
|
165 |
+
* The amount of requests we can perform before locking requests
|
166 |
+
*/
|
167 |
+
limit: number;
|
168 |
+
/**
|
169 |
+
* The major parameter of the route
|
170 |
+
*
|
171 |
+
* For example, in `/channels/x`, this will be `x`.
|
172 |
+
* If there is no major parameter (e.g: `/bot/gateway`) this will be `global`.
|
173 |
+
*/
|
174 |
+
majorParameter: string;
|
175 |
+
/**
|
176 |
+
* The HTTP method being performed
|
177 |
+
*/
|
178 |
+
method: string;
|
179 |
+
/**
|
180 |
+
* The time, in milliseconds, that will need to pass before this specific request can be retried
|
181 |
+
*/
|
182 |
+
retryAfter: number;
|
183 |
+
/**
|
184 |
+
* The route being hit in this request
|
185 |
+
*/
|
186 |
+
route: string;
|
187 |
+
/**
|
188 |
+
* The scope of the rate limit that was hit.
|
189 |
+
*
|
190 |
+
* This can be `user` for rate limits that are per client, `global` for rate limits that affect all clients or `shared` for rate limits that
|
191 |
+
* are shared per resource.
|
192 |
+
*/
|
193 |
+
scope: 'global' | 'shared' | 'user';
|
194 |
+
/**
|
195 |
+
* The time, in milliseconds, that will need to pass before the sublimit lock for the route resets, and requests that fall under a sublimit
|
196 |
+
* can be retried
|
197 |
+
*
|
198 |
+
* This is only present on certain sublimits, and `0` otherwise
|
199 |
+
*/
|
200 |
+
sublimitTimeout: number;
|
201 |
+
/**
|
202 |
+
* The time, in milliseconds, until the route's request-lock is reset
|
203 |
+
*/
|
204 |
+
timeToReset: number;
|
205 |
+
/**
|
206 |
+
* The full URL for this request
|
207 |
+
*/
|
208 |
+
url: string;
|
209 |
+
}
|
210 |
+
/**
|
211 |
+
* A function that determines whether the rate limit hit should throw an Error
|
212 |
+
*/
|
213 |
+
type RateLimitQueueFilter = (rateLimitData: RateLimitData) => Awaitable<boolean>;
|
214 |
+
interface APIRequest {
|
215 |
+
/**
|
216 |
+
* The data that was used to form the body of this request
|
217 |
+
*/
|
218 |
+
data: HandlerRequestData;
|
219 |
+
/**
|
220 |
+
* The HTTP method used in this request
|
221 |
+
*/
|
222 |
+
method: string;
|
223 |
+
/**
|
224 |
+
* Additional HTTP options for this request
|
225 |
+
*/
|
226 |
+
options: RequestInit;
|
227 |
+
/**
|
228 |
+
* The full path used to make the request
|
229 |
+
*/
|
230 |
+
path: RouteLike;
|
231 |
+
/**
|
232 |
+
* The number of times this request has been attempted
|
233 |
+
*/
|
234 |
+
retries: number;
|
235 |
+
/**
|
236 |
+
* The API route identifying the ratelimit for this request
|
237 |
+
*/
|
238 |
+
route: string;
|
239 |
+
}
|
240 |
+
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | 'headers' | 'json' | 'ok' | 'status' | 'statusText' | 'text'> {
|
241 |
+
body: Readable | ReadableStream | null;
|
242 |
+
}
|
243 |
+
interface InvalidRequestWarningData {
|
244 |
+
/**
|
245 |
+
* Number of invalid requests that have been made in the window
|
246 |
+
*/
|
247 |
+
count: number;
|
248 |
+
/**
|
249 |
+
* Time in milliseconds remaining before the count resets
|
250 |
+
*/
|
251 |
+
remainingTime: number;
|
252 |
+
}
|
253 |
+
/**
|
254 |
+
* Represents a file to be added to the request
|
255 |
+
*/
|
256 |
+
interface RawFile {
|
257 |
+
/**
|
258 |
+
* Content-Type of the file
|
259 |
+
*/
|
260 |
+
contentType?: string;
|
261 |
+
/**
|
262 |
+
* The actual data for the file
|
263 |
+
*/
|
264 |
+
data: Buffer | Uint8Array | boolean | number | string;
|
265 |
+
/**
|
266 |
+
* An explicit key to use for key of the formdata field for this file.
|
267 |
+
* When not provided, the index of the file in the files array is used in the form `files[${index}]`.
|
268 |
+
* If you wish to alter the placeholder snowflake, you must provide this property in the same form (`files[${placeholder}]`)
|
269 |
+
*/
|
270 |
+
key?: string;
|
271 |
+
/**
|
272 |
+
* The name of the file
|
273 |
+
*/
|
274 |
+
name: string;
|
275 |
+
}
|
276 |
+
/**
|
277 |
+
* Represents possible data to be given to an endpoint
|
278 |
+
*/
|
279 |
+
interface RequestData {
|
280 |
+
/**
|
281 |
+
* Whether to append JSON data to form data instead of `payload_json` when sending files
|
282 |
+
*/
|
283 |
+
appendToFormData?: boolean;
|
284 |
+
/**
|
285 |
+
* If this request needs the `Authorization` header
|
286 |
+
*
|
287 |
+
* @defaultValue `true`
|
288 |
+
*/
|
289 |
+
auth?: boolean;
|
290 |
+
/**
|
291 |
+
* The authorization prefix to use for this request, useful if you use this with bearer tokens
|
292 |
+
*
|
293 |
+
* @defaultValue `'Bot'`
|
294 |
+
*/
|
295 |
+
authPrefix?: 'Bearer' | 'Bot';
|
296 |
+
/**
|
297 |
+
* The body to send to this request.
|
298 |
+
* If providing as BodyInit, set `passThroughBody: true`
|
299 |
+
*/
|
300 |
+
body?: BodyInit | unknown;
|
301 |
+
/**
|
302 |
+
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} to use for the request.
|
303 |
+
*/
|
304 |
+
dispatcher?: Agent;
|
305 |
+
/**
|
306 |
+
* Files to be attached to this request
|
307 |
+
*/
|
308 |
+
files?: RawFile[] | undefined;
|
309 |
+
/**
|
310 |
+
* Additional headers to add to this request
|
311 |
+
*/
|
312 |
+
headers?: Record<string, string>;
|
313 |
+
/**
|
314 |
+
* Whether to pass-through the body property directly to `fetch()`.
|
315 |
+
* <warn>This only applies when files is NOT present</warn>
|
316 |
+
*/
|
317 |
+
passThroughBody?: boolean;
|
318 |
+
/**
|
319 |
+
* Query string parameters to append to the called endpoint
|
320 |
+
*/
|
321 |
+
query?: URLSearchParams;
|
322 |
+
/**
|
323 |
+
* Reason to show in the audit logs
|
324 |
+
*/
|
325 |
+
reason?: string | undefined;
|
326 |
+
/**
|
327 |
+
* The signal to abort the queue entry or the REST call, where applicable
|
328 |
+
*/
|
329 |
+
signal?: AbortSignal | undefined;
|
330 |
+
/**
|
331 |
+
* If this request should be versioned
|
332 |
+
*
|
333 |
+
* @defaultValue `true`
|
334 |
+
*/
|
335 |
+
versioned?: boolean;
|
336 |
+
}
|
337 |
+
/**
|
338 |
+
* Possible headers for an API call
|
339 |
+
*/
|
340 |
+
interface RequestHeaders {
|
341 |
+
Authorization?: string;
|
342 |
+
'User-Agent': string;
|
343 |
+
'X-Audit-Log-Reason'?: string;
|
344 |
+
}
|
345 |
+
/**
|
346 |
+
* Possible API methods to be used when doing requests
|
347 |
+
*/
|
348 |
+
declare enum RequestMethod {
|
349 |
+
Delete = "DELETE",
|
350 |
+
Get = "GET",
|
351 |
+
Patch = "PATCH",
|
352 |
+
Post = "POST",
|
353 |
+
Put = "PUT"
|
354 |
+
}
|
355 |
+
type RouteLike = `/${string}`;
|
356 |
+
/**
|
357 |
+
* Internal request options
|
358 |
+
*
|
359 |
+
* @internal
|
360 |
+
*/
|
361 |
+
interface InternalRequest extends RequestData {
|
362 |
+
fullRoute: RouteLike;
|
363 |
+
method: RequestMethod;
|
364 |
+
}
|
365 |
+
type HandlerRequestData = Pick<InternalRequest, 'auth' | 'body' | 'files' | 'signal'>;
|
366 |
+
/**
|
367 |
+
* Parsed route data for an endpoint
|
368 |
+
*
|
369 |
+
* @internal
|
370 |
+
*/
|
371 |
+
interface RouteData {
|
372 |
+
bucketRoute: string;
|
373 |
+
majorParameter: string;
|
374 |
+
original: RouteLike;
|
375 |
+
}
|
376 |
+
/**
|
377 |
+
* Represents a hash and its associated fields
|
378 |
+
*
|
379 |
+
* @internal
|
380 |
+
*/
|
381 |
+
interface HashData {
|
382 |
+
lastAccess: number;
|
383 |
+
value: string;
|
384 |
+
}
|
385 |
+
|
386 |
+
declare const DefaultUserAgent: `DiscordBot (https://discord.js.org, ${string})`;
|
387 |
+
/**
|
388 |
+
* The default string to append onto the user agent.
|
389 |
+
*/
|
390 |
+
declare const DefaultUserAgentAppendix: string;
|
391 |
+
declare const DefaultRestOptions: {
|
392 |
+
readonly agent: null;
|
393 |
+
readonly api: "https://discord.com/api";
|
394 |
+
readonly authPrefix: "Bot";
|
395 |
+
readonly cdn: "https://cdn.discordapp.com";
|
396 |
+
readonly headers: {};
|
397 |
+
readonly invalidRequestWarningInterval: 0;
|
398 |
+
readonly globalRequestsPerSecond: 50;
|
399 |
+
readonly offset: 50;
|
400 |
+
readonly rejectOnRateLimit: null;
|
401 |
+
readonly retries: 3;
|
402 |
+
readonly timeout: 15000;
|
403 |
+
readonly userAgentAppendix: string;
|
404 |
+
readonly version: "10";
|
405 |
+
readonly hashSweepInterval: 14400000;
|
406 |
+
readonly hashLifetime: 86400000;
|
407 |
+
readonly handlerSweepInterval: 3600000;
|
408 |
+
readonly makeRequest: (url: string, init: undici.RequestInit) => Promise<ResponseLike>;
|
409 |
+
};
|
410 |
+
/**
|
411 |
+
* The events that the REST manager emits
|
412 |
+
*/
|
413 |
+
declare enum RESTEvents {
|
414 |
+
Debug = "restDebug",
|
415 |
+
HandlerSweep = "handlerSweep",
|
416 |
+
HashSweep = "hashSweep",
|
417 |
+
InvalidRequestWarning = "invalidRequestWarning",
|
418 |
+
RateLimited = "rateLimited",
|
419 |
+
Response = "response"
|
420 |
+
}
|
421 |
+
declare const ALLOWED_EXTENSIONS: readonly ["webp", "png", "jpg", "jpeg", "gif"];
|
422 |
+
declare const ALLOWED_STICKER_EXTENSIONS: readonly ["png", "json", "gif"];
|
423 |
+
declare const ALLOWED_SIZES: readonly [16, 32, 64, 128, 256, 512, 1024, 2048, 4096];
|
424 |
+
type ImageExtension = (typeof ALLOWED_EXTENSIONS)[number];
|
425 |
+
type StickerExtension = (typeof ALLOWED_STICKER_EXTENSIONS)[number];
|
426 |
+
type ImageSize = (typeof ALLOWED_SIZES)[number];
|
427 |
+
declare const OverwrittenMimeTypes: {
|
428 |
+
readonly 'image/apng': "image/png";
|
429 |
+
};
|
430 |
+
declare const BurstHandlerMajorIdKey = "burst";
|
431 |
+
/**
|
432 |
+
* Prefix for deprecation warnings.
|
433 |
+
*
|
434 |
+
* @internal
|
435 |
+
*/
|
436 |
+
declare const DEPRECATION_WARNING_PREFIX: "DeprecationWarning";
|
437 |
+
|
438 |
+
/**
|
439 |
+
* The options used for image URLs
|
440 |
+
*/
|
441 |
+
interface BaseImageURLOptions {
|
442 |
+
/**
|
443 |
+
* The extension to use for the image URL
|
444 |
+
*
|
445 |
+
* @defaultValue `'webp'`
|
446 |
+
*/
|
447 |
+
extension?: ImageExtension;
|
448 |
+
/**
|
449 |
+
* The size specified in the image URL
|
450 |
+
*/
|
451 |
+
size?: ImageSize;
|
452 |
+
}
|
453 |
+
/**
|
454 |
+
* The options used for image URLs with animated content
|
455 |
+
*/
|
456 |
+
interface ImageURLOptions extends BaseImageURLOptions {
|
457 |
+
/**
|
458 |
+
* Whether or not to prefer the static version of an image asset.
|
459 |
+
*/
|
460 |
+
forceStatic?: boolean;
|
461 |
+
}
|
462 |
+
/**
|
463 |
+
* The options to use when making a CDN URL
|
464 |
+
*/
|
465 |
+
interface MakeURLOptions {
|
466 |
+
/**
|
467 |
+
* The allowed extensions that can be used
|
468 |
+
*/
|
469 |
+
allowedExtensions?: readonly string[];
|
470 |
+
/**
|
471 |
+
* The extension to use for the image URL
|
472 |
+
*
|
473 |
+
* @defaultValue `'webp'`
|
474 |
+
*/
|
475 |
+
extension?: string | undefined;
|
476 |
+
/**
|
477 |
+
* The size specified in the image URL
|
478 |
+
*/
|
479 |
+
size?: ImageSize;
|
480 |
+
}
|
481 |
+
/**
|
482 |
+
* The CDN link builder
|
483 |
+
*/
|
484 |
+
declare class CDN {
|
485 |
+
private readonly base;
|
486 |
+
constructor(base?: string);
|
487 |
+
/**
|
488 |
+
* Generates an app asset URL for a client's asset.
|
489 |
+
*
|
490 |
+
* @param clientId - The client id that has the asset
|
491 |
+
* @param assetHash - The hash provided by Discord for this asset
|
492 |
+
* @param options - Optional options for the asset
|
493 |
+
*/
|
494 |
+
appAsset(clientId: string, assetHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
495 |
+
/**
|
496 |
+
* Generates an app icon URL for a client's icon.
|
497 |
+
*
|
498 |
+
* @param clientId - The client id that has the icon
|
499 |
+
* @param iconHash - The hash provided by Discord for this icon
|
500 |
+
* @param options - Optional options for the icon
|
501 |
+
*/
|
502 |
+
appIcon(clientId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
503 |
+
/**
|
504 |
+
* Generates an avatar URL, e.g. for a user or a webhook.
|
505 |
+
*
|
506 |
+
* @param id - The id that has the icon
|
507 |
+
* @param avatarHash - The hash provided by Discord for this avatar
|
508 |
+
* @param options - Optional options for the avatar
|
509 |
+
*/
|
510 |
+
avatar(id: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
511 |
+
/**
|
512 |
+
* Generates a user avatar decoration URL.
|
513 |
+
*
|
514 |
+
* @param userId - The id of the user
|
515 |
+
* @param userAvatarDecoration - The hash provided by Discord for this avatar decoration
|
516 |
+
* @param options - Optional options for the avatar decoration
|
517 |
+
*/
|
518 |
+
avatarDecoration(userId: string, userAvatarDecoration: string, options?: Readonly<BaseImageURLOptions>): string;
|
519 |
+
/**
|
520 |
+
* Generates a banner URL, e.g. for a user or a guild.
|
521 |
+
*
|
522 |
+
* @param id - The id that has the banner splash
|
523 |
+
* @param bannerHash - The hash provided by Discord for this banner
|
524 |
+
* @param options - Optional options for the banner
|
525 |
+
*/
|
526 |
+
banner(id: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
527 |
+
/**
|
528 |
+
* Generates an icon URL for a channel, e.g. a group DM.
|
529 |
+
*
|
530 |
+
* @param channelId - The channel id that has the icon
|
531 |
+
* @param iconHash - The hash provided by Discord for this channel
|
532 |
+
* @param options - Optional options for the icon
|
533 |
+
*/
|
534 |
+
channelIcon(channelId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
535 |
+
/**
|
536 |
+
* Generates a default avatar URL
|
537 |
+
*
|
538 |
+
* @param index - The default avatar index
|
539 |
+
* @remarks
|
540 |
+
* To calculate the index for a user do `(userId >> 22) % 6`,
|
541 |
+
* or `discriminator % 5` if they're using the legacy username system.
|
542 |
+
*/
|
543 |
+
defaultAvatar(index: number): string;
|
544 |
+
/**
|
545 |
+
* Generates a discovery splash URL for a guild's discovery splash.
|
546 |
+
*
|
547 |
+
* @param guildId - The guild id that has the discovery splash
|
548 |
+
* @param splashHash - The hash provided by Discord for this splash
|
549 |
+
* @param options - Optional options for the splash
|
550 |
+
*/
|
551 |
+
discoverySplash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
552 |
+
/**
|
553 |
+
* Generates an emoji's URL for an emoji.
|
554 |
+
*
|
555 |
+
* @param emojiId - The emoji id
|
556 |
+
* @param options - Optional options for the emoji
|
557 |
+
*/
|
558 |
+
emoji(emojiId: string, options?: Readonly<BaseImageURLOptions>): string;
|
559 |
+
/**
|
560 |
+
* Generates an emoji's URL for an emoji.
|
561 |
+
*
|
562 |
+
* @param emojiId - The emoji id
|
563 |
+
* @param extension - The extension of the emoji
|
564 |
+
* @deprecated This overload is deprecated. Pass an object containing the extension instead.
|
565 |
+
*/
|
566 |
+
emoji(emojiId: string, extension?: ImageExtension): string;
|
567 |
+
/**
|
568 |
+
* Generates a guild member avatar URL.
|
569 |
+
*
|
570 |
+
* @param guildId - The id of the guild
|
571 |
+
* @param userId - The id of the user
|
572 |
+
* @param avatarHash - The hash provided by Discord for this avatar
|
573 |
+
* @param options - Optional options for the avatar
|
574 |
+
*/
|
575 |
+
guildMemberAvatar(guildId: string, userId: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
576 |
+
/**
|
577 |
+
* Generates a guild member banner URL.
|
578 |
+
*
|
579 |
+
* @param guildId - The id of the guild
|
580 |
+
* @param userId - The id of the user
|
581 |
+
* @param bannerHash - The hash provided by Discord for this banner
|
582 |
+
* @param options - Optional options for the banner
|
583 |
+
*/
|
584 |
+
guildMemberBanner(guildId: string, userId: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
585 |
+
/**
|
586 |
+
* Generates an icon URL, e.g. for a guild.
|
587 |
+
*
|
588 |
+
* @param id - The id that has the icon splash
|
589 |
+
* @param iconHash - The hash provided by Discord for this icon
|
590 |
+
* @param options - Optional options for the icon
|
591 |
+
*/
|
592 |
+
icon(id: string, iconHash: string, options?: Readonly<ImageURLOptions>): string;
|
593 |
+
/**
|
594 |
+
* Generates a URL for the icon of a role
|
595 |
+
*
|
596 |
+
* @param roleId - The id of the role that has the icon
|
597 |
+
* @param roleIconHash - The hash provided by Discord for this role icon
|
598 |
+
* @param options - Optional options for the role icon
|
599 |
+
*/
|
600 |
+
roleIcon(roleId: string, roleIconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
601 |
+
/**
|
602 |
+
* Generates a guild invite splash URL for a guild's invite splash.
|
603 |
+
*
|
604 |
+
* @param guildId - The guild id that has the invite splash
|
605 |
+
* @param splashHash - The hash provided by Discord for this splash
|
606 |
+
* @param options - Optional options for the splash
|
607 |
+
*/
|
608 |
+
splash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
609 |
+
/**
|
610 |
+
* Generates a sticker URL.
|
611 |
+
*
|
612 |
+
* @param stickerId - The sticker id
|
613 |
+
* @param extension - The extension of the sticker
|
614 |
+
* @privateRemarks
|
615 |
+
* Stickers cannot have a `.webp` extension, so we default to a `.png`
|
616 |
+
*/
|
617 |
+
sticker(stickerId: string, extension?: StickerExtension): string;
|
618 |
+
/**
|
619 |
+
* Generates a sticker pack banner URL.
|
620 |
+
*
|
621 |
+
* @param bannerId - The banner id
|
622 |
+
* @param options - Optional options for the banner
|
623 |
+
*/
|
624 |
+
stickerPackBanner(bannerId: string, options?: Readonly<BaseImageURLOptions>): string;
|
625 |
+
/**
|
626 |
+
* Generates a team icon URL for a team's icon.
|
627 |
+
*
|
628 |
+
* @param teamId - The team id that has the icon
|
629 |
+
* @param iconHash - The hash provided by Discord for this icon
|
630 |
+
* @param options - Optional options for the icon
|
631 |
+
*/
|
632 |
+
teamIcon(teamId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
633 |
+
/**
|
634 |
+
* Generates a cover image for a guild scheduled event.
|
635 |
+
*
|
636 |
+
* @param scheduledEventId - The scheduled event id
|
637 |
+
* @param coverHash - The hash provided by discord for this cover image
|
638 |
+
* @param options - Optional options for the cover image
|
639 |
+
*/
|
640 |
+
guildScheduledEventCover(scheduledEventId: string, coverHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
641 |
+
/**
|
642 |
+
* Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
|
643 |
+
*
|
644 |
+
* @param route - The base cdn route
|
645 |
+
* @param hash - The hash provided by Discord for this icon
|
646 |
+
* @param options - Optional options for the link
|
647 |
+
*/
|
648 |
+
private dynamicMakeURL;
|
649 |
+
/**
|
650 |
+
* Constructs the URL for the resource
|
651 |
+
*
|
652 |
+
* @param route - The base cdn route
|
653 |
+
* @param options - The extension/size options for the link
|
654 |
+
*/
|
655 |
+
private makeURL;
|
656 |
+
}
|
657 |
+
|
658 |
+
interface DiscordErrorFieldInformation {
|
659 |
+
code: string;
|
660 |
+
message: string;
|
661 |
+
}
|
662 |
+
interface DiscordErrorGroupWrapper {
|
663 |
+
_errors: DiscordError[];
|
664 |
+
}
|
665 |
+
type DiscordError = DiscordErrorFieldInformation | DiscordErrorGroupWrapper | string | {
|
666 |
+
[k: string]: DiscordError;
|
667 |
+
};
|
668 |
+
interface DiscordErrorData {
|
669 |
+
code: number;
|
670 |
+
errors?: DiscordError;
|
671 |
+
message: string;
|
672 |
+
}
|
673 |
+
interface OAuthErrorData {
|
674 |
+
error: string;
|
675 |
+
error_description?: string;
|
676 |
+
}
|
677 |
+
interface RequestBody {
|
678 |
+
files: RawFile[] | undefined;
|
679 |
+
json: unknown | undefined;
|
680 |
+
}
|
681 |
+
/**
|
682 |
+
* Represents an API error returned by Discord
|
683 |
+
*/
|
684 |
+
declare class DiscordAPIError extends Error {
|
685 |
+
rawError: DiscordErrorData | OAuthErrorData;
|
686 |
+
code: number | string;
|
687 |
+
status: number;
|
688 |
+
method: string;
|
689 |
+
url: string;
|
690 |
+
requestBody: RequestBody;
|
691 |
+
/**
|
692 |
+
* @param rawError - The error reported by Discord
|
693 |
+
* @param code - The error code reported by Discord
|
694 |
+
* @param status - The status code of the response
|
695 |
+
* @param method - The method of the request that erred
|
696 |
+
* @param url - The url of the request that erred
|
697 |
+
* @param bodyData - The unparsed data for the request that errored
|
698 |
+
*/
|
699 |
+
constructor(rawError: DiscordErrorData | OAuthErrorData, code: number | string, status: number, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
|
700 |
+
/**
|
701 |
+
* The name of the error
|
702 |
+
*/
|
703 |
+
get name(): string;
|
704 |
+
private static getMessage;
|
705 |
+
private static flattenDiscordError;
|
706 |
+
}
|
707 |
+
|
708 |
+
/**
|
709 |
+
* Represents a HTTP error
|
710 |
+
*/
|
711 |
+
declare class HTTPError extends Error {
|
712 |
+
status: number;
|
713 |
+
method: string;
|
714 |
+
url: string;
|
715 |
+
requestBody: RequestBody;
|
716 |
+
name: string;
|
717 |
+
/**
|
718 |
+
* @param status - The status code of the response
|
719 |
+
* @param statusText - The status text of the response
|
720 |
+
* @param method - The method of the request that erred
|
721 |
+
* @param url - The url of the request that erred
|
722 |
+
* @param bodyData - The unparsed data for the request that errored
|
723 |
+
*/
|
724 |
+
constructor(status: number, statusText: string, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
|
725 |
+
}
|
726 |
+
|
727 |
+
declare class RateLimitError extends Error implements RateLimitData {
|
728 |
+
timeToReset: number;
|
729 |
+
limit: number;
|
730 |
+
method: string;
|
731 |
+
hash: string;
|
732 |
+
url: string;
|
733 |
+
route: string;
|
734 |
+
majorParameter: string;
|
735 |
+
global: boolean;
|
736 |
+
retryAfter: number;
|
737 |
+
sublimitTimeout: number;
|
738 |
+
scope: RateLimitData['scope'];
|
739 |
+
constructor({ timeToReset, limit, method, hash, url, route, majorParameter, global, retryAfter, sublimitTimeout, scope, }: RateLimitData);
|
740 |
+
/**
|
741 |
+
* The name of the error
|
742 |
+
*/
|
743 |
+
get name(): string;
|
744 |
+
}
|
745 |
+
|
746 |
+
/**
|
747 |
+
* Represents the class that manages handlers for endpoints
|
748 |
+
*/
|
749 |
+
declare class REST extends AsyncEventEmitter<RestEventsMap> {
|
750 |
+
#private;
|
751 |
+
/**
|
752 |
+
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} for all requests
|
753 |
+
* performed by this manager.
|
754 |
+
*/
|
755 |
+
agent: Dispatcher | null;
|
756 |
+
readonly cdn: CDN;
|
757 |
+
/**
|
758 |
+
* The number of requests remaining in the global bucket
|
759 |
+
*/
|
760 |
+
globalRemaining: number;
|
761 |
+
/**
|
762 |
+
* The promise used to wait out the global rate limit
|
763 |
+
*/
|
764 |
+
globalDelay: Promise<void> | null;
|
765 |
+
/**
|
766 |
+
* The timestamp at which the global bucket resets
|
767 |
+
*/
|
768 |
+
globalReset: number;
|
769 |
+
/**
|
770 |
+
* API bucket hashes that are cached from provided routes
|
771 |
+
*/
|
772 |
+
readonly hashes: Collection<string, HashData>;
|
773 |
+
/**
|
774 |
+
* Request handlers created from the bucket hash and the major parameters
|
775 |
+
*/
|
776 |
+
readonly handlers: Collection<string, IHandler>;
|
777 |
+
private hashTimer;
|
778 |
+
private handlerTimer;
|
779 |
+
readonly options: RESTOptions;
|
780 |
+
constructor(options?: Partial<RESTOptions>);
|
781 |
+
private setupSweepers;
|
782 |
+
/**
|
783 |
+
* Runs a get request from the api
|
784 |
+
*
|
785 |
+
* @param fullRoute - The full route to query
|
786 |
+
* @param options - Optional request options
|
787 |
+
*/
|
788 |
+
get(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
789 |
+
/**
|
790 |
+
* Runs a delete request from the api
|
791 |
+
*
|
792 |
+
* @param fullRoute - The full route to query
|
793 |
+
* @param options - Optional request options
|
794 |
+
*/
|
795 |
+
delete(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
796 |
+
/**
|
797 |
+
* Runs a post request from the api
|
798 |
+
*
|
799 |
+
* @param fullRoute - The full route to query
|
800 |
+
* @param options - Optional request options
|
801 |
+
*/
|
802 |
+
post(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
803 |
+
/**
|
804 |
+
* Runs a put request from the api
|
805 |
+
*
|
806 |
+
* @param fullRoute - The full route to query
|
807 |
+
* @param options - Optional request options
|
808 |
+
*/
|
809 |
+
put(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
810 |
+
/**
|
811 |
+
* Runs a patch request from the api
|
812 |
+
*
|
813 |
+
* @param fullRoute - The full route to query
|
814 |
+
* @param options - Optional request options
|
815 |
+
*/
|
816 |
+
patch(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
817 |
+
/**
|
818 |
+
* Runs a request from the api
|
819 |
+
*
|
820 |
+
* @param options - Request options
|
821 |
+
*/
|
822 |
+
request(options: InternalRequest): Promise<unknown>;
|
823 |
+
/**
|
824 |
+
* Sets the default agent to use for requests performed by this manager
|
825 |
+
*
|
826 |
+
* @param agent - The agent to use
|
827 |
+
*/
|
828 |
+
setAgent(agent: Dispatcher): this;
|
829 |
+
/**
|
830 |
+
* Sets the authorization token that should be used for requests
|
831 |
+
*
|
832 |
+
* @param token - The authorization token to use
|
833 |
+
*/
|
834 |
+
setToken(token: string): this;
|
835 |
+
/**
|
836 |
+
* Queues a request to be sent
|
837 |
+
*
|
838 |
+
* @param request - All the information needed to make a request
|
839 |
+
* @returns The response from the api request
|
840 |
+
*/
|
841 |
+
queueRequest(request: InternalRequest): Promise<ResponseLike>;
|
842 |
+
/**
|
843 |
+
* Creates a new rate limit handler from a hash, based on the hash and the major parameter
|
844 |
+
*
|
845 |
+
* @param hash - The hash for the route
|
846 |
+
* @param majorParameter - The major parameter for this handler
|
847 |
+
* @internal
|
848 |
+
*/
|
849 |
+
private createHandler;
|
850 |
+
/**
|
851 |
+
* Formats the request data to a usable format for fetch
|
852 |
+
*
|
853 |
+
* @param request - The request data
|
854 |
+
*/
|
855 |
+
private resolveRequest;
|
856 |
+
/**
|
857 |
+
* Stops the hash sweeping interval
|
858 |
+
*/
|
859 |
+
clearHashSweeper(): void;
|
860 |
+
/**
|
861 |
+
* Stops the request handler sweeping interval
|
862 |
+
*/
|
863 |
+
clearHandlerSweeper(): void;
|
864 |
+
/**
|
865 |
+
* Generates route data for an endpoint:method
|
866 |
+
*
|
867 |
+
* @param endpoint - The raw endpoint to generalize
|
868 |
+
* @param method - The HTTP method this endpoint is called without
|
869 |
+
* @internal
|
870 |
+
*/
|
871 |
+
private static generateRouteData;
|
872 |
+
}
|
873 |
+
|
874 |
+
/**
|
875 |
+
* Creates and populates an URLSearchParams instance from an object, stripping
|
876 |
+
* out null and undefined values, while also coercing non-strings to strings.
|
877 |
+
*
|
878 |
+
* @param options - The options to use
|
879 |
+
* @returns A populated URLSearchParams instance
|
880 |
+
*/
|
881 |
+
declare function makeURLSearchParams<OptionsType extends object>(options?: Readonly<OptionsType>): url.URLSearchParams;
|
882 |
+
/**
|
883 |
+
* Converts the response to usable data
|
884 |
+
*
|
885 |
+
* @param res - The fetch response
|
886 |
+
*/
|
887 |
+
declare function parseResponse(res: ResponseLike): Promise<unknown>;
|
888 |
+
/**
|
889 |
+
* Calculates the default avatar index for a given user id.
|
890 |
+
*
|
891 |
+
* @param userId - The user id to calculate the default avatar index for
|
892 |
+
*/
|
893 |
+
declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
|
894 |
+
|
895 |
+
/**
|
896 |
+
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/rest#readme | @discordjs/rest} version
|
897 |
+
* that you are currently using.
|
898 |
+
*/
|
899 |
+
declare const version: string;
|
900 |
+
|
901 |
+
export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, APIRequest, BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, DEPRECATION_WARNING_PREFIX, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, DiscordErrorData, HTTPError, HandlerRequestData, HashData, ImageExtension, ImageSize, ImageURLOptions, InternalRequest, InvalidRequestWarningData, MakeURLOptions, OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, RESTOptions, RateLimitData, RateLimitError, RateLimitQueueFilter, RawFile, RequestBody, RequestData, RequestHeaders, RequestMethod, ResponseLike, RestEvents, RestEventsMap, RouteData, RouteLike, StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
|
node_modules/@discordjs/rest/dist/index.js
ADDED
@@ -0,0 +1,1474 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
var __defProp = Object.defineProperty;
|
3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6 |
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
7 |
+
var __export = (target, all) => {
|
8 |
+
for (var name in all)
|
9 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
10 |
+
};
|
11 |
+
var __copyProps = (to, from, except, desc) => {
|
12 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
13 |
+
for (let key of __getOwnPropNames(from))
|
14 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16 |
+
}
|
17 |
+
return to;
|
18 |
+
};
|
19 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
20 |
+
|
21 |
+
// src/index.ts
|
22 |
+
var src_exports = {};
|
23 |
+
__export(src_exports, {
|
24 |
+
ALLOWED_EXTENSIONS: () => ALLOWED_EXTENSIONS,
|
25 |
+
ALLOWED_SIZES: () => ALLOWED_SIZES,
|
26 |
+
ALLOWED_STICKER_EXTENSIONS: () => ALLOWED_STICKER_EXTENSIONS,
|
27 |
+
BurstHandlerMajorIdKey: () => BurstHandlerMajorIdKey,
|
28 |
+
CDN: () => CDN,
|
29 |
+
DEPRECATION_WARNING_PREFIX: () => DEPRECATION_WARNING_PREFIX,
|
30 |
+
DefaultRestOptions: () => DefaultRestOptions,
|
31 |
+
DefaultUserAgent: () => DefaultUserAgent,
|
32 |
+
DefaultUserAgentAppendix: () => DefaultUserAgentAppendix,
|
33 |
+
DiscordAPIError: () => DiscordAPIError,
|
34 |
+
HTTPError: () => HTTPError,
|
35 |
+
OverwrittenMimeTypes: () => OverwrittenMimeTypes,
|
36 |
+
REST: () => REST,
|
37 |
+
RESTEvents: () => RESTEvents,
|
38 |
+
RateLimitError: () => RateLimitError,
|
39 |
+
RequestMethod: () => RequestMethod,
|
40 |
+
calculateUserDefaultAvatarIndex: () => calculateUserDefaultAvatarIndex,
|
41 |
+
makeURLSearchParams: () => makeURLSearchParams,
|
42 |
+
parseResponse: () => parseResponse,
|
43 |
+
version: () => version
|
44 |
+
});
|
45 |
+
module.exports = __toCommonJS(src_exports);
|
46 |
+
var import_node_buffer = require("buffer");
|
47 |
+
var import_util2 = require("@discordjs/util");
|
48 |
+
var import_undici2 = require("undici");
|
49 |
+
|
50 |
+
// src/environment.ts
|
51 |
+
var defaultStrategy;
|
52 |
+
function setDefaultStrategy(newStrategy) {
|
53 |
+
defaultStrategy = newStrategy;
|
54 |
+
}
|
55 |
+
__name(setDefaultStrategy, "setDefaultStrategy");
|
56 |
+
function getDefaultStrategy() {
|
57 |
+
return defaultStrategy;
|
58 |
+
}
|
59 |
+
__name(getDefaultStrategy, "getDefaultStrategy");
|
60 |
+
|
61 |
+
// src/strategies/undiciRequest.ts
|
62 |
+
var import_node_http = require("http");
|
63 |
+
var import_node_url = require("url");
|
64 |
+
var import_node_util = require("util");
|
65 |
+
var import_undici = require("undici");
|
66 |
+
async function makeRequest(url, init) {
|
67 |
+
const options = {
|
68 |
+
...init,
|
69 |
+
body: await resolveBody(init.body)
|
70 |
+
};
|
71 |
+
const res = await (0, import_undici.request)(url, options);
|
72 |
+
return {
|
73 |
+
body: res.body,
|
74 |
+
async arrayBuffer() {
|
75 |
+
return res.body.arrayBuffer();
|
76 |
+
},
|
77 |
+
async json() {
|
78 |
+
return res.body.json();
|
79 |
+
},
|
80 |
+
async text() {
|
81 |
+
return res.body.text();
|
82 |
+
},
|
83 |
+
get bodyUsed() {
|
84 |
+
return res.body.bodyUsed;
|
85 |
+
},
|
86 |
+
headers: new import_undici.Headers(res.headers),
|
87 |
+
status: res.statusCode,
|
88 |
+
statusText: import_node_http.STATUS_CODES[res.statusCode],
|
89 |
+
ok: res.statusCode >= 200 && res.statusCode < 300
|
90 |
+
};
|
91 |
+
}
|
92 |
+
__name(makeRequest, "makeRequest");
|
93 |
+
async function resolveBody(body) {
|
94 |
+
if (body == null) {
|
95 |
+
return null;
|
96 |
+
} else if (typeof body === "string") {
|
97 |
+
return body;
|
98 |
+
} else if (import_node_util.types.isUint8Array(body)) {
|
99 |
+
return body;
|
100 |
+
} else if (import_node_util.types.isArrayBuffer(body)) {
|
101 |
+
return new Uint8Array(body);
|
102 |
+
} else if (body instanceof import_node_url.URLSearchParams) {
|
103 |
+
return body.toString();
|
104 |
+
} else if (body instanceof DataView) {
|
105 |
+
return new Uint8Array(body.buffer);
|
106 |
+
} else if (body instanceof Blob) {
|
107 |
+
return new Uint8Array(await body.arrayBuffer());
|
108 |
+
} else if (body instanceof FormData) {
|
109 |
+
return body;
|
110 |
+
} else if (body[Symbol.iterator]) {
|
111 |
+
const chunks = [...body];
|
112 |
+
return Buffer.concat(chunks);
|
113 |
+
} else if (body[Symbol.asyncIterator]) {
|
114 |
+
const chunks = [];
|
115 |
+
for await (const chunk of body) {
|
116 |
+
chunks.push(chunk);
|
117 |
+
}
|
118 |
+
return Buffer.concat(chunks);
|
119 |
+
}
|
120 |
+
throw new TypeError(`Unable to resolve body.`);
|
121 |
+
}
|
122 |
+
__name(resolveBody, "resolveBody");
|
123 |
+
|
124 |
+
// src/lib/utils/constants.ts
|
125 |
+
var import_util = require("@discordjs/util");
|
126 |
+
var import_v10 = require("discord-api-types/v10");
|
127 |
+
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 2.2.0)`;
|
128 |
+
var DefaultUserAgentAppendix = (0, import_util.getUserAgentAppendix)();
|
129 |
+
var DefaultRestOptions = {
|
130 |
+
agent: null,
|
131 |
+
api: "https://discord.com/api",
|
132 |
+
authPrefix: "Bot",
|
133 |
+
cdn: "https://cdn.discordapp.com",
|
134 |
+
headers: {},
|
135 |
+
invalidRequestWarningInterval: 0,
|
136 |
+
globalRequestsPerSecond: 50,
|
137 |
+
offset: 50,
|
138 |
+
rejectOnRateLimit: null,
|
139 |
+
retries: 3,
|
140 |
+
timeout: 15e3,
|
141 |
+
userAgentAppendix: DefaultUserAgentAppendix,
|
142 |
+
version: import_v10.APIVersion,
|
143 |
+
hashSweepInterval: 144e5,
|
144 |
+
// 4 Hours
|
145 |
+
hashLifetime: 864e5,
|
146 |
+
// 24 Hours
|
147 |
+
handlerSweepInterval: 36e5,
|
148 |
+
// 1 Hour
|
149 |
+
async makeRequest(...args) {
|
150 |
+
return getDefaultStrategy()(...args);
|
151 |
+
}
|
152 |
+
};
|
153 |
+
var RESTEvents = /* @__PURE__ */ ((RESTEvents2) => {
|
154 |
+
RESTEvents2["Debug"] = "restDebug";
|
155 |
+
RESTEvents2["HandlerSweep"] = "handlerSweep";
|
156 |
+
RESTEvents2["HashSweep"] = "hashSweep";
|
157 |
+
RESTEvents2["InvalidRequestWarning"] = "invalidRequestWarning";
|
158 |
+
RESTEvents2["RateLimited"] = "rateLimited";
|
159 |
+
RESTEvents2["Response"] = "response";
|
160 |
+
return RESTEvents2;
|
161 |
+
})(RESTEvents || {});
|
162 |
+
var ALLOWED_EXTENSIONS = ["webp", "png", "jpg", "jpeg", "gif"];
|
163 |
+
var ALLOWED_STICKER_EXTENSIONS = ["png", "json", "gif"];
|
164 |
+
var ALLOWED_SIZES = [16, 32, 64, 128, 256, 512, 1024, 2048, 4096];
|
165 |
+
var OverwrittenMimeTypes = {
|
166 |
+
// https://github.com/discordjs/discord.js/issues/8557
|
167 |
+
"image/apng": "image/png"
|
168 |
+
};
|
169 |
+
var BurstHandlerMajorIdKey = "burst";
|
170 |
+
var DEPRECATION_WARNING_PREFIX = "DeprecationWarning";
|
171 |
+
|
172 |
+
// src/lib/errors/RateLimitError.ts
|
173 |
+
var RateLimitError = class _RateLimitError extends Error {
|
174 |
+
static {
|
175 |
+
__name(this, "RateLimitError");
|
176 |
+
}
|
177 |
+
timeToReset;
|
178 |
+
limit;
|
179 |
+
method;
|
180 |
+
hash;
|
181 |
+
url;
|
182 |
+
route;
|
183 |
+
majorParameter;
|
184 |
+
global;
|
185 |
+
retryAfter;
|
186 |
+
sublimitTimeout;
|
187 |
+
scope;
|
188 |
+
constructor({
|
189 |
+
timeToReset,
|
190 |
+
limit,
|
191 |
+
method,
|
192 |
+
hash,
|
193 |
+
url,
|
194 |
+
route,
|
195 |
+
majorParameter,
|
196 |
+
global,
|
197 |
+
retryAfter,
|
198 |
+
sublimitTimeout,
|
199 |
+
scope
|
200 |
+
}) {
|
201 |
+
super();
|
202 |
+
this.timeToReset = timeToReset;
|
203 |
+
this.limit = limit;
|
204 |
+
this.method = method;
|
205 |
+
this.hash = hash;
|
206 |
+
this.url = url;
|
207 |
+
this.route = route;
|
208 |
+
this.majorParameter = majorParameter;
|
209 |
+
this.global = global;
|
210 |
+
this.retryAfter = retryAfter;
|
211 |
+
this.sublimitTimeout = sublimitTimeout;
|
212 |
+
this.scope = scope;
|
213 |
+
}
|
214 |
+
/**
|
215 |
+
* The name of the error
|
216 |
+
*/
|
217 |
+
get name() {
|
218 |
+
return `${_RateLimitError.name}[${this.route}]`;
|
219 |
+
}
|
220 |
+
};
|
221 |
+
|
222 |
+
// src/lib/utils/types.ts
|
223 |
+
var RequestMethod = /* @__PURE__ */ ((RequestMethod2) => {
|
224 |
+
RequestMethod2["Delete"] = "DELETE";
|
225 |
+
RequestMethod2["Get"] = "GET";
|
226 |
+
RequestMethod2["Patch"] = "PATCH";
|
227 |
+
RequestMethod2["Post"] = "POST";
|
228 |
+
RequestMethod2["Put"] = "PUT";
|
229 |
+
return RequestMethod2;
|
230 |
+
})(RequestMethod || {});
|
231 |
+
|
232 |
+
// src/lib/utils/utils.ts
|
233 |
+
function serializeSearchParam(value) {
|
234 |
+
switch (typeof value) {
|
235 |
+
case "string":
|
236 |
+
return value;
|
237 |
+
case "number":
|
238 |
+
case "bigint":
|
239 |
+
case "boolean":
|
240 |
+
return value.toString();
|
241 |
+
case "object":
|
242 |
+
if (value === null)
|
243 |
+
return null;
|
244 |
+
if (value instanceof Date) {
|
245 |
+
return Number.isNaN(value.getTime()) ? null : value.toISOString();
|
246 |
+
}
|
247 |
+
if (typeof value.toString === "function" && value.toString !== Object.prototype.toString)
|
248 |
+
return value.toString();
|
249 |
+
return null;
|
250 |
+
default:
|
251 |
+
return null;
|
252 |
+
}
|
253 |
+
}
|
254 |
+
__name(serializeSearchParam, "serializeSearchParam");
|
255 |
+
function makeURLSearchParams(options) {
|
256 |
+
const params = new URLSearchParams();
|
257 |
+
if (!options)
|
258 |
+
return params;
|
259 |
+
for (const [key, value] of Object.entries(options)) {
|
260 |
+
const serialized = serializeSearchParam(value);
|
261 |
+
if (serialized !== null)
|
262 |
+
params.append(key, serialized);
|
263 |
+
}
|
264 |
+
return params;
|
265 |
+
}
|
266 |
+
__name(makeURLSearchParams, "makeURLSearchParams");
|
267 |
+
async function parseResponse(res) {
|
268 |
+
if (res.headers.get("Content-Type")?.startsWith("application/json")) {
|
269 |
+
return res.json();
|
270 |
+
}
|
271 |
+
return res.arrayBuffer();
|
272 |
+
}
|
273 |
+
__name(parseResponse, "parseResponse");
|
274 |
+
function hasSublimit(bucketRoute, body, method) {
|
275 |
+
if (bucketRoute === "/channels/:id") {
|
276 |
+
if (typeof body !== "object" || body === null)
|
277 |
+
return false;
|
278 |
+
if (method !== "PATCH" /* Patch */)
|
279 |
+
return false;
|
280 |
+
const castedBody = body;
|
281 |
+
return ["name", "topic"].some((key) => Reflect.has(castedBody, key));
|
282 |
+
}
|
283 |
+
return true;
|
284 |
+
}
|
285 |
+
__name(hasSublimit, "hasSublimit");
|
286 |
+
function shouldRetry(error) {
|
287 |
+
if (error.name === "AbortError")
|
288 |
+
return true;
|
289 |
+
return "code" in error && error.code === "ECONNRESET" || error.message.includes("ECONNRESET");
|
290 |
+
}
|
291 |
+
__name(shouldRetry, "shouldRetry");
|
292 |
+
async function onRateLimit(manager, rateLimitData) {
|
293 |
+
const { options } = manager;
|
294 |
+
if (!options.rejectOnRateLimit)
|
295 |
+
return;
|
296 |
+
const shouldThrow = typeof options.rejectOnRateLimit === "function" ? await options.rejectOnRateLimit(rateLimitData) : options.rejectOnRateLimit.some((route) => rateLimitData.route.startsWith(route.toLowerCase()));
|
297 |
+
if (shouldThrow) {
|
298 |
+
throw new RateLimitError(rateLimitData);
|
299 |
+
}
|
300 |
+
}
|
301 |
+
__name(onRateLimit, "onRateLimit");
|
302 |
+
function calculateUserDefaultAvatarIndex(userId) {
|
303 |
+
return Number(BigInt(userId) >> 22n) % 6;
|
304 |
+
}
|
305 |
+
__name(calculateUserDefaultAvatarIndex, "calculateUserDefaultAvatarIndex");
|
306 |
+
async function sleep(ms) {
|
307 |
+
return new Promise((resolve) => {
|
308 |
+
setTimeout(() => resolve(), ms);
|
309 |
+
});
|
310 |
+
}
|
311 |
+
__name(sleep, "sleep");
|
312 |
+
function isBufferLike(value) {
|
313 |
+
return value instanceof ArrayBuffer || value instanceof Uint8Array || value instanceof Uint8ClampedArray;
|
314 |
+
}
|
315 |
+
__name(isBufferLike, "isBufferLike");
|
316 |
+
function deprecationWarning(message) {
|
317 |
+
if (typeof globalThis.process === "undefined") {
|
318 |
+
console.warn(`${DEPRECATION_WARNING_PREFIX}: ${message}`);
|
319 |
+
} else {
|
320 |
+
process.emitWarning(message, DEPRECATION_WARNING_PREFIX);
|
321 |
+
}
|
322 |
+
}
|
323 |
+
__name(deprecationWarning, "deprecationWarning");
|
324 |
+
|
325 |
+
// src/lib/CDN.ts
|
326 |
+
var deprecationEmittedForEmoji = false;
|
327 |
+
var CDN = class {
|
328 |
+
constructor(base = DefaultRestOptions.cdn) {
|
329 |
+
this.base = base;
|
330 |
+
}
|
331 |
+
static {
|
332 |
+
__name(this, "CDN");
|
333 |
+
}
|
334 |
+
/**
|
335 |
+
* Generates an app asset URL for a client's asset.
|
336 |
+
*
|
337 |
+
* @param clientId - The client id that has the asset
|
338 |
+
* @param assetHash - The hash provided by Discord for this asset
|
339 |
+
* @param options - Optional options for the asset
|
340 |
+
*/
|
341 |
+
appAsset(clientId, assetHash, options) {
|
342 |
+
return this.makeURL(`/app-assets/${clientId}/${assetHash}`, options);
|
343 |
+
}
|
344 |
+
/**
|
345 |
+
* Generates an app icon URL for a client's icon.
|
346 |
+
*
|
347 |
+
* @param clientId - The client id that has the icon
|
348 |
+
* @param iconHash - The hash provided by Discord for this icon
|
349 |
+
* @param options - Optional options for the icon
|
350 |
+
*/
|
351 |
+
appIcon(clientId, iconHash, options) {
|
352 |
+
return this.makeURL(`/app-icons/${clientId}/${iconHash}`, options);
|
353 |
+
}
|
354 |
+
/**
|
355 |
+
* Generates an avatar URL, e.g. for a user or a webhook.
|
356 |
+
*
|
357 |
+
* @param id - The id that has the icon
|
358 |
+
* @param avatarHash - The hash provided by Discord for this avatar
|
359 |
+
* @param options - Optional options for the avatar
|
360 |
+
*/
|
361 |
+
avatar(id, avatarHash, options) {
|
362 |
+
return this.dynamicMakeURL(`/avatars/${id}/${avatarHash}`, avatarHash, options);
|
363 |
+
}
|
364 |
+
/**
|
365 |
+
* Generates a user avatar decoration URL.
|
366 |
+
*
|
367 |
+
* @param userId - The id of the user
|
368 |
+
* @param userAvatarDecoration - The hash provided by Discord for this avatar decoration
|
369 |
+
* @param options - Optional options for the avatar decoration
|
370 |
+
*/
|
371 |
+
avatarDecoration(userId, userAvatarDecoration, options) {
|
372 |
+
return this.makeURL(`/avatar-decorations/${userId}/${userAvatarDecoration}`, options);
|
373 |
+
}
|
374 |
+
/**
|
375 |
+
* Generates a banner URL, e.g. for a user or a guild.
|
376 |
+
*
|
377 |
+
* @param id - The id that has the banner splash
|
378 |
+
* @param bannerHash - The hash provided by Discord for this banner
|
379 |
+
* @param options - Optional options for the banner
|
380 |
+
*/
|
381 |
+
banner(id, bannerHash, options) {
|
382 |
+
return this.dynamicMakeURL(`/banners/${id}/${bannerHash}`, bannerHash, options);
|
383 |
+
}
|
384 |
+
/**
|
385 |
+
* Generates an icon URL for a channel, e.g. a group DM.
|
386 |
+
*
|
387 |
+
* @param channelId - The channel id that has the icon
|
388 |
+
* @param iconHash - The hash provided by Discord for this channel
|
389 |
+
* @param options - Optional options for the icon
|
390 |
+
*/
|
391 |
+
channelIcon(channelId, iconHash, options) {
|
392 |
+
return this.makeURL(`/channel-icons/${channelId}/${iconHash}`, options);
|
393 |
+
}
|
394 |
+
/**
|
395 |
+
* Generates a default avatar URL
|
396 |
+
*
|
397 |
+
* @param index - The default avatar index
|
398 |
+
* @remarks
|
399 |
+
* To calculate the index for a user do `(userId >> 22) % 6`,
|
400 |
+
* or `discriminator % 5` if they're using the legacy username system.
|
401 |
+
*/
|
402 |
+
defaultAvatar(index) {
|
403 |
+
return this.makeURL(`/embed/avatars/${index}`, { extension: "png" });
|
404 |
+
}
|
405 |
+
/**
|
406 |
+
* Generates a discovery splash URL for a guild's discovery splash.
|
407 |
+
*
|
408 |
+
* @param guildId - The guild id that has the discovery splash
|
409 |
+
* @param splashHash - The hash provided by Discord for this splash
|
410 |
+
* @param options - Optional options for the splash
|
411 |
+
*/
|
412 |
+
discoverySplash(guildId, splashHash, options) {
|
413 |
+
return this.makeURL(`/discovery-splashes/${guildId}/${splashHash}`, options);
|
414 |
+
}
|
415 |
+
emoji(emojiId, options) {
|
416 |
+
let resolvedOptions;
|
417 |
+
if (typeof options === "string") {
|
418 |
+
if (!deprecationEmittedForEmoji) {
|
419 |
+
deprecationWarning(
|
420 |
+
"Passing a string for the second parameter of CDN#emoji() is deprecated. Use an object instead."
|
421 |
+
);
|
422 |
+
deprecationEmittedForEmoji = true;
|
423 |
+
}
|
424 |
+
resolvedOptions = { extension: options };
|
425 |
+
} else {
|
426 |
+
resolvedOptions = options;
|
427 |
+
}
|
428 |
+
return this.makeURL(`/emojis/${emojiId}`, resolvedOptions);
|
429 |
+
}
|
430 |
+
/**
|
431 |
+
* Generates a guild member avatar URL.
|
432 |
+
*
|
433 |
+
* @param guildId - The id of the guild
|
434 |
+
* @param userId - The id of the user
|
435 |
+
* @param avatarHash - The hash provided by Discord for this avatar
|
436 |
+
* @param options - Optional options for the avatar
|
437 |
+
*/
|
438 |
+
guildMemberAvatar(guildId, userId, avatarHash, options) {
|
439 |
+
return this.dynamicMakeURL(`/guilds/${guildId}/users/${userId}/avatars/${avatarHash}`, avatarHash, options);
|
440 |
+
}
|
441 |
+
/**
|
442 |
+
* Generates a guild member banner URL.
|
443 |
+
*
|
444 |
+
* @param guildId - The id of the guild
|
445 |
+
* @param userId - The id of the user
|
446 |
+
* @param bannerHash - The hash provided by Discord for this banner
|
447 |
+
* @param options - Optional options for the banner
|
448 |
+
*/
|
449 |
+
guildMemberBanner(guildId, userId, bannerHash, options) {
|
450 |
+
return this.dynamicMakeURL(`/guilds/${guildId}/users/${userId}/banner`, bannerHash, options);
|
451 |
+
}
|
452 |
+
/**
|
453 |
+
* Generates an icon URL, e.g. for a guild.
|
454 |
+
*
|
455 |
+
* @param id - The id that has the icon splash
|
456 |
+
* @param iconHash - The hash provided by Discord for this icon
|
457 |
+
* @param options - Optional options for the icon
|
458 |
+
*/
|
459 |
+
icon(id, iconHash, options) {
|
460 |
+
return this.dynamicMakeURL(`/icons/${id}/${iconHash}`, iconHash, options);
|
461 |
+
}
|
462 |
+
/**
|
463 |
+
* Generates a URL for the icon of a role
|
464 |
+
*
|
465 |
+
* @param roleId - The id of the role that has the icon
|
466 |
+
* @param roleIconHash - The hash provided by Discord for this role icon
|
467 |
+
* @param options - Optional options for the role icon
|
468 |
+
*/
|
469 |
+
roleIcon(roleId, roleIconHash, options) {
|
470 |
+
return this.makeURL(`/role-icons/${roleId}/${roleIconHash}`, options);
|
471 |
+
}
|
472 |
+
/**
|
473 |
+
* Generates a guild invite splash URL for a guild's invite splash.
|
474 |
+
*
|
475 |
+
* @param guildId - The guild id that has the invite splash
|
476 |
+
* @param splashHash - The hash provided by Discord for this splash
|
477 |
+
* @param options - Optional options for the splash
|
478 |
+
*/
|
479 |
+
splash(guildId, splashHash, options) {
|
480 |
+
return this.makeURL(`/splashes/${guildId}/${splashHash}`, options);
|
481 |
+
}
|
482 |
+
/**
|
483 |
+
* Generates a sticker URL.
|
484 |
+
*
|
485 |
+
* @param stickerId - The sticker id
|
486 |
+
* @param extension - The extension of the sticker
|
487 |
+
* @privateRemarks
|
488 |
+
* Stickers cannot have a `.webp` extension, so we default to a `.png`
|
489 |
+
*/
|
490 |
+
sticker(stickerId, extension = "png") {
|
491 |
+
return this.makeURL(`/stickers/${stickerId}`, { allowedExtensions: ALLOWED_STICKER_EXTENSIONS, extension });
|
492 |
+
}
|
493 |
+
/**
|
494 |
+
* Generates a sticker pack banner URL.
|
495 |
+
*
|
496 |
+
* @param bannerId - The banner id
|
497 |
+
* @param options - Optional options for the banner
|
498 |
+
*/
|
499 |
+
stickerPackBanner(bannerId, options) {
|
500 |
+
return this.makeURL(`/app-assets/710982414301790216/store/${bannerId}`, options);
|
501 |
+
}
|
502 |
+
/**
|
503 |
+
* Generates a team icon URL for a team's icon.
|
504 |
+
*
|
505 |
+
* @param teamId - The team id that has the icon
|
506 |
+
* @param iconHash - The hash provided by Discord for this icon
|
507 |
+
* @param options - Optional options for the icon
|
508 |
+
*/
|
509 |
+
teamIcon(teamId, iconHash, options) {
|
510 |
+
return this.makeURL(`/team-icons/${teamId}/${iconHash}`, options);
|
511 |
+
}
|
512 |
+
/**
|
513 |
+
* Generates a cover image for a guild scheduled event.
|
514 |
+
*
|
515 |
+
* @param scheduledEventId - The scheduled event id
|
516 |
+
* @param coverHash - The hash provided by discord for this cover image
|
517 |
+
* @param options - Optional options for the cover image
|
518 |
+
*/
|
519 |
+
guildScheduledEventCover(scheduledEventId, coverHash, options) {
|
520 |
+
return this.makeURL(`/guild-events/${scheduledEventId}/${coverHash}`, options);
|
521 |
+
}
|
522 |
+
/**
|
523 |
+
* Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
|
524 |
+
*
|
525 |
+
* @param route - The base cdn route
|
526 |
+
* @param hash - The hash provided by Discord for this icon
|
527 |
+
* @param options - Optional options for the link
|
528 |
+
*/
|
529 |
+
dynamicMakeURL(route, hash, { forceStatic = false, ...options } = {}) {
|
530 |
+
return this.makeURL(route, !forceStatic && hash.startsWith("a_") ? { ...options, extension: "gif" } : options);
|
531 |
+
}
|
532 |
+
/**
|
533 |
+
* Constructs the URL for the resource
|
534 |
+
*
|
535 |
+
* @param route - The base cdn route
|
536 |
+
* @param options - The extension/size options for the link
|
537 |
+
*/
|
538 |
+
makeURL(route, { allowedExtensions = ALLOWED_EXTENSIONS, extension = "webp", size } = {}) {
|
539 |
+
extension = String(extension).toLowerCase();
|
540 |
+
if (!allowedExtensions.includes(extension)) {
|
541 |
+
throw new RangeError(`Invalid extension provided: ${extension}
|
542 |
+
Must be one of: ${allowedExtensions.join(", ")}`);
|
543 |
+
}
|
544 |
+
if (size && !ALLOWED_SIZES.includes(size)) {
|
545 |
+
throw new RangeError(`Invalid size provided: ${size}
|
546 |
+
Must be one of: ${ALLOWED_SIZES.join(", ")}`);
|
547 |
+
}
|
548 |
+
const url = new URL(`${this.base}${route}.${extension}`);
|
549 |
+
if (size) {
|
550 |
+
url.searchParams.set("size", String(size));
|
551 |
+
}
|
552 |
+
return url.toString();
|
553 |
+
}
|
554 |
+
};
|
555 |
+
|
556 |
+
// src/lib/errors/DiscordAPIError.ts
|
557 |
+
function isErrorGroupWrapper(error) {
|
558 |
+
return Reflect.has(error, "_errors");
|
559 |
+
}
|
560 |
+
__name(isErrorGroupWrapper, "isErrorGroupWrapper");
|
561 |
+
function isErrorResponse(error) {
|
562 |
+
return typeof Reflect.get(error, "message") === "string";
|
563 |
+
}
|
564 |
+
__name(isErrorResponse, "isErrorResponse");
|
565 |
+
var DiscordAPIError = class _DiscordAPIError extends Error {
|
566 |
+
/**
|
567 |
+
* @param rawError - The error reported by Discord
|
568 |
+
* @param code - The error code reported by Discord
|
569 |
+
* @param status - The status code of the response
|
570 |
+
* @param method - The method of the request that erred
|
571 |
+
* @param url - The url of the request that erred
|
572 |
+
* @param bodyData - The unparsed data for the request that errored
|
573 |
+
*/
|
574 |
+
constructor(rawError, code, status, method, url, bodyData) {
|
575 |
+
super(_DiscordAPIError.getMessage(rawError));
|
576 |
+
this.rawError = rawError;
|
577 |
+
this.code = code;
|
578 |
+
this.status = status;
|
579 |
+
this.method = method;
|
580 |
+
this.url = url;
|
581 |
+
this.requestBody = { files: bodyData.files, json: bodyData.body };
|
582 |
+
}
|
583 |
+
static {
|
584 |
+
__name(this, "DiscordAPIError");
|
585 |
+
}
|
586 |
+
requestBody;
|
587 |
+
/**
|
588 |
+
* The name of the error
|
589 |
+
*/
|
590 |
+
get name() {
|
591 |
+
return `${_DiscordAPIError.name}[${this.code}]`;
|
592 |
+
}
|
593 |
+
static getMessage(error) {
|
594 |
+
let flattened = "";
|
595 |
+
if ("code" in error) {
|
596 |
+
if (error.errors) {
|
597 |
+
flattened = [...this.flattenDiscordError(error.errors)].join("\n");
|
598 |
+
}
|
599 |
+
return error.message && flattened ? `${error.message}
|
600 |
+
${flattened}` : error.message || flattened || "Unknown Error";
|
601 |
+
}
|
602 |
+
return error.error_description ?? "No Description";
|
603 |
+
}
|
604 |
+
static *flattenDiscordError(obj, key = "") {
|
605 |
+
if (isErrorResponse(obj)) {
|
606 |
+
return yield `${key.length ? `${key}[${obj.code}]` : `${obj.code}`}: ${obj.message}`.trim();
|
607 |
+
}
|
608 |
+
for (const [otherKey, val] of Object.entries(obj)) {
|
609 |
+
const nextKey = otherKey.startsWith("_") ? key : key ? Number.isNaN(Number(otherKey)) ? `${key}.${otherKey}` : `${key}[${otherKey}]` : otherKey;
|
610 |
+
if (typeof val === "string") {
|
611 |
+
yield val;
|
612 |
+
} else if (isErrorGroupWrapper(val)) {
|
613 |
+
for (const error of val._errors) {
|
614 |
+
yield* this.flattenDiscordError(error, nextKey);
|
615 |
+
}
|
616 |
+
} else {
|
617 |
+
yield* this.flattenDiscordError(val, nextKey);
|
618 |
+
}
|
619 |
+
}
|
620 |
+
}
|
621 |
+
};
|
622 |
+
|
623 |
+
// src/lib/errors/HTTPError.ts
|
624 |
+
var HTTPError = class _HTTPError extends Error {
|
625 |
+
/**
|
626 |
+
* @param status - The status code of the response
|
627 |
+
* @param statusText - The status text of the response
|
628 |
+
* @param method - The method of the request that erred
|
629 |
+
* @param url - The url of the request that erred
|
630 |
+
* @param bodyData - The unparsed data for the request that errored
|
631 |
+
*/
|
632 |
+
constructor(status, statusText, method, url, bodyData) {
|
633 |
+
super(statusText);
|
634 |
+
this.status = status;
|
635 |
+
this.method = method;
|
636 |
+
this.url = url;
|
637 |
+
this.requestBody = { files: bodyData.files, json: bodyData.body };
|
638 |
+
}
|
639 |
+
static {
|
640 |
+
__name(this, "HTTPError");
|
641 |
+
}
|
642 |
+
requestBody;
|
643 |
+
name = _HTTPError.name;
|
644 |
+
};
|
645 |
+
|
646 |
+
// src/lib/REST.ts
|
647 |
+
var import_collection = require("@discordjs/collection");
|
648 |
+
var import_snowflake = require("@sapphire/snowflake");
|
649 |
+
var import_async_event_emitter = require("@vladfrangu/async_event_emitter");
|
650 |
+
var import_magic_bytes = require("magic-bytes.js");
|
651 |
+
|
652 |
+
// src/lib/handlers/Shared.ts
|
653 |
+
var invalidCount = 0;
|
654 |
+
var invalidCountResetTime = null;
|
655 |
+
function incrementInvalidCount(manager) {
|
656 |
+
if (!invalidCountResetTime || invalidCountResetTime < Date.now()) {
|
657 |
+
invalidCountResetTime = Date.now() + 1e3 * 60 * 10;
|
658 |
+
invalidCount = 0;
|
659 |
+
}
|
660 |
+
invalidCount++;
|
661 |
+
const emitInvalid = manager.options.invalidRequestWarningInterval > 0 && invalidCount % manager.options.invalidRequestWarningInterval === 0;
|
662 |
+
if (emitInvalid) {
|
663 |
+
manager.emit("invalidRequestWarning" /* InvalidRequestWarning */, {
|
664 |
+
count: invalidCount,
|
665 |
+
remainingTime: invalidCountResetTime - Date.now()
|
666 |
+
});
|
667 |
+
}
|
668 |
+
}
|
669 |
+
__name(incrementInvalidCount, "incrementInvalidCount");
|
670 |
+
async function makeNetworkRequest(manager, routeId, url, options, requestData, retries) {
|
671 |
+
const controller = new AbortController();
|
672 |
+
const timeout = setTimeout(() => controller.abort(), manager.options.timeout);
|
673 |
+
if (requestData.signal) {
|
674 |
+
if (requestData.signal.aborted)
|
675 |
+
controller.abort();
|
676 |
+
else
|
677 |
+
requestData.signal.addEventListener("abort", () => controller.abort());
|
678 |
+
}
|
679 |
+
let res;
|
680 |
+
try {
|
681 |
+
res = await manager.options.makeRequest(url, { ...options, signal: controller.signal });
|
682 |
+
} catch (error) {
|
683 |
+
if (!(error instanceof Error))
|
684 |
+
throw error;
|
685 |
+
if (shouldRetry(error) && retries !== manager.options.retries) {
|
686 |
+
return null;
|
687 |
+
}
|
688 |
+
throw error;
|
689 |
+
} finally {
|
690 |
+
clearTimeout(timeout);
|
691 |
+
}
|
692 |
+
if (manager.listenerCount("response" /* Response */)) {
|
693 |
+
manager.emit(
|
694 |
+
"response" /* Response */,
|
695 |
+
{
|
696 |
+
method: options.method ?? "get",
|
697 |
+
path: routeId.original,
|
698 |
+
route: routeId.bucketRoute,
|
699 |
+
options,
|
700 |
+
data: requestData,
|
701 |
+
retries
|
702 |
+
},
|
703 |
+
res instanceof Response ? res.clone() : { ...res }
|
704 |
+
);
|
705 |
+
}
|
706 |
+
return res;
|
707 |
+
}
|
708 |
+
__name(makeNetworkRequest, "makeNetworkRequest");
|
709 |
+
async function handleErrors(manager, res, method, url, requestData, retries) {
|
710 |
+
const status = res.status;
|
711 |
+
if (status >= 500 && status < 600) {
|
712 |
+
if (retries !== manager.options.retries) {
|
713 |
+
return null;
|
714 |
+
}
|
715 |
+
throw new HTTPError(status, res.statusText, method, url, requestData);
|
716 |
+
} else {
|
717 |
+
if (status >= 400 && status < 500) {
|
718 |
+
if (status === 401 && requestData.auth) {
|
719 |
+
manager.setToken(null);
|
720 |
+
}
|
721 |
+
const data = await parseResponse(res);
|
722 |
+
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
|
723 |
+
}
|
724 |
+
return res;
|
725 |
+
}
|
726 |
+
}
|
727 |
+
__name(handleErrors, "handleErrors");
|
728 |
+
|
729 |
+
// src/lib/handlers/BurstHandler.ts
|
730 |
+
var BurstHandler = class {
|
731 |
+
/**
|
732 |
+
* @param manager - The request manager
|
733 |
+
* @param hash - The hash that this RequestHandler handles
|
734 |
+
* @param majorParameter - The major parameter for this handler
|
735 |
+
*/
|
736 |
+
constructor(manager, hash, majorParameter) {
|
737 |
+
this.manager = manager;
|
738 |
+
this.hash = hash;
|
739 |
+
this.majorParameter = majorParameter;
|
740 |
+
this.id = `${hash}:${majorParameter}`;
|
741 |
+
}
|
742 |
+
static {
|
743 |
+
__name(this, "BurstHandler");
|
744 |
+
}
|
745 |
+
/**
|
746 |
+
* {@inheritdoc IHandler.id}
|
747 |
+
*/
|
748 |
+
id;
|
749 |
+
/**
|
750 |
+
* {@inheritDoc IHandler.inactive}
|
751 |
+
*/
|
752 |
+
inactive = false;
|
753 |
+
/**
|
754 |
+
* Emits a debug message
|
755 |
+
*
|
756 |
+
* @param message - The message to debug
|
757 |
+
*/
|
758 |
+
debug(message) {
|
759 |
+
this.manager.emit("restDebug" /* Debug */, `[REST ${this.id}] ${message}`);
|
760 |
+
}
|
761 |
+
/**
|
762 |
+
* {@inheritDoc IHandler.queueRequest}
|
763 |
+
*/
|
764 |
+
async queueRequest(routeId, url, options, requestData) {
|
765 |
+
return this.runRequest(routeId, url, options, requestData);
|
766 |
+
}
|
767 |
+
/**
|
768 |
+
* The method that actually makes the request to the API, and updates info about the bucket accordingly
|
769 |
+
*
|
770 |
+
* @param routeId - The generalized API route with literal ids for major parameters
|
771 |
+
* @param url - The fully resolved URL to make the request to
|
772 |
+
* @param options - The fetch options needed to make the request
|
773 |
+
* @param requestData - Extra data from the user's request needed for errors and additional processing
|
774 |
+
* @param retries - The number of retries this request has already attempted (recursion)
|
775 |
+
*/
|
776 |
+
async runRequest(routeId, url, options, requestData, retries = 0) {
|
777 |
+
const method = options.method ?? "get";
|
778 |
+
const res = await makeNetworkRequest(this.manager, routeId, url, options, requestData, retries);
|
779 |
+
if (res === null) {
|
780 |
+
return this.runRequest(routeId, url, options, requestData, ++retries);
|
781 |
+
}
|
782 |
+
const status = res.status;
|
783 |
+
let retryAfter = 0;
|
784 |
+
const retry = res.headers.get("Retry-After");
|
785 |
+
if (retry)
|
786 |
+
retryAfter = Number(retry) * 1e3 + this.manager.options.offset;
|
787 |
+
if (status === 401 || status === 403 || status === 429) {
|
788 |
+
incrementInvalidCount(this.manager);
|
789 |
+
}
|
790 |
+
if (status >= 200 && status < 300) {
|
791 |
+
return res;
|
792 |
+
} else if (status === 429) {
|
793 |
+
const isGlobal = res.headers.has("X-RateLimit-Global");
|
794 |
+
const scope = res.headers.get("X-RateLimit-Scope") ?? "user";
|
795 |
+
await onRateLimit(this.manager, {
|
796 |
+
global: isGlobal,
|
797 |
+
method,
|
798 |
+
url,
|
799 |
+
route: routeId.bucketRoute,
|
800 |
+
majorParameter: this.majorParameter,
|
801 |
+
hash: this.hash,
|
802 |
+
limit: Number.POSITIVE_INFINITY,
|
803 |
+
timeToReset: retryAfter,
|
804 |
+
retryAfter,
|
805 |
+
sublimitTimeout: 0,
|
806 |
+
scope
|
807 |
+
});
|
808 |
+
this.debug(
|
809 |
+
[
|
810 |
+
"Encountered unexpected 429 rate limit",
|
811 |
+
` Global : ${isGlobal}`,
|
812 |
+
` Method : ${method}`,
|
813 |
+
` URL : ${url}`,
|
814 |
+
` Bucket : ${routeId.bucketRoute}`,
|
815 |
+
` Major parameter: ${routeId.majorParameter}`,
|
816 |
+
` Hash : ${this.hash}`,
|
817 |
+
` Limit : ${Number.POSITIVE_INFINITY}`,
|
818 |
+
` Retry After : ${retryAfter}ms`,
|
819 |
+
` Sublimit : None`,
|
820 |
+
` Scope : ${scope}`
|
821 |
+
].join("\n")
|
822 |
+
);
|
823 |
+
await sleep(retryAfter);
|
824 |
+
return this.runRequest(routeId, url, options, requestData, retries);
|
825 |
+
} else {
|
826 |
+
const handled = await handleErrors(this.manager, res, method, url, requestData, retries);
|
827 |
+
if (handled === null) {
|
828 |
+
return this.runRequest(routeId, url, options, requestData, ++retries);
|
829 |
+
}
|
830 |
+
return handled;
|
831 |
+
}
|
832 |
+
}
|
833 |
+
};
|
834 |
+
|
835 |
+
// src/lib/handlers/SequentialHandler.ts
|
836 |
+
var import_async_queue = require("@sapphire/async-queue");
|
837 |
+
var SequentialHandler = class {
|
838 |
+
/**
|
839 |
+
* @param manager - The request manager
|
840 |
+
* @param hash - The hash that this RequestHandler handles
|
841 |
+
* @param majorParameter - The major parameter for this handler
|
842 |
+
*/
|
843 |
+
constructor(manager, hash, majorParameter) {
|
844 |
+
this.manager = manager;
|
845 |
+
this.hash = hash;
|
846 |
+
this.majorParameter = majorParameter;
|
847 |
+
this.id = `${hash}:${majorParameter}`;
|
848 |
+
}
|
849 |
+
static {
|
850 |
+
__name(this, "SequentialHandler");
|
851 |
+
}
|
852 |
+
/**
|
853 |
+
* {@inheritDoc IHandler.id}
|
854 |
+
*/
|
855 |
+
id;
|
856 |
+
/**
|
857 |
+
* The time this rate limit bucket will reset
|
858 |
+
*/
|
859 |
+
reset = -1;
|
860 |
+
/**
|
861 |
+
* The remaining requests that can be made before we are rate limited
|
862 |
+
*/
|
863 |
+
remaining = 1;
|
864 |
+
/**
|
865 |
+
* The total number of requests that can be made before we are rate limited
|
866 |
+
*/
|
867 |
+
limit = Number.POSITIVE_INFINITY;
|
868 |
+
/**
|
869 |
+
* The interface used to sequence async requests sequentially
|
870 |
+
*/
|
871 |
+
#asyncQueue = new import_async_queue.AsyncQueue();
|
872 |
+
/**
|
873 |
+
* The interface used to sequence sublimited async requests sequentially
|
874 |
+
*/
|
875 |
+
#sublimitedQueue = null;
|
876 |
+
/**
|
877 |
+
* A promise wrapper for when the sublimited queue is finished being processed or null when not being processed
|
878 |
+
*/
|
879 |
+
#sublimitPromise = null;
|
880 |
+
/**
|
881 |
+
* Whether the sublimit queue needs to be shifted in the finally block
|
882 |
+
*/
|
883 |
+
#shiftSublimit = false;
|
884 |
+
/**
|
885 |
+
* {@inheritDoc IHandler.inactive}
|
886 |
+
*/
|
887 |
+
get inactive() {
|
888 |
+
return this.#asyncQueue.remaining === 0 && (this.#sublimitedQueue === null || this.#sublimitedQueue.remaining === 0) && !this.limited;
|
889 |
+
}
|
890 |
+
/**
|
891 |
+
* If the rate limit bucket is currently limited by the global limit
|
892 |
+
*/
|
893 |
+
get globalLimited() {
|
894 |
+
return this.manager.globalRemaining <= 0 && Date.now() < this.manager.globalReset;
|
895 |
+
}
|
896 |
+
/**
|
897 |
+
* If the rate limit bucket is currently limited by its limit
|
898 |
+
*/
|
899 |
+
get localLimited() {
|
900 |
+
return this.remaining <= 0 && Date.now() < this.reset;
|
901 |
+
}
|
902 |
+
/**
|
903 |
+
* If the rate limit bucket is currently limited
|
904 |
+
*/
|
905 |
+
get limited() {
|
906 |
+
return this.globalLimited || this.localLimited;
|
907 |
+
}
|
908 |
+
/**
|
909 |
+
* The time until queued requests can continue
|
910 |
+
*/
|
911 |
+
get timeToReset() {
|
912 |
+
return this.reset + this.manager.options.offset - Date.now();
|
913 |
+
}
|
914 |
+
/**
|
915 |
+
* Emits a debug message
|
916 |
+
*
|
917 |
+
* @param message - The message to debug
|
918 |
+
*/
|
919 |
+
debug(message) {
|
920 |
+
this.manager.emit("restDebug" /* Debug */, `[REST ${this.id}] ${message}`);
|
921 |
+
}
|
922 |
+
/**
|
923 |
+
* Delay all requests for the specified amount of time, handling global rate limits
|
924 |
+
*
|
925 |
+
* @param time - The amount of time to delay all requests for
|
926 |
+
*/
|
927 |
+
async globalDelayFor(time) {
|
928 |
+
await sleep(time);
|
929 |
+
this.manager.globalDelay = null;
|
930 |
+
}
|
931 |
+
/**
|
932 |
+
* {@inheritDoc IHandler.queueRequest}
|
933 |
+
*/
|
934 |
+
async queueRequest(routeId, url, options, requestData) {
|
935 |
+
let queue = this.#asyncQueue;
|
936 |
+
let queueType = 0 /* Standard */;
|
937 |
+
if (this.#sublimitedQueue && hasSublimit(routeId.bucketRoute, requestData.body, options.method)) {
|
938 |
+
queue = this.#sublimitedQueue;
|
939 |
+
queueType = 1 /* Sublimit */;
|
940 |
+
}
|
941 |
+
await queue.wait({ signal: requestData.signal });
|
942 |
+
if (queueType === 0 /* Standard */) {
|
943 |
+
if (this.#sublimitedQueue && hasSublimit(routeId.bucketRoute, requestData.body, options.method)) {
|
944 |
+
queue = this.#sublimitedQueue;
|
945 |
+
const wait = queue.wait();
|
946 |
+
this.#asyncQueue.shift();
|
947 |
+
await wait;
|
948 |
+
} else if (this.#sublimitPromise) {
|
949 |
+
await this.#sublimitPromise.promise;
|
950 |
+
}
|
951 |
+
}
|
952 |
+
try {
|
953 |
+
return await this.runRequest(routeId, url, options, requestData);
|
954 |
+
} finally {
|
955 |
+
queue.shift();
|
956 |
+
if (this.#shiftSublimit) {
|
957 |
+
this.#shiftSublimit = false;
|
958 |
+
this.#sublimitedQueue?.shift();
|
959 |
+
}
|
960 |
+
if (this.#sublimitedQueue?.remaining === 0) {
|
961 |
+
this.#sublimitPromise?.resolve();
|
962 |
+
this.#sublimitedQueue = null;
|
963 |
+
}
|
964 |
+
}
|
965 |
+
}
|
966 |
+
/**
|
967 |
+
* The method that actually makes the request to the api, and updates info about the bucket accordingly
|
968 |
+
*
|
969 |
+
* @param routeId - The generalized api route with literal ids for major parameters
|
970 |
+
* @param url - The fully resolved url to make the request to
|
971 |
+
* @param options - The fetch options needed to make the request
|
972 |
+
* @param requestData - Extra data from the user's request needed for errors and additional processing
|
973 |
+
* @param retries - The number of retries this request has already attempted (recursion)
|
974 |
+
*/
|
975 |
+
async runRequest(routeId, url, options, requestData, retries = 0) {
|
976 |
+
while (this.limited) {
|
977 |
+
const isGlobal = this.globalLimited;
|
978 |
+
let limit2;
|
979 |
+
let timeout;
|
980 |
+
let delay;
|
981 |
+
if (isGlobal) {
|
982 |
+
limit2 = this.manager.options.globalRequestsPerSecond;
|
983 |
+
timeout = this.manager.globalReset + this.manager.options.offset - Date.now();
|
984 |
+
if (!this.manager.globalDelay) {
|
985 |
+
this.manager.globalDelay = this.globalDelayFor(timeout);
|
986 |
+
}
|
987 |
+
delay = this.manager.globalDelay;
|
988 |
+
} else {
|
989 |
+
limit2 = this.limit;
|
990 |
+
timeout = this.timeToReset;
|
991 |
+
delay = sleep(timeout);
|
992 |
+
}
|
993 |
+
const rateLimitData = {
|
994 |
+
global: isGlobal,
|
995 |
+
method: options.method ?? "get",
|
996 |
+
url,
|
997 |
+
route: routeId.bucketRoute,
|
998 |
+
majorParameter: this.majorParameter,
|
999 |
+
hash: this.hash,
|
1000 |
+
limit: limit2,
|
1001 |
+
timeToReset: timeout,
|
1002 |
+
retryAfter: timeout,
|
1003 |
+
sublimitTimeout: 0,
|
1004 |
+
scope: "user"
|
1005 |
+
};
|
1006 |
+
this.manager.emit("rateLimited" /* RateLimited */, rateLimitData);
|
1007 |
+
await onRateLimit(this.manager, rateLimitData);
|
1008 |
+
if (isGlobal) {
|
1009 |
+
this.debug(`Global rate limit hit, blocking all requests for ${timeout}ms`);
|
1010 |
+
} else {
|
1011 |
+
this.debug(`Waiting ${timeout}ms for rate limit to pass`);
|
1012 |
+
}
|
1013 |
+
await delay;
|
1014 |
+
}
|
1015 |
+
if (!this.manager.globalReset || this.manager.globalReset < Date.now()) {
|
1016 |
+
this.manager.globalReset = Date.now() + 1e3;
|
1017 |
+
this.manager.globalRemaining = this.manager.options.globalRequestsPerSecond;
|
1018 |
+
}
|
1019 |
+
this.manager.globalRemaining--;
|
1020 |
+
const method = options.method ?? "get";
|
1021 |
+
const res = await makeNetworkRequest(this.manager, routeId, url, options, requestData, retries);
|
1022 |
+
if (res === null) {
|
1023 |
+
return this.runRequest(routeId, url, options, requestData, ++retries);
|
1024 |
+
}
|
1025 |
+
const status = res.status;
|
1026 |
+
let retryAfter = 0;
|
1027 |
+
const limit = res.headers.get("X-RateLimit-Limit");
|
1028 |
+
const remaining = res.headers.get("X-RateLimit-Remaining");
|
1029 |
+
const reset = res.headers.get("X-RateLimit-Reset-After");
|
1030 |
+
const hash = res.headers.get("X-RateLimit-Bucket");
|
1031 |
+
const retry = res.headers.get("Retry-After");
|
1032 |
+
const scope = res.headers.get("X-RateLimit-Scope") ?? "user";
|
1033 |
+
this.limit = limit ? Number(limit) : Number.POSITIVE_INFINITY;
|
1034 |
+
this.remaining = remaining ? Number(remaining) : 1;
|
1035 |
+
this.reset = reset ? Number(reset) * 1e3 + Date.now() + this.manager.options.offset : Date.now();
|
1036 |
+
if (retry)
|
1037 |
+
retryAfter = Number(retry) * 1e3 + this.manager.options.offset;
|
1038 |
+
if (hash && hash !== this.hash) {
|
1039 |
+
this.debug(["Received bucket hash update", ` Old Hash : ${this.hash}`, ` New Hash : ${hash}`].join("\n"));
|
1040 |
+
this.manager.hashes.set(`${method}:${routeId.bucketRoute}`, { value: hash, lastAccess: Date.now() });
|
1041 |
+
} else if (hash) {
|
1042 |
+
const hashData = this.manager.hashes.get(`${method}:${routeId.bucketRoute}`);
|
1043 |
+
if (hashData) {
|
1044 |
+
hashData.lastAccess = Date.now();
|
1045 |
+
}
|
1046 |
+
}
|
1047 |
+
let sublimitTimeout = null;
|
1048 |
+
if (retryAfter > 0) {
|
1049 |
+
if (res.headers.has("X-RateLimit-Global")) {
|
1050 |
+
this.manager.globalRemaining = 0;
|
1051 |
+
this.manager.globalReset = Date.now() + retryAfter;
|
1052 |
+
} else if (!this.localLimited) {
|
1053 |
+
sublimitTimeout = retryAfter;
|
1054 |
+
}
|
1055 |
+
}
|
1056 |
+
if (status === 401 || status === 403 || status === 429) {
|
1057 |
+
incrementInvalidCount(this.manager);
|
1058 |
+
}
|
1059 |
+
if (res.ok) {
|
1060 |
+
return res;
|
1061 |
+
} else if (status === 429) {
|
1062 |
+
const isGlobal = this.globalLimited;
|
1063 |
+
let limit2;
|
1064 |
+
let timeout;
|
1065 |
+
if (isGlobal) {
|
1066 |
+
limit2 = this.manager.options.globalRequestsPerSecond;
|
1067 |
+
timeout = this.manager.globalReset + this.manager.options.offset - Date.now();
|
1068 |
+
} else {
|
1069 |
+
limit2 = this.limit;
|
1070 |
+
timeout = this.timeToReset;
|
1071 |
+
}
|
1072 |
+
await onRateLimit(this.manager, {
|
1073 |
+
global: isGlobal,
|
1074 |
+
method,
|
1075 |
+
url,
|
1076 |
+
route: routeId.bucketRoute,
|
1077 |
+
majorParameter: this.majorParameter,
|
1078 |
+
hash: this.hash,
|
1079 |
+
limit: limit2,
|
1080 |
+
timeToReset: timeout,
|
1081 |
+
retryAfter,
|
1082 |
+
sublimitTimeout: sublimitTimeout ?? 0,
|
1083 |
+
scope
|
1084 |
+
});
|
1085 |
+
this.debug(
|
1086 |
+
[
|
1087 |
+
"Encountered unexpected 429 rate limit",
|
1088 |
+
` Global : ${isGlobal.toString()}`,
|
1089 |
+
` Method : ${method}`,
|
1090 |
+
` URL : ${url}`,
|
1091 |
+
` Bucket : ${routeId.bucketRoute}`,
|
1092 |
+
` Major parameter: ${routeId.majorParameter}`,
|
1093 |
+
` Hash : ${this.hash}`,
|
1094 |
+
` Limit : ${limit2}`,
|
1095 |
+
` Retry After : ${retryAfter}ms`,
|
1096 |
+
` Sublimit : ${sublimitTimeout ? `${sublimitTimeout}ms` : "None"}`,
|
1097 |
+
` Scope : ${scope}`
|
1098 |
+
].join("\n")
|
1099 |
+
);
|
1100 |
+
if (sublimitTimeout) {
|
1101 |
+
const firstSublimit = !this.#sublimitedQueue;
|
1102 |
+
if (firstSublimit) {
|
1103 |
+
this.#sublimitedQueue = new import_async_queue.AsyncQueue();
|
1104 |
+
void this.#sublimitedQueue.wait();
|
1105 |
+
this.#asyncQueue.shift();
|
1106 |
+
}
|
1107 |
+
this.#sublimitPromise?.resolve();
|
1108 |
+
this.#sublimitPromise = null;
|
1109 |
+
await sleep(sublimitTimeout);
|
1110 |
+
let resolve;
|
1111 |
+
const promise = new Promise((res2) => resolve = res2);
|
1112 |
+
this.#sublimitPromise = { promise, resolve };
|
1113 |
+
if (firstSublimit) {
|
1114 |
+
await this.#asyncQueue.wait();
|
1115 |
+
this.#shiftSublimit = true;
|
1116 |
+
}
|
1117 |
+
}
|
1118 |
+
return this.runRequest(routeId, url, options, requestData, retries);
|
1119 |
+
} else {
|
1120 |
+
const handled = await handleErrors(this.manager, res, method, url, requestData, retries);
|
1121 |
+
if (handled === null) {
|
1122 |
+
return this.runRequest(routeId, url, options, requestData, ++retries);
|
1123 |
+
}
|
1124 |
+
return handled;
|
1125 |
+
}
|
1126 |
+
}
|
1127 |
+
};
|
1128 |
+
|
1129 |
+
// src/lib/REST.ts
|
1130 |
+
var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
|
1131 |
+
static {
|
1132 |
+
__name(this, "REST");
|
1133 |
+
}
|
1134 |
+
/**
|
1135 |
+
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} for all requests
|
1136 |
+
* performed by this manager.
|
1137 |
+
*/
|
1138 |
+
agent = null;
|
1139 |
+
cdn;
|
1140 |
+
/**
|
1141 |
+
* The number of requests remaining in the global bucket
|
1142 |
+
*/
|
1143 |
+
globalRemaining;
|
1144 |
+
/**
|
1145 |
+
* The promise used to wait out the global rate limit
|
1146 |
+
*/
|
1147 |
+
globalDelay = null;
|
1148 |
+
/**
|
1149 |
+
* The timestamp at which the global bucket resets
|
1150 |
+
*/
|
1151 |
+
globalReset = -1;
|
1152 |
+
/**
|
1153 |
+
* API bucket hashes that are cached from provided routes
|
1154 |
+
*/
|
1155 |
+
hashes = new import_collection.Collection();
|
1156 |
+
/**
|
1157 |
+
* Request handlers created from the bucket hash and the major parameters
|
1158 |
+
*/
|
1159 |
+
handlers = new import_collection.Collection();
|
1160 |
+
#token = null;
|
1161 |
+
hashTimer;
|
1162 |
+
handlerTimer;
|
1163 |
+
options;
|
1164 |
+
constructor(options = {}) {
|
1165 |
+
super();
|
1166 |
+
this.cdn = new CDN(options.cdn ?? DefaultRestOptions.cdn);
|
1167 |
+
this.options = { ...DefaultRestOptions, ...options };
|
1168 |
+
this.options.offset = Math.max(0, this.options.offset);
|
1169 |
+
this.globalRemaining = Math.max(1, this.options.globalRequestsPerSecond);
|
1170 |
+
this.agent = options.agent ?? null;
|
1171 |
+
this.setupSweepers();
|
1172 |
+
}
|
1173 |
+
setupSweepers() {
|
1174 |
+
const validateMaxInterval = /* @__PURE__ */ __name((interval) => {
|
1175 |
+
if (interval > 144e5) {
|
1176 |
+
throw new Error("Cannot set an interval greater than 4 hours");
|
1177 |
+
}
|
1178 |
+
}, "validateMaxInterval");
|
1179 |
+
if (this.options.hashSweepInterval !== 0 && this.options.hashSweepInterval !== Number.POSITIVE_INFINITY) {
|
1180 |
+
validateMaxInterval(this.options.hashSweepInterval);
|
1181 |
+
this.hashTimer = setInterval(() => {
|
1182 |
+
const sweptHashes = new import_collection.Collection();
|
1183 |
+
const currentDate = Date.now();
|
1184 |
+
this.hashes.sweep((val, key) => {
|
1185 |
+
if (val.lastAccess === -1)
|
1186 |
+
return false;
|
1187 |
+
const shouldSweep = Math.floor(currentDate - val.lastAccess) > this.options.hashLifetime;
|
1188 |
+
if (shouldSweep) {
|
1189 |
+
sweptHashes.set(key, val);
|
1190 |
+
this.emit("restDebug" /* Debug */, `Hash ${val.value} for ${key} swept due to lifetime being exceeded`);
|
1191 |
+
}
|
1192 |
+
return shouldSweep;
|
1193 |
+
});
|
1194 |
+
this.emit("hashSweep" /* HashSweep */, sweptHashes);
|
1195 |
+
}, this.options.hashSweepInterval);
|
1196 |
+
this.hashTimer.unref?.();
|
1197 |
+
}
|
1198 |
+
if (this.options.handlerSweepInterval !== 0 && this.options.handlerSweepInterval !== Number.POSITIVE_INFINITY) {
|
1199 |
+
validateMaxInterval(this.options.handlerSweepInterval);
|
1200 |
+
this.handlerTimer = setInterval(() => {
|
1201 |
+
const sweptHandlers = new import_collection.Collection();
|
1202 |
+
this.handlers.sweep((val, key) => {
|
1203 |
+
const { inactive } = val;
|
1204 |
+
if (inactive) {
|
1205 |
+
sweptHandlers.set(key, val);
|
1206 |
+
this.emit("restDebug" /* Debug */, `Handler ${val.id} for ${key} swept due to being inactive`);
|
1207 |
+
}
|
1208 |
+
return inactive;
|
1209 |
+
});
|
1210 |
+
this.emit("handlerSweep" /* HandlerSweep */, sweptHandlers);
|
1211 |
+
}, this.options.handlerSweepInterval);
|
1212 |
+
this.handlerTimer.unref?.();
|
1213 |
+
}
|
1214 |
+
}
|
1215 |
+
/**
|
1216 |
+
* Runs a get request from the api
|
1217 |
+
*
|
1218 |
+
* @param fullRoute - The full route to query
|
1219 |
+
* @param options - Optional request options
|
1220 |
+
*/
|
1221 |
+
async get(fullRoute, options = {}) {
|
1222 |
+
return this.request({ ...options, fullRoute, method: "GET" /* Get */ });
|
1223 |
+
}
|
1224 |
+
/**
|
1225 |
+
* Runs a delete request from the api
|
1226 |
+
*
|
1227 |
+
* @param fullRoute - The full route to query
|
1228 |
+
* @param options - Optional request options
|
1229 |
+
*/
|
1230 |
+
async delete(fullRoute, options = {}) {
|
1231 |
+
return this.request({ ...options, fullRoute, method: "DELETE" /* Delete */ });
|
1232 |
+
}
|
1233 |
+
/**
|
1234 |
+
* Runs a post request from the api
|
1235 |
+
*
|
1236 |
+
* @param fullRoute - The full route to query
|
1237 |
+
* @param options - Optional request options
|
1238 |
+
*/
|
1239 |
+
async post(fullRoute, options = {}) {
|
1240 |
+
return this.request({ ...options, fullRoute, method: "POST" /* Post */ });
|
1241 |
+
}
|
1242 |
+
/**
|
1243 |
+
* Runs a put request from the api
|
1244 |
+
*
|
1245 |
+
* @param fullRoute - The full route to query
|
1246 |
+
* @param options - Optional request options
|
1247 |
+
*/
|
1248 |
+
async put(fullRoute, options = {}) {
|
1249 |
+
return this.request({ ...options, fullRoute, method: "PUT" /* Put */ });
|
1250 |
+
}
|
1251 |
+
/**
|
1252 |
+
* Runs a patch request from the api
|
1253 |
+
*
|
1254 |
+
* @param fullRoute - The full route to query
|
1255 |
+
* @param options - Optional request options
|
1256 |
+
*/
|
1257 |
+
async patch(fullRoute, options = {}) {
|
1258 |
+
return this.request({ ...options, fullRoute, method: "PATCH" /* Patch */ });
|
1259 |
+
}
|
1260 |
+
/**
|
1261 |
+
* Runs a request from the api
|
1262 |
+
*
|
1263 |
+
* @param options - Request options
|
1264 |
+
*/
|
1265 |
+
async request(options) {
|
1266 |
+
const response = await this.queueRequest(options);
|
1267 |
+
return parseResponse(response);
|
1268 |
+
}
|
1269 |
+
/**
|
1270 |
+
* Sets the default agent to use for requests performed by this manager
|
1271 |
+
*
|
1272 |
+
* @param agent - The agent to use
|
1273 |
+
*/
|
1274 |
+
setAgent(agent) {
|
1275 |
+
this.agent = agent;
|
1276 |
+
return this;
|
1277 |
+
}
|
1278 |
+
/**
|
1279 |
+
* Sets the authorization token that should be used for requests
|
1280 |
+
*
|
1281 |
+
* @param token - The authorization token to use
|
1282 |
+
*/
|
1283 |
+
setToken(token) {
|
1284 |
+
this.#token = token;
|
1285 |
+
return this;
|
1286 |
+
}
|
1287 |
+
/**
|
1288 |
+
* Queues a request to be sent
|
1289 |
+
*
|
1290 |
+
* @param request - All the information needed to make a request
|
1291 |
+
* @returns The response from the api request
|
1292 |
+
*/
|
1293 |
+
async queueRequest(request2) {
|
1294 |
+
const routeId = _REST.generateRouteData(request2.fullRoute, request2.method);
|
1295 |
+
const hash = this.hashes.get(`${request2.method}:${routeId.bucketRoute}`) ?? {
|
1296 |
+
value: `Global(${request2.method}:${routeId.bucketRoute})`,
|
1297 |
+
lastAccess: -1
|
1298 |
+
};
|
1299 |
+
const handler = this.handlers.get(`${hash.value}:${routeId.majorParameter}`) ?? this.createHandler(hash.value, routeId.majorParameter);
|
1300 |
+
const { url, fetchOptions } = await this.resolveRequest(request2);
|
1301 |
+
return handler.queueRequest(routeId, url, fetchOptions, {
|
1302 |
+
body: request2.body,
|
1303 |
+
files: request2.files,
|
1304 |
+
auth: request2.auth !== false,
|
1305 |
+
signal: request2.signal
|
1306 |
+
});
|
1307 |
+
}
|
1308 |
+
/**
|
1309 |
+
* Creates a new rate limit handler from a hash, based on the hash and the major parameter
|
1310 |
+
*
|
1311 |
+
* @param hash - The hash for the route
|
1312 |
+
* @param majorParameter - The major parameter for this handler
|
1313 |
+
* @internal
|
1314 |
+
*/
|
1315 |
+
createHandler(hash, majorParameter) {
|
1316 |
+
const queue = majorParameter === BurstHandlerMajorIdKey ? new BurstHandler(this, hash, majorParameter) : new SequentialHandler(this, hash, majorParameter);
|
1317 |
+
this.handlers.set(queue.id, queue);
|
1318 |
+
return queue;
|
1319 |
+
}
|
1320 |
+
/**
|
1321 |
+
* Formats the request data to a usable format for fetch
|
1322 |
+
*
|
1323 |
+
* @param request - The request data
|
1324 |
+
*/
|
1325 |
+
async resolveRequest(request2) {
|
1326 |
+
const { options } = this;
|
1327 |
+
let query = "";
|
1328 |
+
if (request2.query) {
|
1329 |
+
const resolvedQuery = request2.query.toString();
|
1330 |
+
if (resolvedQuery !== "") {
|
1331 |
+
query = `?${resolvedQuery}`;
|
1332 |
+
}
|
1333 |
+
}
|
1334 |
+
const headers = {
|
1335 |
+
...this.options.headers,
|
1336 |
+
"User-Agent": `${DefaultUserAgent} ${options.userAgentAppendix}`.trim()
|
1337 |
+
};
|
1338 |
+
if (request2.auth !== false) {
|
1339 |
+
if (!this.#token) {
|
1340 |
+
throw new Error("Expected token to be set for this request, but none was present");
|
1341 |
+
}
|
1342 |
+
headers.Authorization = `${request2.authPrefix ?? this.options.authPrefix} ${this.#token}`;
|
1343 |
+
}
|
1344 |
+
if (request2.reason?.length) {
|
1345 |
+
headers["X-Audit-Log-Reason"] = encodeURIComponent(request2.reason);
|
1346 |
+
}
|
1347 |
+
const url = `${options.api}${request2.versioned === false ? "" : `/v${options.version}`}${request2.fullRoute}${query}`;
|
1348 |
+
let finalBody;
|
1349 |
+
let additionalHeaders = {};
|
1350 |
+
if (request2.files?.length) {
|
1351 |
+
const formData = new FormData();
|
1352 |
+
for (const [index, file] of request2.files.entries()) {
|
1353 |
+
const fileKey = file.key ?? `files[${index}]`;
|
1354 |
+
if (isBufferLike(file.data)) {
|
1355 |
+
let contentType = file.contentType;
|
1356 |
+
if (!contentType) {
|
1357 |
+
const [parsedType] = (0, import_magic_bytes.filetypeinfo)(file.data);
|
1358 |
+
if (parsedType) {
|
1359 |
+
contentType = OverwrittenMimeTypes[parsedType.mime] ?? parsedType.mime ?? "application/octet-stream";
|
1360 |
+
}
|
1361 |
+
}
|
1362 |
+
formData.append(fileKey, new Blob([file.data], { type: contentType }), file.name);
|
1363 |
+
} else {
|
1364 |
+
formData.append(fileKey, new Blob([`${file.data}`], { type: file.contentType }), file.name);
|
1365 |
+
}
|
1366 |
+
}
|
1367 |
+
if (request2.body != null) {
|
1368 |
+
if (request2.appendToFormData) {
|
1369 |
+
for (const [key, value] of Object.entries(request2.body)) {
|
1370 |
+
formData.append(key, value);
|
1371 |
+
}
|
1372 |
+
} else {
|
1373 |
+
formData.append("payload_json", JSON.stringify(request2.body));
|
1374 |
+
}
|
1375 |
+
}
|
1376 |
+
finalBody = formData;
|
1377 |
+
} else if (request2.body != null) {
|
1378 |
+
if (request2.passThroughBody) {
|
1379 |
+
finalBody = request2.body;
|
1380 |
+
} else {
|
1381 |
+
finalBody = JSON.stringify(request2.body);
|
1382 |
+
additionalHeaders = { "Content-Type": "application/json" };
|
1383 |
+
}
|
1384 |
+
}
|
1385 |
+
const method = request2.method.toUpperCase();
|
1386 |
+
const fetchOptions = {
|
1387 |
+
// Set body to null on get / head requests. This does not follow fetch spec (likely because it causes subtle bugs) but is aligned with what request was doing
|
1388 |
+
body: ["GET", "HEAD"].includes(method) ? null : finalBody,
|
1389 |
+
headers: { ...request2.headers, ...additionalHeaders, ...headers },
|
1390 |
+
method,
|
1391 |
+
// Prioritize setting an agent per request, use the agent for this instance otherwise.
|
1392 |
+
dispatcher: request2.dispatcher ?? this.agent ?? void 0
|
1393 |
+
};
|
1394 |
+
return { url, fetchOptions };
|
1395 |
+
}
|
1396 |
+
/**
|
1397 |
+
* Stops the hash sweeping interval
|
1398 |
+
*/
|
1399 |
+
clearHashSweeper() {
|
1400 |
+
clearInterval(this.hashTimer);
|
1401 |
+
}
|
1402 |
+
/**
|
1403 |
+
* Stops the request handler sweeping interval
|
1404 |
+
*/
|
1405 |
+
clearHandlerSweeper() {
|
1406 |
+
clearInterval(this.handlerTimer);
|
1407 |
+
}
|
1408 |
+
/**
|
1409 |
+
* Generates route data for an endpoint:method
|
1410 |
+
*
|
1411 |
+
* @param endpoint - The raw endpoint to generalize
|
1412 |
+
* @param method - The HTTP method this endpoint is called without
|
1413 |
+
* @internal
|
1414 |
+
*/
|
1415 |
+
static generateRouteData(endpoint, method) {
|
1416 |
+
if (endpoint.startsWith("/interactions/") && endpoint.endsWith("/callback")) {
|
1417 |
+
return {
|
1418 |
+
majorParameter: BurstHandlerMajorIdKey,
|
1419 |
+
bucketRoute: "/interactions/:id/:token/callback",
|
1420 |
+
original: endpoint
|
1421 |
+
};
|
1422 |
+
}
|
1423 |
+
const majorIdMatch = /(?:^\/webhooks\/(\d{17,19}\/[^/?]+))|(?:^\/(?:channels|guilds|webhooks)\/(\d{17,19}))/.exec(
|
1424 |
+
endpoint
|
1425 |
+
);
|
1426 |
+
const majorId = majorIdMatch?.[2] ?? majorIdMatch?.[1] ?? "global";
|
1427 |
+
const baseRoute = endpoint.replaceAll(/\d{17,19}/g, ":id").replace(/\/reactions\/(.*)/, "/reactions/:reaction").replace(/\/webhooks\/:id\/[^/?]+/, "/webhooks/:id/:token");
|
1428 |
+
let exceptions = "";
|
1429 |
+
if (method === "DELETE" /* Delete */ && baseRoute === "/channels/:id/messages/:id") {
|
1430 |
+
const id = /\d{17,19}$/.exec(endpoint)[0];
|
1431 |
+
const timestamp = import_snowflake.DiscordSnowflake.timestampFrom(id);
|
1432 |
+
if (Date.now() - timestamp > 1e3 * 60 * 60 * 24 * 14) {
|
1433 |
+
exceptions += "/Delete Old Message";
|
1434 |
+
}
|
1435 |
+
}
|
1436 |
+
return {
|
1437 |
+
majorParameter: majorId,
|
1438 |
+
bucketRoute: baseRoute + exceptions,
|
1439 |
+
original: endpoint
|
1440 |
+
};
|
1441 |
+
}
|
1442 |
+
};
|
1443 |
+
|
1444 |
+
// src/shared.ts
|
1445 |
+
var version = "2.2.0";
|
1446 |
+
|
1447 |
+
// src/index.ts
|
1448 |
+
globalThis.FormData ??= import_undici2.FormData;
|
1449 |
+
globalThis.Blob ??= import_node_buffer.Blob;
|
1450 |
+
setDefaultStrategy((0, import_util2.shouldUseGlobalFetchAndWebSocket)() ? fetch : makeRequest);
|
1451 |
+
// Annotate the CommonJS export names for ESM import in node:
|
1452 |
+
0 && (module.exports = {
|
1453 |
+
ALLOWED_EXTENSIONS,
|
1454 |
+
ALLOWED_SIZES,
|
1455 |
+
ALLOWED_STICKER_EXTENSIONS,
|
1456 |
+
BurstHandlerMajorIdKey,
|
1457 |
+
CDN,
|
1458 |
+
DEPRECATION_WARNING_PREFIX,
|
1459 |
+
DefaultRestOptions,
|
1460 |
+
DefaultUserAgent,
|
1461 |
+
DefaultUserAgentAppendix,
|
1462 |
+
DiscordAPIError,
|
1463 |
+
HTTPError,
|
1464 |
+
OverwrittenMimeTypes,
|
1465 |
+
REST,
|
1466 |
+
RESTEvents,
|
1467 |
+
RateLimitError,
|
1468 |
+
RequestMethod,
|
1469 |
+
calculateUserDefaultAvatarIndex,
|
1470 |
+
makeURLSearchParams,
|
1471 |
+
parseResponse,
|
1472 |
+
version
|
1473 |
+
});
|
1474 |
+
//# sourceMappingURL=index.js.map
|
node_modules/@discordjs/rest/dist/index.js.map
ADDED
The diff for this file is too large to render.
See raw diff
|
|
node_modules/@discordjs/rest/dist/index.mjs
ADDED
@@ -0,0 +1,1432 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var __defProp = Object.defineProperty;
|
2 |
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
3 |
+
|
4 |
+
// src/index.ts
|
5 |
+
import { Blob as Blob2 } from "node:buffer";
|
6 |
+
import { shouldUseGlobalFetchAndWebSocket } from "@discordjs/util";
|
7 |
+
import { FormData as FormData2 } from "undici";
|
8 |
+
|
9 |
+
// src/environment.ts
|
10 |
+
var defaultStrategy;
|
11 |
+
function setDefaultStrategy(newStrategy) {
|
12 |
+
defaultStrategy = newStrategy;
|
13 |
+
}
|
14 |
+
__name(setDefaultStrategy, "setDefaultStrategy");
|
15 |
+
function getDefaultStrategy() {
|
16 |
+
return defaultStrategy;
|
17 |
+
}
|
18 |
+
__name(getDefaultStrategy, "getDefaultStrategy");
|
19 |
+
|
20 |
+
// src/strategies/undiciRequest.ts
|
21 |
+
import { STATUS_CODES } from "node:http";
|
22 |
+
import { URLSearchParams as URLSearchParams2 } from "node:url";
|
23 |
+
import { types } from "node:util";
|
24 |
+
import { request, Headers } from "undici";
|
25 |
+
async function makeRequest(url, init) {
|
26 |
+
const options = {
|
27 |
+
...init,
|
28 |
+
body: await resolveBody(init.body)
|
29 |
+
};
|
30 |
+
const res = await request(url, options);
|
31 |
+
return {
|
32 |
+
body: res.body,
|
33 |
+
async arrayBuffer() {
|
34 |
+
return res.body.arrayBuffer();
|
35 |
+
},
|
36 |
+
async json() {
|
37 |
+
return res.body.json();
|
38 |
+
},
|
39 |
+
async text() {
|
40 |
+
return res.body.text();
|
41 |
+
},
|
42 |
+
get bodyUsed() {
|
43 |
+
return res.body.bodyUsed;
|
44 |
+
},
|
45 |
+
headers: new Headers(res.headers),
|
46 |
+
status: res.statusCode,
|
47 |
+
statusText: STATUS_CODES[res.statusCode],
|
48 |
+
ok: res.statusCode >= 200 && res.statusCode < 300
|
49 |
+
};
|
50 |
+
}
|
51 |
+
__name(makeRequest, "makeRequest");
|
52 |
+
async function resolveBody(body) {
|
53 |
+
if (body == null) {
|
54 |
+
return null;
|
55 |
+
} else if (typeof body === "string") {
|
56 |
+
return body;
|
57 |
+
} else if (types.isUint8Array(body)) {
|
58 |
+
return body;
|
59 |
+
} else if (types.isArrayBuffer(body)) {
|
60 |
+
return new Uint8Array(body);
|
61 |
+
} else if (body instanceof URLSearchParams2) {
|
62 |
+
return body.toString();
|
63 |
+
} else if (body instanceof DataView) {
|
64 |
+
return new Uint8Array(body.buffer);
|
65 |
+
} else if (body instanceof Blob) {
|
66 |
+
return new Uint8Array(await body.arrayBuffer());
|
67 |
+
} else if (body instanceof FormData) {
|
68 |
+
return body;
|
69 |
+
} else if (body[Symbol.iterator]) {
|
70 |
+
const chunks = [...body];
|
71 |
+
return Buffer.concat(chunks);
|
72 |
+
} else if (body[Symbol.asyncIterator]) {
|
73 |
+
const chunks = [];
|
74 |
+
for await (const chunk of body) {
|
75 |
+
chunks.push(chunk);
|
76 |
+
}
|
77 |
+
return Buffer.concat(chunks);
|
78 |
+
}
|
79 |
+
throw new TypeError(`Unable to resolve body.`);
|
80 |
+
}
|
81 |
+
__name(resolveBody, "resolveBody");
|
82 |
+
|
83 |
+
// src/lib/utils/constants.ts
|
84 |
+
import { getUserAgentAppendix } from "@discordjs/util";
|
85 |
+
import { APIVersion } from "discord-api-types/v10";
|
86 |
+
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 2.2.0)`;
|
87 |
+
var DefaultUserAgentAppendix = getUserAgentAppendix();
|
88 |
+
var DefaultRestOptions = {
|
89 |
+
agent: null,
|
90 |
+
api: "https://discord.com/api",
|
91 |
+
authPrefix: "Bot",
|
92 |
+
cdn: "https://cdn.discordapp.com",
|
93 |
+
headers: {},
|
94 |
+
invalidRequestWarningInterval: 0,
|
95 |
+
globalRequestsPerSecond: 50,
|
96 |
+
offset: 50,
|
97 |
+
rejectOnRateLimit: null,
|
98 |
+
retries: 3,
|
99 |
+
timeout: 15e3,
|
100 |
+
userAgentAppendix: DefaultUserAgentAppendix,
|
101 |
+
version: APIVersion,
|
102 |
+
hashSweepInterval: 144e5,
|
103 |
+
// 4 Hours
|
104 |
+
hashLifetime: 864e5,
|
105 |
+
// 24 Hours
|
106 |
+
handlerSweepInterval: 36e5,
|
107 |
+
// 1 Hour
|
108 |
+
async makeRequest(...args) {
|
109 |
+
return getDefaultStrategy()(...args);
|
110 |
+
}
|
111 |
+
};
|
112 |
+
var RESTEvents = /* @__PURE__ */ ((RESTEvents2) => {
|
113 |
+
RESTEvents2["Debug"] = "restDebug";
|
114 |
+
RESTEvents2["HandlerSweep"] = "handlerSweep";
|
115 |
+
RESTEvents2["HashSweep"] = "hashSweep";
|
116 |
+
RESTEvents2["InvalidRequestWarning"] = "invalidRequestWarning";
|
117 |
+
RESTEvents2["RateLimited"] = "rateLimited";
|
118 |
+
RESTEvents2["Response"] = "response";
|
119 |
+
return RESTEvents2;
|
120 |
+
})(RESTEvents || {});
|
121 |
+
var ALLOWED_EXTENSIONS = ["webp", "png", "jpg", "jpeg", "gif"];
|
122 |
+
var ALLOWED_STICKER_EXTENSIONS = ["png", "json", "gif"];
|
123 |
+
var ALLOWED_SIZES = [16, 32, 64, 128, 256, 512, 1024, 2048, 4096];
|
124 |
+
var OverwrittenMimeTypes = {
|
125 |
+
// https://github.com/discordjs/discord.js/issues/8557
|
126 |
+
"image/apng": "image/png"
|
127 |
+
};
|
128 |
+
var BurstHandlerMajorIdKey = "burst";
|
129 |
+
var DEPRECATION_WARNING_PREFIX = "DeprecationWarning";
|
130 |
+
|
131 |
+
// src/lib/errors/RateLimitError.ts
|
132 |
+
var RateLimitError = class _RateLimitError extends Error {
|
133 |
+
static {
|
134 |
+
__name(this, "RateLimitError");
|
135 |
+
}
|
136 |
+
timeToReset;
|
137 |
+
limit;
|
138 |
+
method;
|
139 |
+
hash;
|
140 |
+
url;
|
141 |
+
route;
|
142 |
+
majorParameter;
|
143 |
+
global;
|
144 |
+
retryAfter;
|
145 |
+
sublimitTimeout;
|
146 |
+
scope;
|
147 |
+
constructor({
|
148 |
+
timeToReset,
|
149 |
+
limit,
|
150 |
+
method,
|
151 |
+
hash,
|
152 |
+
url,
|
153 |
+
route,
|
154 |
+
majorParameter,
|
155 |
+
global,
|
156 |
+
retryAfter,
|
157 |
+
sublimitTimeout,
|
158 |
+
scope
|
159 |
+
}) {
|
160 |
+
super();
|
161 |
+
this.timeToReset = timeToReset;
|
162 |
+
this.limit = limit;
|
163 |
+
this.method = method;
|
164 |
+
this.hash = hash;
|
165 |
+
this.url = url;
|
166 |
+
this.route = route;
|
167 |
+
this.majorParameter = majorParameter;
|
168 |
+
this.global = global;
|
169 |
+
this.retryAfter = retryAfter;
|
170 |
+
this.sublimitTimeout = sublimitTimeout;
|
171 |
+
this.scope = scope;
|
172 |
+
}
|
173 |
+
/**
|
174 |
+
* The name of the error
|
175 |
+
*/
|
176 |
+
get name() {
|
177 |
+
return `${_RateLimitError.name}[${this.route}]`;
|
178 |
+
}
|
179 |
+
};
|
180 |
+
|
181 |
+
// src/lib/utils/types.ts
|
182 |
+
var RequestMethod = /* @__PURE__ */ ((RequestMethod2) => {
|
183 |
+
RequestMethod2["Delete"] = "DELETE";
|
184 |
+
RequestMethod2["Get"] = "GET";
|
185 |
+
RequestMethod2["Patch"] = "PATCH";
|
186 |
+
RequestMethod2["Post"] = "POST";
|
187 |
+
RequestMethod2["Put"] = "PUT";
|
188 |
+
return RequestMethod2;
|
189 |
+
})(RequestMethod || {});
|
190 |
+
|
191 |
+
// src/lib/utils/utils.ts
|
192 |
+
function serializeSearchParam(value) {
|
193 |
+
switch (typeof value) {
|
194 |
+
case "string":
|
195 |
+
return value;
|
196 |
+
case "number":
|
197 |
+
case "bigint":
|
198 |
+
case "boolean":
|
199 |
+
return value.toString();
|
200 |
+
case "object":
|
201 |
+
if (value === null)
|
202 |
+
return null;
|
203 |
+
if (value instanceof Date) {
|
204 |
+
return Number.isNaN(value.getTime()) ? null : value.toISOString();
|
205 |
+
}
|
206 |
+
if (typeof value.toString === "function" && value.toString !== Object.prototype.toString)
|
207 |
+
return value.toString();
|
208 |
+
return null;
|
209 |
+
default:
|
210 |
+
return null;
|
211 |
+
}
|
212 |
+
}
|
213 |
+
__name(serializeSearchParam, "serializeSearchParam");
|
214 |
+
function makeURLSearchParams(options) {
|
215 |
+
const params = new URLSearchParams();
|
216 |
+
if (!options)
|
217 |
+
return params;
|
218 |
+
for (const [key, value] of Object.entries(options)) {
|
219 |
+
const serialized = serializeSearchParam(value);
|
220 |
+
if (serialized !== null)
|
221 |
+
params.append(key, serialized);
|
222 |
+
}
|
223 |
+
return params;
|
224 |
+
}
|
225 |
+
__name(makeURLSearchParams, "makeURLSearchParams");
|
226 |
+
async function parseResponse(res) {
|
227 |
+
if (res.headers.get("Content-Type")?.startsWith("application/json")) {
|
228 |
+
return res.json();
|
229 |
+
}
|
230 |
+
return res.arrayBuffer();
|
231 |
+
}
|
232 |
+
__name(parseResponse, "parseResponse");
|
233 |
+
function hasSublimit(bucketRoute, body, method) {
|
234 |
+
if (bucketRoute === "/channels/:id") {
|
235 |
+
if (typeof body !== "object" || body === null)
|
236 |
+
return false;
|
237 |
+
if (method !== "PATCH" /* Patch */)
|
238 |
+
return false;
|
239 |
+
const castedBody = body;
|
240 |
+
return ["name", "topic"].some((key) => Reflect.has(castedBody, key));
|
241 |
+
}
|
242 |
+
return true;
|
243 |
+
}
|
244 |
+
__name(hasSublimit, "hasSublimit");
|
245 |
+
function shouldRetry(error) {
|
246 |
+
if (error.name === "AbortError")
|
247 |
+
return true;
|
248 |
+
return "code" in error && error.code === "ECONNRESET" || error.message.includes("ECONNRESET");
|
249 |
+
}
|
250 |
+
__name(shouldRetry, "shouldRetry");
|
251 |
+
async function onRateLimit(manager, rateLimitData) {
|
252 |
+
const { options } = manager;
|
253 |
+
if (!options.rejectOnRateLimit)
|
254 |
+
return;
|
255 |
+
const shouldThrow = typeof options.rejectOnRateLimit === "function" ? await options.rejectOnRateLimit(rateLimitData) : options.rejectOnRateLimit.some((route) => rateLimitData.route.startsWith(route.toLowerCase()));
|
256 |
+
if (shouldThrow) {
|
257 |
+
throw new RateLimitError(rateLimitData);
|
258 |
+
}
|
259 |
+
}
|
260 |
+
__name(onRateLimit, "onRateLimit");
|
261 |
+
function calculateUserDefaultAvatarIndex(userId) {
|
262 |
+
return Number(BigInt(userId) >> 22n) % 6;
|
263 |
+
}
|
264 |
+
__name(calculateUserDefaultAvatarIndex, "calculateUserDefaultAvatarIndex");
|
265 |
+
async function sleep(ms) {
|
266 |
+
return new Promise((resolve) => {
|
267 |
+
setTimeout(() => resolve(), ms);
|
268 |
+
});
|
269 |
+
}
|
270 |
+
__name(sleep, "sleep");
|
271 |
+
function isBufferLike(value) {
|
272 |
+
return value instanceof ArrayBuffer || value instanceof Uint8Array || value instanceof Uint8ClampedArray;
|
273 |
+
}
|
274 |
+
__name(isBufferLike, "isBufferLike");
|
275 |
+
function deprecationWarning(message) {
|
276 |
+
if (typeof globalThis.process === "undefined") {
|
277 |
+
console.warn(`${DEPRECATION_WARNING_PREFIX}: ${message}`);
|
278 |
+
} else {
|
279 |
+
process.emitWarning(message, DEPRECATION_WARNING_PREFIX);
|
280 |
+
}
|
281 |
+
}
|
282 |
+
__name(deprecationWarning, "deprecationWarning");
|
283 |
+
|
284 |
+
// src/lib/CDN.ts
|
285 |
+
var deprecationEmittedForEmoji = false;
|
286 |
+
var CDN = class {
|
287 |
+
constructor(base = DefaultRestOptions.cdn) {
|
288 |
+
this.base = base;
|
289 |
+
}
|
290 |
+
static {
|
291 |
+
__name(this, "CDN");
|
292 |
+
}
|
293 |
+
/**
|
294 |
+
* Generates an app asset URL for a client's asset.
|
295 |
+
*
|
296 |
+
* @param clientId - The client id that has the asset
|
297 |
+
* @param assetHash - The hash provided by Discord for this asset
|
298 |
+
* @param options - Optional options for the asset
|
299 |
+
*/
|
300 |
+
appAsset(clientId, assetHash, options) {
|
301 |
+
return this.makeURL(`/app-assets/${clientId}/${assetHash}`, options);
|
302 |
+
}
|
303 |
+
/**
|
304 |
+
* Generates an app icon URL for a client's icon.
|
305 |
+
*
|
306 |
+
* @param clientId - The client id that has the icon
|
307 |
+
* @param iconHash - The hash provided by Discord for this icon
|
308 |
+
* @param options - Optional options for the icon
|
309 |
+
*/
|
310 |
+
appIcon(clientId, iconHash, options) {
|
311 |
+
return this.makeURL(`/app-icons/${clientId}/${iconHash}`, options);
|
312 |
+
}
|
313 |
+
/**
|
314 |
+
* Generates an avatar URL, e.g. for a user or a webhook.
|
315 |
+
*
|
316 |
+
* @param id - The id that has the icon
|
317 |
+
* @param avatarHash - The hash provided by Discord for this avatar
|
318 |
+
* @param options - Optional options for the avatar
|
319 |
+
*/
|
320 |
+
avatar(id, avatarHash, options) {
|
321 |
+
return this.dynamicMakeURL(`/avatars/${id}/${avatarHash}`, avatarHash, options);
|
322 |
+
}
|
323 |
+
/**
|
324 |
+
* Generates a user avatar decoration URL.
|
325 |
+
*
|
326 |
+
* @param userId - The id of the user
|
327 |
+
* @param userAvatarDecoration - The hash provided by Discord for this avatar decoration
|
328 |
+
* @param options - Optional options for the avatar decoration
|
329 |
+
*/
|
330 |
+
avatarDecoration(userId, userAvatarDecoration, options) {
|
331 |
+
return this.makeURL(`/avatar-decorations/${userId}/${userAvatarDecoration}`, options);
|
332 |
+
}
|
333 |
+
/**
|
334 |
+
* Generates a banner URL, e.g. for a user or a guild.
|
335 |
+
*
|
336 |
+
* @param id - The id that has the banner splash
|
337 |
+
* @param bannerHash - The hash provided by Discord for this banner
|
338 |
+
* @param options - Optional options for the banner
|
339 |
+
*/
|
340 |
+
banner(id, bannerHash, options) {
|
341 |
+
return this.dynamicMakeURL(`/banners/${id}/${bannerHash}`, bannerHash, options);
|
342 |
+
}
|
343 |
+
/**
|
344 |
+
* Generates an icon URL for a channel, e.g. a group DM.
|
345 |
+
*
|
346 |
+
* @param channelId - The channel id that has the icon
|
347 |
+
* @param iconHash - The hash provided by Discord for this channel
|
348 |
+
* @param options - Optional options for the icon
|
349 |
+
*/
|
350 |
+
channelIcon(channelId, iconHash, options) {
|
351 |
+
return this.makeURL(`/channel-icons/${channelId}/${iconHash}`, options);
|
352 |
+
}
|
353 |
+
/**
|
354 |
+
* Generates a default avatar URL
|
355 |
+
*
|
356 |
+
* @param index - The default avatar index
|
357 |
+
* @remarks
|
358 |
+
* To calculate the index for a user do `(userId >> 22) % 6`,
|
359 |
+
* or `discriminator % 5` if they're using the legacy username system.
|
360 |
+
*/
|
361 |
+
defaultAvatar(index) {
|
362 |
+
return this.makeURL(`/embed/avatars/${index}`, { extension: "png" });
|
363 |
+
}
|
364 |
+
/**
|
365 |
+
* Generates a discovery splash URL for a guild's discovery splash.
|
366 |
+
*
|
367 |
+
* @param guildId - The guild id that has the discovery splash
|
368 |
+
* @param splashHash - The hash provided by Discord for this splash
|
369 |
+
* @param options - Optional options for the splash
|
370 |
+
*/
|
371 |
+
discoverySplash(guildId, splashHash, options) {
|
372 |
+
return this.makeURL(`/discovery-splashes/${guildId}/${splashHash}`, options);
|
373 |
+
}
|
374 |
+
emoji(emojiId, options) {
|
375 |
+
let resolvedOptions;
|
376 |
+
if (typeof options === "string") {
|
377 |
+
if (!deprecationEmittedForEmoji) {
|
378 |
+
deprecationWarning(
|
379 |
+
"Passing a string for the second parameter of CDN#emoji() is deprecated. Use an object instead."
|
380 |
+
);
|
381 |
+
deprecationEmittedForEmoji = true;
|
382 |
+
}
|
383 |
+
resolvedOptions = { extension: options };
|
384 |
+
} else {
|
385 |
+
resolvedOptions = options;
|
386 |
+
}
|
387 |
+
return this.makeURL(`/emojis/${emojiId}`, resolvedOptions);
|
388 |
+
}
|
389 |
+
/**
|
390 |
+
* Generates a guild member avatar URL.
|
391 |
+
*
|
392 |
+
* @param guildId - The id of the guild
|
393 |
+
* @param userId - The id of the user
|
394 |
+
* @param avatarHash - The hash provided by Discord for this avatar
|
395 |
+
* @param options - Optional options for the avatar
|
396 |
+
*/
|
397 |
+
guildMemberAvatar(guildId, userId, avatarHash, options) {
|
398 |
+
return this.dynamicMakeURL(`/guilds/${guildId}/users/${userId}/avatars/${avatarHash}`, avatarHash, options);
|
399 |
+
}
|
400 |
+
/**
|
401 |
+
* Generates a guild member banner URL.
|
402 |
+
*
|
403 |
+
* @param guildId - The id of the guild
|
404 |
+
* @param userId - The id of the user
|
405 |
+
* @param bannerHash - The hash provided by Discord for this banner
|
406 |
+
* @param options - Optional options for the banner
|
407 |
+
*/
|
408 |
+
guildMemberBanner(guildId, userId, bannerHash, options) {
|
409 |
+
return this.dynamicMakeURL(`/guilds/${guildId}/users/${userId}/banner`, bannerHash, options);
|
410 |
+
}
|
411 |
+
/**
|
412 |
+
* Generates an icon URL, e.g. for a guild.
|
413 |
+
*
|
414 |
+
* @param id - The id that has the icon splash
|
415 |
+
* @param iconHash - The hash provided by Discord for this icon
|
416 |
+
* @param options - Optional options for the icon
|
417 |
+
*/
|
418 |
+
icon(id, iconHash, options) {
|
419 |
+
return this.dynamicMakeURL(`/icons/${id}/${iconHash}`, iconHash, options);
|
420 |
+
}
|
421 |
+
/**
|
422 |
+
* Generates a URL for the icon of a role
|
423 |
+
*
|
424 |
+
* @param roleId - The id of the role that has the icon
|
425 |
+
* @param roleIconHash - The hash provided by Discord for this role icon
|
426 |
+
* @param options - Optional options for the role icon
|
427 |
+
*/
|
428 |
+
roleIcon(roleId, roleIconHash, options) {
|
429 |
+
return this.makeURL(`/role-icons/${roleId}/${roleIconHash}`, options);
|
430 |
+
}
|
431 |
+
/**
|
432 |
+
* Generates a guild invite splash URL for a guild's invite splash.
|
433 |
+
*
|
434 |
+
* @param guildId - The guild id that has the invite splash
|
435 |
+
* @param splashHash - The hash provided by Discord for this splash
|
436 |
+
* @param options - Optional options for the splash
|
437 |
+
*/
|
438 |
+
splash(guildId, splashHash, options) {
|
439 |
+
return this.makeURL(`/splashes/${guildId}/${splashHash}`, options);
|
440 |
+
}
|
441 |
+
/**
|
442 |
+
* Generates a sticker URL.
|
443 |
+
*
|
444 |
+
* @param stickerId - The sticker id
|
445 |
+
* @param extension - The extension of the sticker
|
446 |
+
* @privateRemarks
|
447 |
+
* Stickers cannot have a `.webp` extension, so we default to a `.png`
|
448 |
+
*/
|
449 |
+
sticker(stickerId, extension = "png") {
|
450 |
+
return this.makeURL(`/stickers/${stickerId}`, { allowedExtensions: ALLOWED_STICKER_EXTENSIONS, extension });
|
451 |
+
}
|
452 |
+
/**
|
453 |
+
* Generates a sticker pack banner URL.
|
454 |
+
*
|
455 |
+
* @param bannerId - The banner id
|
456 |
+
* @param options - Optional options for the banner
|
457 |
+
*/
|
458 |
+
stickerPackBanner(bannerId, options) {
|
459 |
+
return this.makeURL(`/app-assets/710982414301790216/store/${bannerId}`, options);
|
460 |
+
}
|
461 |
+
/**
|
462 |
+
* Generates a team icon URL for a team's icon.
|
463 |
+
*
|
464 |
+
* @param teamId - The team id that has the icon
|
465 |
+
* @param iconHash - The hash provided by Discord for this icon
|
466 |
+
* @param options - Optional options for the icon
|
467 |
+
*/
|
468 |
+
teamIcon(teamId, iconHash, options) {
|
469 |
+
return this.makeURL(`/team-icons/${teamId}/${iconHash}`, options);
|
470 |
+
}
|
471 |
+
/**
|
472 |
+
* Generates a cover image for a guild scheduled event.
|
473 |
+
*
|
474 |
+
* @param scheduledEventId - The scheduled event id
|
475 |
+
* @param coverHash - The hash provided by discord for this cover image
|
476 |
+
* @param options - Optional options for the cover image
|
477 |
+
*/
|
478 |
+
guildScheduledEventCover(scheduledEventId, coverHash, options) {
|
479 |
+
return this.makeURL(`/guild-events/${scheduledEventId}/${coverHash}`, options);
|
480 |
+
}
|
481 |
+
/**
|
482 |
+
* Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
|
483 |
+
*
|
484 |
+
* @param route - The base cdn route
|
485 |
+
* @param hash - The hash provided by Discord for this icon
|
486 |
+
* @param options - Optional options for the link
|
487 |
+
*/
|
488 |
+
dynamicMakeURL(route, hash, { forceStatic = false, ...options } = {}) {
|
489 |
+
return this.makeURL(route, !forceStatic && hash.startsWith("a_") ? { ...options, extension: "gif" } : options);
|
490 |
+
}
|
491 |
+
/**
|
492 |
+
* Constructs the URL for the resource
|
493 |
+
*
|
494 |
+
* @param route - The base cdn route
|
495 |
+
* @param options - The extension/size options for the link
|
496 |
+
*/
|
497 |
+
makeURL(route, { allowedExtensions = ALLOWED_EXTENSIONS, extension = "webp", size } = {}) {
|
498 |
+
extension = String(extension).toLowerCase();
|
499 |
+
if (!allowedExtensions.includes(extension)) {
|
500 |
+
throw new RangeError(`Invalid extension provided: ${extension}
|
501 |
+
Must be one of: ${allowedExtensions.join(", ")}`);
|
502 |
+
}
|
503 |
+
if (size && !ALLOWED_SIZES.includes(size)) {
|
504 |
+
throw new RangeError(`Invalid size provided: ${size}
|
505 |
+
Must be one of: ${ALLOWED_SIZES.join(", ")}`);
|
506 |
+
}
|
507 |
+
const url = new URL(`${this.base}${route}.${extension}`);
|
508 |
+
if (size) {
|
509 |
+
url.searchParams.set("size", String(size));
|
510 |
+
}
|
511 |
+
return url.toString();
|
512 |
+
}
|
513 |
+
};
|
514 |
+
|
515 |
+
// src/lib/errors/DiscordAPIError.ts
|
516 |
+
function isErrorGroupWrapper(error) {
|
517 |
+
return Reflect.has(error, "_errors");
|
518 |
+
}
|
519 |
+
__name(isErrorGroupWrapper, "isErrorGroupWrapper");
|
520 |
+
function isErrorResponse(error) {
|
521 |
+
return typeof Reflect.get(error, "message") === "string";
|
522 |
+
}
|
523 |
+
__name(isErrorResponse, "isErrorResponse");
|
524 |
+
var DiscordAPIError = class _DiscordAPIError extends Error {
|
525 |
+
/**
|
526 |
+
* @param rawError - The error reported by Discord
|
527 |
+
* @param code - The error code reported by Discord
|
528 |
+
* @param status - The status code of the response
|
529 |
+
* @param method - The method of the request that erred
|
530 |
+
* @param url - The url of the request that erred
|
531 |
+
* @param bodyData - The unparsed data for the request that errored
|
532 |
+
*/
|
533 |
+
constructor(rawError, code, status, method, url, bodyData) {
|
534 |
+
super(_DiscordAPIError.getMessage(rawError));
|
535 |
+
this.rawError = rawError;
|
536 |
+
this.code = code;
|
537 |
+
this.status = status;
|
538 |
+
this.method = method;
|
539 |
+
this.url = url;
|
540 |
+
this.requestBody = { files: bodyData.files, json: bodyData.body };
|
541 |
+
}
|
542 |
+
static {
|
543 |
+
__name(this, "DiscordAPIError");
|
544 |
+
}
|
545 |
+
requestBody;
|
546 |
+
/**
|
547 |
+
* The name of the error
|
548 |
+
*/
|
549 |
+
get name() {
|
550 |
+
return `${_DiscordAPIError.name}[${this.code}]`;
|
551 |
+
}
|
552 |
+
static getMessage(error) {
|
553 |
+
let flattened = "";
|
554 |
+
if ("code" in error) {
|
555 |
+
if (error.errors) {
|
556 |
+
flattened = [...this.flattenDiscordError(error.errors)].join("\n");
|
557 |
+
}
|
558 |
+
return error.message && flattened ? `${error.message}
|
559 |
+
${flattened}` : error.message || flattened || "Unknown Error";
|
560 |
+
}
|
561 |
+
return error.error_description ?? "No Description";
|
562 |
+
}
|
563 |
+
static *flattenDiscordError(obj, key = "") {
|
564 |
+
if (isErrorResponse(obj)) {
|
565 |
+
return yield `${key.length ? `${key}[${obj.code}]` : `${obj.code}`}: ${obj.message}`.trim();
|
566 |
+
}
|
567 |
+
for (const [otherKey, val] of Object.entries(obj)) {
|
568 |
+
const nextKey = otherKey.startsWith("_") ? key : key ? Number.isNaN(Number(otherKey)) ? `${key}.${otherKey}` : `${key}[${otherKey}]` : otherKey;
|
569 |
+
if (typeof val === "string") {
|
570 |
+
yield val;
|
571 |
+
} else if (isErrorGroupWrapper(val)) {
|
572 |
+
for (const error of val._errors) {
|
573 |
+
yield* this.flattenDiscordError(error, nextKey);
|
574 |
+
}
|
575 |
+
} else {
|
576 |
+
yield* this.flattenDiscordError(val, nextKey);
|
577 |
+
}
|
578 |
+
}
|
579 |
+
}
|
580 |
+
};
|
581 |
+
|
582 |
+
// src/lib/errors/HTTPError.ts
|
583 |
+
var HTTPError = class _HTTPError extends Error {
|
584 |
+
/**
|
585 |
+
* @param status - The status code of the response
|
586 |
+
* @param statusText - The status text of the response
|
587 |
+
* @param method - The method of the request that erred
|
588 |
+
* @param url - The url of the request that erred
|
589 |
+
* @param bodyData - The unparsed data for the request that errored
|
590 |
+
*/
|
591 |
+
constructor(status, statusText, method, url, bodyData) {
|
592 |
+
super(statusText);
|
593 |
+
this.status = status;
|
594 |
+
this.method = method;
|
595 |
+
this.url = url;
|
596 |
+
this.requestBody = { files: bodyData.files, json: bodyData.body };
|
597 |
+
}
|
598 |
+
static {
|
599 |
+
__name(this, "HTTPError");
|
600 |
+
}
|
601 |
+
requestBody;
|
602 |
+
name = _HTTPError.name;
|
603 |
+
};
|
604 |
+
|
605 |
+
// src/lib/REST.ts
|
606 |
+
import { Collection } from "@discordjs/collection";
|
607 |
+
import { DiscordSnowflake } from "@sapphire/snowflake";
|
608 |
+
import { AsyncEventEmitter } from "@vladfrangu/async_event_emitter";
|
609 |
+
import { filetypeinfo } from "magic-bytes.js";
|
610 |
+
|
611 |
+
// src/lib/handlers/Shared.ts
|
612 |
+
var invalidCount = 0;
|
613 |
+
var invalidCountResetTime = null;
|
614 |
+
function incrementInvalidCount(manager) {
|
615 |
+
if (!invalidCountResetTime || invalidCountResetTime < Date.now()) {
|
616 |
+
invalidCountResetTime = Date.now() + 1e3 * 60 * 10;
|
617 |
+
invalidCount = 0;
|
618 |
+
}
|
619 |
+
invalidCount++;
|
620 |
+
const emitInvalid = manager.options.invalidRequestWarningInterval > 0 && invalidCount % manager.options.invalidRequestWarningInterval === 0;
|
621 |
+
if (emitInvalid) {
|
622 |
+
manager.emit("invalidRequestWarning" /* InvalidRequestWarning */, {
|
623 |
+
count: invalidCount,
|
624 |
+
remainingTime: invalidCountResetTime - Date.now()
|
625 |
+
});
|
626 |
+
}
|
627 |
+
}
|
628 |
+
__name(incrementInvalidCount, "incrementInvalidCount");
|
629 |
+
async function makeNetworkRequest(manager, routeId, url, options, requestData, retries) {
|
630 |
+
const controller = new AbortController();
|
631 |
+
const timeout = setTimeout(() => controller.abort(), manager.options.timeout);
|
632 |
+
if (requestData.signal) {
|
633 |
+
if (requestData.signal.aborted)
|
634 |
+
controller.abort();
|
635 |
+
else
|
636 |
+
requestData.signal.addEventListener("abort", () => controller.abort());
|
637 |
+
}
|
638 |
+
let res;
|
639 |
+
try {
|
640 |
+
res = await manager.options.makeRequest(url, { ...options, signal: controller.signal });
|
641 |
+
} catch (error) {
|
642 |
+
if (!(error instanceof Error))
|
643 |
+
throw error;
|
644 |
+
if (shouldRetry(error) && retries !== manager.options.retries) {
|
645 |
+
return null;
|
646 |
+
}
|
647 |
+
throw error;
|
648 |
+
} finally {
|
649 |
+
clearTimeout(timeout);
|
650 |
+
}
|
651 |
+
if (manager.listenerCount("response" /* Response */)) {
|
652 |
+
manager.emit(
|
653 |
+
"response" /* Response */,
|
654 |
+
{
|
655 |
+
method: options.method ?? "get",
|
656 |
+
path: routeId.original,
|
657 |
+
route: routeId.bucketRoute,
|
658 |
+
options,
|
659 |
+
data: requestData,
|
660 |
+
retries
|
661 |
+
},
|
662 |
+
res instanceof Response ? res.clone() : { ...res }
|
663 |
+
);
|
664 |
+
}
|
665 |
+
return res;
|
666 |
+
}
|
667 |
+
__name(makeNetworkRequest, "makeNetworkRequest");
|
668 |
+
async function handleErrors(manager, res, method, url, requestData, retries) {
|
669 |
+
const status = res.status;
|
670 |
+
if (status >= 500 && status < 600) {
|
671 |
+
if (retries !== manager.options.retries) {
|
672 |
+
return null;
|
673 |
+
}
|
674 |
+
throw new HTTPError(status, res.statusText, method, url, requestData);
|
675 |
+
} else {
|
676 |
+
if (status >= 400 && status < 500) {
|
677 |
+
if (status === 401 && requestData.auth) {
|
678 |
+
manager.setToken(null);
|
679 |
+
}
|
680 |
+
const data = await parseResponse(res);
|
681 |
+
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
|
682 |
+
}
|
683 |
+
return res;
|
684 |
+
}
|
685 |
+
}
|
686 |
+
__name(handleErrors, "handleErrors");
|
687 |
+
|
688 |
+
// src/lib/handlers/BurstHandler.ts
|
689 |
+
var BurstHandler = class {
|
690 |
+
/**
|
691 |
+
* @param manager - The request manager
|
692 |
+
* @param hash - The hash that this RequestHandler handles
|
693 |
+
* @param majorParameter - The major parameter for this handler
|
694 |
+
*/
|
695 |
+
constructor(manager, hash, majorParameter) {
|
696 |
+
this.manager = manager;
|
697 |
+
this.hash = hash;
|
698 |
+
this.majorParameter = majorParameter;
|
699 |
+
this.id = `${hash}:${majorParameter}`;
|
700 |
+
}
|
701 |
+
static {
|
702 |
+
__name(this, "BurstHandler");
|
703 |
+
}
|
704 |
+
/**
|
705 |
+
* {@inheritdoc IHandler.id}
|
706 |
+
*/
|
707 |
+
id;
|
708 |
+
/**
|
709 |
+
* {@inheritDoc IHandler.inactive}
|
710 |
+
*/
|
711 |
+
inactive = false;
|
712 |
+
/**
|
713 |
+
* Emits a debug message
|
714 |
+
*
|
715 |
+
* @param message - The message to debug
|
716 |
+
*/
|
717 |
+
debug(message) {
|
718 |
+
this.manager.emit("restDebug" /* Debug */, `[REST ${this.id}] ${message}`);
|
719 |
+
}
|
720 |
+
/**
|
721 |
+
* {@inheritDoc IHandler.queueRequest}
|
722 |
+
*/
|
723 |
+
async queueRequest(routeId, url, options, requestData) {
|
724 |
+
return this.runRequest(routeId, url, options, requestData);
|
725 |
+
}
|
726 |
+
/**
|
727 |
+
* The method that actually makes the request to the API, and updates info about the bucket accordingly
|
728 |
+
*
|
729 |
+
* @param routeId - The generalized API route with literal ids for major parameters
|
730 |
+
* @param url - The fully resolved URL to make the request to
|
731 |
+
* @param options - The fetch options needed to make the request
|
732 |
+
* @param requestData - Extra data from the user's request needed for errors and additional processing
|
733 |
+
* @param retries - The number of retries this request has already attempted (recursion)
|
734 |
+
*/
|
735 |
+
async runRequest(routeId, url, options, requestData, retries = 0) {
|
736 |
+
const method = options.method ?? "get";
|
737 |
+
const res = await makeNetworkRequest(this.manager, routeId, url, options, requestData, retries);
|
738 |
+
if (res === null) {
|
739 |
+
return this.runRequest(routeId, url, options, requestData, ++retries);
|
740 |
+
}
|
741 |
+
const status = res.status;
|
742 |
+
let retryAfter = 0;
|
743 |
+
const retry = res.headers.get("Retry-After");
|
744 |
+
if (retry)
|
745 |
+
retryAfter = Number(retry) * 1e3 + this.manager.options.offset;
|
746 |
+
if (status === 401 || status === 403 || status === 429) {
|
747 |
+
incrementInvalidCount(this.manager);
|
748 |
+
}
|
749 |
+
if (status >= 200 && status < 300) {
|
750 |
+
return res;
|
751 |
+
} else if (status === 429) {
|
752 |
+
const isGlobal = res.headers.has("X-RateLimit-Global");
|
753 |
+
const scope = res.headers.get("X-RateLimit-Scope") ?? "user";
|
754 |
+
await onRateLimit(this.manager, {
|
755 |
+
global: isGlobal,
|
756 |
+
method,
|
757 |
+
url,
|
758 |
+
route: routeId.bucketRoute,
|
759 |
+
majorParameter: this.majorParameter,
|
760 |
+
hash: this.hash,
|
761 |
+
limit: Number.POSITIVE_INFINITY,
|
762 |
+
timeToReset: retryAfter,
|
763 |
+
retryAfter,
|
764 |
+
sublimitTimeout: 0,
|
765 |
+
scope
|
766 |
+
});
|
767 |
+
this.debug(
|
768 |
+
[
|
769 |
+
"Encountered unexpected 429 rate limit",
|
770 |
+
` Global : ${isGlobal}`,
|
771 |
+
` Method : ${method}`,
|
772 |
+
` URL : ${url}`,
|
773 |
+
` Bucket : ${routeId.bucketRoute}`,
|
774 |
+
` Major parameter: ${routeId.majorParameter}`,
|
775 |
+
` Hash : ${this.hash}`,
|
776 |
+
` Limit : ${Number.POSITIVE_INFINITY}`,
|
777 |
+
` Retry After : ${retryAfter}ms`,
|
778 |
+
` Sublimit : None`,
|
779 |
+
` Scope : ${scope}`
|
780 |
+
].join("\n")
|
781 |
+
);
|
782 |
+
await sleep(retryAfter);
|
783 |
+
return this.runRequest(routeId, url, options, requestData, retries);
|
784 |
+
} else {
|
785 |
+
const handled = await handleErrors(this.manager, res, method, url, requestData, retries);
|
786 |
+
if (handled === null) {
|
787 |
+
return this.runRequest(routeId, url, options, requestData, ++retries);
|
788 |
+
}
|
789 |
+
return handled;
|
790 |
+
}
|
791 |
+
}
|
792 |
+
};
|
793 |
+
|
794 |
+
// src/lib/handlers/SequentialHandler.ts
|
795 |
+
import { AsyncQueue } from "@sapphire/async-queue";
|
796 |
+
var SequentialHandler = class {
|
797 |
+
/**
|
798 |
+
* @param manager - The request manager
|
799 |
+
* @param hash - The hash that this RequestHandler handles
|
800 |
+
* @param majorParameter - The major parameter for this handler
|
801 |
+
*/
|
802 |
+
constructor(manager, hash, majorParameter) {
|
803 |
+
this.manager = manager;
|
804 |
+
this.hash = hash;
|
805 |
+
this.majorParameter = majorParameter;
|
806 |
+
this.id = `${hash}:${majorParameter}`;
|
807 |
+
}
|
808 |
+
static {
|
809 |
+
__name(this, "SequentialHandler");
|
810 |
+
}
|
811 |
+
/**
|
812 |
+
* {@inheritDoc IHandler.id}
|
813 |
+
*/
|
814 |
+
id;
|
815 |
+
/**
|
816 |
+
* The time this rate limit bucket will reset
|
817 |
+
*/
|
818 |
+
reset = -1;
|
819 |
+
/**
|
820 |
+
* The remaining requests that can be made before we are rate limited
|
821 |
+
*/
|
822 |
+
remaining = 1;
|
823 |
+
/**
|
824 |
+
* The total number of requests that can be made before we are rate limited
|
825 |
+
*/
|
826 |
+
limit = Number.POSITIVE_INFINITY;
|
827 |
+
/**
|
828 |
+
* The interface used to sequence async requests sequentially
|
829 |
+
*/
|
830 |
+
#asyncQueue = new AsyncQueue();
|
831 |
+
/**
|
832 |
+
* The interface used to sequence sublimited async requests sequentially
|
833 |
+
*/
|
834 |
+
#sublimitedQueue = null;
|
835 |
+
/**
|
836 |
+
* A promise wrapper for when the sublimited queue is finished being processed or null when not being processed
|
837 |
+
*/
|
838 |
+
#sublimitPromise = null;
|
839 |
+
/**
|
840 |
+
* Whether the sublimit queue needs to be shifted in the finally block
|
841 |
+
*/
|
842 |
+
#shiftSublimit = false;
|
843 |
+
/**
|
844 |
+
* {@inheritDoc IHandler.inactive}
|
845 |
+
*/
|
846 |
+
get inactive() {
|
847 |
+
return this.#asyncQueue.remaining === 0 && (this.#sublimitedQueue === null || this.#sublimitedQueue.remaining === 0) && !this.limited;
|
848 |
+
}
|
849 |
+
/**
|
850 |
+
* If the rate limit bucket is currently limited by the global limit
|
851 |
+
*/
|
852 |
+
get globalLimited() {
|
853 |
+
return this.manager.globalRemaining <= 0 && Date.now() < this.manager.globalReset;
|
854 |
+
}
|
855 |
+
/**
|
856 |
+
* If the rate limit bucket is currently limited by its limit
|
857 |
+
*/
|
858 |
+
get localLimited() {
|
859 |
+
return this.remaining <= 0 && Date.now() < this.reset;
|
860 |
+
}
|
861 |
+
/**
|
862 |
+
* If the rate limit bucket is currently limited
|
863 |
+
*/
|
864 |
+
get limited() {
|
865 |
+
return this.globalLimited || this.localLimited;
|
866 |
+
}
|
867 |
+
/**
|
868 |
+
* The time until queued requests can continue
|
869 |
+
*/
|
870 |
+
get timeToReset() {
|
871 |
+
return this.reset + this.manager.options.offset - Date.now();
|
872 |
+
}
|
873 |
+
/**
|
874 |
+
* Emits a debug message
|
875 |
+
*
|
876 |
+
* @param message - The message to debug
|
877 |
+
*/
|
878 |
+
debug(message) {
|
879 |
+
this.manager.emit("restDebug" /* Debug */, `[REST ${this.id}] ${message}`);
|
880 |
+
}
|
881 |
+
/**
|
882 |
+
* Delay all requests for the specified amount of time, handling global rate limits
|
883 |
+
*
|
884 |
+
* @param time - The amount of time to delay all requests for
|
885 |
+
*/
|
886 |
+
async globalDelayFor(time) {
|
887 |
+
await sleep(time);
|
888 |
+
this.manager.globalDelay = null;
|
889 |
+
}
|
890 |
+
/**
|
891 |
+
* {@inheritDoc IHandler.queueRequest}
|
892 |
+
*/
|
893 |
+
async queueRequest(routeId, url, options, requestData) {
|
894 |
+
let queue = this.#asyncQueue;
|
895 |
+
let queueType = 0 /* Standard */;
|
896 |
+
if (this.#sublimitedQueue && hasSublimit(routeId.bucketRoute, requestData.body, options.method)) {
|
897 |
+
queue = this.#sublimitedQueue;
|
898 |
+
queueType = 1 /* Sublimit */;
|
899 |
+
}
|
900 |
+
await queue.wait({ signal: requestData.signal });
|
901 |
+
if (queueType === 0 /* Standard */) {
|
902 |
+
if (this.#sublimitedQueue && hasSublimit(routeId.bucketRoute, requestData.body, options.method)) {
|
903 |
+
queue = this.#sublimitedQueue;
|
904 |
+
const wait = queue.wait();
|
905 |
+
this.#asyncQueue.shift();
|
906 |
+
await wait;
|
907 |
+
} else if (this.#sublimitPromise) {
|
908 |
+
await this.#sublimitPromise.promise;
|
909 |
+
}
|
910 |
+
}
|
911 |
+
try {
|
912 |
+
return await this.runRequest(routeId, url, options, requestData);
|
913 |
+
} finally {
|
914 |
+
queue.shift();
|
915 |
+
if (this.#shiftSublimit) {
|
916 |
+
this.#shiftSublimit = false;
|
917 |
+
this.#sublimitedQueue?.shift();
|
918 |
+
}
|
919 |
+
if (this.#sublimitedQueue?.remaining === 0) {
|
920 |
+
this.#sublimitPromise?.resolve();
|
921 |
+
this.#sublimitedQueue = null;
|
922 |
+
}
|
923 |
+
}
|
924 |
+
}
|
925 |
+
/**
|
926 |
+
* The method that actually makes the request to the api, and updates info about the bucket accordingly
|
927 |
+
*
|
928 |
+
* @param routeId - The generalized api route with literal ids for major parameters
|
929 |
+
* @param url - The fully resolved url to make the request to
|
930 |
+
* @param options - The fetch options needed to make the request
|
931 |
+
* @param requestData - Extra data from the user's request needed for errors and additional processing
|
932 |
+
* @param retries - The number of retries this request has already attempted (recursion)
|
933 |
+
*/
|
934 |
+
async runRequest(routeId, url, options, requestData, retries = 0) {
|
935 |
+
while (this.limited) {
|
936 |
+
const isGlobal = this.globalLimited;
|
937 |
+
let limit2;
|
938 |
+
let timeout;
|
939 |
+
let delay;
|
940 |
+
if (isGlobal) {
|
941 |
+
limit2 = this.manager.options.globalRequestsPerSecond;
|
942 |
+
timeout = this.manager.globalReset + this.manager.options.offset - Date.now();
|
943 |
+
if (!this.manager.globalDelay) {
|
944 |
+
this.manager.globalDelay = this.globalDelayFor(timeout);
|
945 |
+
}
|
946 |
+
delay = this.manager.globalDelay;
|
947 |
+
} else {
|
948 |
+
limit2 = this.limit;
|
949 |
+
timeout = this.timeToReset;
|
950 |
+
delay = sleep(timeout);
|
951 |
+
}
|
952 |
+
const rateLimitData = {
|
953 |
+
global: isGlobal,
|
954 |
+
method: options.method ?? "get",
|
955 |
+
url,
|
956 |
+
route: routeId.bucketRoute,
|
957 |
+
majorParameter: this.majorParameter,
|
958 |
+
hash: this.hash,
|
959 |
+
limit: limit2,
|
960 |
+
timeToReset: timeout,
|
961 |
+
retryAfter: timeout,
|
962 |
+
sublimitTimeout: 0,
|
963 |
+
scope: "user"
|
964 |
+
};
|
965 |
+
this.manager.emit("rateLimited" /* RateLimited */, rateLimitData);
|
966 |
+
await onRateLimit(this.manager, rateLimitData);
|
967 |
+
if (isGlobal) {
|
968 |
+
this.debug(`Global rate limit hit, blocking all requests for ${timeout}ms`);
|
969 |
+
} else {
|
970 |
+
this.debug(`Waiting ${timeout}ms for rate limit to pass`);
|
971 |
+
}
|
972 |
+
await delay;
|
973 |
+
}
|
974 |
+
if (!this.manager.globalReset || this.manager.globalReset < Date.now()) {
|
975 |
+
this.manager.globalReset = Date.now() + 1e3;
|
976 |
+
this.manager.globalRemaining = this.manager.options.globalRequestsPerSecond;
|
977 |
+
}
|
978 |
+
this.manager.globalRemaining--;
|
979 |
+
const method = options.method ?? "get";
|
980 |
+
const res = await makeNetworkRequest(this.manager, routeId, url, options, requestData, retries);
|
981 |
+
if (res === null) {
|
982 |
+
return this.runRequest(routeId, url, options, requestData, ++retries);
|
983 |
+
}
|
984 |
+
const status = res.status;
|
985 |
+
let retryAfter = 0;
|
986 |
+
const limit = res.headers.get("X-RateLimit-Limit");
|
987 |
+
const remaining = res.headers.get("X-RateLimit-Remaining");
|
988 |
+
const reset = res.headers.get("X-RateLimit-Reset-After");
|
989 |
+
const hash = res.headers.get("X-RateLimit-Bucket");
|
990 |
+
const retry = res.headers.get("Retry-After");
|
991 |
+
const scope = res.headers.get("X-RateLimit-Scope") ?? "user";
|
992 |
+
this.limit = limit ? Number(limit) : Number.POSITIVE_INFINITY;
|
993 |
+
this.remaining = remaining ? Number(remaining) : 1;
|
994 |
+
this.reset = reset ? Number(reset) * 1e3 + Date.now() + this.manager.options.offset : Date.now();
|
995 |
+
if (retry)
|
996 |
+
retryAfter = Number(retry) * 1e3 + this.manager.options.offset;
|
997 |
+
if (hash && hash !== this.hash) {
|
998 |
+
this.debug(["Received bucket hash update", ` Old Hash : ${this.hash}`, ` New Hash : ${hash}`].join("\n"));
|
999 |
+
this.manager.hashes.set(`${method}:${routeId.bucketRoute}`, { value: hash, lastAccess: Date.now() });
|
1000 |
+
} else if (hash) {
|
1001 |
+
const hashData = this.manager.hashes.get(`${method}:${routeId.bucketRoute}`);
|
1002 |
+
if (hashData) {
|
1003 |
+
hashData.lastAccess = Date.now();
|
1004 |
+
}
|
1005 |
+
}
|
1006 |
+
let sublimitTimeout = null;
|
1007 |
+
if (retryAfter > 0) {
|
1008 |
+
if (res.headers.has("X-RateLimit-Global")) {
|
1009 |
+
this.manager.globalRemaining = 0;
|
1010 |
+
this.manager.globalReset = Date.now() + retryAfter;
|
1011 |
+
} else if (!this.localLimited) {
|
1012 |
+
sublimitTimeout = retryAfter;
|
1013 |
+
}
|
1014 |
+
}
|
1015 |
+
if (status === 401 || status === 403 || status === 429) {
|
1016 |
+
incrementInvalidCount(this.manager);
|
1017 |
+
}
|
1018 |
+
if (res.ok) {
|
1019 |
+
return res;
|
1020 |
+
} else if (status === 429) {
|
1021 |
+
const isGlobal = this.globalLimited;
|
1022 |
+
let limit2;
|
1023 |
+
let timeout;
|
1024 |
+
if (isGlobal) {
|
1025 |
+
limit2 = this.manager.options.globalRequestsPerSecond;
|
1026 |
+
timeout = this.manager.globalReset + this.manager.options.offset - Date.now();
|
1027 |
+
} else {
|
1028 |
+
limit2 = this.limit;
|
1029 |
+
timeout = this.timeToReset;
|
1030 |
+
}
|
1031 |
+
await onRateLimit(this.manager, {
|
1032 |
+
global: isGlobal,
|
1033 |
+
method,
|
1034 |
+
url,
|
1035 |
+
route: routeId.bucketRoute,
|
1036 |
+
majorParameter: this.majorParameter,
|
1037 |
+
hash: this.hash,
|
1038 |
+
limit: limit2,
|
1039 |
+
timeToReset: timeout,
|
1040 |
+
retryAfter,
|
1041 |
+
sublimitTimeout: sublimitTimeout ?? 0,
|
1042 |
+
scope
|
1043 |
+
});
|
1044 |
+
this.debug(
|
1045 |
+
[
|
1046 |
+
"Encountered unexpected 429 rate limit",
|
1047 |
+
` Global : ${isGlobal.toString()}`,
|
1048 |
+
` Method : ${method}`,
|
1049 |
+
` URL : ${url}`,
|
1050 |
+
` Bucket : ${routeId.bucketRoute}`,
|
1051 |
+
` Major parameter: ${routeId.majorParameter}`,
|
1052 |
+
` Hash : ${this.hash}`,
|
1053 |
+
` Limit : ${limit2}`,
|
1054 |
+
` Retry After : ${retryAfter}ms`,
|
1055 |
+
` Sublimit : ${sublimitTimeout ? `${sublimitTimeout}ms` : "None"}`,
|
1056 |
+
` Scope : ${scope}`
|
1057 |
+
].join("\n")
|
1058 |
+
);
|
1059 |
+
if (sublimitTimeout) {
|
1060 |
+
const firstSublimit = !this.#sublimitedQueue;
|
1061 |
+
if (firstSublimit) {
|
1062 |
+
this.#sublimitedQueue = new AsyncQueue();
|
1063 |
+
void this.#sublimitedQueue.wait();
|
1064 |
+
this.#asyncQueue.shift();
|
1065 |
+
}
|
1066 |
+
this.#sublimitPromise?.resolve();
|
1067 |
+
this.#sublimitPromise = null;
|
1068 |
+
await sleep(sublimitTimeout);
|
1069 |
+
let resolve;
|
1070 |
+
const promise = new Promise((res2) => resolve = res2);
|
1071 |
+
this.#sublimitPromise = { promise, resolve };
|
1072 |
+
if (firstSublimit) {
|
1073 |
+
await this.#asyncQueue.wait();
|
1074 |
+
this.#shiftSublimit = true;
|
1075 |
+
}
|
1076 |
+
}
|
1077 |
+
return this.runRequest(routeId, url, options, requestData, retries);
|
1078 |
+
} else {
|
1079 |
+
const handled = await handleErrors(this.manager, res, method, url, requestData, retries);
|
1080 |
+
if (handled === null) {
|
1081 |
+
return this.runRequest(routeId, url, options, requestData, ++retries);
|
1082 |
+
}
|
1083 |
+
return handled;
|
1084 |
+
}
|
1085 |
+
}
|
1086 |
+
};
|
1087 |
+
|
1088 |
+
// src/lib/REST.ts
|
1089 |
+
var REST = class _REST extends AsyncEventEmitter {
|
1090 |
+
static {
|
1091 |
+
__name(this, "REST");
|
1092 |
+
}
|
1093 |
+
/**
|
1094 |
+
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} for all requests
|
1095 |
+
* performed by this manager.
|
1096 |
+
*/
|
1097 |
+
agent = null;
|
1098 |
+
cdn;
|
1099 |
+
/**
|
1100 |
+
* The number of requests remaining in the global bucket
|
1101 |
+
*/
|
1102 |
+
globalRemaining;
|
1103 |
+
/**
|
1104 |
+
* The promise used to wait out the global rate limit
|
1105 |
+
*/
|
1106 |
+
globalDelay = null;
|
1107 |
+
/**
|
1108 |
+
* The timestamp at which the global bucket resets
|
1109 |
+
*/
|
1110 |
+
globalReset = -1;
|
1111 |
+
/**
|
1112 |
+
* API bucket hashes that are cached from provided routes
|
1113 |
+
*/
|
1114 |
+
hashes = new Collection();
|
1115 |
+
/**
|
1116 |
+
* Request handlers created from the bucket hash and the major parameters
|
1117 |
+
*/
|
1118 |
+
handlers = new Collection();
|
1119 |
+
#token = null;
|
1120 |
+
hashTimer;
|
1121 |
+
handlerTimer;
|
1122 |
+
options;
|
1123 |
+
constructor(options = {}) {
|
1124 |
+
super();
|
1125 |
+
this.cdn = new CDN(options.cdn ?? DefaultRestOptions.cdn);
|
1126 |
+
this.options = { ...DefaultRestOptions, ...options };
|
1127 |
+
this.options.offset = Math.max(0, this.options.offset);
|
1128 |
+
this.globalRemaining = Math.max(1, this.options.globalRequestsPerSecond);
|
1129 |
+
this.agent = options.agent ?? null;
|
1130 |
+
this.setupSweepers();
|
1131 |
+
}
|
1132 |
+
setupSweepers() {
|
1133 |
+
const validateMaxInterval = /* @__PURE__ */ __name((interval) => {
|
1134 |
+
if (interval > 144e5) {
|
1135 |
+
throw new Error("Cannot set an interval greater than 4 hours");
|
1136 |
+
}
|
1137 |
+
}, "validateMaxInterval");
|
1138 |
+
if (this.options.hashSweepInterval !== 0 && this.options.hashSweepInterval !== Number.POSITIVE_INFINITY) {
|
1139 |
+
validateMaxInterval(this.options.hashSweepInterval);
|
1140 |
+
this.hashTimer = setInterval(() => {
|
1141 |
+
const sweptHashes = new Collection();
|
1142 |
+
const currentDate = Date.now();
|
1143 |
+
this.hashes.sweep((val, key) => {
|
1144 |
+
if (val.lastAccess === -1)
|
1145 |
+
return false;
|
1146 |
+
const shouldSweep = Math.floor(currentDate - val.lastAccess) > this.options.hashLifetime;
|
1147 |
+
if (shouldSweep) {
|
1148 |
+
sweptHashes.set(key, val);
|
1149 |
+
this.emit("restDebug" /* Debug */, `Hash ${val.value} for ${key} swept due to lifetime being exceeded`);
|
1150 |
+
}
|
1151 |
+
return shouldSweep;
|
1152 |
+
});
|
1153 |
+
this.emit("hashSweep" /* HashSweep */, sweptHashes);
|
1154 |
+
}, this.options.hashSweepInterval);
|
1155 |
+
this.hashTimer.unref?.();
|
1156 |
+
}
|
1157 |
+
if (this.options.handlerSweepInterval !== 0 && this.options.handlerSweepInterval !== Number.POSITIVE_INFINITY) {
|
1158 |
+
validateMaxInterval(this.options.handlerSweepInterval);
|
1159 |
+
this.handlerTimer = setInterval(() => {
|
1160 |
+
const sweptHandlers = new Collection();
|
1161 |
+
this.handlers.sweep((val, key) => {
|
1162 |
+
const { inactive } = val;
|
1163 |
+
if (inactive) {
|
1164 |
+
sweptHandlers.set(key, val);
|
1165 |
+
this.emit("restDebug" /* Debug */, `Handler ${val.id} for ${key} swept due to being inactive`);
|
1166 |
+
}
|
1167 |
+
return inactive;
|
1168 |
+
});
|
1169 |
+
this.emit("handlerSweep" /* HandlerSweep */, sweptHandlers);
|
1170 |
+
}, this.options.handlerSweepInterval);
|
1171 |
+
this.handlerTimer.unref?.();
|
1172 |
+
}
|
1173 |
+
}
|
1174 |
+
/**
|
1175 |
+
* Runs a get request from the api
|
1176 |
+
*
|
1177 |
+
* @param fullRoute - The full route to query
|
1178 |
+
* @param options - Optional request options
|
1179 |
+
*/
|
1180 |
+
async get(fullRoute, options = {}) {
|
1181 |
+
return this.request({ ...options, fullRoute, method: "GET" /* Get */ });
|
1182 |
+
}
|
1183 |
+
/**
|
1184 |
+
* Runs a delete request from the api
|
1185 |
+
*
|
1186 |
+
* @param fullRoute - The full route to query
|
1187 |
+
* @param options - Optional request options
|
1188 |
+
*/
|
1189 |
+
async delete(fullRoute, options = {}) {
|
1190 |
+
return this.request({ ...options, fullRoute, method: "DELETE" /* Delete */ });
|
1191 |
+
}
|
1192 |
+
/**
|
1193 |
+
* Runs a post request from the api
|
1194 |
+
*
|
1195 |
+
* @param fullRoute - The full route to query
|
1196 |
+
* @param options - Optional request options
|
1197 |
+
*/
|
1198 |
+
async post(fullRoute, options = {}) {
|
1199 |
+
return this.request({ ...options, fullRoute, method: "POST" /* Post */ });
|
1200 |
+
}
|
1201 |
+
/**
|
1202 |
+
* Runs a put request from the api
|
1203 |
+
*
|
1204 |
+
* @param fullRoute - The full route to query
|
1205 |
+
* @param options - Optional request options
|
1206 |
+
*/
|
1207 |
+
async put(fullRoute, options = {}) {
|
1208 |
+
return this.request({ ...options, fullRoute, method: "PUT" /* Put */ });
|
1209 |
+
}
|
1210 |
+
/**
|
1211 |
+
* Runs a patch request from the api
|
1212 |
+
*
|
1213 |
+
* @param fullRoute - The full route to query
|
1214 |
+
* @param options - Optional request options
|
1215 |
+
*/
|
1216 |
+
async patch(fullRoute, options = {}) {
|
1217 |
+
return this.request({ ...options, fullRoute, method: "PATCH" /* Patch */ });
|
1218 |
+
}
|
1219 |
+
/**
|
1220 |
+
* Runs a request from the api
|
1221 |
+
*
|
1222 |
+
* @param options - Request options
|
1223 |
+
*/
|
1224 |
+
async request(options) {
|
1225 |
+
const response = await this.queueRequest(options);
|
1226 |
+
return parseResponse(response);
|
1227 |
+
}
|
1228 |
+
/**
|
1229 |
+
* Sets the default agent to use for requests performed by this manager
|
1230 |
+
*
|
1231 |
+
* @param agent - The agent to use
|
1232 |
+
*/
|
1233 |
+
setAgent(agent) {
|
1234 |
+
this.agent = agent;
|
1235 |
+
return this;
|
1236 |
+
}
|
1237 |
+
/**
|
1238 |
+
* Sets the authorization token that should be used for requests
|
1239 |
+
*
|
1240 |
+
* @param token - The authorization token to use
|
1241 |
+
*/
|
1242 |
+
setToken(token) {
|
1243 |
+
this.#token = token;
|
1244 |
+
return this;
|
1245 |
+
}
|
1246 |
+
/**
|
1247 |
+
* Queues a request to be sent
|
1248 |
+
*
|
1249 |
+
* @param request - All the information needed to make a request
|
1250 |
+
* @returns The response from the api request
|
1251 |
+
*/
|
1252 |
+
async queueRequest(request2) {
|
1253 |
+
const routeId = _REST.generateRouteData(request2.fullRoute, request2.method);
|
1254 |
+
const hash = this.hashes.get(`${request2.method}:${routeId.bucketRoute}`) ?? {
|
1255 |
+
value: `Global(${request2.method}:${routeId.bucketRoute})`,
|
1256 |
+
lastAccess: -1
|
1257 |
+
};
|
1258 |
+
const handler = this.handlers.get(`${hash.value}:${routeId.majorParameter}`) ?? this.createHandler(hash.value, routeId.majorParameter);
|
1259 |
+
const { url, fetchOptions } = await this.resolveRequest(request2);
|
1260 |
+
return handler.queueRequest(routeId, url, fetchOptions, {
|
1261 |
+
body: request2.body,
|
1262 |
+
files: request2.files,
|
1263 |
+
auth: request2.auth !== false,
|
1264 |
+
signal: request2.signal
|
1265 |
+
});
|
1266 |
+
}
|
1267 |
+
/**
|
1268 |
+
* Creates a new rate limit handler from a hash, based on the hash and the major parameter
|
1269 |
+
*
|
1270 |
+
* @param hash - The hash for the route
|
1271 |
+
* @param majorParameter - The major parameter for this handler
|
1272 |
+
* @internal
|
1273 |
+
*/
|
1274 |
+
createHandler(hash, majorParameter) {
|
1275 |
+
const queue = majorParameter === BurstHandlerMajorIdKey ? new BurstHandler(this, hash, majorParameter) : new SequentialHandler(this, hash, majorParameter);
|
1276 |
+
this.handlers.set(queue.id, queue);
|
1277 |
+
return queue;
|
1278 |
+
}
|
1279 |
+
/**
|
1280 |
+
* Formats the request data to a usable format for fetch
|
1281 |
+
*
|
1282 |
+
* @param request - The request data
|
1283 |
+
*/
|
1284 |
+
async resolveRequest(request2) {
|
1285 |
+
const { options } = this;
|
1286 |
+
let query = "";
|
1287 |
+
if (request2.query) {
|
1288 |
+
const resolvedQuery = request2.query.toString();
|
1289 |
+
if (resolvedQuery !== "") {
|
1290 |
+
query = `?${resolvedQuery}`;
|
1291 |
+
}
|
1292 |
+
}
|
1293 |
+
const headers = {
|
1294 |
+
...this.options.headers,
|
1295 |
+
"User-Agent": `${DefaultUserAgent} ${options.userAgentAppendix}`.trim()
|
1296 |
+
};
|
1297 |
+
if (request2.auth !== false) {
|
1298 |
+
if (!this.#token) {
|
1299 |
+
throw new Error("Expected token to be set for this request, but none was present");
|
1300 |
+
}
|
1301 |
+
headers.Authorization = `${request2.authPrefix ?? this.options.authPrefix} ${this.#token}`;
|
1302 |
+
}
|
1303 |
+
if (request2.reason?.length) {
|
1304 |
+
headers["X-Audit-Log-Reason"] = encodeURIComponent(request2.reason);
|
1305 |
+
}
|
1306 |
+
const url = `${options.api}${request2.versioned === false ? "" : `/v${options.version}`}${request2.fullRoute}${query}`;
|
1307 |
+
let finalBody;
|
1308 |
+
let additionalHeaders = {};
|
1309 |
+
if (request2.files?.length) {
|
1310 |
+
const formData = new FormData();
|
1311 |
+
for (const [index, file] of request2.files.entries()) {
|
1312 |
+
const fileKey = file.key ?? `files[${index}]`;
|
1313 |
+
if (isBufferLike(file.data)) {
|
1314 |
+
let contentType = file.contentType;
|
1315 |
+
if (!contentType) {
|
1316 |
+
const [parsedType] = filetypeinfo(file.data);
|
1317 |
+
if (parsedType) {
|
1318 |
+
contentType = OverwrittenMimeTypes[parsedType.mime] ?? parsedType.mime ?? "application/octet-stream";
|
1319 |
+
}
|
1320 |
+
}
|
1321 |
+
formData.append(fileKey, new Blob([file.data], { type: contentType }), file.name);
|
1322 |
+
} else {
|
1323 |
+
formData.append(fileKey, new Blob([`${file.data}`], { type: file.contentType }), file.name);
|
1324 |
+
}
|
1325 |
+
}
|
1326 |
+
if (request2.body != null) {
|
1327 |
+
if (request2.appendToFormData) {
|
1328 |
+
for (const [key, value] of Object.entries(request2.body)) {
|
1329 |
+
formData.append(key, value);
|
1330 |
+
}
|
1331 |
+
} else {
|
1332 |
+
formData.append("payload_json", JSON.stringify(request2.body));
|
1333 |
+
}
|
1334 |
+
}
|
1335 |
+
finalBody = formData;
|
1336 |
+
} else if (request2.body != null) {
|
1337 |
+
if (request2.passThroughBody) {
|
1338 |
+
finalBody = request2.body;
|
1339 |
+
} else {
|
1340 |
+
finalBody = JSON.stringify(request2.body);
|
1341 |
+
additionalHeaders = { "Content-Type": "application/json" };
|
1342 |
+
}
|
1343 |
+
}
|
1344 |
+
const method = request2.method.toUpperCase();
|
1345 |
+
const fetchOptions = {
|
1346 |
+
// Set body to null on get / head requests. This does not follow fetch spec (likely because it causes subtle bugs) but is aligned with what request was doing
|
1347 |
+
body: ["GET", "HEAD"].includes(method) ? null : finalBody,
|
1348 |
+
headers: { ...request2.headers, ...additionalHeaders, ...headers },
|
1349 |
+
method,
|
1350 |
+
// Prioritize setting an agent per request, use the agent for this instance otherwise.
|
1351 |
+
dispatcher: request2.dispatcher ?? this.agent ?? void 0
|
1352 |
+
};
|
1353 |
+
return { url, fetchOptions };
|
1354 |
+
}
|
1355 |
+
/**
|
1356 |
+
* Stops the hash sweeping interval
|
1357 |
+
*/
|
1358 |
+
clearHashSweeper() {
|
1359 |
+
clearInterval(this.hashTimer);
|
1360 |
+
}
|
1361 |
+
/**
|
1362 |
+
* Stops the request handler sweeping interval
|
1363 |
+
*/
|
1364 |
+
clearHandlerSweeper() {
|
1365 |
+
clearInterval(this.handlerTimer);
|
1366 |
+
}
|
1367 |
+
/**
|
1368 |
+
* Generates route data for an endpoint:method
|
1369 |
+
*
|
1370 |
+
* @param endpoint - The raw endpoint to generalize
|
1371 |
+
* @param method - The HTTP method this endpoint is called without
|
1372 |
+
* @internal
|
1373 |
+
*/
|
1374 |
+
static generateRouteData(endpoint, method) {
|
1375 |
+
if (endpoint.startsWith("/interactions/") && endpoint.endsWith("/callback")) {
|
1376 |
+
return {
|
1377 |
+
majorParameter: BurstHandlerMajorIdKey,
|
1378 |
+
bucketRoute: "/interactions/:id/:token/callback",
|
1379 |
+
original: endpoint
|
1380 |
+
};
|
1381 |
+
}
|
1382 |
+
const majorIdMatch = /(?:^\/webhooks\/(\d{17,19}\/[^/?]+))|(?:^\/(?:channels|guilds|webhooks)\/(\d{17,19}))/.exec(
|
1383 |
+
endpoint
|
1384 |
+
);
|
1385 |
+
const majorId = majorIdMatch?.[2] ?? majorIdMatch?.[1] ?? "global";
|
1386 |
+
const baseRoute = endpoint.replaceAll(/\d{17,19}/g, ":id").replace(/\/reactions\/(.*)/, "/reactions/:reaction").replace(/\/webhooks\/:id\/[^/?]+/, "/webhooks/:id/:token");
|
1387 |
+
let exceptions = "";
|
1388 |
+
if (method === "DELETE" /* Delete */ && baseRoute === "/channels/:id/messages/:id") {
|
1389 |
+
const id = /\d{17,19}$/.exec(endpoint)[0];
|
1390 |
+
const timestamp = DiscordSnowflake.timestampFrom(id);
|
1391 |
+
if (Date.now() - timestamp > 1e3 * 60 * 60 * 24 * 14) {
|
1392 |
+
exceptions += "/Delete Old Message";
|
1393 |
+
}
|
1394 |
+
}
|
1395 |
+
return {
|
1396 |
+
majorParameter: majorId,
|
1397 |
+
bucketRoute: baseRoute + exceptions,
|
1398 |
+
original: endpoint
|
1399 |
+
};
|
1400 |
+
}
|
1401 |
+
};
|
1402 |
+
|
1403 |
+
// src/shared.ts
|
1404 |
+
var version = "2.2.0";
|
1405 |
+
|
1406 |
+
// src/index.ts
|
1407 |
+
globalThis.FormData ??= FormData2;
|
1408 |
+
globalThis.Blob ??= Blob2;
|
1409 |
+
setDefaultStrategy(shouldUseGlobalFetchAndWebSocket() ? fetch : makeRequest);
|
1410 |
+
export {
|
1411 |
+
ALLOWED_EXTENSIONS,
|
1412 |
+
ALLOWED_SIZES,
|
1413 |
+
ALLOWED_STICKER_EXTENSIONS,
|
1414 |
+
BurstHandlerMajorIdKey,
|
1415 |
+
CDN,
|
1416 |
+
DEPRECATION_WARNING_PREFIX,
|
1417 |
+
DefaultRestOptions,
|
1418 |
+
DefaultUserAgent,
|
1419 |
+
DefaultUserAgentAppendix,
|
1420 |
+
DiscordAPIError,
|
1421 |
+
HTTPError,
|
1422 |
+
OverwrittenMimeTypes,
|
1423 |
+
REST,
|
1424 |
+
RESTEvents,
|
1425 |
+
RateLimitError,
|
1426 |
+
RequestMethod,
|
1427 |
+
calculateUserDefaultAvatarIndex,
|
1428 |
+
makeURLSearchParams,
|
1429 |
+
parseResponse,
|
1430 |
+
version
|
1431 |
+
};
|
1432 |
+
//# sourceMappingURL=index.mjs.map
|
node_modules/@discordjs/rest/dist/index.mjs.map
ADDED
The diff for this file is too large to render.
See raw diff
|
|
node_modules/@discordjs/rest/dist/strategies/undiciRequest.d.mts
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Response, request, RequestInit } from 'undici';
|
2 |
+
import { Readable } from 'node:stream';
|
3 |
+
import { ReadableStream } from 'node:stream/web';
|
4 |
+
|
5 |
+
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | 'headers' | 'json' | 'ok' | 'status' | 'statusText' | 'text'> {
|
6 |
+
body: Readable | ReadableStream | null;
|
7 |
+
}
|
8 |
+
|
9 |
+
type RequestOptions = Exclude<Parameters<typeof request>[1], undefined>;
|
10 |
+
declare function makeRequest(url: string, init: RequestInit): Promise<ResponseLike>;
|
11 |
+
declare function resolveBody(body: RequestInit['body']): Promise<Exclude<RequestOptions['body'], undefined>>;
|
12 |
+
|
13 |
+
export { RequestOptions, makeRequest, resolveBody };
|
node_modules/@discordjs/rest/dist/strategies/undiciRequest.d.ts
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Response, request, RequestInit } from 'undici';
|
2 |
+
import { Readable } from 'node:stream';
|
3 |
+
import { ReadableStream } from 'node:stream/web';
|
4 |
+
|
5 |
+
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | 'headers' | 'json' | 'ok' | 'status' | 'statusText' | 'text'> {
|
6 |
+
body: Readable | ReadableStream | null;
|
7 |
+
}
|
8 |
+
|
9 |
+
type RequestOptions = Exclude<Parameters<typeof request>[1], undefined>;
|
10 |
+
declare function makeRequest(url: string, init: RequestInit): Promise<ResponseLike>;
|
11 |
+
declare function resolveBody(body: RequestInit['body']): Promise<Exclude<RequestOptions['body'], undefined>>;
|
12 |
+
|
13 |
+
export { RequestOptions, makeRequest, resolveBody };
|
node_modules/@discordjs/rest/dist/strategies/undiciRequest.js
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"use strict";
|
2 |
+
var __defProp = Object.defineProperty;
|
3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6 |
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
7 |
+
var __export = (target, all) => {
|
8 |
+
for (var name in all)
|
9 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
10 |
+
};
|
11 |
+
var __copyProps = (to, from, except, desc) => {
|
12 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
13 |
+
for (let key of __getOwnPropNames(from))
|
14 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
15 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16 |
+
}
|
17 |
+
return to;
|
18 |
+
};
|
19 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
20 |
+
|
21 |
+
// src/strategies/undiciRequest.ts
|
22 |
+
var undiciRequest_exports = {};
|
23 |
+
__export(undiciRequest_exports, {
|
24 |
+
makeRequest: () => makeRequest,
|
25 |
+
resolveBody: () => resolveBody
|
26 |
+
});
|
27 |
+
module.exports = __toCommonJS(undiciRequest_exports);
|
28 |
+
var import_node_http = require("http");
|
29 |
+
var import_node_url = require("url");
|
30 |
+
var import_node_util = require("util");
|
31 |
+
var import_undici = require("undici");
|
32 |
+
async function makeRequest(url, init) {
|
33 |
+
const options = {
|
34 |
+
...init,
|
35 |
+
body: await resolveBody(init.body)
|
36 |
+
};
|
37 |
+
const res = await (0, import_undici.request)(url, options);
|
38 |
+
return {
|
39 |
+
body: res.body,
|
40 |
+
async arrayBuffer() {
|
41 |
+
return res.body.arrayBuffer();
|
42 |
+
},
|
43 |
+
async json() {
|
44 |
+
return res.body.json();
|
45 |
+
},
|
46 |
+
async text() {
|
47 |
+
return res.body.text();
|
48 |
+
},
|
49 |
+
get bodyUsed() {
|
50 |
+
return res.body.bodyUsed;
|
51 |
+
},
|
52 |
+
headers: new import_undici.Headers(res.headers),
|
53 |
+
status: res.statusCode,
|
54 |
+
statusText: import_node_http.STATUS_CODES[res.statusCode],
|
55 |
+
ok: res.statusCode >= 200 && res.statusCode < 300
|
56 |
+
};
|
57 |
+
}
|
58 |
+
__name(makeRequest, "makeRequest");
|
59 |
+
async function resolveBody(body) {
|
60 |
+
if (body == null) {
|
61 |
+
return null;
|
62 |
+
} else if (typeof body === "string") {
|
63 |
+
return body;
|
64 |
+
} else if (import_node_util.types.isUint8Array(body)) {
|
65 |
+
return body;
|
66 |
+
} else if (import_node_util.types.isArrayBuffer(body)) {
|
67 |
+
return new Uint8Array(body);
|
68 |
+
} else if (body instanceof import_node_url.URLSearchParams) {
|
69 |
+
return body.toString();
|
70 |
+
} else if (body instanceof DataView) {
|
71 |
+
return new Uint8Array(body.buffer);
|
72 |
+
} else if (body instanceof Blob) {
|
73 |
+
return new Uint8Array(await body.arrayBuffer());
|
74 |
+
} else if (body instanceof FormData) {
|
75 |
+
return body;
|
76 |
+
} else if (body[Symbol.iterator]) {
|
77 |
+
const chunks = [...body];
|
78 |
+
return Buffer.concat(chunks);
|
79 |
+
} else if (body[Symbol.asyncIterator]) {
|
80 |
+
const chunks = [];
|
81 |
+
for await (const chunk of body) {
|
82 |
+
chunks.push(chunk);
|
83 |
+
}
|
84 |
+
return Buffer.concat(chunks);
|
85 |
+
}
|
86 |
+
throw new TypeError(`Unable to resolve body.`);
|
87 |
+
}
|
88 |
+
__name(resolveBody, "resolveBody");
|
89 |
+
// Annotate the CommonJS export names for ESM import in node:
|
90 |
+
0 && (module.exports = {
|
91 |
+
makeRequest,
|
92 |
+
resolveBody
|
93 |
+
});
|
94 |
+
//# sourceMappingURL=undiciRequest.js.map
|
node_modules/@discordjs/rest/dist/strategies/undiciRequest.js.map
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"version":3,"sources":["../../src/strategies/undiciRequest.ts"],"sourcesContent":["import { STATUS_CODES } from 'node:http';\nimport { URLSearchParams } from 'node:url';\nimport { types } from 'node:util';\nimport { type RequestInit, request, Headers } from 'undici';\nimport type { ResponseLike } from '../shared.js';\n\nexport type RequestOptions = Exclude<Parameters<typeof request>[1], undefined>;\n\nexport async function makeRequest(url: string, init: RequestInit): Promise<ResponseLike> {\n\t// The cast is necessary because `headers` and `method` are narrower types in `undici.request`\n\t// our request path guarantees they are of acceptable type for `undici.request`\n\tconst options = {\n\t\t...init,\n\t\tbody: await resolveBody(init.body),\n\t} as RequestOptions;\n\tconst res = await request(url, options);\n\treturn {\n\t\tbody: res.body,\n\t\tasync arrayBuffer() {\n\t\t\treturn res.body.arrayBuffer();\n\t\t},\n\t\tasync json() {\n\t\t\treturn res.body.json();\n\t\t},\n\t\tasync text() {\n\t\t\treturn res.body.text();\n\t\t},\n\t\tget bodyUsed() {\n\t\t\treturn res.body.bodyUsed;\n\t\t},\n\t\theaders: new Headers(res.headers as Record<string, string[] | string>),\n\t\tstatus: res.statusCode,\n\t\tstatusText: STATUS_CODES[res.statusCode]!,\n\t\tok: res.statusCode >= 200 && res.statusCode < 300,\n\t};\n}\n\nexport async function resolveBody(body: RequestInit['body']): Promise<Exclude<RequestOptions['body'], undefined>> {\n\t// eslint-disable-next-line no-eq-null, eqeqeq\n\tif (body == null) {\n\t\treturn null;\n\t} else if (typeof body === 'string') {\n\t\treturn body;\n\t} else if (types.isUint8Array(body)) {\n\t\treturn body;\n\t} else if (types.isArrayBuffer(body)) {\n\t\treturn new Uint8Array(body);\n\t} else if (body instanceof URLSearchParams) {\n\t\treturn body.toString();\n\t} else if (body instanceof DataView) {\n\t\treturn new Uint8Array(body.buffer);\n\t} else if (body instanceof Blob) {\n\t\treturn new Uint8Array(await body.arrayBuffer());\n\t} else if (body instanceof FormData) {\n\t\treturn body;\n\t} else if ((body as Iterable<Uint8Array>)[Symbol.iterator]) {\n\t\tconst chunks = [...(body as Iterable<Uint8Array>)];\n\n\t\treturn Buffer.concat(chunks);\n\t} else if ((body as AsyncIterable<Uint8Array>)[Symbol.asyncIterator]) {\n\t\tconst chunks: Uint8Array[] = [];\n\n\t\tfor await (const chunk of body as AsyncIterable<Uint8Array>) {\n\t\t\tchunks.push(chunk);\n\t\t}\n\n\t\treturn Buffer.concat(chunks);\n\t}\n\n\tthrow new TypeError(`Unable to resolve body.`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA6B;AAC7B,sBAAgC;AAChC,uBAAsB;AACtB,oBAAmD;AAKnD,eAAsB,YAAY,KAAa,MAA0C;A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