Delete workspace
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- workspace/.bash_history +0 -59
- workspace/.gitattributes +0 -79
- workspace/database_merger/cache.sqlite +0 -3
- workspace/database_merger/creator.py +0 -198
- workspace/database_merger/fully_merged_database.sqlite +0 -3
- workspace/database_merger/merger.py +0 -150
- workspace/discord-bot/node_modules/.package-lock.json +0 -316
- workspace/discord-bot/node_modules/@discordjs/builders/LICENSE +0 -191
- workspace/discord-bot/node_modules/@discordjs/builders/README.md +0 -72
- workspace/discord-bot/node_modules/@discordjs/builders/dist/index.d.mts +0 -0
- workspace/discord-bot/node_modules/@discordjs/builders/dist/index.d.ts +0 -0
- workspace/discord-bot/node_modules/@discordjs/builders/dist/index.js +0 -0
- workspace/discord-bot/node_modules/@discordjs/builders/dist/index.js.map +0 -0
- workspace/discord-bot/node_modules/@discordjs/builders/dist/index.mjs +0 -0
- workspace/discord-bot/node_modules/@discordjs/builders/dist/index.mjs.map +0 -0
- workspace/discord-bot/node_modules/@discordjs/builders/package.json +0 -99
- workspace/discord-bot/node_modules/@discordjs/collection/CHANGELOG.md +0 -190
- workspace/discord-bot/node_modules/@discordjs/collection/LICENSE +0 -191
- workspace/discord-bot/node_modules/@discordjs/collection/README.md +0 -67
- workspace/discord-bot/node_modules/@discordjs/collection/dist/index.d.mts +0 -457
- workspace/discord-bot/node_modules/@discordjs/collection/dist/index.d.ts +0 -457
- workspace/discord-bot/node_modules/@discordjs/collection/dist/index.js +0 -543
- workspace/discord-bot/node_modules/@discordjs/collection/dist/index.js.map +0 -1
- workspace/discord-bot/node_modules/@discordjs/collection/dist/index.mjs +0 -517
- workspace/discord-bot/node_modules/@discordjs/collection/dist/index.mjs.map +0 -1
- workspace/discord-bot/node_modules/@discordjs/collection/package.json +0 -76
- workspace/discord-bot/node_modules/@discordjs/formatters/LICENSE +0 -191
- workspace/discord-bot/node_modules/@discordjs/formatters/README.md +0 -82
- workspace/discord-bot/node_modules/@discordjs/formatters/dist/index.d.mts +0 -673
- workspace/discord-bot/node_modules/@discordjs/formatters/dist/index.d.ts +0 -673
- workspace/discord-bot/node_modules/@discordjs/formatters/dist/index.js +0 -452
- workspace/discord-bot/node_modules/@discordjs/formatters/dist/index.js.map +0 -1
- workspace/discord-bot/node_modules/@discordjs/formatters/dist/index.mjs +0 -385
- workspace/discord-bot/node_modules/@discordjs/formatters/dist/index.mjs.map +0 -1
- workspace/discord-bot/node_modules/@discordjs/formatters/package.json +0 -83
- workspace/discord-bot/node_modules/@discordjs/rest/LICENSE +0 -192
- workspace/discord-bot/node_modules/@discordjs/rest/README.md +0 -138
- workspace/discord-bot/node_modules/@discordjs/rest/dist/index.d.mts +0 -958
- workspace/discord-bot/node_modules/@discordjs/rest/dist/index.d.ts +0 -958
- workspace/discord-bot/node_modules/@discordjs/rest/dist/index.js +0 -1515
- workspace/discord-bot/node_modules/@discordjs/rest/dist/index.js.map +0 -0
- workspace/discord-bot/node_modules/@discordjs/rest/dist/index.mjs +0 -1473
- workspace/discord-bot/node_modules/@discordjs/rest/dist/index.mjs.map +0 -0
- workspace/discord-bot/node_modules/@discordjs/rest/dist/strategies/undiciRequest.d.mts +0 -13
- workspace/discord-bot/node_modules/@discordjs/rest/dist/strategies/undiciRequest.d.ts +0 -13
- workspace/discord-bot/node_modules/@discordjs/rest/dist/strategies/undiciRequest.js +0 -94
- workspace/discord-bot/node_modules/@discordjs/rest/dist/strategies/undiciRequest.js.map +0 -1
- workspace/discord-bot/node_modules/@discordjs/rest/dist/strategies/undiciRequest.mjs +0 -70
- workspace/discord-bot/node_modules/@discordjs/rest/dist/strategies/undiciRequest.mjs.map +0 -1
- workspace/discord-bot/node_modules/@discordjs/rest/dist/web.d.mts +0 -958
workspace/.bash_history
DELETED
|
@@ -1,59 +0,0 @@
|
|
| 1 |
-
. #LoveSongs
|
| 2 |
-
mkdir discord-bot && cd discord-bot
|
| 3 |
-
npm init -y
|
| 4 |
-
npm install discord.js dotenv
|
| 5 |
-
mkdir video-gen-bot
|
| 6 |
-
cd video-gen-bot
|
| 7 |
-
npm init -y
|
| 8 |
-
npm install discord.js dotenv
|
| 9 |
-
touch index.js .env
|
| 10 |
-
cat > index.js << 'EOF'
|
| 11 |
-
require('dotenv').config();
|
| 12 |
-
const { Client, GatewayIntentBits } = require('discord.js');
|
| 13 |
-
|
| 14 |
-
const client = new Client({
|
| 15 |
-
intents: [
|
| 16 |
-
GatewayIntentBits.Guilds,
|
| 17 |
-
GatewayIntentBits.GuildMes
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
jwerjwer
|
| 21 |
-
wejrsages,
|
| 22 |
-
GatewayIntentBits.MessageContent
|
| 23 |
-
]
|
| 24 |
-
});
|
| 25 |
-
|
| 26 |
-
client.once('ready', () => {
|
| 27 |
-
console.log(`🤖 Logged in as ${client.user.tag}`);
|
| 28 |
-
});
|
| 29 |
-
|
| 30 |
-
client.on('messageCreate', async (message) => {
|
| 31 |
-
if (message.author.bot) return;
|
| 32 |
-
|
| 33 |
-
if (message.content === '!ping') {
|
| 34 |
-
await message.reply('🏓 Pong!');
|
| 35 |
-
}
|
| 36 |
-
|
| 37 |
-
if (message.content.startsWith('!say ')) {
|
| 38 |
-
const text = message.content.replace('!say ', '');
|
| 39 |
-
await message.channel.send(text);
|
| 40 |
-
}
|
| 41 |
-
});
|
| 42 |
-
|
| 43 |
-
client.login(process.env.DISCORD_TOKEN);
|
| 44 |
-
EOF
|
| 45 |
-
|
| 46 |
-
node index.js
|
| 47 |
-
flutter --version
|
| 48 |
-
help
|
| 49 |
-
cls
|
| 50 |
-
clear
|
| 51 |
-
hf
|
| 52 |
-
pip install huggingface_hub[cli]
|
| 53 |
-
hf
|
| 54 |
-
hf auth login
|
| 55 |
-
hf auth whoami
|
| 56 |
-
hf upload ThongCoder/vscode-public-data /home/vscode/ / --repo-type dataset
|
| 57 |
-
hf upload -h
|
| 58 |
-
hf upload ThongCoder/vscode-public-data /home/vscode/ / --repo-type dataset
|
| 59 |
-
hf upload ThongCoder/vscode-public-data /home/vscode/ / --repo-type dataset --exclude .cache/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/.gitattributes
DELETED
|
@@ -1,79 +0,0 @@
|
|
| 1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
-
*.lz4 filter=lfs diff=lfs merge=lfs -text
|
| 12 |
-
*.mds filter=lfs diff=lfs merge=lfs -text
|
| 13 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 14 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
| 15 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 16 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 17 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 18 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 19 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 20 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 21 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 22 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 23 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 24 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 25 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 26 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 27 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 28 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 29 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 30 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 31 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 32 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 34 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 35 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 36 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 37 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 38 |
-
# Audio files - uncompressed
|
| 39 |
-
*.pcm filter=lfs diff=lfs merge=lfs -text
|
| 40 |
-
*.sam filter=lfs diff=lfs merge=lfs -text
|
| 41 |
-
*.raw filter=lfs diff=lfs merge=lfs -text
|
| 42 |
-
# Audio files - compressed
|
| 43 |
-
*.aac filter=lfs diff=lfs merge=lfs -text
|
| 44 |
-
*.flac filter=lfs diff=lfs merge=lfs -text
|
| 45 |
-
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 46 |
-
*.ogg filter=lfs diff=lfs merge=lfs -text
|
| 47 |
-
*.wav filter=lfs diff=lfs merge=lfs -text
|
| 48 |
-
# Image files - uncompressed
|
| 49 |
-
*.bmp filter=lfs diff=lfs merge=lfs -text
|
| 50 |
-
*.gif filter=lfs diff=lfs merge=lfs -text
|
| 51 |
-
*.png filter=lfs diff=lfs merge=lfs -text
|
| 52 |
-
*.tiff filter=lfs diff=lfs merge=lfs -text
|
| 53 |
-
# Image files - compressed
|
| 54 |
-
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
-
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 56 |
-
*.webp filter=lfs diff=lfs merge=lfs -text
|
| 57 |
-
# Video files - compressed
|
| 58 |
-
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 59 |
-
*.webm filter=lfs diff=lfs merge=lfs -text
|
| 60 |
-
.local/lib/python3.12/site-packages/__pycache__/typing_extensions.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 61 |
-
.local/lib/python3.12/site-packages/charset_normalizer/md__mypyc.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 62 |
-
.local/lib/python3.12/site-packages/hf_xet/hf_xet.abi3.so filter=lfs diff=lfs merge=lfs -text
|
| 63 |
-
.local/lib/python3.12/site-packages/huggingface_hub/__pycache__/hf_api.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 64 |
-
.local/lib/python3.12/site-packages/huggingface_hub/inference/__pycache__/_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 65 |
-
.local/lib/python3.12/site-packages/huggingface_hub/inference/_generated/__pycache__/_async_client.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 66 |
-
.local/lib/python3.12/site-packages/idna/__pycache__/uts46data.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 67 |
-
.local/lib/python3.12/site-packages/prompt_toolkit/key_binding/bindings/__pycache__/vi.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 68 |
-
.local/lib/python3.12/site-packages/prompt_toolkit/layout/__pycache__/containers.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 69 |
-
.local/lib/python3.12/site-packages/yaml/_yaml.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 70 |
-
.npm/_cacache/content-v2/sha512/44/36/2b866a41ee64ef98229ca63fa973993b3ce2accd2e04d8ef5361cf94f98e226823feafdd7441d3b8dea9a93a36bc2d1af5449d1bdd4f82a95b273eacdfe3 filter=lfs diff=lfs merge=lfs -text
|
| 71 |
-
.npm/_cacache/content-v2/sha512/6e/aa/9b78e21a0d12245985603287e696ec966beef57d565152addf0922fb95895816ea4fed8b6f50eeb3333900bf9356ee8d0ea4a7abe6947db5062a3b412c07 filter=lfs diff=lfs merge=lfs -text
|
| 72 |
-
.npm/_cacache/content-v2/sha512/77/d7/54996540ecc3222a86cbdd5a4b17c3f669e6a7453bbaca91b6388684bff6471ff494436887395ca2e7000f8d0f879a732e2f4c212bd7b3f08feb6966ed22 filter=lfs diff=lfs merge=lfs -text
|
| 73 |
-
.npm/_cacache/content-v2/sha512/80/12/e46089449d2a7ca456d3eb8c8580613a50807db40921ba40b6dcf98c0c27b935df9c46a2b14a3c39cb9e0c2b601932065f25631a344e276141e08b55c43b filter=lfs diff=lfs merge=lfs -text
|
| 74 |
-
.npm/_cacache/content-v2/sha512/a7/79/1fe5e578f422624537e1b6eb5409e8af4b243f9762652a8756d59aae470c2f94e5a61bdfba8c54a15fac7cad48988673fac0a23deab80dfd25cccb97b96b filter=lfs diff=lfs merge=lfs -text
|
| 75 |
-
.npm/_cacache/content-v2/sha512/bf/69/0311ee7b95e713ba568322e3533f2dd1cb880b189e99d4edef13592b81764daec43e2c54c61d5c558dc5cfb35ecb85b65519e74026ff17675b6f8f916f4a filter=lfs diff=lfs merge=lfs -text
|
| 76 |
-
.npm/_cacache/content-v2/sha512/c0/f9/500f11269438392318493eec57af7572f408d8ab9c42bc55862720fbc3b369f191aef8c73ef7b2c2a0473ff80602a36203a4a8a8887d3f73f9a3e5947d53 filter=lfs diff=lfs merge=lfs -text
|
| 77 |
-
.npm/_cacache/content-v2/sha512/da/09/d8ae05cddf24e5bf670a048488fc0f1bb59c2c4992f02a92105de235712f1aed6ef03f7b055503a6de63eeba29d30fc8c908a18f18d1f7f7dcc4ed49f590 filter=lfs diff=lfs merge=lfs -text
|
| 78 |
-
.npm/_cacache/content-v2/sha512/de/4f/8a8ac77fbf9ef426bebc03590db3ba9584d7a10f00c900f7b80d9d92cadfbfce86dff7311cb9816fb1f21a00e8026b40621cc7ce38a418e1e608365d33ef filter=lfs diff=lfs merge=lfs -text
|
| 79 |
-
.npm/_cacache/content-v2/sha512/de/f5/e64035f2fb0a33fa09eb4efbaf36b3f37a43a2f83b3445e331c342f30622b76bed64d24427f5fd8d5a4fa5803e2b25e845526632da0321276648fbb60ff6 filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/database_merger/cache.sqlite
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:757ba8de1bd7a924d975ea09ca7502b45a8722675a3ccf2ccfce3f4053f92ff9
|
| 3 |
-
size 1482752
|
|
|
|
|
|
|
|
|
|
|
|
workspace/database_merger/creator.py
DELETED
|
@@ -1,198 +0,0 @@
|
|
| 1 |
-
import sqlite3, random, re
|
| 2 |
-
|
| 3 |
-
def connect() -> sqlite3.Connection:
|
| 4 |
-
db = sqlite3.connect("cache.sqlite")
|
| 5 |
-
|
| 6 |
-
db.execute('PRAGMA temp_store = MEMORY')
|
| 7 |
-
db.execute('PRAGMA journal_mode = MEMORY')
|
| 8 |
-
db.execute('PRAGMA synchronous = OFF')
|
| 9 |
-
db.commit()
|
| 10 |
-
return db
|
| 11 |
-
|
| 12 |
-
class Element:
|
| 13 |
-
def __init__(
|
| 14 |
-
self,
|
| 15 |
-
name: str,
|
| 16 |
-
emoji: str | None = None,
|
| 17 |
-
database_id: int | None = None,
|
| 18 |
-
) -> None:
|
| 19 |
-
self.name = name
|
| 20 |
-
self.emoji = emoji
|
| 21 |
-
self.database_id = database_id
|
| 22 |
-
|
| 23 |
-
def __hash__(self) -> int:
|
| 24 |
-
return hash(self.name)
|
| 25 |
-
|
| 26 |
-
def __eq__(self, other: "Element") -> bool:
|
| 27 |
-
return self.name == other.name
|
| 28 |
-
|
| 29 |
-
def __str__(self) -> str:
|
| 30 |
-
return f"{self.emoji} {self.name}"
|
| 31 |
-
|
| 32 |
-
def __repr__(self) -> str:
|
| 33 |
-
return repr(str(self))
|
| 34 |
-
|
| 35 |
-
@property
|
| 36 |
-
def numeric(self) -> bool:
|
| 37 |
-
return re.search(r"\d", self.name) is not None
|
| 38 |
-
|
| 39 |
-
class Pair:
|
| 40 |
-
def __init__(
|
| 41 |
-
self,
|
| 42 |
-
first: Element,
|
| 43 |
-
second: Element,
|
| 44 |
-
result: Element,
|
| 45 |
-
is_discovery: bool | None = None,
|
| 46 |
-
) -> None:
|
| 47 |
-
self.first = first
|
| 48 |
-
self.second = second
|
| 49 |
-
self.result = result
|
| 50 |
-
self.is_discovery = is_discovery is True
|
| 51 |
-
|
| 52 |
-
def __str__(self) -> str:
|
| 53 |
-
addendum = " (New Discovery!)" if self.is_discovery else ""
|
| 54 |
-
return f"{self.first} + {self.second} = {self.result}{addendum}"
|
| 55 |
-
|
| 56 |
-
def __repr__(self) -> str:
|
| 57 |
-
addendum = " (New Discovery!)" if self.is_discovery else ""
|
| 58 |
-
return f"{self.first!r} + {self.second!r} = {self.result!r}{addendum}"
|
| 59 |
-
|
| 60 |
-
@property
|
| 61 |
-
def elements(self) -> tuple[Element, Element, Element]:
|
| 62 |
-
return self.first, self.second, self.result
|
| 63 |
-
|
| 64 |
-
def _upsert_element(conn: sqlite3.Connection, element: Element) -> None:
|
| 65 |
-
conn.execute(
|
| 66 |
-
"""
|
| 67 |
-
INSERT INTO element (name, emoji)
|
| 68 |
-
VALUES (?, ?)
|
| 69 |
-
ON CONFLICT(name) DO UPDATE SET
|
| 70 |
-
emoji = excluded.emoji
|
| 71 |
-
""",
|
| 72 |
-
(element.name, element.emoji),
|
| 73 |
-
)
|
| 74 |
-
|
| 75 |
-
(element.database_id,) = conn.execute(
|
| 76 |
-
"SELECT id FROM element WHERE name = ?",
|
| 77 |
-
(element.name,),
|
| 78 |
-
).fetchone()
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
def _upsert_pair(conn: sqlite3.Connection, pair: Pair) -> None:
|
| 82 |
-
# first, insert the elements:
|
| 83 |
-
for element in pair.elements:
|
| 84 |
-
if element.database_id is not None:
|
| 85 |
-
continue
|
| 86 |
-
|
| 87 |
-
_upsert_element(conn, element)
|
| 88 |
-
|
| 89 |
-
# now, record the pair:
|
| 90 |
-
conn.execute(
|
| 91 |
-
"""
|
| 92 |
-
INSERT INTO pair (first_element_id, second_element_id, result_element_id, is_discovery)
|
| 93 |
-
VALUES (?, ?, ?, ?)
|
| 94 |
-
ON CONFLICT(first_element_id, second_element_id) DO UPDATE SET
|
| 95 |
-
result_element_id = excluded.result_element_id,
|
| 96 |
-
is_discovery = MAX(is_discovery, excluded.is_discovery)
|
| 97 |
-
""",
|
| 98 |
-
(*(e.database_id for e in pair.elements), 1 if pair.is_discovery else 0),
|
| 99 |
-
)
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
def record_pair(pair: Pair) -> None:
|
| 103 |
-
with connect() as conn:
|
| 104 |
-
_upsert_pair(conn, pair)
|
| 105 |
-
|
| 106 |
-
def get_name_and_emoji(db, id):
|
| 107 |
-
try:
|
| 108 |
-
(name, emoji) = db.execute('SELECT name, emoji FROM element WHERE id = ?', (id,)).fetchone()
|
| 109 |
-
return name, emoji
|
| 110 |
-
except:
|
| 111 |
-
return None, None
|
| 112 |
-
|
| 113 |
-
old_db = sqlite3.connect("fully_merged_database.sqlite")
|
| 114 |
-
|
| 115 |
-
new_db = sqlite3.connect('cache.sqlite')
|
| 116 |
-
new_db.execute(
|
| 117 |
-
"""
|
| 118 |
-
CREATE TABLE IF NOT EXISTS element (
|
| 119 |
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 120 |
-
first_created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
| 121 |
-
name TEXT UNIQUE,
|
| 122 |
-
emoji TEXT
|
| 123 |
-
)
|
| 124 |
-
""",
|
| 125 |
-
)
|
| 126 |
-
|
| 127 |
-
new_db.execute(
|
| 128 |
-
"""
|
| 129 |
-
CREATE TABLE IF NOT EXISTS pair (
|
| 130 |
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 131 |
-
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
| 132 |
-
first_element_id INTEGER,
|
| 133 |
-
second_element_id INTEGER,
|
| 134 |
-
result_element_id INTEGER,
|
| 135 |
-
is_discovery INTEGER,
|
| 136 |
-
FOREIGN KEY (first_element_id) REFERENCES element (id),
|
| 137 |
-
FOREIGN KEY (second_element_id) REFERENCES element (id),
|
| 138 |
-
FOREIGN KEY (result_element_id) REFERENCES element (id)
|
| 139 |
-
UNIQUE(first_element_id, second_element_id)
|
| 140 |
-
)
|
| 141 |
-
""",
|
| 142 |
-
)
|
| 143 |
-
|
| 144 |
-
with connect() as conn:
|
| 145 |
-
primary_elements = [
|
| 146 |
-
Element("Fire", "\N{FIRE}"),
|
| 147 |
-
Element("Earth", "\N{EARTH GLOBE EUROPE-AFRICA}"),
|
| 148 |
-
Element("Water", "\N{DROPLET}"),
|
| 149 |
-
Element("Wind", "\N{WIND BLOWING FACE}"),
|
| 150 |
-
]
|
| 151 |
-
|
| 152 |
-
# The search order is "mostly deterministic" on the macroscopic scale
|
| 153 |
-
# so randomize the order of the primary elements so that everyone who runs
|
| 154 |
-
# this code gets one of 4! (factorial) possible "macroscopic routes"
|
| 155 |
-
random.shuffle(primary_elements)
|
| 156 |
-
|
| 157 |
-
for e in primary_elements:
|
| 158 |
-
_upsert_element(conn, e)
|
| 159 |
-
|
| 160 |
-
new_db.commit()
|
| 161 |
-
|
| 162 |
-
old_db.execute('PRAGMA temp_store = MEMORY')
|
| 163 |
-
old_db.execute('PRAGMA journal_mode = MEMORY')
|
| 164 |
-
old_db.execute('PRAGMA synchronous = OFF')
|
| 165 |
-
old_db.commit()
|
| 166 |
-
|
| 167 |
-
new_db.close()
|
| 168 |
-
|
| 169 |
-
count = 0
|
| 170 |
-
for item in old_db.execute('SELECT id, first_element_id, second_element_id, result_element_id, is_discovery FROM pair'):
|
| 171 |
-
id, first, second, result, is_discovery = item
|
| 172 |
-
name, emoji = get_name_and_emoji(old_db, first)
|
| 173 |
-
first = Element(name, emoji)
|
| 174 |
-
if not first:
|
| 175 |
-
old_db.execute('DELETE FROM pair WHERE id = ?', (id,))
|
| 176 |
-
old_db.commit()
|
| 177 |
-
total -= 1
|
| 178 |
-
continue
|
| 179 |
-
name, emoji = get_name_and_emoji(old_db, second)
|
| 180 |
-
second = Element(name, emoji)
|
| 181 |
-
if not second:
|
| 182 |
-
old_db.execute('DELETE FROM pair WHERE id = ?', (id,))
|
| 183 |
-
old_db.commit()
|
| 184 |
-
total -= 1
|
| 185 |
-
continue
|
| 186 |
-
name, emoji = get_name_and_emoji(old_db, result)
|
| 187 |
-
result = Element(name, emoji)
|
| 188 |
-
if not result:
|
| 189 |
-
old_db.execute('DELETE FROM pair WHERE id = ?', (id,))
|
| 190 |
-
old_db.commit()
|
| 191 |
-
total -= 1
|
| 192 |
-
continue
|
| 193 |
-
is_discovery = True if is_discovery == 1 else False
|
| 194 |
-
pair = Pair(first, second, result, is_discovery)
|
| 195 |
-
record_pair(pair)
|
| 196 |
-
count += 1
|
| 197 |
-
print(f'(#{count:,}) Done: {first} + {second} = {result} ', end='\r')
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/database_merger/fully_merged_database.sqlite
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:b67fe2b54d9096d132e375d58c9ef157ba6a8f41bf02e04fccda71313be956b7
|
| 3 |
-
size 5334786048
|
|
|
|
|
|
|
|
|
|
|
|
workspace/database_merger/merger.py
DELETED
|
@@ -1,150 +0,0 @@
|
|
| 1 |
-
import sqlite3, time
|
| 2 |
-
from collections import OrderedDict
|
| 3 |
-
|
| 4 |
-
MAIN_DB = "fully_merged_database.sqlite"
|
| 5 |
-
PRINT_INTERVAL = 0.1 # seconds
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
class Element:
|
| 9 |
-
__slots__ = ("name", "emoji", "database_id")
|
| 10 |
-
def __init__(self, name, emoji=None, database_id=None):
|
| 11 |
-
self.name, self.emoji, self.database_id = name, emoji, database_id
|
| 12 |
-
def __hash__(self): return hash(self.name)
|
| 13 |
-
def __eq__(self, other): return self.name == other.name
|
| 14 |
-
def __str__(self): return f"{self.emoji or ''} {self.name}"
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
class ElementCache:
|
| 18 |
-
def __init__(self, conn):
|
| 19 |
-
self.conn, self.cache = conn, OrderedDict()
|
| 20 |
-
for row in conn.execute("SELECT id, name, emoji FROM element"):
|
| 21 |
-
self.cache[row[1]] = Element(row[1], row[2], row[0])
|
| 22 |
-
|
| 23 |
-
def get_or_create(self, elem: Element):
|
| 24 |
-
if elem.name in self.cache:
|
| 25 |
-
return self.cache[elem.name].database_id
|
| 26 |
-
|
| 27 |
-
cur = self.conn.execute(
|
| 28 |
-
"INSERT INTO element (name, emoji) VALUES (?, ?) "
|
| 29 |
-
"ON CONFLICT(name) DO UPDATE SET emoji=excluded.emoji",
|
| 30 |
-
(elem.name, elem.emoji),
|
| 31 |
-
)
|
| 32 |
-
rowid = cur.lastrowid
|
| 33 |
-
if rowid != 0:
|
| 34 |
-
elem.database_id = rowid
|
| 35 |
-
else:
|
| 36 |
-
elem.database_id = self.conn.execute(
|
| 37 |
-
"SELECT id FROM element WHERE name=?", (elem.name,)
|
| 38 |
-
).fetchone()[0]
|
| 39 |
-
self.cache[elem.name] = elem
|
| 40 |
-
return elem.database_id
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
def connect():
|
| 44 |
-
conn = sqlite3.connect(MAIN_DB)
|
| 45 |
-
conn.execute("PRAGMA synchronous = OFF")
|
| 46 |
-
conn.execute("PRAGMA journal_mode = MEMORY")
|
| 47 |
-
conn.execute("PRAGMA temp_store = MEMORY")
|
| 48 |
-
conn.execute("PRAGMA locking_mode = EXCLUSIVE")
|
| 49 |
-
conn.execute("PRAGMA cache_size = -200000") # ~200MB RAM
|
| 50 |
-
return conn
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
def init_db(conn):
|
| 54 |
-
conn.execute("""
|
| 55 |
-
CREATE TABLE IF NOT EXISTS element (
|
| 56 |
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 57 |
-
first_created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
| 58 |
-
name TEXT UNIQUE,
|
| 59 |
-
emoji TEXT
|
| 60 |
-
)
|
| 61 |
-
""")
|
| 62 |
-
conn.execute("""
|
| 63 |
-
CREATE TABLE IF NOT EXISTS pair (
|
| 64 |
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 65 |
-
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
|
| 66 |
-
first_element_id INTEGER,
|
| 67 |
-
second_element_id INTEGER,
|
| 68 |
-
result_element_id INTEGER,
|
| 69 |
-
is_discovery INTEGER,
|
| 70 |
-
FOREIGN KEY (first_element_id) REFERENCES element (id),
|
| 71 |
-
FOREIGN KEY (second_element_id) REFERENCES element (id),
|
| 72 |
-
FOREIGN KEY (result_element_id) REFERENCES element (id),
|
| 73 |
-
UNIQUE(first_element_id, second_element_id)
|
| 74 |
-
)
|
| 75 |
-
""")
|
| 76 |
-
conn.commit()
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
def merge_one_file(dbfile, conn, cache, start_count=0):
|
| 80 |
-
src = sqlite3.connect(dbfile, uri=True)
|
| 81 |
-
src.execute("PRAGMA synchronous = OFF")
|
| 82 |
-
src.execute("PRAGMA journal_mode = MEMORY")
|
| 83 |
-
src.execute("PRAGMA temp_store = MEMORY")
|
| 84 |
-
src.commit()
|
| 85 |
-
conn.execute("BEGIN IMMEDIATE")
|
| 86 |
-
id_to_element = {row[0]: Element(row[1], row[2]) for row in src.execute("SELECT id, name, emoji FROM element")}
|
| 87 |
-
pps = 0
|
| 88 |
-
count, estim = start_count, 0
|
| 89 |
-
last_time = time.perf_counter()
|
| 90 |
-
|
| 91 |
-
for first_id, second_id, result_id, is_disc in src.execute(
|
| 92 |
-
"SELECT first_element_id, second_element_id, result_element_id, is_discovery FROM pair"
|
| 93 |
-
):
|
| 94 |
-
try:
|
| 95 |
-
first = id_to_element[first_id]
|
| 96 |
-
second = id_to_element[second_id]
|
| 97 |
-
result = id_to_element[result_id]
|
| 98 |
-
except KeyError:
|
| 99 |
-
continue
|
| 100 |
-
|
| 101 |
-
# resolve element IDs
|
| 102 |
-
for e in (first, second, result):
|
| 103 |
-
cache.get_or_create(e)
|
| 104 |
-
|
| 105 |
-
conn.execute("""
|
| 106 |
-
INSERT INTO pair (first_element_id, second_element_id, result_element_id, is_discovery)
|
| 107 |
-
VALUES (?, ?, ?, ?)
|
| 108 |
-
ON CONFLICT(first_element_id, second_element_id) DO UPDATE SET
|
| 109 |
-
result_element_id=excluded.result_element_id,
|
| 110 |
-
is_discovery=MAX(is_discovery, excluded.is_discovery)
|
| 111 |
-
""", (first.database_id, second.database_id, result.database_id, is_disc))
|
| 112 |
-
|
| 113 |
-
count += 1
|
| 114 |
-
estim += 1
|
| 115 |
-
now = time.perf_counter()
|
| 116 |
-
if now - last_time >= PRINT_INTERVAL:
|
| 117 |
-
pps = estim / (now - last_time)
|
| 118 |
-
last_time, estim = now, 0
|
| 119 |
-
print(f"(#{count:,} | PPS: {pps:,.0f}/s) Adding pair: {first} + {second} = {result}", end="\r")
|
| 120 |
-
|
| 121 |
-
src.close()
|
| 122 |
-
print('\nCommiting...')
|
| 123 |
-
conn.commit()
|
| 124 |
-
print(f"Finished merging {dbfile}, total so far: {count:,}")
|
| 125 |
-
return count
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
def merge_multiple(files):
|
| 129 |
-
with connect() as conn:
|
| 130 |
-
init_db(conn)
|
| 131 |
-
cache = ElementCache(conn)
|
| 132 |
-
|
| 133 |
-
count = 0
|
| 134 |
-
for f in files:
|
| 135 |
-
count = merge_one_file(f, conn, cache, start_count=count)
|
| 136 |
-
|
| 137 |
-
print(f"\n✅ All done! {count:,} pairs merged.")
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
if __name__ == "__main__":
|
| 141 |
-
files = [
|
| 142 |
-
"cache (2).sqlite",
|
| 143 |
-
"cache (3).sqlite",
|
| 144 |
-
"cache (4).sqlite",
|
| 145 |
-
"c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/discord-bot/node_modules/.package-lock.json
DELETED
|
@@ -1,316 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "discord-bot",
|
| 3 |
-
"version": "1.0.0",
|
| 4 |
-
"lockfileVersion": 3,
|
| 5 |
-
"requires": true,
|
| 6 |
-
"packages": {
|
| 7 |
-
"node_modules/@discordjs/builders": {
|
| 8 |
-
"version": "1.11.3",
|
| 9 |
-
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.11.3.tgz",
|
| 10 |
-
"integrity": "sha512-p3kf5eV49CJiRTfhtutUCeivSyQ/l2JlKodW1ZquRwwvlOWmG9+6jFShX6x8rUiYhnP6wKI96rgN/SXMy5e5aw==",
|
| 11 |
-
"license": "Apache-2.0",
|
| 12 |
-
"dependencies": {
|
| 13 |
-
"@discordjs/formatters": "^0.6.1",
|
| 14 |
-
"@discordjs/util": "^1.1.1",
|
| 15 |
-
"@sapphire/shapeshift": "^4.0.0",
|
| 16 |
-
"discord-api-types": "^0.38.16",
|
| 17 |
-
"fast-deep-equal": "^3.1.3",
|
| 18 |
-
"ts-mixer": "^6.0.4",
|
| 19 |
-
"tslib": "^2.6.3"
|
| 20 |
-
},
|
| 21 |
-
"engines": {
|
| 22 |
-
"node": ">=16.11.0"
|
| 23 |
-
},
|
| 24 |
-
"funding": {
|
| 25 |
-
"url": "https://github.com/discordjs/discord.js?sponsor"
|
| 26 |
-
}
|
| 27 |
-
},
|
| 28 |
-
"node_modules/@discordjs/collection": {
|
| 29 |
-
"version": "1.5.3",
|
| 30 |
-
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-1.5.3.tgz",
|
| 31 |
-
"integrity": "sha512-SVb428OMd3WO1paV3rm6tSjM4wC+Kecaa1EUGX7vc6/fddvw/6lg90z4QtCqm21zvVe92vMMDt9+DkIvjXImQQ==",
|
| 32 |
-
"license": "Apache-2.0",
|
| 33 |
-
"engines": {
|
| 34 |
-
"node": ">=16.11.0"
|
| 35 |
-
}
|
| 36 |
-
},
|
| 37 |
-
"node_modules/@discordjs/formatters": {
|
| 38 |
-
"version": "0.6.1",
|
| 39 |
-
"resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.6.1.tgz",
|
| 40 |
-
"integrity": "sha512-5cnX+tASiPCqCWtFcFslxBVUaCetB0thvM/JyavhbXInP1HJIEU+Qv/zMrnuwSsX3yWH2lVXNJZeDK3EiP4HHg==",
|
| 41 |
-
"license": "Apache-2.0",
|
| 42 |
-
"dependencies": {
|
| 43 |
-
"discord-api-types": "^0.38.1"
|
| 44 |
-
},
|
| 45 |
-
"engines": {
|
| 46 |
-
"node": ">=16.11.0"
|
| 47 |
-
},
|
| 48 |
-
"funding": {
|
| 49 |
-
"url": "https://github.com/discordjs/discord.js?sponsor"
|
| 50 |
-
}
|
| 51 |
-
},
|
| 52 |
-
"node_modules/@discordjs/rest": {
|
| 53 |
-
"version": "2.6.0",
|
| 54 |
-
"resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.6.0.tgz",
|
| 55 |
-
"integrity": "sha512-RDYrhmpB7mTvmCKcpj+pc5k7POKszS4E2O9TYc+U+Y4iaCP+r910QdO43qmpOja8LRr1RJ0b3U+CqVsnPqzf4w==",
|
| 56 |
-
"license": "Apache-2.0",
|
| 57 |
-
"dependencies": {
|
| 58 |
-
"@discordjs/collection": "^2.1.1",
|
| 59 |
-
"@discordjs/util": "^1.1.1",
|
| 60 |
-
"@sapphire/async-queue": "^1.5.3",
|
| 61 |
-
"@sapphire/snowflake": "^3.5.3",
|
| 62 |
-
"@vladfrangu/async_event_emitter": "^2.4.6",
|
| 63 |
-
"discord-api-types": "^0.38.16",
|
| 64 |
-
"magic-bytes.js": "^1.10.0",
|
| 65 |
-
"tslib": "^2.6.3",
|
| 66 |
-
"undici": "6.21.3"
|
| 67 |
-
},
|
| 68 |
-
"engines": {
|
| 69 |
-
"node": ">=18"
|
| 70 |
-
},
|
| 71 |
-
"funding": {
|
| 72 |
-
"url": "https://github.com/discordjs/discord.js?sponsor"
|
| 73 |
-
}
|
| 74 |
-
},
|
| 75 |
-
"node_modules/@discordjs/rest/node_modules/@discordjs/collection": {
|
| 76 |
-
"version": "2.1.1",
|
| 77 |
-
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.1.tgz",
|
| 78 |
-
"integrity": "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==",
|
| 79 |
-
"license": "Apache-2.0",
|
| 80 |
-
"engines": {
|
| 81 |
-
"node": ">=18"
|
| 82 |
-
},
|
| 83 |
-
"funding": {
|
| 84 |
-
"url": "https://github.com/discordjs/discord.js?sponsor"
|
| 85 |
-
}
|
| 86 |
-
},
|
| 87 |
-
"node_modules/@discordjs/util": {
|
| 88 |
-
"version": "1.1.1",
|
| 89 |
-
"resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.1.1.tgz",
|
| 90 |
-
"integrity": "sha512-eddz6UnOBEB1oITPinyrB2Pttej49M9FZQY8NxgEvc3tq6ZICZ19m70RsmzRdDHk80O9NoYN/25AqJl8vPVf/g==",
|
| 91 |
-
"license": "Apache-2.0",
|
| 92 |
-
"engines": {
|
| 93 |
-
"node": ">=18"
|
| 94 |
-
},
|
| 95 |
-
"funding": {
|
| 96 |
-
"url": "https://github.com/discordjs/discord.js?sponsor"
|
| 97 |
-
}
|
| 98 |
-
},
|
| 99 |
-
"node_modules/@discordjs/ws": {
|
| 100 |
-
"version": "1.2.3",
|
| 101 |
-
"resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-1.2.3.tgz",
|
| 102 |
-
"integrity": "sha512-wPlQDxEmlDg5IxhJPuxXr3Vy9AjYq5xCvFWGJyD7w7Np8ZGu+Mc+97LCoEc/+AYCo2IDpKioiH0/c/mj5ZR9Uw==",
|
| 103 |
-
"license": "Apache-2.0",
|
| 104 |
-
"dependencies": {
|
| 105 |
-
"@discordjs/collection": "^2.1.0",
|
| 106 |
-
"@discordjs/rest": "^2.5.1",
|
| 107 |
-
"@discordjs/util": "^1.1.0",
|
| 108 |
-
"@sapphire/async-queue": "^1.5.2",
|
| 109 |
-
"@types/ws": "^8.5.10",
|
| 110 |
-
"@vladfrangu/async_event_emitter": "^2.2.4",
|
| 111 |
-
"discord-api-types": "^0.38.1",
|
| 112 |
-
"tslib": "^2.6.2",
|
| 113 |
-
"ws": "^8.17.0"
|
| 114 |
-
},
|
| 115 |
-
"engines": {
|
| 116 |
-
"node": ">=16.11.0"
|
| 117 |
-
},
|
| 118 |
-
"funding": {
|
| 119 |
-
"url": "https://github.com/discordjs/discord.js?sponsor"
|
| 120 |
-
}
|
| 121 |
-
},
|
| 122 |
-
"node_modules/@discordjs/ws/node_modules/@discordjs/collection": {
|
| 123 |
-
"version": "2.1.1",
|
| 124 |
-
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.1.tgz",
|
| 125 |
-
"integrity": "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==",
|
| 126 |
-
"license": "Apache-2.0",
|
| 127 |
-
"engines": {
|
| 128 |
-
"node": ">=18"
|
| 129 |
-
},
|
| 130 |
-
"funding": {
|
| 131 |
-
"url": "https://github.com/discordjs/discord.js?sponsor"
|
| 132 |
-
}
|
| 133 |
-
},
|
| 134 |
-
"node_modules/@sapphire/async-queue": {
|
| 135 |
-
"version": "1.5.5",
|
| 136 |
-
"resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.5.tgz",
|
| 137 |
-
"integrity": "sha512-cvGzxbba6sav2zZkH8GPf2oGk9yYoD5qrNWdu9fRehifgnFZJMV+nuy2nON2roRO4yQQ+v7MK/Pktl/HgfsUXg==",
|
| 138 |
-
"license": "MIT",
|
| 139 |
-
"engines": {
|
| 140 |
-
"node": ">=v14.0.0",
|
| 141 |
-
"npm": ">=7.0.0"
|
| 142 |
-
}
|
| 143 |
-
},
|
| 144 |
-
"node_modules/@sapphire/shapeshift": {
|
| 145 |
-
"version": "4.0.0",
|
| 146 |
-
"resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-4.0.0.tgz",
|
| 147 |
-
"integrity": "sha512-d9dUmWVA7MMiKobL3VpLF8P2aeanRTu6ypG2OIaEv/ZHH/SUQ2iHOVyi5wAPjQ+HmnMuL0whK9ez8I/raWbtIg==",
|
| 148 |
-
"license": "MIT",
|
| 149 |
-
"dependencies": {
|
| 150 |
-
"fast-deep-equal": "^3.1.3",
|
| 151 |
-
"lodash": "^4.17.21"
|
| 152 |
-
},
|
| 153 |
-
"engines": {
|
| 154 |
-
"node": ">=v16"
|
| 155 |
-
}
|
| 156 |
-
},
|
| 157 |
-
"node_modules/@sapphire/snowflake": {
|
| 158 |
-
"version": "3.5.3",
|
| 159 |
-
"resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.5.3.tgz",
|
| 160 |
-
"integrity": "sha512-jjmJywLAFoWeBi1W7994zZyiNWPIiqRRNAmSERxyg93xRGzNYvGjlZ0gR6x0F4gPRi2+0O6S71kOZYyr3cxaIQ==",
|
| 161 |
-
"license": "MIT",
|
| 162 |
-
"engines": {
|
| 163 |
-
"node": ">=v14.0.0",
|
| 164 |
-
"npm": ">=7.0.0"
|
| 165 |
-
}
|
| 166 |
-
},
|
| 167 |
-
"node_modules/@types/node": {
|
| 168 |
-
"version": "24.3.1",
|
| 169 |
-
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.3.1.tgz",
|
| 170 |
-
"integrity": "sha512-3vXmQDXy+woz+gnrTvuvNrPzekOi+Ds0ReMxw0LzBiK3a+1k0kQn9f2NWk+lgD4rJehFUmYy2gMhJ2ZI+7YP9g==",
|
| 171 |
-
"license": "MIT",
|
| 172 |
-
"dependencies": {
|
| 173 |
-
"undici-types": "~7.10.0"
|
| 174 |
-
}
|
| 175 |
-
},
|
| 176 |
-
"node_modules/@types/ws": {
|
| 177 |
-
"version": "8.18.1",
|
| 178 |
-
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz",
|
| 179 |
-
"integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==",
|
| 180 |
-
"license": "MIT",
|
| 181 |
-
"dependencies": {
|
| 182 |
-
"@types/node": "*"
|
| 183 |
-
}
|
| 184 |
-
},
|
| 185 |
-
"node_modules/@vladfrangu/async_event_emitter": {
|
| 186 |
-
"version": "2.4.6",
|
| 187 |
-
"resolved": "https://registry.npmjs.org/@vladfrangu/async_event_emitter/-/async_event_emitter-2.4.6.tgz",
|
| 188 |
-
"integrity": "sha512-RaI5qZo6D2CVS6sTHFKg1v5Ohq/+Bo2LZ5gzUEwZ/WkHhwtGTCB/sVLw8ijOkAUxasZ+WshN/Rzj4ywsABJ5ZA==",
|
| 189 |
-
"license": "MIT",
|
| 190 |
-
"engines": {
|
| 191 |
-
"node": ">=v14.0.0",
|
| 192 |
-
"npm": ">=7.0.0"
|
| 193 |
-
}
|
| 194 |
-
},
|
| 195 |
-
"node_modules/discord-api-types": {
|
| 196 |
-
"version": "0.38.22",
|
| 197 |
-
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.22.tgz",
|
| 198 |
-
"integrity": "sha512-2gnYrgXN3yTlv2cKBISI/A8btZwsSZLwKpIQXeI1cS8a7W7wP3sFVQOm3mPuuinTD8jJCKGPGNH399zE7Un1kA==",
|
| 199 |
-
"license": "MIT",
|
| 200 |
-
"workspaces": [
|
| 201 |
-
"scripts/actions/documentation"
|
| 202 |
-
]
|
| 203 |
-
},
|
| 204 |
-
"node_modules/discord.js": {
|
| 205 |
-
"version": "14.22.1",
|
| 206 |
-
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.22.1.tgz",
|
| 207 |
-
"integrity": "sha512-3k+Kisd/v570Jr68A1kNs7qVhNehDwDJAPe4DZ2Syt+/zobf9zEcuYFvsfIaAOgCa0BiHMfOOKQY4eYINl0z7w==",
|
| 208 |
-
"license": "Apache-2.0",
|
| 209 |
-
"dependencies": {
|
| 210 |
-
"@discordjs/builders": "^1.11.2",
|
| 211 |
-
"@discordjs/collection": "1.5.3",
|
| 212 |
-
"@discordjs/formatters": "^0.6.1",
|
| 213 |
-
"@discordjs/rest": "^2.6.0",
|
| 214 |
-
"@discordjs/util": "^1.1.1",
|
| 215 |
-
"@discordjs/ws": "^1.2.3",
|
| 216 |
-
"@sapphire/snowflake": "3.5.3",
|
| 217 |
-
"discord-api-types": "^0.38.16",
|
| 218 |
-
"fast-deep-equal": "3.1.3",
|
| 219 |
-
"lodash.snakecase": "4.1.1",
|
| 220 |
-
"magic-bytes.js": "^1.10.0",
|
| 221 |
-
"tslib": "^2.6.3",
|
| 222 |
-
"undici": "6.21.3"
|
| 223 |
-
},
|
| 224 |
-
"engines": {
|
| 225 |
-
"node": ">=18"
|
| 226 |
-
},
|
| 227 |
-
"funding": {
|
| 228 |
-
"url": "https://github.com/discordjs/discord.js?sponsor"
|
| 229 |
-
}
|
| 230 |
-
},
|
| 231 |
-
"node_modules/dotenv": {
|
| 232 |
-
"version": "17.2.2",
|
| 233 |
-
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.2.2.tgz",
|
| 234 |
-
"integrity": "sha512-Sf2LSQP+bOlhKWWyhFsn0UsfdK/kCWRv1iuA2gXAwt3dyNabr6QSj00I2V10pidqz69soatm9ZwZvpQMTIOd5Q==",
|
| 235 |
-
"license": "BSD-2-Clause",
|
| 236 |
-
"engines": {
|
| 237 |
-
"node": ">=12"
|
| 238 |
-
},
|
| 239 |
-
"funding": {
|
| 240 |
-
"url": "https://dotenvx.com"
|
| 241 |
-
}
|
| 242 |
-
},
|
| 243 |
-
"node_modules/fast-deep-equal": {
|
| 244 |
-
"version": "3.1.3",
|
| 245 |
-
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
| 246 |
-
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
|
| 247 |
-
"license": "MIT"
|
| 248 |
-
},
|
| 249 |
-
"node_modules/lodash": {
|
| 250 |
-
"version": "4.17.21",
|
| 251 |
-
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
| 252 |
-
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
| 253 |
-
"license": "MIT"
|
| 254 |
-
},
|
| 255 |
-
"node_modules/lodash.snakecase": {
|
| 256 |
-
"version": "4.1.1",
|
| 257 |
-
"resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz",
|
| 258 |
-
"integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==",
|
| 259 |
-
"license": "MIT"
|
| 260 |
-
},
|
| 261 |
-
"node_modules/magic-bytes.js": {
|
| 262 |
-
"version": "1.12.1",
|
| 263 |
-
"resolved": "https://registry.npmjs.org/magic-bytes.js/-/magic-bytes.js-1.12.1.tgz",
|
| 264 |
-
"integrity": "sha512-ThQLOhN86ZkJ7qemtVRGYM+gRgR8GEXNli9H/PMvpnZsE44Xfh3wx9kGJaldg314v85m+bFW6WBMaVHJc/c3zA==",
|
| 265 |
-
"license": "MIT"
|
| 266 |
-
},
|
| 267 |
-
"node_modules/ts-mixer": {
|
| 268 |
-
"version": "6.0.4",
|
| 269 |
-
"resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.4.tgz",
|
| 270 |
-
"integrity": "sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==",
|
| 271 |
-
"license": "MIT"
|
| 272 |
-
},
|
| 273 |
-
"node_modules/tslib": {
|
| 274 |
-
"version": "2.8.1",
|
| 275 |
-
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
|
| 276 |
-
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
| 277 |
-
"license": "0BSD"
|
| 278 |
-
},
|
| 279 |
-
"node_modules/undici": {
|
| 280 |
-
"version": "6.21.3",
|
| 281 |
-
"resolved": "https://registry.npmjs.org/undici/-/undici-6.21.3.tgz",
|
| 282 |
-
"integrity": "sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw==",
|
| 283 |
-
"license": "MIT",
|
| 284 |
-
"engines": {
|
| 285 |
-
"node": ">=18.17"
|
| 286 |
-
}
|
| 287 |
-
},
|
| 288 |
-
"node_modules/undici-types": {
|
| 289 |
-
"version": "7.10.0",
|
| 290 |
-
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.10.0.tgz",
|
| 291 |
-
"integrity": "sha512-t5Fy/nfn+14LuOc2KNYg75vZqClpAiqscVvMygNnlsHBFpSXdJaYtXMcdNLpl/Qvc3P2cB3s6lOV51nqsFq4ag==",
|
| 292 |
-
"license": "MIT"
|
| 293 |
-
},
|
| 294 |
-
"node_modules/ws": {
|
| 295 |
-
"version": "8.18.3",
|
| 296 |
-
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz",
|
| 297 |
-
"integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==",
|
| 298 |
-
"license": "MIT",
|
| 299 |
-
"engines": {
|
| 300 |
-
"node": ">=10.0.0"
|
| 301 |
-
},
|
| 302 |
-
"peerDependencies": {
|
| 303 |
-
"bufferutil": "^4.0.1",
|
| 304 |
-
"utf-8-validate": ">=5.0.2"
|
| 305 |
-
},
|
| 306 |
-
"peerDependenciesMeta": {
|
| 307 |
-
"bufferutil": {
|
| 308 |
-
"optional": true
|
| 309 |
-
},
|
| 310 |
-
"utf-8-validate": {
|
| 311 |
-
"optional": true
|
| 312 |
-
}
|
| 313 |
-
}
|
| 314 |
-
}
|
| 315 |
-
}
|
| 316 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/builders/LICENSE
DELETED
|
@@ -1,191 +0,0 @@
|
|
| 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/builders/README.md
DELETED
|
@@ -1,72 +0,0 @@
|
|
| 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/builders/dist/index.d.mts
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
workspace/discord-bot/node_modules/@discordjs/builders/dist/index.d.ts
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
workspace/discord-bot/node_modules/@discordjs/builders/dist/index.js
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
workspace/discord-bot/node_modules/@discordjs/builders/dist/index.js.map
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
workspace/discord-bot/node_modules/@discordjs/builders/dist/index.mjs
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
workspace/discord-bot/node_modules/@discordjs/builders/dist/index.mjs.map
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
workspace/discord-bot/node_modules/@discordjs/builders/package.json
DELETED
|
@@ -1,99 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"$schema": "https://json.schemastore.org/package.json",
|
| 3 |
-
"name": "@discordjs/builders",
|
| 4 |
-
"version": "1.11.3",
|
| 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 <me@vladfrangu.dev>",
|
| 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 |
-
"funding": "https://github.com/discordjs/discord.js?sponsor",
|
| 55 |
-
"dependencies": {
|
| 56 |
-
"@sapphire/shapeshift": "^4.0.0",
|
| 57 |
-
"discord-api-types": "^0.38.16",
|
| 58 |
-
"fast-deep-equal": "^3.1.3",
|
| 59 |
-
"ts-mixer": "^6.0.4",
|
| 60 |
-
"tslib": "^2.6.3",
|
| 61 |
-
"@discordjs/formatters": "^0.6.1",
|
| 62 |
-
"@discordjs/util": "^1.1.1"
|
| 63 |
-
},
|
| 64 |
-
"devDependencies": {
|
| 65 |
-
"@favware/cliff-jumper": "^4.1.0",
|
| 66 |
-
"@types/node": "^16.18.105",
|
| 67 |
-
"@vitest/coverage-v8": "^2.0.5",
|
| 68 |
-
"cross-env": "^7.0.3",
|
| 69 |
-
"esbuild-plugin-version-injector": "^1.2.1",
|
| 70 |
-
"eslint": "^8.57.0",
|
| 71 |
-
"eslint-config-neon": "^0.1.62",
|
| 72 |
-
"eslint-formatter-pretty": "^6.0.1",
|
| 73 |
-
"prettier": "^3.3.3",
|
| 74 |
-
"tsup": "^8.2.4",
|
| 75 |
-
"turbo": "^2.0.14",
|
| 76 |
-
"typescript": "~5.5.4",
|
| 77 |
-
"vitest": "^2.0.5",
|
| 78 |
-
"@discordjs/api-extractor": "^7.38.1",
|
| 79 |
-
"@discordjs/scripts": "^0.1.0"
|
| 80 |
-
},
|
| 81 |
-
"engines": {
|
| 82 |
-
"node": ">=16.11.0"
|
| 83 |
-
},
|
| 84 |
-
"publishConfig": {
|
| 85 |
-
"access": "public",
|
| 86 |
-
"provenance": true
|
| 87 |
-
},
|
| 88 |
-
"scripts": {
|
| 89 |
-
"test": "vitest run",
|
| 90 |
-
"build": "tsc --noEmit && tsup",
|
| 91 |
-
"build:docs": "tsc -p tsconfig.docs.json",
|
| 92 |
-
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
| 93 |
-
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
| 94 |
-
"fmt": "pnpm run format",
|
| 95 |
-
"docs": "pnpm run build:docs && api-extractor run --local --minify && generate-split-documentation",
|
| 96 |
-
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/builders/*'",
|
| 97 |
-
"release": "cliff-jumper"
|
| 98 |
-
}
|
| 99 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/collection/CHANGELOG.md
DELETED
|
@@ -1,190 +0,0 @@
|
|
| 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 `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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/collection/LICENSE
DELETED
|
@@ -1,191 +0,0 @@
|
|
| 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/collection/README.md
DELETED
|
@@ -1,67 +0,0 @@
|
|
| 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/collection/dist/index.d.mts
DELETED
|
@@ -1,457 +0,0 @@
|
|
| 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 };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/collection/dist/index.d.ts
DELETED
|
@@ -1,457 +0,0 @@
|
|
| 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 };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/collection/dist/index.js
DELETED
|
@@ -1,543 +0,0 @@
|
|
| 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/collection/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
| 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;AAC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|
|
|
workspace/discord-bot/node_modules/@discordjs/collection/dist/index.mjs
DELETED
|
@@ -1,517 +0,0 @@
|
|
| 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/collection/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
| 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 as a \"const string\" that gets injected by esbuild\nexport const version = '1.5.3' as string;\n"],"mappings":";;;;AAqCO,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,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
@@ -1,76 +0,0 @@
|
|
| 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 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/formatters/LICENSE
DELETED
|
@@ -1,191 +0,0 @@
|
|
| 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/formatters/README.md
DELETED
|
@@ -1,82 +0,0 @@
|
|
| 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/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/formatters/dist/index.d.mts
DELETED
|
@@ -1,673 +0,0 @@
|
|
| 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 |
-
* @deprecated Use {@link underline} instead.
|
| 216 |
-
*/
|
| 217 |
-
declare function underscore<Content extends string>(content: Content): `__${Content}__`;
|
| 218 |
-
/**
|
| 219 |
-
* Formats the content into underlined text.
|
| 220 |
-
*
|
| 221 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 222 |
-
* @param content - The content to wrap
|
| 223 |
-
*/
|
| 224 |
-
declare function underline<Content extends string>(content: Content): `__${Content}__`;
|
| 225 |
-
/**
|
| 226 |
-
* Formats the content into strike-through text.
|
| 227 |
-
*
|
| 228 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 229 |
-
* @param content - The content to wrap
|
| 230 |
-
*/
|
| 231 |
-
declare function strikethrough<Content extends string>(content: Content): `~~${Content}~~`;
|
| 232 |
-
/**
|
| 233 |
-
* Formats the content into a 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 quote<Content extends string>(content: Content): `> ${Content}`;
|
| 240 |
-
/**
|
| 241 |
-
* Formats the content into a block quote.
|
| 242 |
-
*
|
| 243 |
-
* @remarks This needs to be at the start of the line for Discord to format it.
|
| 244 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 245 |
-
* @param content - The content to wrap
|
| 246 |
-
*/
|
| 247 |
-
declare function blockQuote<Content extends string>(content: Content): `>>> ${Content}`;
|
| 248 |
-
/**
|
| 249 |
-
* Wraps the URL into `<>` which stops it from embedding.
|
| 250 |
-
*
|
| 251 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 252 |
-
* @param url - The URL to wrap
|
| 253 |
-
*/
|
| 254 |
-
declare function hideLinkEmbed<Content extends string>(url: Content): `<${Content}>`;
|
| 255 |
-
/**
|
| 256 |
-
* Wraps the URL into `<>` which stops it from embedding.
|
| 257 |
-
*
|
| 258 |
-
* @param url - The URL to wrap
|
| 259 |
-
*/
|
| 260 |
-
declare function hideLinkEmbed(url: URL): `<${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 |
-
* @param content - The content to display
|
| 266 |
-
* @param url - The URL the content links to
|
| 267 |
-
*/
|
| 268 |
-
declare function hyperlink<Content extends string>(content: Content, url: URL): `[${Content}](${string})`;
|
| 269 |
-
/**
|
| 270 |
-
* Formats the content and the URL into a masked URL.
|
| 271 |
-
*
|
| 272 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 273 |
-
* @typeParam Url - This is inferred by the supplied URL
|
| 274 |
-
* @param content - The content to display
|
| 275 |
-
* @param url - The URL the content links to
|
| 276 |
-
*/
|
| 277 |
-
declare function hyperlink<Content extends string, Url extends string>(content: Content, url: Url): `[${Content}](${Url})`;
|
| 278 |
-
/**
|
| 279 |
-
* Formats the content and the URL into a masked URL with a custom tooltip.
|
| 280 |
-
*
|
| 281 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 282 |
-
* @typeParam Title - This is inferred by the supplied title
|
| 283 |
-
* @param content - The content to display
|
| 284 |
-
* @param url - The URL the content links to
|
| 285 |
-
* @param title - The title shown when hovering on the masked link
|
| 286 |
-
*/
|
| 287 |
-
declare function hyperlink<Content extends string, Title extends string>(content: Content, url: URL, title: Title): `[${Content}](${string} "${Title}")`;
|
| 288 |
-
/**
|
| 289 |
-
* Formats the content and the URL into a masked URL with a custom tooltip.
|
| 290 |
-
*
|
| 291 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 292 |
-
* @typeParam Url - This is inferred by the supplied URL
|
| 293 |
-
* @typeParam Title - This is inferred by the supplied title
|
| 294 |
-
* @param content - The content to display
|
| 295 |
-
* @param url - The URL the content links to
|
| 296 |
-
* @param title - The title shown when hovering on the masked link
|
| 297 |
-
*/
|
| 298 |
-
declare function hyperlink<Content extends string, Url extends string, Title extends string>(content: Content, url: Url, title: Title): `[${Content}](${Url} "${Title}")`;
|
| 299 |
-
/**
|
| 300 |
-
* Formats the content into a spoiler.
|
| 301 |
-
*
|
| 302 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 303 |
-
* @param content - The content to wrap
|
| 304 |
-
*/
|
| 305 |
-
declare function spoiler<Content extends string>(content: Content): `||${Content}||`;
|
| 306 |
-
/**
|
| 307 |
-
* Formats a user id into a user mention.
|
| 308 |
-
*
|
| 309 |
-
* @typeParam UserId - This is inferred by the supplied user id
|
| 310 |
-
* @param userId - The user id to format
|
| 311 |
-
*/
|
| 312 |
-
declare function userMention<UserId extends Snowflake>(userId: UserId): `<@${UserId}>`;
|
| 313 |
-
/**
|
| 314 |
-
* Formats a channel id into a channel mention.
|
| 315 |
-
*
|
| 316 |
-
* @typeParam ChannelId - This is inferred by the supplied channel id
|
| 317 |
-
* @param channelId - The channel id to format
|
| 318 |
-
*/
|
| 319 |
-
declare function channelMention<ChannelId extends Snowflake>(channelId: ChannelId): `<#${ChannelId}>`;
|
| 320 |
-
/**
|
| 321 |
-
* Formats a role id into a role mention.
|
| 322 |
-
*
|
| 323 |
-
* @typeParam RoleId - This is inferred by the supplied role id
|
| 324 |
-
* @param roleId - The role id to format
|
| 325 |
-
*/
|
| 326 |
-
declare function roleMention<RoleId extends Snowflake>(roleId: RoleId): `<@&${RoleId}>`;
|
| 327 |
-
/**
|
| 328 |
-
* Formats an application command name, subcommand group name, subcommand name, and id into an application command mention.
|
| 329 |
-
*
|
| 330 |
-
* @typeParam CommandName - This is inferred by the supplied command name
|
| 331 |
-
* @typeParam SubcommandGroupName - This is inferred by the supplied subcommand group name
|
| 332 |
-
* @typeParam SubcommandName - This is inferred by the supplied subcommand name
|
| 333 |
-
* @typeParam CommandId - This is inferred by the supplied command id
|
| 334 |
-
* @param commandName - The application command name to format
|
| 335 |
-
* @param subcommandGroupName - The subcommand group name to format
|
| 336 |
-
* @param subcommandName - The subcommand name to format
|
| 337 |
-
* @param commandId - The application command id to format
|
| 338 |
-
*/
|
| 339 |
-
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}>`;
|
| 340 |
-
/**
|
| 341 |
-
* Formats an application command name, subcommand name, and id into an application command mention.
|
| 342 |
-
*
|
| 343 |
-
* @typeParam CommandName - This is inferred by the supplied command name
|
| 344 |
-
* @typeParam SubcommandName - This is inferred by the supplied subcommand name
|
| 345 |
-
* @typeParam CommandId - This is inferred by the supplied command id
|
| 346 |
-
* @param commandName - The application command name to format
|
| 347 |
-
* @param subcommandName - The subcommand name to format
|
| 348 |
-
* @param commandId - The application command id to format
|
| 349 |
-
*/
|
| 350 |
-
declare function chatInputApplicationCommandMention<CommandName extends string, SubcommandName extends string, CommandId extends Snowflake>(commandName: CommandName, subcommandName: SubcommandName, commandId: CommandId): `</${CommandName} ${SubcommandName}:${CommandId}>`;
|
| 351 |
-
/**
|
| 352 |
-
* Formats an application command name and id into an application command mention.
|
| 353 |
-
*
|
| 354 |
-
* @typeParam CommandName - This is inferred by the supplied command name
|
| 355 |
-
* @typeParam CommandId - This is inferred by the supplied command id
|
| 356 |
-
* @param commandName - The application command name to format
|
| 357 |
-
* @param commandId - The application command id to format
|
| 358 |
-
*/
|
| 359 |
-
declare function chatInputApplicationCommandMention<CommandName extends string, CommandId extends Snowflake>(commandName: CommandName, commandId: CommandId): `</${CommandName}:${CommandId}>`;
|
| 360 |
-
/**
|
| 361 |
-
* Formats a non-animated emoji id into a fully qualified emoji identifier.
|
| 362 |
-
*
|
| 363 |
-
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
| 364 |
-
* @param emojiId - The emoji id to format
|
| 365 |
-
*/
|
| 366 |
-
declare function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: false): `<:_:${EmojiId}>`;
|
| 367 |
-
/**
|
| 368 |
-
* Formats an animated 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?: true): `<a:_:${EmojiId}>`;
|
| 375 |
-
/**
|
| 376 |
-
* Formats an emoji id into a fully qualified emoji identifier.
|
| 377 |
-
*
|
| 378 |
-
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
| 379 |
-
* @param emojiId - The emoji id to format
|
| 380 |
-
* @param animated - Whether the emoji is animated
|
| 381 |
-
*/
|
| 382 |
-
declare function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: boolean): `<:_:${EmojiId}>` | `<a:_:${EmojiId}>`;
|
| 383 |
-
/**
|
| 384 |
-
* Formats a non-animated emoji id and name into a fully qualified emoji identifier.
|
| 385 |
-
*
|
| 386 |
-
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
| 387 |
-
* @typeParam EmojiName - This is inferred by the supplied name
|
| 388 |
-
* @param options - The options for formatting an emoji
|
| 389 |
-
*/
|
| 390 |
-
declare function formatEmoji<EmojiId extends Snowflake, EmojiName extends string>(options: FormatEmojiOptions<EmojiId, EmojiName> & {
|
| 391 |
-
animated: true;
|
| 392 |
-
}): `<a:${EmojiName}:${EmojiId}>`;
|
| 393 |
-
/**
|
| 394 |
-
* Formats an animated emoji id and name into a fully qualified emoji identifier.
|
| 395 |
-
*
|
| 396 |
-
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
| 397 |
-
* @typeParam EmojiName - This is inferred by the supplied name
|
| 398 |
-
* @param options - The options for formatting an emoji
|
| 399 |
-
*/
|
| 400 |
-
declare function formatEmoji<EmojiId extends Snowflake, EmojiName extends string>(options: FormatEmojiOptions<EmojiId, EmojiName> & {
|
| 401 |
-
animated?: false;
|
| 402 |
-
}): `<:${EmojiName}:${EmojiId}>`;
|
| 403 |
-
/**
|
| 404 |
-
* Formats an emoji id and name into a fully qualified emoji identifier.
|
| 405 |
-
*
|
| 406 |
-
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
| 407 |
-
* @typeParam EmojiName - This is inferred by the supplied emoji name
|
| 408 |
-
* @param options - The options for formatting an emoji
|
| 409 |
-
*/
|
| 410 |
-
declare function formatEmoji<EmojiId extends Snowflake, EmojiName extends string>(options: FormatEmojiOptions<EmojiId, EmojiName>): `<:${EmojiName}:${EmojiId}>` | `<a:${EmojiName}:${EmojiId}>`;
|
| 411 |
-
/**
|
| 412 |
-
* The options for formatting an emoji.
|
| 413 |
-
*
|
| 414 |
-
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
| 415 |
-
* @typeParam EmojiName - This is inferred by the supplied emoji name
|
| 416 |
-
*/
|
| 417 |
-
interface FormatEmojiOptions<EmojiId extends Snowflake, EmojiName extends string> {
|
| 418 |
-
/**
|
| 419 |
-
* Whether the emoji is animated
|
| 420 |
-
*/
|
| 421 |
-
animated?: boolean;
|
| 422 |
-
/**
|
| 423 |
-
* The emoji id to format
|
| 424 |
-
*/
|
| 425 |
-
id: EmojiId;
|
| 426 |
-
/**
|
| 427 |
-
* The name of the emoji
|
| 428 |
-
*/
|
| 429 |
-
name?: EmojiName;
|
| 430 |
-
}
|
| 431 |
-
/**
|
| 432 |
-
* Formats a channel link for a direct message channel.
|
| 433 |
-
*
|
| 434 |
-
* @typeParam ChannelId - This is inferred by the supplied channel id
|
| 435 |
-
* @param channelId - The channel's id
|
| 436 |
-
*/
|
| 437 |
-
declare function channelLink<ChannelId extends Snowflake>(channelId: ChannelId): `https://discord.com/channels/@me/${ChannelId}`;
|
| 438 |
-
/**
|
| 439 |
-
* Formats a channel link for a guild channel.
|
| 440 |
-
*
|
| 441 |
-
* @typeParam ChannelId - This is inferred by the supplied channel id
|
| 442 |
-
* @typeParam GuildId - This is inferred by the supplied guild id
|
| 443 |
-
* @param channelId - The channel's id
|
| 444 |
-
* @param guildId - The guild's id
|
| 445 |
-
*/
|
| 446 |
-
declare function channelLink<ChannelId extends Snowflake, GuildId extends Snowflake>(channelId: ChannelId, guildId: GuildId): `https://discord.com/channels/${GuildId}/${ChannelId}`;
|
| 447 |
-
/**
|
| 448 |
-
* Formats a message link for a direct message channel.
|
| 449 |
-
*
|
| 450 |
-
* @typeParam ChannelId - This is inferred by the supplied channel id
|
| 451 |
-
* @typeParam MessageId - This is inferred by the supplied message id
|
| 452 |
-
* @param channelId - The channel's id
|
| 453 |
-
* @param messageId - The message's id
|
| 454 |
-
*/
|
| 455 |
-
declare function messageLink<ChannelId extends Snowflake, MessageId extends Snowflake>(channelId: ChannelId, messageId: MessageId): `https://discord.com/channels/@me/${ChannelId}/${MessageId}`;
|
| 456 |
-
/**
|
| 457 |
-
* Formats a message link for a guild channel.
|
| 458 |
-
*
|
| 459 |
-
* @typeParam ChannelId - This is inferred by the supplied channel id
|
| 460 |
-
* @typeParam MessageId - This is inferred by the supplied message id
|
| 461 |
-
* @typeParam GuildId - This is inferred by the supplied guild id
|
| 462 |
-
* @param channelId - The channel's id
|
| 463 |
-
* @param messageId - The message's id
|
| 464 |
-
* @param guildId - The guild's id
|
| 465 |
-
*/
|
| 466 |
-
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}`;
|
| 467 |
-
/**
|
| 468 |
-
* The heading levels for expanded markdown.
|
| 469 |
-
*/
|
| 470 |
-
declare enum HeadingLevel {
|
| 471 |
-
/**
|
| 472 |
-
* The first heading level.
|
| 473 |
-
*/
|
| 474 |
-
One = 1,
|
| 475 |
-
/**
|
| 476 |
-
* The second heading level.
|
| 477 |
-
*/
|
| 478 |
-
Two = 2,
|
| 479 |
-
/**
|
| 480 |
-
* The third heading level.
|
| 481 |
-
*/
|
| 482 |
-
Three = 3
|
| 483 |
-
}
|
| 484 |
-
/**
|
| 485 |
-
* Formats the content into a heading level.
|
| 486 |
-
*
|
| 487 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 488 |
-
* @param content - The content to wrap
|
| 489 |
-
* @param level - The heading level
|
| 490 |
-
*/
|
| 491 |
-
declare function heading<Content extends string>(content: Content, level?: HeadingLevel.One): `# ${Content}`;
|
| 492 |
-
/**
|
| 493 |
-
* Formats the content into a heading level.
|
| 494 |
-
*
|
| 495 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 496 |
-
* @param content - The content to wrap
|
| 497 |
-
* @param level - The heading level
|
| 498 |
-
*/
|
| 499 |
-
declare function heading<Content extends string>(content: Content, level: HeadingLevel.Two): `## ${Content}`;
|
| 500 |
-
/**
|
| 501 |
-
* Formats the content into a heading level.
|
| 502 |
-
*
|
| 503 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 504 |
-
* @param content - The content to wrap
|
| 505 |
-
* @param level - The heading level
|
| 506 |
-
*/
|
| 507 |
-
declare function heading<Content extends string>(content: Content, level: HeadingLevel.Three): `### ${Content}`;
|
| 508 |
-
/**
|
| 509 |
-
* A type that recursively traverses into arrays.
|
| 510 |
-
*/
|
| 511 |
-
type RecursiveArray<ItemType> = readonly (ItemType | RecursiveArray<ItemType>)[];
|
| 512 |
-
/**
|
| 513 |
-
* Formats the elements in the array to an ordered list.
|
| 514 |
-
*
|
| 515 |
-
* @param list - The array of elements to list
|
| 516 |
-
* @param startNumber - The starting number for the list
|
| 517 |
-
*/
|
| 518 |
-
declare function orderedList(list: RecursiveArray<string>, startNumber?: number): string;
|
| 519 |
-
/**
|
| 520 |
-
* Formats the elements in the array to an unordered list.
|
| 521 |
-
*
|
| 522 |
-
* @param list - The array of elements to list
|
| 523 |
-
*/
|
| 524 |
-
declare function unorderedList(list: RecursiveArray<string>): string;
|
| 525 |
-
/**
|
| 526 |
-
* Formats the content into a subtext.
|
| 527 |
-
*
|
| 528 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 529 |
-
* @param content - The content to wrap
|
| 530 |
-
*/
|
| 531 |
-
declare function subtext<Content extends string>(content: Content): `-# ${Content}`;
|
| 532 |
-
/**
|
| 533 |
-
* Formats a date into a short date-time string.
|
| 534 |
-
*
|
| 535 |
-
* @param date - The date to format. Defaults to the current time
|
| 536 |
-
*/
|
| 537 |
-
declare function time(date?: Date): `<t:${bigint}>`;
|
| 538 |
-
/**
|
| 539 |
-
* Formats a date given a format style.
|
| 540 |
-
*
|
| 541 |
-
* @typeParam Style - This is inferred by the supplied {@link TimestampStylesString}
|
| 542 |
-
* @param date - The date to format
|
| 543 |
-
* @param style - The style to use
|
| 544 |
-
*/
|
| 545 |
-
declare function time<Style extends TimestampStylesString>(date: Date, style: Style): `<t:${bigint}:${Style}>`;
|
| 546 |
-
/**
|
| 547 |
-
* Formats the given timestamp into a short date-time string.
|
| 548 |
-
*
|
| 549 |
-
* @typeParam Seconds - This is inferred by the supplied timestamp
|
| 550 |
-
* @param seconds - A Unix timestamp in seconds
|
| 551 |
-
*/
|
| 552 |
-
declare function time<Seconds extends number>(seconds: Seconds): `<t:${Seconds}>`;
|
| 553 |
-
/**
|
| 554 |
-
* Formats the given timestamp into a short date-time string.
|
| 555 |
-
*
|
| 556 |
-
* @typeParam Seconds - This is inferred by the supplied timestamp
|
| 557 |
-
* @typeParam Style - This is inferred by the supplied {@link TimestampStylesString}
|
| 558 |
-
* @param seconds - A Unix timestamp in seconds
|
| 559 |
-
* @param style - The style to use
|
| 560 |
-
*/
|
| 561 |
-
declare function time<Seconds extends number, Style extends TimestampStylesString>(seconds: Seconds, style: Style): `<t:${Seconds}:${Style}>`;
|
| 562 |
-
/**
|
| 563 |
-
* Formats an application directory link.
|
| 564 |
-
*
|
| 565 |
-
* @typeParam ApplicationId - This is inferred by the supplied application id
|
| 566 |
-
* @param applicationId - The application id
|
| 567 |
-
*/
|
| 568 |
-
declare function applicationDirectory<ApplicationId extends Snowflake>(applicationId: ApplicationId): `https://discord.com/application-directory/${ApplicationId}/store`;
|
| 569 |
-
/**
|
| 570 |
-
* Formats an application directory SKU link.
|
| 571 |
-
*
|
| 572 |
-
* @typeParam ApplicationId - This is inferred by the supplied application id
|
| 573 |
-
* @typeParam SKUId - This is inferred by the supplied SKU id
|
| 574 |
-
* @param applicationId - The application id
|
| 575 |
-
* @param skuId - The SKU id
|
| 576 |
-
*/
|
| 577 |
-
declare function applicationDirectory<ApplicationId extends Snowflake, SKUId extends Snowflake>(applicationId: ApplicationId, skuId: SKUId): `https://discord.com/application-directory/${ApplicationId}/store/${SKUId}`;
|
| 578 |
-
/**
|
| 579 |
-
* The {@link https://discord.com/developers/docs/reference#message-formatting-timestamp-styles | message formatting timestamp styles}
|
| 580 |
-
* supported by Discord.
|
| 581 |
-
*/
|
| 582 |
-
declare const TimestampStyles: {
|
| 583 |
-
/**
|
| 584 |
-
* Short time format, consisting of hours and minutes.
|
| 585 |
-
*
|
| 586 |
-
* @example `16:20`
|
| 587 |
-
*/
|
| 588 |
-
readonly ShortTime: "t";
|
| 589 |
-
/**
|
| 590 |
-
* Long time format, consisting of hours, minutes, and seconds.
|
| 591 |
-
*
|
| 592 |
-
* @example `16:20:30`
|
| 593 |
-
*/
|
| 594 |
-
readonly LongTime: "T";
|
| 595 |
-
/**
|
| 596 |
-
* Short date format, consisting of day, month, and year.
|
| 597 |
-
*
|
| 598 |
-
* @example `20/04/2021`
|
| 599 |
-
*/
|
| 600 |
-
readonly ShortDate: "d";
|
| 601 |
-
/**
|
| 602 |
-
* Long date format, consisting of day, month, and year.
|
| 603 |
-
*
|
| 604 |
-
* @example `20 April 2021`
|
| 605 |
-
*/
|
| 606 |
-
readonly LongDate: "D";
|
| 607 |
-
/**
|
| 608 |
-
* Short date-time format, consisting of short date and short time formats.
|
| 609 |
-
*
|
| 610 |
-
* @example `20 April 2021 16:20`
|
| 611 |
-
*/
|
| 612 |
-
readonly ShortDateTime: "f";
|
| 613 |
-
/**
|
| 614 |
-
* Long date-time format, consisting of long date and short time formats.
|
| 615 |
-
*
|
| 616 |
-
* @example `Tuesday, 20 April 2021 16:20`
|
| 617 |
-
*/
|
| 618 |
-
readonly LongDateTime: "F";
|
| 619 |
-
/**
|
| 620 |
-
* Relative time format, consisting of a relative duration format.
|
| 621 |
-
*
|
| 622 |
-
* @example `2 months ago`
|
| 623 |
-
*/
|
| 624 |
-
readonly RelativeTime: "R";
|
| 625 |
-
};
|
| 626 |
-
/**
|
| 627 |
-
* The possible {@link TimestampStyles} values.
|
| 628 |
-
*/
|
| 629 |
-
type TimestampStylesString = (typeof TimestampStyles)[keyof typeof TimestampStyles];
|
| 630 |
-
/**
|
| 631 |
-
* All the available faces from Discord's native slash commands.
|
| 632 |
-
*/
|
| 633 |
-
declare enum Faces {
|
| 634 |
-
/**
|
| 635 |
-
* `¯\_(ツ)_/¯`
|
| 636 |
-
*/
|
| 637 |
-
Shrug = "\u00AF\\_(\u30C4)_/\u00AF",
|
| 638 |
-
/**
|
| 639 |
-
* `(╯°□°)╯︵ ┻━┻`
|
| 640 |
-
*/
|
| 641 |
-
Tableflip = "(\u256F\u00B0\u25A1\u00B0)\u256F\uFE35 \u253B\u2501\u253B",
|
| 642 |
-
/**
|
| 643 |
-
* `┬─┬ノ( º _ ºノ)`
|
| 644 |
-
*/
|
| 645 |
-
Unflip = "\u252C\u2500\u252C\u30CE( \u00BA _ \u00BA\u30CE)"
|
| 646 |
-
}
|
| 647 |
-
/**
|
| 648 |
-
* All the available guild navigation mentions.
|
| 649 |
-
*/
|
| 650 |
-
declare enum GuildNavigationMentions {
|
| 651 |
-
/**
|
| 652 |
-
* Browse Channels tab.
|
| 653 |
-
*/
|
| 654 |
-
Browse = "<id:browse>",
|
| 655 |
-
/**
|
| 656 |
-
* Customize tab with the server's {@link https://discord.com/developers/docs/resources/guild#guild-onboarding-object | onboarding prompts}.
|
| 657 |
-
*/
|
| 658 |
-
Customize = "<id:customize>",
|
| 659 |
-
/**
|
| 660 |
-
* {@link https://support.discord.com/hc/articles/13497665141655 | Server Guide} tab.
|
| 661 |
-
*/
|
| 662 |
-
Guide = "<id:guide>"
|
| 663 |
-
}
|
| 664 |
-
|
| 665 |
-
/**
|
| 666 |
-
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/formatters#readme | @discordjs/formatters} version
|
| 667 |
-
* that you are currently using.
|
| 668 |
-
*
|
| 669 |
-
* @privateRemarks This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild.
|
| 670 |
-
*/
|
| 671 |
-
declare const version: string;
|
| 672 |
-
|
| 673 |
-
export { type EscapeMarkdownOptions, Faces, type FormatEmojiOptions, GuildNavigationMentions, HeadingLevel, type RecursiveArray, TimestampStyles, type TimestampStylesString, applicationDirectory, 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, subtext, time, underline, underscore, unorderedList, userMention, version };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/formatters/dist/index.d.ts
DELETED
|
@@ -1,673 +0,0 @@
|
|
| 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 |
-
* @deprecated Use {@link underline} instead.
|
| 216 |
-
*/
|
| 217 |
-
declare function underscore<Content extends string>(content: Content): `__${Content}__`;
|
| 218 |
-
/**
|
| 219 |
-
* Formats the content into underlined text.
|
| 220 |
-
*
|
| 221 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 222 |
-
* @param content - The content to wrap
|
| 223 |
-
*/
|
| 224 |
-
declare function underline<Content extends string>(content: Content): `__${Content}__`;
|
| 225 |
-
/**
|
| 226 |
-
* Formats the content into strike-through text.
|
| 227 |
-
*
|
| 228 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 229 |
-
* @param content - The content to wrap
|
| 230 |
-
*/
|
| 231 |
-
declare function strikethrough<Content extends string>(content: Content): `~~${Content}~~`;
|
| 232 |
-
/**
|
| 233 |
-
* Formats the content into a 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 quote<Content extends string>(content: Content): `> ${Content}`;
|
| 240 |
-
/**
|
| 241 |
-
* Formats the content into a block quote.
|
| 242 |
-
*
|
| 243 |
-
* @remarks This needs to be at the start of the line for Discord to format it.
|
| 244 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 245 |
-
* @param content - The content to wrap
|
| 246 |
-
*/
|
| 247 |
-
declare function blockQuote<Content extends string>(content: Content): `>>> ${Content}`;
|
| 248 |
-
/**
|
| 249 |
-
* Wraps the URL into `<>` which stops it from embedding.
|
| 250 |
-
*
|
| 251 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 252 |
-
* @param url - The URL to wrap
|
| 253 |
-
*/
|
| 254 |
-
declare function hideLinkEmbed<Content extends string>(url: Content): `<${Content}>`;
|
| 255 |
-
/**
|
| 256 |
-
* Wraps the URL into `<>` which stops it from embedding.
|
| 257 |
-
*
|
| 258 |
-
* @param url - The URL to wrap
|
| 259 |
-
*/
|
| 260 |
-
declare function hideLinkEmbed(url: URL): `<${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 |
-
* @param content - The content to display
|
| 266 |
-
* @param url - The URL the content links to
|
| 267 |
-
*/
|
| 268 |
-
declare function hyperlink<Content extends string>(content: Content, url: URL): `[${Content}](${string})`;
|
| 269 |
-
/**
|
| 270 |
-
* Formats the content and the URL into a masked URL.
|
| 271 |
-
*
|
| 272 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 273 |
-
* @typeParam Url - This is inferred by the supplied URL
|
| 274 |
-
* @param content - The content to display
|
| 275 |
-
* @param url - The URL the content links to
|
| 276 |
-
*/
|
| 277 |
-
declare function hyperlink<Content extends string, Url extends string>(content: Content, url: Url): `[${Content}](${Url})`;
|
| 278 |
-
/**
|
| 279 |
-
* Formats the content and the URL into a masked URL with a custom tooltip.
|
| 280 |
-
*
|
| 281 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 282 |
-
* @typeParam Title - This is inferred by the supplied title
|
| 283 |
-
* @param content - The content to display
|
| 284 |
-
* @param url - The URL the content links to
|
| 285 |
-
* @param title - The title shown when hovering on the masked link
|
| 286 |
-
*/
|
| 287 |
-
declare function hyperlink<Content extends string, Title extends string>(content: Content, url: URL, title: Title): `[${Content}](${string} "${Title}")`;
|
| 288 |
-
/**
|
| 289 |
-
* Formats the content and the URL into a masked URL with a custom tooltip.
|
| 290 |
-
*
|
| 291 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 292 |
-
* @typeParam Url - This is inferred by the supplied URL
|
| 293 |
-
* @typeParam Title - This is inferred by the supplied title
|
| 294 |
-
* @param content - The content to display
|
| 295 |
-
* @param url - The URL the content links to
|
| 296 |
-
* @param title - The title shown when hovering on the masked link
|
| 297 |
-
*/
|
| 298 |
-
declare function hyperlink<Content extends string, Url extends string, Title extends string>(content: Content, url: Url, title: Title): `[${Content}](${Url} "${Title}")`;
|
| 299 |
-
/**
|
| 300 |
-
* Formats the content into a spoiler.
|
| 301 |
-
*
|
| 302 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 303 |
-
* @param content - The content to wrap
|
| 304 |
-
*/
|
| 305 |
-
declare function spoiler<Content extends string>(content: Content): `||${Content}||`;
|
| 306 |
-
/**
|
| 307 |
-
* Formats a user id into a user mention.
|
| 308 |
-
*
|
| 309 |
-
* @typeParam UserId - This is inferred by the supplied user id
|
| 310 |
-
* @param userId - The user id to format
|
| 311 |
-
*/
|
| 312 |
-
declare function userMention<UserId extends Snowflake>(userId: UserId): `<@${UserId}>`;
|
| 313 |
-
/**
|
| 314 |
-
* Formats a channel id into a channel mention.
|
| 315 |
-
*
|
| 316 |
-
* @typeParam ChannelId - This is inferred by the supplied channel id
|
| 317 |
-
* @param channelId - The channel id to format
|
| 318 |
-
*/
|
| 319 |
-
declare function channelMention<ChannelId extends Snowflake>(channelId: ChannelId): `<#${ChannelId}>`;
|
| 320 |
-
/**
|
| 321 |
-
* Formats a role id into a role mention.
|
| 322 |
-
*
|
| 323 |
-
* @typeParam RoleId - This is inferred by the supplied role id
|
| 324 |
-
* @param roleId - The role id to format
|
| 325 |
-
*/
|
| 326 |
-
declare function roleMention<RoleId extends Snowflake>(roleId: RoleId): `<@&${RoleId}>`;
|
| 327 |
-
/**
|
| 328 |
-
* Formats an application command name, subcommand group name, subcommand name, and id into an application command mention.
|
| 329 |
-
*
|
| 330 |
-
* @typeParam CommandName - This is inferred by the supplied command name
|
| 331 |
-
* @typeParam SubcommandGroupName - This is inferred by the supplied subcommand group name
|
| 332 |
-
* @typeParam SubcommandName - This is inferred by the supplied subcommand name
|
| 333 |
-
* @typeParam CommandId - This is inferred by the supplied command id
|
| 334 |
-
* @param commandName - The application command name to format
|
| 335 |
-
* @param subcommandGroupName - The subcommand group name to format
|
| 336 |
-
* @param subcommandName - The subcommand name to format
|
| 337 |
-
* @param commandId - The application command id to format
|
| 338 |
-
*/
|
| 339 |
-
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}>`;
|
| 340 |
-
/**
|
| 341 |
-
* Formats an application command name, subcommand name, and id into an application command mention.
|
| 342 |
-
*
|
| 343 |
-
* @typeParam CommandName - This is inferred by the supplied command name
|
| 344 |
-
* @typeParam SubcommandName - This is inferred by the supplied subcommand name
|
| 345 |
-
* @typeParam CommandId - This is inferred by the supplied command id
|
| 346 |
-
* @param commandName - The application command name to format
|
| 347 |
-
* @param subcommandName - The subcommand name to format
|
| 348 |
-
* @param commandId - The application command id to format
|
| 349 |
-
*/
|
| 350 |
-
declare function chatInputApplicationCommandMention<CommandName extends string, SubcommandName extends string, CommandId extends Snowflake>(commandName: CommandName, subcommandName: SubcommandName, commandId: CommandId): `</${CommandName} ${SubcommandName}:${CommandId}>`;
|
| 351 |
-
/**
|
| 352 |
-
* Formats an application command name and id into an application command mention.
|
| 353 |
-
*
|
| 354 |
-
* @typeParam CommandName - This is inferred by the supplied command name
|
| 355 |
-
* @typeParam CommandId - This is inferred by the supplied command id
|
| 356 |
-
* @param commandName - The application command name to format
|
| 357 |
-
* @param commandId - The application command id to format
|
| 358 |
-
*/
|
| 359 |
-
declare function chatInputApplicationCommandMention<CommandName extends string, CommandId extends Snowflake>(commandName: CommandName, commandId: CommandId): `</${CommandName}:${CommandId}>`;
|
| 360 |
-
/**
|
| 361 |
-
* Formats a non-animated emoji id into a fully qualified emoji identifier.
|
| 362 |
-
*
|
| 363 |
-
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
| 364 |
-
* @param emojiId - The emoji id to format
|
| 365 |
-
*/
|
| 366 |
-
declare function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: false): `<:_:${EmojiId}>`;
|
| 367 |
-
/**
|
| 368 |
-
* Formats an animated 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?: true): `<a:_:${EmojiId}>`;
|
| 375 |
-
/**
|
| 376 |
-
* Formats an emoji id into a fully qualified emoji identifier.
|
| 377 |
-
*
|
| 378 |
-
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
| 379 |
-
* @param emojiId - The emoji id to format
|
| 380 |
-
* @param animated - Whether the emoji is animated
|
| 381 |
-
*/
|
| 382 |
-
declare function formatEmoji<EmojiId extends Snowflake>(emojiId: EmojiId, animated?: boolean): `<:_:${EmojiId}>` | `<a:_:${EmojiId}>`;
|
| 383 |
-
/**
|
| 384 |
-
* Formats a non-animated emoji id and name into a fully qualified emoji identifier.
|
| 385 |
-
*
|
| 386 |
-
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
| 387 |
-
* @typeParam EmojiName - This is inferred by the supplied name
|
| 388 |
-
* @param options - The options for formatting an emoji
|
| 389 |
-
*/
|
| 390 |
-
declare function formatEmoji<EmojiId extends Snowflake, EmojiName extends string>(options: FormatEmojiOptions<EmojiId, EmojiName> & {
|
| 391 |
-
animated: true;
|
| 392 |
-
}): `<a:${EmojiName}:${EmojiId}>`;
|
| 393 |
-
/**
|
| 394 |
-
* Formats an animated emoji id and name into a fully qualified emoji identifier.
|
| 395 |
-
*
|
| 396 |
-
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
| 397 |
-
* @typeParam EmojiName - This is inferred by the supplied name
|
| 398 |
-
* @param options - The options for formatting an emoji
|
| 399 |
-
*/
|
| 400 |
-
declare function formatEmoji<EmojiId extends Snowflake, EmojiName extends string>(options: FormatEmojiOptions<EmojiId, EmojiName> & {
|
| 401 |
-
animated?: false;
|
| 402 |
-
}): `<:${EmojiName}:${EmojiId}>`;
|
| 403 |
-
/**
|
| 404 |
-
* Formats an emoji id and name into a fully qualified emoji identifier.
|
| 405 |
-
*
|
| 406 |
-
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
| 407 |
-
* @typeParam EmojiName - This is inferred by the supplied emoji name
|
| 408 |
-
* @param options - The options for formatting an emoji
|
| 409 |
-
*/
|
| 410 |
-
declare function formatEmoji<EmojiId extends Snowflake, EmojiName extends string>(options: FormatEmojiOptions<EmojiId, EmojiName>): `<:${EmojiName}:${EmojiId}>` | `<a:${EmojiName}:${EmojiId}>`;
|
| 411 |
-
/**
|
| 412 |
-
* The options for formatting an emoji.
|
| 413 |
-
*
|
| 414 |
-
* @typeParam EmojiId - This is inferred by the supplied emoji id
|
| 415 |
-
* @typeParam EmojiName - This is inferred by the supplied emoji name
|
| 416 |
-
*/
|
| 417 |
-
interface FormatEmojiOptions<EmojiId extends Snowflake, EmojiName extends string> {
|
| 418 |
-
/**
|
| 419 |
-
* Whether the emoji is animated
|
| 420 |
-
*/
|
| 421 |
-
animated?: boolean;
|
| 422 |
-
/**
|
| 423 |
-
* The emoji id to format
|
| 424 |
-
*/
|
| 425 |
-
id: EmojiId;
|
| 426 |
-
/**
|
| 427 |
-
* The name of the emoji
|
| 428 |
-
*/
|
| 429 |
-
name?: EmojiName;
|
| 430 |
-
}
|
| 431 |
-
/**
|
| 432 |
-
* Formats a channel link for a direct message channel.
|
| 433 |
-
*
|
| 434 |
-
* @typeParam ChannelId - This is inferred by the supplied channel id
|
| 435 |
-
* @param channelId - The channel's id
|
| 436 |
-
*/
|
| 437 |
-
declare function channelLink<ChannelId extends Snowflake>(channelId: ChannelId): `https://discord.com/channels/@me/${ChannelId}`;
|
| 438 |
-
/**
|
| 439 |
-
* Formats a channel link for a guild channel.
|
| 440 |
-
*
|
| 441 |
-
* @typeParam ChannelId - This is inferred by the supplied channel id
|
| 442 |
-
* @typeParam GuildId - This is inferred by the supplied guild id
|
| 443 |
-
* @param channelId - The channel's id
|
| 444 |
-
* @param guildId - The guild's id
|
| 445 |
-
*/
|
| 446 |
-
declare function channelLink<ChannelId extends Snowflake, GuildId extends Snowflake>(channelId: ChannelId, guildId: GuildId): `https://discord.com/channels/${GuildId}/${ChannelId}`;
|
| 447 |
-
/**
|
| 448 |
-
* Formats a message link for a direct message channel.
|
| 449 |
-
*
|
| 450 |
-
* @typeParam ChannelId - This is inferred by the supplied channel id
|
| 451 |
-
* @typeParam MessageId - This is inferred by the supplied message id
|
| 452 |
-
* @param channelId - The channel's id
|
| 453 |
-
* @param messageId - The message's id
|
| 454 |
-
*/
|
| 455 |
-
declare function messageLink<ChannelId extends Snowflake, MessageId extends Snowflake>(channelId: ChannelId, messageId: MessageId): `https://discord.com/channels/@me/${ChannelId}/${MessageId}`;
|
| 456 |
-
/**
|
| 457 |
-
* Formats a message link for a guild channel.
|
| 458 |
-
*
|
| 459 |
-
* @typeParam ChannelId - This is inferred by the supplied channel id
|
| 460 |
-
* @typeParam MessageId - This is inferred by the supplied message id
|
| 461 |
-
* @typeParam GuildId - This is inferred by the supplied guild id
|
| 462 |
-
* @param channelId - The channel's id
|
| 463 |
-
* @param messageId - The message's id
|
| 464 |
-
* @param guildId - The guild's id
|
| 465 |
-
*/
|
| 466 |
-
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}`;
|
| 467 |
-
/**
|
| 468 |
-
* The heading levels for expanded markdown.
|
| 469 |
-
*/
|
| 470 |
-
declare enum HeadingLevel {
|
| 471 |
-
/**
|
| 472 |
-
* The first heading level.
|
| 473 |
-
*/
|
| 474 |
-
One = 1,
|
| 475 |
-
/**
|
| 476 |
-
* The second heading level.
|
| 477 |
-
*/
|
| 478 |
-
Two = 2,
|
| 479 |
-
/**
|
| 480 |
-
* The third heading level.
|
| 481 |
-
*/
|
| 482 |
-
Three = 3
|
| 483 |
-
}
|
| 484 |
-
/**
|
| 485 |
-
* Formats the content into a heading level.
|
| 486 |
-
*
|
| 487 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 488 |
-
* @param content - The content to wrap
|
| 489 |
-
* @param level - The heading level
|
| 490 |
-
*/
|
| 491 |
-
declare function heading<Content extends string>(content: Content, level?: HeadingLevel.One): `# ${Content}`;
|
| 492 |
-
/**
|
| 493 |
-
* Formats the content into a heading level.
|
| 494 |
-
*
|
| 495 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 496 |
-
* @param content - The content to wrap
|
| 497 |
-
* @param level - The heading level
|
| 498 |
-
*/
|
| 499 |
-
declare function heading<Content extends string>(content: Content, level: HeadingLevel.Two): `## ${Content}`;
|
| 500 |
-
/**
|
| 501 |
-
* Formats the content into a heading level.
|
| 502 |
-
*
|
| 503 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 504 |
-
* @param content - The content to wrap
|
| 505 |
-
* @param level - The heading level
|
| 506 |
-
*/
|
| 507 |
-
declare function heading<Content extends string>(content: Content, level: HeadingLevel.Three): `### ${Content}`;
|
| 508 |
-
/**
|
| 509 |
-
* A type that recursively traverses into arrays.
|
| 510 |
-
*/
|
| 511 |
-
type RecursiveArray<ItemType> = readonly (ItemType | RecursiveArray<ItemType>)[];
|
| 512 |
-
/**
|
| 513 |
-
* Formats the elements in the array to an ordered list.
|
| 514 |
-
*
|
| 515 |
-
* @param list - The array of elements to list
|
| 516 |
-
* @param startNumber - The starting number for the list
|
| 517 |
-
*/
|
| 518 |
-
declare function orderedList(list: RecursiveArray<string>, startNumber?: number): string;
|
| 519 |
-
/**
|
| 520 |
-
* Formats the elements in the array to an unordered list.
|
| 521 |
-
*
|
| 522 |
-
* @param list - The array of elements to list
|
| 523 |
-
*/
|
| 524 |
-
declare function unorderedList(list: RecursiveArray<string>): string;
|
| 525 |
-
/**
|
| 526 |
-
* Formats the content into a subtext.
|
| 527 |
-
*
|
| 528 |
-
* @typeParam Content - This is inferred by the supplied content
|
| 529 |
-
* @param content - The content to wrap
|
| 530 |
-
*/
|
| 531 |
-
declare function subtext<Content extends string>(content: Content): `-# ${Content}`;
|
| 532 |
-
/**
|
| 533 |
-
* Formats a date into a short date-time string.
|
| 534 |
-
*
|
| 535 |
-
* @param date - The date to format. Defaults to the current time
|
| 536 |
-
*/
|
| 537 |
-
declare function time(date?: Date): `<t:${bigint}>`;
|
| 538 |
-
/**
|
| 539 |
-
* Formats a date given a format style.
|
| 540 |
-
*
|
| 541 |
-
* @typeParam Style - This is inferred by the supplied {@link TimestampStylesString}
|
| 542 |
-
* @param date - The date to format
|
| 543 |
-
* @param style - The style to use
|
| 544 |
-
*/
|
| 545 |
-
declare function time<Style extends TimestampStylesString>(date: Date, style: Style): `<t:${bigint}:${Style}>`;
|
| 546 |
-
/**
|
| 547 |
-
* Formats the given timestamp into a short date-time string.
|
| 548 |
-
*
|
| 549 |
-
* @typeParam Seconds - This is inferred by the supplied timestamp
|
| 550 |
-
* @param seconds - A Unix timestamp in seconds
|
| 551 |
-
*/
|
| 552 |
-
declare function time<Seconds extends number>(seconds: Seconds): `<t:${Seconds}>`;
|
| 553 |
-
/**
|
| 554 |
-
* Formats the given timestamp into a short date-time string.
|
| 555 |
-
*
|
| 556 |
-
* @typeParam Seconds - This is inferred by the supplied timestamp
|
| 557 |
-
* @typeParam Style - This is inferred by the supplied {@link TimestampStylesString}
|
| 558 |
-
* @param seconds - A Unix timestamp in seconds
|
| 559 |
-
* @param style - The style to use
|
| 560 |
-
*/
|
| 561 |
-
declare function time<Seconds extends number, Style extends TimestampStylesString>(seconds: Seconds, style: Style): `<t:${Seconds}:${Style}>`;
|
| 562 |
-
/**
|
| 563 |
-
* Formats an application directory link.
|
| 564 |
-
*
|
| 565 |
-
* @typeParam ApplicationId - This is inferred by the supplied application id
|
| 566 |
-
* @param applicationId - The application id
|
| 567 |
-
*/
|
| 568 |
-
declare function applicationDirectory<ApplicationId extends Snowflake>(applicationId: ApplicationId): `https://discord.com/application-directory/${ApplicationId}/store`;
|
| 569 |
-
/**
|
| 570 |
-
* Formats an application directory SKU link.
|
| 571 |
-
*
|
| 572 |
-
* @typeParam ApplicationId - This is inferred by the supplied application id
|
| 573 |
-
* @typeParam SKUId - This is inferred by the supplied SKU id
|
| 574 |
-
* @param applicationId - The application id
|
| 575 |
-
* @param skuId - The SKU id
|
| 576 |
-
*/
|
| 577 |
-
declare function applicationDirectory<ApplicationId extends Snowflake, SKUId extends Snowflake>(applicationId: ApplicationId, skuId: SKUId): `https://discord.com/application-directory/${ApplicationId}/store/${SKUId}`;
|
| 578 |
-
/**
|
| 579 |
-
* The {@link https://discord.com/developers/docs/reference#message-formatting-timestamp-styles | message formatting timestamp styles}
|
| 580 |
-
* supported by Discord.
|
| 581 |
-
*/
|
| 582 |
-
declare const TimestampStyles: {
|
| 583 |
-
/**
|
| 584 |
-
* Short time format, consisting of hours and minutes.
|
| 585 |
-
*
|
| 586 |
-
* @example `16:20`
|
| 587 |
-
*/
|
| 588 |
-
readonly ShortTime: "t";
|
| 589 |
-
/**
|
| 590 |
-
* Long time format, consisting of hours, minutes, and seconds.
|
| 591 |
-
*
|
| 592 |
-
* @example `16:20:30`
|
| 593 |
-
*/
|
| 594 |
-
readonly LongTime: "T";
|
| 595 |
-
/**
|
| 596 |
-
* Short date format, consisting of day, month, and year.
|
| 597 |
-
*
|
| 598 |
-
* @example `20/04/2021`
|
| 599 |
-
*/
|
| 600 |
-
readonly ShortDate: "d";
|
| 601 |
-
/**
|
| 602 |
-
* Long date format, consisting of day, month, and year.
|
| 603 |
-
*
|
| 604 |
-
* @example `20 April 2021`
|
| 605 |
-
*/
|
| 606 |
-
readonly LongDate: "D";
|
| 607 |
-
/**
|
| 608 |
-
* Short date-time format, consisting of short date and short time formats.
|
| 609 |
-
*
|
| 610 |
-
* @example `20 April 2021 16:20`
|
| 611 |
-
*/
|
| 612 |
-
readonly ShortDateTime: "f";
|
| 613 |
-
/**
|
| 614 |
-
* Long date-time format, consisting of long date and short time formats.
|
| 615 |
-
*
|
| 616 |
-
* @example `Tuesday, 20 April 2021 16:20`
|
| 617 |
-
*/
|
| 618 |
-
readonly LongDateTime: "F";
|
| 619 |
-
/**
|
| 620 |
-
* Relative time format, consisting of a relative duration format.
|
| 621 |
-
*
|
| 622 |
-
* @example `2 months ago`
|
| 623 |
-
*/
|
| 624 |
-
readonly RelativeTime: "R";
|
| 625 |
-
};
|
| 626 |
-
/**
|
| 627 |
-
* The possible {@link TimestampStyles} values.
|
| 628 |
-
*/
|
| 629 |
-
type TimestampStylesString = (typeof TimestampStyles)[keyof typeof TimestampStyles];
|
| 630 |
-
/**
|
| 631 |
-
* All the available faces from Discord's native slash commands.
|
| 632 |
-
*/
|
| 633 |
-
declare enum Faces {
|
| 634 |
-
/**
|
| 635 |
-
* `¯\_(ツ)_/¯`
|
| 636 |
-
*/
|
| 637 |
-
Shrug = "\u00AF\\_(\u30C4)_/\u00AF",
|
| 638 |
-
/**
|
| 639 |
-
* `(╯°□°)╯︵ ┻━┻`
|
| 640 |
-
*/
|
| 641 |
-
Tableflip = "(\u256F\u00B0\u25A1\u00B0)\u256F\uFE35 \u253B\u2501\u253B",
|
| 642 |
-
/**
|
| 643 |
-
* `┬─┬ノ( º _ ºノ)`
|
| 644 |
-
*/
|
| 645 |
-
Unflip = "\u252C\u2500\u252C\u30CE( \u00BA _ \u00BA\u30CE)"
|
| 646 |
-
}
|
| 647 |
-
/**
|
| 648 |
-
* All the available guild navigation mentions.
|
| 649 |
-
*/
|
| 650 |
-
declare enum GuildNavigationMentions {
|
| 651 |
-
/**
|
| 652 |
-
* Browse Channels tab.
|
| 653 |
-
*/
|
| 654 |
-
Browse = "<id:browse>",
|
| 655 |
-
/**
|
| 656 |
-
* Customize tab with the server's {@link https://discord.com/developers/docs/resources/guild#guild-onboarding-object | onboarding prompts}.
|
| 657 |
-
*/
|
| 658 |
-
Customize = "<id:customize>",
|
| 659 |
-
/**
|
| 660 |
-
* {@link https://support.discord.com/hc/articles/13497665141655 | Server Guide} tab.
|
| 661 |
-
*/
|
| 662 |
-
Guide = "<id:guide>"
|
| 663 |
-
}
|
| 664 |
-
|
| 665 |
-
/**
|
| 666 |
-
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/formatters#readme | @discordjs/formatters} version
|
| 667 |
-
* that you are currently using.
|
| 668 |
-
*
|
| 669 |
-
* @privateRemarks This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild.
|
| 670 |
-
*/
|
| 671 |
-
declare const version: string;
|
| 672 |
-
|
| 673 |
-
export { type EscapeMarkdownOptions, Faces, type FormatEmojiOptions, GuildNavigationMentions, HeadingLevel, type RecursiveArray, TimestampStyles, type TimestampStylesString, applicationDirectory, 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, subtext, time, underline, underscore, unorderedList, userMention, version };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/formatters/dist/index.js
DELETED
|
@@ -1,452 +0,0 @@
|
|
| 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 |
-
Faces: () => Faces,
|
| 25 |
-
GuildNavigationMentions: () => GuildNavigationMentions,
|
| 26 |
-
HeadingLevel: () => HeadingLevel,
|
| 27 |
-
TimestampStyles: () => TimestampStyles,
|
| 28 |
-
applicationDirectory: () => applicationDirectory,
|
| 29 |
-
blockQuote: () => blockQuote,
|
| 30 |
-
bold: () => bold,
|
| 31 |
-
channelLink: () => channelLink,
|
| 32 |
-
channelMention: () => channelMention,
|
| 33 |
-
chatInputApplicationCommandMention: () => chatInputApplicationCommandMention,
|
| 34 |
-
codeBlock: () => codeBlock,
|
| 35 |
-
escapeBold: () => escapeBold,
|
| 36 |
-
escapeBulletedList: () => escapeBulletedList,
|
| 37 |
-
escapeCodeBlock: () => escapeCodeBlock,
|
| 38 |
-
escapeEscape: () => escapeEscape,
|
| 39 |
-
escapeHeading: () => escapeHeading,
|
| 40 |
-
escapeInlineCode: () => escapeInlineCode,
|
| 41 |
-
escapeItalic: () => escapeItalic,
|
| 42 |
-
escapeMarkdown: () => escapeMarkdown,
|
| 43 |
-
escapeMaskedLink: () => escapeMaskedLink,
|
| 44 |
-
escapeNumberedList: () => escapeNumberedList,
|
| 45 |
-
escapeSpoiler: () => escapeSpoiler,
|
| 46 |
-
escapeStrikethrough: () => escapeStrikethrough,
|
| 47 |
-
escapeUnderline: () => escapeUnderline,
|
| 48 |
-
formatEmoji: () => formatEmoji,
|
| 49 |
-
heading: () => heading,
|
| 50 |
-
hideLinkEmbed: () => hideLinkEmbed,
|
| 51 |
-
hyperlink: () => hyperlink,
|
| 52 |
-
inlineCode: () => inlineCode,
|
| 53 |
-
italic: () => italic,
|
| 54 |
-
messageLink: () => messageLink,
|
| 55 |
-
orderedList: () => orderedList,
|
| 56 |
-
quote: () => quote,
|
| 57 |
-
roleMention: () => roleMention,
|
| 58 |
-
spoiler: () => spoiler,
|
| 59 |
-
strikethrough: () => strikethrough,
|
| 60 |
-
subtext: () => subtext,
|
| 61 |
-
time: () => time,
|
| 62 |
-
underline: () => underline,
|
| 63 |
-
underscore: () => underscore,
|
| 64 |
-
unorderedList: () => unorderedList,
|
| 65 |
-
userMention: () => userMention,
|
| 66 |
-
version: () => version
|
| 67 |
-
});
|
| 68 |
-
module.exports = __toCommonJS(src_exports);
|
| 69 |
-
|
| 70 |
-
// src/escapers.ts
|
| 71 |
-
function escapeMarkdown(text, options = {}) {
|
| 72 |
-
const {
|
| 73 |
-
codeBlock: codeBlock2 = true,
|
| 74 |
-
inlineCode: inlineCode2 = true,
|
| 75 |
-
bold: bold2 = true,
|
| 76 |
-
italic: italic2 = true,
|
| 77 |
-
underline: underline2 = true,
|
| 78 |
-
strikethrough: strikethrough2 = true,
|
| 79 |
-
spoiler: spoiler2 = true,
|
| 80 |
-
codeBlockContent = true,
|
| 81 |
-
inlineCodeContent = true,
|
| 82 |
-
escape = true,
|
| 83 |
-
heading: heading2 = false,
|
| 84 |
-
bulletedList = false,
|
| 85 |
-
numberedList = false,
|
| 86 |
-
maskedLink = false
|
| 87 |
-
} = options;
|
| 88 |
-
if (!codeBlockContent) {
|
| 89 |
-
return text.split("```").map((subString, index, array) => {
|
| 90 |
-
if (index % 2 && index !== array.length - 1) return subString;
|
| 91 |
-
return escapeMarkdown(subString, {
|
| 92 |
-
inlineCode: inlineCode2,
|
| 93 |
-
bold: bold2,
|
| 94 |
-
italic: italic2,
|
| 95 |
-
underline: underline2,
|
| 96 |
-
strikethrough: strikethrough2,
|
| 97 |
-
spoiler: spoiler2,
|
| 98 |
-
inlineCodeContent,
|
| 99 |
-
escape,
|
| 100 |
-
heading: heading2,
|
| 101 |
-
bulletedList,
|
| 102 |
-
numberedList,
|
| 103 |
-
maskedLink
|
| 104 |
-
});
|
| 105 |
-
}).join(codeBlock2 ? "\\`\\`\\`" : "```");
|
| 106 |
-
}
|
| 107 |
-
if (!inlineCodeContent) {
|
| 108 |
-
return text.split(/(?<=^|[^`])`(?=[^`]|$)/g).map((subString, index, array) => {
|
| 109 |
-
if (index % 2 && index !== array.length - 1) return subString;
|
| 110 |
-
return escapeMarkdown(subString, {
|
| 111 |
-
codeBlock: codeBlock2,
|
| 112 |
-
bold: bold2,
|
| 113 |
-
italic: italic2,
|
| 114 |
-
underline: underline2,
|
| 115 |
-
strikethrough: strikethrough2,
|
| 116 |
-
spoiler: spoiler2,
|
| 117 |
-
escape,
|
| 118 |
-
heading: heading2,
|
| 119 |
-
bulletedList,
|
| 120 |
-
numberedList,
|
| 121 |
-
maskedLink
|
| 122 |
-
});
|
| 123 |
-
}).join(inlineCode2 ? "\\`" : "`");
|
| 124 |
-
}
|
| 125 |
-
let res = text;
|
| 126 |
-
if (escape) res = escapeEscape(res);
|
| 127 |
-
if (inlineCode2) res = escapeInlineCode(res);
|
| 128 |
-
if (codeBlock2) res = escapeCodeBlock(res);
|
| 129 |
-
if (italic2) res = escapeItalic(res);
|
| 130 |
-
if (bold2) res = escapeBold(res);
|
| 131 |
-
if (underline2) res = escapeUnderline(res);
|
| 132 |
-
if (strikethrough2) res = escapeStrikethrough(res);
|
| 133 |
-
if (spoiler2) res = escapeSpoiler(res);
|
| 134 |
-
if (heading2) res = escapeHeading(res);
|
| 135 |
-
if (bulletedList) res = escapeBulletedList(res);
|
| 136 |
-
if (numberedList) res = escapeNumberedList(res);
|
| 137 |
-
if (maskedLink) res = escapeMaskedLink(res);
|
| 138 |
-
return res;
|
| 139 |
-
}
|
| 140 |
-
__name(escapeMarkdown, "escapeMarkdown");
|
| 141 |
-
function escapeCodeBlock(text) {
|
| 142 |
-
return text.replaceAll("```", "\\`\\`\\`");
|
| 143 |
-
}
|
| 144 |
-
__name(escapeCodeBlock, "escapeCodeBlock");
|
| 145 |
-
function escapeInlineCode(text) {
|
| 146 |
-
return text.replaceAll(/(?<=^|[^`])``?(?=[^`]|$)/g, (match) => match.length === 2 ? "\\`\\`" : "\\`");
|
| 147 |
-
}
|
| 148 |
-
__name(escapeInlineCode, "escapeInlineCode");
|
| 149 |
-
function escapeItalic(text) {
|
| 150 |
-
let idx = 0;
|
| 151 |
-
const newText = text.replaceAll(/(?<=^|[^*])\*([^*]|\*\*|$)/g, (_, match) => {
|
| 152 |
-
if (match === "**") return ++idx % 2 ? `\\*${match}` : `${match}\\*`;
|
| 153 |
-
return `\\*${match}`;
|
| 154 |
-
});
|
| 155 |
-
idx = 0;
|
| 156 |
-
return newText.replaceAll(/(?<=^|[^_])(?<!<a?:.+|https?:\/\/\S+)_(?!:\d+>)([^_]|__|$)/g, (_, match) => {
|
| 157 |
-
if (match === "__") return ++idx % 2 ? `\\_${match}` : `${match}\\_`;
|
| 158 |
-
return `\\_${match}`;
|
| 159 |
-
});
|
| 160 |
-
}
|
| 161 |
-
__name(escapeItalic, "escapeItalic");
|
| 162 |
-
function escapeBold(text) {
|
| 163 |
-
let idx = 0;
|
| 164 |
-
return text.replaceAll(/\*\*(\*)?/g, (_, match) => {
|
| 165 |
-
if (match) return ++idx % 2 ? `${match}\\*\\*` : `\\*\\*${match}`;
|
| 166 |
-
return "\\*\\*";
|
| 167 |
-
});
|
| 168 |
-
}
|
| 169 |
-
__name(escapeBold, "escapeBold");
|
| 170 |
-
function escapeUnderline(text) {
|
| 171 |
-
let idx = 0;
|
| 172 |
-
return text.replaceAll(/(?<!<a?:.+|https?:\/\/\S+)__(_)?(?!:\d+>)/g, (_, match) => {
|
| 173 |
-
if (match) return ++idx % 2 ? `${match}\\_\\_` : `\\_\\_${match}`;
|
| 174 |
-
return "\\_\\_";
|
| 175 |
-
});
|
| 176 |
-
}
|
| 177 |
-
__name(escapeUnderline, "escapeUnderline");
|
| 178 |
-
function escapeStrikethrough(text) {
|
| 179 |
-
return text.replaceAll("~~", "\\~\\~");
|
| 180 |
-
}
|
| 181 |
-
__name(escapeStrikethrough, "escapeStrikethrough");
|
| 182 |
-
function escapeSpoiler(text) {
|
| 183 |
-
return text.replaceAll("||", "\\|\\|");
|
| 184 |
-
}
|
| 185 |
-
__name(escapeSpoiler, "escapeSpoiler");
|
| 186 |
-
function escapeEscape(text) {
|
| 187 |
-
return text.replaceAll("\\", "\\\\");
|
| 188 |
-
}
|
| 189 |
-
__name(escapeEscape, "escapeEscape");
|
| 190 |
-
function escapeHeading(text) {
|
| 191 |
-
return text.replaceAll(/^( {0,2})([*-] )?( *)(#{1,3} )/gm, "$1$2$3\\$4");
|
| 192 |
-
}
|
| 193 |
-
__name(escapeHeading, "escapeHeading");
|
| 194 |
-
function escapeBulletedList(text) {
|
| 195 |
-
return text.replaceAll(/^( *)([*-])( +)/gm, "$1\\$2$3");
|
| 196 |
-
}
|
| 197 |
-
__name(escapeBulletedList, "escapeBulletedList");
|
| 198 |
-
function escapeNumberedList(text) {
|
| 199 |
-
return text.replaceAll(/^( *\d+)\./gm, "$1\\.");
|
| 200 |
-
}
|
| 201 |
-
__name(escapeNumberedList, "escapeNumberedList");
|
| 202 |
-
function escapeMaskedLink(text) {
|
| 203 |
-
return text.replaceAll(/\[.+]\(.+\)/gm, "\\$&");
|
| 204 |
-
}
|
| 205 |
-
__name(escapeMaskedLink, "escapeMaskedLink");
|
| 206 |
-
|
| 207 |
-
// src/formatters.ts
|
| 208 |
-
function codeBlock(language, content) {
|
| 209 |
-
return content === void 0 ? `\`\`\`
|
| 210 |
-
${language}
|
| 211 |
-
\`\`\`` : `\`\`\`${language}
|
| 212 |
-
${content}
|
| 213 |
-
\`\`\``;
|
| 214 |
-
}
|
| 215 |
-
__name(codeBlock, "codeBlock");
|
| 216 |
-
function inlineCode(content) {
|
| 217 |
-
return `\`${content}\``;
|
| 218 |
-
}
|
| 219 |
-
__name(inlineCode, "inlineCode");
|
| 220 |
-
function italic(content) {
|
| 221 |
-
return `_${content}_`;
|
| 222 |
-
}
|
| 223 |
-
__name(italic, "italic");
|
| 224 |
-
function bold(content) {
|
| 225 |
-
return `**${content}**`;
|
| 226 |
-
}
|
| 227 |
-
__name(bold, "bold");
|
| 228 |
-
function underscore(content) {
|
| 229 |
-
return underline(content);
|
| 230 |
-
}
|
| 231 |
-
__name(underscore, "underscore");
|
| 232 |
-
function underline(content) {
|
| 233 |
-
return `__${content}__`;
|
| 234 |
-
}
|
| 235 |
-
__name(underline, "underline");
|
| 236 |
-
function strikethrough(content) {
|
| 237 |
-
return `~~${content}~~`;
|
| 238 |
-
}
|
| 239 |
-
__name(strikethrough, "strikethrough");
|
| 240 |
-
function quote(content) {
|
| 241 |
-
return `> ${content}`;
|
| 242 |
-
}
|
| 243 |
-
__name(quote, "quote");
|
| 244 |
-
function blockQuote(content) {
|
| 245 |
-
return `>>> ${content}`;
|
| 246 |
-
}
|
| 247 |
-
__name(blockQuote, "blockQuote");
|
| 248 |
-
function hideLinkEmbed(url) {
|
| 249 |
-
return `<${url}>`;
|
| 250 |
-
}
|
| 251 |
-
__name(hideLinkEmbed, "hideLinkEmbed");
|
| 252 |
-
function hyperlink(content, url, title) {
|
| 253 |
-
return title ? `[${content}](${url} "${title}")` : `[${content}](${url})`;
|
| 254 |
-
}
|
| 255 |
-
__name(hyperlink, "hyperlink");
|
| 256 |
-
function spoiler(content) {
|
| 257 |
-
return `||${content}||`;
|
| 258 |
-
}
|
| 259 |
-
__name(spoiler, "spoiler");
|
| 260 |
-
function userMention(userId) {
|
| 261 |
-
return `<@${userId}>`;
|
| 262 |
-
}
|
| 263 |
-
__name(userMention, "userMention");
|
| 264 |
-
function channelMention(channelId) {
|
| 265 |
-
return `<#${channelId}>`;
|
| 266 |
-
}
|
| 267 |
-
__name(channelMention, "channelMention");
|
| 268 |
-
function roleMention(roleId) {
|
| 269 |
-
return `<@&${roleId}>`;
|
| 270 |
-
}
|
| 271 |
-
__name(roleMention, "roleMention");
|
| 272 |
-
function chatInputApplicationCommandMention(commandName, subcommandGroupName, subcommandName, commandId) {
|
| 273 |
-
if (commandId !== void 0) {
|
| 274 |
-
return `</${commandName} ${subcommandGroupName} ${subcommandName}:${commandId}>`;
|
| 275 |
-
}
|
| 276 |
-
if (subcommandName !== void 0) {
|
| 277 |
-
return `</${commandName} ${subcommandGroupName}:${subcommandName}>`;
|
| 278 |
-
}
|
| 279 |
-
return `</${commandName}:${subcommandGroupName}>`;
|
| 280 |
-
}
|
| 281 |
-
__name(chatInputApplicationCommandMention, "chatInputApplicationCommandMention");
|
| 282 |
-
function formatEmoji(emojiIdOrOptions, animated) {
|
| 283 |
-
const options = typeof emojiIdOrOptions === "string" ? {
|
| 284 |
-
id: emojiIdOrOptions,
|
| 285 |
-
animated: animated ?? false
|
| 286 |
-
} : emojiIdOrOptions;
|
| 287 |
-
const { id, animated: isAnimated, name: emojiName } = options;
|
| 288 |
-
return `<${isAnimated ? "a" : ""}:${emojiName ?? "_"}:${id}>`;
|
| 289 |
-
}
|
| 290 |
-
__name(formatEmoji, "formatEmoji");
|
| 291 |
-
function channelLink(channelId, guildId) {
|
| 292 |
-
return `https://discord.com/channels/${guildId ?? "@me"}/${channelId}`;
|
| 293 |
-
}
|
| 294 |
-
__name(channelLink, "channelLink");
|
| 295 |
-
function messageLink(channelId, messageId, guildId) {
|
| 296 |
-
return `${guildId === void 0 ? channelLink(channelId) : channelLink(channelId, guildId)}/${messageId}`;
|
| 297 |
-
}
|
| 298 |
-
__name(messageLink, "messageLink");
|
| 299 |
-
var HeadingLevel = /* @__PURE__ */ ((HeadingLevel2) => {
|
| 300 |
-
HeadingLevel2[HeadingLevel2["One"] = 1] = "One";
|
| 301 |
-
HeadingLevel2[HeadingLevel2["Two"] = 2] = "Two";
|
| 302 |
-
HeadingLevel2[HeadingLevel2["Three"] = 3] = "Three";
|
| 303 |
-
return HeadingLevel2;
|
| 304 |
-
})(HeadingLevel || {});
|
| 305 |
-
function heading(content, level) {
|
| 306 |
-
switch (level) {
|
| 307 |
-
case 3 /* Three */:
|
| 308 |
-
return `### ${content}`;
|
| 309 |
-
case 2 /* Two */:
|
| 310 |
-
return `## ${content}`;
|
| 311 |
-
default:
|
| 312 |
-
return `# ${content}`;
|
| 313 |
-
}
|
| 314 |
-
}
|
| 315 |
-
__name(heading, "heading");
|
| 316 |
-
function listCallback(element, startNumber, depth = 0) {
|
| 317 |
-
if (Array.isArray(element)) {
|
| 318 |
-
return element.map((element2) => listCallback(element2, startNumber, depth + 1)).join("\n");
|
| 319 |
-
}
|
| 320 |
-
return `${" ".repeat(depth - 1)}${startNumber ? `${startNumber}.` : "-"} ${element}`;
|
| 321 |
-
}
|
| 322 |
-
__name(listCallback, "listCallback");
|
| 323 |
-
function orderedList(list, startNumber = 1) {
|
| 324 |
-
return listCallback(list, Math.max(startNumber, 1));
|
| 325 |
-
}
|
| 326 |
-
__name(orderedList, "orderedList");
|
| 327 |
-
function unorderedList(list) {
|
| 328 |
-
return listCallback(list);
|
| 329 |
-
}
|
| 330 |
-
__name(unorderedList, "unorderedList");
|
| 331 |
-
function subtext(content) {
|
| 332 |
-
return `-# ${content}`;
|
| 333 |
-
}
|
| 334 |
-
__name(subtext, "subtext");
|
| 335 |
-
function time(timeOrSeconds, style) {
|
| 336 |
-
if (typeof timeOrSeconds !== "number") {
|
| 337 |
-
timeOrSeconds = Math.floor((timeOrSeconds?.getTime() ?? Date.now()) / 1e3);
|
| 338 |
-
}
|
| 339 |
-
return typeof style === "string" ? `<t:${timeOrSeconds}:${style}>` : `<t:${timeOrSeconds}>`;
|
| 340 |
-
}
|
| 341 |
-
__name(time, "time");
|
| 342 |
-
function applicationDirectory(applicationId, skuId) {
|
| 343 |
-
const url = `https://discord.com/application-directory/${applicationId}/store`;
|
| 344 |
-
return skuId ? `${url}/${skuId}` : url;
|
| 345 |
-
}
|
| 346 |
-
__name(applicationDirectory, "applicationDirectory");
|
| 347 |
-
var TimestampStyles = {
|
| 348 |
-
/**
|
| 349 |
-
* Short time format, consisting of hours and minutes.
|
| 350 |
-
*
|
| 351 |
-
* @example `16:20`
|
| 352 |
-
*/
|
| 353 |
-
ShortTime: "t",
|
| 354 |
-
/**
|
| 355 |
-
* Long time format, consisting of hours, minutes, and seconds.
|
| 356 |
-
*
|
| 357 |
-
* @example `16:20:30`
|
| 358 |
-
*/
|
| 359 |
-
LongTime: "T",
|
| 360 |
-
/**
|
| 361 |
-
* Short date format, consisting of day, month, and year.
|
| 362 |
-
*
|
| 363 |
-
* @example `20/04/2021`
|
| 364 |
-
*/
|
| 365 |
-
ShortDate: "d",
|
| 366 |
-
/**
|
| 367 |
-
* Long date format, consisting of day, month, and year.
|
| 368 |
-
*
|
| 369 |
-
* @example `20 April 2021`
|
| 370 |
-
*/
|
| 371 |
-
LongDate: "D",
|
| 372 |
-
/**
|
| 373 |
-
* Short date-time format, consisting of short date and short time formats.
|
| 374 |
-
*
|
| 375 |
-
* @example `20 April 2021 16:20`
|
| 376 |
-
*/
|
| 377 |
-
ShortDateTime: "f",
|
| 378 |
-
/**
|
| 379 |
-
* Long date-time format, consisting of long date and short time formats.
|
| 380 |
-
*
|
| 381 |
-
* @example `Tuesday, 20 April 2021 16:20`
|
| 382 |
-
*/
|
| 383 |
-
LongDateTime: "F",
|
| 384 |
-
/**
|
| 385 |
-
* Relative time format, consisting of a relative duration format.
|
| 386 |
-
*
|
| 387 |
-
* @example `2 months ago`
|
| 388 |
-
*/
|
| 389 |
-
RelativeTime: "R"
|
| 390 |
-
};
|
| 391 |
-
var Faces = /* @__PURE__ */ ((Faces2) => {
|
| 392 |
-
Faces2["Shrug"] = "\xAF\\_(\u30C4)_/\xAF";
|
| 393 |
-
Faces2["Tableflip"] = "(\u256F\xB0\u25A1\xB0)\u256F\uFE35 \u253B\u2501\u253B";
|
| 394 |
-
Faces2["Unflip"] = "\u252C\u2500\u252C\u30CE( \xBA _ \xBA\u30CE)";
|
| 395 |
-
return Faces2;
|
| 396 |
-
})(Faces || {});
|
| 397 |
-
var GuildNavigationMentions = /* @__PURE__ */ ((GuildNavigationMentions2) => {
|
| 398 |
-
GuildNavigationMentions2["Browse"] = "<id:browse>";
|
| 399 |
-
GuildNavigationMentions2["Customize"] = "<id:customize>";
|
| 400 |
-
GuildNavigationMentions2["Guide"] = "<id:guide>";
|
| 401 |
-
return GuildNavigationMentions2;
|
| 402 |
-
})(GuildNavigationMentions || {});
|
| 403 |
-
|
| 404 |
-
// src/index.ts
|
| 405 |
-
var version = "0.6.1";
|
| 406 |
-
// Annotate the CommonJS export names for ESM import in node:
|
| 407 |
-
0 && (module.exports = {
|
| 408 |
-
Faces,
|
| 409 |
-
GuildNavigationMentions,
|
| 410 |
-
HeadingLevel,
|
| 411 |
-
TimestampStyles,
|
| 412 |
-
applicationDirectory,
|
| 413 |
-
blockQuote,
|
| 414 |
-
bold,
|
| 415 |
-
channelLink,
|
| 416 |
-
channelMention,
|
| 417 |
-
chatInputApplicationCommandMention,
|
| 418 |
-
codeBlock,
|
| 419 |
-
escapeBold,
|
| 420 |
-
escapeBulletedList,
|
| 421 |
-
escapeCodeBlock,
|
| 422 |
-
escapeEscape,
|
| 423 |
-
escapeHeading,
|
| 424 |
-
escapeInlineCode,
|
| 425 |
-
escapeItalic,
|
| 426 |
-
escapeMarkdown,
|
| 427 |
-
escapeMaskedLink,
|
| 428 |
-
escapeNumberedList,
|
| 429 |
-
escapeSpoiler,
|
| 430 |
-
escapeStrikethrough,
|
| 431 |
-
escapeUnderline,
|
| 432 |
-
formatEmoji,
|
| 433 |
-
heading,
|
| 434 |
-
hideLinkEmbed,
|
| 435 |
-
hyperlink,
|
| 436 |
-
inlineCode,
|
| 437 |
-
italic,
|
| 438 |
-
messageLink,
|
| 439 |
-
orderedList,
|
| 440 |
-
quote,
|
| 441 |
-
roleMention,
|
| 442 |
-
spoiler,
|
| 443 |
-
strikethrough,
|
| 444 |
-
subtext,
|
| 445 |
-
time,
|
| 446 |
-
underline,
|
| 447 |
-
underscore,
|
| 448 |
-
unorderedList,
|
| 449 |
-
userMention,
|
| 450 |
-
version
|
| 451 |
-
});
|
| 452 |
-
//# sourceMappingURL=index.js.map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/formatters/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"version":3,"sources":["../src/index.ts","../src/escapers.ts","../src/formatters.ts"],"sourcesContent":["export * from './escapers.js';\nexport * from './formatters.js';\n\n/**\n * The {@link https://github.com/discordjs/discord.js/blob/main/packages/formatters#readme | @discordjs/formatters} version\n * that you are currently using.\n *\n * @privateRemarks This needs to explicitly be `string` so it is not typed as a \"const string\" that gets injected by esbuild.\n */\nexport const version = '0.6.1' as string;\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?:.+|https?:\\/\\/\\S+)_(?!:\\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?:.+|https?:\\/\\/\\S+)__(_)?(?!:\\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 * @deprecated Use {@link underline} instead.\n */\nexport function underscore<Content extends string>(content: Content): `__${Content}__` {\n\treturn underline(content);\n}\n\n/**\n * Formats the content into underlined text.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function underline<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\n/**\n * Formats a non-animated emoji id and name into a fully qualified emoji identifier.\n *\n * @typeParam EmojiId - This is inferred by the supplied emoji id\n * @typeParam EmojiName - This is inferred by the supplied name\n * @param options - The options for formatting an emoji\n */\nexport function formatEmoji<EmojiId extends Snowflake, EmojiName extends string>(\n\toptions: FormatEmojiOptions<EmojiId, EmojiName> & { animated: true },\n): `<a:${EmojiName}:${EmojiId}>`;\n\n/**\n * Formats an animated emoji id and name into a fully qualified emoji identifier.\n *\n * @typeParam EmojiId - This is inferred by the supplied emoji id\n * @typeParam EmojiName - This is inferred by the supplied name\n * @param options - The options for formatting an emoji\n */\nexport function formatEmoji<EmojiId extends Snowflake, EmojiName extends string>(\n\toptions: FormatEmojiOptions<EmojiId, EmojiName> & { animated?: false },\n): `<:${EmojiName}:${EmojiId}>`;\n\n/**\n * Formats an emoji id and name into a fully qualified emoji identifier.\n *\n * @typeParam EmojiId - This is inferred by the supplied emoji id\n * @typeParam EmojiName - This is inferred by the supplied emoji name\n * @param options - The options for formatting an emoji\n */\nexport function formatEmoji<EmojiId extends Snowflake, EmojiName extends string>(\n\toptions: FormatEmojiOptions<EmojiId, EmojiName>,\n): `<:${EmojiName}:${EmojiId}>` | `<a:${EmojiName}:${EmojiId}>`;\n\nexport function formatEmoji<EmojiId extends Snowflake, EmojiName extends string>(\n\temojiIdOrOptions: EmojiId | FormatEmojiOptions<EmojiId, EmojiName>,\n\tanimated?: boolean,\n): `<:${string}:${EmojiId}>` | `<a:${string}:${EmojiId}>` {\n\tconst options =\n\t\ttypeof emojiIdOrOptions === 'string'\n\t\t\t? {\n\t\t\t\t\tid: emojiIdOrOptions,\n\t\t\t\t\tanimated: animated ?? false,\n\t\t\t\t}\n\t\t\t: emojiIdOrOptions;\n\n\tconst { id, animated: isAnimated, name: emojiName } = options;\n\n\treturn `<${isAnimated ? 'a' : ''}:${emojiName ?? '_'}:${id}>`;\n}\n\n/**\n * The options for formatting an emoji.\n *\n * @typeParam EmojiId - This is inferred by the supplied emoji id\n * @typeParam EmojiName - This is inferred by the supplied emoji name\n */\nexport interface FormatEmojiOptions<EmojiId extends Snowflake, EmojiName extends string> {\n\t/**\n\t * Whether the emoji is animated\n\t */\n\tanimated?: boolean;\n\t/**\n\t * The emoji id to format\n\t */\n\tid: EmojiId;\n\t/**\n\t * The name of the emoji\n\t */\n\tname?: EmojiName;\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 the content into a subtext.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function subtext<Content extends string>(content: Content): `-# ${Content}` {\n\treturn `-# ${content}`;\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 * Formats an application directory link.\n *\n * @typeParam ApplicationId - This is inferred by the supplied application id\n * @param applicationId - The application id\n */\nexport function applicationDirectory<ApplicationId extends Snowflake>(\n\tapplicationId: ApplicationId,\n): `https://discord.com/application-directory/${ApplicationId}/store`;\n\n/**\n * Formats an application directory SKU link.\n *\n * @typeParam ApplicationId - This is inferred by the supplied application id\n * @typeParam SKUId - This is inferred by the supplied SKU id\n * @param applicationId - The application id\n * @param skuId - The SKU id\n */\nexport function applicationDirectory<ApplicationId extends Snowflake, SKUId extends Snowflake>(\n\tapplicationId: ApplicationId,\n\tskuId: SKUId,\n): `https://discord.com/application-directory/${ApplicationId}/store/${SKUId}`;\n\nexport function applicationDirectory<ApplicationId extends Snowflake, SKUId extends Snowflake>(\n\tapplicationId: ApplicationId,\n\tskuId?: SKUId,\n):\n\t| `https://discord.com/application-directory/${ApplicationId}/store/${SKUId}`\n\t| `https://discord.com/application-directory/${ApplicationId}/store` {\n\tconst url = `https://discord.com/application-directory/${applicationId}/store` as const;\n\treturn skuId ? `${url}/${skuId}` : url;\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/**\n * All the available faces from Discord's native slash commands.\n */\nexport enum Faces {\n\t/**\n\t * `¯\\_(ツ)_/¯`\n\t */\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC8GO,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,WAAAC,aAAY;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,U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AAA;AAAA;AAAA,EAOV,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOf,cAAc;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOd,cAAc;AACf;AAUO,IAAK,QAAL,kBAAKC,WAAL;AAIN,EAAAA,OAAA,WAAQ;AAKR,EAAAA,OAAA,eAAY;AAKZ,EAAAA,OAAA,YAAS;AAdE,SAAAA;AAAA,GAAA;AAoBL,IAAK,0BAAL,kBAAKC,6BAAL;AAIN,EAAAA,yBAAA,YAAS;AAIT,EAAAA,yBAAA,eAAY;AAIZ,EAAAA,yBAAA,WAAQ;AAZG,SAAAA;AAAA,GAAA;;;AF9tBL,IAAM,UAAU;","names":["codeBlock","inlineCode","bold","italic","underline","strikethrough","spoiler","heading","HeadingLevel","element","Faces","GuildNavigationMentions"]}
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/formatters/dist/index.mjs
DELETED
|
@@ -1,385 +0,0 @@
|
|
| 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: underline2 = 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) return subString;
|
| 25 |
-
return escapeMarkdown(subString, {
|
| 26 |
-
inlineCode: inlineCode2,
|
| 27 |
-
bold: bold2,
|
| 28 |
-
italic: italic2,
|
| 29 |
-
underline: underline2,
|
| 30 |
-
strikethrough: strikethrough2,
|
| 31 |
-
spoiler: spoiler2,
|
| 32 |
-
inlineCodeContent,
|
| 33 |
-
escape,
|
| 34 |
-
heading: heading2,
|
| 35 |
-
bulletedList,
|
| 36 |
-
numberedList,
|
| 37 |
-
maskedLink
|
| 38 |
-
});
|
| 39 |
-
}).join(codeBlock2 ? "\\`\\`\\`" : "```");
|
| 40 |
-
}
|
| 41 |
-
if (!inlineCodeContent) {
|
| 42 |
-
return text.split(/(?<=^|[^`])`(?=[^`]|$)/g).map((subString, index, array) => {
|
| 43 |
-
if (index % 2 && index !== array.length - 1) return subString;
|
| 44 |
-
return escapeMarkdown(subString, {
|
| 45 |
-
codeBlock: codeBlock2,
|
| 46 |
-
bold: bold2,
|
| 47 |
-
italic: italic2,
|
| 48 |
-
underline: underline2,
|
| 49 |
-
strikethrough: strikethrough2,
|
| 50 |
-
spoiler: spoiler2,
|
| 51 |
-
escape,
|
| 52 |
-
heading: heading2,
|
| 53 |
-
bulletedList,
|
| 54 |
-
numberedList,
|
| 55 |
-
maskedLink
|
| 56 |
-
});
|
| 57 |
-
}).join(inlineCode2 ? "\\`" : "`");
|
| 58 |
-
}
|
| 59 |
-
let res = text;
|
| 60 |
-
if (escape) res = escapeEscape(res);
|
| 61 |
-
if (inlineCode2) res = escapeInlineCode(res);
|
| 62 |
-
if (codeBlock2) res = escapeCodeBlock(res);
|
| 63 |
-
if (italic2) res = escapeItalic(res);
|
| 64 |
-
if (bold2) res = escapeBold(res);
|
| 65 |
-
if (underline2) res = escapeUnderline(res);
|
| 66 |
-
if (strikethrough2) res = escapeStrikethrough(res);
|
| 67 |
-
if (spoiler2) res = escapeSpoiler(res);
|
| 68 |
-
if (heading2) res = escapeHeading(res);
|
| 69 |
-
if (bulletedList) res = escapeBulletedList(res);
|
| 70 |
-
if (numberedList) res = escapeNumberedList(res);
|
| 71 |
-
if (maskedLink) res = escapeMaskedLink(res);
|
| 72 |
-
return res;
|
| 73 |
-
}
|
| 74 |
-
__name(escapeMarkdown, "escapeMarkdown");
|
| 75 |
-
function escapeCodeBlock(text) {
|
| 76 |
-
return text.replaceAll("```", "\\`\\`\\`");
|
| 77 |
-
}
|
| 78 |
-
__name(escapeCodeBlock, "escapeCodeBlock");
|
| 79 |
-
function escapeInlineCode(text) {
|
| 80 |
-
return text.replaceAll(/(?<=^|[^`])``?(?=[^`]|$)/g, (match) => match.length === 2 ? "\\`\\`" : "\\`");
|
| 81 |
-
}
|
| 82 |
-
__name(escapeInlineCode, "escapeInlineCode");
|
| 83 |
-
function escapeItalic(text) {
|
| 84 |
-
let idx = 0;
|
| 85 |
-
const newText = text.replaceAll(/(?<=^|[^*])\*([^*]|\*\*|$)/g, (_, match) => {
|
| 86 |
-
if (match === "**") return ++idx % 2 ? `\\*${match}` : `${match}\\*`;
|
| 87 |
-
return `\\*${match}`;
|
| 88 |
-
});
|
| 89 |
-
idx = 0;
|
| 90 |
-
return newText.replaceAll(/(?<=^|[^_])(?<!<a?:.+|https?:\/\/\S+)_(?!:\d+>)([^_]|__|$)/g, (_, match) => {
|
| 91 |
-
if (match === "__") return ++idx % 2 ? `\\_${match}` : `${match}\\_`;
|
| 92 |
-
return `\\_${match}`;
|
| 93 |
-
});
|
| 94 |
-
}
|
| 95 |
-
__name(escapeItalic, "escapeItalic");
|
| 96 |
-
function escapeBold(text) {
|
| 97 |
-
let idx = 0;
|
| 98 |
-
return text.replaceAll(/\*\*(\*)?/g, (_, match) => {
|
| 99 |
-
if (match) return ++idx % 2 ? `${match}\\*\\*` : `\\*\\*${match}`;
|
| 100 |
-
return "\\*\\*";
|
| 101 |
-
});
|
| 102 |
-
}
|
| 103 |
-
__name(escapeBold, "escapeBold");
|
| 104 |
-
function escapeUnderline(text) {
|
| 105 |
-
let idx = 0;
|
| 106 |
-
return text.replaceAll(/(?<!<a?:.+|https?:\/\/\S+)__(_)?(?!:\d+>)/g, (_, match) => {
|
| 107 |
-
if (match) return ++idx % 2 ? `${match}\\_\\_` : `\\_\\_${match}`;
|
| 108 |
-
return "\\_\\_";
|
| 109 |
-
});
|
| 110 |
-
}
|
| 111 |
-
__name(escapeUnderline, "escapeUnderline");
|
| 112 |
-
function escapeStrikethrough(text) {
|
| 113 |
-
return text.replaceAll("~~", "\\~\\~");
|
| 114 |
-
}
|
| 115 |
-
__name(escapeStrikethrough, "escapeStrikethrough");
|
| 116 |
-
function escapeSpoiler(text) {
|
| 117 |
-
return text.replaceAll("||", "\\|\\|");
|
| 118 |
-
}
|
| 119 |
-
__name(escapeSpoiler, "escapeSpoiler");
|
| 120 |
-
function escapeEscape(text) {
|
| 121 |
-
return text.replaceAll("\\", "\\\\");
|
| 122 |
-
}
|
| 123 |
-
__name(escapeEscape, "escapeEscape");
|
| 124 |
-
function escapeHeading(text) {
|
| 125 |
-
return text.replaceAll(/^( {0,2})([*-] )?( *)(#{1,3} )/gm, "$1$2$3\\$4");
|
| 126 |
-
}
|
| 127 |
-
__name(escapeHeading, "escapeHeading");
|
| 128 |
-
function escapeBulletedList(text) {
|
| 129 |
-
return text.replaceAll(/^( *)([*-])( +)/gm, "$1\\$2$3");
|
| 130 |
-
}
|
| 131 |
-
__name(escapeBulletedList, "escapeBulletedList");
|
| 132 |
-
function escapeNumberedList(text) {
|
| 133 |
-
return text.replaceAll(/^( *\d+)\./gm, "$1\\.");
|
| 134 |
-
}
|
| 135 |
-
__name(escapeNumberedList, "escapeNumberedList");
|
| 136 |
-
function escapeMaskedLink(text) {
|
| 137 |
-
return text.replaceAll(/\[.+]\(.+\)/gm, "\\$&");
|
| 138 |
-
}
|
| 139 |
-
__name(escapeMaskedLink, "escapeMaskedLink");
|
| 140 |
-
|
| 141 |
-
// src/formatters.ts
|
| 142 |
-
function codeBlock(language, content) {
|
| 143 |
-
return content === void 0 ? `\`\`\`
|
| 144 |
-
${language}
|
| 145 |
-
\`\`\`` : `\`\`\`${language}
|
| 146 |
-
${content}
|
| 147 |
-
\`\`\``;
|
| 148 |
-
}
|
| 149 |
-
__name(codeBlock, "codeBlock");
|
| 150 |
-
function inlineCode(content) {
|
| 151 |
-
return `\`${content}\``;
|
| 152 |
-
}
|
| 153 |
-
__name(inlineCode, "inlineCode");
|
| 154 |
-
function italic(content) {
|
| 155 |
-
return `_${content}_`;
|
| 156 |
-
}
|
| 157 |
-
__name(italic, "italic");
|
| 158 |
-
function bold(content) {
|
| 159 |
-
return `**${content}**`;
|
| 160 |
-
}
|
| 161 |
-
__name(bold, "bold");
|
| 162 |
-
function underscore(content) {
|
| 163 |
-
return underline(content);
|
| 164 |
-
}
|
| 165 |
-
__name(underscore, "underscore");
|
| 166 |
-
function underline(content) {
|
| 167 |
-
return `__${content}__`;
|
| 168 |
-
}
|
| 169 |
-
__name(underline, "underline");
|
| 170 |
-
function strikethrough(content) {
|
| 171 |
-
return `~~${content}~~`;
|
| 172 |
-
}
|
| 173 |
-
__name(strikethrough, "strikethrough");
|
| 174 |
-
function quote(content) {
|
| 175 |
-
return `> ${content}`;
|
| 176 |
-
}
|
| 177 |
-
__name(quote, "quote");
|
| 178 |
-
function blockQuote(content) {
|
| 179 |
-
return `>>> ${content}`;
|
| 180 |
-
}
|
| 181 |
-
__name(blockQuote, "blockQuote");
|
| 182 |
-
function hideLinkEmbed(url) {
|
| 183 |
-
return `<${url}>`;
|
| 184 |
-
}
|
| 185 |
-
__name(hideLinkEmbed, "hideLinkEmbed");
|
| 186 |
-
function hyperlink(content, url, title) {
|
| 187 |
-
return title ? `[${content}](${url} "${title}")` : `[${content}](${url})`;
|
| 188 |
-
}
|
| 189 |
-
__name(hyperlink, "hyperlink");
|
| 190 |
-
function spoiler(content) {
|
| 191 |
-
return `||${content}||`;
|
| 192 |
-
}
|
| 193 |
-
__name(spoiler, "spoiler");
|
| 194 |
-
function userMention(userId) {
|
| 195 |
-
return `<@${userId}>`;
|
| 196 |
-
}
|
| 197 |
-
__name(userMention, "userMention");
|
| 198 |
-
function channelMention(channelId) {
|
| 199 |
-
return `<#${channelId}>`;
|
| 200 |
-
}
|
| 201 |
-
__name(channelMention, "channelMention");
|
| 202 |
-
function roleMention(roleId) {
|
| 203 |
-
return `<@&${roleId}>`;
|
| 204 |
-
}
|
| 205 |
-
__name(roleMention, "roleMention");
|
| 206 |
-
function chatInputApplicationCommandMention(commandName, subcommandGroupName, subcommandName, commandId) {
|
| 207 |
-
if (commandId !== void 0) {
|
| 208 |
-
return `</${commandName} ${subcommandGroupName} ${subcommandName}:${commandId}>`;
|
| 209 |
-
}
|
| 210 |
-
if (subcommandName !== void 0) {
|
| 211 |
-
return `</${commandName} ${subcommandGroupName}:${subcommandName}>`;
|
| 212 |
-
}
|
| 213 |
-
return `</${commandName}:${subcommandGroupName}>`;
|
| 214 |
-
}
|
| 215 |
-
__name(chatInputApplicationCommandMention, "chatInputApplicationCommandMention");
|
| 216 |
-
function formatEmoji(emojiIdOrOptions, animated) {
|
| 217 |
-
const options = typeof emojiIdOrOptions === "string" ? {
|
| 218 |
-
id: emojiIdOrOptions,
|
| 219 |
-
animated: animated ?? false
|
| 220 |
-
} : emojiIdOrOptions;
|
| 221 |
-
const { id, animated: isAnimated, name: emojiName } = options;
|
| 222 |
-
return `<${isAnimated ? "a" : ""}:${emojiName ?? "_"}:${id}>`;
|
| 223 |
-
}
|
| 224 |
-
__name(formatEmoji, "formatEmoji");
|
| 225 |
-
function channelLink(channelId, guildId) {
|
| 226 |
-
return `https://discord.com/channels/${guildId ?? "@me"}/${channelId}`;
|
| 227 |
-
}
|
| 228 |
-
__name(channelLink, "channelLink");
|
| 229 |
-
function messageLink(channelId, messageId, guildId) {
|
| 230 |
-
return `${guildId === void 0 ? channelLink(channelId) : channelLink(channelId, guildId)}/${messageId}`;
|
| 231 |
-
}
|
| 232 |
-
__name(messageLink, "messageLink");
|
| 233 |
-
var HeadingLevel = /* @__PURE__ */ ((HeadingLevel2) => {
|
| 234 |
-
HeadingLevel2[HeadingLevel2["One"] = 1] = "One";
|
| 235 |
-
HeadingLevel2[HeadingLevel2["Two"] = 2] = "Two";
|
| 236 |
-
HeadingLevel2[HeadingLevel2["Three"] = 3] = "Three";
|
| 237 |
-
return HeadingLevel2;
|
| 238 |
-
})(HeadingLevel || {});
|
| 239 |
-
function heading(content, level) {
|
| 240 |
-
switch (level) {
|
| 241 |
-
case 3 /* Three */:
|
| 242 |
-
return `### ${content}`;
|
| 243 |
-
case 2 /* Two */:
|
| 244 |
-
return `## ${content}`;
|
| 245 |
-
default:
|
| 246 |
-
return `# ${content}`;
|
| 247 |
-
}
|
| 248 |
-
}
|
| 249 |
-
__name(heading, "heading");
|
| 250 |
-
function listCallback(element, startNumber, depth = 0) {
|
| 251 |
-
if (Array.isArray(element)) {
|
| 252 |
-
return element.map((element2) => listCallback(element2, startNumber, depth + 1)).join("\n");
|
| 253 |
-
}
|
| 254 |
-
return `${" ".repeat(depth - 1)}${startNumber ? `${startNumber}.` : "-"} ${element}`;
|
| 255 |
-
}
|
| 256 |
-
__name(listCallback, "listCallback");
|
| 257 |
-
function orderedList(list, startNumber = 1) {
|
| 258 |
-
return listCallback(list, Math.max(startNumber, 1));
|
| 259 |
-
}
|
| 260 |
-
__name(orderedList, "orderedList");
|
| 261 |
-
function unorderedList(list) {
|
| 262 |
-
return listCallback(list);
|
| 263 |
-
}
|
| 264 |
-
__name(unorderedList, "unorderedList");
|
| 265 |
-
function subtext(content) {
|
| 266 |
-
return `-# ${content}`;
|
| 267 |
-
}
|
| 268 |
-
__name(subtext, "subtext");
|
| 269 |
-
function time(timeOrSeconds, style) {
|
| 270 |
-
if (typeof timeOrSeconds !== "number") {
|
| 271 |
-
timeOrSeconds = Math.floor((timeOrSeconds?.getTime() ?? Date.now()) / 1e3);
|
| 272 |
-
}
|
| 273 |
-
return typeof style === "string" ? `<t:${timeOrSeconds}:${style}>` : `<t:${timeOrSeconds}>`;
|
| 274 |
-
}
|
| 275 |
-
__name(time, "time");
|
| 276 |
-
function applicationDirectory(applicationId, skuId) {
|
| 277 |
-
const url = `https://discord.com/application-directory/${applicationId}/store`;
|
| 278 |
-
return skuId ? `${url}/${skuId}` : url;
|
| 279 |
-
}
|
| 280 |
-
__name(applicationDirectory, "applicationDirectory");
|
| 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 |
-
|
| 338 |
-
// src/index.ts
|
| 339 |
-
var version = "0.6.1";
|
| 340 |
-
export {
|
| 341 |
-
Faces,
|
| 342 |
-
GuildNavigationMentions,
|
| 343 |
-
HeadingLevel,
|
| 344 |
-
TimestampStyles,
|
| 345 |
-
applicationDirectory,
|
| 346 |
-
blockQuote,
|
| 347 |
-
bold,
|
| 348 |
-
channelLink,
|
| 349 |
-
channelMention,
|
| 350 |
-
chatInputApplicationCommandMention,
|
| 351 |
-
codeBlock,
|
| 352 |
-
escapeBold,
|
| 353 |
-
escapeBulletedList,
|
| 354 |
-
escapeCodeBlock,
|
| 355 |
-
escapeEscape,
|
| 356 |
-
escapeHeading,
|
| 357 |
-
escapeInlineCode,
|
| 358 |
-
escapeItalic,
|
| 359 |
-
escapeMarkdown,
|
| 360 |
-
escapeMaskedLink,
|
| 361 |
-
escapeNumberedList,
|
| 362 |
-
escapeSpoiler,
|
| 363 |
-
escapeStrikethrough,
|
| 364 |
-
escapeUnderline,
|
| 365 |
-
formatEmoji,
|
| 366 |
-
heading,
|
| 367 |
-
hideLinkEmbed,
|
| 368 |
-
hyperlink,
|
| 369 |
-
inlineCode,
|
| 370 |
-
italic,
|
| 371 |
-
messageLink,
|
| 372 |
-
orderedList,
|
| 373 |
-
quote,
|
| 374 |
-
roleMention,
|
| 375 |
-
spoiler,
|
| 376 |
-
strikethrough,
|
| 377 |
-
subtext,
|
| 378 |
-
time,
|
| 379 |
-
underline,
|
| 380 |
-
underscore,
|
| 381 |
-
unorderedList,
|
| 382 |
-
userMention,
|
| 383 |
-
version
|
| 384 |
-
};
|
| 385 |
-
//# sourceMappingURL=index.mjs.map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/formatters/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"version":3,"sources":["../src/escapers.ts","../src/formatters.ts","../src/index.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?:.+|https?:\\/\\/\\S+)_(?!:\\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?:.+|https?:\\/\\/\\S+)__(_)?(?!:\\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 * @deprecated Use {@link underline} instead.\n */\nexport function underscore<Content extends string>(content: Content): `__${Content}__` {\n\treturn underline(content);\n}\n\n/**\n * Formats the content into underlined text.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function underline<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\n/**\n * Formats a non-animated emoji id and name into a fully qualified emoji identifier.\n *\n * @typeParam EmojiId - This is inferred by the supplied emoji id\n * @typeParam EmojiName - This is inferred by the supplied name\n * @param options - The options for formatting an emoji\n */\nexport function formatEmoji<EmojiId extends Snowflake, EmojiName extends string>(\n\toptions: FormatEmojiOptions<EmojiId, EmojiName> & { animated: true },\n): `<a:${EmojiName}:${EmojiId}>`;\n\n/**\n * Formats an animated emoji id and name into a fully qualified emoji identifier.\n *\n * @typeParam EmojiId - This is inferred by the supplied emoji id\n * @typeParam EmojiName - This is inferred by the supplied name\n * @param options - The options for formatting an emoji\n */\nexport function formatEmoji<EmojiId extends Snowflake, EmojiName extends string>(\n\toptions: FormatEmojiOptions<EmojiId, EmojiName> & { animated?: false },\n): `<:${EmojiName}:${EmojiId}>`;\n\n/**\n * Formats an emoji id and name into a fully qualified emoji identifier.\n *\n * @typeParam EmojiId - This is inferred by the supplied emoji id\n * @typeParam EmojiName - This is inferred by the supplied emoji name\n * @param options - The options for formatting an emoji\n */\nexport function formatEmoji<EmojiId extends Snowflake, EmojiName extends string>(\n\toptions: FormatEmojiOptions<EmojiId, EmojiName>,\n): `<:${EmojiName}:${EmojiId}>` | `<a:${EmojiName}:${EmojiId}>`;\n\nexport function formatEmoji<EmojiId extends Snowflake, EmojiName extends string>(\n\temojiIdOrOptions: EmojiId | FormatEmojiOptions<EmojiId, EmojiName>,\n\tanimated?: boolean,\n): `<:${string}:${EmojiId}>` | `<a:${string}:${EmojiId}>` {\n\tconst options =\n\t\ttypeof emojiIdOrOptions === 'string'\n\t\t\t? {\n\t\t\t\t\tid: emojiIdOrOptions,\n\t\t\t\t\tanimated: animated ?? false,\n\t\t\t\t}\n\t\t\t: emojiIdOrOptions;\n\n\tconst { id, animated: isAnimated, name: emojiName } = options;\n\n\treturn `<${isAnimated ? 'a' : ''}:${emojiName ?? '_'}:${id}>`;\n}\n\n/**\n * The options for formatting an emoji.\n *\n * @typeParam EmojiId - This is inferred by the supplied emoji id\n * @typeParam EmojiName - This is inferred by the supplied emoji name\n */\nexport interface FormatEmojiOptions<EmojiId extends Snowflake, EmojiName extends string> {\n\t/**\n\t * Whether the emoji is animated\n\t */\n\tanimated?: boolean;\n\t/**\n\t * The emoji id to format\n\t */\n\tid: EmojiId;\n\t/**\n\t * The name of the emoji\n\t */\n\tname?: EmojiName;\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 the content into a subtext.\n *\n * @typeParam Content - This is inferred by the supplied content\n * @param content - The content to wrap\n */\nexport function subtext<Content extends string>(content: Content): `-# ${Content}` {\n\treturn `-# ${content}`;\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 * Formats an application directory link.\n *\n * @typeParam ApplicationId - This is inferred by the supplied application id\n * @param applicationId - The application id\n */\nexport function applicationDirectory<ApplicationId extends Snowflake>(\n\tapplicationId: ApplicationId,\n): `https://discord.com/application-directory/${ApplicationId}/store`;\n\n/**\n * Formats an application directory SKU link.\n *\n * @typeParam ApplicationId - This is inferred by the supplied application id\n * @typeParam SKUId - This is inferred by the supplied SKU id\n * @param applicationId - The application id\n * @param skuId - The SKU id\n */\nexport function applicationDirectory<ApplicationId extends Snowflake, SKUId extends Snowflake>(\n\tapplicationId: ApplicationId,\n\tskuId: SKUId,\n): `https://discord.com/application-directory/${ApplicationId}/store/${SKUId}`;\n\nexport function applicationDirectory<ApplicationId extends Snowflake, SKUId extends Snowflake>(\n\tapplicationId: ApplicationId,\n\tskuId?: SKUId,\n):\n\t| `https://discord.com/application-directory/${ApplicationId}/store/${SKUId}`\n\t| `https://discord.com/application-directory/${ApplicationId}/store` {\n\tconst url = `https://discord.com/application-directory/${applicationId}/store` as const;\n\treturn skuId ? `${url}/${skuId}` : url;\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/**\n * All the available faces from Discord's native slash commands.\n */\nexport enum Faces {\n\t/**\n\t * `¯\\_(ツ)_/¯`\n\t */\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","export * from './escapers.js';\nexport * from './formatters.js';\n\n/**\n * The {@link https://github.com/discordjs/discord.js/blob/main/packages/formatters#readme | @discordjs/formatters} version\n * that you are currently using.\n *\n * @privateRemarks This needs to explicitly be `string` so it is not typed as a \"const string\" that gets injected by esbuild.\n */\nexport const version = '0.6.1' as string;\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,WAAAC,aAAY;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,EAAG,QAAO;AACpD,aAAO,eAAe,WAAW;AAAA,QAChC,YAAAN;AAAA,QACA,MAAAC;AAAA,QACA,QAAAC;AAAA,QACA,WAAAC;AAAA,QACA,eAAAC;AAAA,QACA,SAAAC;AAAA,QACA;AAAA,QACA;AAAA,QACA,SAAAC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,CAAC;AAAA,IACF,CAAC,EACA,KAAKP,aAAY,cAAc,KAAK;AAAA,EACvC;AAEA,MAAI,CAAC,mBAAmB;AACvB,WAAO,KACL,MAAM,yBAAyB,EAC/B,IAAI,CAAC,WAAW,OAAO,UAAU;AACjC,UAAI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["codeBlock","inlineCode","bold","italic","underline","strikethrough","spoiler","heading","HeadingLevel","element","Faces","GuildNavigationMentions"]}
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/formatters/package.json
DELETED
|
@@ -1,83 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"$schema": "https://json.schemastore.org/package.json",
|
| 3 |
-
"name": "@discordjs/formatters",
|
| 4 |
-
"version": "0.6.1",
|
| 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 <me@vladfrangu.dev>",
|
| 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 |
-
"funding": "https://github.com/discordjs/discord.js?sponsor",
|
| 46 |
-
"dependencies": {
|
| 47 |
-
"discord-api-types": "^0.38.1"
|
| 48 |
-
},
|
| 49 |
-
"devDependencies": {
|
| 50 |
-
"@favware/cliff-jumper": "^4.1.0",
|
| 51 |
-
"@types/node": "^16.18.105",
|
| 52 |
-
"@vitest/coverage-v8": "^2.0.5",
|
| 53 |
-
"cross-env": "^7.0.3",
|
| 54 |
-
"esbuild-plugin-version-injector": "^1.2.1",
|
| 55 |
-
"eslint": "^8.57.0",
|
| 56 |
-
"eslint-config-neon": "^0.1.62",
|
| 57 |
-
"eslint-formatter-pretty": "^6.0.1",
|
| 58 |
-
"prettier": "^3.3.3",
|
| 59 |
-
"tsup": "^8.2.4",
|
| 60 |
-
"turbo": "^2.0.14",
|
| 61 |
-
"typescript": "~5.5.4",
|
| 62 |
-
"vitest": "^2.0.5",
|
| 63 |
-
"@discordjs/api-extractor": "^7.38.1",
|
| 64 |
-
"@discordjs/scripts": "^0.1.0"
|
| 65 |
-
},
|
| 66 |
-
"engines": {
|
| 67 |
-
"node": ">=16.11.0"
|
| 68 |
-
},
|
| 69 |
-
"publishConfig": {
|
| 70 |
-
"access": "public",
|
| 71 |
-
"provenance": true
|
| 72 |
-
},
|
| 73 |
-
"scripts": {
|
| 74 |
-
"test": "vitest run",
|
| 75 |
-
"build": "tsc --noEmit && tsup",
|
| 76 |
-
"build:docs": "tsc -p tsconfig.docs.json",
|
| 77 |
-
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src __tests__",
|
| 78 |
-
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src __tests__",
|
| 79 |
-
"docs": "pnpm run build:docs && api-extractor run --local --minify && generate-split-documentation",
|
| 80 |
-
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/formatters/*'",
|
| 81 |
-
"release": "cliff-jumper"
|
| 82 |
-
}
|
| 83 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/rest/LICENSE
DELETED
|
@@ -1,192 +0,0 @@
|
|
| 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/rest/README.md
DELETED
|
@@ -1,138 +0,0 @@
|
|
| 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://github.com/discordjs/discord.js/commits/main/packages/rest" ><img alt="Last commit." src="https://img.shields.io/github/last-commit/discordjs/discord.js?logo=github&logoColor=ffffff&path=packages%2Frest"></a>
|
| 13 |
-
<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>
|
| 14 |
-
</p>
|
| 15 |
-
<p>
|
| 16 |
-
<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>
|
| 17 |
-
<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>
|
| 18 |
-
</p>
|
| 19 |
-
</div>
|
| 20 |
-
|
| 21 |
-
## About
|
| 22 |
-
|
| 23 |
-
`@discordjs/rest` is a module that allows you to easily make REST requests to the Discord API.
|
| 24 |
-
|
| 25 |
-
## Installation
|
| 26 |
-
|
| 27 |
-
**Node.js 18 or newer is required.**
|
| 28 |
-
|
| 29 |
-
```sh
|
| 30 |
-
npm install @discordjs/rest
|
| 31 |
-
yarn add @discordjs/rest
|
| 32 |
-
pnpm add @discordjs/rest
|
| 33 |
-
bun add @discordjs/rest
|
| 34 |
-
```
|
| 35 |
-
|
| 36 |
-
## Examples
|
| 37 |
-
|
| 38 |
-
Install all required dependencies:
|
| 39 |
-
|
| 40 |
-
```sh
|
| 41 |
-
npm install @discordjs/rest discord-api-types
|
| 42 |
-
yarn add @discordjs/rest discord-api-types
|
| 43 |
-
pnpm add @discordjs/rest discord-api-types
|
| 44 |
-
bun add @discordjs/rest discord-api-types
|
| 45 |
-
```
|
| 46 |
-
|
| 47 |
-
Send a basic message:
|
| 48 |
-
|
| 49 |
-
```js
|
| 50 |
-
import { REST } from '@discordjs/rest';
|
| 51 |
-
import { Routes } from 'discord-api-types/v10';
|
| 52 |
-
|
| 53 |
-
const rest = new REST({ version: '10' }).setToken(TOKEN);
|
| 54 |
-
|
| 55 |
-
try {
|
| 56 |
-
await rest.post(Routes.channelMessages(CHANNEL_ID), {
|
| 57 |
-
body: {
|
| 58 |
-
content: 'A message via REST!',
|
| 59 |
-
},
|
| 60 |
-
});
|
| 61 |
-
} catch (error) {
|
| 62 |
-
console.error(error);
|
| 63 |
-
}
|
| 64 |
-
```
|
| 65 |
-
|
| 66 |
-
Create a thread from an existing message to be archived after 60 minutes of inactivity:
|
| 67 |
-
|
| 68 |
-
```js
|
| 69 |
-
import { REST } from '@discordjs/rest';
|
| 70 |
-
import { Routes } from 'discord-api-types/v10';
|
| 71 |
-
|
| 72 |
-
const rest = new REST({ version: '10' }).setToken(TOKEN);
|
| 73 |
-
|
| 74 |
-
try {
|
| 75 |
-
await rest.post(Routes.threads(CHANNEL_ID, MESSAGE_ID), {
|
| 76 |
-
body: {
|
| 77 |
-
name: 'Thread',
|
| 78 |
-
auto_archive_duration: 60,
|
| 79 |
-
},
|
| 80 |
-
});
|
| 81 |
-
} catch (error) {
|
| 82 |
-
console.error(error);
|
| 83 |
-
}
|
| 84 |
-
```
|
| 85 |
-
|
| 86 |
-
Send a basic message in an edge environment:
|
| 87 |
-
|
| 88 |
-
```js
|
| 89 |
-
import { REST } from '@discordjs/rest';
|
| 90 |
-
import { Routes } from 'discord-api-types/v10';
|
| 91 |
-
|
| 92 |
-
const rest = new REST({ version: '10', makeRequest: fetch }).setToken(TOKEN);
|
| 93 |
-
|
| 94 |
-
try {
|
| 95 |
-
await rest.post(Routes.channelMessages(CHANNEL_ID), {
|
| 96 |
-
body: {
|
| 97 |
-
content: 'A message via REST from the edge!',
|
| 98 |
-
},
|
| 99 |
-
});
|
| 100 |
-
} catch (error) {
|
| 101 |
-
console.error(error);
|
| 102 |
-
}
|
| 103 |
-
```
|
| 104 |
-
|
| 105 |
-
## Links
|
| 106 |
-
|
| 107 |
-
- [Website][website] ([source][website-source])
|
| 108 |
-
- [Documentation][documentation]
|
| 109 |
-
- [Guide][guide] ([source][guide-source])
|
| 110 |
-
Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
|
| 111 |
-
- [discord.js Discord server][discord]
|
| 112 |
-
- [Discord API Discord server][discord-api]
|
| 113 |
-
- [GitHub][source]
|
| 114 |
-
- [npm][npm]
|
| 115 |
-
- [Related libraries][related-libs]
|
| 116 |
-
|
| 117 |
-
## Contributing
|
| 118 |
-
|
| 119 |
-
Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
|
| 120 |
-
[documentation][documentation].
|
| 121 |
-
See [the contribution guide][contributing] if you'd like to submit a PR.
|
| 122 |
-
|
| 123 |
-
## Help
|
| 124 |
-
|
| 125 |
-
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].
|
| 126 |
-
|
| 127 |
-
[website]: https://discord.js.org
|
| 128 |
-
[website-source]: https://github.com/discordjs/discord.js/tree/main/apps/website
|
| 129 |
-
[documentation]: https://discord.js.org/docs/packages/rest/stable
|
| 130 |
-
[guide]: https://discordjs.guide/
|
| 131 |
-
[guide-source]: https://github.com/discordjs/guide
|
| 132 |
-
[guide-update]: https://discordjs.guide/additional-info/changes-in-v14.html
|
| 133 |
-
[discord]: https://discord.gg/djs
|
| 134 |
-
[discord-api]: https://discord.gg/discord-api
|
| 135 |
-
[source]: https://github.com/discordjs/discord.js/tree/main/packages/rest
|
| 136 |
-
[npm]: https://www.npmjs.com/package/@discordjs/rest
|
| 137 |
-
[related-libs]: https://discord.com/developers/docs/topics/community-resources#libraries
|
| 138 |
-
[contributing]: https://github.com/discordjs/discord.js/blob/main/.github/CONTRIBUTING.md
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/rest/dist/index.d.mts
DELETED
|
@@ -1,958 +0,0 @@
|
|
| 1 |
-
import * as url from 'url';
|
| 2 |
-
import { ImageSize, Snowflake } from 'discord-api-types/v10';
|
| 3 |
-
export { ImageSize } from 'discord-api-types/v10';
|
| 4 |
-
import { Readable } from 'node:stream';
|
| 5 |
-
import { ReadableStream } from 'node:stream/web';
|
| 6 |
-
import { Collection } from '@discordjs/collection';
|
| 7 |
-
import { Awaitable } from '@discordjs/util';
|
| 8 |
-
import * as undici from 'undici';
|
| 9 |
-
import { RequestInit, Dispatcher, Response, BodyInit, Agent } from 'undici';
|
| 10 |
-
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
| 11 |
-
|
| 12 |
-
interface IHandler {
|
| 13 |
-
/**
|
| 14 |
-
* The unique id of the handler
|
| 15 |
-
*/
|
| 16 |
-
readonly id: string;
|
| 17 |
-
/**
|
| 18 |
-
* If the bucket is currently inactive (no pending requests)
|
| 19 |
-
*/
|
| 20 |
-
get inactive(): boolean;
|
| 21 |
-
/**
|
| 22 |
-
* Queues a request to be sent
|
| 23 |
-
*
|
| 24 |
-
* @param routeId - The generalized api route with literal ids for major parameters
|
| 25 |
-
* @param url - The url to do the request on
|
| 26 |
-
* @param options - All the information needed to make a request
|
| 27 |
-
* @param requestData - Extra data from the user's request needed for errors and additional processing
|
| 28 |
-
*/
|
| 29 |
-
queueRequest(routeId: RouteData, url: string, options: RequestInit, requestData: HandlerRequestData): Promise<ResponseLike>;
|
| 30 |
-
}
|
| 31 |
-
|
| 32 |
-
interface RestEvents {
|
| 33 |
-
handlerSweep: [sweptHandlers: Collection<string, IHandler>];
|
| 34 |
-
hashSweep: [sweptHashes: Collection<string, HashData>];
|
| 35 |
-
invalidRequestWarning: [invalidRequestInfo: InvalidRequestWarningData];
|
| 36 |
-
rateLimited: [rateLimitInfo: RateLimitData];
|
| 37 |
-
response: [request: APIRequest, response: ResponseLike];
|
| 38 |
-
restDebug: [info: string];
|
| 39 |
-
}
|
| 40 |
-
interface RestEventsMap extends RestEvents {
|
| 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 media proxy path
|
| 113 |
-
*
|
| 114 |
-
* @defaultValue `'https://media.discordapp.net'`
|
| 115 |
-
*/
|
| 116 |
-
mediaProxy: string;
|
| 117 |
-
/**
|
| 118 |
-
* The extra offset to add to rate limits in milliseconds
|
| 119 |
-
*
|
| 120 |
-
* @defaultValue `50`
|
| 121 |
-
*/
|
| 122 |
-
offset: GetRateLimitOffsetFunction | number;
|
| 123 |
-
/**
|
| 124 |
-
* Determines how rate limiting and pre-emptive throttling should be handled.
|
| 125 |
-
* When an array of strings, each element is treated as a prefix for the request route
|
| 126 |
-
* (e.g. `/channels` to match any route starting with `/channels` such as `/channels/:id/messages`)
|
| 127 |
-
* for which to throw {@link RateLimitError}s. All other request routes will be queued normally
|
| 128 |
-
*
|
| 129 |
-
* @defaultValue `null`
|
| 130 |
-
*/
|
| 131 |
-
rejectOnRateLimit: RateLimitQueueFilter | string[] | null;
|
| 132 |
-
/**
|
| 133 |
-
* The number of retries for errors with the 500 code, or errors
|
| 134 |
-
* that timeout
|
| 135 |
-
*
|
| 136 |
-
* @defaultValue `3`
|
| 137 |
-
*/
|
| 138 |
-
retries: number;
|
| 139 |
-
/**
|
| 140 |
-
* The time to wait in milliseconds before a request is aborted
|
| 141 |
-
*
|
| 142 |
-
* @defaultValue `15_000`
|
| 143 |
-
*/
|
| 144 |
-
timeout: number;
|
| 145 |
-
/**
|
| 146 |
-
* Extra information to add to the user agent
|
| 147 |
-
*
|
| 148 |
-
* @defaultValue DefaultUserAgentAppendix
|
| 149 |
-
*/
|
| 150 |
-
userAgentAppendix: string;
|
| 151 |
-
/**
|
| 152 |
-
* The version of the API to use
|
| 153 |
-
*
|
| 154 |
-
* @defaultValue `'10'`
|
| 155 |
-
*/
|
| 156 |
-
version: string;
|
| 157 |
-
}
|
| 158 |
-
/**
|
| 159 |
-
* Data emitted on `RESTEvents.RateLimited`
|
| 160 |
-
*/
|
| 161 |
-
interface RateLimitData {
|
| 162 |
-
/**
|
| 163 |
-
* Whether the rate limit that was reached was the global limit
|
| 164 |
-
*/
|
| 165 |
-
global: boolean;
|
| 166 |
-
/**
|
| 167 |
-
* The bucket hash for this request
|
| 168 |
-
*/
|
| 169 |
-
hash: string;
|
| 170 |
-
/**
|
| 171 |
-
* The amount of requests we can perform before locking requests
|
| 172 |
-
*/
|
| 173 |
-
limit: number;
|
| 174 |
-
/**
|
| 175 |
-
* The major parameter of the route
|
| 176 |
-
*
|
| 177 |
-
* For example, in `/channels/x`, this will be `x`.
|
| 178 |
-
* If there is no major parameter (e.g: `/bot/gateway`) this will be `global`.
|
| 179 |
-
*/
|
| 180 |
-
majorParameter: string;
|
| 181 |
-
/**
|
| 182 |
-
* The HTTP method being performed
|
| 183 |
-
*/
|
| 184 |
-
method: string;
|
| 185 |
-
/**
|
| 186 |
-
* The time, in milliseconds, that will need to pass before this specific request can be retried
|
| 187 |
-
*/
|
| 188 |
-
retryAfter: number;
|
| 189 |
-
/**
|
| 190 |
-
* The route being hit in this request
|
| 191 |
-
*/
|
| 192 |
-
route: string;
|
| 193 |
-
/**
|
| 194 |
-
* The scope of the rate limit that was hit.
|
| 195 |
-
*
|
| 196 |
-
* 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
|
| 197 |
-
* are shared per resource.
|
| 198 |
-
*/
|
| 199 |
-
scope: 'global' | 'shared' | 'user';
|
| 200 |
-
/**
|
| 201 |
-
* The time, in milliseconds, that will need to pass before the sublimit lock for the route resets, and requests that fall under a sublimit
|
| 202 |
-
* can be retried
|
| 203 |
-
*
|
| 204 |
-
* This is only present on certain sublimits, and `0` otherwise
|
| 205 |
-
*/
|
| 206 |
-
sublimitTimeout: number;
|
| 207 |
-
/**
|
| 208 |
-
* The time, in milliseconds, until the route's request-lock is reset
|
| 209 |
-
*/
|
| 210 |
-
timeToReset: number;
|
| 211 |
-
/**
|
| 212 |
-
* The full URL for this request
|
| 213 |
-
*/
|
| 214 |
-
url: string;
|
| 215 |
-
}
|
| 216 |
-
/**
|
| 217 |
-
* A function that determines whether the rate limit hit should throw an Error
|
| 218 |
-
*/
|
| 219 |
-
type RateLimitQueueFilter = (rateLimitData: RateLimitData) => Awaitable<boolean>;
|
| 220 |
-
/**
|
| 221 |
-
* A function that determines the rate limit offset for a given request.
|
| 222 |
-
*/
|
| 223 |
-
type GetRateLimitOffsetFunction = (route: string) => number;
|
| 224 |
-
interface APIRequest {
|
| 225 |
-
/**
|
| 226 |
-
* The data that was used to form the body of this request
|
| 227 |
-
*/
|
| 228 |
-
data: HandlerRequestData;
|
| 229 |
-
/**
|
| 230 |
-
* The HTTP method used in this request
|
| 231 |
-
*/
|
| 232 |
-
method: string;
|
| 233 |
-
/**
|
| 234 |
-
* Additional HTTP options for this request
|
| 235 |
-
*/
|
| 236 |
-
options: RequestInit;
|
| 237 |
-
/**
|
| 238 |
-
* The full path used to make the request
|
| 239 |
-
*/
|
| 240 |
-
path: RouteLike;
|
| 241 |
-
/**
|
| 242 |
-
* The number of times this request has been attempted
|
| 243 |
-
*/
|
| 244 |
-
retries: number;
|
| 245 |
-
/**
|
| 246 |
-
* The API route identifying the ratelimit for this request
|
| 247 |
-
*/
|
| 248 |
-
route: string;
|
| 249 |
-
}
|
| 250 |
-
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | 'headers' | 'json' | 'ok' | 'status' | 'statusText' | 'text'> {
|
| 251 |
-
body: Readable | ReadableStream | null;
|
| 252 |
-
}
|
| 253 |
-
interface InvalidRequestWarningData {
|
| 254 |
-
/**
|
| 255 |
-
* Number of invalid requests that have been made in the window
|
| 256 |
-
*/
|
| 257 |
-
count: number;
|
| 258 |
-
/**
|
| 259 |
-
* Time in milliseconds remaining before the count resets
|
| 260 |
-
*/
|
| 261 |
-
remainingTime: number;
|
| 262 |
-
}
|
| 263 |
-
/**
|
| 264 |
-
* Represents a file to be added to the request
|
| 265 |
-
*/
|
| 266 |
-
interface RawFile {
|
| 267 |
-
/**
|
| 268 |
-
* Content-Type of the file
|
| 269 |
-
*/
|
| 270 |
-
contentType?: string;
|
| 271 |
-
/**
|
| 272 |
-
* The actual data for the file
|
| 273 |
-
*/
|
| 274 |
-
data: Buffer | Uint8Array | boolean | number | string;
|
| 275 |
-
/**
|
| 276 |
-
* An explicit key to use for key of the formdata field for this file.
|
| 277 |
-
* When not provided, the index of the file in the files array is used in the form `files[${index}]`.
|
| 278 |
-
* If you wish to alter the placeholder snowflake, you must provide this property in the same form (`files[${placeholder}]`)
|
| 279 |
-
*/
|
| 280 |
-
key?: string;
|
| 281 |
-
/**
|
| 282 |
-
* The name of the file
|
| 283 |
-
*/
|
| 284 |
-
name: string;
|
| 285 |
-
}
|
| 286 |
-
/**
|
| 287 |
-
* Represents possible data to be given to an endpoint
|
| 288 |
-
*/
|
| 289 |
-
interface RequestData {
|
| 290 |
-
/**
|
| 291 |
-
* Whether to append JSON data to form data instead of `payload_json` when sending files
|
| 292 |
-
*/
|
| 293 |
-
appendToFormData?: boolean;
|
| 294 |
-
/**
|
| 295 |
-
* If this request needs the `Authorization` header
|
| 296 |
-
*
|
| 297 |
-
* @defaultValue `true`
|
| 298 |
-
*/
|
| 299 |
-
auth?: boolean;
|
| 300 |
-
/**
|
| 301 |
-
* The authorization prefix to use for this request, useful if you use this with bearer tokens
|
| 302 |
-
*
|
| 303 |
-
* @defaultValue `'Bot'`
|
| 304 |
-
*/
|
| 305 |
-
authPrefix?: 'Bearer' | 'Bot';
|
| 306 |
-
/**
|
| 307 |
-
* The body to send to this request.
|
| 308 |
-
* If providing as BodyInit, set `passThroughBody: true`
|
| 309 |
-
*/
|
| 310 |
-
body?: BodyInit | unknown;
|
| 311 |
-
/**
|
| 312 |
-
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} to use for the request.
|
| 313 |
-
*/
|
| 314 |
-
dispatcher?: Agent;
|
| 315 |
-
/**
|
| 316 |
-
* Files to be attached to this request
|
| 317 |
-
*/
|
| 318 |
-
files?: RawFile[] | undefined;
|
| 319 |
-
/**
|
| 320 |
-
* Additional headers to add to this request
|
| 321 |
-
*/
|
| 322 |
-
headers?: Record<string, string>;
|
| 323 |
-
/**
|
| 324 |
-
* Whether to pass-through the body property directly to `fetch()`.
|
| 325 |
-
* <warn>This only applies when files is NOT present</warn>
|
| 326 |
-
*/
|
| 327 |
-
passThroughBody?: boolean;
|
| 328 |
-
/**
|
| 329 |
-
* Query string parameters to append to the called endpoint
|
| 330 |
-
*/
|
| 331 |
-
query?: URLSearchParams;
|
| 332 |
-
/**
|
| 333 |
-
* Reason to show in the audit logs
|
| 334 |
-
*/
|
| 335 |
-
reason?: string | undefined;
|
| 336 |
-
/**
|
| 337 |
-
* The signal to abort the queue entry or the REST call, where applicable
|
| 338 |
-
*/
|
| 339 |
-
signal?: AbortSignal | undefined;
|
| 340 |
-
/**
|
| 341 |
-
* If this request should be versioned
|
| 342 |
-
*
|
| 343 |
-
* @defaultValue `true`
|
| 344 |
-
*/
|
| 345 |
-
versioned?: boolean;
|
| 346 |
-
}
|
| 347 |
-
/**
|
| 348 |
-
* Possible headers for an API call
|
| 349 |
-
*/
|
| 350 |
-
interface RequestHeaders {
|
| 351 |
-
Authorization?: string;
|
| 352 |
-
'User-Agent': string;
|
| 353 |
-
'X-Audit-Log-Reason'?: string;
|
| 354 |
-
}
|
| 355 |
-
/**
|
| 356 |
-
* Possible API methods to be used when doing requests
|
| 357 |
-
*/
|
| 358 |
-
declare enum RequestMethod {
|
| 359 |
-
Delete = "DELETE",
|
| 360 |
-
Get = "GET",
|
| 361 |
-
Patch = "PATCH",
|
| 362 |
-
Post = "POST",
|
| 363 |
-
Put = "PUT"
|
| 364 |
-
}
|
| 365 |
-
type RouteLike = `/${string}`;
|
| 366 |
-
/**
|
| 367 |
-
* Internal request options
|
| 368 |
-
*
|
| 369 |
-
* @internal
|
| 370 |
-
*/
|
| 371 |
-
interface InternalRequest extends RequestData {
|
| 372 |
-
fullRoute: RouteLike;
|
| 373 |
-
method: RequestMethod;
|
| 374 |
-
}
|
| 375 |
-
type HandlerRequestData = Pick<InternalRequest, 'auth' | 'body' | 'files' | 'signal'>;
|
| 376 |
-
/**
|
| 377 |
-
* Parsed route data for an endpoint
|
| 378 |
-
*
|
| 379 |
-
* @internal
|
| 380 |
-
*/
|
| 381 |
-
interface RouteData {
|
| 382 |
-
bucketRoute: string;
|
| 383 |
-
majorParameter: string;
|
| 384 |
-
original: RouteLike;
|
| 385 |
-
}
|
| 386 |
-
/**
|
| 387 |
-
* Represents a hash and its associated fields
|
| 388 |
-
*
|
| 389 |
-
* @internal
|
| 390 |
-
*/
|
| 391 |
-
interface HashData {
|
| 392 |
-
lastAccess: number;
|
| 393 |
-
value: string;
|
| 394 |
-
}
|
| 395 |
-
|
| 396 |
-
declare const DefaultUserAgent: `DiscordBot (https://discord.js.org, ${string})`;
|
| 397 |
-
/**
|
| 398 |
-
* The default string to append onto the user agent.
|
| 399 |
-
*/
|
| 400 |
-
declare const DefaultUserAgentAppendix: string;
|
| 401 |
-
declare const DefaultRestOptions: {
|
| 402 |
-
readonly agent: null;
|
| 403 |
-
readonly api: "https://discord.com/api";
|
| 404 |
-
readonly authPrefix: "Bot";
|
| 405 |
-
readonly cdn: "https://cdn.discordapp.com";
|
| 406 |
-
readonly headers: {};
|
| 407 |
-
readonly invalidRequestWarningInterval: 0;
|
| 408 |
-
readonly globalRequestsPerSecond: 50;
|
| 409 |
-
readonly offset: 50;
|
| 410 |
-
readonly rejectOnRateLimit: null;
|
| 411 |
-
readonly retries: 3;
|
| 412 |
-
readonly timeout: 15000;
|
| 413 |
-
readonly userAgentAppendix: string;
|
| 414 |
-
readonly version: "10";
|
| 415 |
-
readonly hashSweepInterval: 14400000;
|
| 416 |
-
readonly hashLifetime: 86400000;
|
| 417 |
-
readonly handlerSweepInterval: 3600000;
|
| 418 |
-
readonly makeRequest: (url: string, init: undici.RequestInit) => Promise<ResponseLike>;
|
| 419 |
-
readonly mediaProxy: "https://media.discordapp.net";
|
| 420 |
-
};
|
| 421 |
-
/**
|
| 422 |
-
* The events that the REST manager emits
|
| 423 |
-
*/
|
| 424 |
-
declare enum RESTEvents {
|
| 425 |
-
Debug = "restDebug",
|
| 426 |
-
HandlerSweep = "handlerSweep",
|
| 427 |
-
HashSweep = "hashSweep",
|
| 428 |
-
InvalidRequestWarning = "invalidRequestWarning",
|
| 429 |
-
RateLimited = "rateLimited",
|
| 430 |
-
Response = "response"
|
| 431 |
-
}
|
| 432 |
-
declare const ALLOWED_EXTENSIONS: readonly ["webp", "png", "jpg", "jpeg", "gif"];
|
| 433 |
-
declare const ALLOWED_STICKER_EXTENSIONS: readonly ["png", "json", "gif"];
|
| 434 |
-
declare const ALLOWED_SIZES: readonly number[];
|
| 435 |
-
type ImageExtension = (typeof ALLOWED_EXTENSIONS)[number];
|
| 436 |
-
type StickerExtension = (typeof ALLOWED_STICKER_EXTENSIONS)[number];
|
| 437 |
-
declare const OverwrittenMimeTypes: {
|
| 438 |
-
readonly 'image/apng': "image/png";
|
| 439 |
-
};
|
| 440 |
-
declare const BurstHandlerMajorIdKey = "burst";
|
| 441 |
-
/**
|
| 442 |
-
* Prefix for deprecation warnings.
|
| 443 |
-
*
|
| 444 |
-
* @internal
|
| 445 |
-
*/
|
| 446 |
-
declare const DEPRECATION_WARNING_PREFIX: "DeprecationWarning";
|
| 447 |
-
|
| 448 |
-
/**
|
| 449 |
-
* The options used for image URLs.
|
| 450 |
-
*/
|
| 451 |
-
interface BaseImageURLOptions {
|
| 452 |
-
/**
|
| 453 |
-
* The extension to use for the image URL.
|
| 454 |
-
*
|
| 455 |
-
* @defaultValue `'webp'`
|
| 456 |
-
*/
|
| 457 |
-
extension?: ImageExtension;
|
| 458 |
-
/**
|
| 459 |
-
* The size specified in the image URL.
|
| 460 |
-
*/
|
| 461 |
-
size?: ImageSize;
|
| 462 |
-
}
|
| 463 |
-
interface EmojiURLOptionsWebp extends BaseImageURLOptions {
|
| 464 |
-
/**
|
| 465 |
-
* Whether to use the `animated` query parameter.
|
| 466 |
-
*/
|
| 467 |
-
animated?: boolean;
|
| 468 |
-
extension?: 'webp';
|
| 469 |
-
}
|
| 470 |
-
interface EmojiURLOptionsNotWebp extends BaseImageURLOptions {
|
| 471 |
-
extension: Exclude<ImageExtension, 'webp'>;
|
| 472 |
-
}
|
| 473 |
-
/**
|
| 474 |
-
* The options used for emoji URLs.
|
| 475 |
-
*/
|
| 476 |
-
type EmojiURLOptions = EmojiURLOptionsNotWebp | EmojiURLOptionsWebp;
|
| 477 |
-
/**
|
| 478 |
-
* The options used for image URLs that may be animated.
|
| 479 |
-
*/
|
| 480 |
-
interface ImageURLOptions extends BaseImageURLOptions {
|
| 481 |
-
/**
|
| 482 |
-
* Whether to prefer the static asset.
|
| 483 |
-
*/
|
| 484 |
-
forceStatic?: boolean;
|
| 485 |
-
}
|
| 486 |
-
/**
|
| 487 |
-
* The options to use when making a CDN URL
|
| 488 |
-
*/
|
| 489 |
-
interface MakeURLOptions {
|
| 490 |
-
/**
|
| 491 |
-
* The allowed extensions that can be used
|
| 492 |
-
*/
|
| 493 |
-
allowedExtensions?: readonly string[];
|
| 494 |
-
/**
|
| 495 |
-
* Whether to use the `animated` query parameter
|
| 496 |
-
*/
|
| 497 |
-
animated?: boolean;
|
| 498 |
-
/**
|
| 499 |
-
* The base URL.
|
| 500 |
-
*
|
| 501 |
-
* @defaultValue `DefaultRestOptions.cdn`
|
| 502 |
-
*/
|
| 503 |
-
base?: string;
|
| 504 |
-
/**
|
| 505 |
-
* The extension to use for the image URL
|
| 506 |
-
*
|
| 507 |
-
* @defaultValue `'webp'`
|
| 508 |
-
*/
|
| 509 |
-
extension?: string | undefined;
|
| 510 |
-
/**
|
| 511 |
-
* The size specified in the image URL
|
| 512 |
-
*/
|
| 513 |
-
size?: ImageSize;
|
| 514 |
-
}
|
| 515 |
-
/**
|
| 516 |
-
* The CDN link builder
|
| 517 |
-
*/
|
| 518 |
-
declare class CDN {
|
| 519 |
-
private readonly cdn;
|
| 520 |
-
private readonly mediaProxy;
|
| 521 |
-
constructor(cdn?: string, mediaProxy?: string);
|
| 522 |
-
/**
|
| 523 |
-
* Generates an app asset URL for a client's asset.
|
| 524 |
-
*
|
| 525 |
-
* @param clientId - The client id that has the asset
|
| 526 |
-
* @param assetHash - The hash provided by Discord for this asset
|
| 527 |
-
* @param options - Optional options for the asset
|
| 528 |
-
*/
|
| 529 |
-
appAsset(clientId: string, assetHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 530 |
-
/**
|
| 531 |
-
* Generates an app icon URL for a client's icon.
|
| 532 |
-
*
|
| 533 |
-
* @param clientId - The client id that has the icon
|
| 534 |
-
* @param iconHash - The hash provided by Discord for this icon
|
| 535 |
-
* @param options - Optional options for the icon
|
| 536 |
-
*/
|
| 537 |
-
appIcon(clientId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 538 |
-
/**
|
| 539 |
-
* Generates an avatar URL, e.g. for a user or a webhook.
|
| 540 |
-
*
|
| 541 |
-
* @param id - The id that has the icon
|
| 542 |
-
* @param avatarHash - The hash provided by Discord for this avatar
|
| 543 |
-
* @param options - Optional options for the avatar
|
| 544 |
-
*/
|
| 545 |
-
avatar(id: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
| 546 |
-
/**
|
| 547 |
-
* Generates a user avatar decoration preset URL.
|
| 548 |
-
*
|
| 549 |
-
* @param asset - The avatar decoration hash
|
| 550 |
-
*/
|
| 551 |
-
avatarDecoration(asset: string): string;
|
| 552 |
-
/**
|
| 553 |
-
* Generates a user avatar decoration URL.
|
| 554 |
-
*
|
| 555 |
-
* @deprecated This overload is deprecated. Pass a hash instead.
|
| 556 |
-
* @param userId - The id of the user
|
| 557 |
-
* @param userAvatarDecoration - The hash provided by Discord for this avatar decoration
|
| 558 |
-
* @param options - Optional options for the avatar decoration
|
| 559 |
-
*/
|
| 560 |
-
avatarDecoration(userId: string, userAvatarDecoration: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 561 |
-
/**
|
| 562 |
-
* Generates a banner URL, e.g. for a user or a guild.
|
| 563 |
-
*
|
| 564 |
-
* @param id - The id that has the banner splash
|
| 565 |
-
* @param bannerHash - The hash provided by Discord for this banner
|
| 566 |
-
* @param options - Optional options for the banner
|
| 567 |
-
*/
|
| 568 |
-
banner(id: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
| 569 |
-
/**
|
| 570 |
-
* Generates an icon URL for a channel, e.g. a group DM.
|
| 571 |
-
*
|
| 572 |
-
* @param channelId - The channel id that has the icon
|
| 573 |
-
* @param iconHash - The hash provided by Discord for this channel
|
| 574 |
-
* @param options - Optional options for the icon
|
| 575 |
-
*/
|
| 576 |
-
channelIcon(channelId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 577 |
-
/**
|
| 578 |
-
* Generates a default avatar URL
|
| 579 |
-
*
|
| 580 |
-
* @param index - The default avatar index
|
| 581 |
-
* @remarks
|
| 582 |
-
* To calculate the index for a user do `(userId >> 22) % 6`,
|
| 583 |
-
* or `discriminator % 5` if they're using the legacy username system.
|
| 584 |
-
*/
|
| 585 |
-
defaultAvatar(index: number): string;
|
| 586 |
-
/**
|
| 587 |
-
* Generates a discovery splash URL for a guild's discovery splash.
|
| 588 |
-
*
|
| 589 |
-
* @param guildId - The guild id that has the discovery splash
|
| 590 |
-
* @param splashHash - The hash provided by Discord for this splash
|
| 591 |
-
* @param options - Optional options for the splash
|
| 592 |
-
*/
|
| 593 |
-
discoverySplash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 594 |
-
/**
|
| 595 |
-
* Generates an emoji's URL for an emoji.
|
| 596 |
-
*
|
| 597 |
-
* @param emojiId - The emoji id
|
| 598 |
-
* @param options - Optional options for the emoji
|
| 599 |
-
*/
|
| 600 |
-
emoji(emojiId: string, options?: Readonly<EmojiURLOptions>): string;
|
| 601 |
-
/**
|
| 602 |
-
* Generates an emoji's URL for an emoji.
|
| 603 |
-
*
|
| 604 |
-
* @param emojiId - The emoji id
|
| 605 |
-
* @param extension - The extension of the emoji
|
| 606 |
-
* @deprecated This overload is deprecated. Pass an object containing the extension instead.
|
| 607 |
-
*/
|
| 608 |
-
emoji(emojiId: string, extension?: ImageExtension): string;
|
| 609 |
-
/**
|
| 610 |
-
* Generates a guild member avatar URL.
|
| 611 |
-
*
|
| 612 |
-
* @param guildId - The id of the guild
|
| 613 |
-
* @param userId - The id of the user
|
| 614 |
-
* @param avatarHash - The hash provided by Discord for this avatar
|
| 615 |
-
* @param options - Optional options for the avatar
|
| 616 |
-
*/
|
| 617 |
-
guildMemberAvatar(guildId: string, userId: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
| 618 |
-
/**
|
| 619 |
-
* Generates a guild member banner URL.
|
| 620 |
-
*
|
| 621 |
-
* @param guildId - The id of the guild
|
| 622 |
-
* @param userId - The id of the user
|
| 623 |
-
* @param bannerHash - The hash provided by Discord for this banner
|
| 624 |
-
* @param options - Optional options for the banner
|
| 625 |
-
*/
|
| 626 |
-
guildMemberBanner(guildId: string, userId: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
| 627 |
-
/**
|
| 628 |
-
* Generates an icon URL, e.g. for a guild.
|
| 629 |
-
*
|
| 630 |
-
* @param id - The id that has the icon splash
|
| 631 |
-
* @param iconHash - The hash provided by Discord for this icon
|
| 632 |
-
* @param options - Optional options for the icon
|
| 633 |
-
*/
|
| 634 |
-
icon(id: string, iconHash: string, options?: Readonly<ImageURLOptions>): string;
|
| 635 |
-
/**
|
| 636 |
-
* Generates a URL for the icon of a role
|
| 637 |
-
*
|
| 638 |
-
* @param roleId - The id of the role that has the icon
|
| 639 |
-
* @param roleIconHash - The hash provided by Discord for this role icon
|
| 640 |
-
* @param options - Optional options for the role icon
|
| 641 |
-
*/
|
| 642 |
-
roleIcon(roleId: string, roleIconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 643 |
-
/**
|
| 644 |
-
* Generates a guild invite splash URL for a guild's invite splash.
|
| 645 |
-
*
|
| 646 |
-
* @param guildId - The guild id that has the invite splash
|
| 647 |
-
* @param splashHash - The hash provided by Discord for this splash
|
| 648 |
-
* @param options - Optional options for the splash
|
| 649 |
-
*/
|
| 650 |
-
splash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 651 |
-
/**
|
| 652 |
-
* Generates a sticker URL.
|
| 653 |
-
*
|
| 654 |
-
* @param stickerId - The sticker id
|
| 655 |
-
* @param extension - The extension of the sticker
|
| 656 |
-
* @privateRemarks
|
| 657 |
-
* Stickers cannot have a `.webp` extension, so we default to a `.png`.
|
| 658 |
-
* Sticker GIFs do not use the CDN base URL.
|
| 659 |
-
*/
|
| 660 |
-
sticker(stickerId: string, extension?: StickerExtension): string;
|
| 661 |
-
/**
|
| 662 |
-
* Generates a sticker pack banner URL.
|
| 663 |
-
*
|
| 664 |
-
* @param bannerId - The banner id
|
| 665 |
-
* @param options - Optional options for the banner
|
| 666 |
-
*/
|
| 667 |
-
stickerPackBanner(bannerId: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 668 |
-
/**
|
| 669 |
-
* Generates a team icon URL for a team's icon.
|
| 670 |
-
*
|
| 671 |
-
* @param teamId - The team id that has the icon
|
| 672 |
-
* @param iconHash - The hash provided by Discord for this icon
|
| 673 |
-
* @param options - Optional options for the icon
|
| 674 |
-
*/
|
| 675 |
-
teamIcon(teamId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 676 |
-
/**
|
| 677 |
-
* Generates a cover image for a guild scheduled event.
|
| 678 |
-
*
|
| 679 |
-
* @param scheduledEventId - The scheduled event id
|
| 680 |
-
* @param coverHash - The hash provided by discord for this cover image
|
| 681 |
-
* @param options - Optional options for the cover image
|
| 682 |
-
*/
|
| 683 |
-
guildScheduledEventCover(scheduledEventId: string, coverHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 684 |
-
/**
|
| 685 |
-
* Generates a URL for a soundboard sound.
|
| 686 |
-
*
|
| 687 |
-
* @param soundId - The soundboard sound id
|
| 688 |
-
*/
|
| 689 |
-
soundboardSound(soundId: string): string;
|
| 690 |
-
/**
|
| 691 |
-
* Generates a URL for a guild tag badge.
|
| 692 |
-
*
|
| 693 |
-
* @param guildId - The guild id
|
| 694 |
-
* @param badgeHash - The hash of the badge
|
| 695 |
-
* @param options - Optional options for the badge
|
| 696 |
-
*/
|
| 697 |
-
guildTagBadge(guildId: string, badgeHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 698 |
-
/**
|
| 699 |
-
* Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
|
| 700 |
-
*
|
| 701 |
-
* @param route - The base cdn route
|
| 702 |
-
* @param hash - The hash provided by Discord for this icon
|
| 703 |
-
* @param options - Optional options for the link
|
| 704 |
-
*/
|
| 705 |
-
private dynamicMakeURL;
|
| 706 |
-
/**
|
| 707 |
-
* Constructs the URL for the resource
|
| 708 |
-
*
|
| 709 |
-
* @param route - The base cdn route
|
| 710 |
-
* @param options - The extension/size options for the link
|
| 711 |
-
*/
|
| 712 |
-
private makeURL;
|
| 713 |
-
}
|
| 714 |
-
|
| 715 |
-
interface DiscordErrorFieldInformation {
|
| 716 |
-
code: string;
|
| 717 |
-
message: string;
|
| 718 |
-
}
|
| 719 |
-
interface DiscordErrorGroupWrapper {
|
| 720 |
-
_errors: DiscordError[];
|
| 721 |
-
}
|
| 722 |
-
type DiscordError = DiscordErrorFieldInformation | DiscordErrorGroupWrapper | string | {
|
| 723 |
-
[k: string]: DiscordError;
|
| 724 |
-
};
|
| 725 |
-
interface DiscordErrorData {
|
| 726 |
-
code: number;
|
| 727 |
-
errors?: DiscordError;
|
| 728 |
-
message: string;
|
| 729 |
-
}
|
| 730 |
-
interface OAuthErrorData {
|
| 731 |
-
error: string;
|
| 732 |
-
error_description?: string;
|
| 733 |
-
}
|
| 734 |
-
interface RequestBody {
|
| 735 |
-
files: RawFile[] | undefined;
|
| 736 |
-
json: unknown | undefined;
|
| 737 |
-
}
|
| 738 |
-
/**
|
| 739 |
-
* Represents an API error returned by Discord
|
| 740 |
-
*/
|
| 741 |
-
declare class DiscordAPIError extends Error {
|
| 742 |
-
rawError: DiscordErrorData | OAuthErrorData;
|
| 743 |
-
code: number | string;
|
| 744 |
-
status: number;
|
| 745 |
-
method: string;
|
| 746 |
-
url: string;
|
| 747 |
-
requestBody: RequestBody;
|
| 748 |
-
/**
|
| 749 |
-
* @param rawError - The error reported by Discord
|
| 750 |
-
* @param code - The error code reported by Discord
|
| 751 |
-
* @param status - The status code of the response
|
| 752 |
-
* @param method - The method of the request that erred
|
| 753 |
-
* @param url - The url of the request that erred
|
| 754 |
-
* @param bodyData - The unparsed data for the request that errored
|
| 755 |
-
*/
|
| 756 |
-
constructor(rawError: DiscordErrorData | OAuthErrorData, code: number | string, status: number, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
|
| 757 |
-
/**
|
| 758 |
-
* The name of the error
|
| 759 |
-
*/
|
| 760 |
-
get name(): string;
|
| 761 |
-
private static getMessage;
|
| 762 |
-
private static flattenDiscordError;
|
| 763 |
-
}
|
| 764 |
-
|
| 765 |
-
/**
|
| 766 |
-
* Represents a HTTP error
|
| 767 |
-
*/
|
| 768 |
-
declare class HTTPError extends Error {
|
| 769 |
-
status: number;
|
| 770 |
-
method: string;
|
| 771 |
-
url: string;
|
| 772 |
-
requestBody: RequestBody;
|
| 773 |
-
name: string;
|
| 774 |
-
/**
|
| 775 |
-
* @param status - The status code of the response
|
| 776 |
-
* @param statusText - The status text of the response
|
| 777 |
-
* @param method - The method of the request that erred
|
| 778 |
-
* @param url - The url of the request that erred
|
| 779 |
-
* @param bodyData - The unparsed data for the request that errored
|
| 780 |
-
*/
|
| 781 |
-
constructor(status: number, statusText: string, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
|
| 782 |
-
}
|
| 783 |
-
|
| 784 |
-
declare class RateLimitError extends Error implements RateLimitData {
|
| 785 |
-
timeToReset: number;
|
| 786 |
-
limit: number;
|
| 787 |
-
method: string;
|
| 788 |
-
hash: string;
|
| 789 |
-
url: string;
|
| 790 |
-
route: string;
|
| 791 |
-
majorParameter: string;
|
| 792 |
-
global: boolean;
|
| 793 |
-
retryAfter: number;
|
| 794 |
-
sublimitTimeout: number;
|
| 795 |
-
scope: RateLimitData['scope'];
|
| 796 |
-
constructor({ timeToReset, limit, method, hash, url, route, majorParameter, global, retryAfter, sublimitTimeout, scope, }: RateLimitData);
|
| 797 |
-
/**
|
| 798 |
-
* The name of the error
|
| 799 |
-
*/
|
| 800 |
-
get name(): string;
|
| 801 |
-
}
|
| 802 |
-
|
| 803 |
-
/**
|
| 804 |
-
* Represents the class that manages handlers for endpoints
|
| 805 |
-
*/
|
| 806 |
-
declare class REST extends AsyncEventEmitter<RestEvents> {
|
| 807 |
-
#private;
|
| 808 |
-
/**
|
| 809 |
-
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} for all requests
|
| 810 |
-
* performed by this manager.
|
| 811 |
-
*/
|
| 812 |
-
agent: Dispatcher | null;
|
| 813 |
-
readonly cdn: CDN;
|
| 814 |
-
/**
|
| 815 |
-
* The number of requests remaining in the global bucket
|
| 816 |
-
*/
|
| 817 |
-
globalRemaining: number;
|
| 818 |
-
/**
|
| 819 |
-
* The promise used to wait out the global rate limit
|
| 820 |
-
*/
|
| 821 |
-
globalDelay: Promise<void> | null;
|
| 822 |
-
/**
|
| 823 |
-
* The timestamp at which the global bucket resets
|
| 824 |
-
*/
|
| 825 |
-
globalReset: number;
|
| 826 |
-
/**
|
| 827 |
-
* API bucket hashes that are cached from provided routes
|
| 828 |
-
*/
|
| 829 |
-
readonly hashes: Collection<string, HashData>;
|
| 830 |
-
/**
|
| 831 |
-
* Request handlers created from the bucket hash and the major parameters
|
| 832 |
-
*/
|
| 833 |
-
readonly handlers: Collection<string, IHandler>;
|
| 834 |
-
private hashTimer;
|
| 835 |
-
private handlerTimer;
|
| 836 |
-
readonly options: RESTOptions;
|
| 837 |
-
constructor(options?: Partial<RESTOptions>);
|
| 838 |
-
private setupSweepers;
|
| 839 |
-
/**
|
| 840 |
-
* Runs a get request from the api
|
| 841 |
-
*
|
| 842 |
-
* @param fullRoute - The full route to query
|
| 843 |
-
* @param options - Optional request options
|
| 844 |
-
*/
|
| 845 |
-
get(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
| 846 |
-
/**
|
| 847 |
-
* Runs a delete request from the api
|
| 848 |
-
*
|
| 849 |
-
* @param fullRoute - The full route to query
|
| 850 |
-
* @param options - Optional request options
|
| 851 |
-
*/
|
| 852 |
-
delete(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
| 853 |
-
/**
|
| 854 |
-
* Runs a post request from the api
|
| 855 |
-
*
|
| 856 |
-
* @param fullRoute - The full route to query
|
| 857 |
-
* @param options - Optional request options
|
| 858 |
-
*/
|
| 859 |
-
post(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
| 860 |
-
/**
|
| 861 |
-
* Runs a put request from the api
|
| 862 |
-
*
|
| 863 |
-
* @param fullRoute - The full route to query
|
| 864 |
-
* @param options - Optional request options
|
| 865 |
-
*/
|
| 866 |
-
put(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
| 867 |
-
/**
|
| 868 |
-
* Runs a patch request from the api
|
| 869 |
-
*
|
| 870 |
-
* @param fullRoute - The full route to query
|
| 871 |
-
* @param options - Optional request options
|
| 872 |
-
*/
|
| 873 |
-
patch(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
| 874 |
-
/**
|
| 875 |
-
* Runs a request from the api
|
| 876 |
-
*
|
| 877 |
-
* @param options - Request options
|
| 878 |
-
*/
|
| 879 |
-
request(options: InternalRequest): Promise<unknown>;
|
| 880 |
-
/**
|
| 881 |
-
* Sets the default agent to use for requests performed by this manager
|
| 882 |
-
*
|
| 883 |
-
* @param agent - The agent to use
|
| 884 |
-
*/
|
| 885 |
-
setAgent(agent: Dispatcher): this;
|
| 886 |
-
/**
|
| 887 |
-
* Sets the authorization token that should be used for requests
|
| 888 |
-
*
|
| 889 |
-
* @param token - The authorization token to use
|
| 890 |
-
*/
|
| 891 |
-
setToken(token: string): this;
|
| 892 |
-
/**
|
| 893 |
-
* Queues a request to be sent
|
| 894 |
-
*
|
| 895 |
-
* @param request - All the information needed to make a request
|
| 896 |
-
* @returns The response from the api request
|
| 897 |
-
*/
|
| 898 |
-
queueRequest(request: InternalRequest): Promise<ResponseLike>;
|
| 899 |
-
/**
|
| 900 |
-
* Creates a new rate limit handler from a hash, based on the hash and the major parameter
|
| 901 |
-
*
|
| 902 |
-
* @param hash - The hash for the route
|
| 903 |
-
* @param majorParameter - The major parameter for this handler
|
| 904 |
-
* @internal
|
| 905 |
-
*/
|
| 906 |
-
private createHandler;
|
| 907 |
-
/**
|
| 908 |
-
* Formats the request data to a usable format for fetch
|
| 909 |
-
*
|
| 910 |
-
* @param request - The request data
|
| 911 |
-
*/
|
| 912 |
-
private resolveRequest;
|
| 913 |
-
/**
|
| 914 |
-
* Stops the hash sweeping interval
|
| 915 |
-
*/
|
| 916 |
-
clearHashSweeper(): void;
|
| 917 |
-
/**
|
| 918 |
-
* Stops the request handler sweeping interval
|
| 919 |
-
*/
|
| 920 |
-
clearHandlerSweeper(): void;
|
| 921 |
-
/**
|
| 922 |
-
* Generates route data for an endpoint:method
|
| 923 |
-
*
|
| 924 |
-
* @param endpoint - The raw endpoint to generalize
|
| 925 |
-
* @param method - The HTTP method this endpoint is called without
|
| 926 |
-
* @internal
|
| 927 |
-
*/
|
| 928 |
-
private static generateRouteData;
|
| 929 |
-
}
|
| 930 |
-
|
| 931 |
-
/**
|
| 932 |
-
* Creates and populates an URLSearchParams instance from an object, stripping
|
| 933 |
-
* out null and undefined values, while also coercing non-strings to strings.
|
| 934 |
-
*
|
| 935 |
-
* @param options - The options to use
|
| 936 |
-
* @returns A populated URLSearchParams instance
|
| 937 |
-
*/
|
| 938 |
-
declare function makeURLSearchParams<OptionsType extends object>(options?: Readonly<OptionsType>): url.URLSearchParams;
|
| 939 |
-
/**
|
| 940 |
-
* Converts the response to usable data
|
| 941 |
-
*
|
| 942 |
-
* @param res - The fetch response
|
| 943 |
-
*/
|
| 944 |
-
declare function parseResponse(res: ResponseLike): Promise<unknown>;
|
| 945 |
-
/**
|
| 946 |
-
* Calculates the default avatar index for a given user id.
|
| 947 |
-
*
|
| 948 |
-
* @param userId - The user id to calculate the default avatar index for
|
| 949 |
-
*/
|
| 950 |
-
declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
|
| 951 |
-
|
| 952 |
-
/**
|
| 953 |
-
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/rest#readme | @discordjs/rest} version
|
| 954 |
-
* that you are currently using.
|
| 955 |
-
*/
|
| 956 |
-
declare const version: string;
|
| 957 |
-
|
| 958 |
-
export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, DEPRECATION_WARNING_PREFIX, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordErrorData, type EmojiURLOptions, type EmojiURLOptionsNotWebp, type EmojiURLOptionsWebp, type GetRateLimitOffsetFunction, HTTPError, type HandlerRequestData, type HashData, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type MakeURLOptions, type OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, type RESTOptions, type RateLimitData, RateLimitError, type RateLimitQueueFilter, type RawFile, type RequestBody, type RequestData, type RequestHeaders, RequestMethod, type ResponseLike, type RestEvents, type RestEventsMap, type RouteData, type RouteLike, type StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/rest/dist/index.d.ts
DELETED
|
@@ -1,958 +0,0 @@
|
|
| 1 |
-
import * as url from 'url';
|
| 2 |
-
import { ImageSize, Snowflake } from 'discord-api-types/v10';
|
| 3 |
-
export { ImageSize } from 'discord-api-types/v10';
|
| 4 |
-
import { Readable } from 'node:stream';
|
| 5 |
-
import { ReadableStream } from 'node:stream/web';
|
| 6 |
-
import { Collection } from '@discordjs/collection';
|
| 7 |
-
import { Awaitable } from '@discordjs/util';
|
| 8 |
-
import * as undici from 'undici';
|
| 9 |
-
import { RequestInit, Dispatcher, Response, BodyInit, Agent } from 'undici';
|
| 10 |
-
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
| 11 |
-
|
| 12 |
-
interface IHandler {
|
| 13 |
-
/**
|
| 14 |
-
* The unique id of the handler
|
| 15 |
-
*/
|
| 16 |
-
readonly id: string;
|
| 17 |
-
/**
|
| 18 |
-
* If the bucket is currently inactive (no pending requests)
|
| 19 |
-
*/
|
| 20 |
-
get inactive(): boolean;
|
| 21 |
-
/**
|
| 22 |
-
* Queues a request to be sent
|
| 23 |
-
*
|
| 24 |
-
* @param routeId - The generalized api route with literal ids for major parameters
|
| 25 |
-
* @param url - The url to do the request on
|
| 26 |
-
* @param options - All the information needed to make a request
|
| 27 |
-
* @param requestData - Extra data from the user's request needed for errors and additional processing
|
| 28 |
-
*/
|
| 29 |
-
queueRequest(routeId: RouteData, url: string, options: RequestInit, requestData: HandlerRequestData): Promise<ResponseLike>;
|
| 30 |
-
}
|
| 31 |
-
|
| 32 |
-
interface RestEvents {
|
| 33 |
-
handlerSweep: [sweptHandlers: Collection<string, IHandler>];
|
| 34 |
-
hashSweep: [sweptHashes: Collection<string, HashData>];
|
| 35 |
-
invalidRequestWarning: [invalidRequestInfo: InvalidRequestWarningData];
|
| 36 |
-
rateLimited: [rateLimitInfo: RateLimitData];
|
| 37 |
-
response: [request: APIRequest, response: ResponseLike];
|
| 38 |
-
restDebug: [info: string];
|
| 39 |
-
}
|
| 40 |
-
interface RestEventsMap extends RestEvents {
|
| 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 media proxy path
|
| 113 |
-
*
|
| 114 |
-
* @defaultValue `'https://media.discordapp.net'`
|
| 115 |
-
*/
|
| 116 |
-
mediaProxy: string;
|
| 117 |
-
/**
|
| 118 |
-
* The extra offset to add to rate limits in milliseconds
|
| 119 |
-
*
|
| 120 |
-
* @defaultValue `50`
|
| 121 |
-
*/
|
| 122 |
-
offset: GetRateLimitOffsetFunction | number;
|
| 123 |
-
/**
|
| 124 |
-
* Determines how rate limiting and pre-emptive throttling should be handled.
|
| 125 |
-
* When an array of strings, each element is treated as a prefix for the request route
|
| 126 |
-
* (e.g. `/channels` to match any route starting with `/channels` such as `/channels/:id/messages`)
|
| 127 |
-
* for which to throw {@link RateLimitError}s. All other request routes will be queued normally
|
| 128 |
-
*
|
| 129 |
-
* @defaultValue `null`
|
| 130 |
-
*/
|
| 131 |
-
rejectOnRateLimit: RateLimitQueueFilter | string[] | null;
|
| 132 |
-
/**
|
| 133 |
-
* The number of retries for errors with the 500 code, or errors
|
| 134 |
-
* that timeout
|
| 135 |
-
*
|
| 136 |
-
* @defaultValue `3`
|
| 137 |
-
*/
|
| 138 |
-
retries: number;
|
| 139 |
-
/**
|
| 140 |
-
* The time to wait in milliseconds before a request is aborted
|
| 141 |
-
*
|
| 142 |
-
* @defaultValue `15_000`
|
| 143 |
-
*/
|
| 144 |
-
timeout: number;
|
| 145 |
-
/**
|
| 146 |
-
* Extra information to add to the user agent
|
| 147 |
-
*
|
| 148 |
-
* @defaultValue DefaultUserAgentAppendix
|
| 149 |
-
*/
|
| 150 |
-
userAgentAppendix: string;
|
| 151 |
-
/**
|
| 152 |
-
* The version of the API to use
|
| 153 |
-
*
|
| 154 |
-
* @defaultValue `'10'`
|
| 155 |
-
*/
|
| 156 |
-
version: string;
|
| 157 |
-
}
|
| 158 |
-
/**
|
| 159 |
-
* Data emitted on `RESTEvents.RateLimited`
|
| 160 |
-
*/
|
| 161 |
-
interface RateLimitData {
|
| 162 |
-
/**
|
| 163 |
-
* Whether the rate limit that was reached was the global limit
|
| 164 |
-
*/
|
| 165 |
-
global: boolean;
|
| 166 |
-
/**
|
| 167 |
-
* The bucket hash for this request
|
| 168 |
-
*/
|
| 169 |
-
hash: string;
|
| 170 |
-
/**
|
| 171 |
-
* The amount of requests we can perform before locking requests
|
| 172 |
-
*/
|
| 173 |
-
limit: number;
|
| 174 |
-
/**
|
| 175 |
-
* The major parameter of the route
|
| 176 |
-
*
|
| 177 |
-
* For example, in `/channels/x`, this will be `x`.
|
| 178 |
-
* If there is no major parameter (e.g: `/bot/gateway`) this will be `global`.
|
| 179 |
-
*/
|
| 180 |
-
majorParameter: string;
|
| 181 |
-
/**
|
| 182 |
-
* The HTTP method being performed
|
| 183 |
-
*/
|
| 184 |
-
method: string;
|
| 185 |
-
/**
|
| 186 |
-
* The time, in milliseconds, that will need to pass before this specific request can be retried
|
| 187 |
-
*/
|
| 188 |
-
retryAfter: number;
|
| 189 |
-
/**
|
| 190 |
-
* The route being hit in this request
|
| 191 |
-
*/
|
| 192 |
-
route: string;
|
| 193 |
-
/**
|
| 194 |
-
* The scope of the rate limit that was hit.
|
| 195 |
-
*
|
| 196 |
-
* 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
|
| 197 |
-
* are shared per resource.
|
| 198 |
-
*/
|
| 199 |
-
scope: 'global' | 'shared' | 'user';
|
| 200 |
-
/**
|
| 201 |
-
* The time, in milliseconds, that will need to pass before the sublimit lock for the route resets, and requests that fall under a sublimit
|
| 202 |
-
* can be retried
|
| 203 |
-
*
|
| 204 |
-
* This is only present on certain sublimits, and `0` otherwise
|
| 205 |
-
*/
|
| 206 |
-
sublimitTimeout: number;
|
| 207 |
-
/**
|
| 208 |
-
* The time, in milliseconds, until the route's request-lock is reset
|
| 209 |
-
*/
|
| 210 |
-
timeToReset: number;
|
| 211 |
-
/**
|
| 212 |
-
* The full URL for this request
|
| 213 |
-
*/
|
| 214 |
-
url: string;
|
| 215 |
-
}
|
| 216 |
-
/**
|
| 217 |
-
* A function that determines whether the rate limit hit should throw an Error
|
| 218 |
-
*/
|
| 219 |
-
type RateLimitQueueFilter = (rateLimitData: RateLimitData) => Awaitable<boolean>;
|
| 220 |
-
/**
|
| 221 |
-
* A function that determines the rate limit offset for a given request.
|
| 222 |
-
*/
|
| 223 |
-
type GetRateLimitOffsetFunction = (route: string) => number;
|
| 224 |
-
interface APIRequest {
|
| 225 |
-
/**
|
| 226 |
-
* The data that was used to form the body of this request
|
| 227 |
-
*/
|
| 228 |
-
data: HandlerRequestData;
|
| 229 |
-
/**
|
| 230 |
-
* The HTTP method used in this request
|
| 231 |
-
*/
|
| 232 |
-
method: string;
|
| 233 |
-
/**
|
| 234 |
-
* Additional HTTP options for this request
|
| 235 |
-
*/
|
| 236 |
-
options: RequestInit;
|
| 237 |
-
/**
|
| 238 |
-
* The full path used to make the request
|
| 239 |
-
*/
|
| 240 |
-
path: RouteLike;
|
| 241 |
-
/**
|
| 242 |
-
* The number of times this request has been attempted
|
| 243 |
-
*/
|
| 244 |
-
retries: number;
|
| 245 |
-
/**
|
| 246 |
-
* The API route identifying the ratelimit for this request
|
| 247 |
-
*/
|
| 248 |
-
route: string;
|
| 249 |
-
}
|
| 250 |
-
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | 'headers' | 'json' | 'ok' | 'status' | 'statusText' | 'text'> {
|
| 251 |
-
body: Readable | ReadableStream | null;
|
| 252 |
-
}
|
| 253 |
-
interface InvalidRequestWarningData {
|
| 254 |
-
/**
|
| 255 |
-
* Number of invalid requests that have been made in the window
|
| 256 |
-
*/
|
| 257 |
-
count: number;
|
| 258 |
-
/**
|
| 259 |
-
* Time in milliseconds remaining before the count resets
|
| 260 |
-
*/
|
| 261 |
-
remainingTime: number;
|
| 262 |
-
}
|
| 263 |
-
/**
|
| 264 |
-
* Represents a file to be added to the request
|
| 265 |
-
*/
|
| 266 |
-
interface RawFile {
|
| 267 |
-
/**
|
| 268 |
-
* Content-Type of the file
|
| 269 |
-
*/
|
| 270 |
-
contentType?: string;
|
| 271 |
-
/**
|
| 272 |
-
* The actual data for the file
|
| 273 |
-
*/
|
| 274 |
-
data: Buffer | Uint8Array | boolean | number | string;
|
| 275 |
-
/**
|
| 276 |
-
* An explicit key to use for key of the formdata field for this file.
|
| 277 |
-
* When not provided, the index of the file in the files array is used in the form `files[${index}]`.
|
| 278 |
-
* If you wish to alter the placeholder snowflake, you must provide this property in the same form (`files[${placeholder}]`)
|
| 279 |
-
*/
|
| 280 |
-
key?: string;
|
| 281 |
-
/**
|
| 282 |
-
* The name of the file
|
| 283 |
-
*/
|
| 284 |
-
name: string;
|
| 285 |
-
}
|
| 286 |
-
/**
|
| 287 |
-
* Represents possible data to be given to an endpoint
|
| 288 |
-
*/
|
| 289 |
-
interface RequestData {
|
| 290 |
-
/**
|
| 291 |
-
* Whether to append JSON data to form data instead of `payload_json` when sending files
|
| 292 |
-
*/
|
| 293 |
-
appendToFormData?: boolean;
|
| 294 |
-
/**
|
| 295 |
-
* If this request needs the `Authorization` header
|
| 296 |
-
*
|
| 297 |
-
* @defaultValue `true`
|
| 298 |
-
*/
|
| 299 |
-
auth?: boolean;
|
| 300 |
-
/**
|
| 301 |
-
* The authorization prefix to use for this request, useful if you use this with bearer tokens
|
| 302 |
-
*
|
| 303 |
-
* @defaultValue `'Bot'`
|
| 304 |
-
*/
|
| 305 |
-
authPrefix?: 'Bearer' | 'Bot';
|
| 306 |
-
/**
|
| 307 |
-
* The body to send to this request.
|
| 308 |
-
* If providing as BodyInit, set `passThroughBody: true`
|
| 309 |
-
*/
|
| 310 |
-
body?: BodyInit | unknown;
|
| 311 |
-
/**
|
| 312 |
-
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} to use for the request.
|
| 313 |
-
*/
|
| 314 |
-
dispatcher?: Agent;
|
| 315 |
-
/**
|
| 316 |
-
* Files to be attached to this request
|
| 317 |
-
*/
|
| 318 |
-
files?: RawFile[] | undefined;
|
| 319 |
-
/**
|
| 320 |
-
* Additional headers to add to this request
|
| 321 |
-
*/
|
| 322 |
-
headers?: Record<string, string>;
|
| 323 |
-
/**
|
| 324 |
-
* Whether to pass-through the body property directly to `fetch()`.
|
| 325 |
-
* <warn>This only applies when files is NOT present</warn>
|
| 326 |
-
*/
|
| 327 |
-
passThroughBody?: boolean;
|
| 328 |
-
/**
|
| 329 |
-
* Query string parameters to append to the called endpoint
|
| 330 |
-
*/
|
| 331 |
-
query?: URLSearchParams;
|
| 332 |
-
/**
|
| 333 |
-
* Reason to show in the audit logs
|
| 334 |
-
*/
|
| 335 |
-
reason?: string | undefined;
|
| 336 |
-
/**
|
| 337 |
-
* The signal to abort the queue entry or the REST call, where applicable
|
| 338 |
-
*/
|
| 339 |
-
signal?: AbortSignal | undefined;
|
| 340 |
-
/**
|
| 341 |
-
* If this request should be versioned
|
| 342 |
-
*
|
| 343 |
-
* @defaultValue `true`
|
| 344 |
-
*/
|
| 345 |
-
versioned?: boolean;
|
| 346 |
-
}
|
| 347 |
-
/**
|
| 348 |
-
* Possible headers for an API call
|
| 349 |
-
*/
|
| 350 |
-
interface RequestHeaders {
|
| 351 |
-
Authorization?: string;
|
| 352 |
-
'User-Agent': string;
|
| 353 |
-
'X-Audit-Log-Reason'?: string;
|
| 354 |
-
}
|
| 355 |
-
/**
|
| 356 |
-
* Possible API methods to be used when doing requests
|
| 357 |
-
*/
|
| 358 |
-
declare enum RequestMethod {
|
| 359 |
-
Delete = "DELETE",
|
| 360 |
-
Get = "GET",
|
| 361 |
-
Patch = "PATCH",
|
| 362 |
-
Post = "POST",
|
| 363 |
-
Put = "PUT"
|
| 364 |
-
}
|
| 365 |
-
type RouteLike = `/${string}`;
|
| 366 |
-
/**
|
| 367 |
-
* Internal request options
|
| 368 |
-
*
|
| 369 |
-
* @internal
|
| 370 |
-
*/
|
| 371 |
-
interface InternalRequest extends RequestData {
|
| 372 |
-
fullRoute: RouteLike;
|
| 373 |
-
method: RequestMethod;
|
| 374 |
-
}
|
| 375 |
-
type HandlerRequestData = Pick<InternalRequest, 'auth' | 'body' | 'files' | 'signal'>;
|
| 376 |
-
/**
|
| 377 |
-
* Parsed route data for an endpoint
|
| 378 |
-
*
|
| 379 |
-
* @internal
|
| 380 |
-
*/
|
| 381 |
-
interface RouteData {
|
| 382 |
-
bucketRoute: string;
|
| 383 |
-
majorParameter: string;
|
| 384 |
-
original: RouteLike;
|
| 385 |
-
}
|
| 386 |
-
/**
|
| 387 |
-
* Represents a hash and its associated fields
|
| 388 |
-
*
|
| 389 |
-
* @internal
|
| 390 |
-
*/
|
| 391 |
-
interface HashData {
|
| 392 |
-
lastAccess: number;
|
| 393 |
-
value: string;
|
| 394 |
-
}
|
| 395 |
-
|
| 396 |
-
declare const DefaultUserAgent: `DiscordBot (https://discord.js.org, ${string})`;
|
| 397 |
-
/**
|
| 398 |
-
* The default string to append onto the user agent.
|
| 399 |
-
*/
|
| 400 |
-
declare const DefaultUserAgentAppendix: string;
|
| 401 |
-
declare const DefaultRestOptions: {
|
| 402 |
-
readonly agent: null;
|
| 403 |
-
readonly api: "https://discord.com/api";
|
| 404 |
-
readonly authPrefix: "Bot";
|
| 405 |
-
readonly cdn: "https://cdn.discordapp.com";
|
| 406 |
-
readonly headers: {};
|
| 407 |
-
readonly invalidRequestWarningInterval: 0;
|
| 408 |
-
readonly globalRequestsPerSecond: 50;
|
| 409 |
-
readonly offset: 50;
|
| 410 |
-
readonly rejectOnRateLimit: null;
|
| 411 |
-
readonly retries: 3;
|
| 412 |
-
readonly timeout: 15000;
|
| 413 |
-
readonly userAgentAppendix: string;
|
| 414 |
-
readonly version: "10";
|
| 415 |
-
readonly hashSweepInterval: 14400000;
|
| 416 |
-
readonly hashLifetime: 86400000;
|
| 417 |
-
readonly handlerSweepInterval: 3600000;
|
| 418 |
-
readonly makeRequest: (url: string, init: undici.RequestInit) => Promise<ResponseLike>;
|
| 419 |
-
readonly mediaProxy: "https://media.discordapp.net";
|
| 420 |
-
};
|
| 421 |
-
/**
|
| 422 |
-
* The events that the REST manager emits
|
| 423 |
-
*/
|
| 424 |
-
declare enum RESTEvents {
|
| 425 |
-
Debug = "restDebug",
|
| 426 |
-
HandlerSweep = "handlerSweep",
|
| 427 |
-
HashSweep = "hashSweep",
|
| 428 |
-
InvalidRequestWarning = "invalidRequestWarning",
|
| 429 |
-
RateLimited = "rateLimited",
|
| 430 |
-
Response = "response"
|
| 431 |
-
}
|
| 432 |
-
declare const ALLOWED_EXTENSIONS: readonly ["webp", "png", "jpg", "jpeg", "gif"];
|
| 433 |
-
declare const ALLOWED_STICKER_EXTENSIONS: readonly ["png", "json", "gif"];
|
| 434 |
-
declare const ALLOWED_SIZES: readonly number[];
|
| 435 |
-
type ImageExtension = (typeof ALLOWED_EXTENSIONS)[number];
|
| 436 |
-
type StickerExtension = (typeof ALLOWED_STICKER_EXTENSIONS)[number];
|
| 437 |
-
declare const OverwrittenMimeTypes: {
|
| 438 |
-
readonly 'image/apng': "image/png";
|
| 439 |
-
};
|
| 440 |
-
declare const BurstHandlerMajorIdKey = "burst";
|
| 441 |
-
/**
|
| 442 |
-
* Prefix for deprecation warnings.
|
| 443 |
-
*
|
| 444 |
-
* @internal
|
| 445 |
-
*/
|
| 446 |
-
declare const DEPRECATION_WARNING_PREFIX: "DeprecationWarning";
|
| 447 |
-
|
| 448 |
-
/**
|
| 449 |
-
* The options used for image URLs.
|
| 450 |
-
*/
|
| 451 |
-
interface BaseImageURLOptions {
|
| 452 |
-
/**
|
| 453 |
-
* The extension to use for the image URL.
|
| 454 |
-
*
|
| 455 |
-
* @defaultValue `'webp'`
|
| 456 |
-
*/
|
| 457 |
-
extension?: ImageExtension;
|
| 458 |
-
/**
|
| 459 |
-
* The size specified in the image URL.
|
| 460 |
-
*/
|
| 461 |
-
size?: ImageSize;
|
| 462 |
-
}
|
| 463 |
-
interface EmojiURLOptionsWebp extends BaseImageURLOptions {
|
| 464 |
-
/**
|
| 465 |
-
* Whether to use the `animated` query parameter.
|
| 466 |
-
*/
|
| 467 |
-
animated?: boolean;
|
| 468 |
-
extension?: 'webp';
|
| 469 |
-
}
|
| 470 |
-
interface EmojiURLOptionsNotWebp extends BaseImageURLOptions {
|
| 471 |
-
extension: Exclude<ImageExtension, 'webp'>;
|
| 472 |
-
}
|
| 473 |
-
/**
|
| 474 |
-
* The options used for emoji URLs.
|
| 475 |
-
*/
|
| 476 |
-
type EmojiURLOptions = EmojiURLOptionsNotWebp | EmojiURLOptionsWebp;
|
| 477 |
-
/**
|
| 478 |
-
* The options used for image URLs that may be animated.
|
| 479 |
-
*/
|
| 480 |
-
interface ImageURLOptions extends BaseImageURLOptions {
|
| 481 |
-
/**
|
| 482 |
-
* Whether to prefer the static asset.
|
| 483 |
-
*/
|
| 484 |
-
forceStatic?: boolean;
|
| 485 |
-
}
|
| 486 |
-
/**
|
| 487 |
-
* The options to use when making a CDN URL
|
| 488 |
-
*/
|
| 489 |
-
interface MakeURLOptions {
|
| 490 |
-
/**
|
| 491 |
-
* The allowed extensions that can be used
|
| 492 |
-
*/
|
| 493 |
-
allowedExtensions?: readonly string[];
|
| 494 |
-
/**
|
| 495 |
-
* Whether to use the `animated` query parameter
|
| 496 |
-
*/
|
| 497 |
-
animated?: boolean;
|
| 498 |
-
/**
|
| 499 |
-
* The base URL.
|
| 500 |
-
*
|
| 501 |
-
* @defaultValue `DefaultRestOptions.cdn`
|
| 502 |
-
*/
|
| 503 |
-
base?: string;
|
| 504 |
-
/**
|
| 505 |
-
* The extension to use for the image URL
|
| 506 |
-
*
|
| 507 |
-
* @defaultValue `'webp'`
|
| 508 |
-
*/
|
| 509 |
-
extension?: string | undefined;
|
| 510 |
-
/**
|
| 511 |
-
* The size specified in the image URL
|
| 512 |
-
*/
|
| 513 |
-
size?: ImageSize;
|
| 514 |
-
}
|
| 515 |
-
/**
|
| 516 |
-
* The CDN link builder
|
| 517 |
-
*/
|
| 518 |
-
declare class CDN {
|
| 519 |
-
private readonly cdn;
|
| 520 |
-
private readonly mediaProxy;
|
| 521 |
-
constructor(cdn?: string, mediaProxy?: string);
|
| 522 |
-
/**
|
| 523 |
-
* Generates an app asset URL for a client's asset.
|
| 524 |
-
*
|
| 525 |
-
* @param clientId - The client id that has the asset
|
| 526 |
-
* @param assetHash - The hash provided by Discord for this asset
|
| 527 |
-
* @param options - Optional options for the asset
|
| 528 |
-
*/
|
| 529 |
-
appAsset(clientId: string, assetHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 530 |
-
/**
|
| 531 |
-
* Generates an app icon URL for a client's icon.
|
| 532 |
-
*
|
| 533 |
-
* @param clientId - The client id that has the icon
|
| 534 |
-
* @param iconHash - The hash provided by Discord for this icon
|
| 535 |
-
* @param options - Optional options for the icon
|
| 536 |
-
*/
|
| 537 |
-
appIcon(clientId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 538 |
-
/**
|
| 539 |
-
* Generates an avatar URL, e.g. for a user or a webhook.
|
| 540 |
-
*
|
| 541 |
-
* @param id - The id that has the icon
|
| 542 |
-
* @param avatarHash - The hash provided by Discord for this avatar
|
| 543 |
-
* @param options - Optional options for the avatar
|
| 544 |
-
*/
|
| 545 |
-
avatar(id: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
| 546 |
-
/**
|
| 547 |
-
* Generates a user avatar decoration preset URL.
|
| 548 |
-
*
|
| 549 |
-
* @param asset - The avatar decoration hash
|
| 550 |
-
*/
|
| 551 |
-
avatarDecoration(asset: string): string;
|
| 552 |
-
/**
|
| 553 |
-
* Generates a user avatar decoration URL.
|
| 554 |
-
*
|
| 555 |
-
* @deprecated This overload is deprecated. Pass a hash instead.
|
| 556 |
-
* @param userId - The id of the user
|
| 557 |
-
* @param userAvatarDecoration - The hash provided by Discord for this avatar decoration
|
| 558 |
-
* @param options - Optional options for the avatar decoration
|
| 559 |
-
*/
|
| 560 |
-
avatarDecoration(userId: string, userAvatarDecoration: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 561 |
-
/**
|
| 562 |
-
* Generates a banner URL, e.g. for a user or a guild.
|
| 563 |
-
*
|
| 564 |
-
* @param id - The id that has the banner splash
|
| 565 |
-
* @param bannerHash - The hash provided by Discord for this banner
|
| 566 |
-
* @param options - Optional options for the banner
|
| 567 |
-
*/
|
| 568 |
-
banner(id: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
| 569 |
-
/**
|
| 570 |
-
* Generates an icon URL for a channel, e.g. a group DM.
|
| 571 |
-
*
|
| 572 |
-
* @param channelId - The channel id that has the icon
|
| 573 |
-
* @param iconHash - The hash provided by Discord for this channel
|
| 574 |
-
* @param options - Optional options for the icon
|
| 575 |
-
*/
|
| 576 |
-
channelIcon(channelId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 577 |
-
/**
|
| 578 |
-
* Generates a default avatar URL
|
| 579 |
-
*
|
| 580 |
-
* @param index - The default avatar index
|
| 581 |
-
* @remarks
|
| 582 |
-
* To calculate the index for a user do `(userId >> 22) % 6`,
|
| 583 |
-
* or `discriminator % 5` if they're using the legacy username system.
|
| 584 |
-
*/
|
| 585 |
-
defaultAvatar(index: number): string;
|
| 586 |
-
/**
|
| 587 |
-
* Generates a discovery splash URL for a guild's discovery splash.
|
| 588 |
-
*
|
| 589 |
-
* @param guildId - The guild id that has the discovery splash
|
| 590 |
-
* @param splashHash - The hash provided by Discord for this splash
|
| 591 |
-
* @param options - Optional options for the splash
|
| 592 |
-
*/
|
| 593 |
-
discoverySplash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 594 |
-
/**
|
| 595 |
-
* Generates an emoji's URL for an emoji.
|
| 596 |
-
*
|
| 597 |
-
* @param emojiId - The emoji id
|
| 598 |
-
* @param options - Optional options for the emoji
|
| 599 |
-
*/
|
| 600 |
-
emoji(emojiId: string, options?: Readonly<EmojiURLOptions>): string;
|
| 601 |
-
/**
|
| 602 |
-
* Generates an emoji's URL for an emoji.
|
| 603 |
-
*
|
| 604 |
-
* @param emojiId - The emoji id
|
| 605 |
-
* @param extension - The extension of the emoji
|
| 606 |
-
* @deprecated This overload is deprecated. Pass an object containing the extension instead.
|
| 607 |
-
*/
|
| 608 |
-
emoji(emojiId: string, extension?: ImageExtension): string;
|
| 609 |
-
/**
|
| 610 |
-
* Generates a guild member avatar URL.
|
| 611 |
-
*
|
| 612 |
-
* @param guildId - The id of the guild
|
| 613 |
-
* @param userId - The id of the user
|
| 614 |
-
* @param avatarHash - The hash provided by Discord for this avatar
|
| 615 |
-
* @param options - Optional options for the avatar
|
| 616 |
-
*/
|
| 617 |
-
guildMemberAvatar(guildId: string, userId: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
| 618 |
-
/**
|
| 619 |
-
* Generates a guild member banner URL.
|
| 620 |
-
*
|
| 621 |
-
* @param guildId - The id of the guild
|
| 622 |
-
* @param userId - The id of the user
|
| 623 |
-
* @param bannerHash - The hash provided by Discord for this banner
|
| 624 |
-
* @param options - Optional options for the banner
|
| 625 |
-
*/
|
| 626 |
-
guildMemberBanner(guildId: string, userId: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
| 627 |
-
/**
|
| 628 |
-
* Generates an icon URL, e.g. for a guild.
|
| 629 |
-
*
|
| 630 |
-
* @param id - The id that has the icon splash
|
| 631 |
-
* @param iconHash - The hash provided by Discord for this icon
|
| 632 |
-
* @param options - Optional options for the icon
|
| 633 |
-
*/
|
| 634 |
-
icon(id: string, iconHash: string, options?: Readonly<ImageURLOptions>): string;
|
| 635 |
-
/**
|
| 636 |
-
* Generates a URL for the icon of a role
|
| 637 |
-
*
|
| 638 |
-
* @param roleId - The id of the role that has the icon
|
| 639 |
-
* @param roleIconHash - The hash provided by Discord for this role icon
|
| 640 |
-
* @param options - Optional options for the role icon
|
| 641 |
-
*/
|
| 642 |
-
roleIcon(roleId: string, roleIconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 643 |
-
/**
|
| 644 |
-
* Generates a guild invite splash URL for a guild's invite splash.
|
| 645 |
-
*
|
| 646 |
-
* @param guildId - The guild id that has the invite splash
|
| 647 |
-
* @param splashHash - The hash provided by Discord for this splash
|
| 648 |
-
* @param options - Optional options for the splash
|
| 649 |
-
*/
|
| 650 |
-
splash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 651 |
-
/**
|
| 652 |
-
* Generates a sticker URL.
|
| 653 |
-
*
|
| 654 |
-
* @param stickerId - The sticker id
|
| 655 |
-
* @param extension - The extension of the sticker
|
| 656 |
-
* @privateRemarks
|
| 657 |
-
* Stickers cannot have a `.webp` extension, so we default to a `.png`.
|
| 658 |
-
* Sticker GIFs do not use the CDN base URL.
|
| 659 |
-
*/
|
| 660 |
-
sticker(stickerId: string, extension?: StickerExtension): string;
|
| 661 |
-
/**
|
| 662 |
-
* Generates a sticker pack banner URL.
|
| 663 |
-
*
|
| 664 |
-
* @param bannerId - The banner id
|
| 665 |
-
* @param options - Optional options for the banner
|
| 666 |
-
*/
|
| 667 |
-
stickerPackBanner(bannerId: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 668 |
-
/**
|
| 669 |
-
* Generates a team icon URL for a team's icon.
|
| 670 |
-
*
|
| 671 |
-
* @param teamId - The team id that has the icon
|
| 672 |
-
* @param iconHash - The hash provided by Discord for this icon
|
| 673 |
-
* @param options - Optional options for the icon
|
| 674 |
-
*/
|
| 675 |
-
teamIcon(teamId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 676 |
-
/**
|
| 677 |
-
* Generates a cover image for a guild scheduled event.
|
| 678 |
-
*
|
| 679 |
-
* @param scheduledEventId - The scheduled event id
|
| 680 |
-
* @param coverHash - The hash provided by discord for this cover image
|
| 681 |
-
* @param options - Optional options for the cover image
|
| 682 |
-
*/
|
| 683 |
-
guildScheduledEventCover(scheduledEventId: string, coverHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 684 |
-
/**
|
| 685 |
-
* Generates a URL for a soundboard sound.
|
| 686 |
-
*
|
| 687 |
-
* @param soundId - The soundboard sound id
|
| 688 |
-
*/
|
| 689 |
-
soundboardSound(soundId: string): string;
|
| 690 |
-
/**
|
| 691 |
-
* Generates a URL for a guild tag badge.
|
| 692 |
-
*
|
| 693 |
-
* @param guildId - The guild id
|
| 694 |
-
* @param badgeHash - The hash of the badge
|
| 695 |
-
* @param options - Optional options for the badge
|
| 696 |
-
*/
|
| 697 |
-
guildTagBadge(guildId: string, badgeHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 698 |
-
/**
|
| 699 |
-
* Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
|
| 700 |
-
*
|
| 701 |
-
* @param route - The base cdn route
|
| 702 |
-
* @param hash - The hash provided by Discord for this icon
|
| 703 |
-
* @param options - Optional options for the link
|
| 704 |
-
*/
|
| 705 |
-
private dynamicMakeURL;
|
| 706 |
-
/**
|
| 707 |
-
* Constructs the URL for the resource
|
| 708 |
-
*
|
| 709 |
-
* @param route - The base cdn route
|
| 710 |
-
* @param options - The extension/size options for the link
|
| 711 |
-
*/
|
| 712 |
-
private makeURL;
|
| 713 |
-
}
|
| 714 |
-
|
| 715 |
-
interface DiscordErrorFieldInformation {
|
| 716 |
-
code: string;
|
| 717 |
-
message: string;
|
| 718 |
-
}
|
| 719 |
-
interface DiscordErrorGroupWrapper {
|
| 720 |
-
_errors: DiscordError[];
|
| 721 |
-
}
|
| 722 |
-
type DiscordError = DiscordErrorFieldInformation | DiscordErrorGroupWrapper | string | {
|
| 723 |
-
[k: string]: DiscordError;
|
| 724 |
-
};
|
| 725 |
-
interface DiscordErrorData {
|
| 726 |
-
code: number;
|
| 727 |
-
errors?: DiscordError;
|
| 728 |
-
message: string;
|
| 729 |
-
}
|
| 730 |
-
interface OAuthErrorData {
|
| 731 |
-
error: string;
|
| 732 |
-
error_description?: string;
|
| 733 |
-
}
|
| 734 |
-
interface RequestBody {
|
| 735 |
-
files: RawFile[] | undefined;
|
| 736 |
-
json: unknown | undefined;
|
| 737 |
-
}
|
| 738 |
-
/**
|
| 739 |
-
* Represents an API error returned by Discord
|
| 740 |
-
*/
|
| 741 |
-
declare class DiscordAPIError extends Error {
|
| 742 |
-
rawError: DiscordErrorData | OAuthErrorData;
|
| 743 |
-
code: number | string;
|
| 744 |
-
status: number;
|
| 745 |
-
method: string;
|
| 746 |
-
url: string;
|
| 747 |
-
requestBody: RequestBody;
|
| 748 |
-
/**
|
| 749 |
-
* @param rawError - The error reported by Discord
|
| 750 |
-
* @param code - The error code reported by Discord
|
| 751 |
-
* @param status - The status code of the response
|
| 752 |
-
* @param method - The method of the request that erred
|
| 753 |
-
* @param url - The url of the request that erred
|
| 754 |
-
* @param bodyData - The unparsed data for the request that errored
|
| 755 |
-
*/
|
| 756 |
-
constructor(rawError: DiscordErrorData | OAuthErrorData, code: number | string, status: number, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
|
| 757 |
-
/**
|
| 758 |
-
* The name of the error
|
| 759 |
-
*/
|
| 760 |
-
get name(): string;
|
| 761 |
-
private static getMessage;
|
| 762 |
-
private static flattenDiscordError;
|
| 763 |
-
}
|
| 764 |
-
|
| 765 |
-
/**
|
| 766 |
-
* Represents a HTTP error
|
| 767 |
-
*/
|
| 768 |
-
declare class HTTPError extends Error {
|
| 769 |
-
status: number;
|
| 770 |
-
method: string;
|
| 771 |
-
url: string;
|
| 772 |
-
requestBody: RequestBody;
|
| 773 |
-
name: string;
|
| 774 |
-
/**
|
| 775 |
-
* @param status - The status code of the response
|
| 776 |
-
* @param statusText - The status text of the response
|
| 777 |
-
* @param method - The method of the request that erred
|
| 778 |
-
* @param url - The url of the request that erred
|
| 779 |
-
* @param bodyData - The unparsed data for the request that errored
|
| 780 |
-
*/
|
| 781 |
-
constructor(status: number, statusText: string, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
|
| 782 |
-
}
|
| 783 |
-
|
| 784 |
-
declare class RateLimitError extends Error implements RateLimitData {
|
| 785 |
-
timeToReset: number;
|
| 786 |
-
limit: number;
|
| 787 |
-
method: string;
|
| 788 |
-
hash: string;
|
| 789 |
-
url: string;
|
| 790 |
-
route: string;
|
| 791 |
-
majorParameter: string;
|
| 792 |
-
global: boolean;
|
| 793 |
-
retryAfter: number;
|
| 794 |
-
sublimitTimeout: number;
|
| 795 |
-
scope: RateLimitData['scope'];
|
| 796 |
-
constructor({ timeToReset, limit, method, hash, url, route, majorParameter, global, retryAfter, sublimitTimeout, scope, }: RateLimitData);
|
| 797 |
-
/**
|
| 798 |
-
* The name of the error
|
| 799 |
-
*/
|
| 800 |
-
get name(): string;
|
| 801 |
-
}
|
| 802 |
-
|
| 803 |
-
/**
|
| 804 |
-
* Represents the class that manages handlers for endpoints
|
| 805 |
-
*/
|
| 806 |
-
declare class REST extends AsyncEventEmitter<RestEvents> {
|
| 807 |
-
#private;
|
| 808 |
-
/**
|
| 809 |
-
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} for all requests
|
| 810 |
-
* performed by this manager.
|
| 811 |
-
*/
|
| 812 |
-
agent: Dispatcher | null;
|
| 813 |
-
readonly cdn: CDN;
|
| 814 |
-
/**
|
| 815 |
-
* The number of requests remaining in the global bucket
|
| 816 |
-
*/
|
| 817 |
-
globalRemaining: number;
|
| 818 |
-
/**
|
| 819 |
-
* The promise used to wait out the global rate limit
|
| 820 |
-
*/
|
| 821 |
-
globalDelay: Promise<void> | null;
|
| 822 |
-
/**
|
| 823 |
-
* The timestamp at which the global bucket resets
|
| 824 |
-
*/
|
| 825 |
-
globalReset: number;
|
| 826 |
-
/**
|
| 827 |
-
* API bucket hashes that are cached from provided routes
|
| 828 |
-
*/
|
| 829 |
-
readonly hashes: Collection<string, HashData>;
|
| 830 |
-
/**
|
| 831 |
-
* Request handlers created from the bucket hash and the major parameters
|
| 832 |
-
*/
|
| 833 |
-
readonly handlers: Collection<string, IHandler>;
|
| 834 |
-
private hashTimer;
|
| 835 |
-
private handlerTimer;
|
| 836 |
-
readonly options: RESTOptions;
|
| 837 |
-
constructor(options?: Partial<RESTOptions>);
|
| 838 |
-
private setupSweepers;
|
| 839 |
-
/**
|
| 840 |
-
* Runs a get request from the api
|
| 841 |
-
*
|
| 842 |
-
* @param fullRoute - The full route to query
|
| 843 |
-
* @param options - Optional request options
|
| 844 |
-
*/
|
| 845 |
-
get(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
| 846 |
-
/**
|
| 847 |
-
* Runs a delete request from the api
|
| 848 |
-
*
|
| 849 |
-
* @param fullRoute - The full route to query
|
| 850 |
-
* @param options - Optional request options
|
| 851 |
-
*/
|
| 852 |
-
delete(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
| 853 |
-
/**
|
| 854 |
-
* Runs a post request from the api
|
| 855 |
-
*
|
| 856 |
-
* @param fullRoute - The full route to query
|
| 857 |
-
* @param options - Optional request options
|
| 858 |
-
*/
|
| 859 |
-
post(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
| 860 |
-
/**
|
| 861 |
-
* Runs a put request from the api
|
| 862 |
-
*
|
| 863 |
-
* @param fullRoute - The full route to query
|
| 864 |
-
* @param options - Optional request options
|
| 865 |
-
*/
|
| 866 |
-
put(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
| 867 |
-
/**
|
| 868 |
-
* Runs a patch request from the api
|
| 869 |
-
*
|
| 870 |
-
* @param fullRoute - The full route to query
|
| 871 |
-
* @param options - Optional request options
|
| 872 |
-
*/
|
| 873 |
-
patch(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
| 874 |
-
/**
|
| 875 |
-
* Runs a request from the api
|
| 876 |
-
*
|
| 877 |
-
* @param options - Request options
|
| 878 |
-
*/
|
| 879 |
-
request(options: InternalRequest): Promise<unknown>;
|
| 880 |
-
/**
|
| 881 |
-
* Sets the default agent to use for requests performed by this manager
|
| 882 |
-
*
|
| 883 |
-
* @param agent - The agent to use
|
| 884 |
-
*/
|
| 885 |
-
setAgent(agent: Dispatcher): this;
|
| 886 |
-
/**
|
| 887 |
-
* Sets the authorization token that should be used for requests
|
| 888 |
-
*
|
| 889 |
-
* @param token - The authorization token to use
|
| 890 |
-
*/
|
| 891 |
-
setToken(token: string): this;
|
| 892 |
-
/**
|
| 893 |
-
* Queues a request to be sent
|
| 894 |
-
*
|
| 895 |
-
* @param request - All the information needed to make a request
|
| 896 |
-
* @returns The response from the api request
|
| 897 |
-
*/
|
| 898 |
-
queueRequest(request: InternalRequest): Promise<ResponseLike>;
|
| 899 |
-
/**
|
| 900 |
-
* Creates a new rate limit handler from a hash, based on the hash and the major parameter
|
| 901 |
-
*
|
| 902 |
-
* @param hash - The hash for the route
|
| 903 |
-
* @param majorParameter - The major parameter for this handler
|
| 904 |
-
* @internal
|
| 905 |
-
*/
|
| 906 |
-
private createHandler;
|
| 907 |
-
/**
|
| 908 |
-
* Formats the request data to a usable format for fetch
|
| 909 |
-
*
|
| 910 |
-
* @param request - The request data
|
| 911 |
-
*/
|
| 912 |
-
private resolveRequest;
|
| 913 |
-
/**
|
| 914 |
-
* Stops the hash sweeping interval
|
| 915 |
-
*/
|
| 916 |
-
clearHashSweeper(): void;
|
| 917 |
-
/**
|
| 918 |
-
* Stops the request handler sweeping interval
|
| 919 |
-
*/
|
| 920 |
-
clearHandlerSweeper(): void;
|
| 921 |
-
/**
|
| 922 |
-
* Generates route data for an endpoint:method
|
| 923 |
-
*
|
| 924 |
-
* @param endpoint - The raw endpoint to generalize
|
| 925 |
-
* @param method - The HTTP method this endpoint is called without
|
| 926 |
-
* @internal
|
| 927 |
-
*/
|
| 928 |
-
private static generateRouteData;
|
| 929 |
-
}
|
| 930 |
-
|
| 931 |
-
/**
|
| 932 |
-
* Creates and populates an URLSearchParams instance from an object, stripping
|
| 933 |
-
* out null and undefined values, while also coercing non-strings to strings.
|
| 934 |
-
*
|
| 935 |
-
* @param options - The options to use
|
| 936 |
-
* @returns A populated URLSearchParams instance
|
| 937 |
-
*/
|
| 938 |
-
declare function makeURLSearchParams<OptionsType extends object>(options?: Readonly<OptionsType>): url.URLSearchParams;
|
| 939 |
-
/**
|
| 940 |
-
* Converts the response to usable data
|
| 941 |
-
*
|
| 942 |
-
* @param res - The fetch response
|
| 943 |
-
*/
|
| 944 |
-
declare function parseResponse(res: ResponseLike): Promise<unknown>;
|
| 945 |
-
/**
|
| 946 |
-
* Calculates the default avatar index for a given user id.
|
| 947 |
-
*
|
| 948 |
-
* @param userId - The user id to calculate the default avatar index for
|
| 949 |
-
*/
|
| 950 |
-
declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
|
| 951 |
-
|
| 952 |
-
/**
|
| 953 |
-
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/rest#readme | @discordjs/rest} version
|
| 954 |
-
* that you are currently using.
|
| 955 |
-
*/
|
| 956 |
-
declare const version: string;
|
| 957 |
-
|
| 958 |
-
export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, DEPRECATION_WARNING_PREFIX, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordErrorData, type EmojiURLOptions, type EmojiURLOptionsNotWebp, type EmojiURLOptionsWebp, type GetRateLimitOffsetFunction, HTTPError, type HandlerRequestData, type HashData, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type MakeURLOptions, type OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, type RESTOptions, type RateLimitData, RateLimitError, type RateLimitQueueFilter, type RawFile, type RequestBody, type RequestData, type RequestHeaders, RequestMethod, type ResponseLike, type RestEvents, type RestEventsMap, type RouteData, type RouteLike, type StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/rest/dist/index.js
DELETED
|
@@ -1,1515 +0,0 @@
|
|
| 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/CDN.ts
|
| 125 |
-
var import_v102 = require("discord-api-types/v10");
|
| 126 |
-
|
| 127 |
-
// src/lib/utils/constants.ts
|
| 128 |
-
var import_util = require("@discordjs/util");
|
| 129 |
-
var import_v10 = require("discord-api-types/v10");
|
| 130 |
-
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 2.6.0)`;
|
| 131 |
-
var DefaultUserAgentAppendix = (0, import_util.getUserAgentAppendix)();
|
| 132 |
-
var DefaultRestOptions = {
|
| 133 |
-
agent: null,
|
| 134 |
-
api: "https://discord.com/api",
|
| 135 |
-
authPrefix: "Bot",
|
| 136 |
-
cdn: "https://cdn.discordapp.com",
|
| 137 |
-
headers: {},
|
| 138 |
-
invalidRequestWarningInterval: 0,
|
| 139 |
-
globalRequestsPerSecond: 50,
|
| 140 |
-
offset: 50,
|
| 141 |
-
rejectOnRateLimit: null,
|
| 142 |
-
retries: 3,
|
| 143 |
-
timeout: 15e3,
|
| 144 |
-
userAgentAppendix: DefaultUserAgentAppendix,
|
| 145 |
-
version: import_v10.APIVersion,
|
| 146 |
-
hashSweepInterval: 144e5,
|
| 147 |
-
// 4 Hours
|
| 148 |
-
hashLifetime: 864e5,
|
| 149 |
-
// 24 Hours
|
| 150 |
-
handlerSweepInterval: 36e5,
|
| 151 |
-
// 1 Hour
|
| 152 |
-
async makeRequest(...args) {
|
| 153 |
-
return getDefaultStrategy()(...args);
|
| 154 |
-
},
|
| 155 |
-
mediaProxy: "https://media.discordapp.net"
|
| 156 |
-
};
|
| 157 |
-
var RESTEvents = /* @__PURE__ */ ((RESTEvents2) => {
|
| 158 |
-
RESTEvents2["Debug"] = "restDebug";
|
| 159 |
-
RESTEvents2["HandlerSweep"] = "handlerSweep";
|
| 160 |
-
RESTEvents2["HashSweep"] = "hashSweep";
|
| 161 |
-
RESTEvents2["InvalidRequestWarning"] = "invalidRequestWarning";
|
| 162 |
-
RESTEvents2["RateLimited"] = "rateLimited";
|
| 163 |
-
RESTEvents2["Response"] = "response";
|
| 164 |
-
return RESTEvents2;
|
| 165 |
-
})(RESTEvents || {});
|
| 166 |
-
var ALLOWED_EXTENSIONS = ["webp", "png", "jpg", "jpeg", "gif"];
|
| 167 |
-
var ALLOWED_STICKER_EXTENSIONS = ["png", "json", "gif"];
|
| 168 |
-
var ALLOWED_SIZES = [
|
| 169 |
-
16,
|
| 170 |
-
32,
|
| 171 |
-
64,
|
| 172 |
-
128,
|
| 173 |
-
256,
|
| 174 |
-
512,
|
| 175 |
-
1024,
|
| 176 |
-
2048,
|
| 177 |
-
4096
|
| 178 |
-
];
|
| 179 |
-
var OverwrittenMimeTypes = {
|
| 180 |
-
// https://github.com/discordjs/discord.js/issues/8557
|
| 181 |
-
"image/apng": "image/png"
|
| 182 |
-
};
|
| 183 |
-
var BurstHandlerMajorIdKey = "burst";
|
| 184 |
-
var DEPRECATION_WARNING_PREFIX = "DeprecationWarning";
|
| 185 |
-
|
| 186 |
-
// src/lib/errors/RateLimitError.ts
|
| 187 |
-
var RateLimitError = class _RateLimitError extends Error {
|
| 188 |
-
static {
|
| 189 |
-
__name(this, "RateLimitError");
|
| 190 |
-
}
|
| 191 |
-
timeToReset;
|
| 192 |
-
limit;
|
| 193 |
-
method;
|
| 194 |
-
hash;
|
| 195 |
-
url;
|
| 196 |
-
route;
|
| 197 |
-
majorParameter;
|
| 198 |
-
global;
|
| 199 |
-
retryAfter;
|
| 200 |
-
sublimitTimeout;
|
| 201 |
-
scope;
|
| 202 |
-
constructor({
|
| 203 |
-
timeToReset,
|
| 204 |
-
limit,
|
| 205 |
-
method,
|
| 206 |
-
hash,
|
| 207 |
-
url,
|
| 208 |
-
route,
|
| 209 |
-
majorParameter,
|
| 210 |
-
global,
|
| 211 |
-
retryAfter,
|
| 212 |
-
sublimitTimeout,
|
| 213 |
-
scope
|
| 214 |
-
}) {
|
| 215 |
-
super();
|
| 216 |
-
this.timeToReset = timeToReset;
|
| 217 |
-
this.limit = limit;
|
| 218 |
-
this.method = method;
|
| 219 |
-
this.hash = hash;
|
| 220 |
-
this.url = url;
|
| 221 |
-
this.route = route;
|
| 222 |
-
this.majorParameter = majorParameter;
|
| 223 |
-
this.global = global;
|
| 224 |
-
this.retryAfter = retryAfter;
|
| 225 |
-
this.sublimitTimeout = sublimitTimeout;
|
| 226 |
-
this.scope = scope;
|
| 227 |
-
}
|
| 228 |
-
/**
|
| 229 |
-
* The name of the error
|
| 230 |
-
*/
|
| 231 |
-
get name() {
|
| 232 |
-
return `${_RateLimitError.name}[${this.route}]`;
|
| 233 |
-
}
|
| 234 |
-
};
|
| 235 |
-
|
| 236 |
-
// src/lib/utils/types.ts
|
| 237 |
-
var RequestMethod = /* @__PURE__ */ ((RequestMethod2) => {
|
| 238 |
-
RequestMethod2["Delete"] = "DELETE";
|
| 239 |
-
RequestMethod2["Get"] = "GET";
|
| 240 |
-
RequestMethod2["Patch"] = "PATCH";
|
| 241 |
-
RequestMethod2["Post"] = "POST";
|
| 242 |
-
RequestMethod2["Put"] = "PUT";
|
| 243 |
-
return RequestMethod2;
|
| 244 |
-
})(RequestMethod || {});
|
| 245 |
-
|
| 246 |
-
// src/lib/utils/utils.ts
|
| 247 |
-
function serializeSearchParam(value) {
|
| 248 |
-
switch (typeof value) {
|
| 249 |
-
case "string":
|
| 250 |
-
return value;
|
| 251 |
-
case "number":
|
| 252 |
-
case "bigint":
|
| 253 |
-
case "boolean":
|
| 254 |
-
return value.toString();
|
| 255 |
-
case "object":
|
| 256 |
-
if (value === null) return null;
|
| 257 |
-
if (value instanceof Date) {
|
| 258 |
-
return Number.isNaN(value.getTime()) ? null : value.toISOString();
|
| 259 |
-
}
|
| 260 |
-
if (typeof value.toString === "function" && value.toString !== Object.prototype.toString) return value.toString();
|
| 261 |
-
return null;
|
| 262 |
-
default:
|
| 263 |
-
return null;
|
| 264 |
-
}
|
| 265 |
-
}
|
| 266 |
-
__name(serializeSearchParam, "serializeSearchParam");
|
| 267 |
-
function makeURLSearchParams(options) {
|
| 268 |
-
const params = new URLSearchParams();
|
| 269 |
-
if (!options) return params;
|
| 270 |
-
for (const [key, value] of Object.entries(options)) {
|
| 271 |
-
const serialized = serializeSearchParam(value);
|
| 272 |
-
if (serialized !== null) params.append(key, serialized);
|
| 273 |
-
}
|
| 274 |
-
return params;
|
| 275 |
-
}
|
| 276 |
-
__name(makeURLSearchParams, "makeURLSearchParams");
|
| 277 |
-
async function parseResponse(res) {
|
| 278 |
-
if (res.headers.get("Content-Type")?.startsWith("application/json")) {
|
| 279 |
-
return res.json();
|
| 280 |
-
}
|
| 281 |
-
return res.arrayBuffer();
|
| 282 |
-
}
|
| 283 |
-
__name(parseResponse, "parseResponse");
|
| 284 |
-
function hasSublimit(bucketRoute, body, method) {
|
| 285 |
-
if (bucketRoute === "/channels/:id") {
|
| 286 |
-
if (typeof body !== "object" || body === null) return false;
|
| 287 |
-
if (method !== "PATCH" /* Patch */) return false;
|
| 288 |
-
const castedBody = body;
|
| 289 |
-
return ["name", "topic"].some((key) => Reflect.has(castedBody, key));
|
| 290 |
-
}
|
| 291 |
-
return true;
|
| 292 |
-
}
|
| 293 |
-
__name(hasSublimit, "hasSublimit");
|
| 294 |
-
function shouldRetry(error) {
|
| 295 |
-
if (error.name === "AbortError") return true;
|
| 296 |
-
return "code" in error && error.code === "ECONNRESET" || error.message.includes("ECONNRESET");
|
| 297 |
-
}
|
| 298 |
-
__name(shouldRetry, "shouldRetry");
|
| 299 |
-
async function onRateLimit(manager, rateLimitData) {
|
| 300 |
-
const { options } = manager;
|
| 301 |
-
if (!options.rejectOnRateLimit) return;
|
| 302 |
-
const shouldThrow = typeof options.rejectOnRateLimit === "function" ? await options.rejectOnRateLimit(rateLimitData) : options.rejectOnRateLimit.some((route) => rateLimitData.route.startsWith(route.toLowerCase()));
|
| 303 |
-
if (shouldThrow) {
|
| 304 |
-
throw new RateLimitError(rateLimitData);
|
| 305 |
-
}
|
| 306 |
-
}
|
| 307 |
-
__name(onRateLimit, "onRateLimit");
|
| 308 |
-
function calculateUserDefaultAvatarIndex(userId) {
|
| 309 |
-
return Number(BigInt(userId) >> 22n) % 6;
|
| 310 |
-
}
|
| 311 |
-
__name(calculateUserDefaultAvatarIndex, "calculateUserDefaultAvatarIndex");
|
| 312 |
-
async function sleep(ms) {
|
| 313 |
-
return new Promise((resolve) => {
|
| 314 |
-
setTimeout(() => resolve(), ms);
|
| 315 |
-
});
|
| 316 |
-
}
|
| 317 |
-
__name(sleep, "sleep");
|
| 318 |
-
function isBufferLike(value) {
|
| 319 |
-
return value instanceof ArrayBuffer || value instanceof Uint8Array || value instanceof Uint8ClampedArray;
|
| 320 |
-
}
|
| 321 |
-
__name(isBufferLike, "isBufferLike");
|
| 322 |
-
function deprecationWarning(message) {
|
| 323 |
-
if (typeof globalThis.process === "undefined") {
|
| 324 |
-
console.warn(`${DEPRECATION_WARNING_PREFIX}: ${message}`);
|
| 325 |
-
} else {
|
| 326 |
-
process.emitWarning(message, DEPRECATION_WARNING_PREFIX);
|
| 327 |
-
}
|
| 328 |
-
}
|
| 329 |
-
__name(deprecationWarning, "deprecationWarning");
|
| 330 |
-
function normalizeRateLimitOffset(offset, route) {
|
| 331 |
-
if (typeof offset === "number") {
|
| 332 |
-
return Math.max(0, offset);
|
| 333 |
-
}
|
| 334 |
-
const result = offset(route);
|
| 335 |
-
return Math.max(0, result);
|
| 336 |
-
}
|
| 337 |
-
__name(normalizeRateLimitOffset, "normalizeRateLimitOffset");
|
| 338 |
-
|
| 339 |
-
// src/lib/CDN.ts
|
| 340 |
-
var deprecationEmittedForEmoji = false;
|
| 341 |
-
var CDN = class {
|
| 342 |
-
constructor(cdn = DefaultRestOptions.cdn, mediaProxy = DefaultRestOptions.mediaProxy) {
|
| 343 |
-
this.cdn = cdn;
|
| 344 |
-
this.mediaProxy = mediaProxy;
|
| 345 |
-
}
|
| 346 |
-
static {
|
| 347 |
-
__name(this, "CDN");
|
| 348 |
-
}
|
| 349 |
-
/**
|
| 350 |
-
* Generates an app asset URL for a client's asset.
|
| 351 |
-
*
|
| 352 |
-
* @param clientId - The client id that has the asset
|
| 353 |
-
* @param assetHash - The hash provided by Discord for this asset
|
| 354 |
-
* @param options - Optional options for the asset
|
| 355 |
-
*/
|
| 356 |
-
appAsset(clientId, assetHash, options) {
|
| 357 |
-
return this.makeURL(`/app-assets/${clientId}/${assetHash}`, options);
|
| 358 |
-
}
|
| 359 |
-
/**
|
| 360 |
-
* Generates an app icon URL for a client's icon.
|
| 361 |
-
*
|
| 362 |
-
* @param clientId - The client id that has the icon
|
| 363 |
-
* @param iconHash - The hash provided by Discord for this icon
|
| 364 |
-
* @param options - Optional options for the icon
|
| 365 |
-
*/
|
| 366 |
-
appIcon(clientId, iconHash, options) {
|
| 367 |
-
return this.makeURL(`/app-icons/${clientId}/${iconHash}`, options);
|
| 368 |
-
}
|
| 369 |
-
/**
|
| 370 |
-
* Generates an avatar URL, e.g. for a user or a webhook.
|
| 371 |
-
*
|
| 372 |
-
* @param id - The id that has the icon
|
| 373 |
-
* @param avatarHash - The hash provided by Discord for this avatar
|
| 374 |
-
* @param options - Optional options for the avatar
|
| 375 |
-
*/
|
| 376 |
-
avatar(id, avatarHash, options) {
|
| 377 |
-
return this.dynamicMakeURL(`/avatars/${id}/${avatarHash}`, avatarHash, options);
|
| 378 |
-
}
|
| 379 |
-
avatarDecoration(userIdOrAsset, userAvatarDecoration, options) {
|
| 380 |
-
if (userAvatarDecoration) {
|
| 381 |
-
return this.makeURL(`/avatar-decorations/${userIdOrAsset}/${userAvatarDecoration}`, options);
|
| 382 |
-
}
|
| 383 |
-
return this.makeURL(`/avatar-decoration-presets/${userIdOrAsset}`, { extension: "png" });
|
| 384 |
-
}
|
| 385 |
-
/**
|
| 386 |
-
* Generates a banner URL, e.g. for a user or a guild.
|
| 387 |
-
*
|
| 388 |
-
* @param id - The id that has the banner splash
|
| 389 |
-
* @param bannerHash - The hash provided by Discord for this banner
|
| 390 |
-
* @param options - Optional options for the banner
|
| 391 |
-
*/
|
| 392 |
-
banner(id, bannerHash, options) {
|
| 393 |
-
return this.dynamicMakeURL(`/banners/${id}/${bannerHash}`, bannerHash, options);
|
| 394 |
-
}
|
| 395 |
-
/**
|
| 396 |
-
* Generates an icon URL for a channel, e.g. a group DM.
|
| 397 |
-
*
|
| 398 |
-
* @param channelId - The channel id that has the icon
|
| 399 |
-
* @param iconHash - The hash provided by Discord for this channel
|
| 400 |
-
* @param options - Optional options for the icon
|
| 401 |
-
*/
|
| 402 |
-
channelIcon(channelId, iconHash, options) {
|
| 403 |
-
return this.makeURL(`/channel-icons/${channelId}/${iconHash}`, options);
|
| 404 |
-
}
|
| 405 |
-
/**
|
| 406 |
-
* Generates a default avatar URL
|
| 407 |
-
*
|
| 408 |
-
* @param index - The default avatar index
|
| 409 |
-
* @remarks
|
| 410 |
-
* To calculate the index for a user do `(userId >> 22) % 6`,
|
| 411 |
-
* or `discriminator % 5` if they're using the legacy username system.
|
| 412 |
-
*/
|
| 413 |
-
defaultAvatar(index) {
|
| 414 |
-
return this.makeURL(`/embed/avatars/${index}`, { extension: "png" });
|
| 415 |
-
}
|
| 416 |
-
/**
|
| 417 |
-
* Generates a discovery splash URL for a guild's discovery splash.
|
| 418 |
-
*
|
| 419 |
-
* @param guildId - The guild id that has the discovery splash
|
| 420 |
-
* @param splashHash - The hash provided by Discord for this splash
|
| 421 |
-
* @param options - Optional options for the splash
|
| 422 |
-
*/
|
| 423 |
-
discoverySplash(guildId, splashHash, options) {
|
| 424 |
-
return this.makeURL(`/discovery-splashes/${guildId}/${splashHash}`, options);
|
| 425 |
-
}
|
| 426 |
-
emoji(emojiId, options) {
|
| 427 |
-
let resolvedOptions;
|
| 428 |
-
if (typeof options === "string") {
|
| 429 |
-
if (!deprecationEmittedForEmoji) {
|
| 430 |
-
deprecationWarning(
|
| 431 |
-
"Passing a string for the second parameter of CDN#emoji() is deprecated. Use an object instead."
|
| 432 |
-
);
|
| 433 |
-
deprecationEmittedForEmoji = true;
|
| 434 |
-
}
|
| 435 |
-
resolvedOptions = { extension: options };
|
| 436 |
-
} else {
|
| 437 |
-
resolvedOptions = options;
|
| 438 |
-
}
|
| 439 |
-
return this.makeURL(`/emojis/${emojiId}`, resolvedOptions);
|
| 440 |
-
}
|
| 441 |
-
/**
|
| 442 |
-
* Generates a guild member avatar URL.
|
| 443 |
-
*
|
| 444 |
-
* @param guildId - The id of the guild
|
| 445 |
-
* @param userId - The id of the user
|
| 446 |
-
* @param avatarHash - The hash provided by Discord for this avatar
|
| 447 |
-
* @param options - Optional options for the avatar
|
| 448 |
-
*/
|
| 449 |
-
guildMemberAvatar(guildId, userId, avatarHash, options) {
|
| 450 |
-
return this.dynamicMakeURL(`/guilds/${guildId}/users/${userId}/avatars/${avatarHash}`, avatarHash, options);
|
| 451 |
-
}
|
| 452 |
-
/**
|
| 453 |
-
* Generates a guild member banner URL.
|
| 454 |
-
*
|
| 455 |
-
* @param guildId - The id of the guild
|
| 456 |
-
* @param userId - The id of the user
|
| 457 |
-
* @param bannerHash - The hash provided by Discord for this banner
|
| 458 |
-
* @param options - Optional options for the banner
|
| 459 |
-
*/
|
| 460 |
-
guildMemberBanner(guildId, userId, bannerHash, options) {
|
| 461 |
-
return this.dynamicMakeURL(`/guilds/${guildId}/users/${userId}/banners/${bannerHash}`, bannerHash, options);
|
| 462 |
-
}
|
| 463 |
-
/**
|
| 464 |
-
* Generates an icon URL, e.g. for a guild.
|
| 465 |
-
*
|
| 466 |
-
* @param id - The id that has the icon splash
|
| 467 |
-
* @param iconHash - The hash provided by Discord for this icon
|
| 468 |
-
* @param options - Optional options for the icon
|
| 469 |
-
*/
|
| 470 |
-
icon(id, iconHash, options) {
|
| 471 |
-
return this.dynamicMakeURL(`/icons/${id}/${iconHash}`, iconHash, options);
|
| 472 |
-
}
|
| 473 |
-
/**
|
| 474 |
-
* Generates a URL for the icon of a role
|
| 475 |
-
*
|
| 476 |
-
* @param roleId - The id of the role that has the icon
|
| 477 |
-
* @param roleIconHash - The hash provided by Discord for this role icon
|
| 478 |
-
* @param options - Optional options for the role icon
|
| 479 |
-
*/
|
| 480 |
-
roleIcon(roleId, roleIconHash, options) {
|
| 481 |
-
return this.makeURL(`/role-icons/${roleId}/${roleIconHash}`, options);
|
| 482 |
-
}
|
| 483 |
-
/**
|
| 484 |
-
* Generates a guild invite splash URL for a guild's invite splash.
|
| 485 |
-
*
|
| 486 |
-
* @param guildId - The guild id that has the invite splash
|
| 487 |
-
* @param splashHash - The hash provided by Discord for this splash
|
| 488 |
-
* @param options - Optional options for the splash
|
| 489 |
-
*/
|
| 490 |
-
splash(guildId, splashHash, options) {
|
| 491 |
-
return this.makeURL(`/splashes/${guildId}/${splashHash}`, options);
|
| 492 |
-
}
|
| 493 |
-
/**
|
| 494 |
-
* Generates a sticker URL.
|
| 495 |
-
*
|
| 496 |
-
* @param stickerId - The sticker id
|
| 497 |
-
* @param extension - The extension of the sticker
|
| 498 |
-
* @privateRemarks
|
| 499 |
-
* Stickers cannot have a `.webp` extension, so we default to a `.png`.
|
| 500 |
-
* Sticker GIFs do not use the CDN base URL.
|
| 501 |
-
*/
|
| 502 |
-
sticker(stickerId, extension = "png") {
|
| 503 |
-
return this.makeURL(`/stickers/${stickerId}`, {
|
| 504 |
-
allowedExtensions: ALLOWED_STICKER_EXTENSIONS,
|
| 505 |
-
base: extension === "gif" ? this.mediaProxy : this.cdn,
|
| 506 |
-
extension
|
| 507 |
-
});
|
| 508 |
-
}
|
| 509 |
-
/**
|
| 510 |
-
* Generates a sticker pack banner URL.
|
| 511 |
-
*
|
| 512 |
-
* @param bannerId - The banner id
|
| 513 |
-
* @param options - Optional options for the banner
|
| 514 |
-
*/
|
| 515 |
-
stickerPackBanner(bannerId, options) {
|
| 516 |
-
return this.makeURL(`/app-assets/710982414301790216/store/${bannerId}`, options);
|
| 517 |
-
}
|
| 518 |
-
/**
|
| 519 |
-
* Generates a team icon URL for a team's icon.
|
| 520 |
-
*
|
| 521 |
-
* @param teamId - The team id that has the icon
|
| 522 |
-
* @param iconHash - The hash provided by Discord for this icon
|
| 523 |
-
* @param options - Optional options for the icon
|
| 524 |
-
*/
|
| 525 |
-
teamIcon(teamId, iconHash, options) {
|
| 526 |
-
return this.makeURL(`/team-icons/${teamId}/${iconHash}`, options);
|
| 527 |
-
}
|
| 528 |
-
/**
|
| 529 |
-
* Generates a cover image for a guild scheduled event.
|
| 530 |
-
*
|
| 531 |
-
* @param scheduledEventId - The scheduled event id
|
| 532 |
-
* @param coverHash - The hash provided by discord for this cover image
|
| 533 |
-
* @param options - Optional options for the cover image
|
| 534 |
-
*/
|
| 535 |
-
guildScheduledEventCover(scheduledEventId, coverHash, options) {
|
| 536 |
-
return this.makeURL(`/guild-events/${scheduledEventId}/${coverHash}`, options);
|
| 537 |
-
}
|
| 538 |
-
/**
|
| 539 |
-
* Generates a URL for a soundboard sound.
|
| 540 |
-
*
|
| 541 |
-
* @param soundId - The soundboard sound id
|
| 542 |
-
*/
|
| 543 |
-
soundboardSound(soundId) {
|
| 544 |
-
return `${this.cdn}${import_v102.CDNRoutes.soundboardSound(soundId)}`;
|
| 545 |
-
}
|
| 546 |
-
/**
|
| 547 |
-
* Generates a URL for a guild tag badge.
|
| 548 |
-
*
|
| 549 |
-
* @param guildId - The guild id
|
| 550 |
-
* @param badgeHash - The hash of the badge
|
| 551 |
-
* @param options - Optional options for the badge
|
| 552 |
-
*/
|
| 553 |
-
guildTagBadge(guildId, badgeHash, options) {
|
| 554 |
-
return this.makeURL(`/guild-tag-badges/${guildId}/${badgeHash}`, options);
|
| 555 |
-
}
|
| 556 |
-
/**
|
| 557 |
-
* Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
|
| 558 |
-
*
|
| 559 |
-
* @param route - The base cdn route
|
| 560 |
-
* @param hash - The hash provided by Discord for this icon
|
| 561 |
-
* @param options - Optional options for the link
|
| 562 |
-
*/
|
| 563 |
-
dynamicMakeURL(route, hash, { forceStatic = false, ...options } = {}) {
|
| 564 |
-
return this.makeURL(route, !forceStatic && hash.startsWith("a_") ? { ...options, extension: "gif" } : options);
|
| 565 |
-
}
|
| 566 |
-
/**
|
| 567 |
-
* Constructs the URL for the resource
|
| 568 |
-
*
|
| 569 |
-
* @param route - The base cdn route
|
| 570 |
-
* @param options - The extension/size options for the link
|
| 571 |
-
*/
|
| 572 |
-
makeURL(route, {
|
| 573 |
-
allowedExtensions = ALLOWED_EXTENSIONS,
|
| 574 |
-
base = this.cdn,
|
| 575 |
-
extension = "webp",
|
| 576 |
-
size,
|
| 577 |
-
animated
|
| 578 |
-
} = {}) {
|
| 579 |
-
extension = String(extension).toLowerCase();
|
| 580 |
-
if (!allowedExtensions.includes(extension)) {
|
| 581 |
-
throw new RangeError(`Invalid extension provided: ${extension}
|
| 582 |
-
Must be one of: ${allowedExtensions.join(", ")}`);
|
| 583 |
-
}
|
| 584 |
-
if (size && !ALLOWED_SIZES.includes(size)) {
|
| 585 |
-
throw new RangeError(`Invalid size provided: ${size}
|
| 586 |
-
Must be one of: ${ALLOWED_SIZES.join(", ")}`);
|
| 587 |
-
}
|
| 588 |
-
const url = new URL(`${base}${route}.${extension}`);
|
| 589 |
-
if (animated !== void 0) {
|
| 590 |
-
url.searchParams.set("animated", String(animated));
|
| 591 |
-
}
|
| 592 |
-
if (size) {
|
| 593 |
-
url.searchParams.set("size", String(size));
|
| 594 |
-
}
|
| 595 |
-
return url.toString();
|
| 596 |
-
}
|
| 597 |
-
};
|
| 598 |
-
|
| 599 |
-
// src/lib/errors/DiscordAPIError.ts
|
| 600 |
-
function isErrorGroupWrapper(error) {
|
| 601 |
-
return Reflect.has(error, "_errors");
|
| 602 |
-
}
|
| 603 |
-
__name(isErrorGroupWrapper, "isErrorGroupWrapper");
|
| 604 |
-
function isErrorResponse(error) {
|
| 605 |
-
return typeof Reflect.get(error, "message") === "string";
|
| 606 |
-
}
|
| 607 |
-
__name(isErrorResponse, "isErrorResponse");
|
| 608 |
-
var DiscordAPIError = class _DiscordAPIError extends Error {
|
| 609 |
-
/**
|
| 610 |
-
* @param rawError - The error reported by Discord
|
| 611 |
-
* @param code - The error code reported by Discord
|
| 612 |
-
* @param status - The status code of the response
|
| 613 |
-
* @param method - The method of the request that erred
|
| 614 |
-
* @param url - The url of the request that erred
|
| 615 |
-
* @param bodyData - The unparsed data for the request that errored
|
| 616 |
-
*/
|
| 617 |
-
constructor(rawError, code, status, method, url, bodyData) {
|
| 618 |
-
super(_DiscordAPIError.getMessage(rawError));
|
| 619 |
-
this.rawError = rawError;
|
| 620 |
-
this.code = code;
|
| 621 |
-
this.status = status;
|
| 622 |
-
this.method = method;
|
| 623 |
-
this.url = url;
|
| 624 |
-
this.requestBody = { files: bodyData.files, json: bodyData.body };
|
| 625 |
-
}
|
| 626 |
-
static {
|
| 627 |
-
__name(this, "DiscordAPIError");
|
| 628 |
-
}
|
| 629 |
-
requestBody;
|
| 630 |
-
/**
|
| 631 |
-
* The name of the error
|
| 632 |
-
*/
|
| 633 |
-
get name() {
|
| 634 |
-
return `${_DiscordAPIError.name}[${this.code}]`;
|
| 635 |
-
}
|
| 636 |
-
static getMessage(error) {
|
| 637 |
-
let flattened = "";
|
| 638 |
-
if ("code" in error) {
|
| 639 |
-
if (error.errors) {
|
| 640 |
-
flattened = [...this.flattenDiscordError(error.errors)].join("\n");
|
| 641 |
-
}
|
| 642 |
-
return error.message && flattened ? `${error.message}
|
| 643 |
-
${flattened}` : error.message || flattened || "Unknown Error";
|
| 644 |
-
}
|
| 645 |
-
return error.error_description ?? "No Description";
|
| 646 |
-
}
|
| 647 |
-
static *flattenDiscordError(obj, key = "") {
|
| 648 |
-
if (isErrorResponse(obj)) {
|
| 649 |
-
return yield `${key.length ? `${key}[${obj.code}]` : `${obj.code}`}: ${obj.message}`.trim();
|
| 650 |
-
}
|
| 651 |
-
for (const [otherKey, val] of Object.entries(obj)) {
|
| 652 |
-
const nextKey = otherKey.startsWith("_") ? key : key ? Number.isNaN(Number(otherKey)) ? `${key}.${otherKey}` : `${key}[${otherKey}]` : otherKey;
|
| 653 |
-
if (typeof val === "string") {
|
| 654 |
-
yield val;
|
| 655 |
-
} else if (isErrorGroupWrapper(val)) {
|
| 656 |
-
for (const error of val._errors) {
|
| 657 |
-
yield* this.flattenDiscordError(error, nextKey);
|
| 658 |
-
}
|
| 659 |
-
} else {
|
| 660 |
-
yield* this.flattenDiscordError(val, nextKey);
|
| 661 |
-
}
|
| 662 |
-
}
|
| 663 |
-
}
|
| 664 |
-
};
|
| 665 |
-
|
| 666 |
-
// src/lib/errors/HTTPError.ts
|
| 667 |
-
var HTTPError = class _HTTPError extends Error {
|
| 668 |
-
/**
|
| 669 |
-
* @param status - The status code of the response
|
| 670 |
-
* @param statusText - The status text of the response
|
| 671 |
-
* @param method - The method of the request that erred
|
| 672 |
-
* @param url - The url of the request that erred
|
| 673 |
-
* @param bodyData - The unparsed data for the request that errored
|
| 674 |
-
*/
|
| 675 |
-
constructor(status, statusText, method, url, bodyData) {
|
| 676 |
-
super(statusText);
|
| 677 |
-
this.status = status;
|
| 678 |
-
this.method = method;
|
| 679 |
-
this.url = url;
|
| 680 |
-
this.requestBody = { files: bodyData.files, json: bodyData.body };
|
| 681 |
-
}
|
| 682 |
-
static {
|
| 683 |
-
__name(this, "HTTPError");
|
| 684 |
-
}
|
| 685 |
-
requestBody;
|
| 686 |
-
name = _HTTPError.name;
|
| 687 |
-
};
|
| 688 |
-
|
| 689 |
-
// src/lib/REST.ts
|
| 690 |
-
var import_collection = require("@discordjs/collection");
|
| 691 |
-
var import_snowflake = require("@sapphire/snowflake");
|
| 692 |
-
var import_async_event_emitter = require("@vladfrangu/async_event_emitter");
|
| 693 |
-
var import_magic_bytes = require("magic-bytes.js");
|
| 694 |
-
|
| 695 |
-
// src/lib/handlers/Shared.ts
|
| 696 |
-
var invalidCount = 0;
|
| 697 |
-
var invalidCountResetTime = null;
|
| 698 |
-
function incrementInvalidCount(manager) {
|
| 699 |
-
if (!invalidCountResetTime || invalidCountResetTime < Date.now()) {
|
| 700 |
-
invalidCountResetTime = Date.now() + 1e3 * 60 * 10;
|
| 701 |
-
invalidCount = 0;
|
| 702 |
-
}
|
| 703 |
-
invalidCount++;
|
| 704 |
-
const emitInvalid = manager.options.invalidRequestWarningInterval > 0 && invalidCount % manager.options.invalidRequestWarningInterval === 0;
|
| 705 |
-
if (emitInvalid) {
|
| 706 |
-
manager.emit("invalidRequestWarning" /* InvalidRequestWarning */, {
|
| 707 |
-
count: invalidCount,
|
| 708 |
-
remainingTime: invalidCountResetTime - Date.now()
|
| 709 |
-
});
|
| 710 |
-
}
|
| 711 |
-
}
|
| 712 |
-
__name(incrementInvalidCount, "incrementInvalidCount");
|
| 713 |
-
async function makeNetworkRequest(manager, routeId, url, options, requestData, retries) {
|
| 714 |
-
const controller = new AbortController();
|
| 715 |
-
const timeout = setTimeout(() => controller.abort(), manager.options.timeout);
|
| 716 |
-
if (requestData.signal) {
|
| 717 |
-
if (requestData.signal.aborted) controller.abort();
|
| 718 |
-
else requestData.signal.addEventListener("abort", () => controller.abort());
|
| 719 |
-
}
|
| 720 |
-
let res;
|
| 721 |
-
try {
|
| 722 |
-
res = await manager.options.makeRequest(url, { ...options, signal: controller.signal });
|
| 723 |
-
} catch (error) {
|
| 724 |
-
if (!(error instanceof Error)) throw error;
|
| 725 |
-
if (shouldRetry(error) && retries !== manager.options.retries) {
|
| 726 |
-
return null;
|
| 727 |
-
}
|
| 728 |
-
throw error;
|
| 729 |
-
} finally {
|
| 730 |
-
clearTimeout(timeout);
|
| 731 |
-
}
|
| 732 |
-
if (manager.listenerCount("response" /* Response */)) {
|
| 733 |
-
manager.emit(
|
| 734 |
-
"response" /* Response */,
|
| 735 |
-
{
|
| 736 |
-
method: options.method ?? "get",
|
| 737 |
-
path: routeId.original,
|
| 738 |
-
route: routeId.bucketRoute,
|
| 739 |
-
options,
|
| 740 |
-
data: requestData,
|
| 741 |
-
retries
|
| 742 |
-
},
|
| 743 |
-
res instanceof Response ? res.clone() : { ...res }
|
| 744 |
-
);
|
| 745 |
-
}
|
| 746 |
-
return res;
|
| 747 |
-
}
|
| 748 |
-
__name(makeNetworkRequest, "makeNetworkRequest");
|
| 749 |
-
async function handleErrors(manager, res, method, url, requestData, retries) {
|
| 750 |
-
const status = res.status;
|
| 751 |
-
if (status >= 500 && status < 600) {
|
| 752 |
-
if (retries !== manager.options.retries) {
|
| 753 |
-
return null;
|
| 754 |
-
}
|
| 755 |
-
throw new HTTPError(status, res.statusText, method, url, requestData);
|
| 756 |
-
} else {
|
| 757 |
-
if (status >= 400 && status < 500) {
|
| 758 |
-
if (status === 401 && requestData.auth) {
|
| 759 |
-
manager.setToken(null);
|
| 760 |
-
}
|
| 761 |
-
const data = await parseResponse(res);
|
| 762 |
-
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
|
| 763 |
-
}
|
| 764 |
-
return res;
|
| 765 |
-
}
|
| 766 |
-
}
|
| 767 |
-
__name(handleErrors, "handleErrors");
|
| 768 |
-
|
| 769 |
-
// src/lib/handlers/BurstHandler.ts
|
| 770 |
-
var BurstHandler = class {
|
| 771 |
-
/**
|
| 772 |
-
* @param manager - The request manager
|
| 773 |
-
* @param hash - The hash that this RequestHandler handles
|
| 774 |
-
* @param majorParameter - The major parameter for this handler
|
| 775 |
-
*/
|
| 776 |
-
constructor(manager, hash, majorParameter) {
|
| 777 |
-
this.manager = manager;
|
| 778 |
-
this.hash = hash;
|
| 779 |
-
this.majorParameter = majorParameter;
|
| 780 |
-
this.id = `${hash}:${majorParameter}`;
|
| 781 |
-
}
|
| 782 |
-
static {
|
| 783 |
-
__name(this, "BurstHandler");
|
| 784 |
-
}
|
| 785 |
-
/**
|
| 786 |
-
* {@inheritdoc IHandler.id}
|
| 787 |
-
*/
|
| 788 |
-
id;
|
| 789 |
-
/**
|
| 790 |
-
* {@inheritDoc IHandler.inactive}
|
| 791 |
-
*/
|
| 792 |
-
inactive = false;
|
| 793 |
-
/**
|
| 794 |
-
* Emits a debug message
|
| 795 |
-
*
|
| 796 |
-
* @param message - The message to debug
|
| 797 |
-
*/
|
| 798 |
-
debug(message) {
|
| 799 |
-
this.manager.emit("restDebug" /* Debug */, `[REST ${this.id}] ${message}`);
|
| 800 |
-
}
|
| 801 |
-
/**
|
| 802 |
-
* {@inheritDoc IHandler.queueRequest}
|
| 803 |
-
*/
|
| 804 |
-
async queueRequest(routeId, url, options, requestData) {
|
| 805 |
-
return this.runRequest(routeId, url, options, requestData);
|
| 806 |
-
}
|
| 807 |
-
/**
|
| 808 |
-
* The method that actually makes the request to the API, and updates info about the bucket accordingly
|
| 809 |
-
*
|
| 810 |
-
* @param routeId - The generalized API route with literal ids for major parameters
|
| 811 |
-
* @param url - The fully resolved URL to make the request to
|
| 812 |
-
* @param options - The fetch options needed to make the request
|
| 813 |
-
* @param requestData - Extra data from the user's request needed for errors and additional processing
|
| 814 |
-
* @param retries - The number of retries this request has already attempted (recursion)
|
| 815 |
-
*/
|
| 816 |
-
async runRequest(routeId, url, options, requestData, retries = 0) {
|
| 817 |
-
const method = options.method ?? "get";
|
| 818 |
-
const res = await makeNetworkRequest(this.manager, routeId, url, options, requestData, retries);
|
| 819 |
-
if (res === null) {
|
| 820 |
-
return this.runRequest(routeId, url, options, requestData, ++retries);
|
| 821 |
-
}
|
| 822 |
-
const status = res.status;
|
| 823 |
-
let retryAfter = 0;
|
| 824 |
-
const retry = res.headers.get("Retry-After");
|
| 825 |
-
const offset = normalizeRateLimitOffset(this.manager.options.offset, routeId.bucketRoute);
|
| 826 |
-
if (retry) retryAfter = Number(retry) * 1e3 + offset;
|
| 827 |
-
if (status === 401 || status === 403 || status === 429) {
|
| 828 |
-
incrementInvalidCount(this.manager);
|
| 829 |
-
}
|
| 830 |
-
if (status >= 200 && status < 300) {
|
| 831 |
-
return res;
|
| 832 |
-
} else if (status === 429) {
|
| 833 |
-
const isGlobal = res.headers.has("X-RateLimit-Global");
|
| 834 |
-
const scope = res.headers.get("X-RateLimit-Scope") ?? "user";
|
| 835 |
-
await onRateLimit(this.manager, {
|
| 836 |
-
global: isGlobal,
|
| 837 |
-
method,
|
| 838 |
-
url,
|
| 839 |
-
route: routeId.bucketRoute,
|
| 840 |
-
majorParameter: this.majorParameter,
|
| 841 |
-
hash: this.hash,
|
| 842 |
-
limit: Number.POSITIVE_INFINITY,
|
| 843 |
-
timeToReset: retryAfter,
|
| 844 |
-
retryAfter,
|
| 845 |
-
sublimitTimeout: 0,
|
| 846 |
-
scope
|
| 847 |
-
});
|
| 848 |
-
this.debug(
|
| 849 |
-
[
|
| 850 |
-
"Encountered unexpected 429 rate limit",
|
| 851 |
-
` Global : ${isGlobal}`,
|
| 852 |
-
` Method : ${method}`,
|
| 853 |
-
` URL : ${url}`,
|
| 854 |
-
` Bucket : ${routeId.bucketRoute}`,
|
| 855 |
-
` Major parameter: ${routeId.majorParameter}`,
|
| 856 |
-
` Hash : ${this.hash}`,
|
| 857 |
-
` Limit : ${Number.POSITIVE_INFINITY}`,
|
| 858 |
-
` Retry After : ${retryAfter}ms`,
|
| 859 |
-
` Sublimit : None`,
|
| 860 |
-
` Scope : ${scope}`
|
| 861 |
-
].join("\n")
|
| 862 |
-
);
|
| 863 |
-
await sleep(retryAfter);
|
| 864 |
-
return this.runRequest(routeId, url, options, requestData, retries);
|
| 865 |
-
} else {
|
| 866 |
-
const handled = await handleErrors(this.manager, res, method, url, requestData, retries);
|
| 867 |
-
if (handled === null) {
|
| 868 |
-
return this.runRequest(routeId, url, options, requestData, ++retries);
|
| 869 |
-
}
|
| 870 |
-
return handled;
|
| 871 |
-
}
|
| 872 |
-
}
|
| 873 |
-
};
|
| 874 |
-
|
| 875 |
-
// src/lib/handlers/SequentialHandler.ts
|
| 876 |
-
var import_async_queue = require("@sapphire/async-queue");
|
| 877 |
-
var SequentialHandler = class {
|
| 878 |
-
/**
|
| 879 |
-
* @param manager - The request manager
|
| 880 |
-
* @param hash - The hash that this RequestHandler handles
|
| 881 |
-
* @param majorParameter - The major parameter for this handler
|
| 882 |
-
*/
|
| 883 |
-
constructor(manager, hash, majorParameter) {
|
| 884 |
-
this.manager = manager;
|
| 885 |
-
this.hash = hash;
|
| 886 |
-
this.majorParameter = majorParameter;
|
| 887 |
-
this.id = `${hash}:${majorParameter}`;
|
| 888 |
-
}
|
| 889 |
-
static {
|
| 890 |
-
__name(this, "SequentialHandler");
|
| 891 |
-
}
|
| 892 |
-
/**
|
| 893 |
-
* {@inheritDoc IHandler.id}
|
| 894 |
-
*/
|
| 895 |
-
id;
|
| 896 |
-
/**
|
| 897 |
-
* The time this rate limit bucket will reset
|
| 898 |
-
*/
|
| 899 |
-
reset = -1;
|
| 900 |
-
/**
|
| 901 |
-
* The remaining requests that can be made before we are rate limited
|
| 902 |
-
*/
|
| 903 |
-
remaining = 1;
|
| 904 |
-
/**
|
| 905 |
-
* The total number of requests that can be made before we are rate limited
|
| 906 |
-
*/
|
| 907 |
-
limit = Number.POSITIVE_INFINITY;
|
| 908 |
-
/**
|
| 909 |
-
* The interface used to sequence async requests sequentially
|
| 910 |
-
*/
|
| 911 |
-
#asyncQueue = new import_async_queue.AsyncQueue();
|
| 912 |
-
/**
|
| 913 |
-
* The interface used to sequence sublimited async requests sequentially
|
| 914 |
-
*/
|
| 915 |
-
#sublimitedQueue = null;
|
| 916 |
-
/**
|
| 917 |
-
* A promise wrapper for when the sublimited queue is finished being processed or null when not being processed
|
| 918 |
-
*/
|
| 919 |
-
#sublimitPromise = null;
|
| 920 |
-
/**
|
| 921 |
-
* Whether the sublimit queue needs to be shifted in the finally block
|
| 922 |
-
*/
|
| 923 |
-
#shiftSublimit = false;
|
| 924 |
-
/**
|
| 925 |
-
* {@inheritDoc IHandler.inactive}
|
| 926 |
-
*/
|
| 927 |
-
get inactive() {
|
| 928 |
-
return this.#asyncQueue.remaining === 0 && (this.#sublimitedQueue === null || this.#sublimitedQueue.remaining === 0) && !this.limited;
|
| 929 |
-
}
|
| 930 |
-
/**
|
| 931 |
-
* If the rate limit bucket is currently limited by the global limit
|
| 932 |
-
*/
|
| 933 |
-
get globalLimited() {
|
| 934 |
-
return this.manager.globalRemaining <= 0 && Date.now() < this.manager.globalReset;
|
| 935 |
-
}
|
| 936 |
-
/**
|
| 937 |
-
* If the rate limit bucket is currently limited by its limit
|
| 938 |
-
*/
|
| 939 |
-
get localLimited() {
|
| 940 |
-
return this.remaining <= 0 && Date.now() < this.reset;
|
| 941 |
-
}
|
| 942 |
-
/**
|
| 943 |
-
* If the rate limit bucket is currently limited
|
| 944 |
-
*/
|
| 945 |
-
get limited() {
|
| 946 |
-
return this.globalLimited || this.localLimited;
|
| 947 |
-
}
|
| 948 |
-
/**
|
| 949 |
-
* The time until queued requests can continue
|
| 950 |
-
*/
|
| 951 |
-
getTimeToReset(routeId) {
|
| 952 |
-
const offset = normalizeRateLimitOffset(this.manager.options.offset, routeId.bucketRoute);
|
| 953 |
-
return this.reset + offset - Date.now();
|
| 954 |
-
}
|
| 955 |
-
/**
|
| 956 |
-
* Emits a debug message
|
| 957 |
-
*
|
| 958 |
-
* @param message - The message to debug
|
| 959 |
-
*/
|
| 960 |
-
debug(message) {
|
| 961 |
-
this.manager.emit("restDebug" /* Debug */, `[REST ${this.id}] ${message}`);
|
| 962 |
-
}
|
| 963 |
-
/**
|
| 964 |
-
* Delay all requests for the specified amount of time, handling global rate limits
|
| 965 |
-
*
|
| 966 |
-
* @param time - The amount of time to delay all requests for
|
| 967 |
-
*/
|
| 968 |
-
async globalDelayFor(time) {
|
| 969 |
-
await sleep(time);
|
| 970 |
-
this.manager.globalDelay = null;
|
| 971 |
-
}
|
| 972 |
-
/**
|
| 973 |
-
* {@inheritDoc IHandler.queueRequest}
|
| 974 |
-
*/
|
| 975 |
-
async queueRequest(routeId, url, options, requestData) {
|
| 976 |
-
let queue = this.#asyncQueue;
|
| 977 |
-
let queueType = 0 /* Standard */;
|
| 978 |
-
if (this.#sublimitedQueue && hasSublimit(routeId.bucketRoute, requestData.body, options.method)) {
|
| 979 |
-
queue = this.#sublimitedQueue;
|
| 980 |
-
queueType = 1 /* Sublimit */;
|
| 981 |
-
}
|
| 982 |
-
await queue.wait({ signal: requestData.signal });
|
| 983 |
-
if (queueType === 0 /* Standard */) {
|
| 984 |
-
if (this.#sublimitedQueue && hasSublimit(routeId.bucketRoute, requestData.body, options.method)) {
|
| 985 |
-
queue = this.#sublimitedQueue;
|
| 986 |
-
const wait = queue.wait();
|
| 987 |
-
this.#asyncQueue.shift();
|
| 988 |
-
await wait;
|
| 989 |
-
} else if (this.#sublimitPromise) {
|
| 990 |
-
await this.#sublimitPromise.promise;
|
| 991 |
-
}
|
| 992 |
-
}
|
| 993 |
-
try {
|
| 994 |
-
return await this.runRequest(routeId, url, options, requestData);
|
| 995 |
-
} finally {
|
| 996 |
-
queue.shift();
|
| 997 |
-
if (this.#shiftSublimit) {
|
| 998 |
-
this.#shiftSublimit = false;
|
| 999 |
-
this.#sublimitedQueue?.shift();
|
| 1000 |
-
}
|
| 1001 |
-
if (this.#sublimitedQueue?.remaining === 0) {
|
| 1002 |
-
this.#sublimitPromise?.resolve();
|
| 1003 |
-
this.#sublimitedQueue = null;
|
| 1004 |
-
}
|
| 1005 |
-
}
|
| 1006 |
-
}
|
| 1007 |
-
/**
|
| 1008 |
-
* The method that actually makes the request to the api, and updates info about the bucket accordingly
|
| 1009 |
-
*
|
| 1010 |
-
* @param routeId - The generalized api route with literal ids for major parameters
|
| 1011 |
-
* @param url - The fully resolved url to make the request to
|
| 1012 |
-
* @param options - The fetch options needed to make the request
|
| 1013 |
-
* @param requestData - Extra data from the user's request needed for errors and additional processing
|
| 1014 |
-
* @param retries - The number of retries this request has already attempted (recursion)
|
| 1015 |
-
*/
|
| 1016 |
-
async runRequest(routeId, url, options, requestData, retries = 0) {
|
| 1017 |
-
while (this.limited) {
|
| 1018 |
-
const isGlobal = this.globalLimited;
|
| 1019 |
-
let limit2;
|
| 1020 |
-
let timeout;
|
| 1021 |
-
let delay;
|
| 1022 |
-
if (isGlobal) {
|
| 1023 |
-
const offset2 = normalizeRateLimitOffset(this.manager.options.offset, routeId.bucketRoute);
|
| 1024 |
-
limit2 = this.manager.options.globalRequestsPerSecond;
|
| 1025 |
-
timeout = this.manager.globalReset + offset2 - Date.now();
|
| 1026 |
-
if (!this.manager.globalDelay) {
|
| 1027 |
-
this.manager.globalDelay = this.globalDelayFor(timeout);
|
| 1028 |
-
}
|
| 1029 |
-
delay = this.manager.globalDelay;
|
| 1030 |
-
} else {
|
| 1031 |
-
limit2 = this.limit;
|
| 1032 |
-
timeout = this.getTimeToReset(routeId);
|
| 1033 |
-
delay = sleep(timeout);
|
| 1034 |
-
}
|
| 1035 |
-
const rateLimitData = {
|
| 1036 |
-
global: isGlobal,
|
| 1037 |
-
method: options.method ?? "get",
|
| 1038 |
-
url,
|
| 1039 |
-
route: routeId.bucketRoute,
|
| 1040 |
-
majorParameter: this.majorParameter,
|
| 1041 |
-
hash: this.hash,
|
| 1042 |
-
limit: limit2,
|
| 1043 |
-
timeToReset: timeout,
|
| 1044 |
-
retryAfter: timeout,
|
| 1045 |
-
sublimitTimeout: 0,
|
| 1046 |
-
scope: "user"
|
| 1047 |
-
};
|
| 1048 |
-
this.manager.emit("rateLimited" /* RateLimited */, rateLimitData);
|
| 1049 |
-
await onRateLimit(this.manager, rateLimitData);
|
| 1050 |
-
if (isGlobal) {
|
| 1051 |
-
this.debug(`Global rate limit hit, blocking all requests for ${timeout}ms`);
|
| 1052 |
-
} else {
|
| 1053 |
-
this.debug(`Waiting ${timeout}ms for rate limit to pass`);
|
| 1054 |
-
}
|
| 1055 |
-
await delay;
|
| 1056 |
-
}
|
| 1057 |
-
if (!this.manager.globalReset || this.manager.globalReset < Date.now()) {
|
| 1058 |
-
this.manager.globalReset = Date.now() + 1e3;
|
| 1059 |
-
this.manager.globalRemaining = this.manager.options.globalRequestsPerSecond;
|
| 1060 |
-
}
|
| 1061 |
-
this.manager.globalRemaining--;
|
| 1062 |
-
const method = options.method ?? "get";
|
| 1063 |
-
const res = await makeNetworkRequest(this.manager, routeId, url, options, requestData, retries);
|
| 1064 |
-
if (res === null) {
|
| 1065 |
-
return this.runRequest(routeId, url, options, requestData, ++retries);
|
| 1066 |
-
}
|
| 1067 |
-
const status = res.status;
|
| 1068 |
-
let retryAfter = 0;
|
| 1069 |
-
const limit = res.headers.get("X-RateLimit-Limit");
|
| 1070 |
-
const remaining = res.headers.get("X-RateLimit-Remaining");
|
| 1071 |
-
const reset = res.headers.get("X-RateLimit-Reset-After");
|
| 1072 |
-
const hash = res.headers.get("X-RateLimit-Bucket");
|
| 1073 |
-
const retry = res.headers.get("Retry-After");
|
| 1074 |
-
const scope = res.headers.get("X-RateLimit-Scope") ?? "user";
|
| 1075 |
-
const offset = normalizeRateLimitOffset(this.manager.options.offset, routeId.bucketRoute);
|
| 1076 |
-
this.limit = limit ? Number(limit) : Number.POSITIVE_INFINITY;
|
| 1077 |
-
this.remaining = remaining ? Number(remaining) : 1;
|
| 1078 |
-
this.reset = reset ? Number(reset) * 1e3 + Date.now() + offset : Date.now();
|
| 1079 |
-
if (retry) retryAfter = Number(retry) * 1e3 + offset;
|
| 1080 |
-
if (hash && hash !== this.hash) {
|
| 1081 |
-
this.debug(["Received bucket hash update", ` Old Hash : ${this.hash}`, ` New Hash : ${hash}`].join("\n"));
|
| 1082 |
-
this.manager.hashes.set(`${method}:${routeId.bucketRoute}`, { value: hash, lastAccess: Date.now() });
|
| 1083 |
-
} else if (hash) {
|
| 1084 |
-
const hashData = this.manager.hashes.get(`${method}:${routeId.bucketRoute}`);
|
| 1085 |
-
if (hashData) {
|
| 1086 |
-
hashData.lastAccess = Date.now();
|
| 1087 |
-
}
|
| 1088 |
-
}
|
| 1089 |
-
let sublimitTimeout = null;
|
| 1090 |
-
if (retryAfter > 0) {
|
| 1091 |
-
if (res.headers.has("X-RateLimit-Global")) {
|
| 1092 |
-
this.manager.globalRemaining = 0;
|
| 1093 |
-
this.manager.globalReset = Date.now() + retryAfter;
|
| 1094 |
-
} else if (!this.localLimited) {
|
| 1095 |
-
sublimitTimeout = retryAfter;
|
| 1096 |
-
}
|
| 1097 |
-
}
|
| 1098 |
-
if (status === 401 || status === 403 || status === 429) {
|
| 1099 |
-
incrementInvalidCount(this.manager);
|
| 1100 |
-
}
|
| 1101 |
-
if (res.ok) {
|
| 1102 |
-
return res;
|
| 1103 |
-
} else if (status === 429) {
|
| 1104 |
-
const isGlobal = this.globalLimited;
|
| 1105 |
-
let limit2;
|
| 1106 |
-
let timeout;
|
| 1107 |
-
if (isGlobal) {
|
| 1108 |
-
const offset2 = normalizeRateLimitOffset(this.manager.options.offset, routeId.bucketRoute);
|
| 1109 |
-
limit2 = this.manager.options.globalRequestsPerSecond;
|
| 1110 |
-
timeout = this.manager.globalReset + offset2 - Date.now();
|
| 1111 |
-
} else {
|
| 1112 |
-
limit2 = this.limit;
|
| 1113 |
-
timeout = this.getTimeToReset(routeId);
|
| 1114 |
-
}
|
| 1115 |
-
await onRateLimit(this.manager, {
|
| 1116 |
-
global: isGlobal,
|
| 1117 |
-
method,
|
| 1118 |
-
url,
|
| 1119 |
-
route: routeId.bucketRoute,
|
| 1120 |
-
majorParameter: this.majorParameter,
|
| 1121 |
-
hash: this.hash,
|
| 1122 |
-
limit: limit2,
|
| 1123 |
-
timeToReset: timeout,
|
| 1124 |
-
retryAfter,
|
| 1125 |
-
sublimitTimeout: sublimitTimeout ?? 0,
|
| 1126 |
-
scope
|
| 1127 |
-
});
|
| 1128 |
-
this.debug(
|
| 1129 |
-
[
|
| 1130 |
-
"Encountered unexpected 429 rate limit",
|
| 1131 |
-
` Global : ${isGlobal.toString()}`,
|
| 1132 |
-
` Method : ${method}`,
|
| 1133 |
-
` URL : ${url}`,
|
| 1134 |
-
` Bucket : ${routeId.bucketRoute}`,
|
| 1135 |
-
` Major parameter: ${routeId.majorParameter}`,
|
| 1136 |
-
` Hash : ${this.hash}`,
|
| 1137 |
-
` Limit : ${limit2}`,
|
| 1138 |
-
` Retry After : ${retryAfter}ms`,
|
| 1139 |
-
` Sublimit : ${sublimitTimeout ? `${sublimitTimeout}ms` : "None"}`,
|
| 1140 |
-
` Scope : ${scope}`
|
| 1141 |
-
].join("\n")
|
| 1142 |
-
);
|
| 1143 |
-
if (sublimitTimeout) {
|
| 1144 |
-
const firstSublimit = !this.#sublimitedQueue;
|
| 1145 |
-
if (firstSublimit) {
|
| 1146 |
-
this.#sublimitedQueue = new import_async_queue.AsyncQueue();
|
| 1147 |
-
void this.#sublimitedQueue.wait();
|
| 1148 |
-
this.#asyncQueue.shift();
|
| 1149 |
-
}
|
| 1150 |
-
this.#sublimitPromise?.resolve();
|
| 1151 |
-
this.#sublimitPromise = null;
|
| 1152 |
-
await sleep(sublimitTimeout);
|
| 1153 |
-
let resolve;
|
| 1154 |
-
const promise = new Promise((res2) => resolve = res2);
|
| 1155 |
-
this.#sublimitPromise = { promise, resolve };
|
| 1156 |
-
if (firstSublimit) {
|
| 1157 |
-
await this.#asyncQueue.wait();
|
| 1158 |
-
this.#shiftSublimit = true;
|
| 1159 |
-
}
|
| 1160 |
-
}
|
| 1161 |
-
return this.runRequest(routeId, url, options, requestData, retries);
|
| 1162 |
-
} else {
|
| 1163 |
-
const handled = await handleErrors(this.manager, res, method, url, requestData, retries);
|
| 1164 |
-
if (handled === null) {
|
| 1165 |
-
return this.runRequest(routeId, url, options, requestData, ++retries);
|
| 1166 |
-
}
|
| 1167 |
-
return handled;
|
| 1168 |
-
}
|
| 1169 |
-
}
|
| 1170 |
-
};
|
| 1171 |
-
|
| 1172 |
-
// src/lib/REST.ts
|
| 1173 |
-
var REST = class _REST extends import_async_event_emitter.AsyncEventEmitter {
|
| 1174 |
-
static {
|
| 1175 |
-
__name(this, "REST");
|
| 1176 |
-
}
|
| 1177 |
-
/**
|
| 1178 |
-
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} for all requests
|
| 1179 |
-
* performed by this manager.
|
| 1180 |
-
*/
|
| 1181 |
-
agent = null;
|
| 1182 |
-
cdn;
|
| 1183 |
-
/**
|
| 1184 |
-
* The number of requests remaining in the global bucket
|
| 1185 |
-
*/
|
| 1186 |
-
globalRemaining;
|
| 1187 |
-
/**
|
| 1188 |
-
* The promise used to wait out the global rate limit
|
| 1189 |
-
*/
|
| 1190 |
-
globalDelay = null;
|
| 1191 |
-
/**
|
| 1192 |
-
* The timestamp at which the global bucket resets
|
| 1193 |
-
*/
|
| 1194 |
-
globalReset = -1;
|
| 1195 |
-
/**
|
| 1196 |
-
* API bucket hashes that are cached from provided routes
|
| 1197 |
-
*/
|
| 1198 |
-
hashes = new import_collection.Collection();
|
| 1199 |
-
/**
|
| 1200 |
-
* Request handlers created from the bucket hash and the major parameters
|
| 1201 |
-
*/
|
| 1202 |
-
handlers = new import_collection.Collection();
|
| 1203 |
-
#token = null;
|
| 1204 |
-
hashTimer;
|
| 1205 |
-
handlerTimer;
|
| 1206 |
-
options;
|
| 1207 |
-
constructor(options = {}) {
|
| 1208 |
-
super();
|
| 1209 |
-
this.cdn = new CDN(options.cdn ?? DefaultRestOptions.cdn, options.mediaProxy ?? DefaultRestOptions.mediaProxy);
|
| 1210 |
-
this.options = { ...DefaultRestOptions, ...options };
|
| 1211 |
-
this.globalRemaining = Math.max(1, this.options.globalRequestsPerSecond);
|
| 1212 |
-
this.agent = options.agent ?? null;
|
| 1213 |
-
this.setupSweepers();
|
| 1214 |
-
}
|
| 1215 |
-
setupSweepers() {
|
| 1216 |
-
const validateMaxInterval = /* @__PURE__ */ __name((interval) => {
|
| 1217 |
-
if (interval > 144e5) {
|
| 1218 |
-
throw new Error("Cannot set an interval greater than 4 hours");
|
| 1219 |
-
}
|
| 1220 |
-
}, "validateMaxInterval");
|
| 1221 |
-
if (this.options.hashSweepInterval !== 0 && this.options.hashSweepInterval !== Number.POSITIVE_INFINITY) {
|
| 1222 |
-
validateMaxInterval(this.options.hashSweepInterval);
|
| 1223 |
-
this.hashTimer = setInterval(() => {
|
| 1224 |
-
const sweptHashes = new import_collection.Collection();
|
| 1225 |
-
const currentDate = Date.now();
|
| 1226 |
-
this.hashes.sweep((val, key) => {
|
| 1227 |
-
if (val.lastAccess === -1) return false;
|
| 1228 |
-
const shouldSweep = Math.floor(currentDate - val.lastAccess) > this.options.hashLifetime;
|
| 1229 |
-
if (shouldSweep) {
|
| 1230 |
-
sweptHashes.set(key, val);
|
| 1231 |
-
this.emit("restDebug" /* Debug */, `Hash ${val.value} for ${key} swept due to lifetime being exceeded`);
|
| 1232 |
-
}
|
| 1233 |
-
return shouldSweep;
|
| 1234 |
-
});
|
| 1235 |
-
this.emit("hashSweep" /* HashSweep */, sweptHashes);
|
| 1236 |
-
}, this.options.hashSweepInterval);
|
| 1237 |
-
this.hashTimer.unref?.();
|
| 1238 |
-
}
|
| 1239 |
-
if (this.options.handlerSweepInterval !== 0 && this.options.handlerSweepInterval !== Number.POSITIVE_INFINITY) {
|
| 1240 |
-
validateMaxInterval(this.options.handlerSweepInterval);
|
| 1241 |
-
this.handlerTimer = setInterval(() => {
|
| 1242 |
-
const sweptHandlers = new import_collection.Collection();
|
| 1243 |
-
this.handlers.sweep((val, key) => {
|
| 1244 |
-
const { inactive } = val;
|
| 1245 |
-
if (inactive) {
|
| 1246 |
-
sweptHandlers.set(key, val);
|
| 1247 |
-
this.emit("restDebug" /* Debug */, `Handler ${val.id} for ${key} swept due to being inactive`);
|
| 1248 |
-
}
|
| 1249 |
-
return inactive;
|
| 1250 |
-
});
|
| 1251 |
-
this.emit("handlerSweep" /* HandlerSweep */, sweptHandlers);
|
| 1252 |
-
}, this.options.handlerSweepInterval);
|
| 1253 |
-
this.handlerTimer.unref?.();
|
| 1254 |
-
}
|
| 1255 |
-
}
|
| 1256 |
-
/**
|
| 1257 |
-
* Runs a get request from the api
|
| 1258 |
-
*
|
| 1259 |
-
* @param fullRoute - The full route to query
|
| 1260 |
-
* @param options - Optional request options
|
| 1261 |
-
*/
|
| 1262 |
-
async get(fullRoute, options = {}) {
|
| 1263 |
-
return this.request({ ...options, fullRoute, method: "GET" /* Get */ });
|
| 1264 |
-
}
|
| 1265 |
-
/**
|
| 1266 |
-
* Runs a delete request from the api
|
| 1267 |
-
*
|
| 1268 |
-
* @param fullRoute - The full route to query
|
| 1269 |
-
* @param options - Optional request options
|
| 1270 |
-
*/
|
| 1271 |
-
async delete(fullRoute, options = {}) {
|
| 1272 |
-
return this.request({ ...options, fullRoute, method: "DELETE" /* Delete */ });
|
| 1273 |
-
}
|
| 1274 |
-
/**
|
| 1275 |
-
* Runs a post request from the api
|
| 1276 |
-
*
|
| 1277 |
-
* @param fullRoute - The full route to query
|
| 1278 |
-
* @param options - Optional request options
|
| 1279 |
-
*/
|
| 1280 |
-
async post(fullRoute, options = {}) {
|
| 1281 |
-
return this.request({ ...options, fullRoute, method: "POST" /* Post */ });
|
| 1282 |
-
}
|
| 1283 |
-
/**
|
| 1284 |
-
* Runs a put request from the api
|
| 1285 |
-
*
|
| 1286 |
-
* @param fullRoute - The full route to query
|
| 1287 |
-
* @param options - Optional request options
|
| 1288 |
-
*/
|
| 1289 |
-
async put(fullRoute, options = {}) {
|
| 1290 |
-
return this.request({ ...options, fullRoute, method: "PUT" /* Put */ });
|
| 1291 |
-
}
|
| 1292 |
-
/**
|
| 1293 |
-
* Runs a patch request from the api
|
| 1294 |
-
*
|
| 1295 |
-
* @param fullRoute - The full route to query
|
| 1296 |
-
* @param options - Optional request options
|
| 1297 |
-
*/
|
| 1298 |
-
async patch(fullRoute, options = {}) {
|
| 1299 |
-
return this.request({ ...options, fullRoute, method: "PATCH" /* Patch */ });
|
| 1300 |
-
}
|
| 1301 |
-
/**
|
| 1302 |
-
* Runs a request from the api
|
| 1303 |
-
*
|
| 1304 |
-
* @param options - Request options
|
| 1305 |
-
*/
|
| 1306 |
-
async request(options) {
|
| 1307 |
-
const response = await this.queueRequest(options);
|
| 1308 |
-
return parseResponse(response);
|
| 1309 |
-
}
|
| 1310 |
-
/**
|
| 1311 |
-
* Sets the default agent to use for requests performed by this manager
|
| 1312 |
-
*
|
| 1313 |
-
* @param agent - The agent to use
|
| 1314 |
-
*/
|
| 1315 |
-
setAgent(agent) {
|
| 1316 |
-
this.agent = agent;
|
| 1317 |
-
return this;
|
| 1318 |
-
}
|
| 1319 |
-
/**
|
| 1320 |
-
* Sets the authorization token that should be used for requests
|
| 1321 |
-
*
|
| 1322 |
-
* @param token - The authorization token to use
|
| 1323 |
-
*/
|
| 1324 |
-
setToken(token) {
|
| 1325 |
-
this.#token = token;
|
| 1326 |
-
return this;
|
| 1327 |
-
}
|
| 1328 |
-
/**
|
| 1329 |
-
* Queues a request to be sent
|
| 1330 |
-
*
|
| 1331 |
-
* @param request - All the information needed to make a request
|
| 1332 |
-
* @returns The response from the api request
|
| 1333 |
-
*/
|
| 1334 |
-
async queueRequest(request2) {
|
| 1335 |
-
const routeId = _REST.generateRouteData(request2.fullRoute, request2.method);
|
| 1336 |
-
const hash = this.hashes.get(`${request2.method}:${routeId.bucketRoute}`) ?? {
|
| 1337 |
-
value: `Global(${request2.method}:${routeId.bucketRoute})`,
|
| 1338 |
-
lastAccess: -1
|
| 1339 |
-
};
|
| 1340 |
-
const handler = this.handlers.get(`${hash.value}:${routeId.majorParameter}`) ?? this.createHandler(hash.value, routeId.majorParameter);
|
| 1341 |
-
const { url, fetchOptions } = await this.resolveRequest(request2);
|
| 1342 |
-
return handler.queueRequest(routeId, url, fetchOptions, {
|
| 1343 |
-
body: request2.body,
|
| 1344 |
-
files: request2.files,
|
| 1345 |
-
auth: request2.auth !== false,
|
| 1346 |
-
signal: request2.signal
|
| 1347 |
-
});
|
| 1348 |
-
}
|
| 1349 |
-
/**
|
| 1350 |
-
* Creates a new rate limit handler from a hash, based on the hash and the major parameter
|
| 1351 |
-
*
|
| 1352 |
-
* @param hash - The hash for the route
|
| 1353 |
-
* @param majorParameter - The major parameter for this handler
|
| 1354 |
-
* @internal
|
| 1355 |
-
*/
|
| 1356 |
-
createHandler(hash, majorParameter) {
|
| 1357 |
-
const queue = majorParameter === BurstHandlerMajorIdKey ? new BurstHandler(this, hash, majorParameter) : new SequentialHandler(this, hash, majorParameter);
|
| 1358 |
-
this.handlers.set(queue.id, queue);
|
| 1359 |
-
return queue;
|
| 1360 |
-
}
|
| 1361 |
-
/**
|
| 1362 |
-
* Formats the request data to a usable format for fetch
|
| 1363 |
-
*
|
| 1364 |
-
* @param request - The request data
|
| 1365 |
-
*/
|
| 1366 |
-
async resolveRequest(request2) {
|
| 1367 |
-
const { options } = this;
|
| 1368 |
-
let query = "";
|
| 1369 |
-
if (request2.query) {
|
| 1370 |
-
const resolvedQuery = request2.query.toString();
|
| 1371 |
-
if (resolvedQuery !== "") {
|
| 1372 |
-
query = `?${resolvedQuery}`;
|
| 1373 |
-
}
|
| 1374 |
-
}
|
| 1375 |
-
const headers = {
|
| 1376 |
-
...this.options.headers,
|
| 1377 |
-
"User-Agent": `${DefaultUserAgent} ${options.userAgentAppendix}`.trim()
|
| 1378 |
-
};
|
| 1379 |
-
if (request2.auth !== false) {
|
| 1380 |
-
if (!this.#token) {
|
| 1381 |
-
throw new Error("Expected token to be set for this request, but none was present");
|
| 1382 |
-
}
|
| 1383 |
-
headers.Authorization = `${request2.authPrefix ?? this.options.authPrefix} ${this.#token}`;
|
| 1384 |
-
}
|
| 1385 |
-
if (request2.reason?.length) {
|
| 1386 |
-
headers["X-Audit-Log-Reason"] = encodeURIComponent(request2.reason);
|
| 1387 |
-
}
|
| 1388 |
-
const url = `${options.api}${request2.versioned === false ? "" : `/v${options.version}`}${request2.fullRoute}${query}`;
|
| 1389 |
-
let finalBody;
|
| 1390 |
-
let additionalHeaders = {};
|
| 1391 |
-
if (request2.files?.length) {
|
| 1392 |
-
const formData = new FormData();
|
| 1393 |
-
for (const [index, file] of request2.files.entries()) {
|
| 1394 |
-
const fileKey = file.key ?? `files[${index}]`;
|
| 1395 |
-
if (isBufferLike(file.data)) {
|
| 1396 |
-
let contentType = file.contentType;
|
| 1397 |
-
if (!contentType) {
|
| 1398 |
-
const [parsedType] = (0, import_magic_bytes.filetypeinfo)(file.data);
|
| 1399 |
-
if (parsedType) {
|
| 1400 |
-
contentType = OverwrittenMimeTypes[parsedType.mime] ?? parsedType.mime ?? "application/octet-stream";
|
| 1401 |
-
}
|
| 1402 |
-
}
|
| 1403 |
-
formData.append(fileKey, new Blob([file.data], { type: contentType }), file.name);
|
| 1404 |
-
} else {
|
| 1405 |
-
formData.append(fileKey, new Blob([`${file.data}`], { type: file.contentType }), file.name);
|
| 1406 |
-
}
|
| 1407 |
-
}
|
| 1408 |
-
if (request2.body != null) {
|
| 1409 |
-
if (request2.appendToFormData) {
|
| 1410 |
-
for (const [key, value] of Object.entries(request2.body)) {
|
| 1411 |
-
formData.append(key, value);
|
| 1412 |
-
}
|
| 1413 |
-
} else {
|
| 1414 |
-
formData.append("payload_json", JSON.stringify(request2.body));
|
| 1415 |
-
}
|
| 1416 |
-
}
|
| 1417 |
-
finalBody = formData;
|
| 1418 |
-
} else if (request2.body != null) {
|
| 1419 |
-
if (request2.passThroughBody) {
|
| 1420 |
-
finalBody = request2.body;
|
| 1421 |
-
} else {
|
| 1422 |
-
finalBody = JSON.stringify(request2.body);
|
| 1423 |
-
additionalHeaders = { "Content-Type": "application/json" };
|
| 1424 |
-
}
|
| 1425 |
-
}
|
| 1426 |
-
const method = request2.method.toUpperCase();
|
| 1427 |
-
const fetchOptions = {
|
| 1428 |
-
// 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
|
| 1429 |
-
body: ["GET", "HEAD"].includes(method) ? null : finalBody,
|
| 1430 |
-
headers: { ...request2.headers, ...additionalHeaders, ...headers },
|
| 1431 |
-
method,
|
| 1432 |
-
// Prioritize setting an agent per request, use the agent for this instance otherwise.
|
| 1433 |
-
dispatcher: request2.dispatcher ?? this.agent ?? void 0
|
| 1434 |
-
};
|
| 1435 |
-
return { url, fetchOptions };
|
| 1436 |
-
}
|
| 1437 |
-
/**
|
| 1438 |
-
* Stops the hash sweeping interval
|
| 1439 |
-
*/
|
| 1440 |
-
clearHashSweeper() {
|
| 1441 |
-
clearInterval(this.hashTimer);
|
| 1442 |
-
}
|
| 1443 |
-
/**
|
| 1444 |
-
* Stops the request handler sweeping interval
|
| 1445 |
-
*/
|
| 1446 |
-
clearHandlerSweeper() {
|
| 1447 |
-
clearInterval(this.handlerTimer);
|
| 1448 |
-
}
|
| 1449 |
-
/**
|
| 1450 |
-
* Generates route data for an endpoint:method
|
| 1451 |
-
*
|
| 1452 |
-
* @param endpoint - The raw endpoint to generalize
|
| 1453 |
-
* @param method - The HTTP method this endpoint is called without
|
| 1454 |
-
* @internal
|
| 1455 |
-
*/
|
| 1456 |
-
static generateRouteData(endpoint, method) {
|
| 1457 |
-
if (endpoint.startsWith("/interactions/") && endpoint.endsWith("/callback")) {
|
| 1458 |
-
return {
|
| 1459 |
-
majorParameter: BurstHandlerMajorIdKey,
|
| 1460 |
-
bucketRoute: "/interactions/:id/:token/callback",
|
| 1461 |
-
original: endpoint
|
| 1462 |
-
};
|
| 1463 |
-
}
|
| 1464 |
-
const majorIdMatch = /(?:^\/webhooks\/(\d{17,19}\/[^/?]+))|(?:^\/(?:channels|guilds|webhooks)\/(\d{17,19}))/.exec(
|
| 1465 |
-
endpoint
|
| 1466 |
-
);
|
| 1467 |
-
const majorId = majorIdMatch?.[2] ?? majorIdMatch?.[1] ?? "global";
|
| 1468 |
-
const baseRoute = endpoint.replaceAll(/\d{17,19}/g, ":id").replace(/\/reactions\/(.*)/, "/reactions/:reaction").replace(/\/webhooks\/:id\/[^/?]+/, "/webhooks/:id/:token");
|
| 1469 |
-
let exceptions = "";
|
| 1470 |
-
if (method === "DELETE" /* Delete */ && baseRoute === "/channels/:id/messages/:id") {
|
| 1471 |
-
const id = /\d{17,19}$/.exec(endpoint)[0];
|
| 1472 |
-
const timestamp = import_snowflake.DiscordSnowflake.timestampFrom(id);
|
| 1473 |
-
if (Date.now() - timestamp > 1e3 * 60 * 60 * 24 * 14) {
|
| 1474 |
-
exceptions += "/Delete Old Message";
|
| 1475 |
-
}
|
| 1476 |
-
}
|
| 1477 |
-
return {
|
| 1478 |
-
majorParameter: majorId,
|
| 1479 |
-
bucketRoute: baseRoute + exceptions,
|
| 1480 |
-
original: endpoint
|
| 1481 |
-
};
|
| 1482 |
-
}
|
| 1483 |
-
};
|
| 1484 |
-
|
| 1485 |
-
// src/shared.ts
|
| 1486 |
-
var version = "2.6.0";
|
| 1487 |
-
|
| 1488 |
-
// src/index.ts
|
| 1489 |
-
globalThis.FormData ??= import_undici2.FormData;
|
| 1490 |
-
globalThis.Blob ??= import_node_buffer.Blob;
|
| 1491 |
-
setDefaultStrategy((0, import_util2.shouldUseGlobalFetchAndWebSocket)() ? fetch : makeRequest);
|
| 1492 |
-
// Annotate the CommonJS export names for ESM import in node:
|
| 1493 |
-
0 && (module.exports = {
|
| 1494 |
-
ALLOWED_EXTENSIONS,
|
| 1495 |
-
ALLOWED_SIZES,
|
| 1496 |
-
ALLOWED_STICKER_EXTENSIONS,
|
| 1497 |
-
BurstHandlerMajorIdKey,
|
| 1498 |
-
CDN,
|
| 1499 |
-
DEPRECATION_WARNING_PREFIX,
|
| 1500 |
-
DefaultRestOptions,
|
| 1501 |
-
DefaultUserAgent,
|
| 1502 |
-
DefaultUserAgentAppendix,
|
| 1503 |
-
DiscordAPIError,
|
| 1504 |
-
HTTPError,
|
| 1505 |
-
OverwrittenMimeTypes,
|
| 1506 |
-
REST,
|
| 1507 |
-
RESTEvents,
|
| 1508 |
-
RateLimitError,
|
| 1509 |
-
RequestMethod,
|
| 1510 |
-
calculateUserDefaultAvatarIndex,
|
| 1511 |
-
makeURLSearchParams,
|
| 1512 |
-
parseResponse,
|
| 1513 |
-
version
|
| 1514 |
-
});
|
| 1515 |
-
//# sourceMappingURL=index.js.map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/rest/dist/index.js.map
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
workspace/discord-bot/node_modules/@discordjs/rest/dist/index.mjs
DELETED
|
@@ -1,1473 +0,0 @@
|
|
| 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/CDN.ts
|
| 84 |
-
import { CDNRoutes } from "discord-api-types/v10";
|
| 85 |
-
|
| 86 |
-
// src/lib/utils/constants.ts
|
| 87 |
-
import { getUserAgentAppendix } from "@discordjs/util";
|
| 88 |
-
import { APIVersion } from "discord-api-types/v10";
|
| 89 |
-
var DefaultUserAgent = `DiscordBot (https://discord.js.org, 2.6.0)`;
|
| 90 |
-
var DefaultUserAgentAppendix = getUserAgentAppendix();
|
| 91 |
-
var DefaultRestOptions = {
|
| 92 |
-
agent: null,
|
| 93 |
-
api: "https://discord.com/api",
|
| 94 |
-
authPrefix: "Bot",
|
| 95 |
-
cdn: "https://cdn.discordapp.com",
|
| 96 |
-
headers: {},
|
| 97 |
-
invalidRequestWarningInterval: 0,
|
| 98 |
-
globalRequestsPerSecond: 50,
|
| 99 |
-
offset: 50,
|
| 100 |
-
rejectOnRateLimit: null,
|
| 101 |
-
retries: 3,
|
| 102 |
-
timeout: 15e3,
|
| 103 |
-
userAgentAppendix: DefaultUserAgentAppendix,
|
| 104 |
-
version: APIVersion,
|
| 105 |
-
hashSweepInterval: 144e5,
|
| 106 |
-
// 4 Hours
|
| 107 |
-
hashLifetime: 864e5,
|
| 108 |
-
// 24 Hours
|
| 109 |
-
handlerSweepInterval: 36e5,
|
| 110 |
-
// 1 Hour
|
| 111 |
-
async makeRequest(...args) {
|
| 112 |
-
return getDefaultStrategy()(...args);
|
| 113 |
-
},
|
| 114 |
-
mediaProxy: "https://media.discordapp.net"
|
| 115 |
-
};
|
| 116 |
-
var RESTEvents = /* @__PURE__ */ ((RESTEvents2) => {
|
| 117 |
-
RESTEvents2["Debug"] = "restDebug";
|
| 118 |
-
RESTEvents2["HandlerSweep"] = "handlerSweep";
|
| 119 |
-
RESTEvents2["HashSweep"] = "hashSweep";
|
| 120 |
-
RESTEvents2["InvalidRequestWarning"] = "invalidRequestWarning";
|
| 121 |
-
RESTEvents2["RateLimited"] = "rateLimited";
|
| 122 |
-
RESTEvents2["Response"] = "response";
|
| 123 |
-
return RESTEvents2;
|
| 124 |
-
})(RESTEvents || {});
|
| 125 |
-
var ALLOWED_EXTENSIONS = ["webp", "png", "jpg", "jpeg", "gif"];
|
| 126 |
-
var ALLOWED_STICKER_EXTENSIONS = ["png", "json", "gif"];
|
| 127 |
-
var ALLOWED_SIZES = [
|
| 128 |
-
16,
|
| 129 |
-
32,
|
| 130 |
-
64,
|
| 131 |
-
128,
|
| 132 |
-
256,
|
| 133 |
-
512,
|
| 134 |
-
1024,
|
| 135 |
-
2048,
|
| 136 |
-
4096
|
| 137 |
-
];
|
| 138 |
-
var OverwrittenMimeTypes = {
|
| 139 |
-
// https://github.com/discordjs/discord.js/issues/8557
|
| 140 |
-
"image/apng": "image/png"
|
| 141 |
-
};
|
| 142 |
-
var BurstHandlerMajorIdKey = "burst";
|
| 143 |
-
var DEPRECATION_WARNING_PREFIX = "DeprecationWarning";
|
| 144 |
-
|
| 145 |
-
// src/lib/errors/RateLimitError.ts
|
| 146 |
-
var RateLimitError = class _RateLimitError extends Error {
|
| 147 |
-
static {
|
| 148 |
-
__name(this, "RateLimitError");
|
| 149 |
-
}
|
| 150 |
-
timeToReset;
|
| 151 |
-
limit;
|
| 152 |
-
method;
|
| 153 |
-
hash;
|
| 154 |
-
url;
|
| 155 |
-
route;
|
| 156 |
-
majorParameter;
|
| 157 |
-
global;
|
| 158 |
-
retryAfter;
|
| 159 |
-
sublimitTimeout;
|
| 160 |
-
scope;
|
| 161 |
-
constructor({
|
| 162 |
-
timeToReset,
|
| 163 |
-
limit,
|
| 164 |
-
method,
|
| 165 |
-
hash,
|
| 166 |
-
url,
|
| 167 |
-
route,
|
| 168 |
-
majorParameter,
|
| 169 |
-
global,
|
| 170 |
-
retryAfter,
|
| 171 |
-
sublimitTimeout,
|
| 172 |
-
scope
|
| 173 |
-
}) {
|
| 174 |
-
super();
|
| 175 |
-
this.timeToReset = timeToReset;
|
| 176 |
-
this.limit = limit;
|
| 177 |
-
this.method = method;
|
| 178 |
-
this.hash = hash;
|
| 179 |
-
this.url = url;
|
| 180 |
-
this.route = route;
|
| 181 |
-
this.majorParameter = majorParameter;
|
| 182 |
-
this.global = global;
|
| 183 |
-
this.retryAfter = retryAfter;
|
| 184 |
-
this.sublimitTimeout = sublimitTimeout;
|
| 185 |
-
this.scope = scope;
|
| 186 |
-
}
|
| 187 |
-
/**
|
| 188 |
-
* The name of the error
|
| 189 |
-
*/
|
| 190 |
-
get name() {
|
| 191 |
-
return `${_RateLimitError.name}[${this.route}]`;
|
| 192 |
-
}
|
| 193 |
-
};
|
| 194 |
-
|
| 195 |
-
// src/lib/utils/types.ts
|
| 196 |
-
var RequestMethod = /* @__PURE__ */ ((RequestMethod2) => {
|
| 197 |
-
RequestMethod2["Delete"] = "DELETE";
|
| 198 |
-
RequestMethod2["Get"] = "GET";
|
| 199 |
-
RequestMethod2["Patch"] = "PATCH";
|
| 200 |
-
RequestMethod2["Post"] = "POST";
|
| 201 |
-
RequestMethod2["Put"] = "PUT";
|
| 202 |
-
return RequestMethod2;
|
| 203 |
-
})(RequestMethod || {});
|
| 204 |
-
|
| 205 |
-
// src/lib/utils/utils.ts
|
| 206 |
-
function serializeSearchParam(value) {
|
| 207 |
-
switch (typeof value) {
|
| 208 |
-
case "string":
|
| 209 |
-
return value;
|
| 210 |
-
case "number":
|
| 211 |
-
case "bigint":
|
| 212 |
-
case "boolean":
|
| 213 |
-
return value.toString();
|
| 214 |
-
case "object":
|
| 215 |
-
if (value === null) return null;
|
| 216 |
-
if (value instanceof Date) {
|
| 217 |
-
return Number.isNaN(value.getTime()) ? null : value.toISOString();
|
| 218 |
-
}
|
| 219 |
-
if (typeof value.toString === "function" && value.toString !== Object.prototype.toString) return value.toString();
|
| 220 |
-
return null;
|
| 221 |
-
default:
|
| 222 |
-
return null;
|
| 223 |
-
}
|
| 224 |
-
}
|
| 225 |
-
__name(serializeSearchParam, "serializeSearchParam");
|
| 226 |
-
function makeURLSearchParams(options) {
|
| 227 |
-
const params = new URLSearchParams();
|
| 228 |
-
if (!options) return params;
|
| 229 |
-
for (const [key, value] of Object.entries(options)) {
|
| 230 |
-
const serialized = serializeSearchParam(value);
|
| 231 |
-
if (serialized !== null) params.append(key, serialized);
|
| 232 |
-
}
|
| 233 |
-
return params;
|
| 234 |
-
}
|
| 235 |
-
__name(makeURLSearchParams, "makeURLSearchParams");
|
| 236 |
-
async function parseResponse(res) {
|
| 237 |
-
if (res.headers.get("Content-Type")?.startsWith("application/json")) {
|
| 238 |
-
return res.json();
|
| 239 |
-
}
|
| 240 |
-
return res.arrayBuffer();
|
| 241 |
-
}
|
| 242 |
-
__name(parseResponse, "parseResponse");
|
| 243 |
-
function hasSublimit(bucketRoute, body, method) {
|
| 244 |
-
if (bucketRoute === "/channels/:id") {
|
| 245 |
-
if (typeof body !== "object" || body === null) return false;
|
| 246 |
-
if (method !== "PATCH" /* Patch */) return false;
|
| 247 |
-
const castedBody = body;
|
| 248 |
-
return ["name", "topic"].some((key) => Reflect.has(castedBody, key));
|
| 249 |
-
}
|
| 250 |
-
return true;
|
| 251 |
-
}
|
| 252 |
-
__name(hasSublimit, "hasSublimit");
|
| 253 |
-
function shouldRetry(error) {
|
| 254 |
-
if (error.name === "AbortError") return true;
|
| 255 |
-
return "code" in error && error.code === "ECONNRESET" || error.message.includes("ECONNRESET");
|
| 256 |
-
}
|
| 257 |
-
__name(shouldRetry, "shouldRetry");
|
| 258 |
-
async function onRateLimit(manager, rateLimitData) {
|
| 259 |
-
const { options } = manager;
|
| 260 |
-
if (!options.rejectOnRateLimit) return;
|
| 261 |
-
const shouldThrow = typeof options.rejectOnRateLimit === "function" ? await options.rejectOnRateLimit(rateLimitData) : options.rejectOnRateLimit.some((route) => rateLimitData.route.startsWith(route.toLowerCase()));
|
| 262 |
-
if (shouldThrow) {
|
| 263 |
-
throw new RateLimitError(rateLimitData);
|
| 264 |
-
}
|
| 265 |
-
}
|
| 266 |
-
__name(onRateLimit, "onRateLimit");
|
| 267 |
-
function calculateUserDefaultAvatarIndex(userId) {
|
| 268 |
-
return Number(BigInt(userId) >> 22n) % 6;
|
| 269 |
-
}
|
| 270 |
-
__name(calculateUserDefaultAvatarIndex, "calculateUserDefaultAvatarIndex");
|
| 271 |
-
async function sleep(ms) {
|
| 272 |
-
return new Promise((resolve) => {
|
| 273 |
-
setTimeout(() => resolve(), ms);
|
| 274 |
-
});
|
| 275 |
-
}
|
| 276 |
-
__name(sleep, "sleep");
|
| 277 |
-
function isBufferLike(value) {
|
| 278 |
-
return value instanceof ArrayBuffer || value instanceof Uint8Array || value instanceof Uint8ClampedArray;
|
| 279 |
-
}
|
| 280 |
-
__name(isBufferLike, "isBufferLike");
|
| 281 |
-
function deprecationWarning(message) {
|
| 282 |
-
if (typeof globalThis.process === "undefined") {
|
| 283 |
-
console.warn(`${DEPRECATION_WARNING_PREFIX}: ${message}`);
|
| 284 |
-
} else {
|
| 285 |
-
process.emitWarning(message, DEPRECATION_WARNING_PREFIX);
|
| 286 |
-
}
|
| 287 |
-
}
|
| 288 |
-
__name(deprecationWarning, "deprecationWarning");
|
| 289 |
-
function normalizeRateLimitOffset(offset, route) {
|
| 290 |
-
if (typeof offset === "number") {
|
| 291 |
-
return Math.max(0, offset);
|
| 292 |
-
}
|
| 293 |
-
const result = offset(route);
|
| 294 |
-
return Math.max(0, result);
|
| 295 |
-
}
|
| 296 |
-
__name(normalizeRateLimitOffset, "normalizeRateLimitOffset");
|
| 297 |
-
|
| 298 |
-
// src/lib/CDN.ts
|
| 299 |
-
var deprecationEmittedForEmoji = false;
|
| 300 |
-
var CDN = class {
|
| 301 |
-
constructor(cdn = DefaultRestOptions.cdn, mediaProxy = DefaultRestOptions.mediaProxy) {
|
| 302 |
-
this.cdn = cdn;
|
| 303 |
-
this.mediaProxy = mediaProxy;
|
| 304 |
-
}
|
| 305 |
-
static {
|
| 306 |
-
__name(this, "CDN");
|
| 307 |
-
}
|
| 308 |
-
/**
|
| 309 |
-
* Generates an app asset URL for a client's asset.
|
| 310 |
-
*
|
| 311 |
-
* @param clientId - The client id that has the asset
|
| 312 |
-
* @param assetHash - The hash provided by Discord for this asset
|
| 313 |
-
* @param options - Optional options for the asset
|
| 314 |
-
*/
|
| 315 |
-
appAsset(clientId, assetHash, options) {
|
| 316 |
-
return this.makeURL(`/app-assets/${clientId}/${assetHash}`, options);
|
| 317 |
-
}
|
| 318 |
-
/**
|
| 319 |
-
* Generates an app icon URL for a client's icon.
|
| 320 |
-
*
|
| 321 |
-
* @param clientId - The client id that has the icon
|
| 322 |
-
* @param iconHash - The hash provided by Discord for this icon
|
| 323 |
-
* @param options - Optional options for the icon
|
| 324 |
-
*/
|
| 325 |
-
appIcon(clientId, iconHash, options) {
|
| 326 |
-
return this.makeURL(`/app-icons/${clientId}/${iconHash}`, options);
|
| 327 |
-
}
|
| 328 |
-
/**
|
| 329 |
-
* Generates an avatar URL, e.g. for a user or a webhook.
|
| 330 |
-
*
|
| 331 |
-
* @param id - The id that has the icon
|
| 332 |
-
* @param avatarHash - The hash provided by Discord for this avatar
|
| 333 |
-
* @param options - Optional options for the avatar
|
| 334 |
-
*/
|
| 335 |
-
avatar(id, avatarHash, options) {
|
| 336 |
-
return this.dynamicMakeURL(`/avatars/${id}/${avatarHash}`, avatarHash, options);
|
| 337 |
-
}
|
| 338 |
-
avatarDecoration(userIdOrAsset, userAvatarDecoration, options) {
|
| 339 |
-
if (userAvatarDecoration) {
|
| 340 |
-
return this.makeURL(`/avatar-decorations/${userIdOrAsset}/${userAvatarDecoration}`, options);
|
| 341 |
-
}
|
| 342 |
-
return this.makeURL(`/avatar-decoration-presets/${userIdOrAsset}`, { extension: "png" });
|
| 343 |
-
}
|
| 344 |
-
/**
|
| 345 |
-
* Generates a banner URL, e.g. for a user or a guild.
|
| 346 |
-
*
|
| 347 |
-
* @param id - The id that has the banner splash
|
| 348 |
-
* @param bannerHash - The hash provided by Discord for this banner
|
| 349 |
-
* @param options - Optional options for the banner
|
| 350 |
-
*/
|
| 351 |
-
banner(id, bannerHash, options) {
|
| 352 |
-
return this.dynamicMakeURL(`/banners/${id}/${bannerHash}`, bannerHash, options);
|
| 353 |
-
}
|
| 354 |
-
/**
|
| 355 |
-
* Generates an icon URL for a channel, e.g. a group DM.
|
| 356 |
-
*
|
| 357 |
-
* @param channelId - The channel id that has the icon
|
| 358 |
-
* @param iconHash - The hash provided by Discord for this channel
|
| 359 |
-
* @param options - Optional options for the icon
|
| 360 |
-
*/
|
| 361 |
-
channelIcon(channelId, iconHash, options) {
|
| 362 |
-
return this.makeURL(`/channel-icons/${channelId}/${iconHash}`, options);
|
| 363 |
-
}
|
| 364 |
-
/**
|
| 365 |
-
* Generates a default avatar URL
|
| 366 |
-
*
|
| 367 |
-
* @param index - The default avatar index
|
| 368 |
-
* @remarks
|
| 369 |
-
* To calculate the index for a user do `(userId >> 22) % 6`,
|
| 370 |
-
* or `discriminator % 5` if they're using the legacy username system.
|
| 371 |
-
*/
|
| 372 |
-
defaultAvatar(index) {
|
| 373 |
-
return this.makeURL(`/embed/avatars/${index}`, { extension: "png" });
|
| 374 |
-
}
|
| 375 |
-
/**
|
| 376 |
-
* Generates a discovery splash URL for a guild's discovery splash.
|
| 377 |
-
*
|
| 378 |
-
* @param guildId - The guild id that has the discovery splash
|
| 379 |
-
* @param splashHash - The hash provided by Discord for this splash
|
| 380 |
-
* @param options - Optional options for the splash
|
| 381 |
-
*/
|
| 382 |
-
discoverySplash(guildId, splashHash, options) {
|
| 383 |
-
return this.makeURL(`/discovery-splashes/${guildId}/${splashHash}`, options);
|
| 384 |
-
}
|
| 385 |
-
emoji(emojiId, options) {
|
| 386 |
-
let resolvedOptions;
|
| 387 |
-
if (typeof options === "string") {
|
| 388 |
-
if (!deprecationEmittedForEmoji) {
|
| 389 |
-
deprecationWarning(
|
| 390 |
-
"Passing a string for the second parameter of CDN#emoji() is deprecated. Use an object instead."
|
| 391 |
-
);
|
| 392 |
-
deprecationEmittedForEmoji = true;
|
| 393 |
-
}
|
| 394 |
-
resolvedOptions = { extension: options };
|
| 395 |
-
} else {
|
| 396 |
-
resolvedOptions = options;
|
| 397 |
-
}
|
| 398 |
-
return this.makeURL(`/emojis/${emojiId}`, resolvedOptions);
|
| 399 |
-
}
|
| 400 |
-
/**
|
| 401 |
-
* Generates a guild member avatar URL.
|
| 402 |
-
*
|
| 403 |
-
* @param guildId - The id of the guild
|
| 404 |
-
* @param userId - The id of the user
|
| 405 |
-
* @param avatarHash - The hash provided by Discord for this avatar
|
| 406 |
-
* @param options - Optional options for the avatar
|
| 407 |
-
*/
|
| 408 |
-
guildMemberAvatar(guildId, userId, avatarHash, options) {
|
| 409 |
-
return this.dynamicMakeURL(`/guilds/${guildId}/users/${userId}/avatars/${avatarHash}`, avatarHash, options);
|
| 410 |
-
}
|
| 411 |
-
/**
|
| 412 |
-
* Generates a guild member banner URL.
|
| 413 |
-
*
|
| 414 |
-
* @param guildId - The id of the guild
|
| 415 |
-
* @param userId - The id of the user
|
| 416 |
-
* @param bannerHash - The hash provided by Discord for this banner
|
| 417 |
-
* @param options - Optional options for the banner
|
| 418 |
-
*/
|
| 419 |
-
guildMemberBanner(guildId, userId, bannerHash, options) {
|
| 420 |
-
return this.dynamicMakeURL(`/guilds/${guildId}/users/${userId}/banners/${bannerHash}`, bannerHash, options);
|
| 421 |
-
}
|
| 422 |
-
/**
|
| 423 |
-
* Generates an icon URL, e.g. for a guild.
|
| 424 |
-
*
|
| 425 |
-
* @param id - The id that has the icon splash
|
| 426 |
-
* @param iconHash - The hash provided by Discord for this icon
|
| 427 |
-
* @param options - Optional options for the icon
|
| 428 |
-
*/
|
| 429 |
-
icon(id, iconHash, options) {
|
| 430 |
-
return this.dynamicMakeURL(`/icons/${id}/${iconHash}`, iconHash, options);
|
| 431 |
-
}
|
| 432 |
-
/**
|
| 433 |
-
* Generates a URL for the icon of a role
|
| 434 |
-
*
|
| 435 |
-
* @param roleId - The id of the role that has the icon
|
| 436 |
-
* @param roleIconHash - The hash provided by Discord for this role icon
|
| 437 |
-
* @param options - Optional options for the role icon
|
| 438 |
-
*/
|
| 439 |
-
roleIcon(roleId, roleIconHash, options) {
|
| 440 |
-
return this.makeURL(`/role-icons/${roleId}/${roleIconHash}`, options);
|
| 441 |
-
}
|
| 442 |
-
/**
|
| 443 |
-
* Generates a guild invite splash URL for a guild's invite splash.
|
| 444 |
-
*
|
| 445 |
-
* @param guildId - The guild id that has the invite splash
|
| 446 |
-
* @param splashHash - The hash provided by Discord for this splash
|
| 447 |
-
* @param options - Optional options for the splash
|
| 448 |
-
*/
|
| 449 |
-
splash(guildId, splashHash, options) {
|
| 450 |
-
return this.makeURL(`/splashes/${guildId}/${splashHash}`, options);
|
| 451 |
-
}
|
| 452 |
-
/**
|
| 453 |
-
* Generates a sticker URL.
|
| 454 |
-
*
|
| 455 |
-
* @param stickerId - The sticker id
|
| 456 |
-
* @param extension - The extension of the sticker
|
| 457 |
-
* @privateRemarks
|
| 458 |
-
* Stickers cannot have a `.webp` extension, so we default to a `.png`.
|
| 459 |
-
* Sticker GIFs do not use the CDN base URL.
|
| 460 |
-
*/
|
| 461 |
-
sticker(stickerId, extension = "png") {
|
| 462 |
-
return this.makeURL(`/stickers/${stickerId}`, {
|
| 463 |
-
allowedExtensions: ALLOWED_STICKER_EXTENSIONS,
|
| 464 |
-
base: extension === "gif" ? this.mediaProxy : this.cdn,
|
| 465 |
-
extension
|
| 466 |
-
});
|
| 467 |
-
}
|
| 468 |
-
/**
|
| 469 |
-
* Generates a sticker pack banner URL.
|
| 470 |
-
*
|
| 471 |
-
* @param bannerId - The banner id
|
| 472 |
-
* @param options - Optional options for the banner
|
| 473 |
-
*/
|
| 474 |
-
stickerPackBanner(bannerId, options) {
|
| 475 |
-
return this.makeURL(`/app-assets/710982414301790216/store/${bannerId}`, options);
|
| 476 |
-
}
|
| 477 |
-
/**
|
| 478 |
-
* Generates a team icon URL for a team's icon.
|
| 479 |
-
*
|
| 480 |
-
* @param teamId - The team id that has the icon
|
| 481 |
-
* @param iconHash - The hash provided by Discord for this icon
|
| 482 |
-
* @param options - Optional options for the icon
|
| 483 |
-
*/
|
| 484 |
-
teamIcon(teamId, iconHash, options) {
|
| 485 |
-
return this.makeURL(`/team-icons/${teamId}/${iconHash}`, options);
|
| 486 |
-
}
|
| 487 |
-
/**
|
| 488 |
-
* Generates a cover image for a guild scheduled event.
|
| 489 |
-
*
|
| 490 |
-
* @param scheduledEventId - The scheduled event id
|
| 491 |
-
* @param coverHash - The hash provided by discord for this cover image
|
| 492 |
-
* @param options - Optional options for the cover image
|
| 493 |
-
*/
|
| 494 |
-
guildScheduledEventCover(scheduledEventId, coverHash, options) {
|
| 495 |
-
return this.makeURL(`/guild-events/${scheduledEventId}/${coverHash}`, options);
|
| 496 |
-
}
|
| 497 |
-
/**
|
| 498 |
-
* Generates a URL for a soundboard sound.
|
| 499 |
-
*
|
| 500 |
-
* @param soundId - The soundboard sound id
|
| 501 |
-
*/
|
| 502 |
-
soundboardSound(soundId) {
|
| 503 |
-
return `${this.cdn}${CDNRoutes.soundboardSound(soundId)}`;
|
| 504 |
-
}
|
| 505 |
-
/**
|
| 506 |
-
* Generates a URL for a guild tag badge.
|
| 507 |
-
*
|
| 508 |
-
* @param guildId - The guild id
|
| 509 |
-
* @param badgeHash - The hash of the badge
|
| 510 |
-
* @param options - Optional options for the badge
|
| 511 |
-
*/
|
| 512 |
-
guildTagBadge(guildId, badgeHash, options) {
|
| 513 |
-
return this.makeURL(`/guild-tag-badges/${guildId}/${badgeHash}`, options);
|
| 514 |
-
}
|
| 515 |
-
/**
|
| 516 |
-
* Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
|
| 517 |
-
*
|
| 518 |
-
* @param route - The base cdn route
|
| 519 |
-
* @param hash - The hash provided by Discord for this icon
|
| 520 |
-
* @param options - Optional options for the link
|
| 521 |
-
*/
|
| 522 |
-
dynamicMakeURL(route, hash, { forceStatic = false, ...options } = {}) {
|
| 523 |
-
return this.makeURL(route, !forceStatic && hash.startsWith("a_") ? { ...options, extension: "gif" } : options);
|
| 524 |
-
}
|
| 525 |
-
/**
|
| 526 |
-
* Constructs the URL for the resource
|
| 527 |
-
*
|
| 528 |
-
* @param route - The base cdn route
|
| 529 |
-
* @param options - The extension/size options for the link
|
| 530 |
-
*/
|
| 531 |
-
makeURL(route, {
|
| 532 |
-
allowedExtensions = ALLOWED_EXTENSIONS,
|
| 533 |
-
base = this.cdn,
|
| 534 |
-
extension = "webp",
|
| 535 |
-
size,
|
| 536 |
-
animated
|
| 537 |
-
} = {}) {
|
| 538 |
-
extension = String(extension).toLowerCase();
|
| 539 |
-
if (!allowedExtensions.includes(extension)) {
|
| 540 |
-
throw new RangeError(`Invalid extension provided: ${extension}
|
| 541 |
-
Must be one of: ${allowedExtensions.join(", ")}`);
|
| 542 |
-
}
|
| 543 |
-
if (size && !ALLOWED_SIZES.includes(size)) {
|
| 544 |
-
throw new RangeError(`Invalid size provided: ${size}
|
| 545 |
-
Must be one of: ${ALLOWED_SIZES.join(", ")}`);
|
| 546 |
-
}
|
| 547 |
-
const url = new URL(`${base}${route}.${extension}`);
|
| 548 |
-
if (animated !== void 0) {
|
| 549 |
-
url.searchParams.set("animated", String(animated));
|
| 550 |
-
}
|
| 551 |
-
if (size) {
|
| 552 |
-
url.searchParams.set("size", String(size));
|
| 553 |
-
}
|
| 554 |
-
return url.toString();
|
| 555 |
-
}
|
| 556 |
-
};
|
| 557 |
-
|
| 558 |
-
// src/lib/errors/DiscordAPIError.ts
|
| 559 |
-
function isErrorGroupWrapper(error) {
|
| 560 |
-
return Reflect.has(error, "_errors");
|
| 561 |
-
}
|
| 562 |
-
__name(isErrorGroupWrapper, "isErrorGroupWrapper");
|
| 563 |
-
function isErrorResponse(error) {
|
| 564 |
-
return typeof Reflect.get(error, "message") === "string";
|
| 565 |
-
}
|
| 566 |
-
__name(isErrorResponse, "isErrorResponse");
|
| 567 |
-
var DiscordAPIError = class _DiscordAPIError extends Error {
|
| 568 |
-
/**
|
| 569 |
-
* @param rawError - The error reported by Discord
|
| 570 |
-
* @param code - The error code reported by Discord
|
| 571 |
-
* @param status - The status code of the response
|
| 572 |
-
* @param method - The method of the request that erred
|
| 573 |
-
* @param url - The url of the request that erred
|
| 574 |
-
* @param bodyData - The unparsed data for the request that errored
|
| 575 |
-
*/
|
| 576 |
-
constructor(rawError, code, status, method, url, bodyData) {
|
| 577 |
-
super(_DiscordAPIError.getMessage(rawError));
|
| 578 |
-
this.rawError = rawError;
|
| 579 |
-
this.code = code;
|
| 580 |
-
this.status = status;
|
| 581 |
-
this.method = method;
|
| 582 |
-
this.url = url;
|
| 583 |
-
this.requestBody = { files: bodyData.files, json: bodyData.body };
|
| 584 |
-
}
|
| 585 |
-
static {
|
| 586 |
-
__name(this, "DiscordAPIError");
|
| 587 |
-
}
|
| 588 |
-
requestBody;
|
| 589 |
-
/**
|
| 590 |
-
* The name of the error
|
| 591 |
-
*/
|
| 592 |
-
get name() {
|
| 593 |
-
return `${_DiscordAPIError.name}[${this.code}]`;
|
| 594 |
-
}
|
| 595 |
-
static getMessage(error) {
|
| 596 |
-
let flattened = "";
|
| 597 |
-
if ("code" in error) {
|
| 598 |
-
if (error.errors) {
|
| 599 |
-
flattened = [...this.flattenDiscordError(error.errors)].join("\n");
|
| 600 |
-
}
|
| 601 |
-
return error.message && flattened ? `${error.message}
|
| 602 |
-
${flattened}` : error.message || flattened || "Unknown Error";
|
| 603 |
-
}
|
| 604 |
-
return error.error_description ?? "No Description";
|
| 605 |
-
}
|
| 606 |
-
static *flattenDiscordError(obj, key = "") {
|
| 607 |
-
if (isErrorResponse(obj)) {
|
| 608 |
-
return yield `${key.length ? `${key}[${obj.code}]` : `${obj.code}`}: ${obj.message}`.trim();
|
| 609 |
-
}
|
| 610 |
-
for (const [otherKey, val] of Object.entries(obj)) {
|
| 611 |
-
const nextKey = otherKey.startsWith("_") ? key : key ? Number.isNaN(Number(otherKey)) ? `${key}.${otherKey}` : `${key}[${otherKey}]` : otherKey;
|
| 612 |
-
if (typeof val === "string") {
|
| 613 |
-
yield val;
|
| 614 |
-
} else if (isErrorGroupWrapper(val)) {
|
| 615 |
-
for (const error of val._errors) {
|
| 616 |
-
yield* this.flattenDiscordError(error, nextKey);
|
| 617 |
-
}
|
| 618 |
-
} else {
|
| 619 |
-
yield* this.flattenDiscordError(val, nextKey);
|
| 620 |
-
}
|
| 621 |
-
}
|
| 622 |
-
}
|
| 623 |
-
};
|
| 624 |
-
|
| 625 |
-
// src/lib/errors/HTTPError.ts
|
| 626 |
-
var HTTPError = class _HTTPError extends Error {
|
| 627 |
-
/**
|
| 628 |
-
* @param status - The status code of the response
|
| 629 |
-
* @param statusText - The status text of the response
|
| 630 |
-
* @param method - The method of the request that erred
|
| 631 |
-
* @param url - The url of the request that erred
|
| 632 |
-
* @param bodyData - The unparsed data for the request that errored
|
| 633 |
-
*/
|
| 634 |
-
constructor(status, statusText, method, url, bodyData) {
|
| 635 |
-
super(statusText);
|
| 636 |
-
this.status = status;
|
| 637 |
-
this.method = method;
|
| 638 |
-
this.url = url;
|
| 639 |
-
this.requestBody = { files: bodyData.files, json: bodyData.body };
|
| 640 |
-
}
|
| 641 |
-
static {
|
| 642 |
-
__name(this, "HTTPError");
|
| 643 |
-
}
|
| 644 |
-
requestBody;
|
| 645 |
-
name = _HTTPError.name;
|
| 646 |
-
};
|
| 647 |
-
|
| 648 |
-
// src/lib/REST.ts
|
| 649 |
-
import { Collection } from "@discordjs/collection";
|
| 650 |
-
import { DiscordSnowflake } from "@sapphire/snowflake";
|
| 651 |
-
import { AsyncEventEmitter } from "@vladfrangu/async_event_emitter";
|
| 652 |
-
import { filetypeinfo } from "magic-bytes.js";
|
| 653 |
-
|
| 654 |
-
// src/lib/handlers/Shared.ts
|
| 655 |
-
var invalidCount = 0;
|
| 656 |
-
var invalidCountResetTime = null;
|
| 657 |
-
function incrementInvalidCount(manager) {
|
| 658 |
-
if (!invalidCountResetTime || invalidCountResetTime < Date.now()) {
|
| 659 |
-
invalidCountResetTime = Date.now() + 1e3 * 60 * 10;
|
| 660 |
-
invalidCount = 0;
|
| 661 |
-
}
|
| 662 |
-
invalidCount++;
|
| 663 |
-
const emitInvalid = manager.options.invalidRequestWarningInterval > 0 && invalidCount % manager.options.invalidRequestWarningInterval === 0;
|
| 664 |
-
if (emitInvalid) {
|
| 665 |
-
manager.emit("invalidRequestWarning" /* InvalidRequestWarning */, {
|
| 666 |
-
count: invalidCount,
|
| 667 |
-
remainingTime: invalidCountResetTime - Date.now()
|
| 668 |
-
});
|
| 669 |
-
}
|
| 670 |
-
}
|
| 671 |
-
__name(incrementInvalidCount, "incrementInvalidCount");
|
| 672 |
-
async function makeNetworkRequest(manager, routeId, url, options, requestData, retries) {
|
| 673 |
-
const controller = new AbortController();
|
| 674 |
-
const timeout = setTimeout(() => controller.abort(), manager.options.timeout);
|
| 675 |
-
if (requestData.signal) {
|
| 676 |
-
if (requestData.signal.aborted) controller.abort();
|
| 677 |
-
else 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)) throw error;
|
| 684 |
-
if (shouldRetry(error) && retries !== manager.options.retries) {
|
| 685 |
-
return null;
|
| 686 |
-
}
|
| 687 |
-
throw error;
|
| 688 |
-
} finally {
|
| 689 |
-
clearTimeout(timeout);
|
| 690 |
-
}
|
| 691 |
-
if (manager.listenerCount("response" /* Response */)) {
|
| 692 |
-
manager.emit(
|
| 693 |
-
"response" /* Response */,
|
| 694 |
-
{
|
| 695 |
-
method: options.method ?? "get",
|
| 696 |
-
path: routeId.original,
|
| 697 |
-
route: routeId.bucketRoute,
|
| 698 |
-
options,
|
| 699 |
-
data: requestData,
|
| 700 |
-
retries
|
| 701 |
-
},
|
| 702 |
-
res instanceof Response ? res.clone() : { ...res }
|
| 703 |
-
);
|
| 704 |
-
}
|
| 705 |
-
return res;
|
| 706 |
-
}
|
| 707 |
-
__name(makeNetworkRequest, "makeNetworkRequest");
|
| 708 |
-
async function handleErrors(manager, res, method, url, requestData, retries) {
|
| 709 |
-
const status = res.status;
|
| 710 |
-
if (status >= 500 && status < 600) {
|
| 711 |
-
if (retries !== manager.options.retries) {
|
| 712 |
-
return null;
|
| 713 |
-
}
|
| 714 |
-
throw new HTTPError(status, res.statusText, method, url, requestData);
|
| 715 |
-
} else {
|
| 716 |
-
if (status >= 400 && status < 500) {
|
| 717 |
-
if (status === 401 && requestData.auth) {
|
| 718 |
-
manager.setToken(null);
|
| 719 |
-
}
|
| 720 |
-
const data = await parseResponse(res);
|
| 721 |
-
throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
|
| 722 |
-
}
|
| 723 |
-
return res;
|
| 724 |
-
}
|
| 725 |
-
}
|
| 726 |
-
__name(handleErrors, "handleErrors");
|
| 727 |
-
|
| 728 |
-
// src/lib/handlers/BurstHandler.ts
|
| 729 |
-
var BurstHandler = class {
|
| 730 |
-
/**
|
| 731 |
-
* @param manager - The request manager
|
| 732 |
-
* @param hash - The hash that this RequestHandler handles
|
| 733 |
-
* @param majorParameter - The major parameter for this handler
|
| 734 |
-
*/
|
| 735 |
-
constructor(manager, hash, majorParameter) {
|
| 736 |
-
this.manager = manager;
|
| 737 |
-
this.hash = hash;
|
| 738 |
-
this.majorParameter = majorParameter;
|
| 739 |
-
this.id = `${hash}:${majorParameter}`;
|
| 740 |
-
}
|
| 741 |
-
static {
|
| 742 |
-
__name(this, "BurstHandler");
|
| 743 |
-
}
|
| 744 |
-
/**
|
| 745 |
-
* {@inheritdoc IHandler.id}
|
| 746 |
-
*/
|
| 747 |
-
id;
|
| 748 |
-
/**
|
| 749 |
-
* {@inheritDoc IHandler.inactive}
|
| 750 |
-
*/
|
| 751 |
-
inactive = false;
|
| 752 |
-
/**
|
| 753 |
-
* Emits a debug message
|
| 754 |
-
*
|
| 755 |
-
* @param message - The message to debug
|
| 756 |
-
*/
|
| 757 |
-
debug(message) {
|
| 758 |
-
this.manager.emit("restDebug" /* Debug */, `[REST ${this.id}] ${message}`);
|
| 759 |
-
}
|
| 760 |
-
/**
|
| 761 |
-
* {@inheritDoc IHandler.queueRequest}
|
| 762 |
-
*/
|
| 763 |
-
async queueRequest(routeId, url, options, requestData) {
|
| 764 |
-
return this.runRequest(routeId, url, options, requestData);
|
| 765 |
-
}
|
| 766 |
-
/**
|
| 767 |
-
* The method that actually makes the request to the API, and updates info about the bucket accordingly
|
| 768 |
-
*
|
| 769 |
-
* @param routeId - The generalized API route with literal ids for major parameters
|
| 770 |
-
* @param url - The fully resolved URL to make the request to
|
| 771 |
-
* @param options - The fetch options needed to make the request
|
| 772 |
-
* @param requestData - Extra data from the user's request needed for errors and additional processing
|
| 773 |
-
* @param retries - The number of retries this request has already attempted (recursion)
|
| 774 |
-
*/
|
| 775 |
-
async runRequest(routeId, url, options, requestData, retries = 0) {
|
| 776 |
-
const method = options.method ?? "get";
|
| 777 |
-
const res = await makeNetworkRequest(this.manager, routeId, url, options, requestData, retries);
|
| 778 |
-
if (res === null) {
|
| 779 |
-
return this.runRequest(routeId, url, options, requestData, ++retries);
|
| 780 |
-
}
|
| 781 |
-
const status = res.status;
|
| 782 |
-
let retryAfter = 0;
|
| 783 |
-
const retry = res.headers.get("Retry-After");
|
| 784 |
-
const offset = normalizeRateLimitOffset(this.manager.options.offset, routeId.bucketRoute);
|
| 785 |
-
if (retry) retryAfter = Number(retry) * 1e3 + offset;
|
| 786 |
-
if (status === 401 || status === 403 || status === 429) {
|
| 787 |
-
incrementInvalidCount(this.manager);
|
| 788 |
-
}
|
| 789 |
-
if (status >= 200 && status < 300) {
|
| 790 |
-
return res;
|
| 791 |
-
} else if (status === 429) {
|
| 792 |
-
const isGlobal = res.headers.has("X-RateLimit-Global");
|
| 793 |
-
const scope = res.headers.get("X-RateLimit-Scope") ?? "user";
|
| 794 |
-
await onRateLimit(this.manager, {
|
| 795 |
-
global: isGlobal,
|
| 796 |
-
method,
|
| 797 |
-
url,
|
| 798 |
-
route: routeId.bucketRoute,
|
| 799 |
-
majorParameter: this.majorParameter,
|
| 800 |
-
hash: this.hash,
|
| 801 |
-
limit: Number.POSITIVE_INFINITY,
|
| 802 |
-
timeToReset: retryAfter,
|
| 803 |
-
retryAfter,
|
| 804 |
-
sublimitTimeout: 0,
|
| 805 |
-
scope
|
| 806 |
-
});
|
| 807 |
-
this.debug(
|
| 808 |
-
[
|
| 809 |
-
"Encountered unexpected 429 rate limit",
|
| 810 |
-
` Global : ${isGlobal}`,
|
| 811 |
-
` Method : ${method}`,
|
| 812 |
-
` URL : ${url}`,
|
| 813 |
-
` Bucket : ${routeId.bucketRoute}`,
|
| 814 |
-
` Major parameter: ${routeId.majorParameter}`,
|
| 815 |
-
` Hash : ${this.hash}`,
|
| 816 |
-
` Limit : ${Number.POSITIVE_INFINITY}`,
|
| 817 |
-
` Retry After : ${retryAfter}ms`,
|
| 818 |
-
` Sublimit : None`,
|
| 819 |
-
` Scope : ${scope}`
|
| 820 |
-
].join("\n")
|
| 821 |
-
);
|
| 822 |
-
await sleep(retryAfter);
|
| 823 |
-
return this.runRequest(routeId, url, options, requestData, retries);
|
| 824 |
-
} else {
|
| 825 |
-
const handled = await handleErrors(this.manager, res, method, url, requestData, retries);
|
| 826 |
-
if (handled === null) {
|
| 827 |
-
return this.runRequest(routeId, url, options, requestData, ++retries);
|
| 828 |
-
}
|
| 829 |
-
return handled;
|
| 830 |
-
}
|
| 831 |
-
}
|
| 832 |
-
};
|
| 833 |
-
|
| 834 |
-
// src/lib/handlers/SequentialHandler.ts
|
| 835 |
-
import { AsyncQueue } from "@sapphire/async-queue";
|
| 836 |
-
var SequentialHandler = class {
|
| 837 |
-
/**
|
| 838 |
-
* @param manager - The request manager
|
| 839 |
-
* @param hash - The hash that this RequestHandler handles
|
| 840 |
-
* @param majorParameter - The major parameter for this handler
|
| 841 |
-
*/
|
| 842 |
-
constructor(manager, hash, majorParameter) {
|
| 843 |
-
this.manager = manager;
|
| 844 |
-
this.hash = hash;
|
| 845 |
-
this.majorParameter = majorParameter;
|
| 846 |
-
this.id = `${hash}:${majorParameter}`;
|
| 847 |
-
}
|
| 848 |
-
static {
|
| 849 |
-
__name(this, "SequentialHandler");
|
| 850 |
-
}
|
| 851 |
-
/**
|
| 852 |
-
* {@inheritDoc IHandler.id}
|
| 853 |
-
*/
|
| 854 |
-
id;
|
| 855 |
-
/**
|
| 856 |
-
* The time this rate limit bucket will reset
|
| 857 |
-
*/
|
| 858 |
-
reset = -1;
|
| 859 |
-
/**
|
| 860 |
-
* The remaining requests that can be made before we are rate limited
|
| 861 |
-
*/
|
| 862 |
-
remaining = 1;
|
| 863 |
-
/**
|
| 864 |
-
* The total number of requests that can be made before we are rate limited
|
| 865 |
-
*/
|
| 866 |
-
limit = Number.POSITIVE_INFINITY;
|
| 867 |
-
/**
|
| 868 |
-
* The interface used to sequence async requests sequentially
|
| 869 |
-
*/
|
| 870 |
-
#asyncQueue = new AsyncQueue();
|
| 871 |
-
/**
|
| 872 |
-
* The interface used to sequence sublimited async requests sequentially
|
| 873 |
-
*/
|
| 874 |
-
#sublimitedQueue = null;
|
| 875 |
-
/**
|
| 876 |
-
* A promise wrapper for when the sublimited queue is finished being processed or null when not being processed
|
| 877 |
-
*/
|
| 878 |
-
#sublimitPromise = null;
|
| 879 |
-
/**
|
| 880 |
-
* Whether the sublimit queue needs to be shifted in the finally block
|
| 881 |
-
*/
|
| 882 |
-
#shiftSublimit = false;
|
| 883 |
-
/**
|
| 884 |
-
* {@inheritDoc IHandler.inactive}
|
| 885 |
-
*/
|
| 886 |
-
get inactive() {
|
| 887 |
-
return this.#asyncQueue.remaining === 0 && (this.#sublimitedQueue === null || this.#sublimitedQueue.remaining === 0) && !this.limited;
|
| 888 |
-
}
|
| 889 |
-
/**
|
| 890 |
-
* If the rate limit bucket is currently limited by the global limit
|
| 891 |
-
*/
|
| 892 |
-
get globalLimited() {
|
| 893 |
-
return this.manager.globalRemaining <= 0 && Date.now() < this.manager.globalReset;
|
| 894 |
-
}
|
| 895 |
-
/**
|
| 896 |
-
* If the rate limit bucket is currently limited by its limit
|
| 897 |
-
*/
|
| 898 |
-
get localLimited() {
|
| 899 |
-
return this.remaining <= 0 && Date.now() < this.reset;
|
| 900 |
-
}
|
| 901 |
-
/**
|
| 902 |
-
* If the rate limit bucket is currently limited
|
| 903 |
-
*/
|
| 904 |
-
get limited() {
|
| 905 |
-
return this.globalLimited || this.localLimited;
|
| 906 |
-
}
|
| 907 |
-
/**
|
| 908 |
-
* The time until queued requests can continue
|
| 909 |
-
*/
|
| 910 |
-
getTimeToReset(routeId) {
|
| 911 |
-
const offset = normalizeRateLimitOffset(this.manager.options.offset, routeId.bucketRoute);
|
| 912 |
-
return this.reset + 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 |
-
const offset2 = normalizeRateLimitOffset(this.manager.options.offset, routeId.bucketRoute);
|
| 983 |
-
limit2 = this.manager.options.globalRequestsPerSecond;
|
| 984 |
-
timeout = this.manager.globalReset + offset2 - Date.now();
|
| 985 |
-
if (!this.manager.globalDelay) {
|
| 986 |
-
this.manager.globalDelay = this.globalDelayFor(timeout);
|
| 987 |
-
}
|
| 988 |
-
delay = this.manager.globalDelay;
|
| 989 |
-
} else {
|
| 990 |
-
limit2 = this.limit;
|
| 991 |
-
timeout = this.getTimeToReset(routeId);
|
| 992 |
-
delay = sleep(timeout);
|
| 993 |
-
}
|
| 994 |
-
const rateLimitData = {
|
| 995 |
-
global: isGlobal,
|
| 996 |
-
method: options.method ?? "get",
|
| 997 |
-
url,
|
| 998 |
-
route: routeId.bucketRoute,
|
| 999 |
-
majorParameter: this.majorParameter,
|
| 1000 |
-
hash: this.hash,
|
| 1001 |
-
limit: limit2,
|
| 1002 |
-
timeToReset: timeout,
|
| 1003 |
-
retryAfter: timeout,
|
| 1004 |
-
sublimitTimeout: 0,
|
| 1005 |
-
scope: "user"
|
| 1006 |
-
};
|
| 1007 |
-
this.manager.emit("rateLimited" /* RateLimited */, rateLimitData);
|
| 1008 |
-
await onRateLimit(this.manager, rateLimitData);
|
| 1009 |
-
if (isGlobal) {
|
| 1010 |
-
this.debug(`Global rate limit hit, blocking all requests for ${timeout}ms`);
|
| 1011 |
-
} else {
|
| 1012 |
-
this.debug(`Waiting ${timeout}ms for rate limit to pass`);
|
| 1013 |
-
}
|
| 1014 |
-
await delay;
|
| 1015 |
-
}
|
| 1016 |
-
if (!this.manager.globalReset || this.manager.globalReset < Date.now()) {
|
| 1017 |
-
this.manager.globalReset = Date.now() + 1e3;
|
| 1018 |
-
this.manager.globalRemaining = this.manager.options.globalRequestsPerSecond;
|
| 1019 |
-
}
|
| 1020 |
-
this.manager.globalRemaining--;
|
| 1021 |
-
const method = options.method ?? "get";
|
| 1022 |
-
const res = await makeNetworkRequest(this.manager, routeId, url, options, requestData, retries);
|
| 1023 |
-
if (res === null) {
|
| 1024 |
-
return this.runRequest(routeId, url, options, requestData, ++retries);
|
| 1025 |
-
}
|
| 1026 |
-
const status = res.status;
|
| 1027 |
-
let retryAfter = 0;
|
| 1028 |
-
const limit = res.headers.get("X-RateLimit-Limit");
|
| 1029 |
-
const remaining = res.headers.get("X-RateLimit-Remaining");
|
| 1030 |
-
const reset = res.headers.get("X-RateLimit-Reset-After");
|
| 1031 |
-
const hash = res.headers.get("X-RateLimit-Bucket");
|
| 1032 |
-
const retry = res.headers.get("Retry-After");
|
| 1033 |
-
const scope = res.headers.get("X-RateLimit-Scope") ?? "user";
|
| 1034 |
-
const offset = normalizeRateLimitOffset(this.manager.options.offset, routeId.bucketRoute);
|
| 1035 |
-
this.limit = limit ? Number(limit) : Number.POSITIVE_INFINITY;
|
| 1036 |
-
this.remaining = remaining ? Number(remaining) : 1;
|
| 1037 |
-
this.reset = reset ? Number(reset) * 1e3 + Date.now() + offset : Date.now();
|
| 1038 |
-
if (retry) retryAfter = Number(retry) * 1e3 + offset;
|
| 1039 |
-
if (hash && hash !== this.hash) {
|
| 1040 |
-
this.debug(["Received bucket hash update", ` Old Hash : ${this.hash}`, ` New Hash : ${hash}`].join("\n"));
|
| 1041 |
-
this.manager.hashes.set(`${method}:${routeId.bucketRoute}`, { value: hash, lastAccess: Date.now() });
|
| 1042 |
-
} else if (hash) {
|
| 1043 |
-
const hashData = this.manager.hashes.get(`${method}:${routeId.bucketRoute}`);
|
| 1044 |
-
if (hashData) {
|
| 1045 |
-
hashData.lastAccess = Date.now();
|
| 1046 |
-
}
|
| 1047 |
-
}
|
| 1048 |
-
let sublimitTimeout = null;
|
| 1049 |
-
if (retryAfter > 0) {
|
| 1050 |
-
if (res.headers.has("X-RateLimit-Global")) {
|
| 1051 |
-
this.manager.globalRemaining = 0;
|
| 1052 |
-
this.manager.globalReset = Date.now() + retryAfter;
|
| 1053 |
-
} else if (!this.localLimited) {
|
| 1054 |
-
sublimitTimeout = retryAfter;
|
| 1055 |
-
}
|
| 1056 |
-
}
|
| 1057 |
-
if (status === 401 || status === 403 || status === 429) {
|
| 1058 |
-
incrementInvalidCount(this.manager);
|
| 1059 |
-
}
|
| 1060 |
-
if (res.ok) {
|
| 1061 |
-
return res;
|
| 1062 |
-
} else if (status === 429) {
|
| 1063 |
-
const isGlobal = this.globalLimited;
|
| 1064 |
-
let limit2;
|
| 1065 |
-
let timeout;
|
| 1066 |
-
if (isGlobal) {
|
| 1067 |
-
const offset2 = normalizeRateLimitOffset(this.manager.options.offset, routeId.bucketRoute);
|
| 1068 |
-
limit2 = this.manager.options.globalRequestsPerSecond;
|
| 1069 |
-
timeout = this.manager.globalReset + offset2 - Date.now();
|
| 1070 |
-
} else {
|
| 1071 |
-
limit2 = this.limit;
|
| 1072 |
-
timeout = this.getTimeToReset(routeId);
|
| 1073 |
-
}
|
| 1074 |
-
await onRateLimit(this.manager, {
|
| 1075 |
-
global: isGlobal,
|
| 1076 |
-
method,
|
| 1077 |
-
url,
|
| 1078 |
-
route: routeId.bucketRoute,
|
| 1079 |
-
majorParameter: this.majorParameter,
|
| 1080 |
-
hash: this.hash,
|
| 1081 |
-
limit: limit2,
|
| 1082 |
-
timeToReset: timeout,
|
| 1083 |
-
retryAfter,
|
| 1084 |
-
sublimitTimeout: sublimitTimeout ?? 0,
|
| 1085 |
-
scope
|
| 1086 |
-
});
|
| 1087 |
-
this.debug(
|
| 1088 |
-
[
|
| 1089 |
-
"Encountered unexpected 429 rate limit",
|
| 1090 |
-
` Global : ${isGlobal.toString()}`,
|
| 1091 |
-
` Method : ${method}`,
|
| 1092 |
-
` URL : ${url}`,
|
| 1093 |
-
` Bucket : ${routeId.bucketRoute}`,
|
| 1094 |
-
` Major parameter: ${routeId.majorParameter}`,
|
| 1095 |
-
` Hash : ${this.hash}`,
|
| 1096 |
-
` Limit : ${limit2}`,
|
| 1097 |
-
` Retry After : ${retryAfter}ms`,
|
| 1098 |
-
` Sublimit : ${sublimitTimeout ? `${sublimitTimeout}ms` : "None"}`,
|
| 1099 |
-
` Scope : ${scope}`
|
| 1100 |
-
].join("\n")
|
| 1101 |
-
);
|
| 1102 |
-
if (sublimitTimeout) {
|
| 1103 |
-
const firstSublimit = !this.#sublimitedQueue;
|
| 1104 |
-
if (firstSublimit) {
|
| 1105 |
-
this.#sublimitedQueue = new AsyncQueue();
|
| 1106 |
-
void this.#sublimitedQueue.wait();
|
| 1107 |
-
this.#asyncQueue.shift();
|
| 1108 |
-
}
|
| 1109 |
-
this.#sublimitPromise?.resolve();
|
| 1110 |
-
this.#sublimitPromise = null;
|
| 1111 |
-
await sleep(sublimitTimeout);
|
| 1112 |
-
let resolve;
|
| 1113 |
-
const promise = new Promise((res2) => resolve = res2);
|
| 1114 |
-
this.#sublimitPromise = { promise, resolve };
|
| 1115 |
-
if (firstSublimit) {
|
| 1116 |
-
await this.#asyncQueue.wait();
|
| 1117 |
-
this.#shiftSublimit = true;
|
| 1118 |
-
}
|
| 1119 |
-
}
|
| 1120 |
-
return this.runRequest(routeId, url, options, requestData, retries);
|
| 1121 |
-
} else {
|
| 1122 |
-
const handled = await handleErrors(this.manager, res, method, url, requestData, retries);
|
| 1123 |
-
if (handled === null) {
|
| 1124 |
-
return this.runRequest(routeId, url, options, requestData, ++retries);
|
| 1125 |
-
}
|
| 1126 |
-
return handled;
|
| 1127 |
-
}
|
| 1128 |
-
}
|
| 1129 |
-
};
|
| 1130 |
-
|
| 1131 |
-
// src/lib/REST.ts
|
| 1132 |
-
var REST = class _REST extends AsyncEventEmitter {
|
| 1133 |
-
static {
|
| 1134 |
-
__name(this, "REST");
|
| 1135 |
-
}
|
| 1136 |
-
/**
|
| 1137 |
-
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} for all requests
|
| 1138 |
-
* performed by this manager.
|
| 1139 |
-
*/
|
| 1140 |
-
agent = null;
|
| 1141 |
-
cdn;
|
| 1142 |
-
/**
|
| 1143 |
-
* The number of requests remaining in the global bucket
|
| 1144 |
-
*/
|
| 1145 |
-
globalRemaining;
|
| 1146 |
-
/**
|
| 1147 |
-
* The promise used to wait out the global rate limit
|
| 1148 |
-
*/
|
| 1149 |
-
globalDelay = null;
|
| 1150 |
-
/**
|
| 1151 |
-
* The timestamp at which the global bucket resets
|
| 1152 |
-
*/
|
| 1153 |
-
globalReset = -1;
|
| 1154 |
-
/**
|
| 1155 |
-
* API bucket hashes that are cached from provided routes
|
| 1156 |
-
*/
|
| 1157 |
-
hashes = new Collection();
|
| 1158 |
-
/**
|
| 1159 |
-
* Request handlers created from the bucket hash and the major parameters
|
| 1160 |
-
*/
|
| 1161 |
-
handlers = new Collection();
|
| 1162 |
-
#token = null;
|
| 1163 |
-
hashTimer;
|
| 1164 |
-
handlerTimer;
|
| 1165 |
-
options;
|
| 1166 |
-
constructor(options = {}) {
|
| 1167 |
-
super();
|
| 1168 |
-
this.cdn = new CDN(options.cdn ?? DefaultRestOptions.cdn, options.mediaProxy ?? DefaultRestOptions.mediaProxy);
|
| 1169 |
-
this.options = { ...DefaultRestOptions, ...options };
|
| 1170 |
-
this.globalRemaining = Math.max(1, this.options.globalRequestsPerSecond);
|
| 1171 |
-
this.agent = options.agent ?? null;
|
| 1172 |
-
this.setupSweepers();
|
| 1173 |
-
}
|
| 1174 |
-
setupSweepers() {
|
| 1175 |
-
const validateMaxInterval = /* @__PURE__ */ __name((interval) => {
|
| 1176 |
-
if (interval > 144e5) {
|
| 1177 |
-
throw new Error("Cannot set an interval greater than 4 hours");
|
| 1178 |
-
}
|
| 1179 |
-
}, "validateMaxInterval");
|
| 1180 |
-
if (this.options.hashSweepInterval !== 0 && this.options.hashSweepInterval !== Number.POSITIVE_INFINITY) {
|
| 1181 |
-
validateMaxInterval(this.options.hashSweepInterval);
|
| 1182 |
-
this.hashTimer = setInterval(() => {
|
| 1183 |
-
const sweptHashes = new Collection();
|
| 1184 |
-
const currentDate = Date.now();
|
| 1185 |
-
this.hashes.sweep((val, key) => {
|
| 1186 |
-
if (val.lastAccess === -1) 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 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] = 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 = 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.6.0";
|
| 1446 |
-
|
| 1447 |
-
// src/index.ts
|
| 1448 |
-
globalThis.FormData ??= FormData2;
|
| 1449 |
-
globalThis.Blob ??= Blob2;
|
| 1450 |
-
setDefaultStrategy(shouldUseGlobalFetchAndWebSocket() ? fetch : makeRequest);
|
| 1451 |
-
export {
|
| 1452 |
-
ALLOWED_EXTENSIONS,
|
| 1453 |
-
ALLOWED_SIZES,
|
| 1454 |
-
ALLOWED_STICKER_EXTENSIONS,
|
| 1455 |
-
BurstHandlerMajorIdKey,
|
| 1456 |
-
CDN,
|
| 1457 |
-
DEPRECATION_WARNING_PREFIX,
|
| 1458 |
-
DefaultRestOptions,
|
| 1459 |
-
DefaultUserAgent,
|
| 1460 |
-
DefaultUserAgentAppendix,
|
| 1461 |
-
DiscordAPIError,
|
| 1462 |
-
HTTPError,
|
| 1463 |
-
OverwrittenMimeTypes,
|
| 1464 |
-
REST,
|
| 1465 |
-
RESTEvents,
|
| 1466 |
-
RateLimitError,
|
| 1467 |
-
RequestMethod,
|
| 1468 |
-
calculateUserDefaultAvatarIndex,
|
| 1469 |
-
makeURLSearchParams,
|
| 1470 |
-
parseResponse,
|
| 1471 |
-
version
|
| 1472 |
-
};
|
| 1473 |
-
//# sourceMappingURL=index.mjs.map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/rest/dist/index.mjs.map
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
workspace/discord-bot/node_modules/@discordjs/rest/dist/strategies/undiciRequest.d.mts
DELETED
|
@@ -1,13 +0,0 @@
|
|
| 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 { type RequestOptions, makeRequest, resolveBody };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/rest/dist/strategies/undiciRequest.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
| 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 { type RequestOptions, makeRequest, resolveBody };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/rest/dist/strategies/undiciRequest.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
| 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/rest/dist/strategies/undiciRequest.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
| 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;AAGxF,QAAM,UAAU;AAAA,IACf,GAAG;AAAA,IACH,MAAM,MAAM,YAAY,KAAK,IAAI;AAAA,EACl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aAAO,KAAK,KAAK;AAAA,IAClB;AAEA,WAAO,OAAO,OAAO,MAAM;AAAA,EAC5B;AAEA,QAAM,IAAI,UAAU,yBAAyB;AAC9C;AAjCsB;","names":[]}
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/rest/dist/strategies/undiciRequest.mjs
DELETED
|
@@ -1,70 +0,0 @@
|
|
| 1 |
-
var __defProp = Object.defineProperty;
|
| 2 |
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
| 3 |
-
|
| 4 |
-
// src/strategies/undiciRequest.ts
|
| 5 |
-
import { STATUS_CODES } from "node:http";
|
| 6 |
-
import { URLSearchParams } from "node:url";
|
| 7 |
-
import { types } from "node:util";
|
| 8 |
-
import { request, Headers } from "undici";
|
| 9 |
-
async function makeRequest(url, init) {
|
| 10 |
-
const options = {
|
| 11 |
-
...init,
|
| 12 |
-
body: await resolveBody(init.body)
|
| 13 |
-
};
|
| 14 |
-
const res = await request(url, options);
|
| 15 |
-
return {
|
| 16 |
-
body: res.body,
|
| 17 |
-
async arrayBuffer() {
|
| 18 |
-
return res.body.arrayBuffer();
|
| 19 |
-
},
|
| 20 |
-
async json() {
|
| 21 |
-
return res.body.json();
|
| 22 |
-
},
|
| 23 |
-
async text() {
|
| 24 |
-
return res.body.text();
|
| 25 |
-
},
|
| 26 |
-
get bodyUsed() {
|
| 27 |
-
return res.body.bodyUsed;
|
| 28 |
-
},
|
| 29 |
-
headers: new Headers(res.headers),
|
| 30 |
-
status: res.statusCode,
|
| 31 |
-
statusText: STATUS_CODES[res.statusCode],
|
| 32 |
-
ok: res.statusCode >= 200 && res.statusCode < 300
|
| 33 |
-
};
|
| 34 |
-
}
|
| 35 |
-
__name(makeRequest, "makeRequest");
|
| 36 |
-
async function resolveBody(body) {
|
| 37 |
-
if (body == null) {
|
| 38 |
-
return null;
|
| 39 |
-
} else if (typeof body === "string") {
|
| 40 |
-
return body;
|
| 41 |
-
} else if (types.isUint8Array(body)) {
|
| 42 |
-
return body;
|
| 43 |
-
} else if (types.isArrayBuffer(body)) {
|
| 44 |
-
return new Uint8Array(body);
|
| 45 |
-
} else if (body instanceof URLSearchParams) {
|
| 46 |
-
return body.toString();
|
| 47 |
-
} else if (body instanceof DataView) {
|
| 48 |
-
return new Uint8Array(body.buffer);
|
| 49 |
-
} else if (body instanceof Blob) {
|
| 50 |
-
return new Uint8Array(await body.arrayBuffer());
|
| 51 |
-
} else if (body instanceof FormData) {
|
| 52 |
-
return body;
|
| 53 |
-
} else if (body[Symbol.iterator]) {
|
| 54 |
-
const chunks = [...body];
|
| 55 |
-
return Buffer.concat(chunks);
|
| 56 |
-
} else if (body[Symbol.asyncIterator]) {
|
| 57 |
-
const chunks = [];
|
| 58 |
-
for await (const chunk of body) {
|
| 59 |
-
chunks.push(chunk);
|
| 60 |
-
}
|
| 61 |
-
return Buffer.concat(chunks);
|
| 62 |
-
}
|
| 63 |
-
throw new TypeError(`Unable to resolve body.`);
|
| 64 |
-
}
|
| 65 |
-
__name(resolveBody, "resolveBody");
|
| 66 |
-
export {
|
| 67 |
-
makeRequest,
|
| 68 |
-
resolveBody
|
| 69 |
-
};
|
| 70 |
-
//# sourceMappingURL=undiciRequest.mjs.map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/rest/dist/strategies/undiciRequest.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
| 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,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,aAAa;AACtB,SAA2B,SAAS,eAAe;AAKnD,eAAsB,YAAY,KAAa,MAA0C;AAGxF,QAAM,UAAU;AAAA,IACf,GAAG;AAAA,IACH,MAAM,MAAM,YAAY,KAAK,IAAI;AAAA,EAClC;AACA,QAAM,MAAM,MAAM,QAAQ,KAAK,OAAO;AACtC,SAAO;AAAA,IACN,MAAM,IAAI;AAAA,IACV,MAAM,cAAc;AACnB,aAAO,IAAI,KAAK,YAAY;AAAA,IAC7B;AAAA,IACA,MAAM,OAAO;AACZ,aAAO,IAAI,KAAK,KAAK;AAAA,IACtB;AAAA,IACA,MAAM,OAAO;AACZ,aAAO,IAAI,KAAK,KAAK;AAAA,IACtB;AAAA,IACA,IAAI,WAAW;AACd,aAAO,IAAI,KAAK;AAAA,IACjB;AAAA,IACA,SAAS,IAAI,QAAQ,IAAI,OAA4C;AAAA,IACrE,QAAQ,IAAI;AAAA,IACZ,YAAY,aAAa,IAAI,UAAU;AAAA,IACvC,IAAI,IAAI,cAAc,OAAO,IAAI,aAAa;AAAA,EAC/C;AACD;AA3BsB;AA6BtB,eAAsB,YAAY,MAAgF;AAEjH,MAAI,QAAQ,MAAM;AACjB,WAAO;AAAA,EACR,WAAW,OAAO,SAAS,UAAU;AACpC,WAAO;AAAA,EACR,WAAW,MAAM,aAAa,IAAI,GAAG;AACpC,WAAO;AAAA,EACR,WAAW,MAAM,cAAc,IAAI,GAAG;AACrC,WAAO,IAAI,WAAW,IAAI;AAAA,EAC3B,WAAW,gBAAgB,iBAAiB;AAC3C,WAAO,KAAK,SAAS;AAAA,EACtB,WAAW,gBAAgB,UAAU;AACpC,WAAO,IAAI,WAAW,KAAK,MAAM;AAAA,EAClC,WAAW,gBAAgB,MAAM;AAChC,WAAO,IAAI,WAAW,MAAM,KAAK,YAAY,CAAC;AAAA,EAC/C,WAAW,gBAAgB,UAAU;AACpC,WAAO;AAAA,EACR,WAAY,KAA8B,OAAO,QAAQ,GAAG;AAC3D,UAAM,SAAS,CAAC,GAAI,IAA6B;AAEjD,WAAO,OAAO,OAAO,MAAM;AAAA,EAC5B,WAAY,KAAmC,OAAO,aAAa,GAAG;AACrE,UAAM,SAAuB,CAAC;AAE9B,qBAAiB,SAAS,MAAmC;AAC5D,aAAO,KAAK,KAAK;AAAA,IAClB;AAEA,WAAO,OAAO,OAAO,MAAM;AAAA,EAC5B;AAEA,QAAM,IAAI,UAAU,yBAAyB;AAC9C;AAjCsB;","names":[]}
|
|
|
|
|
|
workspace/discord-bot/node_modules/@discordjs/rest/dist/web.d.mts
DELETED
|
@@ -1,958 +0,0 @@
|
|
| 1 |
-
import * as url from 'url';
|
| 2 |
-
import { ImageSize, Snowflake } from 'discord-api-types/v10';
|
| 3 |
-
export { ImageSize } from 'discord-api-types/v10';
|
| 4 |
-
import { Readable } from 'node:stream';
|
| 5 |
-
import { ReadableStream } from 'node:stream/web';
|
| 6 |
-
import { Collection } from '@discordjs/collection';
|
| 7 |
-
import { Awaitable } from '@discordjs/util';
|
| 8 |
-
import * as undici from 'undici';
|
| 9 |
-
import { RequestInit, Dispatcher, Response, BodyInit, Agent } from 'undici';
|
| 10 |
-
import { AsyncEventEmitter } from '@vladfrangu/async_event_emitter';
|
| 11 |
-
|
| 12 |
-
interface IHandler {
|
| 13 |
-
/**
|
| 14 |
-
* The unique id of the handler
|
| 15 |
-
*/
|
| 16 |
-
readonly id: string;
|
| 17 |
-
/**
|
| 18 |
-
* If the bucket is currently inactive (no pending requests)
|
| 19 |
-
*/
|
| 20 |
-
get inactive(): boolean;
|
| 21 |
-
/**
|
| 22 |
-
* Queues a request to be sent
|
| 23 |
-
*
|
| 24 |
-
* @param routeId - The generalized api route with literal ids for major parameters
|
| 25 |
-
* @param url - The url to do the request on
|
| 26 |
-
* @param options - All the information needed to make a request
|
| 27 |
-
* @param requestData - Extra data from the user's request needed for errors and additional processing
|
| 28 |
-
*/
|
| 29 |
-
queueRequest(routeId: RouteData, url: string, options: RequestInit, requestData: HandlerRequestData): Promise<ResponseLike>;
|
| 30 |
-
}
|
| 31 |
-
|
| 32 |
-
interface RestEvents {
|
| 33 |
-
handlerSweep: [sweptHandlers: Collection<string, IHandler>];
|
| 34 |
-
hashSweep: [sweptHashes: Collection<string, HashData>];
|
| 35 |
-
invalidRequestWarning: [invalidRequestInfo: InvalidRequestWarningData];
|
| 36 |
-
rateLimited: [rateLimitInfo: RateLimitData];
|
| 37 |
-
response: [request: APIRequest, response: ResponseLike];
|
| 38 |
-
restDebug: [info: string];
|
| 39 |
-
}
|
| 40 |
-
interface RestEventsMap extends RestEvents {
|
| 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 media proxy path
|
| 113 |
-
*
|
| 114 |
-
* @defaultValue `'https://media.discordapp.net'`
|
| 115 |
-
*/
|
| 116 |
-
mediaProxy: string;
|
| 117 |
-
/**
|
| 118 |
-
* The extra offset to add to rate limits in milliseconds
|
| 119 |
-
*
|
| 120 |
-
* @defaultValue `50`
|
| 121 |
-
*/
|
| 122 |
-
offset: GetRateLimitOffsetFunction | number;
|
| 123 |
-
/**
|
| 124 |
-
* Determines how rate limiting and pre-emptive throttling should be handled.
|
| 125 |
-
* When an array of strings, each element is treated as a prefix for the request route
|
| 126 |
-
* (e.g. `/channels` to match any route starting with `/channels` such as `/channels/:id/messages`)
|
| 127 |
-
* for which to throw {@link RateLimitError}s. All other request routes will be queued normally
|
| 128 |
-
*
|
| 129 |
-
* @defaultValue `null`
|
| 130 |
-
*/
|
| 131 |
-
rejectOnRateLimit: RateLimitQueueFilter | string[] | null;
|
| 132 |
-
/**
|
| 133 |
-
* The number of retries for errors with the 500 code, or errors
|
| 134 |
-
* that timeout
|
| 135 |
-
*
|
| 136 |
-
* @defaultValue `3`
|
| 137 |
-
*/
|
| 138 |
-
retries: number;
|
| 139 |
-
/**
|
| 140 |
-
* The time to wait in milliseconds before a request is aborted
|
| 141 |
-
*
|
| 142 |
-
* @defaultValue `15_000`
|
| 143 |
-
*/
|
| 144 |
-
timeout: number;
|
| 145 |
-
/**
|
| 146 |
-
* Extra information to add to the user agent
|
| 147 |
-
*
|
| 148 |
-
* @defaultValue DefaultUserAgentAppendix
|
| 149 |
-
*/
|
| 150 |
-
userAgentAppendix: string;
|
| 151 |
-
/**
|
| 152 |
-
* The version of the API to use
|
| 153 |
-
*
|
| 154 |
-
* @defaultValue `'10'`
|
| 155 |
-
*/
|
| 156 |
-
version: string;
|
| 157 |
-
}
|
| 158 |
-
/**
|
| 159 |
-
* Data emitted on `RESTEvents.RateLimited`
|
| 160 |
-
*/
|
| 161 |
-
interface RateLimitData {
|
| 162 |
-
/**
|
| 163 |
-
* Whether the rate limit that was reached was the global limit
|
| 164 |
-
*/
|
| 165 |
-
global: boolean;
|
| 166 |
-
/**
|
| 167 |
-
* The bucket hash for this request
|
| 168 |
-
*/
|
| 169 |
-
hash: string;
|
| 170 |
-
/**
|
| 171 |
-
* The amount of requests we can perform before locking requests
|
| 172 |
-
*/
|
| 173 |
-
limit: number;
|
| 174 |
-
/**
|
| 175 |
-
* The major parameter of the route
|
| 176 |
-
*
|
| 177 |
-
* For example, in `/channels/x`, this will be `x`.
|
| 178 |
-
* If there is no major parameter (e.g: `/bot/gateway`) this will be `global`.
|
| 179 |
-
*/
|
| 180 |
-
majorParameter: string;
|
| 181 |
-
/**
|
| 182 |
-
* The HTTP method being performed
|
| 183 |
-
*/
|
| 184 |
-
method: string;
|
| 185 |
-
/**
|
| 186 |
-
* The time, in milliseconds, that will need to pass before this specific request can be retried
|
| 187 |
-
*/
|
| 188 |
-
retryAfter: number;
|
| 189 |
-
/**
|
| 190 |
-
* The route being hit in this request
|
| 191 |
-
*/
|
| 192 |
-
route: string;
|
| 193 |
-
/**
|
| 194 |
-
* The scope of the rate limit that was hit.
|
| 195 |
-
*
|
| 196 |
-
* 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
|
| 197 |
-
* are shared per resource.
|
| 198 |
-
*/
|
| 199 |
-
scope: 'global' | 'shared' | 'user';
|
| 200 |
-
/**
|
| 201 |
-
* The time, in milliseconds, that will need to pass before the sublimit lock for the route resets, and requests that fall under a sublimit
|
| 202 |
-
* can be retried
|
| 203 |
-
*
|
| 204 |
-
* This is only present on certain sublimits, and `0` otherwise
|
| 205 |
-
*/
|
| 206 |
-
sublimitTimeout: number;
|
| 207 |
-
/**
|
| 208 |
-
* The time, in milliseconds, until the route's request-lock is reset
|
| 209 |
-
*/
|
| 210 |
-
timeToReset: number;
|
| 211 |
-
/**
|
| 212 |
-
* The full URL for this request
|
| 213 |
-
*/
|
| 214 |
-
url: string;
|
| 215 |
-
}
|
| 216 |
-
/**
|
| 217 |
-
* A function that determines whether the rate limit hit should throw an Error
|
| 218 |
-
*/
|
| 219 |
-
type RateLimitQueueFilter = (rateLimitData: RateLimitData) => Awaitable<boolean>;
|
| 220 |
-
/**
|
| 221 |
-
* A function that determines the rate limit offset for a given request.
|
| 222 |
-
*/
|
| 223 |
-
type GetRateLimitOffsetFunction = (route: string) => number;
|
| 224 |
-
interface APIRequest {
|
| 225 |
-
/**
|
| 226 |
-
* The data that was used to form the body of this request
|
| 227 |
-
*/
|
| 228 |
-
data: HandlerRequestData;
|
| 229 |
-
/**
|
| 230 |
-
* The HTTP method used in this request
|
| 231 |
-
*/
|
| 232 |
-
method: string;
|
| 233 |
-
/**
|
| 234 |
-
* Additional HTTP options for this request
|
| 235 |
-
*/
|
| 236 |
-
options: RequestInit;
|
| 237 |
-
/**
|
| 238 |
-
* The full path used to make the request
|
| 239 |
-
*/
|
| 240 |
-
path: RouteLike;
|
| 241 |
-
/**
|
| 242 |
-
* The number of times this request has been attempted
|
| 243 |
-
*/
|
| 244 |
-
retries: number;
|
| 245 |
-
/**
|
| 246 |
-
* The API route identifying the ratelimit for this request
|
| 247 |
-
*/
|
| 248 |
-
route: string;
|
| 249 |
-
}
|
| 250 |
-
interface ResponseLike extends Pick<Response, 'arrayBuffer' | 'bodyUsed' | 'headers' | 'json' | 'ok' | 'status' | 'statusText' | 'text'> {
|
| 251 |
-
body: Readable | ReadableStream | null;
|
| 252 |
-
}
|
| 253 |
-
interface InvalidRequestWarningData {
|
| 254 |
-
/**
|
| 255 |
-
* Number of invalid requests that have been made in the window
|
| 256 |
-
*/
|
| 257 |
-
count: number;
|
| 258 |
-
/**
|
| 259 |
-
* Time in milliseconds remaining before the count resets
|
| 260 |
-
*/
|
| 261 |
-
remainingTime: number;
|
| 262 |
-
}
|
| 263 |
-
/**
|
| 264 |
-
* Represents a file to be added to the request
|
| 265 |
-
*/
|
| 266 |
-
interface RawFile {
|
| 267 |
-
/**
|
| 268 |
-
* Content-Type of the file
|
| 269 |
-
*/
|
| 270 |
-
contentType?: string;
|
| 271 |
-
/**
|
| 272 |
-
* The actual data for the file
|
| 273 |
-
*/
|
| 274 |
-
data: Buffer | Uint8Array | boolean | number | string;
|
| 275 |
-
/**
|
| 276 |
-
* An explicit key to use for key of the formdata field for this file.
|
| 277 |
-
* When not provided, the index of the file in the files array is used in the form `files[${index}]`.
|
| 278 |
-
* If you wish to alter the placeholder snowflake, you must provide this property in the same form (`files[${placeholder}]`)
|
| 279 |
-
*/
|
| 280 |
-
key?: string;
|
| 281 |
-
/**
|
| 282 |
-
* The name of the file
|
| 283 |
-
*/
|
| 284 |
-
name: string;
|
| 285 |
-
}
|
| 286 |
-
/**
|
| 287 |
-
* Represents possible data to be given to an endpoint
|
| 288 |
-
*/
|
| 289 |
-
interface RequestData {
|
| 290 |
-
/**
|
| 291 |
-
* Whether to append JSON data to form data instead of `payload_json` when sending files
|
| 292 |
-
*/
|
| 293 |
-
appendToFormData?: boolean;
|
| 294 |
-
/**
|
| 295 |
-
* If this request needs the `Authorization` header
|
| 296 |
-
*
|
| 297 |
-
* @defaultValue `true`
|
| 298 |
-
*/
|
| 299 |
-
auth?: boolean;
|
| 300 |
-
/**
|
| 301 |
-
* The authorization prefix to use for this request, useful if you use this with bearer tokens
|
| 302 |
-
*
|
| 303 |
-
* @defaultValue `'Bot'`
|
| 304 |
-
*/
|
| 305 |
-
authPrefix?: 'Bearer' | 'Bot';
|
| 306 |
-
/**
|
| 307 |
-
* The body to send to this request.
|
| 308 |
-
* If providing as BodyInit, set `passThroughBody: true`
|
| 309 |
-
*/
|
| 310 |
-
body?: BodyInit | unknown;
|
| 311 |
-
/**
|
| 312 |
-
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} to use for the request.
|
| 313 |
-
*/
|
| 314 |
-
dispatcher?: Agent;
|
| 315 |
-
/**
|
| 316 |
-
* Files to be attached to this request
|
| 317 |
-
*/
|
| 318 |
-
files?: RawFile[] | undefined;
|
| 319 |
-
/**
|
| 320 |
-
* Additional headers to add to this request
|
| 321 |
-
*/
|
| 322 |
-
headers?: Record<string, string>;
|
| 323 |
-
/**
|
| 324 |
-
* Whether to pass-through the body property directly to `fetch()`.
|
| 325 |
-
* <warn>This only applies when files is NOT present</warn>
|
| 326 |
-
*/
|
| 327 |
-
passThroughBody?: boolean;
|
| 328 |
-
/**
|
| 329 |
-
* Query string parameters to append to the called endpoint
|
| 330 |
-
*/
|
| 331 |
-
query?: URLSearchParams;
|
| 332 |
-
/**
|
| 333 |
-
* Reason to show in the audit logs
|
| 334 |
-
*/
|
| 335 |
-
reason?: string | undefined;
|
| 336 |
-
/**
|
| 337 |
-
* The signal to abort the queue entry or the REST call, where applicable
|
| 338 |
-
*/
|
| 339 |
-
signal?: AbortSignal | undefined;
|
| 340 |
-
/**
|
| 341 |
-
* If this request should be versioned
|
| 342 |
-
*
|
| 343 |
-
* @defaultValue `true`
|
| 344 |
-
*/
|
| 345 |
-
versioned?: boolean;
|
| 346 |
-
}
|
| 347 |
-
/**
|
| 348 |
-
* Possible headers for an API call
|
| 349 |
-
*/
|
| 350 |
-
interface RequestHeaders {
|
| 351 |
-
Authorization?: string;
|
| 352 |
-
'User-Agent': string;
|
| 353 |
-
'X-Audit-Log-Reason'?: string;
|
| 354 |
-
}
|
| 355 |
-
/**
|
| 356 |
-
* Possible API methods to be used when doing requests
|
| 357 |
-
*/
|
| 358 |
-
declare enum RequestMethod {
|
| 359 |
-
Delete = "DELETE",
|
| 360 |
-
Get = "GET",
|
| 361 |
-
Patch = "PATCH",
|
| 362 |
-
Post = "POST",
|
| 363 |
-
Put = "PUT"
|
| 364 |
-
}
|
| 365 |
-
type RouteLike = `/${string}`;
|
| 366 |
-
/**
|
| 367 |
-
* Internal request options
|
| 368 |
-
*
|
| 369 |
-
* @internal
|
| 370 |
-
*/
|
| 371 |
-
interface InternalRequest extends RequestData {
|
| 372 |
-
fullRoute: RouteLike;
|
| 373 |
-
method: RequestMethod;
|
| 374 |
-
}
|
| 375 |
-
type HandlerRequestData = Pick<InternalRequest, 'auth' | 'body' | 'files' | 'signal'>;
|
| 376 |
-
/**
|
| 377 |
-
* Parsed route data for an endpoint
|
| 378 |
-
*
|
| 379 |
-
* @internal
|
| 380 |
-
*/
|
| 381 |
-
interface RouteData {
|
| 382 |
-
bucketRoute: string;
|
| 383 |
-
majorParameter: string;
|
| 384 |
-
original: RouteLike;
|
| 385 |
-
}
|
| 386 |
-
/**
|
| 387 |
-
* Represents a hash and its associated fields
|
| 388 |
-
*
|
| 389 |
-
* @internal
|
| 390 |
-
*/
|
| 391 |
-
interface HashData {
|
| 392 |
-
lastAccess: number;
|
| 393 |
-
value: string;
|
| 394 |
-
}
|
| 395 |
-
|
| 396 |
-
declare const DefaultUserAgent: `DiscordBot (https://discord.js.org, ${string})`;
|
| 397 |
-
/**
|
| 398 |
-
* The default string to append onto the user agent.
|
| 399 |
-
*/
|
| 400 |
-
declare const DefaultUserAgentAppendix: string;
|
| 401 |
-
declare const DefaultRestOptions: {
|
| 402 |
-
readonly agent: null;
|
| 403 |
-
readonly api: "https://discord.com/api";
|
| 404 |
-
readonly authPrefix: "Bot";
|
| 405 |
-
readonly cdn: "https://cdn.discordapp.com";
|
| 406 |
-
readonly headers: {};
|
| 407 |
-
readonly invalidRequestWarningInterval: 0;
|
| 408 |
-
readonly globalRequestsPerSecond: 50;
|
| 409 |
-
readonly offset: 50;
|
| 410 |
-
readonly rejectOnRateLimit: null;
|
| 411 |
-
readonly retries: 3;
|
| 412 |
-
readonly timeout: 15000;
|
| 413 |
-
readonly userAgentAppendix: string;
|
| 414 |
-
readonly version: "10";
|
| 415 |
-
readonly hashSweepInterval: 14400000;
|
| 416 |
-
readonly hashLifetime: 86400000;
|
| 417 |
-
readonly handlerSweepInterval: 3600000;
|
| 418 |
-
readonly makeRequest: (url: string, init: undici.RequestInit) => Promise<ResponseLike>;
|
| 419 |
-
readonly mediaProxy: "https://media.discordapp.net";
|
| 420 |
-
};
|
| 421 |
-
/**
|
| 422 |
-
* The events that the REST manager emits
|
| 423 |
-
*/
|
| 424 |
-
declare enum RESTEvents {
|
| 425 |
-
Debug = "restDebug",
|
| 426 |
-
HandlerSweep = "handlerSweep",
|
| 427 |
-
HashSweep = "hashSweep",
|
| 428 |
-
InvalidRequestWarning = "invalidRequestWarning",
|
| 429 |
-
RateLimited = "rateLimited",
|
| 430 |
-
Response = "response"
|
| 431 |
-
}
|
| 432 |
-
declare const ALLOWED_EXTENSIONS: readonly ["webp", "png", "jpg", "jpeg", "gif"];
|
| 433 |
-
declare const ALLOWED_STICKER_EXTENSIONS: readonly ["png", "json", "gif"];
|
| 434 |
-
declare const ALLOWED_SIZES: readonly number[];
|
| 435 |
-
type ImageExtension = (typeof ALLOWED_EXTENSIONS)[number];
|
| 436 |
-
type StickerExtension = (typeof ALLOWED_STICKER_EXTENSIONS)[number];
|
| 437 |
-
declare const OverwrittenMimeTypes: {
|
| 438 |
-
readonly 'image/apng': "image/png";
|
| 439 |
-
};
|
| 440 |
-
declare const BurstHandlerMajorIdKey = "burst";
|
| 441 |
-
/**
|
| 442 |
-
* Prefix for deprecation warnings.
|
| 443 |
-
*
|
| 444 |
-
* @internal
|
| 445 |
-
*/
|
| 446 |
-
declare const DEPRECATION_WARNING_PREFIX: "DeprecationWarning";
|
| 447 |
-
|
| 448 |
-
/**
|
| 449 |
-
* The options used for image URLs.
|
| 450 |
-
*/
|
| 451 |
-
interface BaseImageURLOptions {
|
| 452 |
-
/**
|
| 453 |
-
* The extension to use for the image URL.
|
| 454 |
-
*
|
| 455 |
-
* @defaultValue `'webp'`
|
| 456 |
-
*/
|
| 457 |
-
extension?: ImageExtension;
|
| 458 |
-
/**
|
| 459 |
-
* The size specified in the image URL.
|
| 460 |
-
*/
|
| 461 |
-
size?: ImageSize;
|
| 462 |
-
}
|
| 463 |
-
interface EmojiURLOptionsWebp extends BaseImageURLOptions {
|
| 464 |
-
/**
|
| 465 |
-
* Whether to use the `animated` query parameter.
|
| 466 |
-
*/
|
| 467 |
-
animated?: boolean;
|
| 468 |
-
extension?: 'webp';
|
| 469 |
-
}
|
| 470 |
-
interface EmojiURLOptionsNotWebp extends BaseImageURLOptions {
|
| 471 |
-
extension: Exclude<ImageExtension, 'webp'>;
|
| 472 |
-
}
|
| 473 |
-
/**
|
| 474 |
-
* The options used for emoji URLs.
|
| 475 |
-
*/
|
| 476 |
-
type EmojiURLOptions = EmojiURLOptionsNotWebp | EmojiURLOptionsWebp;
|
| 477 |
-
/**
|
| 478 |
-
* The options used for image URLs that may be animated.
|
| 479 |
-
*/
|
| 480 |
-
interface ImageURLOptions extends BaseImageURLOptions {
|
| 481 |
-
/**
|
| 482 |
-
* Whether to prefer the static asset.
|
| 483 |
-
*/
|
| 484 |
-
forceStatic?: boolean;
|
| 485 |
-
}
|
| 486 |
-
/**
|
| 487 |
-
* The options to use when making a CDN URL
|
| 488 |
-
*/
|
| 489 |
-
interface MakeURLOptions {
|
| 490 |
-
/**
|
| 491 |
-
* The allowed extensions that can be used
|
| 492 |
-
*/
|
| 493 |
-
allowedExtensions?: readonly string[];
|
| 494 |
-
/**
|
| 495 |
-
* Whether to use the `animated` query parameter
|
| 496 |
-
*/
|
| 497 |
-
animated?: boolean;
|
| 498 |
-
/**
|
| 499 |
-
* The base URL.
|
| 500 |
-
*
|
| 501 |
-
* @defaultValue `DefaultRestOptions.cdn`
|
| 502 |
-
*/
|
| 503 |
-
base?: string;
|
| 504 |
-
/**
|
| 505 |
-
* The extension to use for the image URL
|
| 506 |
-
*
|
| 507 |
-
* @defaultValue `'webp'`
|
| 508 |
-
*/
|
| 509 |
-
extension?: string | undefined;
|
| 510 |
-
/**
|
| 511 |
-
* The size specified in the image URL
|
| 512 |
-
*/
|
| 513 |
-
size?: ImageSize;
|
| 514 |
-
}
|
| 515 |
-
/**
|
| 516 |
-
* The CDN link builder
|
| 517 |
-
*/
|
| 518 |
-
declare class CDN {
|
| 519 |
-
private readonly cdn;
|
| 520 |
-
private readonly mediaProxy;
|
| 521 |
-
constructor(cdn?: string, mediaProxy?: string);
|
| 522 |
-
/**
|
| 523 |
-
* Generates an app asset URL for a client's asset.
|
| 524 |
-
*
|
| 525 |
-
* @param clientId - The client id that has the asset
|
| 526 |
-
* @param assetHash - The hash provided by Discord for this asset
|
| 527 |
-
* @param options - Optional options for the asset
|
| 528 |
-
*/
|
| 529 |
-
appAsset(clientId: string, assetHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 530 |
-
/**
|
| 531 |
-
* Generates an app icon URL for a client's icon.
|
| 532 |
-
*
|
| 533 |
-
* @param clientId - The client id that has the icon
|
| 534 |
-
* @param iconHash - The hash provided by Discord for this icon
|
| 535 |
-
* @param options - Optional options for the icon
|
| 536 |
-
*/
|
| 537 |
-
appIcon(clientId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 538 |
-
/**
|
| 539 |
-
* Generates an avatar URL, e.g. for a user or a webhook.
|
| 540 |
-
*
|
| 541 |
-
* @param id - The id that has the icon
|
| 542 |
-
* @param avatarHash - The hash provided by Discord for this avatar
|
| 543 |
-
* @param options - Optional options for the avatar
|
| 544 |
-
*/
|
| 545 |
-
avatar(id: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
| 546 |
-
/**
|
| 547 |
-
* Generates a user avatar decoration preset URL.
|
| 548 |
-
*
|
| 549 |
-
* @param asset - The avatar decoration hash
|
| 550 |
-
*/
|
| 551 |
-
avatarDecoration(asset: string): string;
|
| 552 |
-
/**
|
| 553 |
-
* Generates a user avatar decoration URL.
|
| 554 |
-
*
|
| 555 |
-
* @deprecated This overload is deprecated. Pass a hash instead.
|
| 556 |
-
* @param userId - The id of the user
|
| 557 |
-
* @param userAvatarDecoration - The hash provided by Discord for this avatar decoration
|
| 558 |
-
* @param options - Optional options for the avatar decoration
|
| 559 |
-
*/
|
| 560 |
-
avatarDecoration(userId: string, userAvatarDecoration: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 561 |
-
/**
|
| 562 |
-
* Generates a banner URL, e.g. for a user or a guild.
|
| 563 |
-
*
|
| 564 |
-
* @param id - The id that has the banner splash
|
| 565 |
-
* @param bannerHash - The hash provided by Discord for this banner
|
| 566 |
-
* @param options - Optional options for the banner
|
| 567 |
-
*/
|
| 568 |
-
banner(id: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
| 569 |
-
/**
|
| 570 |
-
* Generates an icon URL for a channel, e.g. a group DM.
|
| 571 |
-
*
|
| 572 |
-
* @param channelId - The channel id that has the icon
|
| 573 |
-
* @param iconHash - The hash provided by Discord for this channel
|
| 574 |
-
* @param options - Optional options for the icon
|
| 575 |
-
*/
|
| 576 |
-
channelIcon(channelId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 577 |
-
/**
|
| 578 |
-
* Generates a default avatar URL
|
| 579 |
-
*
|
| 580 |
-
* @param index - The default avatar index
|
| 581 |
-
* @remarks
|
| 582 |
-
* To calculate the index for a user do `(userId >> 22) % 6`,
|
| 583 |
-
* or `discriminator % 5` if they're using the legacy username system.
|
| 584 |
-
*/
|
| 585 |
-
defaultAvatar(index: number): string;
|
| 586 |
-
/**
|
| 587 |
-
* Generates a discovery splash URL for a guild's discovery splash.
|
| 588 |
-
*
|
| 589 |
-
* @param guildId - The guild id that has the discovery splash
|
| 590 |
-
* @param splashHash - The hash provided by Discord for this splash
|
| 591 |
-
* @param options - Optional options for the splash
|
| 592 |
-
*/
|
| 593 |
-
discoverySplash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 594 |
-
/**
|
| 595 |
-
* Generates an emoji's URL for an emoji.
|
| 596 |
-
*
|
| 597 |
-
* @param emojiId - The emoji id
|
| 598 |
-
* @param options - Optional options for the emoji
|
| 599 |
-
*/
|
| 600 |
-
emoji(emojiId: string, options?: Readonly<EmojiURLOptions>): string;
|
| 601 |
-
/**
|
| 602 |
-
* Generates an emoji's URL for an emoji.
|
| 603 |
-
*
|
| 604 |
-
* @param emojiId - The emoji id
|
| 605 |
-
* @param extension - The extension of the emoji
|
| 606 |
-
* @deprecated This overload is deprecated. Pass an object containing the extension instead.
|
| 607 |
-
*/
|
| 608 |
-
emoji(emojiId: string, extension?: ImageExtension): string;
|
| 609 |
-
/**
|
| 610 |
-
* Generates a guild member avatar URL.
|
| 611 |
-
*
|
| 612 |
-
* @param guildId - The id of the guild
|
| 613 |
-
* @param userId - The id of the user
|
| 614 |
-
* @param avatarHash - The hash provided by Discord for this avatar
|
| 615 |
-
* @param options - Optional options for the avatar
|
| 616 |
-
*/
|
| 617 |
-
guildMemberAvatar(guildId: string, userId: string, avatarHash: string, options?: Readonly<ImageURLOptions>): string;
|
| 618 |
-
/**
|
| 619 |
-
* Generates a guild member banner URL.
|
| 620 |
-
*
|
| 621 |
-
* @param guildId - The id of the guild
|
| 622 |
-
* @param userId - The id of the user
|
| 623 |
-
* @param bannerHash - The hash provided by Discord for this banner
|
| 624 |
-
* @param options - Optional options for the banner
|
| 625 |
-
*/
|
| 626 |
-
guildMemberBanner(guildId: string, userId: string, bannerHash: string, options?: Readonly<ImageURLOptions>): string;
|
| 627 |
-
/**
|
| 628 |
-
* Generates an icon URL, e.g. for a guild.
|
| 629 |
-
*
|
| 630 |
-
* @param id - The id that has the icon splash
|
| 631 |
-
* @param iconHash - The hash provided by Discord for this icon
|
| 632 |
-
* @param options - Optional options for the icon
|
| 633 |
-
*/
|
| 634 |
-
icon(id: string, iconHash: string, options?: Readonly<ImageURLOptions>): string;
|
| 635 |
-
/**
|
| 636 |
-
* Generates a URL for the icon of a role
|
| 637 |
-
*
|
| 638 |
-
* @param roleId - The id of the role that has the icon
|
| 639 |
-
* @param roleIconHash - The hash provided by Discord for this role icon
|
| 640 |
-
* @param options - Optional options for the role icon
|
| 641 |
-
*/
|
| 642 |
-
roleIcon(roleId: string, roleIconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 643 |
-
/**
|
| 644 |
-
* Generates a guild invite splash URL for a guild's invite splash.
|
| 645 |
-
*
|
| 646 |
-
* @param guildId - The guild id that has the invite splash
|
| 647 |
-
* @param splashHash - The hash provided by Discord for this splash
|
| 648 |
-
* @param options - Optional options for the splash
|
| 649 |
-
*/
|
| 650 |
-
splash(guildId: string, splashHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 651 |
-
/**
|
| 652 |
-
* Generates a sticker URL.
|
| 653 |
-
*
|
| 654 |
-
* @param stickerId - The sticker id
|
| 655 |
-
* @param extension - The extension of the sticker
|
| 656 |
-
* @privateRemarks
|
| 657 |
-
* Stickers cannot have a `.webp` extension, so we default to a `.png`.
|
| 658 |
-
* Sticker GIFs do not use the CDN base URL.
|
| 659 |
-
*/
|
| 660 |
-
sticker(stickerId: string, extension?: StickerExtension): string;
|
| 661 |
-
/**
|
| 662 |
-
* Generates a sticker pack banner URL.
|
| 663 |
-
*
|
| 664 |
-
* @param bannerId - The banner id
|
| 665 |
-
* @param options - Optional options for the banner
|
| 666 |
-
*/
|
| 667 |
-
stickerPackBanner(bannerId: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 668 |
-
/**
|
| 669 |
-
* Generates a team icon URL for a team's icon.
|
| 670 |
-
*
|
| 671 |
-
* @param teamId - The team id that has the icon
|
| 672 |
-
* @param iconHash - The hash provided by Discord for this icon
|
| 673 |
-
* @param options - Optional options for the icon
|
| 674 |
-
*/
|
| 675 |
-
teamIcon(teamId: string, iconHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 676 |
-
/**
|
| 677 |
-
* Generates a cover image for a guild scheduled event.
|
| 678 |
-
*
|
| 679 |
-
* @param scheduledEventId - The scheduled event id
|
| 680 |
-
* @param coverHash - The hash provided by discord for this cover image
|
| 681 |
-
* @param options - Optional options for the cover image
|
| 682 |
-
*/
|
| 683 |
-
guildScheduledEventCover(scheduledEventId: string, coverHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 684 |
-
/**
|
| 685 |
-
* Generates a URL for a soundboard sound.
|
| 686 |
-
*
|
| 687 |
-
* @param soundId - The soundboard sound id
|
| 688 |
-
*/
|
| 689 |
-
soundboardSound(soundId: string): string;
|
| 690 |
-
/**
|
| 691 |
-
* Generates a URL for a guild tag badge.
|
| 692 |
-
*
|
| 693 |
-
* @param guildId - The guild id
|
| 694 |
-
* @param badgeHash - The hash of the badge
|
| 695 |
-
* @param options - Optional options for the badge
|
| 696 |
-
*/
|
| 697 |
-
guildTagBadge(guildId: string, badgeHash: string, options?: Readonly<BaseImageURLOptions>): string;
|
| 698 |
-
/**
|
| 699 |
-
* Constructs the URL for the resource, checking whether or not `hash` starts with `a_` if `dynamic` is set to `true`.
|
| 700 |
-
*
|
| 701 |
-
* @param route - The base cdn route
|
| 702 |
-
* @param hash - The hash provided by Discord for this icon
|
| 703 |
-
* @param options - Optional options for the link
|
| 704 |
-
*/
|
| 705 |
-
private dynamicMakeURL;
|
| 706 |
-
/**
|
| 707 |
-
* Constructs the URL for the resource
|
| 708 |
-
*
|
| 709 |
-
* @param route - The base cdn route
|
| 710 |
-
* @param options - The extension/size options for the link
|
| 711 |
-
*/
|
| 712 |
-
private makeURL;
|
| 713 |
-
}
|
| 714 |
-
|
| 715 |
-
interface DiscordErrorFieldInformation {
|
| 716 |
-
code: string;
|
| 717 |
-
message: string;
|
| 718 |
-
}
|
| 719 |
-
interface DiscordErrorGroupWrapper {
|
| 720 |
-
_errors: DiscordError[];
|
| 721 |
-
}
|
| 722 |
-
type DiscordError = DiscordErrorFieldInformation | DiscordErrorGroupWrapper | string | {
|
| 723 |
-
[k: string]: DiscordError;
|
| 724 |
-
};
|
| 725 |
-
interface DiscordErrorData {
|
| 726 |
-
code: number;
|
| 727 |
-
errors?: DiscordError;
|
| 728 |
-
message: string;
|
| 729 |
-
}
|
| 730 |
-
interface OAuthErrorData {
|
| 731 |
-
error: string;
|
| 732 |
-
error_description?: string;
|
| 733 |
-
}
|
| 734 |
-
interface RequestBody {
|
| 735 |
-
files: RawFile[] | undefined;
|
| 736 |
-
json: unknown | undefined;
|
| 737 |
-
}
|
| 738 |
-
/**
|
| 739 |
-
* Represents an API error returned by Discord
|
| 740 |
-
*/
|
| 741 |
-
declare class DiscordAPIError extends Error {
|
| 742 |
-
rawError: DiscordErrorData | OAuthErrorData;
|
| 743 |
-
code: number | string;
|
| 744 |
-
status: number;
|
| 745 |
-
method: string;
|
| 746 |
-
url: string;
|
| 747 |
-
requestBody: RequestBody;
|
| 748 |
-
/**
|
| 749 |
-
* @param rawError - The error reported by Discord
|
| 750 |
-
* @param code - The error code reported by Discord
|
| 751 |
-
* @param status - The status code of the response
|
| 752 |
-
* @param method - The method of the request that erred
|
| 753 |
-
* @param url - The url of the request that erred
|
| 754 |
-
* @param bodyData - The unparsed data for the request that errored
|
| 755 |
-
*/
|
| 756 |
-
constructor(rawError: DiscordErrorData | OAuthErrorData, code: number | string, status: number, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
|
| 757 |
-
/**
|
| 758 |
-
* The name of the error
|
| 759 |
-
*/
|
| 760 |
-
get name(): string;
|
| 761 |
-
private static getMessage;
|
| 762 |
-
private static flattenDiscordError;
|
| 763 |
-
}
|
| 764 |
-
|
| 765 |
-
/**
|
| 766 |
-
* Represents a HTTP error
|
| 767 |
-
*/
|
| 768 |
-
declare class HTTPError extends Error {
|
| 769 |
-
status: number;
|
| 770 |
-
method: string;
|
| 771 |
-
url: string;
|
| 772 |
-
requestBody: RequestBody;
|
| 773 |
-
name: string;
|
| 774 |
-
/**
|
| 775 |
-
* @param status - The status code of the response
|
| 776 |
-
* @param statusText - The status text of the response
|
| 777 |
-
* @param method - The method of the request that erred
|
| 778 |
-
* @param url - The url of the request that erred
|
| 779 |
-
* @param bodyData - The unparsed data for the request that errored
|
| 780 |
-
*/
|
| 781 |
-
constructor(status: number, statusText: string, method: string, url: string, bodyData: Pick<InternalRequest, 'body' | 'files'>);
|
| 782 |
-
}
|
| 783 |
-
|
| 784 |
-
declare class RateLimitError extends Error implements RateLimitData {
|
| 785 |
-
timeToReset: number;
|
| 786 |
-
limit: number;
|
| 787 |
-
method: string;
|
| 788 |
-
hash: string;
|
| 789 |
-
url: string;
|
| 790 |
-
route: string;
|
| 791 |
-
majorParameter: string;
|
| 792 |
-
global: boolean;
|
| 793 |
-
retryAfter: number;
|
| 794 |
-
sublimitTimeout: number;
|
| 795 |
-
scope: RateLimitData['scope'];
|
| 796 |
-
constructor({ timeToReset, limit, method, hash, url, route, majorParameter, global, retryAfter, sublimitTimeout, scope, }: RateLimitData);
|
| 797 |
-
/**
|
| 798 |
-
* The name of the error
|
| 799 |
-
*/
|
| 800 |
-
get name(): string;
|
| 801 |
-
}
|
| 802 |
-
|
| 803 |
-
/**
|
| 804 |
-
* Represents the class that manages handlers for endpoints
|
| 805 |
-
*/
|
| 806 |
-
declare class REST extends AsyncEventEmitter<RestEvents> {
|
| 807 |
-
#private;
|
| 808 |
-
/**
|
| 809 |
-
* The {@link https://undici.nodejs.org/#/docs/api/Agent | Agent} for all requests
|
| 810 |
-
* performed by this manager.
|
| 811 |
-
*/
|
| 812 |
-
agent: Dispatcher | null;
|
| 813 |
-
readonly cdn: CDN;
|
| 814 |
-
/**
|
| 815 |
-
* The number of requests remaining in the global bucket
|
| 816 |
-
*/
|
| 817 |
-
globalRemaining: number;
|
| 818 |
-
/**
|
| 819 |
-
* The promise used to wait out the global rate limit
|
| 820 |
-
*/
|
| 821 |
-
globalDelay: Promise<void> | null;
|
| 822 |
-
/**
|
| 823 |
-
* The timestamp at which the global bucket resets
|
| 824 |
-
*/
|
| 825 |
-
globalReset: number;
|
| 826 |
-
/**
|
| 827 |
-
* API bucket hashes that are cached from provided routes
|
| 828 |
-
*/
|
| 829 |
-
readonly hashes: Collection<string, HashData>;
|
| 830 |
-
/**
|
| 831 |
-
* Request handlers created from the bucket hash and the major parameters
|
| 832 |
-
*/
|
| 833 |
-
readonly handlers: Collection<string, IHandler>;
|
| 834 |
-
private hashTimer;
|
| 835 |
-
private handlerTimer;
|
| 836 |
-
readonly options: RESTOptions;
|
| 837 |
-
constructor(options?: Partial<RESTOptions>);
|
| 838 |
-
private setupSweepers;
|
| 839 |
-
/**
|
| 840 |
-
* Runs a get request from the api
|
| 841 |
-
*
|
| 842 |
-
* @param fullRoute - The full route to query
|
| 843 |
-
* @param options - Optional request options
|
| 844 |
-
*/
|
| 845 |
-
get(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
| 846 |
-
/**
|
| 847 |
-
* Runs a delete request from the api
|
| 848 |
-
*
|
| 849 |
-
* @param fullRoute - The full route to query
|
| 850 |
-
* @param options - Optional request options
|
| 851 |
-
*/
|
| 852 |
-
delete(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
| 853 |
-
/**
|
| 854 |
-
* Runs a post request from the api
|
| 855 |
-
*
|
| 856 |
-
* @param fullRoute - The full route to query
|
| 857 |
-
* @param options - Optional request options
|
| 858 |
-
*/
|
| 859 |
-
post(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
| 860 |
-
/**
|
| 861 |
-
* Runs a put request from the api
|
| 862 |
-
*
|
| 863 |
-
* @param fullRoute - The full route to query
|
| 864 |
-
* @param options - Optional request options
|
| 865 |
-
*/
|
| 866 |
-
put(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
| 867 |
-
/**
|
| 868 |
-
* Runs a patch request from the api
|
| 869 |
-
*
|
| 870 |
-
* @param fullRoute - The full route to query
|
| 871 |
-
* @param options - Optional request options
|
| 872 |
-
*/
|
| 873 |
-
patch(fullRoute: RouteLike, options?: RequestData): Promise<unknown>;
|
| 874 |
-
/**
|
| 875 |
-
* Runs a request from the api
|
| 876 |
-
*
|
| 877 |
-
* @param options - Request options
|
| 878 |
-
*/
|
| 879 |
-
request(options: InternalRequest): Promise<unknown>;
|
| 880 |
-
/**
|
| 881 |
-
* Sets the default agent to use for requests performed by this manager
|
| 882 |
-
*
|
| 883 |
-
* @param agent - The agent to use
|
| 884 |
-
*/
|
| 885 |
-
setAgent(agent: Dispatcher): this;
|
| 886 |
-
/**
|
| 887 |
-
* Sets the authorization token that should be used for requests
|
| 888 |
-
*
|
| 889 |
-
* @param token - The authorization token to use
|
| 890 |
-
*/
|
| 891 |
-
setToken(token: string): this;
|
| 892 |
-
/**
|
| 893 |
-
* Queues a request to be sent
|
| 894 |
-
*
|
| 895 |
-
* @param request - All the information needed to make a request
|
| 896 |
-
* @returns The response from the api request
|
| 897 |
-
*/
|
| 898 |
-
queueRequest(request: InternalRequest): Promise<ResponseLike>;
|
| 899 |
-
/**
|
| 900 |
-
* Creates a new rate limit handler from a hash, based on the hash and the major parameter
|
| 901 |
-
*
|
| 902 |
-
* @param hash - The hash for the route
|
| 903 |
-
* @param majorParameter - The major parameter for this handler
|
| 904 |
-
* @internal
|
| 905 |
-
*/
|
| 906 |
-
private createHandler;
|
| 907 |
-
/**
|
| 908 |
-
* Formats the request data to a usable format for fetch
|
| 909 |
-
*
|
| 910 |
-
* @param request - The request data
|
| 911 |
-
*/
|
| 912 |
-
private resolveRequest;
|
| 913 |
-
/**
|
| 914 |
-
* Stops the hash sweeping interval
|
| 915 |
-
*/
|
| 916 |
-
clearHashSweeper(): void;
|
| 917 |
-
/**
|
| 918 |
-
* Stops the request handler sweeping interval
|
| 919 |
-
*/
|
| 920 |
-
clearHandlerSweeper(): void;
|
| 921 |
-
/**
|
| 922 |
-
* Generates route data for an endpoint:method
|
| 923 |
-
*
|
| 924 |
-
* @param endpoint - The raw endpoint to generalize
|
| 925 |
-
* @param method - The HTTP method this endpoint is called without
|
| 926 |
-
* @internal
|
| 927 |
-
*/
|
| 928 |
-
private static generateRouteData;
|
| 929 |
-
}
|
| 930 |
-
|
| 931 |
-
/**
|
| 932 |
-
* Creates and populates an URLSearchParams instance from an object, stripping
|
| 933 |
-
* out null and undefined values, while also coercing non-strings to strings.
|
| 934 |
-
*
|
| 935 |
-
* @param options - The options to use
|
| 936 |
-
* @returns A populated URLSearchParams instance
|
| 937 |
-
*/
|
| 938 |
-
declare function makeURLSearchParams<OptionsType extends object>(options?: Readonly<OptionsType>): url.URLSearchParams;
|
| 939 |
-
/**
|
| 940 |
-
* Converts the response to usable data
|
| 941 |
-
*
|
| 942 |
-
* @param res - The fetch response
|
| 943 |
-
*/
|
| 944 |
-
declare function parseResponse(res: ResponseLike): Promise<unknown>;
|
| 945 |
-
/**
|
| 946 |
-
* Calculates the default avatar index for a given user id.
|
| 947 |
-
*
|
| 948 |
-
* @param userId - The user id to calculate the default avatar index for
|
| 949 |
-
*/
|
| 950 |
-
declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
|
| 951 |
-
|
| 952 |
-
/**
|
| 953 |
-
* The {@link https://github.com/discordjs/discord.js/blob/main/packages/rest#readme | @discordjs/rest} version
|
| 954 |
-
* that you are currently using.
|
| 955 |
-
*/
|
| 956 |
-
declare const version: string;
|
| 957 |
-
|
| 958 |
-
export { ALLOWED_EXTENSIONS, ALLOWED_SIZES, ALLOWED_STICKER_EXTENSIONS, type APIRequest, type BaseImageURLOptions, BurstHandlerMajorIdKey, CDN, DEPRECATION_WARNING_PREFIX, DefaultRestOptions, DefaultUserAgent, DefaultUserAgentAppendix, DiscordAPIError, type DiscordErrorData, type EmojiURLOptions, type EmojiURLOptionsNotWebp, type EmojiURLOptionsWebp, type GetRateLimitOffsetFunction, HTTPError, type HandlerRequestData, type HashData, type ImageExtension, type ImageURLOptions, type InternalRequest, type InvalidRequestWarningData, type MakeURLOptions, type OAuthErrorData, OverwrittenMimeTypes, REST, RESTEvents, type RESTOptions, type RateLimitData, RateLimitError, type RateLimitQueueFilter, type RawFile, type RequestBody, type RequestData, type RequestHeaders, RequestMethod, type ResponseLike, type RestEvents, type RestEventsMap, type RouteData, type RouteLike, type StickerExtension, calculateUserDefaultAvatarIndex, makeURLSearchParams, parseResponse, version };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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