Compare commits

..

151 Commits

Author SHA1 Message Date
iCrawl
d04987f09b chore(rest): release @discordjs/rest@2.0.0 2023-07-31 21:24:28 +02:00
iCrawl
ca5a2626b4 chore(collection): release @discordjs/collection@1.5.2 2023-07-31 21:22:35 +02:00
iCrawl
3c5a4dc7a7 chore(util): release @discordjs/util@1.0.0 2023-07-31 21:18:33 +02:00
iCrawl
447652ec8a chore: format 2023-07-31 21:08:13 +02:00
iCrawl
488aa58b29 chore: fixup yarn.lock 2023-07-30 23:16:45 +02:00
iCrawl
a92d19212d ci: publishing dev version semver 2023-07-30 23:08:46 +02:00
iCrawl
fd8197fe5b chore: deps 2023-07-30 02:13:39 +02:00
ckohen
8f4256db8a refactor(REST): remove double classing (#9722)
* refactor(REST): remove double classing

BREAKING CHANGE: `REST` and `RequestManager` have been combined, most of the properties, methods, and events from both classes can now be found on `REST`
BREAKING CHANGE: `REST#raw` has been removed in favor of `REST#queueRequest`
BREAKING CHANGE: `REST#getAgent` has been removed in favor of `REST#agent`

* chore: update for /rest changes
2023-07-25 08:40:21 +00:00
Saya
6307f81385 feat: add ws option support for "buildIdentifyThrottler" (#9728)
* feat: add option support for "buildIdentifyThrottler"

* docs: add documentation for buildIdentifyThrottler

* docs: fix example code
2023-07-22 08:57:24 +00:00
iCrawl
d26e022afc chore: deps 2023-07-19 11:59:42 +02:00
iCrawl
afa98793cd chore: deps 2023-07-17 09:45:07 +02:00
Vlad Frangu
386f206caf feat: no-de-no-de, now with extra buns (#9683)
BREAKING CHANGE: The REST and RequestManager classes now extend AsyncEventEmitter
from `@vladfrangu/async_event_emitter`, which aids in cross-compatibility
between Node, Deno, Bun, CF Workers, Vercel Functions, etc.

BREAKING CHANGE: DefaultUserAgentAppendix has been adapted to support multiple
different platforms (previously mentioned Deno, Bun, CF Workers, etc)

BREAKING CHANGE: the entry point for `@discordjs/rest` will now differ
in non-node-like environments (CF Workers, etc.)

Co-authored-by: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: suneettipirneni <suneettipirneni@icloud.com>
2023-07-17 08:27:57 +02:00
David Malchin
351a18bc35 feat(create-discord-bot): throw error if the directory is a file (#9719) 2023-07-16 17:38:22 +00:00
Suneet Tipirneni
84f1b1890d feat(create-discord-bot): Add prompts, command handler and deployment script (#9570)
* feat(create-discord-bot): Add prompts, command handler and deployment script

* fix: revert package template name

* chore: make requested changes

* chore: make requested changes

* fix: remove uneeded listeners

* fix: use `0` for eslint

* fix: remaining requested changes

* chore: requested changes

* fix: remove redundant call
2023-07-16 17:13:18 +00:00
Jiralite
e5effb6f6a docs: Change Channel to BaseChannel (#9718)
docs: change `Channel` to `BaseChannel`
2023-07-16 15:06:14 +00:00
Jiralite
125405f1cf docs(BaseChannel): Remove APIChannel (#9717)
docs(BaseChannel): remove `APIChannel`
2023-07-16 14:59:35 +00:00
David Malchin
bc83cabfda feat(WebhooksAPI): allow with token requests without bot auth (#9715)
* Also move `get`'s `token` parameter to options.
2023-07-16 10:25:29 +00:00
brynpttrsn
20268ac0c4 feat(website): switch overload on hash location (#9699)
* feat(website): switch overload on hash location

* Update apps/website/src/components/OverloadSwitcher.tsx

---------

Co-authored-by: Noel <buechler.noel@outlook.com>
2023-07-15 19:34:28 +02:00
Aura Román
3c85fb21e6 feat(Client): add guildAvailable event (#9692)
* feat(Client): add `guildAvailable` event

* refactor: sort entries alphabetically

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-15 17:33:47 +00:00
brynpttrsn
4141405dcd fix(website): type alias search symbol (#9705) 2023-07-15 19:25:56 +02:00
David Malchin
8c782bfd52 fix(WebSocketShard): close errors not being catchable (#9704)
* fix(WebSocketShard): close errors not being catchable

* fix(WebSocketShard): requested changes
2023-07-15 10:55:05 +00:00
Almeida
8d97017458 feat: user avatar decorations (#8914)
feat(User): add avatar decorations

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-07-13 20:33:38 +00:00
DD
ceab07bec8 refactor(WebSocketShard): throttling error handling (#9701)
* refactor(WebSocketShard): handle unknown identify errors

* chore: use better abort check

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-12 17:19:11 +00:00
Jiralite
7fb91c57f7 fix(ChannelUpdate): Check against unknown channels (#9697)
fix(ChannelUpdate): check against unknown channels
2023-07-11 18:13:25 +00:00
Aura Román
09b0382c45 perf(Channel): linear speed position getter (#9497)
* perf(Channel): linear speed position getter

* fix: add another set of parens

* perf: lower memory and CPU usage

* refactor: add shared private utility for group types

* perf: improve readability and performance

Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>

* feat: add support for voice sortables

---------

Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-09 20:57:33 +00:00
Jiralite
719e54a921 fix(Action): Use existing recipients if available (#9653)
* fix(Action): use existing recipients if available

* fix: account for message delete -> interaction

* fix(Action): use `last_message_id` if it exists

* refactor(Action): use ternary

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-09 19:30:48 +00:00
Jiralite
ede9f4e5e2 docs(BuildersSelectMenuOption): Update link (#9690)
docs(BuildersSelectMenuOption): update link
2023-07-09 19:26:21 +00:00
MovementGH
df40dcdb85 feat: add silent option to ShardingManager (#9506)
* feat: add silent option to ShardingManager

* chore: update ShardingManagerOptions type

* chore: update typings

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-07-07 23:32:29 +00:00
RedGuy12
53c17e00c0 feat(EmbedBuilder): add .length (#8682)
* feat(Embed): add `.length`

Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>

* Move to mainlib

Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>

* types: add typings

---------

Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-07 21:53:19 +00:00
Almeida
dc73c938ff feat: guild onboarding (#9120)
* feat: guild onboarding

* feat: types and /core method

* fix: route

* fix: make emoji name non-nullable

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-07 21:48:17 +00:00
Jiralite
a48d0efb09 types(MessageManager): Allow comparison of messages again (#9612)
* types(MessageManager): allow comparison of messages again

* feat: match TypeScript

* docs: update wording

* chore: revert breaking change

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-07 21:39:01 +00:00
GrapeColor
a73d54e43a feat: add resume event in shard (#9650)
Co-authored-by: GrapeColor <grapecolor@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-07 21:34:42 +00:00
Rodrigo Leitão
cf8012c200 refactor(User): remove deprecation warning from tag (#9660)
* refactor(User): remove deprecation warning from tag

* fix: remove unnecessary declarations

* style: fix formatting issue

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-06 16:49:03 +00:00
Synbulat Biishev
0803eb562b fix: everyone role members (#9685)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-06 14:09:31 +00:00
David Malchin
78381a56cf feat(ChannelsAPI): add permission overwrites (#9651)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-07-06 13:55:29 +00:00
Suneet Tipirneni
6d5840c61e fix(core): fix inconsistencies on core (#9680)
* fix(core): fix inconsistencies on `core`

* fix: add `createForumPost` back

* fix: create -> createWebhook
2023-07-06 13:35:10 +00:00
ShadowAya
75d91b52b3 setNameLocalization typo (#9656)
fix JSDoc typo in NameAndDescription.ts > setNameLocalization
2023-06-17 14:29:35 +00:00
Almeida
766be94b93 chore: bump discord-api-types to 0.37.45 (#9654) 2023-06-15 19:06:52 +00:00
RedGuy12
b61e4fb0dc fix: awaitMessageComponent with MessageComponentInteractions (#8598)
* fix: `awaitMessageComponent` with `MessageComponentInteraction`s

Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>

* Update packages/discord.js/src/structures/InteractionCollector.js

Co-authored-by: Almeida <almeidx@pm.me>

* types: revert unrelated changes

Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>

* Remove unneeded truey check

Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>

* chore: remove extra block

Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>

* fix: `awaitMessageComponent` with `MessageComponentInteraction`s

Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>

* fix: `awaitMessageComponent` with `MessageComponentInteraction`s

Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>

---------

Signed-off-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
Co-authored-by: Almeida <almeidx@pm.me>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-14 18:25:53 +00:00
Jiralite
d64330a157 types(AutoModerationActionExecution): Add forum channels as a possible type in channel() (#9623)
types(AutoModerationActionExecution): type forum channels

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-14 18:14:16 +00:00
Jiralite
2818d7cc1d fix(client): Add missing application command permissions update event (#9639)
fix(client): add missing event

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-14 18:11:00 +00:00
RedGuy12
a6dbe163dd fix(ThreadManager): Fix internal crash upon conditionally resolving thread members (#9648)
* fix(ThreadManager): Fix crash

* chore: prettier

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-14 18:07:48 +00:00
Souji
73c2f8aa17 feat(presence): re-introduce image resolving for other platforms (#9637)
* spotify, youtube, twitch
* regression born from misunderstanding in 9a6e691

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-14 17:45:28 +00:00
GrapeColor
a873ec1e85 feat: Add message to send resume event to shard (#9626)
* fix(WebSocketManager): Fix not ready after reconnect

* fix(WebSocketManager): Move fixes from Ready to Resume

* fix: undo changes

* feat: Add message to send resume event to shard

---------

Co-authored-by: GrapeColor <grapecolor@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-14 11:43:23 +00:00
dependabot[bot]
db925fa269 build(deps-dev): bump vite from 4.3.8 to 4.3.9 (#9625)
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 4.3.8 to 4.3.9.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v4.3.9/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-13 19:20:07 +00:00
Ryan Munro
8f3bd38072 fix(User): check global name in equals (#9631)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-13 19:17:21 +00:00
ckohen
8f014c65ef chore: unpin rest, unbump node version req (#9632)
* chore: unpin rest, unbump node version req

* chore: update readmes

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-13 19:08:35 +00:00
brynpttrsn
1716202f44 fix(website): Overload switcher duplicates reference links (#9614)
fix(website): add idx to link key
2023-06-13 21:01:18 +02:00
Rodrigo Leitão
1cab79f6fd types(ModalSubmitFields): components is an array (#9406)
* types(ModalSubmitFields): components is an array

* types(ModalSubmitFields): make type coherent with docs

* refactor(ModalSubmitInteraction): remove undefined props
2023-06-13 20:58:50 +02:00
brynpttrsn
7b494aca5b fix(website): switch signature with overload (#9643) 2023-06-13 20:55:56 +02:00
Jiralite
cd6986854f types: Use readonly arrays and const type parameters in places (#9641)
* types: wrap arrays in `Readonly<>`

* refactor: prefer `readonly` syntax

Co-authored-by: Almeida <almeidx@pm.me>

* types: `const` type parameters

* test: add tests

* fix: fix more instances

---------

Co-authored-by: Almeida <almeidx@pm.me>
2023-06-12 18:00:45 +00:00
Jiralite
6c2242f4f9 types(BaseInteraction): appPermissions not null in guilds (#9601)
types(BaseInteraction): allow `appPermissions` only in guilds

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-09 10:02:22 +00:00
Mogyuchi
75308f2669 fix(WebSocketManager): await WebSocket destroy (#9519)
fix(WebSocketManager): await ws destroy

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-09 09:59:18 +00:00
İbrahim
bc2798b8ee docs: Define /core token in example (#9586)
* Importing Token

Importing token was missing, so I added it. It is getting the token from configuration file. 

It could have been done with defining a constant variable too, but importing makes more sense.

* Updated Token Field to "dotenv"

From now, user's can use dotenv package to keep their Discord client token.

* Referring token as DISCORD_TOKEN

Co-authored-by: Jaw0r3k <jaworekwiadomosci@gmail.com>

---------

Co-authored-by: Jaw0r3k <jaworekwiadomosci@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-09 09:41:07 +00:00
volcanofr
a531dc9f1c RESTOptions: (really) small description update for cdn (#9615)
Small option update cnd REST.ts

I just add "``" to uniform cdn @defaultValue with others one (like api).
The link is not broken anymore, because it do not work anymore.

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-09 09:00:20 +00:00
Ryoh827
911e6eff75 docs(ClientOptions): change default value of sweepers in docs (#9591)
* docs(ClientOptions): change default value of sweepers in docs

* docs(ClientOptions): set sweeper defaults by type

* docs(ClientOptions): add 'this.' to DefaultSweeperSettings in docs

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-09 08:45:42 +00:00
Synbulat Biishev
1ab60f9da4 feat: support new username system (#9512)
* feat: support new username system

* docs(GuildMember#displayName): update

* fix(User#hasNewUsername): use User#discriminator

* feat(User#tag): add new username

* docs(User#tag): update

* docs(User#hasNewUsername): update

* docs: update

* feat(User#defaultAvatarURL): update

* feat: remove some newly added properties

* docs(User#discriminator): update

* docs(User#globalName): bad Copilot

* feat(User#displayName): return display name

* types(User#displayName): not a partial structure

* feat: add `calculateUserDefaultAvatarId` function

* docs(CND#defaultAvatar): update

* docs(CDN#defaultAvatar): update

* feat: change default avatar id to type

* feat: deprecate `User#tag`

* docs(CDN#defaultAvatar): update

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>

* docs(User): update

Co-authored-by: Rodrigo Leitão <38259440+ImRodry@users.noreply.github.com>

* feat: update

* typing: update

Co-authored-by: Jan <66554238+vaporoxx@users.noreply.github.com>

* feat: change the param type to `Snowflake`

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: Rodrigo Leitão <38259440+ImRodry@users.noreply.github.com>
Co-authored-by: Jan <66554238+vaporoxx@users.noreply.github.com>
2023-06-08 18:16:42 +00:00
Qjuh
df8b6e9934 fix(WebSocketManager): always cache result of fetchGatewayInformation (#9611)
* fix(WebSocketManager): always cache result of fetchGatewayInformation

* fix: add comment
2023-05-29 18:45:17 +00:00
nopeless
24a61495b9 fix(Client): safe call for possibly null WebSocket (#9600)
fix(client): safe call for possibly null Websocket
2023-05-26 17:27:17 +00:00
Jiralite
e1b6eeed0e docs(Client): Correct invite gateway permission checks (#9597)
docs: correct invite gateway permission checks
2023-05-26 08:18:48 +00:00
Jiralite
53aa24d418 fix(ThreadManager): Ensure fetchActive() only returns active threads in a channel (#9568)
fix(ThreadManager): revert breaking change

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-25 17:16:48 +00:00
iCrawl
9b06734445 chore: deps 2023-05-23 20:14:15 +02:00
Digital
9345d1b1ac fix(LimitedCollection): allow items to be stored if keepOverLimit is true when maxSize is 0 (#9534)
Update LimitedCollection.js

Keep value if it matches the limit.

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-22 08:11:47 +00:00
Jiralite
47843493a5 feat(guide): Add formatters popular topic (#9566)
* feat: add formatters page

* chore: rename pages
2023-05-22 10:06:48 +02:00
David Malchin
6c7a5ed1e7 fix(api): various fixes for overlooked stuff (#9588)
* types(GuildsAPI): fix `getWidgetSettings()` result type

* types(GuildsAPI): fix `beginPrune()` result type

* types(GuildsAPI): fix `editAutoModerationRule()` result type

* types(ApplicationCommandsAPI): fix guild application types

* types(GuildsAPI): fix `createTemplate()` body type

* fix(InteractionsAPI): make `followUp()` return the message

According to the Discord docs, creating a followup message is the same as executing a webhook, but *wait is always true*, meaning we always get the message.

* types(WebhooksAPI): fix result types
2023-05-22 07:59:57 +00:00
Jaw0r3k
985def3f25 feat(api): add stage instances (#9578)
* feat(core): add stage instances

* chore: use one import

* Apply suggestions from code review

Co-authored-by: Aura Román <kyradiscord@gmail.com>

* chore: requested changes

Co-authored-by: David Malchin <malchin459@gmail.com>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: David Malchin <malchin459@gmail.com>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>

---------

Co-authored-by: Aura Román <kyradiscord@gmail.com>
Co-authored-by: David Malchin <malchin459@gmail.com>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-19 19:18:33 +00:00
Jiralite
1c4a12c7d6 types: use Snowflake instead of string for snowflakes (#9583)
fix: use `Snowflake` not `string`

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-19 17:33:43 +00:00
brynpttrsn
8107c5c0e7 fix(website): header and sidebar icons (#9574)
* fix: header icons

* Reorder imports

* remove field symbol

* fix type sidebar icon

* remove import

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-19 17:28:37 +00:00
Aura Román
b85a3f2dde refactor(collection): reduce reduce's code (#9581)
* refactor(collection): reduce `reduce`'s code

* fix: resolved bug in tests

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-18 21:05:48 +00:00
David Malchin
3535321b98 fix(GuildsAPI): use level rather than mfa_level when editing MFA (#9584) 2023-05-18 17:03:09 +00:00
Idris
46167a79d7 refactor(GuildMember): make _roles property non-enumerable (#9387)
* refactor(GuildMember): make _roles a getter and roles a normal prop

* fix: revert changes

* fix: requested changes

* fix: requested changes

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-18 10:13:19 +00:00
Idris
cffa5d19c9 feat(guide): port Collectors page (#9567)
* feat(guide): port Collectors page

* fix: requested changes

* fix: requested changes

* fix: suggested changes

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-18 09:06:00 +00:00
David Malchin
5d6eed6414 feat(GuildsAPI): add removeMember() (#9576) 2023-05-16 09:37:06 +00:00
iCrawl
90e243d350 chore: deps 2023-05-16 00:14:14 +02:00
David Malchin
590f5bc38e feat(api): add getMemberBans() query options and getMemberBan() (#9569) 2023-05-14 07:40:04 +00:00
Jiralite
7196fe36e8 fix(AutocompleteInteraction): Prevent snake casing of locales (#9565)
* fix(AutocompleteInteraction): prevent snake casing of locales

* fix: avoid unnecessary overhead ops

Co-authored-by: Aura Román <kyradiscord@gmail.com>

---------

Co-authored-by: Aura Román <kyradiscord@gmail.com>
2023-05-12 22:03:10 +00:00
iCrawl
5351ab429b build(ui): tree-shake ui components 2023-05-12 20:20:42 +02:00
iCrawl
d033f925e0 fix(websites/guide): remove flex-basis 2023-05-12 20:02:04 +02:00
iCrawl
13073acefc fix(ui): expose options for discord components 2023-05-12 20:00:02 +02:00
iCrawl
7c8849fae5 chore: deps 2023-05-12 19:58:51 +02:00
Jiralite
d01e8aa8af docs: Fix broken links to new documentation (#9563)
docs: fix broken links
2023-05-12 16:54:25 +00:00
DD
4dcc9c50f8 fix(WebSocketShard): handle initial connect being a resume (#9549)
* fix(WebSocketShard): handle initial connect being a resume

* chore: remove leftover

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-11 17:42:10 +00:00
Jiralite
a51c48e743 fix(webhooks): Remove incorrect properties in edit message code sample (#9562)
fix(webhooks): remove incorrect properties in edit message code sample
2023-05-11 16:43:54 +00:00
Jiralite
1edd01a7a4 feat(client): Support more request member fields (#9475)
feat(client): support more request member fields

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-10 16:40:52 +00:00
Jiralite
7b617bd22e feat: Create discord-api-types documentation component (#9555)
feat: add discord-api-types link component

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-09 19:49:07 +00:00
brynpttrsn
0c175c02e9 fix(website): package and version button formatting (#9556)
* fix for djs package button and removed redundant divs

* version arrow formatting

* formatting
2023-05-09 16:02:52 +02:00
Jiralite
460ac7dfe2 chore: Add repository directory (#9552)
chore: add repository directory
2023-05-08 17:12:31 +00:00
Jiralite
64324a8be1 feat: Check for empty directory (#9539)
* feat: check for empty directory

* fix: correct error

Co-authored-by: space <spaceeec@yahoo.com>

---------

Co-authored-by: space <spaceeec@yahoo.com>
2023-05-08 09:00:09 +02:00
Jiralite
b6162bc5b5 fix: Resolve imports for Windows (#9546)
fix: windows why

Co-authored-by: DD <didinele.dev@gmail.com>
Co-authored-by: Almeida <almeidx@pm.me>
2023-05-08 08:59:53 +02:00
synicalsyntax
280ed0ce08 fix(website): various UI improvements (#9538)
* fix(website): raise category z-index to prevent clipping

* refactor(website): wrap footer badges when necessary to prevent overflow
2023-05-08 08:59:25 +02:00
Jaw0r3k
5b8d535fd6 fix: Non-existing data property (#9544)
fix: not existed data prop

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-07 19:39:43 +00:00
Almeida
c4a3120354 feat(create-discord-bot): inherit stdio when installing deps (#9543) 2023-05-07 19:27:33 +00:00
Jaw0r3k
8482e3c95d fix(create-discord-bot): Fix start script (#9542)
fix: not working npm start

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-07 19:08:23 +00:00
Superchupu
12482b70ed docs: add Cloudflare sponsorship in create-discord-bot readme (#9540)
chore: add cloudflare sponsorship in `create-discord-bot` readme
2023-05-07 18:47:46 +00:00
iCrawl
fa746b079d chore: patch tsup 2023-05-07 19:17:10 +02:00
iCrawl
fc3f0756a4 chore: configs 2023-05-07 18:26:46 +02:00
iCrawl
3bfb6197a0 chore(create-discord-bot): release create-discord-bot@0.1.0 2023-05-07 18:13:04 +02:00
iCrawl
5ecc4f13b5 chore: re-gen yarn.lock 2023-05-07 18:10:56 +02:00
Jiralite
f83a8a58c9 feat: create-discord-bot (#9420)
* feat: basic initialisation

* fix: no scope

* chore: add options for issues

* feat: good word, Monbrey

* feat: basic README.md

* fix: no documentation for this

* feat: install for them

* chore: update licencing

* chore: fix year

* fix: build tsup

* feat: add TypeScript option

* feat: add `name` option

* chore: ignore annoying errors

* chore: add tsconfig.json

* refactor: remove name

We can just use the name of the directory instead.

* chore: update cliff jumper rc

* chore: bump dependencies

* chore: bump dependencies

* fix: build in prepack

* fix: configure ESLint correctly

* feat: infer package manager

* docs(packageManager): document `install()`

* fix(packageManager): do not emit a warning for `npm`

* refactor: change project name colour to yellow

* docs(constants): basic documentation

* feat: add link

* chore: add `verbatimModuleSyntax`

* chore: bump discord.js

* refactor: switch to @sapphire/ts-config

* refactor: file name changes

* refactor: tweak description

* chore: update yarn.lock

* fix: add .env

* chore: bump dependencies

* feat: event handler

* refactor: use `default`

* refactor: simpler event

* chore: bump discord.js

* fix: add release script and reorder

* style: reorder package.json

* chore: remove unneeded ignores

* chore: bump minimum Node.js version

* chore: add @types/node to TypeScript package.json

* chore: apply requested changes

Co-authored-by: Noel <buechler.noel@outlook.com>

* style: run ESLint + Prettier

* refactor: prefer "the"

* refactor: remove some comments

* feat: add ESLint + Prettier

* chore: requested changes

Co-authored-by: Noel <buechler.noel@outlook.com>

* chore: more requested changes

Co-authored-by: Noel <buechler.noel@outlook.com>

---------

Co-authored-by: Noel <buechler.noel@outlook.com>
2023-05-07 18:05:26 +02:00
iCrawl
9ddb3ff71d chore: deps 2023-05-07 18:04:10 +02:00
Superchupu
7ce6bb99e9 chore(deps): pin @discordjs/ws version in discord.js (#9533)
* chore(discord.js): pin `@discordjs/ws` version

* chore: update lockfile
2023-05-07 16:40:19 +02:00
Jiralite
da6de92e8c feat(DocsLink): Support overriding text (#9525) 2023-05-07 16:22:05 +02:00
synicalsyntax
bbf80efbb0 fix(guide): various UI improvements (#9532) 2023-05-07 16:20:54 +02:00
Synbulat Biishev
227232112d feat(GuildAuditLogsEntry#extra): add missing channel property (#9518)
* feat(GuildAuditLogsEntry#extra): add missing `channel` property

* types(GuildAuditLogsEntryExtraField): update

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-05-07 00:55:02 +00:00
Jaw0r3k
37181ab232 perf(Role): improve members getter (#9529)
perf(Role): improve members
2023-05-06 23:37:43 +00:00
ckohen
cdaa0a36f5 refactor(rest): switch api to fetch-like and provide strategies (#9416)
BREAKING CHANGE: NodeJS v18+ is required when using node due to the use of global `fetch`
BREAKING CHANGE: The raw method of REST now returns a web compatible `Respone` object.
BREAKING CHANGE: The `parseResponse` utility method has been updated to operate on a web compatible `Response` object.
BREAKING CHANGE: Many underlying internals have changed, some of which were exported.
BREAKING CHANGE: `DefaultRestOptions` used to contain a default `agent`, which is now set to `null` instead.
2023-05-06 21:09:19 +02:00
iCrawl
fc5b9c523b ci: positional arguments 2023-05-06 17:00:27 +02:00
iCrawl
256b68bf9f ci: pass push arguments to buildx 2023-05-06 16:54:08 +02:00
Jiralite
75195cc539 chore(guide): Update discord.js version to 14.11.0 (#9523) 2023-05-06 14:57:13 +02:00
DD
8d5ce32080 fix(proxy-container): docker builds (#9524) 2023-05-06 13:59:14 +02:00
iCrawl
5bfcf93e29 chore(discord.js): release discord.js@14.11.0 2023-05-06 11:06:10 +02:00
iCrawl
28f51791a2 chore(ws): release @discordjs/ws@0.8.3 2023-05-06 11:05:18 +02:00
DD
e6274681fd fix(WebSocketManager): properly emit shard error events (#9521)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-05 20:17:05 +00:00
DD
00da44a120 fix(WebSocketShard): wait a little before reconnecting (#9517)
* fix(WebSocketShard): wait a little before reconnecting

* chore: leftover comment

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-05 20:14:53 +00:00
Mateusz Burzyński
ab39683a50 chore: "hide" ./defaultWorker entrypoint with types: null (#9485)
* fix: move `types` condition to the front

* Update packages/ws/package.json

---------

Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-05-05 20:08:12 +00:00
DD
3e80f0b384 tests(ws): fix tests (#9520) 2023-05-05 22:01:28 +02:00
iCrawl
e53b94c979 chore: remove cron 2023-05-05 21:21:09 +02:00
Almeida
6b2c3fb9d0 feat(Guild): safety alerts channel and mention raid protection (#8959)
* feat(Guild): add safety alerts channel and mention raid protection

* docs: add missing tag

* fix: keep other properties in triggerMetadata

* docs(Guild): update example usage

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-05-05 18:39:58 +00:00
iCrawl
d8d21cf370 chore: cloudflare sponsorship 2023-05-05 20:29:10 +02:00
Aura Román
8e9a2b4630 perf(Role): linear speed position getter (#9493)
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-05-05 12:49:00 +00:00
iCrawl
d4f12e0a0c chore: deps 2023-05-05 14:30:47 +02:00
Jiralite
d7b18f0681 types(StringSelectMenuComponentData): options is required (#9515)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-05 12:28:39 +00:00
Jiralite
166c961261 fix(roleConnections): Fix body type for updateMetadataRecords() (#9516) 2023-05-05 09:42:12 +02:00
Jiralite
506f7fcd3b fix(guide): Fix unknown component in v14 update guide (#9514)
* chore(constants): update discord.js to 14.10.2

* feat(DocsLink): handle only a package

* fix(updating-to-v14): fix unknown component
2023-05-05 07:37:47 +00:00
Jiralite
51d53f5117 feat(guide): Add webhooks (#9479)
* feat: add page

* feat: add assets

* chore: DocsLink

Co-authored-by: Ryan Munro <monbrey@gmail.com>

* fix: config import

* fix: another assert bug

* chore: lint

* fix: actually fix the destructure

---------

Co-authored-by: Ryan Munro <monbrey@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-04 08:49:18 +00:00
Idris
aa32d67619 chore(voice-description): being consistency with Node.js casing (#9505)
docs(voice-description): being consistency with Node.js casing

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-04 08:44:35 +00:00
Suneet Tipirneni
4b077e679c refactor(guide): use @type comments for command data code (#9489)
* refactor(guide): use `@type` comments for command data code

* fix: typo

* fix: use correct doc comment

* fix: use one line

* feat: add param types

* fix: use command interaction instead

* Update apps/guide/src/content/03-creating-your-bot/03-adding-commands.mdx

Co-authored-by: Souji <timoqueezle@gmail.com>

* chore: lint

---------

Co-authored-by: Souji <timoqueezle@gmail.com>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-05-03 23:58:53 +00:00
iCrawl
c190c57d64 chore: re-apply patches 2023-05-03 18:25:20 +02:00
Jaw0r3k
423bfce286 docs: Add bug/feature form for ui and util (#9504)
feat: add tags for other packages
2023-05-03 16:20:09 +00:00
iCrawl
5d05b7230a chore: re-gen yarn.lock 2023-05-03 02:30:15 +02:00
iCrawl
7e875f6919 chore: refactor workspace 2023-05-03 02:14:22 +02:00
Qjuh
c429763be8 fix(WebSocketManager): emit raw ws events again (#9502) 2023-05-02 19:49:55 +00:00
Jiralite
1b7981e469 docs(Client): Update Sapphire's snowflake utility links (#9501) 2023-05-02 12:56:38 +02:00
Aura Román
f2ad0762c5 refactor(GuildChannel): simplify constructor (#9499) 2023-05-02 10:32:47 +00:00
iCrawl
6d7f3b0f5c chore(discord.js): release discord.js@14.10.2 2023-05-02 01:18:23 +02:00
Almeida
201b002ad4 fix: correct isJSONEncodable() import (#9495)
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-05-01 22:25:51 +00:00
Almeida
b327f4925f fix(Client): generateInvite() scope validation (#9492) 2023-05-01 22:11:11 +00:00
iCrawl
e262df9117 chore(discord.js): release discord.js@14.10.1 2023-05-01 23:50:16 +02:00
iCrawl
7a761d4cfb chore: properly use cjs in module 2023-05-01 23:49:59 +02:00
iCrawl
ac9bf3ac06 fix(Client): spelling of InvalidScopesWithPermissions 2023-05-01 23:49:32 +02:00
iCrawl
133a6bbf49 chore(builders): release @discordjs/builders@1.6.3 2023-05-01 23:35:14 +02:00
iCrawl
63fc9f8504 chore(util): release @discordjs/util@0.3.1 2023-05-01 23:34:16 +02:00
Almeida
a9f2bff82a refactor(ShardClientUtil): logic de-duplication (#9491)
added docs to the `calculateShardId` function
2023-05-01 20:08:45 +00:00
Almeida
54ceedf6c5 refactor: remove @discordjs/util re-export (#9488) 2023-05-01 21:47:30 +02:00
Jiralite
36b7fb2f00 feat(guide): Update to 14.10.0 (#9487) 2023-05-01 21:05:29 +02:00
iCrawl
9a56edaf8c chore: add module resolution for the website 2023-05-01 18:21:02 +02:00
iCrawl
be81c8bf3b chore(discord.js): release discord.js@14.10.0 2023-05-01 17:42:07 +02:00
iCrawl
c77a1765c4 chore(core): release @discordjs/core@0.6.0 2023-05-01 17:35:40 +02:00
iCrawl
3665ad65d0 chore(ws): release @discordjs/ws@0.8.2 2023-05-01 17:34:27 +02:00
iCrawl
d4de1cd09e chore(proxy): release @discordjs/proxy@1.4.1 2023-05-01 17:31:00 +02:00
iCrawl
481bbc924f chore(rest): release @discordjs/rest@1.7.1 2023-05-01 17:29:19 +02:00
420 changed files with 14638 additions and 9786 deletions

View File

@@ -1,31 +1,33 @@
# Packages
node_modules/
**/node_modules
# Log files
logs/
*.log
npm-debug.log*
**/logs
**/*.log
**/npm-debug.log*
# Runtime data
pids
*.pid
*.seed
**/pids
**/*.pid
**/*.seed
# Env
.env
**/.env
# Dist
dist/
**/dist/
**/dist-docs/
# Miscellaneous
.tmp/
.vscode/*
.idea/
.DS_Store
.turbo
tsconfig.tsbuildinfo
coverage/
__tests__/
**/.tmp
**/.vscode
**/.idea
**/.DS_Store
**/.turbo
**/tsconfig.tsbuildinfo
**/coverage
**/__tests__
**/out
# yarn
.pnp.*
@@ -37,20 +39,29 @@ __tests__/
!.yarn/versions
# Cache
.prettiercache
.eslintcache
**/.prettiercache
**/.eslintcache
**/.vercel
# Docker specific
.cliff-jumperrc.json
api-extractor.json
.eslintrc.json
.lintstagedrc.cjs
.lintstagedrc.cjs
.prettierignore
.prettierrc.js
.prettierrc.cjs
cliff.toml
CHANGELOG.md
README.md
tsconfig.eslint.json
docs/
**/.cliff-jumperrc.json
**/api-extractor.json
**/api-extractor-docs.json
**/.eslintignore
**/.eslintrc.json
**/.lintstagedrc.js
**/.lintstagedrc.cjs
**/.lintstagedrc.json
**/.prettierignore
**/.prettierrc.js
**/.prettierrc.cjs
**/.prettierrc.json
**/cliff.toml
**/CHANGELOG.md
**/README.md
**/LICENSE
**/tsconfig.eslint.json
**/tsconfig.docs.json
**/docs/
**/vitest.config.ts

View File

@@ -2,7 +2,7 @@
"root": true,
"extends": ["neon/common", "neon/node", "neon/typescript", "neon/prettier"],
"parserOptions": {
"project": "./tsconfig.eslint.json"
"project": ["./tsconfig.eslint.json", "./apps/*/tsconfig.eslint.json", "./packages/*/tsconfig.eslint.json"]
},
"rules": {
"@typescript-eslint/consistent-type-definitions": ["error", "interface"]

1
.github/CODEOWNERS vendored
View File

@@ -13,6 +13,7 @@
/packages/builders/ @discordjs/builders
/packages/collection/ @discordjs/collection
/packages/core/ @discordjs/core
/packages/create-discord-bot/ @discordjs/guide
/packages/discord.js/ @discordjs/core
/packages/docgen/ @iCrawl
/packages/formatters/ @discordjs/formatters

View File

@@ -45,4 +45,4 @@ yarn create-package <package-name> [package-description]
```
This will create new package directory under `packages/` with the required configuration files. You can
begin to make changes within the `src/` directory.
begin to make changes within the `src/` directory. It may also be required to update the CODEOWNERS file.

View File

@@ -18,11 +18,14 @@ body:
- builders
- collection
- core
- create-discord-bot
- formatters
- next
- proxy
- proxy-container
- rest
- ui
- util
- voice
- ws
validations:

View File

@@ -20,11 +20,14 @@ body:
- builders
- collection
- core
- create-discord-bot
- formatters
- next
- proxy
- proxy-container
- rest
- ui
- util
- voice
- ws
validations:

View File

@@ -16,6 +16,9 @@ packages:collection:
packages:core:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\ncore\\n"
packages:create-discord-bot:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\ncreate-discord-bot\\n"
packages:discord.js:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\ndiscord.js\\n"
@@ -34,6 +37,12 @@ packages:proxy-container:
packages:rest:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\nrest\\n"
packages:ui:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\ui\\n"
packages:util:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\util\\n"
packages:voice:
- "### Which (application|package|application or package) is this (bug
report|feature request) for\\?\\n\\nvoice\\n"

9
.github/labeler.yml vendored
View File

@@ -16,18 +16,21 @@ packages:collection:
packages:core:
- packages/core/*
- packages/core/**/*
packages:create-discord-bot:
- packages/create-discord-bot/*
- packages/create-discord-bot/**/*
packages:discord.js:
- packages/discord.js/*
- packages/discord.js/**/*
packages:next:
- packages/next/*
- packages/next/**/*
packages:docgen:
- packages/docgen/*
- packages/docgen/**/*
packages:formatters:
- packages/formatters/*
- packages/formatters/**/*
packages:next:
- packages/next/*
- packages/next/**/*
packages:proxy:
- packages/proxy/*
- packages/proxy/**/*

14
.github/labels.yml vendored
View File

@@ -1,7 +1,7 @@
- name: api changes
color: '5663e9'
color: 5663e9
- name: api support
color: '5663e9'
color: 5663e9
- name: apps:guide
color: fbca04
- name: apps:website
@@ -23,7 +23,7 @@
- name: dependencies
color: 276bd1
- name: discord
color: '5663e9'
color: 5663e9
- name: discussion
color: b6b1f9
- name: documentation
@@ -41,7 +41,7 @@
- name: has PR
color: 4b1f8e
- name: help wanted
color: '008672'
color: 008672
- name: in progress
color: ffccd7
- name: in review
@@ -60,14 +60,16 @@
color: fbca04
- name: packages:core
color: fbca04
- name: packages:discord.js
- name: packages:create-discord-bot
color: fbca04
- name: packages:next
- name: packages:discord.js
color: fbca04
- name: packages:docgen
color: fbca04
- name: packages:formatters
color: fbca04
- name: packages:next
color: fbca04
- name: packages:proxy
color: fbca04
- name: packages:proxy-container

BIN
.github/powered-by-workers.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -29,8 +29,5 @@ jobs:
- name: Login to DockerHub
run: echo ${{ secrets.DOCKER_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Build the image
run: yarn docker build @discordjs/proxy-container -t discordjs/proxy:latest
- name: Push image to DockerHub
run: docker push discordjs/proxy:latest
- name: Build & push docker image
run: yarn docker build --buildkit @discordjs/proxy-container -t discordjs/proxy:latest --push

View File

@@ -42,6 +42,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install node.js v18
uses: actions/setup-node@v3

View File

@@ -26,11 +26,5 @@ jobs:
- name: Login to DockerHub
run: echo ${{ secrets.DOCKER_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Build docker image
run: yarn docker build @discordjs/proxy-container -t discordjs/proxy:latest
- name: Tag image with major
run: docker tag discordjs/proxy discordjs/proxy:$(cut -d '.' -f1 <<< $(jq --raw-output '.version' packages/proxy-container/package.json))
- name: Push image to DockerHub
run: docker push --all-tags discordjs/proxy
- name: Build & push docker image
run: yarn docker build --buildkit @discordjs/proxy-container -t discordjs/proxy:$(cut -d '.' -f1 <<< $(jq --raw-output '.version' packages/proxy-container/package.json)) --push

18
.gitignore vendored
View File

@@ -1,8 +1,8 @@
# Packages
node_modules/
node_modules
# Log files
logs/
logs
*.log
npm-debug.log*
@@ -15,20 +15,20 @@ pids
.env
# Dist
dist/
dist-docs/
dist
dist-docs
# Miscellaneous
.tmp/
.vscode/*
.tmp
.vscode
!.vscode/extensions.json
!.vscode/settings.json
.idea/
.idea
.DS_Store
.turbo
tsconfig.tsbuildinfo
coverage/
out/
coverage
out
# yarn
.pnp.*

View File

@@ -215,7 +215,8 @@ module.exports = {
await c({ workspace: e, report: t, destination: u });
});
}
await i.execUtils.pipevp('docker', ['build', ...this.args, '-f', s, '.'], {
const h = this.buildKit ? ['buildx', 'build'] : ['build'];
await i.execUtils.pipevp('docker', [...h, ...this.args, '-f', s, '.'], {
cwd: o,
strict: !0,
stdin: this.context.stdin,
@@ -241,6 +242,7 @@ module.exports = {
'yarn docker build --copy secret.key --copy config.json @foo/bar',
],
['Install production dependencies only', 'yarn docker build --production @foo/bar'],
['Build a Docker image using BuildKit', 'yarn docker build --buildkit @foo/bar'],
],
})),
d([r.Command.String()], f.prototype, 'workspaceName', void 0),
@@ -248,6 +250,7 @@ module.exports = {
d([r.Command.String('-f,--file')], f.prototype, 'dockerFilePath', void 0),
d([r.Command.Array('--copy')], f.prototype, 'copyFiles', void 0),
d([r.Command.Boolean('--production')], f.prototype, 'production', void 0),
d([r.Command.Boolean('--buildkit')], f.prototype, 'buildKit', void 0),
d([r.Command.Path('docker', 'build')], f.prototype, 'execute', null);
const u = { commands: [f] };
plugin = e;

File diff suppressed because one or more lines are too long

View File

@@ -1,3 +1,17 @@
logFilters:
# MISSING_PEER_DEPENDENCY
- code: YN0002
level: discard
# FETCH_NOT_CACHED
- code: YN0013
level: discard
# NODE_GYP_INJECTED
- code: YN0032
level: discard
# INCOMPATIBLE_PEER_DEPENDENCY
- code: YN0060
level: discard
nodeLinker: node-modules
plugins:
@@ -10,9 +24,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-docker-build.cjs
spec: 'https://github.com/Dcard/yarn-plugins/releases/latest/download/plugin-docker-build.js'
yarnPath: .yarn/releases/yarn-3.5.0.cjs
packageExtensions:
'@storybook/core-common@*':
dependencies:
'@storybook/react-vite': '7.0.7'
yarnPath: .yarn/releases/yarn-3.5.1.cjs

View File

@@ -13,6 +13,7 @@
</p>
<p>
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
</p>
</div>

1
apps/guide/.eslintignore Normal file
View File

@@ -0,0 +1 @@
next-env.d.ts

21
apps/guide/.gitignore vendored
View File

@@ -1,8 +1,8 @@
# Packages
node_modules/
node_modules
# Log files
logs/
logs
*.log
npm-debug.log*
@@ -16,18 +16,13 @@ pids
.env*.local
# Dist
dist/
typings/
.cache/
build/
.contentlayer
.next
public/searchIndex
src/styles/unocss.css
.next/
# Miscellaneous
.tmp/
coverage/
.vercel
public/searchIndex
.tmp
.vscode
lighthouse-results/
.contentlayer
lighthouse-results

View File

@@ -1,15 +1,7 @@
# Autogenerated
CHANGELOG.md
.contentlayer
.next
.turbo
dist/
docs/**/*
!docs/index.yml
!docs/README.md
coverage/
.cache
build/
.vscode
coverage
src/styles/unocss.css
api/
.next/
.vercel/
.cache/
next-env.d.ts

View File

@@ -10,6 +10,7 @@
</p>
<p>
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
</p>
</div>

View File

@@ -7,15 +7,14 @@
"test": "vitest run",
"test:lighthouse": "lighthouse http://localhost:3000 --output-path=./lighthouse-results",
"build:local": "yarn build:prod",
"build:prod": "yarn workspaces foreach -ptR run build && yarn build:css && yarn build:next",
"build:prod": "yarn build:css && yarn build:next",
"build:next": "next build",
"build:css": "yarn generate:css",
"build:analyze": "cross-env-shell ANALYZE=true yarn build:prod",
"build:analyze": "cross-env ANALYZE=true yarn build:prod",
"preview": "next start",
"dev": "concurrently 'yarn dev:contentlayer' 'yarn dev:css' 'yarn dev:next'",
"dev": "concurrently 'yarn dev:css' 'yarn dev:next'",
"dev:next": "next dev",
"dev:css": "yarn generate:css --watch",
"dev:contentlayer": "contentlayer dev",
"generate:css": "unocss 'src/**/*.tsx' 'contentlayer.config.ts' '../../packages/ui/src/lib/components/**/*.tsx' --out-file ./src/styles/unocss.css --config ../../unocss.config.ts",
"lint": "prettier --check . && cross-env TIMING=1 eslint src --ext .mjs,.js,.cjs,.ts,.tsx --format=pretty",
"format": "prettier --write . && cross-env TIMING=1 eslint src --ext .mjs,.js,.cjs,.ts,.tsx --fix --format=pretty",
@@ -45,58 +44,55 @@
},
"homepage": "https://discord.js.org",
"dependencies": {
"@code-hike/mdx": "^0.8.2",
"@code-hike/mdx": "^0.9.0",
"@discordjs/ui": "workspace:^",
"@react-icons/all-files": "^4.1.0",
"@vercel/analytics": "^1.0.0",
"@vercel/edge-config": "^0.1.8",
"@vercel/og": "^0.5.4",
"@vercel/analytics": "^1.0.1",
"@vercel/edge-config": "^0.2.1",
"@vercel/og": "^0.5.9",
"ariakit": "^2.0.0-next.44",
"cmdk": "^0.2.0",
"contentlayer": "^0.3.2",
"next": "^13.3.4",
"next-contentlayer": "^0.3.2",
"contentlayer": "0.3.1",
"next": "^13.4.12",
"next-contentlayer": "0.3.1",
"next-themes": "^0.2.1",
"react": "^18.2.0",
"react-custom-scrollbars-2": "^4.5.0",
"react-dom": "^18.2.0",
"react-use": "^17.4.0",
"rehype-autolink-headings": "^6.1.1",
"rehype-ignore": "^1.0.5",
"rehype-raw": "^6.1.1",
"rehype-slug": "^5.1.0",
"remark-gfm": "^3.0.1",
"server-only": "^0.0.1",
"sharp": "^0.32.1"
"sharp": "^0.32.4"
},
"devDependencies": {
"@next/bundle-analyzer": "^13.3.4",
"@next/bundle-analyzer": "^13.4.12",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/html-escaper": "^3.0.0",
"@types/node": "18.16.3",
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.1",
"@unocss/cli": "^0.51.8",
"@unocss/eslint-config": "^0.51.8",
"@unocss/reset": "^0.51.8",
"@vitejs/plugin-react": "^4.0.0",
"@vitest/coverage-c8": "^0.30.1",
"concurrently": "^8.0.1",
"@types/node": "18.17.1",
"@types/react": "^18.2.17",
"@types/react-dom": "^18.2.7",
"@unocss/cli": "^0.54.0",
"@unocss/eslint-config": "^0.54.0",
"@unocss/reset": "^0.54.0",
"@vitejs/plugin-react": "^4.0.3",
"@vitest/coverage-c8": "^0.33.0",
"concurrently": "^8.2.0",
"cross-env": "^7.0.3",
"eslint": "^8.39.0",
"eslint-config-neon": "^0.1.42",
"eslint": "^8.46.0",
"eslint-config-neon": "^0.1.47",
"eslint-formatter-pretty": "^5.0.0",
"happy-dom": "^9.10.1",
"happy-dom": "^10.5.2",
"hast-util-to-string": "^2.0.0",
"hastscript": "^7.2.0",
"html-escaper": "^3.0.3",
"lighthouse": "^10.1.1",
"lighthouse": "^10.4.0",
"prettier": "^2.8.8",
"typescript": "^5.0.4",
"unocss": "^0.51.8",
"vercel": "^29.0.3",
"vitest": "^0.29.8"
"turbo": "^1.10.12",
"typescript": "^5.1.6",
"unocss": "^0.54.0",
"vercel": "^31.2.0",
"vitest": "^0.33.0"
},
"engines": {
"node": ">=18.13.0"

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

View File

@@ -3,7 +3,7 @@
import { Providers } from './providers';
import { inter } from '~/util/fonts';
export default function GlobalError({ error }: { error: Error }) {
export default function GlobalError({ error }: { readonly error: Error }) {
console.error(error);
return (

View File

@@ -1,6 +1,6 @@
'use client';
export default function Error({ error }: { error: Error }) {
export default function Error({ error }: { readonly error: Error }) {
console.error(error);
return (

View File

@@ -6,7 +6,7 @@ export async function generateStaticParams() {
return allContents.map((content) => ({ slug: [content.slug] }));
}
export default function Page({ params }: { params: { slug: string[] } }) {
export default function Page({ params }: { readonly params: { slug: string[] } }) {
const content = allContents.find((content) => content.slug === params.slug?.join('/'));
if (!content) {
@@ -14,7 +14,7 @@ export default function Page({ params }: { params: { slug: string[] } }) {
}
return (
<article className="max-w-none prose">
<article className="max-w-none px-5 prose">
<Mdx code={content?.body.code ?? ''} />
</article>
);

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1,91 @@
import { FiExternalLink } from '@react-icons/all-files/fi/FiExternalLink';
import type { PropsWithChildren } from 'react';
import {
BASE_URL_DISCORD_API_TYPES,
DISCORD_API_TYPES_VERSION,
DISCORD_API_TYPES_VOICE_VERSION,
} from '~/util/constants';
interface DiscordAPITypesLinkOptions {
/**
* The initial documentation enum, interface, function etc.
*
* @example `'RESTJSONErrorCodes'`
*/
readonly parent?: string;
/**
* The scope of where this link lives.
*
* @remarks API does not have a scope.
*/
readonly scope?: 'gateway' | 'globals' | 'payloads' | 'rest' | 'rpc' | 'utils' | 'voice';
/**
* The symbol belonging to the parent.
*
* @example '`MaximumNumberOfGuildsReached'`
*/
readonly symbol?: string;
/**
* The type of the {@link DiscordAPITypesLinkOptions.parent}.
*
* @example `'enum'`
* @example `'interface'`
*/
readonly type?: string;
}
export function DiscordAPITypesLink({
parent,
scope,
symbol,
type,
children,
}: PropsWithChildren<DiscordAPITypesLinkOptions>) {
let url = BASE_URL_DISCORD_API_TYPES;
let text = 'discord-api-types';
if (type || parent) {
url += `/api/discord-api-types`;
switch (scope) {
case 'globals':
url += `-${scope}`;
break;
case 'gateway':
case 'payloads':
case 'rest':
url += `-${scope}/common`;
break;
case 'rpc':
case 'utils':
url += `-${scope}/${DISCORD_API_TYPES_VERSION}`;
break;
case 'voice':
url += `-${scope}/${DISCORD_API_TYPES_VOICE_VERSION}`;
break;
default:
url += `-${DISCORD_API_TYPES_VERSION}`;
}
if (type) {
url += `/${type}/${parent}`;
if (symbol) url += `#${symbol}`;
} else {
url += `#${parent}`;
}
text = `${parent}${symbol ? `#${symbol}` : ''}${type?.toUpperCase() === 'FUNCTION' ? '()' : ''}`;
}
return (
<a
className="inline-flex flex-row place-items-center gap-1"
href={url}
rel="external noopener noreferrer"
target="_blank"
>
{children ?? text}
<FiExternalLink size={18} />
</a>
);
}

View File

@@ -1,4 +1,5 @@
import { FiExternalLink } from '@react-icons/all-files/fi/FiExternalLink';
import type { PropsWithChildren } from 'react';
import { BASE_URL, BASE_URL_LEGACY, PACKAGES, VERSION } from '~/util/constants';
interface DocsLinkOptions {
@@ -7,19 +8,19 @@ interface DocsLinkOptions {
*
* @remarks Functions automatically infer this.
*/
brackets?: boolean;
readonly brackets?: boolean;
/**
* The package.
*
* @defaultValue `'discord.js'`
*/
package?: (typeof PACKAGES)[number];
readonly package?: (typeof PACKAGES)[number];
/**
* The initial documentation class, function, interface etc.
*
* @example `'Client'`
*/
parent: string;
readonly parent?: string;
/**
* Whether to reference a static property.
*
@@ -27,20 +28,20 @@ interface DocsLinkOptions {
* This should only be used for the https://discord.js.org domain
* as static properties are not identified in the URL.
*/
static?: boolean;
readonly static?: boolean;
/**
* The symbol belonging to the parent.
*
* @example '`login'`
*/
symbol?: string;
readonly symbol?: string;
/**
* The type of the {@link DocsLinkOptions.parent}.
*
* @example `'class'`
* @example `'Function'`
*/
type: string;
readonly type?: string;
}
export function DocsLink({
@@ -50,29 +51,35 @@ export function DocsLink({
symbol,
brackets,
static: staticReference,
}: DocsLinkOptions) {
const bracketText = brackets || type.toUpperCase() === 'FUNCTION' ? '()' : '';
const trimmedSymbol = symbol;
let url;
let text;
children,
}: PropsWithChildren<DocsLinkOptions>) {
// In the case of no type and no parent, this will default to the entry point of the respective documentation.
let url = docs === PACKAGES[0] ? `${BASE_URL_LEGACY}/${VERSION}/general/welcome` : `${BASE_URL}/${docs}/stable`;
let text = `${docs === PACKAGES[0] ? '' : '@discordjs/'}${docs}`;
if (docs === PACKAGES[0]) {
url = `${BASE_URL_LEGACY}/${VERSION}/${type}/${parent}`;
if (trimmedSymbol) url += `?scrollTo=${trimmedSymbol}`;
// If there is a type and parent, we need to do some parsing.
if (type && parent) {
const bracketText = brackets || type?.toUpperCase() === 'FUNCTION' ? '()' : '';
text = `${parent}${trimmedSymbol ? (trimmedSymbol.startsWith('s-') ? '.' : '#') : ''}${
// eslint-disable-next-line prefer-named-capture-group
trimmedSymbol ? `${trimmedSymbol.replace(/(e|s)-/, '')}` : ''
}${bracketText}`;
} else {
url = `${BASE_URL}/${docs}/stable/${parent}:${type}`;
if (trimmedSymbol) url += `#${trimmedSymbol}`;
text = `${parent}${trimmedSymbol ? `${staticReference ? '.' : '#'}${trimmedSymbol}` : ''}${bracketText}`;
// Legacy discord.js documentation parsing.
if (docs === PACKAGES[0]) {
url = `${BASE_URL_LEGACY}/${VERSION}/${type}/${parent}`;
if (symbol) url += `?scrollTo=${symbol}`;
text = `${parent}${symbol ? (symbol.startsWith('s-') ? '.' : '#') : ''}${
// eslint-disable-next-line prefer-named-capture-group
symbol ? `${symbol.replace(/(e|s)-/, '')}` : ''
}${bracketText}`;
} else {
url += `/${parent}:${type}`;
if (symbol) url += `#${symbol}`;
text = `${parent}${symbol ? `${staticReference ? '.' : '#'}${symbol}` : ''}${bracketText}`;
}
}
return (
<a className="inline-flex flex-row place-items-center gap-1" href={url} rel="noopener noreferrer" target="_blank">
{text}
{children ?? text}
<FiExternalLink size={18} />
</a>
);

View File

@@ -1,11 +1,12 @@
import Image from 'next/image';
import vercelLogo from '~/assets/powered-by-vercel.svg';
import workersLogo from '~/assets/powered-by-workers.png';
export default function Footer() {
return (
<footer className="md:pl-12 md:pr-12">
<div className="mx-auto max-w-6xl flex flex-col place-items-center gap-12 pt-12 lg:place-content-center">
<div className="w-full flex flex-col place-content-between place-items-center gap-12 md:flex-row md:gap-0">
<div className="flex flex-col flex-wrap place-content-center gap-6 pt-12 sm:flex-row md:gap-12">
<div className="flex flex-wrap place-content-center place-items-center gap-4">
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"
@@ -22,56 +23,72 @@ export default function Footer() {
width={212}
/>
</a>
<div className="flex flex-row gap-6 md:gap-12">
<div className="flex flex-col gap-2">
<div className="text-lg font-semibold">Community</div>
<div className="flex flex-col gap-1">
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://discord.gg/djs"
rel="external noopener noreferrer"
target="_blank"
>
Discord
</a>
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://github.com/discordjs/discord.js/discussions"
rel="external noopener noreferrer"
target="_blank"
>
GitHub discussions
</a>
</div>
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://www.cloudflare.com"
rel="external noopener noreferrer"
target="_blank"
title="Cloudflare Workers"
>
<Image
alt="Cloudflare"
blurDataURL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAABLCAQAAAA1k5H2AAAAi0lEQVR42u3SMQEAAAgDoC251a3gL2SgmfBYBRAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARCAgwWEOSWBnYbKggAAAABJRU5ErkJggg=="
height={44}
placeholder="blur"
priority
src={workersLogo}
/>
</a>
</div>
<div className="flex flex-col place-self-center gap-6 sm:flex-row md:gap-12">
<div className="max-w-max flex flex-col gap-2">
<div className="text-lg font-semibold">Community</div>
<div className="flex flex-col gap-1">
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://discord.gg/djs"
rel="external noopener noreferrer"
target="_blank"
>
Discord
</a>
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://github.com/discordjs/discord.js/discussions"
rel="external noopener noreferrer"
target="_blank"
>
GitHub discussions
</a>
</div>
<div className="flex flex-col gap-2">
<div className="text-lg font-semibold">Project</div>
<div className="flex flex-col gap-1">
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://github.com/discordjs/discord.js"
rel="external noopener noreferrer"
target="_blank"
>
discord.js
</a>
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://discord.js.org/docs"
rel="noopener noreferrer"
target="_blank"
>
discord.js documentation
</a>
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://discord-api-types.dev"
rel="external noopener noreferrer"
target="_blank"
>
discord-api-types
</a>
</div>
</div>
<div className="max-w-max flex flex-col gap-2">
<div className="text-lg font-semibold">Project</div>
<div className="flex flex-col gap-1">
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://github.com/discordjs/discord.js"
rel="external noopener noreferrer"
target="_blank"
>
discord.js
</a>
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://discord.js.org/docs"
rel="noopener noreferrer"
target="_blank"
>
discord.js documentation
</a>
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://discord-api-types.dev"
rel="external noopener noreferrer"
target="_blank"
>
discord-api-types
</a>
</div>
</div>
</div>

View File

@@ -2,6 +2,7 @@
import { Alert, Section, DiscordMessages, DiscordMessage, DiscordMessageEmbed } from '@discordjs/ui';
import { useMDXComponent } from 'next-contentlayer/hooks';
import { DiscordAPITypesLink } from './DiscordAPITypesLink';
import { H1 } from './H1';
import { H2 } from './H2';
import { H3 } from './H3';
@@ -9,7 +10,7 @@ import { H4 } from './H4';
import { DocsLink } from '~/components/DocsLink';
import { ResultingCode } from '~/components/ResultingCode';
export function Mdx({ code }: { code: string }) {
export function Mdx({ code }: { readonly code: string }) {
const Component = useMDXComponent(code);
return (
@@ -20,6 +21,7 @@ export function Mdx({ code }: { code: string }) {
DiscordMessages,
DiscordMessage,
DiscordMessageEmbed,
DiscordAPITypesLink,
DocsLink,
ResultingCode,
h1: H1,

View File

@@ -5,7 +5,7 @@ const LINK_HEIGHT = 30;
const INDICATOR_SIZE = 10;
const INDICATOR_OFFSET = (LINK_HEIGHT - INDICATOR_SIZE) / 2;
export function Outline({ headings }: { headings: any[] }) {
export function Outline({ headings }: { readonly headings: any[] }) {
// eslint-disable-next-line react/hook-use-state
const [active /* setActive */] = useState(0);

View File

@@ -1,4 +1,12 @@
export function PageButton({ url, title, direction }: { direction: 'next' | 'prev'; title: string; url: string }) {
export function PageButton({
url,
title,
direction,
}: {
readonly direction: 'next' | 'prev';
readonly title: string;
readonly url: string;
}) {
return (
<a
className="flex flex-row flex-col transform-gpu cursor-pointer select-none appearance-none place-items-center gap-2 rounded bg-light-600 px-4 py-3 leading-none no-underline outline-none active:translate-y-px active:bg-light-800 dark:bg-dark-600 hover:bg-light-700 focus:ring focus:ring-width-2 focus:ring-blurple dark:active:bg-dark-400 dark:hover:bg-dark-500"

View File

@@ -34,7 +34,7 @@ export function Sidebar() {
<div className="flex flex-col gap-3 p-3">
{Object.keys(itemsByCategory).map((category, idx) => (
<Section
buttonClassName="bg-light-600 hover:bg-light-700 active:bg-light-800 dark:bg-dark-400 dark:hover:bg-dark-300 dark:active:bg-dark-400 focus:ring-width-2 focus:ring-blurple rounded p-3 outline-none focus:ring"
buttonClassName="bg-light-600 hover:bg-light-700 active:bg-light-800 dark:bg-dark-400 dark:hover:bg-dark-300 dark:active:bg-dark-400 focus:ring-width-2 focus:ring-blurple rounded p-3 outline-none focus:ring z-10"
key={`${category}-${idx}`}
title={category}
>

View File

@@ -53,6 +53,7 @@ At a minimum, the definition of a slash command must have a name and a descripti
<CH.Code>
```js
/** @type {import('discord.js').RESTPostAPIApplicationCommandsJSONBody} */
export const data = {
name: 'ping',
description: 'Replies with Pong!',
@@ -68,6 +69,7 @@ The simplest way to acknowledge and respond to an interaction is the _`interacti
<CH.Code>
```js
/** @param {import('discord.js').CommandInteraction} interaction */
export async function execute(interaction) {
await interaction.reply('Pong!');
}
@@ -75,6 +77,14 @@ export async function execute(interaction) {
</CH.Code>
<Alert title="@type and @param tags" type="info">
[`@type`](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#type) and
[`@param`](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#param-and-returns) tags allow you
to annotate your code with type information. The tags are not required for your code to run but provide autocomplete
and type information for fields and parameters, which can majorly improve your developer experience when working with
them.
</Alert>
Put these two together by creating a `commands/ping.js` file for your first command. Inside this file, you're going to define and export two items.
- The `data` property, which will provide the command definition shown above for registering to Discord.
@@ -85,11 +95,13 @@ The _`export`_ keyword ensures these values can be imported and read by other fi
<CH.Code>
```js commands/ping.js
/** @type {import('discord.js').RESTPostAPIApplicationCommandsJSONBody} */
export const data = {
name: 'ping',
description: 'Replies with Pong!',
};
/** @param {import('discord.js').CommandInteraction} interaction */
export async function execute(interaction) {
await interaction.reply('Pong!');
}
@@ -109,11 +121,13 @@ That's it for your basic ping command. Below are examples of two more commands w
<CH.Code>
```js commands/user.js
/** @type {import('discord.js').RESTPostAPIApplicationCommandsJSONBody} */
export const data = {
name: 'user',
description: 'Provides information about the user.',
};
/** @param {import('discord.js').CommandInteraction} interaction */
export async function execute(interaction) {
// interaction.user is the object representing the User who ran the command
// interaction.member is the GuildMember object, which represents the user in the specific guild
@@ -124,11 +138,13 @@ export async function execute(interaction) {
```
```js commands/server.js
/** @type {import('discord.js').RESTPostAPIApplicationCommandsJSONBody} */
export const data = {
name: 'server',
description: 'Provides information about the server.',
};
/** @param {import('discord.js').CommandInteraction} interaction */
export async function execute(interaction) {
// interaction.guild is the object representing the Guild in which the command was run
await interaction.reply(`This server is ${interaction.guild.name} and has

View File

@@ -162,4 +162,4 @@ client.on(Events.GuildAuditLogEntryCreate, async (auditLog) => {
</CH.Code>
If you want to check who banned a user, it's the same example as above except the _`action`_ should be _`AuditLogEvent.MemberBanAdd`_. You can check the rest of the types over at the [discord-api-types documentation](https://discord-api-types.dev/api/discord-api-types-v10/enum/AuditLogEvent).
If you want to check who banned a user, it's the same example as above except the _`action`_ should be <DiscordAPITypesLink type="enum" parent="AuditLogEvent" symbol="MemberBanAdd" />. You can check the rest of the possible actions on this page.

View File

@@ -0,0 +1,223 @@
---
title: Collectors
category: Popular topics
---
# Collectors
## Message collectors
{/* prettier-ignore */}
<DocsLink type="class" parent="Collector">Collectors</DocsLink> are useful to enable your bot to obtain _additional_ input after the first command was sent. An example would be initiating a quiz, where the bot will "await" a correct response from somebody.
### Basic message collector
Let's take a look at a basic message collector:
<CH.Code>
```js
const collectorFilter = (message) => message.content.includes('discord');
const collector = interaction.channel.createMessageCollector({ filter: collectorFilter, time: 15_000 });
collector.on('collect', (message) => {
console.log(`Collected ${message.content}`);
});
collector.on('end', (collected) => {
console.log(`Collected ${collected.size} messages`);
});
```
</CH.Code>
You can provide a _`filter`_ key to the object parameter of <DocsLink type="class" parent="TextChannel" symbol="createMessageCollector" brackets />. The value to this key should be a function that returns a boolean value to indicate if this message should be collected or not. To check for multiple conditions in your filter you can connect them using [logical operators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#logical_operators). If you don't provide a filter all messages in the channel the collector was started on will be collected.
Note that the above example uses [implicit return](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#function_body) for the filter function and passes it to the options object using the [object property shorthand](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#property_definitions) notation.
If a message passes through the filter, it will trigger the <DocsLink type="class" parent="Collector" symbol="e-collect" /> event for the _`collector`_ you've created. This message is then passed into the event listener as _`collected`_ and the provided function is executed. In the above example, you simply log the message. Once the collector finishes collecting based on the provided end conditions the <DocsLink type="class" parent="Collector" symbol="e-end" /> event emits.
You can control when a collector ends by supplying additional option keys when creating a collector:
- _`time`_: Amount of time in milliseconds the collector should run for
- _`max`_: Number of messages to successfully pass the filter
- _`maxProcessed`_: Number of messages encountered (no matter the filter result)
The benefit of using an event-based collector over _`awaitMessages()`_ (its promise-based counterpart) is that you can do something directly after each message is collected, rather than just after the collector ended. You can also stop the collector manually by calling <DocsLink type="class" parent="Collector" symbol="stop" brackets />.
### Await messages
Using <DocsLink type="class" parent="TextChannel" symbol="awaitMessages" brackets /> can be easier if you understand [Promises](../additional-info/understanding-async-await), and it allows you to have cleaner code overall. It is essentially identical to <DocsLink type="class" parent="TextChannel" symbol="createMessageCollector" brackets />, except promisified. However, the drawback of using this method is that you cannot do things before the Promise is resolved or rejected, either by an error or completion. However, it should do for most purposes, such as awaiting the correct response in a quiz. Instead of taking their example, let's set up a basic quiz command using the _`.awaitMessages()`_ feature.
First, you'll need some questions and answers to choose from, so here's a basic set:
<CH.Code>
```json
[
{
"question": "What color is the sky?",
"answers": ["blue"]
},
{
"question": "How many letters are there in the alphabet?",
"answers": ["26", "twenty-six", "twenty six", "twentysix"]
}
]
```
</CH.Code>
The provided set allows for responder error with an array of answers permitted. Ideally, it would be best to place this in a JSON file, which you can call _`quiz.json`_ for simplicity.
<CH.Code>
```js
import quiz from './quiz.json' assert { type: 'json' };
// ...
const item = quiz[Math.floor(Math.random() * quiz.length)];
const collectorFilter = (response) => {
return item.answers.some((answer) => answer.toLowerCase() === response.content.toLowerCase());
};
await interaction.reply({ content: item.question });
try {
const collected = await interaction.channel.awaitMessages({
filter: collectorFilter,
max: 1,
time: 30_000,
errors: ['time'],
});
await interaction.followUp(`${collected.first().author} got the correct answer!`);
} catch {
await interaction.followUp('Looks like nobody got the answer this time.');
}
```
</CH.Code>
<Alert title="Tip" type="info">
If you don't understand how _`.some()`_ works, you can read about it in more detail
[here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some).
</Alert>
In this filter, you iterate through the answers to find what you want. You would like to ignore the case because simple typos can happen, so you convert each answer to its lowercase form and check if it's equal to the response in lowercase form as well. In the options section, you only want to allow one answer to pass through, hence the _`max: 1`_ setting.
The filter looks for messages that match one of the answers in the array of possible answers to pass through the collector. The _`max`_ option (the second parameter) specifies that only a maximum of one message can go through the filter successfully before the Promise successfully resolves. The _`errors`_ section specifies that time will cause it to error out, which will cause the Promise to reject if one correct answer is not received within the time limit of one minute. As you can see, there is no _`collect`_ event, so you are limited in that regard.
## Reaction collectors
### Basic reaction collector
These work quite similarly to message collectors, except that you apply them on a message rather than a channel. This example uses the <DocsLink type="class" parent="Message" symbol="createReactionCollector" brackets /> method. The filter will check for the 👍 emojiin the default skin tone specifically, so be wary of that. It will also check that the person who reacted shares the same id as the author of the original message that the collector was assigned to.
```js
const collectorFilter = (reaction, user) => {
return reaction.emoji.name === '👍' && user.id === message.author.id;
};
const collector = message.createReactionCollector({ filter: collectorFilter, time: 15_000 });
collector.on('collect', (reaction, user) => {
console.log(`Collected ${reaction.emoji.name} from ${user.tag}`);
});
collector.on('end', (collected) => {
console.log(`Collected ${collected.size} items`);
});
```
### Await reactions
<DocsLink type="class" parent="Message" symbol="awaitReactions" brackets /> works almost the same as a reaction collector,
except it is Promise-based. The same differences apply as with channel collectors.
```js
const collectorFilter = (reaction, user) => {
return reaction.emoji.name === '👍' && user.id === message.author.id;
};
try {
const collected = await message.awaitReactions({ filter: collectorFilter, max: 1, time: 60_000, errors: ['time'] });
console.log(collected.size);
} catch (collected) {
console.log(`After a minute, the user did not react.`);
}
```
## Interaction collectors
The third type of collector allows you to collect interactions; such as when users activate a slash command or click on a button in a message.
### Basic message component collector
Collecting interactions from message components works similarly to reaction collectors. In the following example, you will check that the interaction came from a button, and that the user clicking the button is the same user that initiated the command.
One important difference to note with interaction collectors is that Discord expects a response to _all_ interactions within 3 seconds - even ones that you don't want to collect. For this reason, you may wish to _`.deferUpdate()`_ all interactions in your filter, or not use a filter at all and handle this behavior in the _`collect`_ event.
```js
import { ComponentType } from 'discord.js';
const collector = message.createMessageComponentCollector({ componentType: ComponentType.Button, time: 15_000 });
collector.on('collect', (i) => {
if (i.user.id === interaction.user.id) {
await i.reply(`${i.user.id} clicked on the ${i.customId} button.`);
} else {
await i.reply({ content: `These buttons aren't for you!`, ephemeral: true });
}
});
collector.on('end', (collected) => {
console.log(`Collected ${collected.size} interactions.`);
});
```
### Await message component
As before, this works similarly to the message component collector, except it is Promise-based.
Unlike other Promise-based collectors, this method will only ever collect one interaction that passes the filter. If no interactions are collected before the time runs out, the Promise will reject. This behavior aligns with Discord's requirement that actions should immediately receive a response. In this example, you will use _`.deferUpdate()`_ on all interactions in the filter.
```js
import { ComponentType } from 'discord.js';
const collectorFilter = (i) => {
i.deferUpdate();
return i.user.id === interaction.user.id;
};
try {
const interaction = await message.awaitMessageComponent({
filter: collectorFilter,
componentType: ComponentType.StringSelect,
time: 60_000,
});
await interaction.editReply(`You selected ${interaction.values.join(', ')}!`);
} catch (error) {
console.log('No interactions were collected.');
}
```
### Await modal submit
If you want to wait for the submission of a modal within the context of another command or button execution, you may find the promisified collector <DocsLink type="class" parent="CommandInteraction" symbol="awaitModalSubmit" brackets /> useful.
As Discord does not inform you if the user dismisses the modal, supplying a maximum _`time`_ to wait for is crucial:
```js
try {
const interaction = await initialInteraction.awaitModalSubmit({ time: 60_000, filter });
await interaction.editReply('Thank you for your submission!');
} catch (error) {
console.log('No modal submit interaction was collected');
}
```
For more information on working with modals, see the [modals section of this guide](../interactions/modals).

View File

@@ -0,0 +1,95 @@
---
title: Formatters
category: Popular topics
---
# Formatters
discord.js provides the <DocsLink package="formatters" /> package which contains a variety of utilities you can use when writing your Discord bot.
## Basic Markdown
These functions format strings into all the different markdown styles supported by Discord.
<CH.Code>
```js
import { bold, italic, strikethrough, underscore, spoiler, quote, blockQuote } from 'discord.js';
const string = 'Hello!';
const boldString = bold(string);
const italicString = italic(string);
const strikethroughString = strikethrough(string);
const underscoreString = underscore(string);
const spoilerString = spoiler(string);
const quoteString = quote(string);
const blockquoteString = blockQuote(string);
```
</CH.Code>
## Links
There are also two functions to format hyperlinks. _`hyperlink()`_ will format the URL into a masked markdown link, and _`hideLinkEmbed()`_ will wrap the URL in _`<>`_, preventing it from embedding.
<CH.Code>
```js
import { hyperlink, hideLinkEmbed } from 'discord.js';
const url = 'https://discord.js.org/';
const link = hyperlink('discord.js', url);
const hiddenEmbed = hideLinkEmbed(url);
```
</CH.Code>
## Code blocks
You can use _`inlineCode()`_ and _`codeBlock()`_ to turn a string into an inline code block or a regular code block with or without syntax highlighting.
<CH.Code>
```js
import { inlineCode, codeBlock } from 'discord.js';
const jsString = 'const value = true;';
const inline = inlineCode(jsString);
const codeblock = codeBlock(jsString);
const highlighted = codeBlock('js', jsString);
```
</CH.Code>
## Timestamps
With _`time()`_, you can format Unix timestamps and dates into a Discord time string.
<CH.Code>
```js
import { time, TimestampStyles } from 'discord.js';
const date = new Date();
const timeString = time(date);
const relative = time(date, TimestampStyles.RelativeTime);
```
</CH.Code>
## Mentions
_`userMention()`_, _`channelMention()`_, and _`roleMention()`_ all exist to format Snowflakes into mentions.
<CH.Code>
```js
import { channelMention, roleMention, userMention } from 'discord.js';
const id = '123456789012345678';
const channel = channelMention(id);
const role = roleMention(id);
const user = userMention(id);
```
</CH.Code>

View File

@@ -0,0 +1,227 @@
---
title: Webhooks
category: Popular topics
---
# Webhooks
Webhooks can send messages to a text channel without having to log in as a bot. They can also fetch, edit, and delete their own messages. There are a variety of methods in discord.js to interact with webhooks. In this section, you will learn how to create, fetch, edit, and use webhooks.
## What is a webhook
Webhooks are a utility used to send messages to text channels without needing a Discord application. Webhooks are useful for allowing something to send messages without requiring a Discord application. You can also directly edit or delete messages you sent through the webhook. There are two structures to make use of this functionality: <DocsLink type="class" parent="Webhook" /> and <DocsLink type="class" parent="WebhookClient" />. _`WebhookClient`_ is an extended version of a _`Webhook`_, which allows you to send messages through it without needing a bot client.
<Alert title="Tip" type="info">
If you would like to read about using webhooks through the API without discord.js, you can read about them
[here](https://discord.com/developers/docs/resources/webhook).
</Alert>
## Detecting webhook messages
Bots receive webhook messages in a text channel as usual. You can detect if a webhook sent the message by checking if the _`Message.webhookId`_ is not _`null`_. In this example, we return if a webhook sent the message.
<CH.Code>
```js
if (message.webhookId) return;
```
</CH.Code>
If you would like to get the webhook object that sent the message, you can use <DocsLink type="class" parent="Message" symbol="fetchWebhook" brackets />.
## Fetching webhooks
<Alert title="Tip" type="info">
Webhook fetching will always make use of collections and promises. If you do not understand either concept, revise
them, and then come back to this section. You can read about collections [here](../additional-info/collections), and
promises [here](../additional-info/understanding-async-await) and
[here](https://developer.mozilla.org/docs/Web/JavaScript/Guide/Using_promises).
</Alert>
### Fetching all webhooks of a guild
If you would like to get all webhooks of a guild, you can use the <DocsLink type="class" parent="Guild" symbol="fetchWebhooks" brackets /> method. This will return a promise which will resolve into a collection of webhooks.
### Fetching webhooks of a channel
Webhooks belonging to a channel can be fetched using the <DocsLink type="class" parent="TextChannel" symbol="fetchWebhooks" brackets /> method. This will return a promise which will resolve into a collection of webhooks. A collection will be returned even if the channel contains a single webhook. If you are certain the channel contains a single webhook, you can use the <DocsLink package="collection" type="Class" parent="Collection" symbol="first" brackets /> method on the collection to get the webhook.
### Fetching a single webhook
#### Using client
You can fetch a specific webhook using its _`id`_ with the <DocsLink type="class" parent="Client" symbol="fetchWebhook" brackets /> method. You can obtain the webhook id by looking at its URL: the number after _`https://discord.com/api/webhooks/`_ is the _`id`_ and the part after that is the _`token`_.
#### Using the WebhookClient constructor
If you are not using a bot client, you can get a webhook by creating a new instance of _`WebhookClient`_ and passing the _`id`_ and _`token`_ into the constructor. These credentials do not require you to have a bot application, but it also offers limited information instead of fetching it using an authorized client.
<CH.Code>
```js
const webhookClient = new WebhookClient({ id: 'id', token: 'token' });
```
</CH.Code>
You can also pass in just a _`url`_:
<CH.Code>
```js
const webhookClient = new WebhookClient({ url: 'https://discord.com/api/webhooks/id/token' });
```
</CH.Code>
## Creating webhooks
### Creating webhooks through server settings
You can create webhooks directly through the Discord client. Go to Server Settings, and you will see an _`Integrations`_ tab.
![Integrations tab](/assets/integrations-tab.png)
If you already have created a webhook, the webhooks tab will look like this; you will need to click the _`View Webhooks`_ button.
![Integrations tab](/assets/integrations-view-tab.png)
Once you are there, click on the _`Create Webhook`_ / _`New Webhook`_ button; this will create a webhook. From here, you can edit the channel, the name, and the avatar. Copy the link, the first part is the id, and the second is the token.
![Creating a Webhook](/assets/webhook.png)
### Creating webhooks with discord.js
Webhooks can be created with the <DocsLink type="class" parent="TextChannel" symbol="createWebhook" brackets /> method.
<CH.Code>
```js
channel
.createWebhook({ name: 'Username', avatar: 'https://guide.discordjs.dev/assets/discordjs.png' })
.then((webhook) => console.log(`Created webhook ${webhook}`))
.catch(console.error);
```
</CH.Code>
## Editing webhooks
You can edit Webhooks and WebhookClients to change their name, avatar, and channel using <DocsLink type="class" parent="Webhook" symbol="edit" brackets />.
<CH.Code>
```js
webhook
.edit({ name: 'Username', avatar: 'https://guide.discordjs.dev/assets/discordjs.png', channel: '123456789012345678' })
.then((webhook) => console.log(`Edited webhook ${webhook}`))
.catch(console.error);
```
</CH.Code>
## Using webhooks
Webhooks can send messages to text channels, as well as fetch, edit, and delete their own. These methods are the same for both _`Webhook`_ and _`WebhookClient`_.
### Sending messages
Webhooks, like bots, can send up to 10 embeds per message. They can also send attachments and normal content. The <DocsLink type="class" parent="Webhook" symbol="send" brackets /> method is very similar to the method used for sending a message to a text channel. Webhooks can also choose how the username and avatar will appear when they send the message.
Example using a _`WebhookClient`_:
<CH.Code>
```js
import { EmbedBuilder, WebhookClient } from 'discord.js';
import config from './config.json' assert { type: 'json' };
const { webhookId, webhookToken } = config;
const webhookClient = new WebhookClient({ id: webhookId, token: webhookToken });
const embed = new EmbedBuilder().setTitle('Some Title').setColor(0x00ffff);
await webhookClient.send({
content: 'Webhook test',
username: 'some-username',
avatarURL: 'https://guide.discordjs.dev/assets/discordjs.png',
embeds: [embed],
});
```
</CH.Code>
Try to find a webhook your bot knows the token for. This makes sure your bot can execute the webhook later on.
<CH.Code>
```js
import { Client, EmbedBuilder, Events, GatewayIntentBits } from 'discord.js';
import config from './config.json' assert { type: 'json' };
const { token } = config;
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
const embed = new EmbedBuilder().setTitle('Some Title').setColor(0x00ffff);
client.once(Events.ClientReady, async () => {
const channel = client.channels.cache.get('123456789012345678');
try {
const webhooks = await channel.fetchWebhooks();
const webhook = webhooks.find((wh) => wh.token);
if (!webhook) return console.log('No webhook was found that I can use!');
await webhook.send({
content: 'Webhook test',
username: 'some-username',
avatarURL: 'https://guide.discordjs.dev/assets/discordjs.png',
embeds: [embed],
});
} catch (error) {
console.error('Error trying to send a message: ', error);
}
});
client.login(token);
```
</CH.Code>
### Fetching messages
You can use <DocsLink type="class" parent="Webhook" symbol="fetchMessage" brackets /> to fetch messages previously sent by the Webhook.
<CH.Code>
```js
const message = await webhookClient.fetchMessage('123456789012345678');
```
</CH.Code>
### Editing messages
You can use <DocsLink type="class" parent="Webhook" symbol="editMessage" brackets /> to edit messages previously sent by the Webhook.
<CH.Code>
```js
const message = await webhook.editMessage('123456789012345678', {
content: 'Edited!',
embeds: [embed],
});
```
</CH.Code>
### Deleting messages
You can use <DocsLink type="class" parent="Webhook" symbol="deleteMessage" brackets /> to delete messages previously sent by the webhook.
<CH.Code>
```js
await webhookClient.deleteMessage('123456789012345678');
```
</CH.Code>

View File

@@ -41,7 +41,7 @@ discord.js v14 makes the switch to Discord API v10!
Any areas that used to accept a _`string`_ or _`number`_ type for an enum parameter will now only accept a _`number`_.
In addition, the old enums exported by discord.js v13 and lower are replaced with new enums from [discord-api-types](https://discord-api-types.dev/api/discord-api-types-v10).
In addition, the old enums exported by discord.js v13 and lower are replaced with new enums from <DiscordAPITypesLink />.
#### New enum differences
@@ -121,7 +121,7 @@ Areas like _`Client`_ initialization, JSON slash commands and JSON message compo
#### Channels
Some channel type guard methods that narrowed to one channel type have been removed. Instead compare the _`type`_ property against a [ChannelType](https://discord-api-types.dev/api/discord-api-types-v10/enum/ChannelType) enum member to narrow channels.
Some channel type guard methods that narrowed to one channel type have been removed. Instead compare the _`type`_ property against a <DiscordAPITypesLink type="enum" parent="ChannelType" /> enum member to narrow channels.
<CH.Code>
@@ -361,7 +361,7 @@ _`IntegrationApplication#summary`_ has been removed as it is no longer supported
### Interaction
Whenever an interaction is replied to and one fetches the reply, it could possibly give an [APIMessage](https://discord-api-types.dev/api/discord-api-types-v10/interface/APIMessage) if the guild was not cached. However, interaction replies now always return a discord.js <DocsLink type="class" parent="Message"/> object with _`fetchReply`_ as _`true`_.
Whenever an interaction is replied to and one fetches the reply, it could possibly give an <DiscordAPITypesLink type="interface" parent="APIMessage" /> if the guild was not cached. However, interaction replies now always return a discord.js <DocsLink type="class" parent="Message"/> object with _`fetchReply`_ as _`true`_.
The base interaction class is now <DocsLink type="class" parent="BaseInteraction"/>.
@@ -419,7 +419,7 @@ The base interaction class is now <DocsLink type="class" parent="BaseInteraction
### MessageManager
The second parameter of <DocsLink type="class" parent="MessageManager" symbol="fetch" brackets /> has been removed. The <DocsLink type="class" parent="BaseFetchOptions" /> the second parameter once was is now merged into the first parameter.
The second parameter of <DocsLink type="class" parent="MessageManager" symbol="fetch" brackets /> has been removed. The <DocsLink type="typedef" parent="BaseFetchOptions" /> the second parameter once was is now merged into the first parameter.
<CH.Code>
@@ -490,6 +490,8 @@ In addition to this, there is now a new partial: _`Partials.ThreadMember`_.
The thread permissions _`USE_PUBLIC_THREADS`_ and _`USE_PRIVATE_THREADS`_ have been removed as they are deprecated in the API. Use _`CREATE_PUBLIC_THREADS`_ and _`CREATE_PRIVATE_THREADS`_ respectively.
_`ManageEmojisAndStickers`_ has been deprecated due to API changes. Its replacement is _`ManageGuildExpressions`_.[^7]
### PermissionOverwritesManager
Overwrites are now keyed by the _`PascalCase`_ permission key rather than the _`SCREAMING_SNAKE_CASE`_ permission key.
@@ -647,6 +649,10 @@ The second parameter of <DocsLink type="class" parent="Webhook" symbol="fetchMes
NFSW commands are supported.
### Attachment
Added support for voice message metadata fields.
### AutocompleteInteraction
<DocsLink type="class" parent="AutocompleteInteraction" symbol="commandGuildId" /> has been added which is the id of the
@@ -684,7 +690,7 @@ Added support for role connection metadata.
A new <DocsLink type="class" parent="Collector" symbol="e-ignore"/> event has been added which is emitted whenever an element is not collected by the collector.
Component collector options now use the [ComponentType](https://discord-api-types.dev/api/discord-api-types-v10/enum/ComponentType) enum values:
Component collector options now use the <DiscordAPITypesLink type="enum" parent="ComponentType" /> enum values:
<CH.Code>
@@ -777,6 +783,8 @@ Added <DocsLink type="class" parent="MessageReaction" symbol="react" brackets />
Added support for role subscriptions.
Added support for _`Role#tags#guildConnections`_.
### StageChannel
Stage channels now allow messages to be sent in them, much like voice channels.
@@ -797,9 +805,14 @@ Added <DocsLink type="class" parent="Webhook" symbol="applicationId" />.
Added the _`threadName`_ property in <DocsLink type="typedef" parent="WebhookMessageCreateOptions"/> which allows a webhook to create a post in a forum channel.
### WebSocketManager
discord.js uses <DocsLink package="ws" /> internally.
[^1]: https://github.com/discordjs/discord.js/pull/7188
[^2]: https://github.com/discordjs/discord.js/pull/6492
[^3]: https://github.com/discordjs/discord.js/pull/7669
[^4]: https://github.com/discordjs/discord.js/issues/6546
[^5]: https://github.com/discordjs/discord.js/pull/8010
[^6]: https://github.com/discordjs/discord.js/issues/7091
[^7]: https://github.com/discord/discord-api-docs/pull/6017

View File

@@ -2,6 +2,8 @@ export const BASE_URL = 'https://discord.js.org/docs/packages' as const;
export const BASE_URL_LEGACY = 'https://old.discordjs.dev/#/docs/discord.js' as const;
export const BASE_URL_DISCORD_API_TYPES = 'https://discord-api-types.dev' as const;
export const DESCRIPTION = 'Imagine a guide... that explores the many possibilities for your discord.js bot.';
export const GITHUB_BASE_PAGES_PATH = 'https://github.com/discordjs/discord.js/tree/main/apps/guide/src/pages';
@@ -24,4 +26,14 @@ export const PACKAGES = [
/**
* The stable version of discord.js.
*/
export const VERSION = '14.9.0' as const;
export const VERSION = '14.11.0' as const;
/**
* The API version (for discord-api-types). This is prefixed with a "v".
*/
export const DISCORD_API_TYPES_VERSION = 'v10' as const;
/**
* The voice API version (for discord-api-types). This is prefixed with a "v".
*/
export const DISCORD_API_TYPES_VOICE_VERSION = 'v4' as const;

View File

@@ -22,13 +22,6 @@
"strictNullChecks": true,
"moduleResolution": "node"
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"next-env.d.ts",
"types.d.ts",
".next/types/**/*.ts",
".contentlayer/generated"
],
"include": ["src/**/*.ts", "src/**/*.tsx", "next-env.d.ts", ".next/types/**/*.ts", ".contentlayer/generated"],
"exclude": ["node_modules"]
}

View File

@@ -1 +0,0 @@
declare module '*.css';

View File

@@ -0,0 +1 @@
next-env.d.ts

View File

@@ -1,8 +1,8 @@
# Packages
node_modules/
node_modules
# Log files
logs/
logs
*.log
npm-debug.log*
@@ -16,19 +16,14 @@ pids
.env*.local
# Dist
dist/
typings/
.cache/
build/
.contentlayer
.next
public/searchIndex
src/assets/readme
src/styles/unocss.css
.next/
src/assets/readme/
static/
# Miscellaneous
.tmp/
coverage/
.vercel
public/searchIndex
.tmp
.vscode
lighthouse-results/
lighthouse-results

View File

@@ -1,16 +1,8 @@
# Autogenerated
CHANGELOG.md
.next
.turbo
dist/
docs/**/*
!docs/index.yml
!docs/README.md
coverage/
.cache
build/
src/styles/unocss.css
api/
.next/
.vercel/
.cache/
.vscode
coverage
public/searchIndex
src/assets/readme
src/styles/unocss.css
next-env.d.ts

View File

@@ -10,6 +10,7 @@
</p>
<p>
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
<a href="https://www.cloudflare.com"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-workers.png" alt="Cloudflare Workers" height="44" /></a>
</p>
</div>

View File

@@ -7,15 +7,15 @@
"test": "vitest run",
"test:lighthouse": "lighthouse http://localhost:3000 --output-path=./lighthouse-results",
"build:copy_readme": "cpy '../../packages/*/README.md' 'src/assets/readme' --rename='home-{{basename}}'",
"build:local": "yarn run --top-level docs --force && yarn build:copy_readme && cross-env-shell NEXT_PUBLIC_LOCAL_DEV=true yarn build:prod",
"build:prod": "yarn workspaces foreach -ptR run build && yarn build:copy_readme && yarn build:css && yarn build:next",
"build:local": "cross-env NEXT_PUBLIC_LOCAL_DEV=true yarn build:prod",
"build:prod": "yarn build:copy_readme && yarn build:css && yarn build:next",
"build:next": "next build",
"build:css": "yarn generate:css",
"build:search_indices": "yarn node scripts/generateAllIndices.js",
"build:analyze": "yarn run --top-level docs --force && cross-env-shell ANALYZE=true NEXT_PUBLIC_LOCAL_DEV=true yarn build:prod",
"build:analyze": "turbo run docs && cross-env ANALYZE=true NEXT_PUBLIC_LOCAL_DEV=true yarn build:prod",
"preview": "next start",
"dev": "yarn run --top-level docs && concurrently 'yarn dev:css' 'yarn dev:next'",
"dev:next": "yarn workspaces foreach -ptR run build && next dev",
"dev": "concurrently 'yarn dev:css' 'yarn dev:next'",
"dev:next": "next dev",
"dev:css": "yarn generate:css --watch",
"generate:css": "unocss 'src/**/*.tsx' '../../packages/ui/src/lib/components/**/*.tsx' --out-file ./src/styles/unocss.css --config ../../unocss.config.ts",
"lint": "prettier --check . && cross-env TIMING=1 eslint src --ext .mjs,.js,.cjs,.ts,.tsx --format=pretty",
@@ -49,59 +49,56 @@
"@discordjs/api-extractor-utils": "workspace:^",
"@discordjs/scripts": "workspace:^",
"@discordjs/ui": "workspace:^",
"@microsoft/api-extractor-model": "7.26.6",
"@microsoft/api-extractor-model": "7.27.5",
"@microsoft/tsdoc": "0.14.2",
"@planetscale/database": "1.7.0",
"@react-icons/all-files": "^4.1.0",
"@vercel/analytics": "^1.0.0",
"@vercel/edge-config": "^0.1.8",
"@vercel/og": "^0.5.4",
"@vscode/codicons": "^0.0.32",
"@vercel/analytics": "^1.0.1",
"@vercel/edge-config": "^0.2.1",
"@vercel/og": "^0.5.9",
"ariakit": "^2.0.0-next.44",
"bright": "^0.8.2",
"class-variance-authority": "^0.6.0",
"bright": "^0.8.4",
"class-variance-authority": "^0.7.0",
"cmdk": "^0.2.0",
"meilisearch": "^0.32.3",
"next": "^13.3.4",
"meilisearch": "^0.33.0",
"next": "^13.4.12",
"next-mdx-remote": "^4.4.1",
"next-themes": "^0.2.1",
"react": "^18.2.0",
"react-custom-scrollbars-2": "^4.5.0",
"react-dom": "^18.2.0",
"react-use": "^17.4.0",
"rehype-ignore": "^1.0.5",
"rehype-raw": "^6.1.1",
"rehype-slug": "^5.1.0",
"remark-gfm": "^3.0.1",
"server-only": "^0.0.1",
"sharp": "^0.32.1",
"swr": "^2.1.5"
"sharp": "^0.32.4",
"swr": "^2.2.0"
},
"devDependencies": {
"@next/bundle-analyzer": "^13.3.4",
"@next/bundle-analyzer": "^13.4.12",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@types/node": "18.16.3",
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.1",
"@unocss/cli": "^0.51.8",
"@unocss/eslint-config": "^0.51.8",
"@unocss/reset": "^0.51.8",
"@vitejs/plugin-react": "^4.0.0",
"@vitest/coverage-c8": "^0.30.1",
"concurrently": "^8.0.1",
"cpy-cli": "^4.2.0",
"@types/node": "18.17.1",
"@types/react": "^18.2.17",
"@types/react-dom": "^18.2.7",
"@unocss/cli": "^0.54.0",
"@unocss/eslint-config": "^0.54.0",
"@unocss/reset": "^0.54.0",
"@vitejs/plugin-react": "^4.0.3",
"@vitest/coverage-c8": "^0.33.0",
"concurrently": "^8.2.0",
"cpy-cli": "^5.0.0",
"cross-env": "^7.0.3",
"eslint": "^8.39.0",
"eslint-config-neon": "^0.1.42",
"eslint": "^8.46.0",
"eslint-config-neon": "^0.1.47",
"eslint-formatter-pretty": "^5.0.0",
"happy-dom": "^9.10.1",
"lighthouse": "^10.1.1",
"happy-dom": "^10.5.2",
"lighthouse": "^10.4.0",
"prettier": "^2.8.8",
"typescript": "^5.0.4",
"unocss": "^0.51.8",
"vercel": "^29.0.3",
"vitest": "^0.29.8"
"turbo": "^1.10.12",
"typescript": "^5.1.6",
"vercel": "^31.2.0",
"vitest": "^0.33.0"
},
"engines": {
"node": ">=18.13.0"

View File

@@ -73,7 +73,7 @@ export const metadata: Metadata = {
},
};
export default function GlobalError({ error }: { error: Error }) {
export default function GlobalError({ error }: { readonly error: Error }) {
console.error(error);
return (

View File

@@ -1,29 +0,0 @@
import { get } from '@vercel/edge-config';
import { NextResponse } from 'next/server';
export const runtime = 'edge';
export async function GET() {
try {
const url = await get<string>('DISCORD_WEBHOOK_URL');
const imageUrl = await get<string>('IT_IS_WEDNESDAY_MY_DUDES');
if (url && imageUrl) {
await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
username: 'It is wednesday, my dudes',
embeds: [
{
image: {
url: imageUrl,
},
},
],
}),
});
}
} catch {}
return NextResponse.json({ message: 'It is wednesday, my dudes' });
}

View File

@@ -1,5 +1,3 @@
import 'server-only';
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
import { connect } from '@planetscale/database';

View File

@@ -116,7 +116,7 @@ export async function generateStaticParams({ params: { package: packageName, ver
}));
}
function Member({ member }: { member?: ApiItem }) {
function Member({ member }: { readonly member?: ApiItem }) {
switch (member?.kind) {
case 'Class':
return <Class clazz={member as ApiClass} />;

View File

@@ -1,6 +1,6 @@
'use client';
export default function Error({ error }: { error: Error }) {
export default function Error({ error }: { readonly error: Error }) {
console.error(error);
return (

View File

@@ -2,7 +2,6 @@ import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
import type { SerializeOptions } from 'next-mdx-remote/dist/types';
import { MDXRemote } from 'next-mdx-remote/rsc';
import rehypeIgnore from 'rehype-ignore';
import rehypeRaw from 'rehype-raw';
import rehypeSlug from 'rehype-slug';
import remarkGfm from 'remark-gfm';
@@ -17,7 +16,7 @@ const mdxOptions = {
mdxOptions: {
remarkPlugins: [remarkGfm],
remarkRehypeOptions: { allowDangerousHtml: true },
rehypePlugins: [rehypeRaw, rehypeIgnore, rehypeSlug],
rehypePlugins: [rehypeRaw, rehypeSlug],
format: 'md',
},
} satisfies SerializeOptions;
@@ -28,7 +27,7 @@ export default async function Page({ params }: { params: VersionRouteParams }) {
return (
<div className="max-w-none prose">
{/* @ts-expect-error async component */}
{/* @ts-expect-error SyntaxHighlighter is assignable */}
<MDXRemote components={{ pre: SyntaxHighlighter }} options={mdxOptions} source={readmeSource} />
</div>
);

View File

@@ -36,7 +36,7 @@ export default async function Page({ params }: { params: { package: string } })
href={`/docs/packages/${params.package}/${version}`}
key={`${version}-${idx}`}
>
<div className="flex flex-row place-content-between place-items-center gap-4">
<div className="flex grow flex-row place-content-between place-items-center gap-4">
<div className="flex flex-row place-content-between place-items-center gap-4">
<VscVersions size={25} />
<h2 className="font-semibold">{version}</h2>

View File

@@ -13,16 +13,11 @@ export default function Page() {
<div className="mx-auto min-h-screen min-w-xs flex flex-col gap-8 px-4 py-6 sm:w-md lg:px-6 lg:py-6">
<h1 className="text-2xl font-semibold">Select a package:</h1>
<div className="flex flex-col gap-4">
<a
className="h-11 flex transform-gpu cursor-pointer select-none appearance-none place-content-between border border-neutral-300 rounded bg-white p-4 text-base font-semibold leading-none text-black outline-none active:translate-y-px dark:border-dark-100 active:bg-neutral-200 dark:bg-dark-400 hover:bg-neutral-100 dark:text-white focus:ring focus:ring-width-2 focus:ring-blurple dark:active:bg-dark-200 dark:hover:bg-dark-300"
href="https://old.discordjs.dev/#/docs/discord.js"
>
<a className={buttonVariants({ variant: 'secondary' })} href="https://old.discordjs.dev/#/docs/discord.js">
<div className="flex grow flex-row place-content-between place-items-center gap-4">
<div className="flex grow flex-row place-content-between place-items-center gap-4">
<div className="flex flex-row place-content-between place-items-center gap-4">
<VscPackage size={25} />
<h2 className="font-semibold">discord.js</h2>
</div>
<div className="flex flex-row place-content-between place-items-center gap-4">
<VscPackage size={25} />
<h2 className="font-semibold">discord.js</h2>
</div>
<VscArrowRight size={20} />
</div>
@@ -34,31 +29,27 @@ export default function Page() {
key={`${pkg}-${idx}`}
>
<div className="flex grow flex-row place-content-between place-items-center gap-4">
<div className="flex grow flex-row place-content-between place-items-center gap-4">
<div className="flex flex-row place-content-between place-items-center gap-4">
<VscPackage size={25} />
<h2 className="font-semibold">{pkg}</h2>
</div>
{/* <Link href={`/docs/packages/${pkg}`}>
<div
className="bg-blurple focus:ring-width-2 flex h-6 transform-gpu cursor-pointer select-none appearance-none flex-row place-content-center place-items-center rounded border-0 px-2 text-xs font-semibold leading-none text-white outline-none focus:ring focus:ring-white active:translate-y-px"
role="link"
>
Select version
</div>
</Link> */}
<div className="flex flex-row place-content-between place-items-center gap-4">
<VscPackage size={25} />
<h2 className="font-semibold">{pkg}</h2>
</div>
{/* <Link href={`/docs/packages/${pkg}`}>
<div
className="bg-blurple focus:ring-width-2 flex h-6 transform-gpu cursor-pointer select-none appearance-none flex-row place-content-center place-items-center rounded border-0 px-2 text-xs font-semibold leading-none text-white outline-none focus:ring focus:ring-white active:translate-y-px"
role="link"
>
Select version
</div>
</Link> */}
<VscArrowRight size={20} />
</div>
</Link>
))}
<a className={buttonVariants({ variant: 'secondary' })} href="https://discord-api-types.dev/">
<div className="flex grow flex-row place-content-between place-items-center gap-4">
<div className="flex grow flex-row place-content-between place-items-center gap-4">
<div className="flex flex-row place-content-between place-items-center gap-4">
<VscPackage size={25} />
<h2 className="font-semibold">discord-api-types</h2>
</div>
<div className="flex flex-row place-content-between place-items-center gap-4">
<VscPackage size={25} />
<h2 className="font-semibold">discord-api-types</h2>
</div>
<FiExternalLink size={20} />
</div>

View File

@@ -1,6 +1,6 @@
'use client';
export default function Error({ error }: { error: Error }) {
export default function Error({ error }: { readonly error: Error }) {
console.error(error);
return (

View File

@@ -2,6 +2,7 @@ import { FiExternalLink } from '@react-icons/all-files/fi/FiExternalLink';
import Image from 'next/image';
import Link from 'next/link';
import vercelLogo from '~/assets/powered-by-vercel.svg';
import workersLogo from '~/assets/powered-by-workers.png';
import { Banner } from '~/components/Banner';
import { InstallButton } from '~/components/InstallButton';
import { buttonVariants } from '~/styles/Button';
@@ -19,9 +20,12 @@ export default function Page() {
Discord bots.
</h1>
<p className="my-6 leading-normal text-neutral-700 dark:text-neutral-300">{DESCRIPTION}</p>
<div className="flex flex-row gap-4">
<Link className={buttonVariants()} href="/docs">
<div className="flex flex-wrap place-content-center gap-4 md:flex-row">
<a className={buttonVariants()} href="https://old.discordjs.dev/#/docs" rel="noopener noreferrer">
Docs
</a>
<Link className={buttonVariants()} href="/docs">
Module docs
</Link>
<a
className={buttonVariants({ variant: 'secondary' })}
@@ -43,23 +47,41 @@ export default function Page() {
<InstallButton />
</div>
</div>
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"
rel="external noopener noreferrer"
target="_blank"
title="Vercel"
>
<Image
alt="Vercel"
blurDataURL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAABLCAQAAAA1k5H2AAAAi0lEQVR42u3SMQEAAAgDoC251a3gL2SgmfBYBRAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARCAgwWEOSWBnYbKggAAAABJRU5ErkJggg=="
height={44}
placeholder="blur"
priority
src={vercelLogo}
width={212}
/>
</a>
<div className="flex flex-col gap-4 md:flex-row">
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"
rel="external noopener noreferrer"
target="_blank"
title="Vercel"
>
<Image
alt="Vercel"
blurDataURL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAABLCAQAAAA1k5H2AAAAi0lEQVR42u3SMQEAAAgDoC251a3gL2SgmfBYBRAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARCAgwWEOSWBnYbKggAAAABJRU5ErkJggg=="
height={44}
placeholder="blur"
priority
src={vercelLogo}
width={212}
/>
</a>
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://www.cloudflare.com"
rel="external noopener noreferrer"
target="_blank"
title="Cloudflare Workers"
>
<Image
alt="Cloudflare"
blurDataURL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAABLCAQAAAA1k5H2AAAAi0lEQVR42u3SMQEAAAgDoC251a3gL2SgmfBYBRAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARCAgwWEOSWBnYbKggAAAABJRU5ErkJggg=="
height={44}
placeholder="blur"
priority
src={workersLogo}
/>
</a>
</div>
</div>
</div>
);

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -1,6 +1,6 @@
import { FiLink } from '@react-icons/all-files/fi/FiLink';
export function Anchor({ href }: { href: string }) {
export function Anchor({ href }: { readonly href: string }) {
return (
<a className="mr-1 inline-block rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple" href={href}>
<FiLink size={20} />

View File

@@ -8,7 +8,10 @@ export enum BadgeColor {
Warning = 'bg-yellow-500',
}
export function Badge({ children, color = BadgeColor.Primary }: PropsWithChildren<{ color?: BadgeColor | undefined }>) {
export function Badge({
children,
color = BadgeColor.Primary,
}: PropsWithChildren<{ readonly color?: BadgeColor | undefined }>) {
return (
<span
className={`h-5 flex flex-row place-content-center place-items-center rounded-full px-3 text-center text-xs font-semibold uppercase text-white ${color}`}
@@ -18,7 +21,7 @@ export function Badge({ children, color = BadgeColor.Primary }: PropsWithChildre
);
}
export function Badges({ item }: { item: ApiDocumentedItem }) {
export function Badges({ item }: { readonly item: ApiDocumentedItem }) {
const isStatic = ApiStaticMixin.isBaseClassOf(item) && item.isStatic;
const isProtected = ApiProtectedMixin.isBaseClassOf(item) && item.isProtected;
const isReadonly = ApiReadonlyMixin.isBaseClassOf(item) && item.isReadonly;

View File

@@ -4,7 +4,6 @@ import type { ApiItemKind } from '@microsoft/api-extractor-model';
import { VscArrowRight } from '@react-icons/all-files/vsc/VscArrowRight';
import { VscSymbolClass } from '@react-icons/all-files/vsc/VscSymbolClass';
import { VscSymbolEnum } from '@react-icons/all-files/vsc/VscSymbolEnum';
import { VscSymbolField } from '@react-icons/all-files/vsc/VscSymbolField';
import { VscSymbolInterface } from '@react-icons/all-files/vsc/VscSymbolInterface';
import { VscSymbolMethod } from '@react-icons/all-files/vsc/VscSymbolMethod';
import { VscSymbolProperty } from '@react-icons/all-files/vsc/VscSymbolProperty';
@@ -28,7 +27,7 @@ function resolveIcon(item: keyof typeof ApiItemKind) {
case 'Property':
return <VscSymbolProperty className="shrink-0" size={25} />;
case 'TypeAlias':
return <VscSymbolField className="shrink-0" size={25} />;
return <VscSymbolVariable className="shrink-0" size={25} />;
case 'Variable':
return <VscSymbolVariable className="shrink-0" size={25} />;
default:

View File

@@ -5,15 +5,15 @@ export interface CodeListingProps {
/**
* The value of this heading.
*/
children: ReactNode;
readonly children: ReactNode;
/**
* Additional class names to apply to the root element.
*/
className?: string | undefined;
readonly className?: string | undefined;
/**
* The href of this heading.
*/
href?: string | undefined;
readonly href?: string | undefined;
}
export function CodeHeading({ href, className, children }: CodeListingProps) {

View File

@@ -8,11 +8,11 @@ export interface ExcerptTextProps {
/**
* The tokens to render.
*/
excerpt: Excerpt;
readonly excerpt: Excerpt;
/**
* The model to resolve item references from.
*/
model: ApiModel;
readonly model: ApiModel;
}
/**
@@ -49,7 +49,7 @@ export function ExcerptText({ model, excerpt }: ExcerptTextProps) {
<ItemLink
className="text-blurple"
itemURI={resolveItemURI(item)}
key={`${item.displayName}-${item.containerKey}`}
key={`${item.displayName}-${item.containerKey}-${idx}`}
packageName={item.getAssociatedPackage()?.displayName.replace('@discordjs/', '')}
>
{token.text}

View File

@@ -1,11 +1,12 @@
import Image from 'next/image';
import vercelLogo from '~/assets/powered-by-vercel.svg';
import workersLogo from '~/assets/powered-by-workers.png';
export default function Footer() {
return (
<footer className="md:pl-12 md:pr-12">
<div className="mx-auto max-w-6xl flex flex-col place-items-center gap-12 pt-12 lg:place-content-center">
<div className="w-full flex flex-col place-content-between place-items-center gap-12 md:flex-row md:gap-0">
<div className="flex flex-col flex-wrap place-content-center gap-6 pt-12 sm:flex-row md:gap-12">
<div className="flex flex-wrap place-content-center place-items-center gap-4">
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"
@@ -22,56 +23,72 @@ export default function Footer() {
width={212}
/>
</a>
<div className="flex flex-row gap-6 md:gap-12">
<div className="flex flex-col gap-2">
<div className="text-lg font-semibold">Community</div>
<div className="flex flex-col gap-1">
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://discord.gg/djs"
rel="external noopener noreferrer"
target="_blank"
>
Discord
</a>
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://github.com/discordjs/discord.js/discussions"
rel="external noopener noreferrer"
target="_blank"
>
GitHub discussions
</a>
</div>
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://www.cloudflare.com"
rel="external noopener noreferrer"
target="_blank"
title="Cloudflare Workers"
>
<Image
alt="Cloudflare"
blurDataURL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAABLCAQAAAA1k5H2AAAAi0lEQVR42u3SMQEAAAgDoC251a3gL2SgmfBYBRAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARAAARCAgwWEOSWBnYbKggAAAABJRU5ErkJggg=="
height={44}
placeholder="blur"
priority
src={workersLogo}
/>
</a>
</div>
<div className="flex flex-col place-self-center gap-6 sm:flex-row md:gap-12">
<div className="max-w-max flex flex-col gap-2">
<div className="text-lg font-semibold">Community</div>
<div className="flex flex-col gap-1">
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://discord.gg/djs"
rel="external noopener noreferrer"
target="_blank"
>
Discord
</a>
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://github.com/discordjs/discord.js/discussions"
rel="external noopener noreferrer"
target="_blank"
>
GitHub discussions
</a>
</div>
<div className="flex flex-col gap-2">
<div className="text-lg font-semibold">Project</div>
<div className="flex flex-col gap-1">
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://github.com/discordjs/discord.js"
rel="external noopener noreferrer"
target="_blank"
>
discord.js
</a>
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://discordjs.guide"
rel="noopener noreferrer"
target="_blank"
>
discord.js guide
</a>
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://discord-api-types.dev"
rel="external noopener noreferrer"
target="_blank"
>
discord-api-types
</a>
</div>
</div>
<div className="max-w-max flex flex-col gap-2">
<div className="text-lg font-semibold">Project</div>
<div className="flex flex-col gap-1">
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://github.com/discordjs/discord.js"
rel="external noopener noreferrer"
target="_blank"
>
discord.js
</a>
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://discord.js.org/docs"
rel="noopener noreferrer"
target="_blank"
>
discord.js documentation
</a>
<a
className="rounded outline-none focus:ring focus:ring-width-2 focus:ring-blurple"
href="https://discord-api-types.dev"
rel="external noopener noreferrer"
target="_blank"
>
discord-api-types
</a>
</div>
</div>
</div>

View File

@@ -2,7 +2,7 @@ import type { ApiDeclaredItem } from '@microsoft/api-extractor-model';
import { ItemLink } from './ItemLink';
import { resolveItemURI } from './documentation/util';
export function InheritanceText({ parent }: { parent: ApiDeclaredItem }) {
export function InheritanceText({ parent }: { readonly parent: ApiDeclaredItem }) {
return (
<span className="font-semibold">
Inherited from{' '}

View File

@@ -10,17 +10,17 @@ export interface ItemLinkProps
extends Omit<LinkProps, 'href'>,
RefAttributes<HTMLAnchorElement>,
Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof LinkProps> {
className?: string;
readonly className?: string;
/**
* The URI of the api item to link to. (e.g. `/RestManager`)
*/
itemURI: string;
readonly itemURI: string;
/**
* The name of the package the item belongs to.
*/
packageName?: string | undefined;
readonly packageName?: string | undefined;
}
/**

View File

@@ -9,7 +9,7 @@ import { useNav } from '~/contexts/nav';
const PackageSelect = dynamic(async () => import('./PackageSelect'));
const VersionSelect = dynamic(async () => import('./VersionSelect'));
export function Nav({ members }: { members: SidebarSectionItemData[] }) {
export function Nav({ members }: { readonly members: SidebarSectionItemData[] }) {
const { opened } = useNav();
return (

View File

@@ -4,7 +4,7 @@ import { Scrollbars } from './Scrollbars';
import type { TableOfContentsSerialized } from './TableOfContentItems';
import { TableOfContentItems } from './TableOfContentItems';
export function Outline({ members }: { members: TableOfContentsSerialized[] }) {
export function Outline({ members }: { readonly members: TableOfContentsSerialized[] }) {
return (
<aside className="fixed bottom-0 right-0 top-[50px] z-20 hidden h-[calc(100vh_-_65px)] w-64 border-l border-light-800 bg-white pr-2 xl:block dark:border-dark-100 dark:bg-dark-600">
<Scrollbars

View File

@@ -4,17 +4,52 @@ import { VscChevronDown } from '@react-icons/all-files/vsc/VscChevronDown';
import { VscVersions } from '@react-icons/all-files/vsc/VscVersions';
import { Menu, MenuButton, MenuItem, useMenuState } from 'ariakit/menu';
import type { PropsWithChildren, ReactNode } from 'react';
import { useMemo, useState } from 'react';
import { useCallback, useMemo, useState, useEffect } from 'react';
export interface OverloadSwitcherProps {
methodName: string;
overloads: ReactNode[];
}
export default function OverloadSwitcher({ overloads, children }: PropsWithChildren<{ overloads: ReactNode[] }>) {
export default function OverloadSwitcher({
methodName,
overloads,
children,
}: PropsWithChildren<{ readonly methodName: string; readonly overloads: ReactNode[] }>) {
const [hash, setHash] = useState(() => (typeof window === 'undefined' ? '' : window.location.hash));
const hashChangeHandler = useCallback(() => {
setHash(window.location.hash);
}, []);
const [overloadIndex, setOverloadIndex] = useState(1);
const overloadedNode = overloads[overloadIndex - 1]!;
const menu = useMenuState({ gutter: 8, sameWidth: true, fitViewport: true });
useEffect(() => {
window.addEventListener('hashchange', hashChangeHandler);
return () => {
window.removeEventListener('hashchange', hashChangeHandler);
};
});
useEffect(() => {
if (hash) {
const elementId = hash.replace('#', '');
const [name, idx] = elementId.split(':');
if (name && methodName === name) {
if (idx) {
const hashOverload = Number.parseInt(idx, 10);
const resolvedOverload = Math.max(Math.min(hashOverload, overloads.length), 1);
setOverloadIndex(Number.isNaN(resolvedOverload) ? 1 : resolvedOverload);
}
const element = document.querySelector(`[id^='${name}']`);
if (element) {
element.scrollIntoView({ behavior: 'smooth' });
}
}
}
}, [hash, methodName, overloads.length]);
const menuItems = useMemo(
() =>
overloads.map((_, idx) => (

View File

@@ -10,7 +10,7 @@ const columnStyles = {
Type: 'font-mono whitespace-pre-wrap break-normal',
};
export function ParameterTable({ item }: { item: ApiDocumentedItem & ApiParameterListMixin }) {
export function ParameterTable({ item }: { readonly item: ApiDocumentedItem & ApiParameterListMixin }) {
const params = resolveParameters(item);
const rows = useMemo(

View File

@@ -16,8 +16,8 @@ export function Property({
children,
inheritedFrom,
}: PropsWithChildren<{
inheritedFrom?: (ApiDeclaredItem & ApiItemContainerMixin) | undefined;
item: ApiProperty | ApiPropertySignature;
readonly inheritedFrom?: (ApiDeclaredItem & ApiItemContainerMixin) | undefined;
readonly item: ApiProperty | ApiPropertySignature;
}>) {
const hasSummary = Boolean(item.tsdocComment?.summarySection);

View File

@@ -14,7 +14,7 @@ export function isPropertyLike(item: ApiItem): item is ApiProperty | ApiProperty
return item.kind === ApiItemKind.Property || item.kind === ApiItemKind.PropertySignature;
}
export function PropertyList({ item }: { item: ApiItemContainerMixin }) {
export function PropertyList({ item }: { readonly item: ApiItemContainerMixin }) {
const members = resolveMembers(item, isPropertyLike);
const propertyItems = useMemo(

View File

@@ -3,7 +3,6 @@
import type { ApiItemKind } from '@microsoft/api-extractor-model';
import { VscSymbolClass } from '@react-icons/all-files/vsc/VscSymbolClass';
import { VscSymbolEnum } from '@react-icons/all-files/vsc/VscSymbolEnum';
import { VscSymbolField } from '@react-icons/all-files/vsc/VscSymbolField';
import { VscSymbolInterface } from '@react-icons/all-files/vsc/VscSymbolInterface';
import { VscSymbolMethod } from '@react-icons/all-files/vsc/VscSymbolMethod';
import { VscSymbolVariable } from '@react-icons/all-files/vsc/VscSymbolVariable';
@@ -74,7 +73,6 @@ function resolveIcon(item: string) {
case 'Interfaces':
return <VscSymbolInterface size={20} />;
case 'Types':
return <VscSymbolField size={20} />;
case 'Variables':
return <VscSymbolVariable size={20} />;
default:
@@ -82,7 +80,7 @@ function resolveIcon(item: string) {
}
}
export function Sidebar({ members }: { members: SidebarSectionItemData[] }) {
export function Sidebar({ members }: { readonly members: SidebarSectionItemData[] }) {
const segment = useSelectedLayoutSegment();
const { setOpened } = useNav();
@@ -94,7 +92,7 @@ export function Sidebar({ members }: { members: SidebarSectionItemData[] }) {
.filter((group) => groupItems[group].length)
.map((group, idx) => (
<Section
buttonClassName="bg-light-600 hover:bg-light-700 active:bg-light-800 dark:bg-dark-400 dark:hover:bg-dark-300 dark:active:bg-dark-400 focus:ring-width-2 focus:ring-blurple rounded p-3 outline-none focus:ring"
buttonClassName="bg-light-600 hover:bg-light-700 active:bg-light-800 dark:bg-dark-400 dark:hover:bg-dark-300 dark:active:bg-dark-400 focus:ring-width-2 focus:ring-blurple rounded p-3 outline-none focus:ring z-10"
icon={resolveIcon(group)}
key={`${group}-${idx}`}
title={group}

View File

@@ -1,9 +1,9 @@
import type { ApiModel, Excerpt } from '@microsoft/api-extractor-model';
import { ExcerptText } from './ExcerptText';
export function SignatureText({ excerpt, model }: { excerpt: Excerpt; model: ApiModel }) {
export function SignatureText({ excerpt, model }: { readonly excerpt: Excerpt; readonly model: ApiModel }) {
return (
<h4 className="break-all font-mono text-lg font-bold">
<h4 className="break-all text-lg font-bold font-mono">
<ExcerptText excerpt={excerpt} model={model} />
</h4>
);

View File

@@ -4,11 +4,9 @@ export function SyntaxHighlighter(props: typeof Code) {
return (
<>
<div data-theme="dark">
{/* @ts-expect-error async component */}
<Code codeClassName="font-mono" lang={props.lang ?? 'typescript'} {...props} theme="github-dark-dimmed" />
</div>
<div className="[&_pre]:border [&_pre]:border-gray-300 [&_pre]:rounded-md" data-theme="light">
{/* @ts-expect-error async component */}
<Code codeClassName="font-mono" lang={props.lang ?? 'typescript'} {...props} theme="min-light" />
</div>
</>

View File

@@ -7,9 +7,9 @@ export function Table({
columns,
columnStyles,
}: {
columnStyles?: Record<string, string>;
columns: string[];
rows: Record<string, ReactNode>[];
readonly columnStyles?: Record<string, string>;
readonly columns: string[];
readonly rows: Record<string, ReactNode>[];
}) {
const cols = useMemo(
() =>

View File

@@ -19,10 +19,10 @@ export interface TableOfContentsSerializedProperty {
export type TableOfContentsSerialized = TableOfContentsSerializedMethod | TableOfContentsSerializedProperty;
export interface TableOfContentsItemProps {
serializedMembers: TableOfContentsSerialized[];
readonly serializedMembers: TableOfContentsSerialized[];
}
export function TableOfContentsPropertyItem({ property }: { property: TableOfContentsSerializedProperty }) {
export function TableOfContentsPropertyItem({ property }: { readonly property: TableOfContentsSerializedProperty }) {
return (
<a
className="ml-[10px] border-l border-light-800 p-[5px] pl-6.5 text-sm outline-none focus:border-0 dark:border-dark-100 focus:rounded active:bg-light-800 hover:bg-light-700 focus:ring focus:ring-width-2 focus:ring-blurple dark:active:bg-dark-100 dark:hover:bg-dark-200"
@@ -35,7 +35,7 @@ export function TableOfContentsPropertyItem({ property }: { property: TableOfCon
);
}
export function TableOfContentsMethodItem({ method }: { method: TableOfContentsSerializedMethod }) {
export function TableOfContentsMethodItem({ method }: { readonly method: TableOfContentsSerializedMethod }) {
if (method.overloadIndex && method.overloadIndex > 1) {
return null;
}

View File

@@ -10,7 +10,7 @@ const rowElements = {
Default: 'font-mono whitespace-pre break-normal',
};
export function TypeParamTable({ item }: { item: ApiTypeParameterListMixin }) {
export function TypeParamTable({ item }: { readonly item: ApiTypeParameterListMixin }) {
const model = item.getAssociatedModel()!;
const rows = useMemo(
() =>

View File

@@ -19,6 +19,7 @@ function generateIcon(kind: ApiItemKind) {
case ApiItemKind.Interface:
return <VscSymbolInterface />;
case ApiItemKind.TypeAlias:
case ApiItemKind.Variable:
return <VscSymbolVariable />;
default:
return <VscSymbolMethod />;
@@ -29,7 +30,7 @@ export function Header({
kind,
name,
sourceURL,
}: PropsWithChildren<{ kind: ApiItemKind; name: string; sourceURL?: string | undefined }>) {
}: PropsWithChildren<{ readonly kind: ApiItemKind; readonly name: string; readonly sourceURL?: string | undefined }>) {
return (
<div className="flex flex-col">
<h2 className="flex flex-row place-items-center justify-between gap-2 break-all text-2xl font-bold">

View File

@@ -2,7 +2,13 @@ import type { ApiClass, ApiInterface, Excerpt } from '@microsoft/api-extractor-m
import { ApiItemKind } from '@microsoft/api-extractor-model';
import { ExcerptText } from '../ExcerptText';
export function HierarchyText({ item, type }: { item: ApiClass | ApiInterface; type: 'Extends' | 'Implements' }) {
export function HierarchyText({
item,
type,
}: {
readonly item: ApiClass | ApiInterface;
readonly type: 'Extends' | 'Implements';
}) {
const model = item.getAssociatedModel()!;
if (

View File

@@ -3,7 +3,7 @@ import { MethodsSection } from './section/MethodsSection';
import { PropertiesSection } from './section/PropertiesSection';
import { hasProperties, hasMethods } from './util';
export function Members({ item }: { item: ApiDeclaredItem & ApiItemContainerMixin }) {
export function Members({ item }: { readonly item: ApiDeclaredItem & ApiItemContainerMixin }) {
return (
<>
{hasProperties(item) ? <PropertiesSection item={item} /> : null}

View File

@@ -4,7 +4,7 @@ import { Header } from './Header';
import { SummarySection } from './section/SummarySection';
export interface ObjectHeaderProps {
item: ApiDeclaredItem;
readonly item: ApiDeclaredItem;
}
export function ObjectHeader({ item }: ObjectHeaderProps) {

View File

@@ -6,7 +6,7 @@ import { parametersString } from '../util';
import { DocumentationSection } from './DocumentationSection';
import { CodeHeading } from '~/components/CodeHeading';
export function ConstructorSection({ item }: { item: ApiConstructor }) {
export function ConstructorSection({ item }: { readonly item: ApiConstructor }) {
return (
<DocumentationSection icon={<VscSymbolMethod size={20} />} padded title="Constructor">
<div className="flex flex-col gap-2">

View File

@@ -19,7 +19,7 @@ function isMethodLike(item: ApiItem): item is ApiMethod | ApiMethodSignature {
);
}
export function MethodsSection({ item }: { item: ApiItemContainerMixin }) {
export function MethodsSection({ item }: { readonly item: ApiItemContainerMixin }) {
const members = resolveMembers(item, isMethodLike);
const methodItems = useMemo(

View File

@@ -3,7 +3,7 @@ import { VscSymbolParameter } from '@react-icons/all-files/vsc/VscSymbolParamete
import { ParameterTable } from '../../ParameterTable';
import { DocumentationSection } from './DocumentationSection';
export function ParameterSection({ item }: { item: ApiDocumentedItem & ApiParameterListMixin }) {
export function ParameterSection({ item }: { readonly item: ApiDocumentedItem & ApiParameterListMixin }) {
return (
<DocumentationSection icon={<VscSymbolParameter size={20} />} padded title="Parameters">
<ParameterTable item={item} />

View File

@@ -3,7 +3,7 @@ import { VscSymbolProperty } from '@react-icons/all-files/vsc/VscSymbolProperty'
import { PropertyList } from '../../PropertyList';
import { DocumentationSection } from './DocumentationSection';
export function PropertiesSection({ item }: { item: ApiItemContainerMixin }) {
export function PropertiesSection({ item }: { readonly item: ApiItemContainerMixin }) {
return (
<DocumentationSection icon={<VscSymbolProperty size={20} />} padded title="Properties">
<PropertyList item={item} />

View File

@@ -3,7 +3,7 @@ import { VscListSelection } from '@react-icons/all-files/vsc/VscListSelection';
import { TSDoc } from '../tsdoc/TSDoc';
import { DocumentationSection } from './DocumentationSection';
export function SummarySection({ item }: { item: ApiDeclaredItem }) {
export function SummarySection({ item }: { readonly item: ApiDeclaredItem }) {
return (
<DocumentationSection icon={<VscListSelection size={20} />} padded separator title="Summary">
{item.tsdocComment?.summarySection ? (

View File

@@ -3,7 +3,7 @@ import { VscSymbolParameter } from '@react-icons/all-files/vsc/VscSymbolParamete
import { TypeParamTable } from '../../TypeParamTable';
import { DocumentationSection } from './DocumentationSection';
export function TypeParameterSection({ item }: { item: ApiTypeParameterListMixin }) {
export function TypeParameterSection({ item }: { readonly item: ApiTypeParameterListMixin }) {
return (
<DocumentationSection icon={<VscSymbolParameter size={20} />} padded title="Type Parameters">
<TypeParamTable item={item} />

View File

@@ -1,7 +1,7 @@
import { Alert } from '@discordjs/ui';
import type { PropsWithChildren } from 'react';
export function Block({ children, title }: PropsWithChildren<{ title: string }>) {
export function Block({ children, title }: PropsWithChildren<{ readonly title: string }>) {
return (
<div className="flex flex-col gap-2">
<h5 className="font-bold">{title}</h5>
@@ -13,7 +13,7 @@ export function Block({ children, title }: PropsWithChildren<{ title: string }>)
export function ExampleBlock({
children,
exampleIndex,
}: PropsWithChildren<{ exampleIndex?: number | undefined }>): JSX.Element {
}: PropsWithChildren<{ readonly exampleIndex?: number | undefined }>): JSX.Element {
return <Block title={`Example ${exampleIndex ? exampleIndex : ''}`}>{children}</Block>;
}

View File

@@ -8,7 +8,7 @@ import { SyntaxHighlighter } from '../../SyntaxHighlighter';
import { resolveItemURI } from '../util';
import { DefaultValueBlock, DeprecatedBlock, ExampleBlock, RemarksBlock, ReturnsBlock, SeeBlock } from './BlockComment';
export function TSDoc({ item, tsdoc }: { item: ApiItem; tsdoc: DocNode }): JSX.Element {
export function TSDoc({ item, tsdoc }: { readonly item: ApiItem; readonly tsdoc: DocNode }): JSX.Element {
const createNode = useCallback(
(tsdoc: DocNode, idx?: number): ReactNode => {
switch (tsdoc.kind) {
@@ -66,7 +66,7 @@ export function TSDoc({ item, tsdoc }: { item: ApiItem; tsdoc: DocNode }): JSX.E
case DocNodeKind.CodeSpan: {
const { code } = tsdoc as DocFencedCode;
return (
<code className="font-mono text-sm" key={idx}>
<code className="text-sm font-mono" key={idx}>
{code}
</code>
);

View File

@@ -10,7 +10,7 @@ import { ConstructorSection } from '../documentation/section/ConstructorSection'
import { TypeParameterSection } from '../documentation/section/TypeParametersSection';
// import { serializeMembers } from '../documentation/util';
export function Class({ clazz }: { clazz: ApiClass }) {
export function Class({ clazz }: { readonly clazz: ApiClass }) {
const constructor = clazz.members.find((member) => member.kind === ApiItemKind.Constructor) as
| ApiConstructor
| undefined;

View File

@@ -7,7 +7,7 @@ import { ObjectHeader } from '../documentation/ObjectHeader';
import { TypeParameterSection } from '../documentation/section/TypeParametersSection';
// import { serializeMembers } from '../documentation/util';
export function Interface({ item }: { item: ApiInterface }) {
export function Interface({ item }: { readonly item: ApiInterface }) {
return (
<Documentation>
<ObjectHeader item={item} />

View File

@@ -4,7 +4,7 @@ import { Documentation } from '../documentation/Documentation';
import { Header } from '../documentation/Header';
import { SummarySection } from '../documentation/section/SummarySection';
export function TypeAlias({ item }: { item: ApiTypeAlias }) {
export function TypeAlias({ item }: { readonly item: ApiTypeAlias }) {
return (
<Documentation>
<Header kind={item.kind} name={item.displayName} sourceURL={item.sourceLocation.fileUrl} />

View File

@@ -2,7 +2,7 @@ import type { ApiVariable } from '@microsoft/api-extractor-model';
import { Documentation } from '../documentation/Documentation';
import { ObjectHeader } from '../documentation/ObjectHeader';
export function Variable({ item }: { item: ApiVariable }) {
export function Variable({ item }: { readonly item: ApiVariable }) {
return (
<Documentation>
<ObjectHeader item={item} />

View File

@@ -6,7 +6,7 @@ import { ObjectHeader } from '../../documentation/ObjectHeader';
import { DocumentationSection } from '../../documentation/section/DocumentationSection';
import { EnumMember } from './EnumMember';
export function Enum({ item }: { item: ApiEnum }) {
export function Enum({ item }: { readonly item: ApiEnum }) {
return (
<Documentation>
<ObjectHeader item={item} />

Some files were not shown because too many files have changed in this diff Show More