Compare commits

...

46 Commits

Author SHA1 Message Date
iCrawl
9d8966fe24 chore(discord.js): release discord.js@14.2.0 2022-08-10 20:50:57 +02:00
iCrawl
4d128acac5 chore: deps 2022-08-10 20:37:25 +02:00
iCrawl
831d6506cb chore: update changelog 2022-08-10 20:26:45 +02:00
RedGuy12
c5b96a185c types(Message): correct bulkDelete return type (#8465)
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: Noel <buechler.noel@outlook.com>
2022-08-10 20:25:12 +02:00
Jiralite
afa27b15c5 fix(ThreadChannel): Handle possibly null parent (#8466) 2022-08-10 20:16:57 +02:00
iCrawl
4d7283933d chore: update changelog 2022-08-10 19:44:23 +02:00
Jan Parisek
452e94fd3e types: fix missing types for mentionable options (#8443)
Co-authored-by: A. Román <kyradiscord@gmail.com>
Co-authored-by: Noel <buechler.noel@outlook.com>
2022-08-10 18:33:52 +02:00
Jiralite
6c6fe74dd8 fix: Remove DM channels from Client#messageDeleteBulk's types (#8460) 2022-08-10 18:29:46 +02:00
A. Román
0e2a09571c fix(Transformers): do not transform Date objects (#8463) 2022-08-10 18:28:35 +02:00
Ryan Munro
0fab869e51 fix(ModalSubmitInteraction): allow deferUpdate (#8455) 2022-08-10 18:25:56 +02:00
advaith
64a4041a05 docs: change registration example to use global commands (#8454) 2022-08-10 18:25:31 +02:00
Jan Parisek
38275fc53d types(ApplicationCommandOption): add ApplicationCommandBooleanOption (#8434) 2022-08-10 18:24:50 +02:00
n1ck_pro
aac8acc22b fix(Guild): unable to fetch templates (#8420) 2022-08-08 11:11:10 +02:00
Ryan Munro
6ef4754d40 docs(Colors): provide enum descriptions (#8437) 2022-08-08 11:10:43 +02:00
Almeida
b8a31360a2 fix(MessageMentions): infinite loop in parsedUsers getter (#8430) 2022-08-08 11:10:32 +02:00
RedGuy12
5b053cf82e docs(AttachmentBuilder): fix #8407 (#8421)
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2022-08-08 11:06:11 +02:00
Synbulat Biishev
e72b986939 fix(DataResolver): make Buffer from string (#8416) 2022-08-08 11:05:56 +02:00
Jiralite
3a96ce7970 feat(Guild): Add max_video_channel_users (#8423) 2022-08-08 11:05:40 +02:00
SpaceEEC
359f688555 fix(WebSocketShard): always reconnect on disconnected with 1000 (#8405) 2022-08-01 13:24:25 +02:00
SpaceEEC
3161e1a1ac fix(WebSocketShard): emit errors directly instead of objects (#8406) 2022-08-01 13:24:09 +02:00
iCrawl
4d8361c711 build: fix building actions 2022-07-30 22:02:02 +02:00
iCrawl
d6e4d149fd chore(discord.js): release discord.js@14.1.2 2022-07-30 21:00:09 +02:00
DD
480c85c9c3 fix(errors): error codes (#8398) 2022-07-30 20:49:59 +02:00
iCrawl
b45b99f92b chore(ws): release @discordjs/ws@0.2.0 2022-07-30 20:42:46 +02:00
DD
5137bfc17d fix(WebSocketShard): account code 1000 with no prior indication (#8399) 2022-07-30 20:37:46 +02:00
Jiralite
fca3dada2a docs(Embed): Ensure height and width are numbers (#8396) 2022-07-30 11:39:15 +02:00
Parbez
d070de6da7 chore: fix file path (#8391)
* chore: fix file path

* chore: emit only mjs
2022-07-29 18:43:57 +02:00
iCrawl
a3183cfad4 chore(discord.js): release discord.js@14.1.1 2022-07-29 13:47:21 +02:00
iCrawl
aba307341d chore(builders): release @discordjs/builders@1.1.0 2022-07-29 13:42:55 +02:00
Parbez
c479d39a6b chore: build only actions (#8383) 2022-07-29 11:19:54 +02:00
Parbez
52c2818b25 feat(website): add implements for class (#8388)
Co-authored-by: Noel <buechler.noel@outlook.com>
2022-07-29 11:19:32 +02:00
iCrawl
d03cf6176c chore(discord.js): release discord.js@14.1.0 2022-07-29 11:04:08 +02:00
iCrawl
11e77f7f86 chore: deps 2022-07-29 11:00:45 +02:00
iCrawl
2b1e88b5fa chore: update changelog 2022-07-29 10:59:35 +02:00
Synbulat Biishev
e5bfe2c7c2 chore: reexport rest (#8372) 2022-07-29 10:47:30 +02:00
Jiralite
a7deb8f898 feat: Add channel & message URL formatters (#8371) 2022-07-29 10:47:23 +02:00
Almeida
b4e2c0c4d5 fix(MessageMentions): ignoreRepliedUser option in has() (#8202) 2022-07-29 10:47:05 +02:00
Suneet Tipirneni
33113614e0 feat(website): parse tsdoc comments (#8386) 2022-07-29 10:46:17 +02:00
Suneet Tipirneni
26556390a3 fix: use proper format for @link text (#8384)
fix(collection): use proper format for link text
2022-07-28 20:24:07 +02:00
Parbez
5494791313 docs: use link tags (#8382) 2022-07-28 19:18:42 +02:00
Parbez
c258bdf083 chore: cleanup tsup configs (#8381) 2022-07-28 18:57:57 +02:00
Parbez
ff5dd1fcb4 docs: hide sections with no members (#8380) 2022-07-28 17:55:46 +02:00
iCrawl
a38c58dbd0 feat: tertiary sidebar 2022-07-28 17:46:41 +02:00
Suneet Tipirneni
ec43c184fe feat(website): add icons for sections (#8377)
* feat(website): add icons for sections

* chore: make requested changes

* fix: add icon for function parameters
2022-07-28 16:26:06 +02:00
iCrawl
c25e8ad78b chore: use date order instead of topological for changelog 2022-07-27 14:36:09 +02:00
iCrawl
3f17ff23bf chore: fix changelog 2022-07-27 14:22:13 +02:00
100 changed files with 2369 additions and 1864 deletions

View File

@@ -90,7 +90,7 @@ jobs:
run: yarn --immutable
- name: Build actions
run: yarn build
run: yarn workspace @discordjs/actions build
- name: Download docgen artifacts
uses: actions/download-artifact@v3

View File

@@ -46,19 +46,18 @@ pnpm add discord.js
## Example usage
Install all required dependencies:
Install discord.js:
```sh-session
npm install discord.js @discordjs/rest
yarn add discord.js @discordjs/rest
pnpm add discord.js @discordjs/rest
npm install discord.js
yarn add discord.js
pnpm add discord.js
```
Register a slash command against the Discord API:
```js
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord.js');
const { REST, Routes } = require('discord.js');
const commands = [
{
@@ -73,7 +72,7 @@ const rest = new REST({ version: '10' }).setToken('token');
try {
console.log('Started refreshing application (/) commands.');
await rest.put(Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), { body: commands });
await rest.put(Routes.applicationCommands(CLIENT_ID), { body: commands });
console.log('Successfully reloaded application (/) commands.');
} catch (error) {

View File

@@ -39,15 +39,15 @@
"devDependencies": {
"@commitlint/cli": "^17.0.3",
"@commitlint/config-angular": "^17.0.3",
"@favware/cliff-jumper": "^1.8.5",
"@favware/npm-deprecate": "^1.0.4",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"@favware/cliff-jumper": "^1.8.6",
"@favware/npm-deprecate": "^1.0.5",
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0",
"conventional-changelog-cli": "^2.2.2",
"eslint": "^8.20.0",
"eslint": "^8.21.0",
"eslint-config-marine": "^9.4.1",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^3.3.0",
"eslint-import-resolver-typescript": "^3.4.0",
"eslint-plugin-import": "^2.26.0",
"fast-glob": "^3.2.11",
"husky": "^8.0.1",

View File

@@ -5,5 +5,4 @@ dist/
docs/**/*
!docs/index.yml
!docs/README.md
coverage/
tsup.config.*.mjs
coverage/

View File

@@ -1,3 +1,11 @@
import { createUnbuildConfig } from '../../build.config';
export default createUnbuildConfig({ minify: true });
export default createUnbuildConfig({
entries: [
{ builder: 'rollup', input: 'src/index' },
{ builder: 'rollup', input: 'src/formatTag/index' },
],
preserveModules: false,
minify: true,
emitCJS: false,
});

View File

@@ -10,14 +10,8 @@
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
"fmt": "yarn format"
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"main": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
},
"directories": {
"lib": "src",
"test": "__tests__"
@@ -45,19 +39,18 @@
},
"homepage": "https://discord.js.org",
"dependencies": {
"@actions/core": "^1.9.0",
"@actions/core": "^1.9.1",
"tslib": "^2.4.0"
},
"devDependencies": {
"@types/node": "^16.11.45",
"@types/node": "^16.11.47",
"c8": "^7.12.0",
"eslint": "^8.20.0",
"eslint": "^8.21.0",
"prettier": "^2.7.1",
"rollup-plugin-typescript2": "0.32.1",
"tsup": "^6.2.0",
"typescript": "^4.7.4",
"unbuild": "^0.7.6",
"vitest": "^0.19.1"
"unbuild": "^0.8.4",
"vitest": "^0.21.1"
},
"engines": {
"node": ">=16.9.0"

View File

@@ -11,4 +11,4 @@ outputs:
description: 'The semver string that was extracted from this tag'
runs:
using: node16
main: ../../dist/formatTag/index.js
main: ../../dist/index.mjs

View File

@@ -1,9 +0,0 @@
import { createTsupConfig } from '../../tsup.config';
export default createTsupConfig({
entry: ['src/index.ts', 'src/formatTag/index.ts'],
format: ['cjs'],
skipNodeModulesBundle: false,
noExternal: ['@actions/core'],
minify: true,
});

View File

@@ -5,5 +5,4 @@ dist/
docs/**/*
!docs/index.yml
!docs/README.md
coverage/
tsup.config.*.mjs
coverage/

View File

@@ -2,6 +2,22 @@
All notable changes to this project will be documented in this file.
# [@discordjs/builders@1.1.0](https://github.com/discordjs/discord.js/compare/@discordjs/builders@1.0.0...@discordjs/builders@1.1.0) - (2022-07-29)
## Bug Fixes
- Use proper format for `@link` text (#8384) ([2655639](https://github.com/discordjs/discord.js/commit/26556390a3800e954974a00c1328ff47d3e67e9a))
- **Formatters:** Add newline in `codeBlock` (#8369) ([5d8bd03](https://github.com/discordjs/discord.js/commit/5d8bd030d60ef364de3ef5f9963da8bda5c4efd4))
- **selectMenu:** Allow json to be used for select menu options (#8322) ([6a2d0d8](https://github.com/discordjs/discord.js/commit/6a2d0d8e96d157d5b85cee7f17bffdfff4240074))
## Documentation
- Use link tags (#8382) ([5494791](https://github.com/discordjs/discord.js/commit/549479131318c659f86f0eb18578d597e22522d3))
## Features
- Add channel & message URL formatters (#8371) ([a7deb8f](https://github.com/discordjs/discord.js/commit/a7deb8f89830ead6185c5fb46a49688b6d209ed1))
# [@discordjs/builders@1.0.0](https://github.com/discordjs/discord.js/compare/@discordjs/builders@0.16.0...@discordjs/builders@1.0.0) - (2022-07-17)
## Info

View File

@@ -3,6 +3,7 @@ import { describe, test, expect, vitest } from 'vitest';
import {
blockQuote,
bold,
channelLink,
channelMention,
codeBlock,
Faces,
@@ -11,6 +12,7 @@ import {
hyperlink,
inlineCode,
italic,
messageLink,
quote,
roleMention,
spoiler,
@@ -150,6 +152,34 @@ describe('Message formatters', () => {
});
});
describe('channelLink', () => {
test('GIVEN channelId THEN returns "https://discord.com/channels/@me/${channelId}"', () => {
expect<'https://discord.com/channels/@me/123456789012345678'>(channelLink('123456789012345678')).toEqual(
'https://discord.com/channels/@me/123456789012345678',
);
});
test('GIVEN channelId WITH guildId THEN returns "https://discord.com/channels/${guildId}/${channelId}"', () => {
expect<'https://discord.com/channels/987654321987654/123456789012345678'>(
channelLink('123456789012345678', '987654321987654'),
).toEqual('https://discord.com/channels/987654321987654/123456789012345678');
});
});
describe('messageLink', () => {
test('GIVEN channelId AND messageId THEN returns "https://discord.com/channels/@me/${channelId}/${messageId}"', () => {
expect<'https://discord.com/channels/@me/123456789012345678/102938475657483'>(
messageLink('123456789012345678', '102938475657483'),
).toEqual('https://discord.com/channels/@me/123456789012345678/102938475657483');
});
test('GIVEN channelId AND messageId WITH guildId THEN returns "https://discord.com/channels/${guildId}/${channelId}/${messageId}"', () => {
expect<'https://discord.com/channels/987654321987654/123456789012345678/102938475657483'>(
messageLink('123456789012345678', '102938475657483', '987654321987654'),
).toEqual('https://discord.com/channels/987654321987654/123456789012345678/102938475657483');
});
});
describe('time', () => {
test('GIVEN no arguments THEN returns "<t:${bigint}>"', () => {
vitest.useFakeTimers();

View File

@@ -59,5 +59,5 @@ commit_parsers = [
filter_commits = true
tag_pattern = "@discordjs/builders@[0-9]*"
ignore_tags = ""
topo_order = false
date_order = true
sort_commits = "newest"

View File

@@ -1,6 +1,6 @@
{
"name": "@discordjs/builders",
"version": "1.0.0",
"version": "1.1.0",
"description": "A set of builders that you can use when creating your bot",
"scripts": {
"test": "vitest run",
@@ -62,18 +62,17 @@
},
"devDependencies": {
"@discordjs/docgen": "workspace:^",
"@favware/cliff-jumper": "^1.8.5",
"@microsoft/api-extractor": "^7.28.6",
"@types/node": "^16.11.45",
"@favware/cliff-jumper": "^1.8.6",
"@microsoft/api-extractor": "^7.29.2",
"@types/node": "^16.11.47",
"c8": "^7.12.0",
"downlevel-dts": "^0.10.0",
"eslint": "^8.20.0",
"eslint": "^8.21.0",
"prettier": "^2.7.1",
"rollup-plugin-typescript2": "0.32.1",
"tsup": "^6.2.0",
"typescript": "^4.7.4",
"unbuild": "^0.7.6",
"vitest": "^0.19.1"
"unbuild": "^0.8.4",
"vitest": "^0.21.1"
},
"engines": {
"node": ">=16.9.0"

View File

@@ -207,6 +207,63 @@ export function formatEmoji<C extends Snowflake>(emojiId: C, animated = false):
return `<${animated ? 'a' : ''}:_:${emojiId}>`;
}
/**
* Formats a channel link for a direct message channel.
*
* @param channelId - The channel's id
*/
export function channelLink<C extends Snowflake>(channelId: C): `https://discord.com/channels/@me/${C}`;
/**
* Formats a channel link for a guild channel.
*
* @param channelId - The channel's id
* @param guildId - The guild's id
*/
export function channelLink<C extends Snowflake, G extends Snowflake>(
channelId: C,
guildId: G,
): `https://discord.com/channels/${G}/${C}`;
export function channelLink<C extends Snowflake, G extends Snowflake>(
channelId: C,
guildId?: G,
): `https://discord.com/channels/@me/${C}` | `https://discord.com/channels/${G}/${C}` {
return `https://discord.com/channels/${guildId ?? '@me'}/${channelId}`;
}
/**
* Formats a message link for a direct message channel.
*
* @param channelId - The channel's id
* @param messageId - The message's id
*/
export function messageLink<C extends Snowflake, M extends Snowflake>(
channelId: C,
messageId: M,
): `https://discord.com/channels/@me/${C}/${M}`;
/**
* Formats a message link for a guild channel.
*
* @param channelId - The channel's id
* @param messageId - The message's id
* @param guildId - The guild's id
*/
export function messageLink<C extends Snowflake, M extends Snowflake, G extends Snowflake>(
channelId: C,
messageId: M,
guildId: G,
): `https://discord.com/channels/${G}/${C}/${M}`;
export function messageLink<C extends Snowflake, M extends Snowflake, G extends Snowflake>(
channelId: C,
messageId: M,
guildId?: G,
): `https://discord.com/channels/@me/${C}/${M}` | `https://discord.com/channels/${G}/${C}/${M}` {
return `${typeof guildId === 'undefined' ? channelLink(channelId) : channelLink(channelId, guildId)}/${messageId}`;
}
/**
* Formats a date into a short date-time string
*
@@ -245,7 +302,7 @@ export function time(timeOrSeconds?: number | Date, style?: TimestampStylesStrin
}
/**
* The [message formatting timestamp styles](https://discord.com/developers/docs/reference#message-formatting-timestamp-styles) supported by Discord
* The {@link https://discord.com/developers/docs/reference#message-formatting-timestamp-styles | message formatting timestamp styles} supported by Discord
*/
export const TimestampStyles = {
/**

View File

@@ -1,3 +0,0 @@
import { createTsupConfig } from '../../tsup.config';
export default createTsupConfig();

View File

@@ -5,5 +5,4 @@ dist/
docs/**/*
!docs/index.yml
!docs/README.md
coverage/
tsup.config.*.mjs
coverage/

View File

@@ -33,43 +33,6 @@ All notable changes to this project will be documented in this file.
- **collection:** Improve coverage (#8222) ([a51f721](https://github.com/discordjs/discord.js/commit/a51f7215eca67a0f46fba8b2d706f7ec6f6dc228))
# [@discordjs/collection@1.0.0](https://github.com/discordjs/discord.js/compare/@discordjs/collection@0.8.0...@discordjs/collection@1.0.0) - (2022-07-17)
## Info
- 1.0.0 release bump, no new features.
# [@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)
## Bug Fixes
- **Collection:** Make error messages consistent (#8224) ([5bd6b28](https://github.com/discordjs/discord.js/commit/5bd6b28b3ebfced1cb9d23e83bd7c0def7a12404))
- Check for function type (#8064) ([3bb9c0e](https://github.com/discordjs/discord.js/commit/3bb9c0e5c37311044ff41761b572ac4f91cda57c))
## Documentation
- Add codecov coverage badge to readmes (#8226) ([f6db285](https://github.com/discordjs/discord.js/commit/f6db285c073898a749fe4591cbd4463d1896daf5))
## Features
- Codecov (#8219) ([f10f4cd](https://github.com/discordjs/discord.js/commit/f10f4cdcd88ca6be7ec735ed3a415ba13da83db0))
- **docgen:** Update typedoc ([b3346f4](https://github.com/discordjs/discord.js/commit/b3346f4b9b3d4f96443506643d4631dc1c6d7b21))
- Website (#8043) ([127931d](https://github.com/discordjs/discord.js/commit/127931d1df7a2a5c27923c2f2151dbf3824e50cc))
- **docgen:** Typescript support ([3279b40](https://github.com/discordjs/discord.js/commit/3279b40912e6aa61507bedb7db15a2b8668de44b))
- Docgen package (#8029) ([8b979c0](https://github.com/discordjs/discord.js/commit/8b979c0245c42fd824d8e98745ee869f5360fc86))
- Use vitest instead of jest for more speed ([8d8e6c0](https://github.com/discordjs/discord.js/commit/8d8e6c03decd7352a2aa180f6e5bc1a13602539b))
- Add scripts package for locally used scripts ([f2ae1f9](https://github.com/discordjs/discord.js/commit/f2ae1f9348bfd893332a9060f71a8a5f272a1b8b))
## Refactor
- **collection:** Remove `default` property (#8055) ([c8f1690](https://github.com/discordjs/discord.js/commit/c8f1690896f55f06e05a83704262783cfc2bb91d))
- **collection:** Remove default export (#8053) ([16810f3](https://github.com/discordjs/discord.js/commit/16810f3e410bf35ed7e6e7412d517ea74c792c5d))
- Move all the config files to root (#8033) ([769ea0b](https://github.com/discordjs/discord.js/commit/769ea0bfe78c4f1d413c6b397c604ffe91e39c6a))
## Testing
- **collection:** Improve coverage (#8222) ([a51f721](https://github.com/discordjs/discord.js/commit/a51f7215eca67a0f46fba8b2d706f7ec6f6dc228))
# [@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)
## Styling

View File

@@ -59,5 +59,5 @@ commit_parsers = [
filter_commits = true
tag_pattern = "@discordjs/collection@[0-9]*"
ignore_tags = ""
topo_order = false
date_order = true
sort_commits = "newest"

View File

@@ -51,18 +51,17 @@
"homepage": "https://discord.js.org",
"devDependencies": {
"@discordjs/docgen": "workspace:^",
"@favware/cliff-jumper": "^1.8.5",
"@microsoft/api-extractor": "^7.28.6",
"@types/node": "^16.11.45",
"@favware/cliff-jumper": "^1.8.6",
"@microsoft/api-extractor": "^7.29.2",
"@types/node": "^16.11.47",
"c8": "^7.12.0",
"downlevel-dts": "^0.10.0",
"eslint": "^8.20.0",
"eslint": "^8.21.0",
"prettier": "^2.7.1",
"rollup-plugin-typescript2": "0.32.1",
"tsup": "^6.2.0",
"typescript": "^4.7.4",
"unbuild": "^0.7.6",
"vitest": "^0.19.1"
"unbuild": "^0.8.4",
"vitest": "^0.21.1"
},
"engines": {
"node": ">=16.9.0"

View File

@@ -145,7 +145,7 @@ export class Collection<K, V> extends Map<K, V> {
}
/**
* Identical to [Array.at()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at).
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
* Returns the item at a given index, allowing for positive and negative integers.
* Negative integers count back from the last item in the collection.
*
@@ -158,7 +158,7 @@ export class Collection<K, V> extends Map<K, V> {
}
/**
* Identical to [Array.at()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at).
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at | Array.at()}.
* Returns the key at a given index, allowing for positive and negative integers.
* Negative integers count back from the last item in the collection.
*
@@ -209,7 +209,7 @@ export class Collection<K, V> extends Map<K, V> {
}
/**
* Identical to [Array.reverse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse)
* Identical to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse | Array.reverse()}
* but returns a Collection instead of an Array.
*/
public reverse() {
@@ -221,10 +221,10 @@ export class Collection<K, V> extends Map<K, V> {
/**
* Searches for a single item where the given function returns a truthy value. This behaves like
* [Array.find()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find).
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find | Array.find()}.
* <warn>All collections used in Discord.js are mapped using their `id` property, and if you want to find by id you
* should use the `get` method. See
* [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get) for details.</warn>
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get | MDN} for details.</warn>
*
* @param fn - The function to test with (should return boolean)
* @param thisArg - Value to use as `this` when executing function
@@ -250,7 +250,7 @@ export class Collection<K, V> extends Map<K, V> {
/**
* Searches for the key of a single item where the given function returns a truthy value. This behaves like
* [Array.findIndex()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex),
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findIndex | Array.findIndex()},
* but returns the key rather than the positional index.
*
* @param fn - The function to test with (should return boolean)
@@ -297,7 +297,7 @@ export class Collection<K, V> extends Map<K, V> {
/**
* Identical to
* [Array.filter()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter),
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter | Array.filter()},
* but returns a Collection instead of an Array.
*
* @param fn - The function to test with (should return boolean)
@@ -379,7 +379,7 @@ export class Collection<K, V> extends Map<K, V> {
/**
* Maps each item into a Collection, then joins the results into a single Collection. Identical in behavior to
* [Array.flatMap()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap).
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap | Array.flatMap()}.
*
* @param fn - Function that produces a new Collection
* @param thisArg - Value to use as `this` when executing function
@@ -399,7 +399,7 @@ export class Collection<K, V> extends Map<K, V> {
/**
* Maps each item to another value into an array. Identical in behavior to
* [Array.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.
*
* @param fn - Function that produces an element of the new array, taking three arguments
* @param thisArg - Value to use as `this` when executing function
@@ -423,7 +423,7 @@ export class Collection<K, V> extends Map<K, V> {
/**
* Maps each item to another value into a collection. Identical in behavior to
* [Array.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | Array.map()}.
*
* @param fn - Function that produces an element of the new collection, taking three arguments
* @param thisArg - Value to use as `this` when executing function
@@ -443,7 +443,7 @@ export class Collection<K, V> extends Map<K, V> {
/**
* Checks if there exists an item that passes a test. Identical in behavior to
* [Array.some()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some).
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some | Array.some()}.
*
* @param fn - Function used to test (should return a boolean)
* @param thisArg - Value to use as `this` when executing function
@@ -464,7 +464,7 @@ export class Collection<K, V> extends Map<K, V> {
/**
* Checks if all items passes a test. Identical in behavior to
* [Array.every()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every).
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every | Array.every()}.
*
* @param fn - Function used to test (should return a boolean)
* @param thisArg - Value to use as `this` when executing function
@@ -495,7 +495,7 @@ export class Collection<K, V> extends Map<K, V> {
/**
* Applies a function to produce a single value. Identical in behavior to
* [Array.reduce()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce | Array.reduce()}.
*
* @param fn - Function used to reduce, taking four arguments; `accumulator`, `currentValue`, `currentKey`,
* and `collection`
@@ -533,7 +533,7 @@ export class Collection<K, V> extends Map<K, V> {
/**
* Identical to
* [Map.forEach()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach),
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach | Map.forEach()},
* but returns the collection instead of undefined.
*
* @param fn - Function to execute for each element

View File

@@ -1,3 +0,0 @@
import { createTsupConfig } from '../../tsup.config';
export default createTsupConfig();

View File

@@ -5,5 +5,4 @@ dist/
docs/**/*
!docs/index.yml
!docs/README.md
coverage/
tsup.config.*.mjs
coverage/

View File

@@ -2,6 +2,81 @@
All notable changes to this project will be documented in this file.
# [14.2.0](https://github.com/discordjs/discord.js/compare/14.1.2...14.2.0) - (2022-08-10)
## Bug Fixes
- **ThreadChannel:** Handle possibly `null` parent (#8466) ([afa27b1](https://github.com/discordjs/discord.js/commit/afa27b15c5b92bc8d55b8285834d8e03f6692d06))
- Remove DM channels from `Client#messageDeleteBulk`'s types (#8460) ([6c6fe74](https://github.com/discordjs/discord.js/commit/6c6fe74dd84859c5319efa999404e8168f189710))
- **Transformers:** Do not transform `Date` objects (#8463) ([0e2a095](https://github.com/discordjs/discord.js/commit/0e2a09571c8e5ee61153b04e45334a226a1b4534))
- **ModalSubmitInteraction:** Allow deferUpdate (#8455) ([0fab869](https://github.com/discordjs/discord.js/commit/0fab869e5179dca7ddec75b5519615278e51ad82))
- **Guild:** Unable to fetch templates (#8420) ([aac8acc](https://github.com/discordjs/discord.js/commit/aac8acc22be7d7af99933ef099eca7deda43cb40))
- **MessageMentions:** Infinite loop in `parsedUsers` getter (#8430) ([b8a3136](https://github.com/discordjs/discord.js/commit/b8a31360a220e3d796f5381bd215d30a379ecb7c))
- **DataResolver:** Make `Buffer` from string (#8416) ([e72b986](https://github.com/discordjs/discord.js/commit/e72b986939e2958547c0e54d6d27472c8d111609))
## Documentation
- Change registration example to use global commands (#8454) ([64a4041](https://github.com/discordjs/discord.js/commit/64a4041a05e9514334a9f9e1f38a1ea18bb676d5))
- **Colors:** Provide enum descriptions (#8437) ([6ef4754](https://github.com/discordjs/discord.js/commit/6ef4754d40c5ec65715fc1e00e643c52fe0a6209))
- **AttachmentBuilder:** Fix #8407 (#8421) ([5b053cf](https://github.com/discordjs/discord.js/commit/5b053cf82ec2f2b717a490485af052dc956fe3c9))
## Features
- **Guild:** Add `max_video_channel_users` (#8423) ([3a96ce7](https://github.com/discordjs/discord.js/commit/3a96ce7970947f6268c21a1323d986aac8cb736d))
## Typings
- **Message:** Correct `bulkDelete` return type (#8465) ([c5b96a1](https://github.com/discordjs/discord.js/commit/c5b96a185cb8ba836b7cd10526c14059866f218f))
- Fix missing types for mentionable options (#8443) ([452e94f](https://github.com/discordjs/discord.js/commit/452e94fd3ecc12de9e3408982c5c7fd931bae634))
- **ApplicationCommandOption:** Add `ApplicationCommandBooleanOption` (#8434) ([38275fc](https://github.com/discordjs/discord.js/commit/38275fc53d633ce77ed2b142aff788dcbd4fad8c))
# [14.1.2](https://github.com/discordjs/discord.js/compare/14.1.1...14.1.2) - (2022-07-30)
## Bug Fixes
- **errors:** Error codes (#8398) ([480c85c](https://github.com/discordjs/discord.js/commit/480c85c9c3d129204b3399ed726a4e570e0b2852))
## Documentation
- **Embed:** Ensure height and width are numbers (#8396) ([fca3dad](https://github.com/discordjs/discord.js/commit/fca3dada2a565eecfc7e5275cc9317df1d261871))
# [14.1.0](https://github.com/discordjs/discord.js/compare/14.0.3...14.1.0) - (2022-07-29)
## Bug Fixes
- **MessageMentions:** `ignoreRepliedUser` option in `has()` (#8202) ([b4e2c0c](https://github.com/discordjs/discord.js/commit/b4e2c0c4d5538b945f9d597c6410a6f84b315084))
- **GuildChannelManager:** Allow unsetting rtcRegion (#8359) ([a7d49e5](https://github.com/discordjs/discord.js/commit/a7d49e56fc7c34d2e4548d9e5bf0aec45273506e))
- **ThreadChannel:** Omit webhook fetching (#8351) ([3839958](https://github.com/discordjs/discord.js/commit/3839958e3f682c715f1017da05436d2fe34900fd))
- **GuildAuditLogsEntry:** Replace OverwriteType with AuditLogOptionsType (#8345) ([58c1b51](https://github.com/discordjs/discord.js/commit/58c1b51c5ceab137ad9851919b338419eeeab69e))
- **ShardClientUtil#\_respond:** Construct global error (#8348) ([8e520f9](https://github.com/discordjs/discord.js/commit/8e520f946a5b9f93a939290facf4ccca2c05ff21))
- **Presence:** Do not return NaN for activity timestamp (#8340) ([df42fdf](https://github.com/discordjs/discord.js/commit/df42fdfc421f1190f0a2267a66efd3c921ec2348))
- **Client:** Omit private properties from toJSON (#8337) ([830c670](https://github.com/discordjs/discord.js/commit/830c670c61dcb17d8ab2a894a3203c68917d27e0))
- **ApplicationCommandManager:** Allow passing 0n to defaultMemberPermissions (#8311) ([1fb7b30](https://github.com/discordjs/discord.js/commit/1fb7b30963cfe7ea4c05b1f3b42171c879c46a1d))
## Documentation
- **InteractionResponses:** Add `showModal()` return type (#8376) ([0b61dbf](https://github.com/discordjs/discord.js/commit/0b61dbf720e844322b066e30080c3537ab3d8174))
- **WebhookClient:** Document working options (#8375) ([ba6797e](https://github.com/discordjs/discord.js/commit/ba6797e74209161b64c412de1b6f307cb28736b8))
- **Message:** Document gateway intent for content (#8364) ([2130aae](https://github.com/discordjs/discord.js/commit/2130aae3210a8eaf91c5ccae5463940d49052c7d))
- Use info blocks for requirements (#8361) ([80b9738](https://github.com/discordjs/discord.js/commit/80b9738957ebf5b6eb7c9858cec0fb1c897d0a1f))
- **WebhookClient:** Make constructor a union (#8370) ([e9920a9](https://github.com/discordjs/discord.js/commit/e9920a9c98ffb78bd7d0ae00d486476367296646))
- Update docs and examples to PascalCase links (#8305) ([34ba9d1](https://github.com/discordjs/discord.js/commit/34ba9d1c4c80eff7e6ac199a40232d07491432cc))
## Features
- Add channel & message URL formatters (#8371) ([a7deb8f](https://github.com/discordjs/discord.js/commit/a7deb8f89830ead6185c5fb46a49688b6d209ed1))
- Restore missing typeguards (#8328) ([77ed407](https://github.com/discordjs/discord.js/commit/77ed407f6aadb68e729470c5269e9b526cb1b3f0))
- **GuildMember:** Add dmChannel getter (#8281) ([4fc2c60](https://github.com/discordjs/discord.js/commit/4fc2c60a3bb43671b4b0202ae75eab42aba163ff))
## Refactor
- Deprecate `Formatter` class (#8373) ([7fd9ed8](https://github.com/discordjs/discord.js/commit/7fd9ed8f13d17ce7e98e34f7454d9047054d8467))
- **PermissionOverwriteManager:** Use `OverwriteType` (#8374) ([6d24805](https://github.com/discordjs/discord.js/commit/6d248051cfd431e9cb1c65cb98f56aa0a6556407))
## Typings
- **GuildAuditLogsEntryExtraField:** Use `AuditLogOptionsType` (#8349) ([200ab91](https://github.com/discordjs/discord.js/commit/200ab91f527d8a5706d277b89a975096f75d141a))
# [14.0.3](https://github.com/discordjs/discord.js/compare/14.0.2...14.0.3) - (2022-07-18)
## Bug Fixes
@@ -20,7 +95,7 @@ All notable changes to this project will be documented in this file.
- 14.0.1 release bump, no new features.
# [14.0.0](https://github.com/discordjs/discord.js/compare/13.9.0...14.0.0) - (2022-07-17)
# [14.0.0](https://github.com/discordjs/discord.js/compare/13.10.1...14.0.0) - (2022-07-17)
## Bug Fixes
@@ -426,6 +501,37 @@ All notable changes to this project will be documented in this file.
- AssertType -> expectType ([3f36746](https://github.com/discordjs/discord.js/commit/3f36746561a40cd61a7cd2e054b7ef80d58fc707))
- Fix cache types resolving to `never` (#7164) ([c978dbb](https://github.com/discordjs/discord.js/commit/c978dbb6233bcd85408caf0bca7619c9c5d508f0))
# [13.10.1](https://github.com/discordjs/discord.js/compare/13.10.0...13.10.1) - (2022-08-10)
## Bug Fixes
- **ThreadChannel:** Handle possibly `null` parent (v13) (#8467) ([2a46d9f](https://github.com/discordjs/discord.js/commit/2a46d9f58e4714c8580218a3459992bbfec2bcf7))
# [13.10.0](https://github.com/discordjs/discord.js/compare/13.9.2...13.10.0) - (2022-08-08)
## Features
- **Guild:** Add `max_video_channel_users` (v13) (#8424) ([ae43bca](https://github.com/discordjs/discord.js/commit/ae43bca8b0afd8b90db7a1d99f67205b29338c2d))
# [13.9.2](https://github.com/discordjs/discord.js/compare/13.9.1...13.9.2) - (2022-07-29)
## Bug Fixes
- **MessageMentions:** `ignoreRepliedUser` option in `has()` (v13) (#8365) ([d0a4199](https://github.com/discordjs/discord.js/commit/d0a4199760b4c7fe64f558d8d4d2302873f78b0e))
- **GuildChannelManager:** Allow unsetting rtcRegion (v13) (#8362) ([9612507](https://github.com/discordjs/discord.js/commit/96125079a23c87fe0fb3ee01a0de5a9889fc1057))
- **ThreadChannel:** Omit webhook fetching (v13) (#8352) ([4f7c1e3](https://github.com/discordjs/discord.js/commit/4f7c1e35c38bb9f1d524406c008ffceb2cfde3db))
# [13.9.1](https://github.com/discordjs/discord.js/compare/13.9.0...13.9.1) - (2022-07-23)
## Bug Fixes
- **ApplicationCommandManager:** Allow passing 0n to defaultMemberPermissions (v13) (#8312) ([4cf0555](https://github.com/discordjs/discord.js/commit/4cf05559a2cc6c4dfc409f8aab60256e5b030bca))
## Refactor
- **embed:** Deprecate addField (#8318) ([be35db2](https://github.com/discordjs/discord.js/commit/be35db2410c24fcca8b28ddfb3c1c580e7e2a22f))
- **Presence:** Remove redundant date parsing (v13) (#8341) ([e95caa7](https://github.com/discordjs/discord.js/commit/e95caa7e4515beab627b5394d011a6b6a8ae6a18))
# [13.9.0](https://github.com/discordjs/discord.js/compare/13.8.1...13.9.0) - (2022-07-17)
## Bug Fixes

View File

@@ -45,19 +45,18 @@ pnpm add discord.js
## Example usage
Install all required dependencies:
Install discord.js:
```sh-session
npm install discord.js @discordjs/rest
yarn add discord.js @discordjs/rest
pnpm add discord.js @discordjs/rest
npm install discord.js
yarn add discord.js
pnpm add discord.js
```
Register a slash command against the Discord API:
```js
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord.js');
const { REST, Routes } = require('discord.js');
const commands = [
{
@@ -72,7 +71,7 @@ const rest = new REST({ version: '10' }).setToken('token');
try {
console.log('Started refreshing application (/) commands.');
await rest.put(Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), { body: commands });
await rest.put(Routes.applicationCommands(CLIENT_ID), { body: commands });
console.log('Successfully reloaded application (/) commands.');
} catch (error) {

View File

@@ -60,5 +60,5 @@ filter_commits = true
tag_pattern = "[0-9]*"
skip_tags = "v[0-9]*|9*|11*|12*|@discordjs*"
ignore_tags = ""
topo_order = false
date_order = true
sort_commits = "newest"

View File

@@ -1,6 +1,6 @@
{
"name": "discord.js",
"version": "14.0.3",
"version": "14.2.0",
"description": "A powerful library for interacting with the Discord API",
"scripts": {
"test": "yarn docs:test && yarn test:typescript",
@@ -58,15 +58,15 @@
"fast-deep-equal": "^3.1.3",
"lodash.snakecase": "^4.1.1",
"tslib": "^2.4.0",
"undici": "^5.8.0",
"undici": "^5.8.2",
"ws": "^8.8.1"
},
"devDependencies": {
"@discordjs/docgen": "workspace:^",
"@favware/cliff-jumper": "^1.8.5",
"@types/node": "^16.11.45",
"@favware/cliff-jumper": "^1.8.6",
"@types/node": "^16.11.47",
"dtslint": "^4.2.1",
"eslint": "^8.20.0",
"eslint": "^8.21.0",
"jest": "^28.1.3",
"prettier": "^2.7.1",
"tsd": "^0.22.0",

View File

@@ -33,7 +33,7 @@ class MessageDeleteBulkAction extends Action {
* Emitted whenever messages are deleted in bulk.
* @event Client#messageDeleteBulk
* @param {Collection<Snowflake, Message>} messages The deleted messages, mapped by their id
* @param {TextBasedChannels} channel The channel that the messages were deleted in
* @param {GuildTextBasedChannel} channel The channel that the messages were deleted in
*/
if (messages.size > 0) client.emit(Events.MessageBulkDelete, messages, channel);
return { messages };

View File

@@ -3,7 +3,6 @@
// Heavily inspired by node's `internal/errors` module
const ErrorCodes = require('./ErrorCodes');
const Messages = require('./Messages');
const kCode = Symbol('code');
/**
* Extend an error of some sort into a DiscordjsError.
@@ -15,17 +14,13 @@ function makeDiscordjsError(Base) {
return class DiscordjsError extends Base {
constructor(code, ...args) {
super(message(code, args));
this[kCode] = code;
this.code = code;
Error.captureStackTrace?.(this, DiscordjsError);
}
get name() {
return `${super.name} [${this.code}]`;
}
get code() {
return ErrorCodes[this[kCode]];
}
};
}
@@ -37,9 +32,9 @@ function makeDiscordjsError(Base) {
* @ignore
*/
function message(code, args) {
if (typeof code !== 'number') throw new Error('Error code must be a valid DiscordjsErrorCodes');
if (!(code in ErrorCodes)) throw new Error('Error code must be a valid DiscordjsErrorCodes');
const msg = Messages[code];
if (!msg) throw new Error(`An invalid error code was used: ${code}.`);
if (!msg) throw new Error(`No message associated with error code: ${code}.`);
if (typeof msg === 'function') return msg(...args);
if (!args?.length) return msg;
args.unshift(msg);

View File

@@ -1,159 +1,152 @@
'use strict';
const { createEnum } = require('../util/Enums');
/**
* @typedef {Object} DiscordjsErrorCodes
* @property {number} ClientInvalidOption
* @property {number} ClientInvalidProvidedShards
* @property {number} ClientMissingIntents
* @property {number} ClientNotReady
* @property {'ClientInvalidOption'} ClientInvalidOption
* @property {'ClientInvalidProvidedShards'} ClientInvalidProvidedShards
* @property {'ClientMissingIntents'} ClientMissingIntents
* @property {'ClientNotReady'} ClientNotReady
* @property {number} TokenInvalid
* @property {number} TokenMissing
* @property {number} ApplicationCommandPermissionsTokenMissing
* @property {'TokenInvalid'} TokenInvalid
* @property {'TokenMissing'} TokenMissing
* @property {'ApplicationCommandPermissionsTokenMissing'} ApplicationCommandPermissionsTokenMissing
* @property {number} WSCloseRequested
* @property {number} WSConnectionExists
* @property {number} WSNotOpen
* @property {number} ManagerDestroyed
* @property {'WSCloseRequested'} WSCloseRequested
* @property {'WSConnectionExists'} WSConnectionExists
* @property {'WSNotOpen'} WSNotOpen
* @property {'ManagerDestroyed'} ManagerDestroyed
* @property {number} BitFieldInvalid
* @property {'BitFieldInvalid'} BitFieldInvalid
* @property {number} ShardingInvalid
* @property {number} ShardingRequired
* @property {number} InvalidIntents
* @property {number} DisallowedIntents
* @property {number} ShardingNoShards
* @property {number} ShardingInProcess
* @property {number} ShardingInvalidEvalBroadcast
* @property {number} ShardingShardNotFound
* @property {number} ShardingAlreadySpawned
* @property {number} ShardingProcessExists
* @property {number} ShardingWorkerExists
* @property {number} ShardingReadyTimeout
* @property {number} ShardingReadyDisconnected
* @property {number} ShardingReadyDied
* @property {number} ShardingNoChildExists
* @property {number} ShardingShardMiscalculation
* @property {'ShardingInvalid'} ShardingInvalid
* @property {'ShardingRequired'} ShardingRequired
* @property {'InvalidIntents'} InvalidIntents
* @property {'DisallowedIntents'} DisallowedIntents
* @property {'ShardingNoShards'} ShardingNoShards
* @property {'ShardingInProcess'} ShardingInProcess
* @property {'ShardingInvalidEvalBroadcast'} ShardingInvalidEvalBroadcast
* @property {'ShardingShardNotFound'} ShardingShardNotFound
* @property {'ShardingAlreadySpawned'} ShardingAlreadySpawned
* @property {'ShardingProcessExists'} ShardingProcessExists
* @property {'ShardingWorkerExists'} ShardingWorkerExists
* @property {'ShardingReadyTimeout'} ShardingReadyTimeout
* @property {'ShardingReadyDisconnected'} ShardingReadyDisconnected
* @property {'ShardingReadyDied'} ShardingReadyDied
* @property {'ShardingNoChildExists'} ShardingNoChildExists
* @property {'ShardingShardMiscalculation'} ShardingShardMiscalculation
* @property {number} ColorRange
* @property {number} ColorConvert
* @property {'ColorRange'} ColorRange
* @property {'ColorConvert'} ColorConvert
* @property {number} InviteOptionsMissingChannel
* @property {'InviteOptionsMissingChannel'} InviteOptionsMissingChannel
* @property {number} ButtonLabel
* @property {number} ButtonURL
* @property {number} ButtonCustomId
* @property {'ButtonLabel'} ButtonLabel
* @property {'ButtonURL'} ButtonURL
* @property {'ButtonCustomId'} ButtonCustomId
* @property {number} SelectMenuCustomId
* @property {number} SelectMenuPlaceholder
* @property {number} SelectOptionLabel
* @property {number} SelectOptionValue
* @property {number} SelectOptionDescription
* @property {'SelectMenuCustomId'} SelectMenuCustomId
* @property {'SelectMenuPlaceholder'} SelectMenuPlaceholder
* @property {'SelectOptionLabel'} SelectOptionLabel
* @property {'SelectOptionValue'} SelectOptionValue
* @property {'SelectOptionDescription'} SelectOptionDescription
* @property {number} InteractionCollectorError
* @property {'InteractionCollectorError'} InteractionCollectorError
* @property {number} FileNotFound
* @property {'FileNotFound'} FileNotFound
* @property {number} UserBannerNotFetched
* @property {number} UserNoDMChannel
* @property {'UserBannerNotFetched'} UserBannerNotFetched
* @property {'UserNoDMChannel'} UserNoDMChannel
* @property {number} VoiceNotStageChannel
* @property {'VoiceNotStageChannel'} VoiceNotStageChannel
* @property {number} VoiceStateNotOwn
* @property {number} VoiceStateInvalidType
* @property {'VoiceStateNotOwn'} VoiceStateNotOwn
* @property {'VoiceStateInvalidType'} VoiceStateInvalidType
* @property {number} ReqResourceType
* @property {'ReqResourceType'} ReqResourceType
* @property {number} ImageFormat
* @property {number} ImageSize
* @property {'ImageFormat'} ImageFormat
* @property {'ImageSize'} ImageSize
* @property {number} MessageBulkDeleteType
* @property {number} MessageNonceType
* @property {number} MessageContentType
* @property {'MessageBulkDeleteType'} MessageBulkDeleteType
* @property {'MessageNonceType'} MessageNonceType
* @property {'MessageContentType'} MessageContentType
* @property {number} SplitMaxLen
* @property {'SplitMaxLen'} SplitMaxLen
* @property {number} BanResolveId
* @property {number} FetchBanResolveId
* @property {'BanResolveId'} BanResolveId
* @property {'FetchBanResolveId'} FetchBanResolveId
* @property {number} PruneDaysType
* @property {'PruneDaysType'} PruneDaysType
* @property {number} GuildChannelResolve
* @property {number} GuildVoiceChannelResolve
* @property {number} GuildChannelOrphan
* @property {number} GuildChannelUnowned
* @property {number} GuildOwned
* @property {number} GuildMembersTimeout
* @property {number} GuildUncachedMe
* @property {number} ChannelNotCached
* @property {number} StageChannelResolve
* @property {number} GuildScheduledEventResolve
* @property {number} FetchOwnerId
* @property {'GuildChannelResolve'} GuildChannelResolve
* @property {'GuildVoiceChannelResolve'} GuildVoiceChannelResolve
* @property {'GuildChannelOrphan'} GuildChannelOrphan
* @property {'GuildChannelUnowned'} GuildChannelUnowned
* @property {'GuildOwned'} GuildOwned
* @property {'GuildMembersTimeout'} GuildMembersTimeout
* @property {'GuildUncachedMe'} GuildUncachedMe
* @property {'ChannelNotCached'} ChannelNotCached
* @property {'StageChannelResolve'} StageChannelResolve
* @property {'GuildScheduledEventResolve'} GuildScheduledEventResolve
* @property {'FetchOwnerId'} FetchOwnerId
* @property {number} InvalidType
* @property {number} InvalidElement
* @property {'InvalidType'} InvalidType
* @property {'InvalidElement'} InvalidElement
* @property {number} MessageThreadParent
* @property {number} MessageExistingThread
* @property {number} ThreadInvitableType
* @property {'MessageThreadParent'} MessageThreadParent
* @property {'MessageExistingThread'} MessageExistingThread
* @property {'ThreadInvitableType'} ThreadInvitableType
* @property {number} WebhookMessage
* @property {number} WebhookTokenUnavailable
* @property {number} WebhookURLInvalid
* @property {number} WebhookApplication
* @property {number} MessageReferenceMissing
* @property {'WebhookMessage'} WebhookMessage
* @property {'WebhookTokenUnavailable'} WebhookTokenUnavailable
* @property {'WebhookURLInvalid'} WebhookURLInvalid
* @property {'WebhookApplication'} WebhookApplication
* @property {'MessageReferenceMissing'} MessageReferenceMissing
* @property {number} EmojiType
* @property {number} EmojiManaged
* @property {number} MissingManageEmojisAndStickersPermission
* @property {number} NotGuildSticker
* @property {'EmojiType'} EmojiType
* @property {'EmojiManaged'} EmojiManaged
* @property {'MissingManageEmojisAndStickersPermission'} MissingManageEmojisAndStickersPermission
* @property {'NotGuildSticker'} NotGuildSticker
* @property {number} ReactionResolveUser
* @property {'ReactionResolveUser'} ReactionResolveUser
* @property {number} VanityURL
* @property {'VanityURL'} VanityURL
* @property {number} InviteResolveCode
* @property {'InviteResolveCode'} InviteResolveCode
* @property {number} InviteNotFound
* @property {'InviteNotFound'} InviteNotFound
* @property {number} DeleteGroupDMChannel
* @property {number} FetchGroupDMChannel
* @property {'DeleteGroupDMChannel'} DeleteGroupDMChannel
* @property {'FetchGroupDMChannel'} FetchGroupDMChannel
* @property {number} MemberFetchNonceLength
* @property {'MemberFetchNonceLength'} MemberFetchNonceLength
* @property {number} GlobalCommandPermissions
* @property {number} GuildUncachedEntityResolve
* @property {'GlobalCommandPermissions'} GlobalCommandPermissions
* @property {'GuildUncachedEntityResolve'} GuildUncachedEntityResolve
* @property {number} InteractionAlreadyReplied
* @property {number} InteractionNotReplied
* @property {number} InteractionEphemeralReplied
* @property {'InteractionAlreadyReplied'} InteractionAlreadyReplied
* @property {'InteractionNotReplied'} InteractionNotReplied
* @property {'InteractionEphemeralReplied'} InteractionEphemeralReplied
* @property {number} CommandInteractionOptionNotFound
* @property {number} CommandInteractionOptionType
* @property {number} CommandInteractionOptionEmpty
* @property {number} CommandInteractionOptionNoSubcommand
* @property {number} CommandInteractionOptionNoSubcommandGroup
* @property {number} AutocompleteInteractionOptionNoFocusedOption
* @property {'CommandInteractionOptionNotFound'} CommandInteractionOptionNotFound
* @property {'CommandInteractionOptionType'} CommandInteractionOptionType
* @property {'CommandInteractionOptionEmpty'} CommandInteractionOptionEmpty
* @property {'CommandInteractionOptionNoSubcommand'} CommandInteractionOptionNoSubcommand
* @property {'CommandInteractionOptionNoSubcommandGroup'} CommandInteractionOptionNoSubcommandGroup
* @property {'AutocompleteInteractionOptionNoFocusedOption'} AutocompleteInteractionOptionNoFocusedOption
* @property {number} ModalSubmitInteractionFieldNotFound
* @property {number} ModalSubmitInteractionFieldType
* @property {'ModalSubmitInteractionFieldNotFound'} ModalSubmitInteractionFieldNotFound
* @property {'ModalSubmitInteractionFieldType'} ModalSubmitInteractionFieldType
* @property {number} InvalidMissingScopes
* @property {'InvalidMissingScopes'} InvalidMissingScopes
* @property {number} NotImplemented
* @property {'NotImplemented'} NotImplemented
* @property {number} SweepFilterReturn
* @property {'SweepFilterReturn'} SweepFilterReturn
*/
// JSDoc for IntelliSense purposes
/**
* @type {DiscordjsErrorCodes}
* @ignore
*/
module.exports = createEnum([
const keys = [
'ClientInvalidOption',
'ClientInvalidProvidedShards',
'ClientMissingIntents',
@@ -295,4 +288,11 @@ module.exports = createEnum([
'NotImplemented',
'SweepFilterReturn',
]);
];
// JSDoc for IntelliSense purposes
/**
* @type {DiscordjsErrorCodes}
* @ignore
*/
module.exports = Object.fromEntries(keys.map(key => [key, key]));

View File

@@ -180,9 +180,6 @@ exports.WelcomeScreen = require('./structures/WelcomeScreen');
exports.WebSocket = require('./WebSocket');
// External
exports.DiscordAPIError = require('@discordjs/rest').DiscordAPIError;
exports.HTTPError = require('@discordjs/rest').HTTPError;
exports.RateLimitError = require('@discordjs/rest').RateLimitError;
__exportStar(require('discord-api-types/v10'), exports);
__exportStar(require('@discordjs/builders'), exports);
__exportStar(require('@discordjs/rest'), exports);

View File

@@ -8,7 +8,7 @@ const { basename, flatten } = require('../util/Util');
class AttachmentBuilder {
/**
* @param {BufferResolvable|Stream} attachment The file
* @param {APIAttachment} [data] Extra data
* @param {AttachmentData} [data] Extra data
*/
constructor(attachment, data = {}) {
/**
@@ -108,3 +108,9 @@ module.exports = AttachmentBuilder;
* @external APIAttachment
* @see {@link https://discord.com/developers/docs/resources/channel#attachment-object}
*/
/**
* @typedef {Object} AttachmentData
* @property {string} [name] The name of the attachment
* @property {string} [description] The description of the attachment
*/

View File

@@ -1,5 +1,6 @@
'use strict';
const { channelLink } = require('@discordjs/builders');
const { DiscordSnowflake } = require('@sapphire/snowflake');
const { ChannelType, Routes } = require('discord-api-types/v10');
const Base = require('./Base');
@@ -55,7 +56,7 @@ class BaseChannel extends Base {
* @readonly
*/
get url() {
return `https://discord.com/channels/${this.isDMBased() ? '@me' : this.guildId}/${this.id}`;
return this.isDMBased() ? channelLink(this.id) : channelLink(this.id, this.guildId);
}
/**

View File

@@ -73,8 +73,8 @@ class Embed {
* @typedef {Object} EmbedAssetData
* @property {?string} url The URL of the image
* @property {?string} proxyURL The proxy URL of the image
* @property {?string} height The height of the image
* @property {?string} width The width of the image
* @property {?number} height The height of the image
* @property {?number} width The width of the image
*/
/**

View File

@@ -287,6 +287,16 @@ class Guild extends AnonymousGuild {
this.maximumPresences ??= null;
}
if ('max_video_channel_users' in data) {
/**
* The maximum amount of users allowed in a video channel.
* @type {?number}
*/
this.maxVideoChannelUsers = data.max_video_channel_users;
} else {
this.maxVideoChannelUsers ??= null;
}
if ('approximate_member_count' in data) {
/**
* The approximate amount of members the guild has
@@ -550,7 +560,7 @@ class Guild extends AnonymousGuild {
* @returns {Promise<Collection<string, GuildTemplate>>}
*/
async fetchTemplates() {
const templates = await this.client.rest.get(Routes.guildTemplate(this.id));
const templates = await this.client.rest.get(Routes.guildTemplates(this.id));
return templates.reduce((col, data) => col.set(data.code, new GuildTemplate(this.client, data)), new Collection());
}

View File

@@ -1,5 +1,6 @@
'use strict';
const { messageLink } = require('@discordjs/builders');
const { Collection } = require('@discordjs/collection');
const { DiscordSnowflake } = require('@sapphire/snowflake');
const {
@@ -439,7 +440,7 @@ class Message extends Base {
* @readonly
*/
get url() {
return `https://discord.com/channels/${this.guildId ?? '@me'}/${this.channelId}/${this.id}`;
return this.inGuild() ? messageLink(this.channelId, this.id, this.guildId) : messageLink(this.channelId, this.id);
}
/**

View File

@@ -48,6 +48,14 @@ class MessageMentions {
*/
static GlobalChannelsPattern = new RegExp(this.ChannelsPattern.source, 'g');
/**
* A global regular expression variant of {@link MessageMentions.UsersPattern}.
* @type {RegExp}
* @memberof MessageMentions
* @private
*/
static GlobalUsersPattern = new RegExp(this.UsersPattern.source, 'g');
constructor(message, users, roles, everyone, crosspostedChannels, repliedUser) {
/**
* The client the message is from
@@ -133,6 +141,13 @@ class MessageMentions {
*/
this._channels = null;
/**
* Cached users for {@link MessageMentions#parsedUsers}
* @type {?Collection<Snowflake, User>}
* @private
*/
this._parsedUsers = null;
/**
* Crossposted channel data.
* @typedef {Object} CrosspostedChannel
@@ -208,6 +223,23 @@ class MessageMentions {
return this._channels;
}
/**
* Any user mentions that were included in the message content
* <info>Order as they appear first in the message content</info>
* @type {Collection<Snowflake, User>}
* @readonly
*/
get parsedUsers() {
if (this._parsedUsers) return this._parsedUsers;
this._parsedUsers = new Collection();
let matches;
while ((matches = this.constructor.GlobalUsersPattern.exec(this._content)) !== null) {
const user = this.client.users.cache.get(matches[1]);
if (user) this._parsedUsers.set(user.id, user);
}
return this._parsedUsers;
}
/**
* Options used to check for a mention.
* @typedef {Object} MessageMentionsHasOptions
@@ -227,16 +259,23 @@ class MessageMentions {
*/
has(data, { ignoreDirect = false, ignoreRoles = false, ignoreRepliedUser = false, ignoreEveryone = false } = {}) {
const user = this.client.users.resolve(data);
const role = this.guild?.roles.resolve(data);
const channel = this.client.channels.resolve(data);
if (!ignoreRepliedUser && this.users.has(this.repliedUser?.id) && this.repliedUser?.id === user?.id) return true;
if (!ignoreEveryone && user && this.everyone) return true;
const userWasRepliedTo = user && this.repliedUser?.id === user.id;
if (!ignoreRepliedUser && userWasRepliedTo && this.users.has(user.id)) return true;
if (!ignoreDirect) {
if (this.users.has(user?.id)) return true;
if (this.roles.has(role?.id)) return true;
if (this.channels.has(channel?.id)) return true;
if (user && (!ignoreRepliedUser || this.parsedUsers.has(user.id)) && this.users.has(user.id)) return true;
const role = this.guild?.roles.resolve(data);
if (role && this.roles.has(role.id)) return true;
const channel = this.client.channels.resolve(data);
if (channel && this.channels.has(channel.id)) return true;
}
if (user && !ignoreEveryone && this.everyone) return true;
if (!ignoreRoles) {
const member = this.guild?.members.resolve(data);
if (member) {

View File

@@ -283,10 +283,11 @@ class ThreadChannel extends BaseChannel {
* <info>This only works when the thread started from a message in the parent channel, otherwise the promise will
* reject. If you just need the id of that message, use {@link ThreadChannel#id} instead.</info>
* @param {BaseFetchOptions} [options] Additional options for this fetch
* @returns {Promise<Message>}
* @returns {Promise<Message|null>}
*/
fetchStarterMessage(options) {
return this.parent.messages.fetch({ message: this.id, ...options });
// eslint-disable-next-line require-await
async fetchStarterMessage(options) {
return this.parent?.messages.fetch({ message: this.id, ...options }) ?? null;
}
/**

View File

@@ -197,7 +197,7 @@ class InteractionResponses {
});
this.deferred = true;
return options.fetchReply ? this.fetchReply() : new InteractionResponse(this, this.message.interaction?.id);
return options.fetchReply ? this.fetchReply() : new InteractionResponse(this, this.message?.interaction?.id);
}
/**

View File

@@ -283,7 +283,7 @@ class TextBasedChannel {
* @param {Collection<Snowflake, Message>|MessageResolvable[]|number} messages
* Messages or number of messages to delete
* @param {boolean} [filterOld=false] Filter messages to remove those which are older than two weeks automatically
* @returns {Promise<Collection<Snowflake, Message>>} Returns the deleted messages
* @returns {Promise<Collection<Snowflake, Message|undefined>>} Returns the deleted messages
* @example
* // Bulk delete messages
* channel.bulkDelete(5)

View File

@@ -2,36 +2,36 @@
/**
* @typedef {Object} Colors
* @property {number} Default
* @property {number} White
* @property {number} Aqua
* @property {number} Green
* @property {number} Blue
* @property {number} Yellow
* @property {number} Purple
* @property {number} LuminousVividPink
* @property {number} Fuchsia
* @property {number} Gold
* @property {number} Orange
* @property {number} Red
* @property {number} Grey
* @property {number} Navy
* @property {number} DarkAqua
* @property {number} DarkGreen
* @property {number} DarkBlue
* @property {number} DarkPurple
* @property {number} DarkVividPink
* @property {number} DarkGold
* @property {number} DarkOrange
* @property {number} DarkRed
* @property {number} DarkGrey
* @property {number} DarkerGrey
* @property {number} LightGrey
* @property {number} DarkNavy
* @property {number} Blurple
* @property {number} Greyple
* @property {number} DarkButNotBlack
* @property {number} NotQuiteBlack
* @property {number} Default 0x000000 | rgb(0,0,0)
* @property {number} White 0xFFFFFF | rgb(255,255,255)
* @property {number} Aqua 0x1ABC9C | rgb(26,188,156)
* @property {number} Green 0x57F287 | rgb(87,242,135)
* @property {number} Blue 0x3498DB | rgb(52,152,219)
* @property {number} Yellow 0xFEE75C | rgb(254,231,92)
* @property {number} Purple 0x9B59B6 | rgb(155,89,182)
* @property {number} LuminousVividPink 0xE91E63 | rgb(233,30,99)
* @property {number} Fuchsia 0xEB459E | rgb(235,69,158)
* @property {number} Gold 0xF1C40F | rgb(241,196,15)
* @property {number} Orange 0xE67E22 | rgb(230,126,34)
* @property {number} Red 0xED4245 | rgb(237,66,69)
* @property {number} Grey 0x95A5A6 | rgb(149,165,166)
* @property {number} Navy 0x34495E | rgb(52,73,94)
* @property {number} DarkAqua 0x11806A | rgb(17,128,106)
* @property {number} DarkGreen 0x1F8B4C | rgb(31,139,76)
* @property {number} DarkBlue 0x206694 | rgb(32,102,148)
* @property {number} DarkPurple 0x71368A | rgb(113,54,138)
* @property {number} DarkVividPink 0xAD1457 | rgb(173,20,87)
* @property {number} DarkGold 0xC27C0E | rgb(194,124,14)
* @property {number} DarkOrange 0xA84300 | rgb(168,67,0)
* @property {number} DarkRed 0x992D22 | rgb(153,45,34)
* @property {number} DarkGrey 0x979C9F | rgb(151,156,159)
* @property {number} DarkerGrey 0x7F8C8D | rgb(127,140,141)
* @property {number} LightGrey 0xBCC0C0 | rgb(188,192,192)
* @property {number} DarkNavy 0x2C3E50 | rgb(44,62,80)
* @property {number} Blurple 0x5865F2 | rgb(88,101,242)
* @property {number} Greyple 0x99AAb5 | rgb(153,170,181)
* @property {number} DarkButNotBlack 0x2C2F33 | rgb(44,47,51)
* @property {number} NotQuiteBlack 0x23272A | rgb(35,39,42)
*/
// JSDoc for IntelliSense purposes

View File

@@ -53,13 +53,19 @@ exports.NonSystemMessageTypes = [
];
/**
* The channels that are text-based.
* * DMChannel
* The guild channels that are text-based.
* * TextChannel
* * NewsChannel
* * ThreadChannel
* * VoiceChannel
* @typedef {DMChannel|TextChannel|NewsChannel|ThreadChannel|VoiceChannel} TextBasedChannels
* @typedef {TextChannel|NewsChannel|ThreadChannel|VoiceChannel} GuildTextBasedChannel
*/
/**
* The channels that are text-based.
* * DMChannel
* * GuildTextBasedChannel
* @typedef {DMChannel|GuildTextBasedChannel} TextBasedChannels
*/
/**

View File

@@ -116,7 +116,7 @@ class DataResolver extends null {
if (typeof resource[Symbol.asyncIterator] === 'function') {
const buffers = [];
for await (const data of resource) buffers.push(data);
for await (const data of resource) buffers.push(Buffer.from(data));
return { data: Buffer.concat(buffers) };
}

View File

@@ -132,6 +132,23 @@ const {
* @returns {string}
*/
/**
* Formats a channel link for a channel.
* @method channelLink
* @param {Snowflake} channelId The id of the channel
* @param {Snowflake} [guildId] The id of the guild
* @returns {string}
*/
/**
* Formats a message link for a channel.
* @method messageLink
* @param {Snowflake} channelId The id of the channel
* @param {Snowflake} messageId The id of the message
* @param {Snowflake} [guildId] The id of the guild
* @returns {string}
*/
/**
* A message formatting timestamp style, as defined in
* [here](https://discord.com/developers/docs/reference#message-formatting-timestamp-styles).

View File

@@ -9,6 +9,7 @@ const snakeCase = require('lodash.snakecase');
*/
function toSnakeCase(obj) {
if (typeof obj !== 'object' || !obj) return obj;
if (obj instanceof Date) return obj;
if (Array.isArray(obj)) return obj.map(toSnakeCase);
return Object.fromEntries(Object.entries(obj).map(([key, value]) => [snakeCase(key), toSnakeCase(value)]));
}

View File

@@ -1083,6 +1083,7 @@ export class Guild extends AnonymousGuild {
public afkChannelId: Snowflake | null;
public afkTimeout: number;
public applicationId: Snowflake | null;
public maxVideoChannelUsers: number | null;
public approximateMemberCount: number | null;
public approximatePresenceCount: number | null;
public available: boolean;
@@ -1865,6 +1866,7 @@ export class MessageMentions {
private _channels: Collection<Snowflake, Channel> | null;
private readonly _content: string;
private _members: Collection<Snowflake, GuildMember> | null;
private _parsedUsers: Collection<Snowflake, User> | null;
public get channels(): Collection<Snowflake, Channel>;
public readonly client: Client;
@@ -1872,14 +1874,16 @@ export class MessageMentions {
public readonly guild: Guild;
public has(data: UserResolvable | RoleResolvable | ChannelResolvable, options?: MessageMentionsHasOptions): boolean;
public get members(): Collection<Snowflake, GuildMember> | null;
public get parsedUsers(): Collection<Snowflake, User>;
public repliedUser: User | null;
public roles: Collection<Snowflake, Role>;
public users: Collection<Snowflake, User>;
public crosspostedChannels: Collection<Snowflake, CrosspostedChannel>;
public toJSON(): unknown;
public static ChannelsPattern: typeof FormattingPatterns.Channel;
private static GlobalChannelsPattern: RegExp;
private static GlobalUsersPattern: RegExp;
public static ChannelsPattern: typeof FormattingPatterns.Channel;
public static EveryonePattern: RegExp;
public static RolesPattern: typeof FormattingPatterns.Role;
public static UsersPattern: typeof FormattingPatterns.User;
@@ -1970,8 +1974,6 @@ export interface ModalMessageModalSubmitInteraction<Cached extends CacheType = C
update(
options: string | MessagePayload | InteractionUpdateOptions,
): Promise<InteractionResponse<BooleanCache<Cached>>>;
deferUpdate(options: InteractionDeferUpdateOptions & { fetchReply: true }): Promise<Message>;
deferUpdate(options?: InteractionDeferUpdateOptions): Promise<InteractionResponse<BooleanCache<Cached>>>;
inGuild(): this is ModalMessageModalSubmitInteraction<'raw' | 'cached'>;
inCachedGuild(): this is ModalMessageModalSubmitInteraction<'cached'>;
inRawGuild(): this is ModalMessageModalSubmitInteraction<'raw'>;
@@ -2002,6 +2004,8 @@ export class ModalSubmitInteraction<Cached extends CacheType = CacheType> extend
public deferReply(options?: InteractionDeferReplyOptions): Promise<InteractionResponse<BooleanCache<Cached>>>;
public fetchReply(): Promise<Message<BooleanCache<Cached>>>;
public followUp(options: string | MessagePayload | InteractionReplyOptions): Promise<Message<BooleanCache<Cached>>>;
public deferUpdate(options: InteractionDeferUpdateOptions & { fetchReply: true }): Promise<Message>;
public deferUpdate(options?: InteractionDeferUpdateOptions): Promise<InteractionResponse<BooleanCache<Cached>>>;
public inGuild(): this is ModalSubmitInteraction<'raw' | 'cached'>;
public inCachedGuild(): this is ModalSubmitInteraction<'cached'>;
public inRawGuild(): this is ModalSubmitInteraction<'raw'>;
@@ -2536,7 +2540,7 @@ export class ThreadChannel extends TextBasedChannelMixin(BaseChannel, ['fetchWeb
checkAdmin?: boolean,
): Readonly<PermissionsBitField> | null;
public fetchOwner(options?: BaseFetchOptions): Promise<ThreadMember | null>;
public fetchStarterMessage(options?: BaseFetchOptions): Promise<Message>;
public fetchStarterMessage(options?: BaseFetchOptions): Promise<Message | null>;
public setArchived(archived?: boolean, reason?: string): Promise<AnyThreadChannel>;
public setAutoArchiveDuration(
autoArchiveDuration: ThreadAutoArchiveDuration,
@@ -3019,152 +3023,152 @@ export const version: string;
//#region Errors
export enum DiscordjsErrorCodes {
ClientInvalidOption,
ClientInvalidProvidedShards,
ClientMissingIntents,
ClientNotReady,
ClientInvalidOption = 'ClientInvalidOption',
ClientInvalidProvidedShards = 'ClientInvalidProvidedShards',
ClientMissingIntents = 'ClientMissingIntents',
ClientNotReady = 'ClientNotReady',
TokenInvalid,
TokenMissing,
ApplicationCommandPermissionsTokenMissing,
TokenInvalid = 'TokenInvalid',
TokenMissing = 'TokenMissing',
ApplicationCommandPermissionsTokenMissing = 'ApplicationCommandPermissionsTokenMissing',
WSCloseRequested,
WSConnectionExists,
WSNotOpen,
ManagerDestroyed,
WSCloseRequested = 'WSCloseRequested',
WSConnectionExists = 'WSConnectionExists',
WSNotOpen = 'WSNotOpen',
ManagerDestroyed = 'ManagerDestroyed',
BitFieldInvalid,
BitFieldInvalid = 'BitFieldInvalid',
ShardingInvalid,
ShardingRequired,
InvalidIntents,
DisallowedIntents,
ShardingNoShards,
ShardingInProcess,
ShardingInvalidEvalBroadcast,
ShardingShardNotFound,
ShardingAlreadySpawned,
ShardingProcessExists,
ShardingWorkerExists,
ShardingReadyTimeout,
ShardingReadyDisconnected,
ShardingReadyDied,
ShardingNoChildExists,
ShardingShardMiscalculation,
ShardingInvalid = 'ShardingInvalid',
ShardingRequired = 'ShardingRequired',
InvalidIntents = 'InvalidIntents',
DisallowedIntents = 'DisallowedIntents',
ShardingNoShards = 'ShardingNoShards',
ShardingInProcess = 'ShardingInProcess',
ShardingInvalidEvalBroadcast = 'ShardingInvalidEvalBroadcast',
ShardingShardNotFound = 'ShardingShardNotFound',
ShardingAlreadySpawned = 'ShardingAlreadySpawned',
ShardingProcessExists = 'ShardingProcessExists',
ShardingWorkerExists = 'ShardingWorkerExists',
ShardingReadyTimeout = 'ShardingReadyTimeout',
ShardingReadyDisconnected = 'ShardingReadyDisconnected',
ShardingReadyDied = 'ShardingReadyDied',
ShardingNoChildExists = 'ShardingNoChildExists',
ShardingShardMiscalculation = 'ShardingShardMiscalculation',
ColorRange,
ColorConvert,
ColorRange = 'ColorRange',
ColorConvert = 'ColorConvert',
InviteOptionsMissingChannel,
InviteOptionsMissingChannel = 'InviteOptionsMissingChannel',
ButtonLabel,
ButtonURL,
ButtonCustomId,
ButtonLabel = 'ButtonLabel',
ButtonURL = 'ButtonURL',
ButtonCustomId = 'ButtonCustomId',
SelectMenuCustomId,
SelectMenuPlaceholder,
SelectOptionLabel,
SelectOptionValue,
SelectOptionDescription,
SelectMenuCustomId = 'SelectMenuCustomId',
SelectMenuPlaceholder = 'SelectMenuPlaceholder',
SelectOptionLabel = 'SelectOptionLabel',
SelectOptionValue = 'SelectOptionValue',
SelectOptionDescription = 'SelectOptionDescription',
InteractionCollectorError,
InteractionCollectorError = 'InteractionCollectorError',
FileNotFound,
FileNotFound = 'FileNotFound',
UserBannerNotFetched,
UserNoDMChannel,
UserBannerNotFetched = 'UserBannerNotFetched',
UserNoDMChannel = 'UserNoDMChannel',
VoiceNotStageChannel,
VoiceNotStageChannel = 'VoiceNotStageChannel',
VoiceStateNotOwn,
VoiceStateInvalidType,
VoiceStateNotOwn = 'VoiceStateNotOwn',
VoiceStateInvalidType = 'VoiceStateInvalidType',
ReqResourceType,
ReqResourceType = 'ReqResourceType',
ImageFormat,
ImageSize,
ImageFormat = 'ImageFormat',
ImageSize = 'ImageSize',
MessageBulkDeleteType,
MessageNonceType,
MessageContentType,
MessageBulkDeleteType = 'MessageBulkDeleteType',
MessageNonceType = 'MessageNonceType',
MessageContentType = 'MessageContentType',
SplitMaxLen,
SplitMaxLen = 'SplitMaxLen',
BanResolveId,
FetchBanResolveId,
BanResolveId = 'BanResolveId',
FetchBanResolveId = 'FetchBanResolveId',
PruneDaysType,
PruneDaysType = 'PruneDaysType',
GuildChannelResolve,
GuildVoiceChannelResolve,
GuildChannelOrphan,
GuildChannelUnowned,
GuildOwned,
GuildMembersTimeout,
GuildUncachedMe,
ChannelNotCached,
StageChannelResolve,
GuildScheduledEventResolve,
FetchOwnerId,
GuildChannelResolve = 'GuildChannelResolve',
GuildVoiceChannelResolve = 'GuildVoiceChannelResolve',
GuildChannelOrphan = 'GuildChannelOrphan',
GuildChannelUnowned = 'GuildChannelUnowned',
GuildOwned = 'GuildOwned',
GuildMembersTimeout = 'GuildMembersTimeout',
GuildUncachedMe = 'GuildUncachedMe',
ChannelNotCached = 'ChannelNotCached',
StageChannelResolve = 'StageChannelResolve',
GuildScheduledEventResolve = 'GuildScheduledEventResolve',
FetchOwnerId = 'FetchOwnerId',
InvalidType,
InvalidElement,
InvalidType = 'InvalidType',
InvalidElement = 'InvalidElement',
MessageThreadParent,
MessageExistingThread,
ThreadInvitableType,
MessageThreadParent = 'MessageThreadParent',
MessageExistingThread = 'MessageExistingThread',
ThreadInvitableType = 'ThreadInvitableType',
WebhookMessage,
WebhookTokenUnavailable,
WebhookURLInvalid,
WebhookApplication,
MessageReferenceMissing,
WebhookMessage = 'WebhookMessage',
WebhookTokenUnavailable = 'WebhookTokenUnavailable',
WebhookURLInvalid = 'WebhookURLInvalid',
WebhookApplication = 'WebhookApplication',
MessageReferenceMissing = 'MessageReferenceMissing',
EmojiType,
EmojiManaged,
MissingManageEmojisAndStickersPermission,
NotGuildSticker,
EmojiType = 'EmojiType',
EmojiManaged = 'EmojiManaged',
MissingManageEmojisAndStickersPermission = 'MissingManageEmojisAndStickersPermission',
NotGuildSticker = 'NotGuildSticker',
ReactionResolveUser,
ReactionResolveUser = 'ReactionResolveUser',
VanityURL,
VanityURL = 'VanityURL',
InviteResolveCode,
InviteResolveCode = 'InviteResolveCode',
InviteNotFound,
InviteNotFound = 'InviteNotFound',
DeleteGroupDMChannel,
FetchGroupDMChannel,
DeleteGroupDMChannel = 'DeleteGroupDMChannel',
FetchGroupDMChannel = 'FetchGroupDMChannel',
MemberFetchNonceLength,
MemberFetchNonceLength = 'MemberFetchNonceLength',
GlobalCommandPermissions,
GuildUncachedEntityResolve,
GlobalCommandPermissions = 'GlobalCommandPermissions',
GuildUncachedEntityResolve = 'GuildUncachedEntityResolve',
InteractionAlreadyReplied,
InteractionNotReplied,
InteractionEphemeralReplied,
InteractionAlreadyReplied = 'InteractionAlreadyReplied',
InteractionNotReplied = 'InteractionNotReplied',
InteractionEphemeralReplied = 'InteractionEphemeralReplied',
CommandInteractionOptionNotFound,
CommandInteractionOptionType,
CommandInteractionOptionEmpty,
CommandInteractionOptionNoSubcommand,
CommandInteractionOptionNoSubcommandGroup,
AutocompleteInteractionOptionNoFocusedOption,
CommandInteractionOptionNotFound = 'CommandInteractionOptionNotFound',
CommandInteractionOptionType = 'CommandInteractionOptionType',
CommandInteractionOptionEmpty = 'CommandInteractionOptionEmpty',
CommandInteractionOptionNoSubcommand = 'CommandInteractionOptionNoSubcommand',
CommandInteractionOptionNoSubcommandGroup = 'CommandInteractionOptionNoSubcommandGroup',
AutocompleteInteractionOptionNoFocusedOption = 'AutocompleteInteractionOptionNoFocusedOption',
ModalSubmitInteractionFieldNotFound,
ModalSubmitInteractionFieldType,
ModalSubmitInteractionFieldNotFound = 'ModalSubmitInteractionFieldNotFound',
ModalSubmitInteractionFieldType = 'ModalSubmitInteractionFieldType',
InvalidMissingScopes,
InvalidMissingScopes = 'InvalidMissingScopes',
NotImplemented,
NotImplemented = 'NotImplemented',
SweepFilterReturn,
SweepFilterReturn = 'SweepFilterReturn',
}
export interface DiscordjsErrorFields<Name extends string> {
readonly name: `${Name} [${keyof typeof DiscordjsErrorCodes}]`;
get code(): keyof typeof DiscordjsErrorCodes;
readonly name: `${Name} [${DiscordjsErrorCodes}]`;
get code(): DiscordjsErrorCodes;
}
export function DiscordjsErrorMixin<T, N extends string>(
@@ -3654,7 +3658,7 @@ export interface TextBasedChannelFields extends PartialTextBasedChannelFields {
bulkDelete(
messages: Collection<Snowflake, Message> | readonly MessageResolvable[] | number,
filterOld?: boolean,
): Promise<Collection<Snowflake, Message>>;
): Promise<Collection<Snowflake, Message | PartialMessage | undefined>>;
createMessageComponentCollector<T extends MessageComponentType>(
options?: MessageChannelCollectorOptionsParams<T, true>,
): InteractionCollector<MappedInteractionTypes[T]>;
@@ -3791,6 +3795,30 @@ export interface ApplicationCommandChannelOption extends BaseApplicationCommandO
channelTypes?: ChannelType[];
}
export interface ApplicationCommandRoleOptionData extends BaseApplicationCommandOptionsData {
type: ApplicationCommandOptionType.Role;
}
export interface ApplicationCommandRoleOption extends BaseApplicationCommandOptionsData {
type: ApplicationCommandOptionType.Role;
}
export interface ApplicationCommandUserOptionData extends BaseApplicationCommandOptionsData {
type: ApplicationCommandOptionType.User;
}
export interface ApplicationCommandUserOption extends BaseApplicationCommandOptionsData {
type: ApplicationCommandOptionType.User;
}
export interface ApplicationCommandMentionableOptionData extends BaseApplicationCommandOptionsData {
type: ApplicationCommandOptionType.Mentionable;
}
export interface ApplicationCommandMentionableOption extends BaseApplicationCommandOptionsData {
type: ApplicationCommandOptionType.Mentionable;
}
export interface ApplicationCommandAttachmentOption extends BaseApplicationCommandOptionsData {
type: ApplicationCommandOptionType.Attachment;
}
@@ -3831,6 +3859,10 @@ export interface ApplicationCommandStringOptionData extends ApplicationCommandCh
max_length?: number;
}
export interface ApplicationCommandBooleanOptionData extends BaseApplicationCommandOptionsData {
type: ApplicationCommandOptionType.Boolean;
}
export interface ApplicationCommandNumericOption extends ApplicationCommandChoicesOption {
type: CommandOptionNumericResolvableType;
minValue?: number;
@@ -3843,6 +3875,10 @@ export interface ApplicationCommandStringOption extends ApplicationCommandChoice
maxLength?: number;
}
export interface ApplicationCommandBooleanOption extends BaseApplicationCommandOptionsData {
type: ApplicationCommandOptionType.Boolean;
}
export interface ApplicationCommandSubGroupData extends Omit<BaseApplicationCommandOptionsData, 'required'> {
type: ApplicationCommandOptionType.SubcommandGroup;
options?: ApplicationCommandSubCommandData[];
@@ -3861,7 +3897,11 @@ export interface ApplicationCommandSubCommandData extends Omit<BaseApplicationCo
| ApplicationCommandChannelOptionData
| ApplicationCommandAutocompleteOption
| ApplicationCommandNumericOptionData
| ApplicationCommandRoleOptionData
| ApplicationCommandUserOptionData
| ApplicationCommandMentionableOptionData
| ApplicationCommandStringOptionData
| ApplicationCommandBooleanOption
)[];
}
@@ -3886,6 +3926,10 @@ export type ApplicationCommandOptionData =
| ApplicationCommandAutocompleteOption
| ApplicationCommandNumericOptionData
| ApplicationCommandStringOptionData
| ApplicationCommandRoleOptionData
| ApplicationCommandUserOptionData
| ApplicationCommandMentionableOptionData
| ApplicationCommandBooleanOptionData
| ApplicationCommandSubCommandData;
export type ApplicationCommandOption =
@@ -3895,6 +3939,10 @@ export type ApplicationCommandOption =
| ApplicationCommandChoicesOption
| ApplicationCommandNumericOption
| ApplicationCommandStringOption
| ApplicationCommandRoleOption
| ApplicationCommandUserOption
| ApplicationCommandMentionableOption
| ApplicationCommandBooleanOption
| ApplicationCommandAttachmentOption
| ApplicationCommandSubCommand;
@@ -4119,7 +4167,7 @@ export interface ClientEvents {
reactions: Collection<string | Snowflake, MessageReaction>,
];
messageReactionRemoveEmoji: [reaction: MessageReaction | PartialMessageReaction];
messageDeleteBulk: [messages: Collection<Snowflake, Message | PartialMessage>, channel: TextBasedChannel];
messageDeleteBulk: [messages: Collection<Snowflake, Message | PartialMessage>, channel: GuildTextBasedChannel];
messageReactionAdd: [reaction: MessageReaction | PartialMessageReaction, user: User | PartialUser];
messageReactionRemove: [reaction: MessageReaction | PartialMessageReaction, user: User | PartialUser];
messageUpdate: [oldMessage: Message | PartialMessage, newMessage: Message | PartialMessage];
@@ -5620,4 +5668,4 @@ export type InternalDiscordGatewayAdapterCreator = (
// External
export * from 'discord-api-types/v10';
export * from '@discordjs/builders';
export { DiscordAPIError, HTTPError, RateLimitError } from '@discordjs/rest';
export * from '@discordjs/rest';

View File

@@ -5,5 +5,4 @@ dist/
docs/**/*
!docs/index.yml
!docs/README.md
coverage/
tsup.config.*.mjs
coverage/

View File

@@ -46,18 +46,17 @@
"commander": "^9.4.0",
"jsdoc-to-markdown": "^7.1.1",
"tslib": "^2.4.0",
"typedoc": "^0.23.9"
"typedoc": "^0.23.10"
},
"devDependencies": {
"@favware/cliff-jumper": "^1.8.5",
"@favware/cliff-jumper": "^1.8.6",
"@types/jsdoc-to-markdown": "^7.0.3",
"@types/node": "^16.11.45",
"eslint": "^8.20.0",
"@types/node": "^16.11.47",
"eslint": "^8.21.0",
"prettier": "^2.7.1",
"rollup-plugin-typescript2": "0.32.1",
"tsup": "^6.2.0",
"typescript": "^4.7.4",
"unbuild": "^0.7.6"
"unbuild": "^0.8.4"
},
"engines": {
"node": ">=16.9.0"

View File

@@ -1,5 +0,0 @@
import { createTsupConfig } from '../../tsup.config';
export default createTsupConfig({
minify: true,
});

View File

@@ -3,7 +3,7 @@ FROM node:16-alpine
WORKDIR /usr/proxy
# First copy over dependencies separate from src for better caching
COPY package.json yarn.lock tsconfig.json .yarnrc.yml tsup.config.ts ./
COPY package.json yarn.lock tsconfig.json .yarnrc.yml build.config.ts ./
COPY .yarn ./.yarn
COPY ./packages/proxy-container/package.json ./packages/proxy-container/

View File

@@ -60,5 +60,5 @@ filter_commits = true
tag_pattern = "@discordjs\\/proxy-container@.*"
skip_tags = "v[0-9]*|11|12"
ignore_tags = ""
topo_order = false
date_order = true
sort_commits = "newest"

View File

@@ -49,13 +49,12 @@
"tslib": "^2.4.0"
},
"devDependencies": {
"@types/node": "^16.11.45",
"eslint": "^8.20.0",
"@types/node": "^16.11.47",
"eslint": "^8.21.0",
"prettier": "^2.7.1",
"rollup-plugin-typescript2": "0.32.1",
"tsup": "^6.2.0",
"typescript": "^4.7.4",
"unbuild": "^0.7.6"
"unbuild": "^0.8.4"
},
"engines": {
"node": ">=16.9.0"

View File

@@ -1,4 +0,0 @@
import { createTsupConfig } from '../../tsup.config';
// TODO: Set options to bundle node_modules - making the Docker image smaller
export default createTsupConfig({ minify: true, dts: false });

View File

@@ -5,5 +5,4 @@ dist/
docs/**/*
!docs/index.yml
!docs/README.md
coverage/
tsup.config.*.mjs
coverage/

View File

@@ -2,38 +2,7 @@
All notable changes to this project will be documented in this file.
# [@discordjs/proxy@1.0.1](https://github.com/discordjs/discord.js/tree/@discordjs/proxy@1.0.1) - (2022-07-27)
## Bug Fixes
- **proxy-container:** Proper deps (#8120) ([17867f9](https://github.com/discordjs/discord.js/commit/17867f9154d0dd16357f4ff29da641e23a33a9fa))
- **proxy:** Add docs script ([a45bef4](https://github.com/discordjs/discord.js/commit/a45bef4cad77dac1a4138fd0d52b769ce09b5678))
## Documentation
- Add codecov coverage badge to readmes (#8226) ([f6db285](https://github.com/discordjs/discord.js/commit/f6db285c073898a749fe4591cbd4463d1896daf5))
## Features
- Codecov (#8219) ([f10f4cd](https://github.com/discordjs/discord.js/commit/f10f4cdcd88ca6be7ec735ed3a415ba13da83db0))
- Proxy container (#8000) ([2681929](https://github.com/discordjs/discord.js/commit/2681929e4263032ad34a99ecb42465c320b271ba))
- **docgen:** Update typedoc ([b3346f4](https://github.com/discordjs/discord.js/commit/b3346f4b9b3d4f96443506643d4631dc1c6d7b21))
- Website (#8043) ([127931d](https://github.com/discordjs/discord.js/commit/127931d1df7a2a5c27923c2f2151dbf3824e50cc))
- **docgen:** Typescript support ([3279b40](https://github.com/discordjs/discord.js/commit/3279b40912e6aa61507bedb7db15a2b8668de44b))
- Docgen package (#8029) ([8b979c0](https://github.com/discordjs/discord.js/commit/8b979c0245c42fd824d8e98745ee869f5360fc86))
- Use vitest instead of jest for more speed ([8d8e6c0](https://github.com/discordjs/discord.js/commit/8d8e6c03decd7352a2aa180f6e5bc1a13602539b))
- Add scripts package for locally used scripts ([f2ae1f9](https://github.com/discordjs/discord.js/commit/f2ae1f9348bfd893332a9060f71a8a5f272a1b8b))
- @discordjs/proxy (#7925) ([1ba2d2a](https://github.com/discordjs/discord.js/commit/1ba2d2a898613e5fcc119a97dce935f4db91162c))
## Refactor
- Move all the config files to root (#8033) ([769ea0b](https://github.com/discordjs/discord.js/commit/769ea0bfe78c4f1d413c6b397c604ffe91e39c6a))
## Styling
- Cleanup tests and tsup configs ([6b8ef20](https://github.com/discordjs/discord.js/commit/6b8ef20cb3af5b5cfd176dd0aa0a1a1e98551629))
# [@discordjs/proxy@1.1.0](https://github.com/discordjs/discord.js/tree/@discordjs/proxy@1.1.0) - (2022-07-17)
# [@discordjs/proxy@1.0.0](https://github.com/discordjs/discord.js/tree/@discordjs/proxy@1.1.0) - (2022-07-17)
## Bug Fixes

View File

@@ -60,5 +60,5 @@ filter_commits = true
tag_pattern = "@discordjs\\/proxy@.*"
skip_tags = "v[0-9]*|11|12"
ignore_tags = ""
topo_order = false
date_order = true
sort_commits = "newest"

View File

@@ -56,24 +56,23 @@
"dependencies": {
"@discordjs/rest": "^1.0.0",
"tslib": "^2.4.0",
"undici": "^5.8.0"
"undici": "^5.8.2"
},
"devDependencies": {
"@discordjs/docgen": "workspace:^",
"@favware/cliff-jumper": "^1.8.5",
"@microsoft/api-extractor": "^7.28.6",
"@types/node": "^16.11.45",
"@favware/cliff-jumper": "^1.8.6",
"@microsoft/api-extractor": "^7.29.2",
"@types/node": "^16.11.47",
"@types/supertest": "^2.0.12",
"c8": "^7.12.0",
"downlevel-dts": "^0.10.0",
"eslint": "^8.20.0",
"eslint": "^8.21.0",
"prettier": "^2.7.1",
"rollup-plugin-typescript2": "0.32.1",
"supertest": "^6.2.4",
"tsup": "^6.2.0",
"typescript": "^4.7.4",
"unbuild": "^0.7.6",
"vitest": "^0.19.1"
"unbuild": "^0.8.4",
"vitest": "^0.21.1"
},
"engines": {
"node": ">=16.9.0"

View File

@@ -1,3 +0,0 @@
import { createTsupConfig } from '../../tsup.config';
export default createTsupConfig();

View File

@@ -5,5 +5,4 @@ dist/
docs/**/*
!docs/index.yml
!docs/README.md
coverage/
tsup.config.*.mjs
coverage/

View File

@@ -25,35 +25,6 @@ All notable changes to this project will be documented in this file.
- **collection:** Remove default export (#8053) ([16810f3](https://github.com/discordjs/discord.js/commit/16810f3e410bf35ed7e6e7412d517ea74c792c5d))
- Move all the config files to root (#8033) ([769ea0b](https://github.com/discordjs/discord.js/commit/769ea0bfe78c4f1d413c6b397c604ffe91e39c6a))
# [@discordjs/rest@1.0.0](https://github.com/discordjs/discord.js/compare/@discordjs/rest@0.6.0...@discordjs/rest@1.0.0) - (2022-07-17)
## Info
- 1.0.0 release bump, no new features.
# [@discordjs/rest@0.6.0](https://github.com/discordjs/discord.js/compare/@discordjs/rest@0.5.0...@discordjs/rest@0.6.0) - (2022-07-17)
## Documentation
- Add codecov coverage badge to readmes (#8226) ([f6db285](https://github.com/discordjs/discord.js/commit/f6db285c073898a749fe4591cbd4463d1896daf5))
## Features
- **builder:** Add max min length in string option (#8214) ([96c8d21](https://github.com/discordjs/discord.js/commit/96c8d21f95eb366c46ae23505ba9054f44821b25))
- Codecov (#8219) ([f10f4cd](https://github.com/discordjs/discord.js/commit/f10f4cdcd88ca6be7ec735ed3a415ba13da83db0))
- **docgen:** Update typedoc ([b3346f4](https://github.com/discordjs/discord.js/commit/b3346f4b9b3d4f96443506643d4631dc1c6d7b21))
- Website (#8043) ([127931d](https://github.com/discordjs/discord.js/commit/127931d1df7a2a5c27923c2f2151dbf3824e50cc))
- **docgen:** Typescript support ([3279b40](https://github.com/discordjs/discord.js/commit/3279b40912e6aa61507bedb7db15a2b8668de44b))
- Docgen package (#8029) ([8b979c0](https://github.com/discordjs/discord.js/commit/8b979c0245c42fd824d8e98745ee869f5360fc86))
- Use vitest instead of jest for more speed ([8d8e6c0](https://github.com/discordjs/discord.js/commit/8d8e6c03decd7352a2aa180f6e5bc1a13602539b))
- Add scripts package for locally used scripts ([f2ae1f9](https://github.com/discordjs/discord.js/commit/f2ae1f9348bfd893332a9060f71a8a5f272a1b8b))
## Refactor
- **rest:** Add content-type(s) to uploads (#8290) ([103a358](https://github.com/discordjs/discord.js/commit/103a3584c95a7b7f57fa62d47b86520d5ec32303))
- **collection:** Remove default export (#8053) ([16810f3](https://github.com/discordjs/discord.js/commit/16810f3e410bf35ed7e6e7412d517ea74c792c5d))
- Move all the config files to root (#8033) ([769ea0b](https://github.com/discordjs/discord.js/commit/769ea0bfe78c4f1d413c6b397c604ffe91e39c6a))
# [@discordjs/rest@0.5.0](https://github.com/discordjs/discord.js/compare/@discordjs/rest@0.4.0...@discordjs/rest@0.5.0) - (2022-06-04)
## Bug Fixes

View File

@@ -59,5 +59,5 @@ commit_parsers = [
filter_commits = true
tag_pattern = "@discordjs/rest@[0-9]*"
ignore_tags = ""
topo_order = false
date_order = true
sort_commits = "newest"

View File

@@ -53,27 +53,26 @@
"homepage": "https://discord.js.org",
"dependencies": {
"@discordjs/collection": "workspace:^",
"@sapphire/async-queue": "^1.3.2",
"@sapphire/async-queue": "^1.4.0",
"@sapphire/snowflake": "^3.2.2",
"discord-api-types": "^0.36.3",
"file-type": "^17.1.4",
"file-type": "^17.1.6",
"tslib": "^2.4.0",
"undici": "^5.8.0"
"undici": "^5.8.2"
},
"devDependencies": {
"@discordjs/docgen": "workspace:^",
"@favware/cliff-jumper": "^1.8.5",
"@microsoft/api-extractor": "^7.28.6",
"@types/node": "^16.11.45",
"@favware/cliff-jumper": "^1.8.6",
"@microsoft/api-extractor": "^7.29.2",
"@types/node": "^16.11.47",
"c8": "^7.12.0",
"downlevel-dts": "^0.10.0",
"eslint": "^8.20.0",
"eslint": "^8.21.0",
"prettier": "^2.7.1",
"rollup-plugin-typescript2": "0.32.1",
"tsup": "^6.2.0",
"typescript": "^4.7.4",
"unbuild": "^0.7.6",
"vitest": "^0.19.1"
"unbuild": "^0.8.4",
"vitest": "^0.21.1"
},
"engines": {
"node": ">=16.9.0"

View File

@@ -1,3 +0,0 @@
import { createTsupConfig } from '../../tsup.config';
export default createTsupConfig();

View File

@@ -5,5 +5,4 @@ dist/
docs/**/*
!docs/index.yml
!docs/README.md
coverage/
tsup.config.*.mjs
coverage/

View File

@@ -48,15 +48,14 @@
"tslib": "^2.4.0"
},
"devDependencies": {
"@types/node": "^16.11.45",
"@types/node": "^16.11.47",
"c8": "^7.12.0",
"eslint": "^8.20.0",
"eslint": "^8.21.0",
"prettier": "^2.7.1",
"rollup-plugin-typescript2": "0.32.1",
"tsup": "^6.2.0",
"typescript": "^4.7.4",
"unbuild": "^0.7.6",
"vitest": "^0.19.1"
"unbuild": "^0.8.4",
"vitest": "^0.21.1"
},
"engines": {
"node": ">=16.9.0"

View File

@@ -1,5 +0,0 @@
import { createTsupConfig } from '../../tsup.config';
export default createTsupConfig({
minify: true,
});

View File

@@ -5,5 +5,4 @@ dist/
docs/**/*
!docs/index.yml
!docs/README.md
coverage/
tsup.config.*.mjs
coverage/

View File

@@ -59,5 +59,5 @@ commit_parsers = [
filter_commits = true
tag_pattern = "@discordjs/voice@[0-9]*"
ignore_tags = ""
topo_order = false
date_order = true
sort_commits = "newest"

View File

@@ -59,26 +59,25 @@
"ws": "^8.8.1"
},
"devDependencies": {
"@babel/core": "^7.18.9",
"@babel/preset-env": "^7.18.9",
"@babel/core": "^7.18.10",
"@babel/preset-env": "^7.18.10",
"@babel/preset-typescript": "^7.18.6",
"@discordjs/docgen": "workspace:^",
"@discordjs/scripts": "workspace:^",
"@favware/cliff-jumper": "^1.8.5",
"@microsoft/api-extractor": "^7.28.6",
"@favware/cliff-jumper": "^1.8.6",
"@microsoft/api-extractor": "^7.29.2",
"@types/jest": "^28.1.6",
"@types/node": "^16.11.45",
"@types/node": "^16.11.47",
"downlevel-dts": "^0.10.0",
"eslint": "^8.20.0",
"eslint": "^8.21.0",
"jest": "^28.1.3",
"jest-websocket-mock": "^2.3.0",
"jest-websocket-mock": "^2.4.0",
"mock-socket": "^9.1.5",
"prettier": "^2.7.1",
"rollup-plugin-typescript2": "0.32.1",
"tsup": "^6.2.0",
"tweetnacl": "^1.0.3",
"typescript": "^4.7.4",
"unbuild": "^0.7.6"
"unbuild": "^0.8.4"
},
"engines": {
"node": ">=16.9.0"

View File

@@ -1,3 +0,0 @@
import { createTsupConfig } from '../../tsup.config';
export default createTsupConfig();

View File

@@ -6,7 +6,6 @@ docs/**/*
!docs/index.yml
!docs/README.md
coverage/
tsup.config.*.mjs
.cache
build/
src/styles/unocss.css

View File

@@ -47,12 +47,12 @@
},
"homepage": "https://discord.js.org",
"dependencies": {
"@microsoft/api-extractor-model": "^7.22.1",
"@microsoft/api-extractor-model": "^7.23.0",
"@microsoft/tsdoc": "0.14.1",
"@microsoft/tsdoc-config": "0.16.1",
"@vscode/codicons": "^0.0.31",
"framer-motion": "^6.5.1",
"next": "^12.2.3",
"@vscode/codicons": "^0.0.32",
"framer-motion": "^7.0.1",
"next": "^12.2.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^4.4.0",
@@ -61,26 +61,26 @@
},
"devDependencies": {
"@testing-library/cypress": "^8.0.3",
"@testing-library/dom": "^8.16.0",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/dom": "^8.17.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^14.3.0",
"@types/node": "^16.11.45",
"@testing-library/user-event": "^14.4.3",
"@types/node": "^16.11.47",
"@types/react-dom": "^18.0.6",
"@types/react-syntax-highlighter": "^15.5.4",
"@typescript-eslint/eslint-plugin": "^5.31.0",
"@typescript-eslint/parser": "^5.31.0",
"@unocss/cli": "^0.44.7",
"@unocss/preset-web-fonts": "^0.44.7",
"@unocss/reset": "^0.44.7",
"@typescript-eslint/eslint-plugin": "^5.33.0",
"@typescript-eslint/parser": "^5.33.0",
"@unocss/cli": "^0.45.5",
"@unocss/preset-web-fonts": "^0.45.5",
"@unocss/reset": "^0.45.5",
"@vitejs/plugin-react": "^2.0.0",
"c8": "^7.12.0",
"concurrently": "^7.3.0",
"cypress": "^10.3.1",
"eslint": "^8.20.0",
"cypress": "^10.4.0",
"eslint": "^8.21.0",
"eslint-config-marine": "^9.4.1",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^3.3.0",
"eslint-import-resolver-typescript": "^3.4.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
@@ -88,9 +88,9 @@
"msw": "^0.44.2",
"prettier": "^2.7.1",
"typescript": "^4.7.4",
"unocss": "^0.44.7",
"vercel": "^27.2.0",
"vitest": "^0.19.1"
"unocss": "^0.45.5",
"vercel": "^27.4.0",
"vitest": "^0.21.1"
},
"engines": {
"node": ">=16.9.0"

View File

@@ -1,11 +1,12 @@
import type { ApiEnum, ApiModel } from '@microsoft/api-extractor-model';
import { DocItem } from './DocItem';
import { genToken, resolveDocComment, TokenDocumentation } from '~/util/parse.server';
import { CommentNodeContainer } from './comment/CommentNodeContainer';
import { genToken, TokenDocumentation } from '~/util/parse.server';
export interface EnumMemberData {
name: string;
initializerTokens: TokenDocumentation[];
summary: string | null;
summary: ReturnType<DocItem['toJSON']>['summary'];
}
export class DocEnum extends DocItem<ApiEnum> {
@@ -17,7 +18,9 @@ export class DocEnum extends DocItem<ApiEnum> {
this.members = item.members.map((member) => ({
name: member.name,
initializerTokens: member.initializerExcerpt?.spannedTokens.map((token) => genToken(this.model, token)) ?? [],
summary: resolveDocComment(member),
summary: member.tsdocComment
? new CommentNodeContainer(member.tsdocComment.summarySection, model, member).toJSON()
: null,
}));
}

View File

@@ -1,6 +1,7 @@
import type { ApiModel, ApiDeclaredItem } from '@microsoft/api-extractor-model';
import { CommentNodeContainer } from './comment/CommentNodeContainer';
import type { ReferenceData } from '~/util/model.server';
import { resolveName, genReference, resolveDocComment, TokenDocumentation, genToken } from '~/util/parse.server';
import { resolveName, genReference, TokenDocumentation, genToken } from '~/util/parse.server';
export type DocItemConstructor<T = DocItem> = new (...args: any[]) => T;
@@ -8,11 +9,12 @@ export class DocItem<T extends ApiDeclaredItem = ApiDeclaredItem> {
public readonly item: T;
public readonly name: string;
public readonly referenceData: ReferenceData;
public readonly summary: string | null;
public readonly model: ApiModel;
public readonly excerpt: string;
public readonly excerptTokens: TokenDocumentation[] = [];
public readonly kind: string;
public readonly remarks: CommentNodeContainer | null;
public readonly summary: CommentNodeContainer | null;
public constructor(model: ApiModel, item: T) {
this.item = item;
@@ -20,19 +22,25 @@ export class DocItem<T extends ApiDeclaredItem = ApiDeclaredItem> {
this.model = model;
this.name = resolveName(item);
this.referenceData = genReference(item);
this.summary = resolveDocComment(item);
this.excerpt = item.excerpt.text;
this.excerptTokens = item.excerpt.spannedTokens.map((token) => genToken(model, token));
this.remarks = item.tsdocComment?.remarksBlock
? new CommentNodeContainer(item.tsdocComment.remarksBlock.content, model, item.parent)
: null;
this.summary = item.tsdocComment?.summarySection
? new CommentNodeContainer(item.tsdocComment.summarySection, model, item.parent)
: null;
}
public toJSON() {
return {
name: this.name,
referenceData: this.referenceData,
summary: this.summary,
summary: this.summary?.toJSON() ?? null,
excerpt: this.excerpt,
excerptTokens: this.excerptTokens,
kind: this.kind,
remarks: this.remarks?.toJSON() ?? null,
};
}
}

View File

@@ -0,0 +1,22 @@
import type { ApiItem, ApiModel } from '@microsoft/api-extractor-model';
import type { DocNode } from '@microsoft/tsdoc';
export class CommentNode<T extends DocNode = DocNode> {
public readonly node: T;
public readonly kind: string;
public readonly model: ApiModel;
public readonly parentItem: ApiItem | null;
public constructor(node: T, model: ApiModel, parentItem?: ApiItem) {
this.node = node;
this.kind = node.kind;
this.model = model;
this.parentItem = parentItem ?? null;
}
public toJSON() {
return {
kind: this.kind,
};
}
}

View File

@@ -0,0 +1,20 @@
import type { ApiItem, ApiModel } from '@microsoft/api-extractor-model';
import type { DocNodeContainer } from '@microsoft/tsdoc';
import { createCommentNode } from '.';
import { CommentNode } from './CommentNode';
export class CommentNodeContainer<T extends DocNodeContainer = DocNodeContainer> extends CommentNode<DocNodeContainer> {
public readonly nodes: CommentNode[];
public constructor(container: T, model: ApiModel, parentItem?: ApiItem) {
super(container, model, parentItem);
this.nodes = container.nodes.map((node) => createCommentNode(node, model, parentItem));
}
public override toJSON() {
return {
...super.toJSON(),
nodes: this.nodes.map((node) => node.toJSON()),
};
}
}

View File

@@ -0,0 +1,22 @@
import type { ApiModel, ApiItem } from '@microsoft/api-extractor-model';
import type { DocFencedCode } from '@microsoft/tsdoc';
import { CommentNode } from './CommentNode';
export class FencedCodeCommentNode extends CommentNode<DocFencedCode> {
public readonly code: string;
public readonly language: string;
public constructor(node: DocFencedCode, model: ApiModel, parentItem?: ApiItem) {
super(node, model, parentItem);
this.code = node.code;
this.language = node.language;
}
public override toJSON() {
return {
...super.toJSON(),
code: this.code,
language: this.language,
};
}
}

View File

@@ -0,0 +1,54 @@
import type { ApiItem, ApiModel } from '@microsoft/api-extractor-model';
import type { DocDeclarationReference, DocLinkTag } from '@microsoft/tsdoc';
import { CommentNode } from './CommentNode';
import { generatePath, resolveName } from '~/util/parse.server';
export function genToken(
model: ApiModel,
ref: DocDeclarationReference,
context: ApiItem | null,
): LinkTagCodeLink | null {
if (!context) {
return null;
}
const item = model.resolveDeclarationReference(ref, context).resolvedApiItem ?? null;
if (!item) {
return null;
}
return {
name: resolveName(item),
kind: item.kind,
path: generatePath(item.getHierarchy()),
};
}
export interface LinkTagCodeLink {
name: string;
kind: string;
path: string;
}
export class LinkTagCommentNode extends CommentNode<DocLinkTag> {
public readonly codeDestination: LinkTagCodeLink | null;
public readonly text: string | null;
public readonly urlDestination: string | null;
public constructor(node: DocLinkTag, model: ApiModel, parentItem?: ApiItem) {
super(node, model, parentItem);
this.codeDestination = node.codeDestination ? genToken(model, node.codeDestination, this.parentItem) : null;
this.text = node.linkText ?? null;
this.urlDestination = node.urlDestination ?? null;
}
public override toJSON() {
return {
...super.toJSON(),
text: this.text,
codeDestination: this.codeDestination,
urlDestination: this.urlDestination,
};
}
}

View File

@@ -0,0 +1,19 @@
import type { ApiItem, ApiModel } from '@microsoft/api-extractor-model';
import type { DocPlainText } from '@microsoft/tsdoc';
import { CommentNode } from './CommentNode';
export class PlainTextCommentNode extends CommentNode<DocPlainText> {
public readonly text: string;
public constructor(node: DocPlainText, model: ApiModel, parentItem?: ApiItem) {
super(node, model, parentItem);
this.text = node.text;
}
public override toJSON() {
return {
...super.toJSON(),
text: this.text,
};
}
}

View File

@@ -0,0 +1,22 @@
import type { ApiModel, ApiItem } from '@microsoft/api-extractor-model';
import type { DocNode, DocPlainText, DocLinkTag, DocParagraph, DocFencedCode } from '@microsoft/tsdoc';
import { CommentNode } from './CommentNode';
import { CommentNodeContainer } from './CommentNodeContainer';
import { FencedCodeCommentNode } from './FencedCodeCommentNode';
import { LinkTagCommentNode } from './LinkTagCommentNode';
import { PlainTextCommentNode } from './PlainTextCommentNode';
export function createCommentNode(node: DocNode, model: ApiModel, parentItem?: ApiItem): CommentNode {
switch (node.kind) {
case 'PlainText':
return new PlainTextCommentNode(node as DocPlainText, model, parentItem);
case 'LinkTag':
return new LinkTagCommentNode(node as DocLinkTag, model, parentItem);
case 'Paragraph':
return new CommentNodeContainer(node as DocParagraph, model, parentItem);
case 'FencedCode':
return new FencedCodeCommentNode(node as DocFencedCode, model, parentItem);
default:
return new CommentNode(node, model, parentItem);
}
}

View File

@@ -1,5 +1,7 @@
import type { ReactNode } from 'react';
import { CommentSection } from './Comment';
import { HyperlinkedText } from './HyperlinkedText';
import type { DocItem } from '~/DocModel/DocItem';
import type { TokenDocumentation } from '~/util/parse.server';
export enum CodeListingSeparatorType {
@@ -9,7 +11,7 @@ export enum CodeListingSeparatorType {
export interface CodeListingProps {
name: string;
summary?: string | null;
summary?: ReturnType<DocItem['toJSON']>['summary'];
typeTokens: TokenDocumentation[];
separator?: CodeListingSeparatorType;
children?: ReactNode;
@@ -34,7 +36,7 @@ export function CodeListing({
<HyperlinkedText tokens={typeTokens} />
</h4>
</div>
{summary && <p className="text-dark-100 dark:text-gray-300">{summary}</p>}
{summary && <CommentSection textClassName="text-dark-100 dark:text-gray-300" node={summary} />}
{children}
</div>
</div>

View File

@@ -0,0 +1,61 @@
import Link from 'next/link';
import type { ReactNode } from 'react';
import { PrismAsyncLight as SyntaxHighlighter } from 'react-syntax-highlighter';
import type { CommentNode } from '~/DocModel/comment/CommentNode';
import type { CommentNodeContainer } from '~/DocModel/comment/CommentNodeContainer';
import type { FencedCodeCommentNode } from '~/DocModel/comment/FencedCodeCommentNode';
import type { LinkTagCommentNode } from '~/DocModel/comment/LinkTagCommentNode';
import type { PlainTextCommentNode } from '~/DocModel/comment/PlainTextCommentNode';
export interface RemarksBlockProps {
node: ReturnType<CommentNode['toJSON']>;
textClassName?: string | undefined;
}
export function CommentSection({ node, textClassName }: RemarksBlockProps): JSX.Element {
const createNode = (node: ReturnType<CommentNode['toJSON']>): ReactNode => {
switch (node.kind) {
case 'PlainText':
return <span>{(node as ReturnType<PlainTextCommentNode['toJSON']>).text}</span>;
case 'Paragraph':
return (
<p className={textClassName}>
{(node as ReturnType<CommentNodeContainer['toJSON']>).nodes.map((node) => createNode(node))}
</p>
);
case 'SoftBreak':
return <br />;
case 'LinkTag': {
const { codeDestination, urlDestination, text } = node as ReturnType<LinkTagCommentNode['toJSON']>;
if (codeDestination) {
return <Link href={codeDestination.path}>{text ?? codeDestination.name}</Link>;
}
if (urlDestination) {
return <Link href={urlDestination}>{text ?? urlDestination}</Link>;
}
return null;
}
case 'FencedCodeBlock': {
const { language, code } = node as ReturnType<FencedCodeCommentNode['toJSON']>;
return <SyntaxHighlighter language={language}>{code}</SyntaxHighlighter>;
}
default:
break;
}
return null;
};
return (
<div>
{node.kind === 'Paragraph' || node.kind === 'Section' ? (
<>{(node as CommentNodeContainer).nodes.map(createNode)}</>
) : (
<>{createNode(node)}</>
)}
</div>
);
}

View File

@@ -1,10 +1,13 @@
import type { ReactNode } from 'react';
import { VscListSelection, VscSymbolParameter } from 'react-icons/vsc';
import { PrismAsyncLight as SyntaxHighlighter } from 'react-syntax-highlighter';
import { vscDarkPlus } from 'react-syntax-highlighter/dist/cjs/styles/prism';
import { CodeListingSeparatorType } from './CodeListing';
import { CommentSection } from './Comment';
import { HyperlinkedText } from './HyperlinkedText';
import { Section } from './Section';
import { TypeParamTable } from './TypeParamTable';
import type { DocItem } from '~/DocModel/DocItem';
import { generateIcon } from '~/util/icon';
import type { TokenDocumentation, TypeParameterData } from '~/util/parse.server';
@@ -12,23 +15,33 @@ export interface DocContainerProps {
name: string;
kind: string;
excerpt: string;
summary?: string | null;
summary?: ReturnType<DocItem['toJSON']>['summary'];
children?: ReactNode;
extendsTokens?: TokenDocumentation[] | null;
implementsTokens?: TokenDocumentation[][];
typeParams?: TypeParameterData[];
}
export function DocContainer({ name, kind, excerpt, summary, typeParams, children, extendsTokens }: DocContainerProps) {
export function DocContainer({
name,
kind,
excerpt,
summary,
typeParams,
children,
extendsTokens,
implementsTokens,
}: DocContainerProps) {
return (
<>
<div className="bg-white dark:bg-dark border-b-solid border-gray border-0.5 border-width-0.5 sticky top-0 px-10 py-2">
<div className="flex flex-col min-h-full max-h-full grow">
<div className="border-0.5 border-gray px-10 py-2">
<h2 className="flex gap-2 items-center break-all m-0 dark:text-white">
{generateIcon(kind)}
{name}
</h2>
</div>
<div className="px-10 pt-5 pb-10">
<div className="min-h-full overflow-y-auto overflow-x-clip px-10 pt-5 pb-10">
<SyntaxHighlighter
wrapLines
wrapLongLines
@@ -40,25 +53,48 @@ export function DocContainer({ name, kind, excerpt, summary, typeParams, childre
</SyntaxHighlighter>
{extendsTokens?.length ? (
<div className="flex flex-row items-center dark:text-white gap-3">
<h3 className="m-0">Extends:</h3>
<h3 className="m-0">Extends</h3>
<h3 className="m-0">{CodeListingSeparatorType.Type}</h3>
<p className="font-mono break-all">
<HyperlinkedText tokens={extendsTokens} />
</p>
</div>
) : null}
{implementsTokens?.length ? (
<div className="flex flex-row items-center dark:text-white gap-3">
<h3 className="m-0">Implements</h3>
<h3 className="m-0">{CodeListingSeparatorType.Type}</h3>
<p className="font-mono break-all">
{implementsTokens.map((token, i) => (
<>
<HyperlinkedText key={i} tokens={token} />
{i < implementsTokens.length - 1 ? ', ' : ''}
</>
))}
</p>
</div>
) : null}
<div className="space-y-10">
<Section title="Summary" className="dark:text-white">
<p className="text-dark-100 dark:text-gray-300 m-0">{summary ?? 'No summary provided.'}</p>
<Section iconElement={<VscListSelection />} title="Summary" className="dark:text-white">
{summary ? (
<CommentSection textClassName="text-dark-100 dark:text-gray-300" node={summary} />
) : (
<p className="text-dark-100 dark:text-gray-300">No summary provided.</p>
)}
</Section>
{typeParams?.length ? (
<Section title="Type Parameters" className="dark:text-white" defaultClosed>
<Section
iconElement={<VscSymbolParameter />}
title="Type Parameters"
className="dark:text-white"
defaultClosed
>
<TypeParamTable data={typeParams} />
</Section>
) : null}
<div className="space-y-10">{children}</div>
</div>
</div>
</>
</div>
);
}

View File

@@ -19,7 +19,7 @@ export function HyperlinkedText({ tokens }: HyperlinkedTextProps) {
if (token.path) {
return (
<Link key={token.text} href={token.path}>
<a className="text-blue-500 dark:text-blue-300">{token.text}</a>
<a className="text-blue-500 dark:text-blue-300 no-underline">{token.text}</a>
</Link>
);
}

View File

@@ -29,7 +29,7 @@ export function ItemSidebar({ packageName, data, selectedMember }: ItemListProps
<FiMenu size={32} />
</button>
</div>
<div className="hidden lg:block lg:min-h-full overflow-y-auto overflow-x-clip py-7 px-4">
<div className="hidden lg:block lg:min-h-full overflow-y-auto overflow-x-clip py-3 px-4">
<ListSidebar members={data.members} title="test" selectedMember={selectedMember} />
</div>
</div>

View File

@@ -1,8 +1,14 @@
import { AnimatePresence, motion } from 'framer-motion';
import Link from 'next/link';
import { useState } from 'react';
import { VscChevronDown, VscChevronRight } from 'react-icons/vsc';
import {
VscSymbolClass,
VscSymbolEnum,
VscSymbolField,
VscSymbolInterface,
VscSymbolMethod,
VscSymbolVariable,
} from 'react-icons/vsc';
import type { ItemListProps } from './ItemSidebar';
import { Section } from './Section';
export type Members = ItemListProps['data']['members'];
@@ -57,61 +63,21 @@ function groupMembers(members: Members): GroupedMembers {
return { Classes, Functions, Enums, Interfaces, Types, Variables };
}
export function ListSidebarSection({ members, selectedMember, title }: ListSidebarSectionProps) {
const [showList, setShowList] = useState(true);
return (
<div>
<h3
className="flex items-center dark:text-white m-0 py-3 font-semibold gap-2 cursor-pointer"
onClick={() => setShowList(!showList)}
>
{showList ? <VscChevronDown size={20} /> : <VscChevronRight size={20} />}
{title}
</h3>
<AnimatePresence exitBeforeEnter initial={false}>
{showList ? (
<motion.div
className="ml-7 space-y-3"
transition={{ duration: 0.5, ease: [0.04, 0.62, 0.23, 0.98] }}
key="content"
initial="collapsed"
animate="open"
exit="collapsed"
variants={{
open: {
opacity: 1,
height: 'auto',
},
collapsed: {
opacity: 0,
height: 0,
},
}}
>
{members.map((member, i) => (
<div
key={i}
className="flex gap-2 whitespace-pre-wrap no-underline break-all text-blue-500 dark:text-blue-300"
>
<Link href={member.path}>
<a
className={`no-underline m-0 text-sm font-semibold ${
selectedMember === member.name
? 'text-blue-500 dark:text-blue-300'
: 'text-gray-500 dark:text-gray-300 hover:text-dark-100 dark:hover:text-white'
}`}
>
{member.name}
</a>
</Link>
</div>
))}
</motion.div>
) : null}
</AnimatePresence>
</div>
);
function resolveIcon(item: keyof GroupedMembers) {
switch (item) {
case 'Classes':
return <VscSymbolClass />;
case 'Enums':
return <VscSymbolEnum />;
case 'Interfaces':
return <VscSymbolInterface />;
case 'Types':
return <VscSymbolField />;
case 'Variables':
return <VscSymbolVariable />;
case 'Functions':
return <VscSymbolMethod />;
}
}
export function ListSidebar({ members, selectedMember }: ListSidebarSectionProps) {
@@ -119,14 +85,32 @@ export function ListSidebar({ members, selectedMember }: ListSidebarSectionProps
return (
<>
{Object.keys(groupItems).map((group, i) => (
<ListSidebarSection
key={i}
members={groupItems[group as keyof GroupedMembers]}
selectedMember={selectedMember}
title={group}
/>
))}
{(Object.keys(groupItems) as (keyof GroupedMembers)[])
.filter((group) => groupItems[group].length)
.map((group, i) => (
<Section iconElement={resolveIcon(group)} key={i} title={group} showSeparator={false}>
<div className="space-y-2">
{groupItems[group].map((member, i) => (
<div
key={i}
className="flex gap-2 whitespace-pre-wrap no-underline break-all text-blue-500 dark:text-blue-300"
>
<Link href={member.path}>
<a
className={`no-underline m-0 text-sm font-semibold ${
selectedMember === member.name
? 'text-blue-500 dark:text-blue-300'
: 'text-gray-500 dark:text-gray-300 hover:text-dark-100 dark:hover:text-white'
}`}
>
{member.name}
</a>
</Link>
</div>
))}
</div>
</Section>
))}
</>
);
}

View File

@@ -1,4 +1,5 @@
import { FiLink } from 'react-icons/fi';
import { CommentSection } from './Comment';
import { HyperlinkedText } from './HyperlinkedText';
import { ParameterTable } from './ParameterTable';
import type { DocMethod } from '~/DocModel/DocMethod';
@@ -43,7 +44,7 @@ export function MethodItem({ data }: MethodItemProps) {
</div>
</div>
<div className="mx-7 mb-5">
{data.summary && <p className="text-dark-100 dark:text-gray-300">{data.summary}</p>}
{data.summary && <CommentSection textClassName="text-dark-100 dark:text-gray-300" node={data.summary} />}
{data.parameters.length ? <ParameterTable data={data.parameters} /> : null}
</div>
</div>

View File

@@ -8,21 +8,31 @@ export interface SectionProps {
title: string;
className?: string | undefined;
defaultClosed?: boolean;
iconElement?: JSX.Element;
showSeparator?: boolean;
}
export function Section({ title, children, className, defaultClosed }: SectionProps) {
export function Section({
title,
children,
className,
defaultClosed,
iconElement,
showSeparator = true,
}: SectionProps) {
const [collapsed, setCollapsed] = useState(defaultClosed ?? false);
return (
<div className={className}>
<AnimatePresence initial={false}>
<h3
className="flex gap-2 whitespace-pre-wrap font-semibold dark:text-white cursor-pointer"
onClick={() => setCollapsed(!collapsed)}
>
{collapsed ? <VscChevronRight size={20} /> : <VscChevronDown size={20} />}
{title}
</h3>
<h3
className="flex gap-2 whitespace-pre-wrap font-semibold dark:text-white cursor-pointer"
onClick={() => setCollapsed(!collapsed)}
>
{collapsed ? <VscChevronRight size={20} /> : <VscChevronDown size={20} />}
{iconElement ?? null}
{title}
</h3>
<AnimatePresence initial={false} exitBeforeEnter>
{collapsed ? null : (
<>
<motion.div
@@ -37,14 +47,13 @@ export function Section({ title, children, className, defaultClosed }: SectionPr
height: 'auto',
paddingLeft: '1.75rem',
paddingRight: '1.75rem',
paddingBottom: '2.5rem',
},
collapsed: { opacity: 0, height: 0, paddingLeft: '1.75rem', paddingRight: '1.75rem', paddingBottom: 0 },
}}
>
{children}
</motion.div>
<Separator />
{showSeparator && <Separator />}
</>
)}
</AnimatePresence>

View File

@@ -1,3 +1,4 @@
import { VscSymbolConstant, VscSymbolMethod, VscSymbolProperty } from 'react-icons/vsc';
import { MethodList } from './MethodList';
import { ParameterTable } from './ParameterTable';
import { PropertyList } from './PropertyList';
@@ -11,7 +12,7 @@ export interface PropertiesSectionProps {
export function PropertiesSection({ data }: PropertiesSectionProps) {
return data.length ? (
<Section title="Properties" className="dark:text-white">
<Section iconElement={<VscSymbolProperty />} title="Properties" className="dark:text-white">
<PropertyList data={data} />
</Section>
) : null;
@@ -23,7 +24,7 @@ export interface MethodsSectionProps {
export function MethodsSection({ data }: MethodsSectionProps) {
return data.length ? (
<Section title="Methods" className="dark:text-white">
<Section iconElement={<VscSymbolMethod />} title="Methods" className="dark:text-white">
<MethodList data={data} />
</Section>
) : null;
@@ -35,7 +36,7 @@ export interface ParametersSectionProps {
export function ParametersSection({ data }: ParametersSectionProps) {
return data.length ? (
<Section title="Parameters" className="dark:text-white">
<Section iconElement={<VscSymbolConstant />} title="Parameters" className="dark:text-white">
<ParameterTable data={data} />
</Section>
) : null;

View File

@@ -9,12 +9,17 @@ export function SidebarLayout({
}: PropsWithChildren<Partial<ItemListProps & { data: { member: ReturnType<typeof findMember> } }>>) {
return (
<div className="flex flex-col lg:flex-row overflow-hidden max-w-full h-full max-h-full bg-white dark:bg-dark">
<div className="h-full w-full lg:max-w-[370px] lg:min-w-[370px]">
<div className="h-full w-full lg:max-w-[310px] lg:min-w-[310px]">
{packageName && data ? (
<ItemSidebar packageName={packageName} data={data} selectedMember={data.member?.name} />
) : null}
</div>
<div className="max-h-full grow overflow-x-hidden overflow-y-auto">{children}</div>
<div className="h-full grow">{children}</div>
<div className="h-full w-full lg:max-w-[310px] lg:min-w-[310px]">
{packageName && data?.member ? (
<ItemSidebar packageName={packageName} data={data} selectedMember={data.member.name} />
) : null}
</div>
</div>
);
}

View File

@@ -15,6 +15,7 @@ export function Class({ data }: ClassProps) {
summary={data.summary}
typeParams={data.typeParameterData}
extendsTokens={data.extendsTokens}
implementsTokens={data.implementsTokens}
>
<PropertiesSection data={data.properties} />
<MethodsSection data={data.methods} />

View File

@@ -1,3 +1,4 @@
import { VscSymbolEnumMember } from 'react-icons/vsc';
import { CodeListing, CodeListingSeparatorType } from '../CodeListing';
import { DocContainer } from '../DocContainer';
import { Section } from '../Section';
@@ -10,7 +11,7 @@ export interface EnumProps {
export function Enum({ data }: EnumProps) {
return (
<DocContainer name={data.name} kind={data.kind} excerpt={data.excerpt} summary={data.summary}>
<Section title="Members" className="dark:text-white">
<Section iconElement={<VscSymbolEnumMember />} title="Members" className="dark:text-white">
<div className="flex flex-col gap-5">
{data.members.map((member) => (
<CodeListing

View File

@@ -21,7 +21,7 @@ export function findPackage(model: ApiModel, name: string): ApiPackage | undefin
| undefined;
}
function generatePath(items: readonly ApiItem[]) {
export function generatePath(items: readonly ApiItem[]) {
let path = '/docs/main/packages/';
for (const item of items) {
switch (item.kind) {

View File

@@ -6,4 +6,3 @@ docs/**/*
!docs/index.yml
!docs/README.md
coverage/
tsup.config.*.mjs

View File

@@ -2,6 +2,12 @@
All notable changes to this project will be documented in this file.
# [@discordjs/ws@0.2.0](https://github.com/discordjs/discord.js/compare/@discordjs/ws@0.1.0...@discordjs/ws@0.2.0) - (2022-07-30)
## Bug Fixes
- **WebSocketShard:** Account code 1000 with no prior indication (#8399) ([5137bfc](https://github.com/discordjs/discord.js/commit/5137bfc17d763488083b76ee9008611df333272a))
# [@discordjs/ws@0.1.0](https://github.com/discordjs/discord.js/tree/@discordjs/ws@0.1.0) - (2022-07-27)
## Bug Fixes

View File

@@ -59,5 +59,5 @@ commit_parsers = [
filter_commits = true
tag_pattern = "@discordjs/ws@[0-9]*"
ignore_tags = ""
topo_order = false
date_order = true
sort_commits = "newest"

View File

@@ -1,6 +1,6 @@
{
"name": "@discordjs/ws",
"version": "0.1.0",
"version": "0.2.0",
"description": "Wrapper around Discord's gateway",
"scripts": {
"test": "vitest run",
@@ -54,7 +54,7 @@
"dependencies": {
"@discordjs/collection": "workspace:^",
"@discordjs/rest": "workspace:^",
"@sapphire/async-queue": "^1.3.2",
"@sapphire/async-queue": "^1.4.0",
"@types/ws": "^8.5.3",
"@vladfrangu/async_event_emitter": "^2.0.1",
"discord-api-types": "^0.36.3",
@@ -63,19 +63,18 @@
},
"devDependencies": {
"@discordjs/docgen": "workspace:^",
"@favware/cliff-jumper": "^1.8.5",
"@microsoft/api-extractor": "^7.28.6",
"@types/node": "^16.11.45",
"@favware/cliff-jumper": "^1.8.6",
"@microsoft/api-extractor": "^7.29.2",
"@types/node": "^16.11.47",
"c8": "^7.12.0",
"eslint": "^8.20.0",
"eslint": "^8.21.0",
"mock-socket": "^9.1.5",
"prettier": "^2.7.1",
"rollup-plugin-typescript2": "0.32.1",
"tsup": "^6.2.0",
"typescript": "^4.7.4",
"unbuild": "^0.7.6",
"undici": "^5.8.0",
"vitest": "^0.19.1",
"unbuild": "^0.8.4",
"undici": "^5.8.2",
"vitest": "^0.21.1",
"zlib-sync": "^0.1.7"
},
"engines": {

View File

@@ -455,13 +455,21 @@ export class WebSocketShard extends AsyncEventEmitter<WebSocketShardEventsMap> {
}
private onError(err: Error) {
this.emit('error', { err });
this.emit('error', err);
}
private async onClose(code: number) {
switch (code) {
case 1000:
case 4200: {
case CloseCodes.Normal: {
this.debug([`Disconnected normally from code ${code}`]);
return this.destroy({
code,
reason: 'Got disconnected by Discord',
recover: WebSocketShardDestroyRecovery.Reconnect,
});
}
case CloseCodes.Resuming: {
this.debug([`Disconnected normally from code ${code}`]);
break;
}

View File

@@ -1,3 +0,0 @@
import { createTsupConfig } from '../../tsup.config';
export default createTsupConfig({ entry: ['./src/**/*.ts'], bundle: false });

View File

@@ -1,54 +0,0 @@
import { relative, resolve } from 'node:path';
import { defineConfig, type Options } from 'tsup';
type ConfigOptions = Pick<
Options,
| 'globalName'
| 'minify'
| 'entry'
| 'format'
| 'target'
| 'sourcemap'
| 'skipNodeModulesBundle'
| 'noExternal'
| 'esbuildOptions'
| 'dts'
| 'bundle'
>;
export const createTsupConfig = ({
globalName,
format = ['esm', 'cjs'],
dts = true,
target = 'es2021',
sourcemap = true,
minify = false,
entry = ['src/index.ts'],
skipNodeModulesBundle = true,
noExternal,
esbuildOptions = (options, context) => {
if (context.format === 'cjs') {
options.banner = {
js: '"use strict";',
};
}
},
bundle,
}: ConfigOptions = {}) =>
defineConfig({
clean: true,
dts,
entry,
format,
minify,
skipNodeModulesBundle,
sourcemap,
target,
tsconfig: relative(__dirname, resolve(process.cwd(), 'tsconfig.json')),
keepNames: true,
globalName,
noExternal,
esbuildOptions,
bundle,
shims: true,
});

2300
yarn.lock

File diff suppressed because it is too large Load Diff