Compare commits

..

386 Commits

Author SHA1 Message Date
Vlad Frangu
776880d06b chore: fix changelogs 2024-05-05 21:00:59 +03:00
Vlad Frangu
c05244af61 chore(discord.js): release discord.js@14.15.2 2024-05-05 21:00:59 +03:00
Vlad Frangu
12deea85e5 chore(builders): release @discordjs/builders@1.8.1 2024-05-05 21:00:59 +03:00
Qjuh
07c12101e5 fix: slashcommand builder type split (#10253) 2024-05-05 10:03:14 +00:00
XCraftTM
30d79e85fb fix(PollAnswer): fetchVoters route changed to MessageManager (#10251)
Update PollAnswer.js
2024-05-04 21:18:04 +00:00
Vlad Frangu
f2794e1221 chore(discord.js): release discord.js@14.15.1 (#10250)
* chore(discord.js): release discord.js@14.15.1

* chore: fix changelog

* chore: update link
2024-05-04 19:18:07 +00:00
DD
0474a43751 fix(MessageManager): poll methods don't need a channel id (#10249)
* fix(MessageManager): end poll does not need channel id

* chore: rest of the work
2024-05-04 19:06:03 +00:00
Almeida
c91d03c535 ci: fix documentation workflow (#10248) 2024-05-04 18:18:45 +00:00
Vlad Frangu
d92695cdd6 chore: brother why 2024-05-04 20:50:15 +03:00
Vlad Frangu
1d27b3bde0 chore: fix duplicated discord.js changelog 2024-05-04 20:50:15 +03:00
Vlad Frangu
903a7d3404 chore: fix duplicated voice changelog 2024-05-04 20:50:15 +03:00
Vlad Frangu
840dc565cd chore: update templates for create-discord-bot 2024-05-04 20:50:15 +03:00
Vlad Frangu
a84086194e chore(discord.js): release discord.js@14.15.0 2024-05-04 20:50:15 +03:00
Vlad Frangu
b66c067dd7 chore(core): release @discordjs/core@1.2.0 2024-05-04 20:50:15 +03:00
Vlad Frangu
e9d560f128 chore(ws): release @discordjs/ws@1.1.0 2024-05-04 20:50:15 +03:00
Vlad Frangu
6f986886c5 chore(proxy): release @discordjs/proxy@2.1.0 2024-05-04 20:50:15 +03:00
Vlad Frangu
7b913b674f chore(rest): release @discordjs/rest@2.3.0 2024-05-04 20:50:15 +03:00
Vlad Frangu
7dc51aa935 chore(builders): release @discordjs/builders@1.8.0 2024-05-04 20:50:15 +03:00
Vlad Frangu
16df4f3c38 chore(voice): release @discordjs/voice@0.17.0 2024-05-04 20:50:15 +03:00
Vlad Frangu
6239f24f19 chore(util): release @discordjs/util@1.1.0 2024-05-04 20:50:15 +03:00
Vlad Frangu
92501ae343 chore(formatters): release @discordjs/formatters@0.4.0 2024-05-04 20:50:15 +03:00
Vlad Frangu
35f2b3a8c9 chore(create-discord-bot): release create-discord-bot@0.3.0 2024-05-04 20:50:15 +03:00
Vlad Frangu
23ed447ec2 chore(collection): release @discordjs/collection@2.1.0 2024-05-04 20:50:15 +03:00
Vlad Frangu
5d61197ca3 chore(brokers): release @discordjs/brokers@0.3.0 2024-05-04 20:50:15 +03:00
Almeida
a6b9f1b37e fix(Message): not crosspostable if has a poll (#10246) 2024-05-04 16:21:04 +00:00
Jacob Morrison
cb961f5be3 types: add Poll to Message (#10245)
* Add poll to message type

* Add poll to message type without whitespace changes
2024-05-04 16:06:16 +00:00
codershiba
96169add6d docs: Remove duplicate word in comment (#10244)
* fix: Remove duplicate word in comment

* Update README.md

not part of the typo

---------

Co-authored-by: Souji <timoqueezle@gmail.com>
2024-05-04 08:33:24 +00:00
DD
728164ed86 feat(ws): support for custom worker messaging (#10241) 2024-05-03 14:53:09 +00:00
Almeida
6cf094c282 feat(MessageManager): poll methods (#10239)
* feat(MessageManager): poll methods

* docs: wording

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

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2024-05-02 20:54:00 +00:00
Almeida
997887069a feat: consumable entitlements (#10235)
* feat: consumable entitlements

* feat: move logic to EntitlementManager

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-05-01 17:57:25 +00:00
Almeida
a1aeaeb9d8 feat: polls (#10185)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-04-30 23:21:07 +00:00
Almeida
c7adce351a build: bump discord-api-types to 0.37.83 (#10238)
build: bump discord-api-types to 0.37.82
2024-04-30 23:04:00 +00:00
Parbez
7ea3638dbc fix: don't mutate user provided array (#10014)
* fix(builders): don't mutate user provided array

* test: add normalize array tests

* chore: revert vscode autochange

* Update util.test.ts

* refactor: remove unnecessary clone

---------

Co-authored-by: Vlad Frangu <me@vladfrangu.dev>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: Almeida <github@almeidx.dev>
2024-04-30 20:46:21 +00:00
DD
798f28cb9b fix(actions): always emit message create for own messages (#10211)
* fix(actions): always emit message create for own messages

* fix: don't re-cache

* fix: user can be missing

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-04-27 22:37:16 +00:00
Synbulat Biishev
14f9ff7412 chore: Add funding field to package.json (#10230)
* chore: funding

* chore: one more package.json

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-04-27 17:26:11 +00:00
Almeida
c2e68ceaad build: bump discord-api-types to 0.37.82 (#10226)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-04-27 17:16:20 +00:00
Almeida
dc8f14967c test: skip flaky rest test (#10234) 2024-04-27 19:11:03 +02:00
Qjuh
b79b7068e9 fix(api-extractor-model): resolve doc reference for classes with merged interfaces (#10225)
fix(api-extractor-model): resolve doc reference with merged interfaces
2024-04-27 16:35:25 +02:00
Synbulat Biishev
dae897bd09 ci: optimize tests (#10231)
chore: optimize tests
2024-04-27 16:34:58 +02:00
Jacob Morrison
4ad285804b perf(Presence): prefer boolean client status comparison before activity checks (#10213)
Prefer boolean client status comparison before activity checks

Co-authored-by: Jacob Morrison <jake@matchmd.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-04-20 23:08:26 +00:00
iCrawl
6759f5b9c5 chore: deps 2024-04-16 21:44:21 +02:00
Qjuh
c6721d9aa7 fix(api-extractor): link class in docs if interface merging happened (#10217) 2024-04-16 21:34:43 +02:00
Qjuh
1c5de21a29 feat(api-extractor): support export * as ___ syntax (#10173)
* feat(api-extractor): support `export * as ___` syntax

* fix: typescript version
2024-04-16 08:35:34 +00:00
Qjuh
7baa9e4333 feat(website): add type field to search index to sort by (#10212) 2024-04-14 19:53:16 +02:00
Qjuh
afb97fbd00 fix(website): use correct version for cross-package links (#10193) 2024-04-11 17:38:04 +02:00
Qjuh
7dc5bdfef5 ci: fix call to generateSplitDocumentation if run on tag (#10209)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-04-10 16:27:20 +00:00
Dawid Jaworski
de14c92c11 feat(ClientUser): Add support for setting bot banner (#10176)
* feat(discord.js): added support to setting bot banner

added feature to set banner for bot from code level
the function is in the experimental phase of Discord.

* fix: resolve requested changes

* fix: add missing type in ClientUserEditOptions

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2024-04-09 14:09:01 +00:00
Jiralite
464d627f1d ci: Ensure reviews in progress label do not merge (#10208)
ci: ensure reviews do not merge
2024-04-07 23:09:39 +02:00
Almeida
bfc3b100da feat(GuildsAPI): bulk ban users (#10202)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-04-06 07:24:16 +00:00
n1ck_pro
f1f2683dc7 docs: remove unused Locale typedef (#10191)
docs: remove unused typedef

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-04-04 19:34:13 +00:00
avoidaway
26af3868a5 docs: remove duplicated words (#10178)
chore: remove repetitive words

Signed-off-by: avoidaway <cmoman@126.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-04-04 19:29:34 +00:00
codershiba
b6bdd578b9 feat(GuildBanManager): Add bulkCreate() method (#10182) 2024-04-02 19:38:48 +00:00
Almeida
ba6476d07e build: bump discord-api-types to 0.37.78 (#10201) 2024-04-01 17:55:45 +00:00
Qjuh
980a2b71c7 types: generic for Webhook type (#10188)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-03-31 14:15:21 +00:00
Qjuh
654f1a48b9 chore: remove ws dependency (#10180) 2024-03-31 14:09:38 +00:00
LeCarbonator
a1a3a95c94 feat: allow RestOrArray for command option builders (#10175)
* feat(builders): allow RestOrArray for command option builders

change ApplicationCommandOption methods to allow both rest and array params,
which previously wasn't consistent with other builders.

* chore: merge imports

---------

Co-authored-by: almeidx <github@almeidx.dev>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-03-24 18:12:05 +00:00
Danial Raza
ddc927fabd fix(Embed): address equals method issue (#10152)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-03-24 14:45:56 +00:00
Danial Raza
f500ad6e2e refactor(ThreadChannel): use single thread member endpoint (#10136)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-03-24 14:41:29 +00:00
cobalt
6cc5fa28e6 fix(types): Export ReadonlyCollection (#10184) 2024-03-20 13:10:34 +00:00
iCrawl
93c174bc82 chore: fix test type import 2024-03-11 18:15:21 +01:00
iCrawl
0d4c26ba4c chore: deps 2024-03-11 17:50:39 +01:00
Qjuh
5f2095b76c ci: use correct github tag in docs source links (#10163)
* ci: use correct github tag in docs source links

* fix: also apply on new tags
2024-03-09 13:52:38 +01:00
Superchupu
a66fc65742 ci: enable npm provenance (#10164)
* chore: enable npm provenance

* chore: do the same for dev releases

* chore: actually enable it in normal releases

* chore: specify provenance in `package.json`

* chore: remove `publishConfig` from api-extractor-utils as it's `private`
2024-03-04 21:11:32 +00:00
Qjuh
a1010c61f5 types: fix duplicate props in merged interfaces (#10160)
types(discord.js): fix duplicate props in merged interfaces
2024-03-04 11:55:01 +01:00
Superchupu
8de8371204 chore(gitattributes): mark pnpm-lock.yaml as generated (#10159) 2024-03-04 00:15:47 +01:00
iCrawl
0efd1bea46 fix: anchor link for events 2024-03-04 00:02:52 +01:00
iCrawl
9fa115df86 fix: can't use node internals on edge 2024-03-03 02:36:06 +01:00
iCrawl
79fbda3aac feat: local and preview detection 2024-03-03 02:30:08 +01:00
iCrawl
2848591e21 fix: switch out syntax highlighter themes 2024-03-03 00:54:47 +01:00
iCrawl
3fd36f745f ci: remove debug logging 2024-03-02 22:26:09 +01:00
iCrawl
34936a0312 chore: never cache doc generation 2024-03-02 22:21:48 +01:00
iCrawl
e401841f63 ci: more logging 2024-03-02 22:14:02 +01:00
iCrawl
d6bf0fe43e ci: logging for ci 2024-03-02 21:52:10 +01:00
iCrawl
59f4db3e1d ci: update split upload 2024-03-02 21:19:13 +01:00
iCrawl
71bba547b6 refactor: docs ordering 2024-03-02 20:25:51 +01:00
Noel
18cce83d80 refactor: docs (#10126) 2024-02-29 04:37:52 +01:00
cobalt
0f9017ef95 fix(Faces): Escape backslash in Shrug (#10156)
* fix(Faces): Escape backslash in `Shrug`

* Update formatters.ts

* Update formatters.ts

* Update formatters.test.ts
2024-02-27 17:23:31 +00:00
Jiralite
efa3cac6f2 types: Update accessibility modifiers on constructors (#10147)
types: update accessibility modifiers on constructors
2024-02-23 12:51:13 +00:00
Synbulat Biishev
bfbd62e3e0 types(Builder.from): fix wrong types (#10071)
* types(Builder.from): fix wrong types

* test: add tests

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-02-23 11:54:41 +00:00
Almeida
c8bbdb70f2 fix(ReadonlyCollection): omit clear method (#10148)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-02-23 09:02:24 +00:00
Danial Raza
f67da74a5a docs(ActionRow): fix deprecated message (#10130)
docs(ActionRow): fix deprecated link

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-02-23 00:37:43 +00:00
Almeida
bcd4c2cb23 types: use readonly array / collection types for user input (#10045)
* types: use readonly arrays

* chore: check on interface properties

* chore: ReadonlyCollection

* chore: exclude EventEmitter methods

* chore: resolve false positive
2024-02-23 00:29:06 +00:00
Jiralite
8c2ababa78 feat(guild): Add with_counts to getting guilds (#10143)
* feat(guild): add get with counts

* refactor: simplify `query`

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

---------

Co-authored-by: Almeida <almeidx@pm.me>
2024-02-21 21:52:26 +00:00
Danial Raza
1d565443b0 refactor: improve structure validation with zod (#10103)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-02-21 20:19:43 +00:00
Matt Rubin
906ade9cc5 refactor(oauth2): remove unnecessary dependency on 'node:url' (#10141)
This change fixes a runtime error when using '@discordjs/core/http-only' on Cloudflare Workers.
2024-02-21 20:15:26 +00:00
Almeida
c89c343b0a types(InteractionReplyOptions): allow setting MessageFlags.SuppressNotifications (#9199) 2024-02-20 20:28:37 +00:00
Danial Raza
992aa67841 feat(MessageCreateOptions): add enforceNonce (#10129)
Co-authored-by: almeidx <github@almeidx.dev>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-02-17 18:31:14 +00:00
Danial Raza
e9d654772d docs(ApplicationCommandPermissionsManager): remove incorrect comment (#10123)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-02-17 18:03:33 +00:00
Suneet Tipirneni
543d61737e feat: add support for using keyword on discord.js Client and WebSocketManager (#10063)
* feat: add support for `using` keyword on client

* fix: use async dispose

* feat: add support for web socket manager disposing

* fix: use interface for client

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-02-13 17:48:56 +00:00
Almeida
f48cb2a357 refactor: remove usage of mixin on error classes (#10128) 2024-02-13 11:54:56 +00:00
Qjuh
54106dbd81 types: replace Mixins with interface merging (#10094)
* types(TextBasedChannelMixin): refactor to user interface merging instead

* types(WebhookMixin): refactor to interface merging

* fix: ignore empty-interface tslint errors

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-02-11 19:26:20 +00:00
Qjuh
ce6b2b74bc fix(docs): remove spaces in type parameter brackets (#10127)
* fix(docs): remove spaces in type parameter brackets

* fix: missing global flag
2024-02-11 18:59:03 +01:00
Qjuh
36db77f107 fix(docs): use ts types for inherited properties instead of jsdoc (#10125)
* fix(docs): use ts types for inherited properties instead of jsdoc

* fix(docs): remove spaces in type parameters
2024-02-10 21:36:25 +01:00
iCrawl
597340f288 docs: split docs.api.json into multiple json files 2024-02-06 17:24:18 +01:00
iCrawl
ae57d7facb chore: deps 2024-02-06 01:53:30 +01:00
Jiralite
3755e66d41 fix(resolveColor): Address case for numbers (#10115)
fix(resolveColor): address case for numbers

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-02-05 22:11:41 +00:00
DD
c878b65ef5 refactor(WebSocketShard): payload sending (#10098)
* refactor(WebSocketShard): payload sending

* fix: adjust ratelimit state onopen

* fix: use >=

* chore: spelling

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

---------

Co-authored-by: space <spaceeec@yahoo.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-02-05 18:42:33 +00:00
Suneet Tipirneni
f401cff3f4 fix: Correct testing local changes in CONTRIBUTING.md (#10066)
fix: remove unneeded step for testing local changes

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-02-04 20:11:36 +00:00
brynpttrsn
bff1caebd1 fix(website): move function header into switcher (#10077)
fix(website): move header into switcher
2024-02-04 21:06:50 +01:00
Qjuh
ef83bc3e41 fix(api-extractor): link to enum types on inherited properties (#10085)
* fix: link to enum types on inherited properties

* fix: `undefined` in properties without access modifier
2024-02-04 21:06:03 +01:00
Qjuh
bc9b487eb1 fix(website): always link in TypeAlias (#10105)
* fix(website): always link in TypeAlias

* fix: use div instead span for DocParagraph
2024-02-04 00:39:00 +00:00
brynpttrsn
56943a72f4 fix(website): resolve linkTags in meta description (#10088)
* fix(website): resolve linkTags in summaries

* fix: case body as block

* fix: add discord-api-types support

* fix: remove urlDestination when undefined

* fix: breaks to if/else

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-02-03 22:10:28 +00:00
Vinayak Kulkarni
9f8d7fe7b4 build: Update husky to v9 (#10102)
* refactor(dev-deps): migrate to husky v9

Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com>

* revert: only core committers in package.json

* chore: remove hashbang 🎉

* chore: remove install from prepare script 

* chore: upgrade to latest minor

---------

Signed-off-by: Vinayak Kulkarni <19776877+vinayakkulkarni@users.noreply.github.com>
Co-authored-by: almeidx <github@almeidx.dev>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-02-03 22:06:19 +00:00
Almeida
42bc5d2c74 fix: invert deletable message types list (#10093)
* fix: invert deletable message types list

* docs: consistency

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

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-02-03 21:49:11 +00:00
brynpttrsn
f69165883f fix(website): cmdk duplicate values (#10100)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-02-03 21:45:28 +00:00
Jiralite
d4472f85a5 refactor(resolveColor): Prioritise number type check (#10116)
* refactor(resolveColor): prioritise number type check

* refactor: prefer `!Number.isInteger()`

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-02-03 21:42:16 +00:00
Jiralite
b16647e6cc fix(BaseClient): Fall back to userAgentAppendix (#10113)
fix(BaseClient): fall back to `Options.userAgentAppendix`
2024-02-02 16:32:18 +00:00
DD
278396e815 feat(REST): dynamic rate limit offsets (#10099)
* feat(REST): dynamic rate limit offsets

* chore: update tests

* chore: better doc comment

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

* fix: don't overlook globalReset

Co-authored-by: ckohen <chaikohen@gmail.com>

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: ckohen <chaikohen@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-01-30 09:29:42 +00:00
Jiralite
fc1f8ae374 refactor(Messages): Improve ColorConvert error (#10108)
* feat(Messages): improve `ColorConvert` error

* style(Util): consistency
2024-01-30 07:17:45 +00:00
Almeida
bfc7bb5564 docs: convert comment into private remark (#10097)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-01-22 18:45:49 +00:00
Qjuh
a0c83a254c refactor: make builders types great again (#10026)
* refactor: make builders types great again

* fix: subcommands only type

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-01-22 15:02:34 +00:00
Jacob Morrison
fed7f341be Skip sweeping if the guild is not available (#10070)
* Skip sweeping if the guild is not available

* Typo

* Fix formatting

* Fix lint

* Check  if key in guild

* Bwck to guild a ailable

---------

Co-authored-by: Jake Morrison <jake.morrison@pinnsg.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-01-22 13:17:23 +00:00
Danial Raza
f48787eef1 docs(BaseInteraction): correct return type of member (#10096) 2024-01-22 11:40:13 +00:00
Qjuh
1431c18769 fix(website): search hanging on complex types (#10095) 2024-01-21 17:08:31 +00:00
Almeida
33674be85e feat(Webhook): allow setting appliedTags on send() (#10027)
* feat(Webhook): allow setting `appliedTags` on `send()`

* docs: fix grammar

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

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-01-15 22:29:49 +00:00
James
7e12bee337 docs: remove utf-8-validate (#10059)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2024-01-13 11:10:10 +00:00
codershiba
7b8e0debeb refactor(formatters): Add support for object and name param in formatEmoji() (#10076)
* feat: add support for name param and object in `formatEmoji()`

* Update formatters.ts

* refactor: swap priority

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2024-01-13 11:02:41 +00:00
Jiralite
136c66c213 build: Bump versions (#9986)
fix: bump versions

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-12-30 18:03:00 +00:00
Danial Raza
ce84d3efee fix(Gateway): Export interface (#10060)
* fix(types): export missing `Gateway` interface

* docs(Gateway): update link to `WebSocketManager`
2023-12-30 17:40:20 +00:00
Renegade334
4824ac154d docs(ThreadMember): fix docblock async return type (#10058) 2023-12-28 12:24:30 +00:00
Almeida
0f1e02b3dd fix(escape*): dont escape urls (#9958)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-12-24 16:16:33 +00:00
Almeida
c4fcee3ef6 feat: premium application subscriptions (#9907)
* feat: premium application subscriptions

* types: readonly array

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

* fix: requested changes

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

* fix: core client types

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-12-24 15:49:58 +00:00
iCrawl
520d6f64dd fix: nextjs unreliable params in route 2023-12-21 05:19:32 +01:00
iCrawl
1c3211a5fc fix: remove ppr from website for now 2023-12-21 04:39:14 +01:00
iCrawl
891a67ac4d fix: use proper api endpoint 2023-12-20 23:49:39 +01:00
iCrawl
7b5c31b2bc refactor: fetch versions on the client 2023-12-20 23:21:49 +01:00
iCrawl
d869d9b3fe style: fix up lint 2023-12-19 14:45:28 +01:00
iCrawl
171cb182ed chore: deps 2023-12-19 14:33:04 +01:00
Jiralite
db56324624 types(DirectoryChannel): Ensure directory channels cannot contain user mentions when stringified (#10043)
* types(DirectoryChannel): `ChannelMention` `toString()`

* refactor: dynamic test
2023-12-18 22:30:24 +00:00
Almeida
a000df624c chore: use double quotes for globs in scripts (#10032) 2023-12-18 18:14:15 +01:00
Danial Raza
6cd6e3baaf chore: use string values in vs code settings (#10028) 2023-12-18 18:13:55 +01:00
Qjuh
e43f96cec5 ci: always use the workflows from main branch (#10048) 2023-12-18 18:13:30 +01:00
Danial Raza
461948c07d fix: deprecate underscore in favor of underline (#10054)
* fix: deprecate `underscore` in favor of `underline`

* refactor: use `underline` in `underscore`

Co-authored-by: Almeida <github@almeidx.dev>

---------

Co-authored-by: Almeida <github@almeidx.dev>
2023-12-17 20:44:54 +00:00
advaith
1acc9abae2 types: change Awaitable<void> to void (#10017)
Co-authored-by: Almeida <almeidx@pm.me>
2023-12-17 13:54:21 +00:00
Jiralite
18c2dccd0e feat: Utilise create-discord-bot (#10013)
* feat: utilise create-discord-bot

* chore: hide line numbers

* feat: add intents page

* feat: add more Node.js variants

* refactor: redo page a bit

* fix: 👀

* chore: touch up introduction page

* chore: touch up what's new

* chore: touch up how to contribute

* chore: remove enforced locale

* chore: Fix typo

Co-authored-by: Danial Raza <danialrazafb@gmail.com>

* chore: commit suggestions

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

* chore: address improper capitalisation

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

* refactor: remove `applications.commands`

* refactor: remove unique comment

* fix(intents): remove shard comment

* docs(intents): add missing info

---------

Co-authored-by: Danial Raza <danialrazafb@gmail.com>
Co-authored-by: Souji <timoqueezle@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-12-14 21:15:27 +00:00
Qjuh
adfd9cd3b3 refactor: use interfaces for AsyncEventEmitter event maps (#10044)
* refactor: use interfaces for AsyncEventEmitter event maps

* refactor: apply suggestions from code review and add tests

* refactor: better errors on missing dispatch types
2023-12-14 16:09:13 +00:00
Qjuh
f2138bb5a8 ci: always generate docs with latest main ae (#10037) 2023-12-13 14:06:50 +01:00
Qjuh
651ffc2caf feat(website): more builtin docs links (#10030)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-12-10 14:06:09 +00:00
Vlad Frangu
319ef9a70b feat: use globally available WebSocket client in runtimes that have it (#10042) 2023-12-10 13:42:02 +00:00
Jiralite
8ace6face8 docs(CategoryCreateChannelOptions): Update reference (#10031)
docs(CategoryCreateChannelOptions): update reference

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-12-05 19:26:27 +00:00
Jiralite
e245a390e7 docs(resolvePartialEmoji): Add @internal to all overloads (#10033)
docs: add `@internal`
2023-12-05 19:19:52 +00:00
Jiralite
2b8ac35e56 refactor: Document relevant types as @internal (#9974)
* refactor: mark data resolver as internal

* docs: mark relevant TypeScript symbols as `@internal`

* docs: extra additions

* style: prefer at end

* docs: add more `@internal`s

* test: update template code
2023-12-05 18:15:08 +00:00
Danial Raza
62e31cb9ee fix(InteractionResponses): check if ephemeral message flag is used (#10021) 2023-12-04 20:16:26 +00:00
Ryan Munro
941642ad2f fix: replace internal calls to Emoji#url (#10025) 2023-12-03 22:53:02 +00:00
Jiralite
54453b04e5 chore(uploadDocumentation): Expose full error (#10012)
chore: expose full error

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-12-02 12:50:53 +00:00
Danial Raza
b992019a78 docs(PermissionOverwriteManager): PermissionsFlagsBit typo (#10004)
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-12-01 20:58:21 +00:00
Qjuh
17a6f5d3c9 types: omit unnecessary methods from <ContextMenuCommandInteraction>.options (#10003)
* types: omit getUser/Member/Message from ContextMenu interaction

* types: omit getAttachment and add tests

* fix: remove duplicate tests
2023-12-01 20:13:20 +00:00
Qjuh
a44ada661f feat(website): show union members of type aliases (#10001)
* feat(website): show union members of type aliases

* refactor: suggestions from code review

* Apply suggestions from code review

---------

Co-authored-by: Noel <buechler.noel@outlook.com>
2023-12-01 02:19:07 +01:00
Qjuh
b229240731 ci: documentation.yml refactor branch/tag check to one place only (#10008)
* ci: fix documentation manual dispatch run on tag

* ci: move conditional to env var

* fix: spacing
2023-12-01 02:12:36 +01:00
Qjuh
1ec2901f56 feat(website): type parameters on methods and overloads (#9998)
* feat(website): type parameters on methods and overloads

* refactor: add collapsible parameter list
2023-12-01 02:11:59 +01:00
Renegade334
179af387d0 refactor(ThreadMemberManager): #remove accepts UserResolvable (#10000)
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-12-01 00:35:59 +00:00
Vlad Frangu
e412a22ceb fix: export "ESM" types when discord.js is imported in ESM land (#10009)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-30 23:19:22 +00:00
Jiralite
30f6a5fc56 types(InteractionWebhook): Add client (#9997)
types(InteractionWebhook): add `client`

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-30 21:48:54 +00:00
brynpttrsn
cbbbfb9823 fix(website): serialize methods with overload index (#10005)
fix: add overload index to methods
2023-11-30 22:43:43 +01:00
Qjuh
fe90487974 ci: fix documentation manual dispatch run on tag (#10007) 2023-11-30 22:41:55 +01:00
Noel
d0aa8d25e2 ci: fix deploy-website 2023-11-24 12:23:31 +01:00
Qjuh
bc2ecef73d fix: cross package links again (#9995) 2023-11-24 12:10:16 +01:00
Qjuh
9fdbf0ad65 fix(website): doc links to other packages (#9994)
* fix(website): doc links to other packages

* fix: missing parameter

* Apply suggestions from code review

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

---------

Co-authored-by: Almeida <almeidx@pm.me>
2023-11-22 19:06:13 +01:00
Qjuh
57c414be21 fix(website): discord-api-types links, URL links and some minor doc issues (#9990)
* fix(website): correctly link to discord-api-types in link tags

* fix: url links and some minor doc issues

* fix: unneeded import

* fix: another unneccessary import

* fix: several linting issues

* refactor: simplify ApiItemLike interface

* refactor: apply suggestions

* fix: missing newline in docComment

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-22 08:26:43 +00:00
Jiralite
e9ff99101b docs: Remove hyphen after @returns (#9989)
docs: remove hyphen after `@returns`

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-21 17:16:51 +00:00
Qjuh
3d1c884926 refactor(website): remove unneccessary addPackageToModel function (#9983)
* types: fix links in @deprecated tags

* Merge branch 'main' into fix/deprecated-links-d.ts

* fix: searchIndices

* refactor: apply review suggestions

* refactor: remove addPackageToModel function

* fix: event links in search index

* fix: wrong overload condition
2023-11-21 10:06:13 +01:00
Rahul Mishra
ce0be392d8 fix(Bun): Fix typo for Bun template (#9987)
fix(create-discord-bot): Fix typo for Bun Template which caused install errors
2023-11-18 16:58:33 +00:00
Qjuh
802ec63a48 fix(website): cross package deprecated links (#9981)
* refactor: minify api.json by shortening keys

* fix: links to other packages

* refactor: get doclink from canonicalReference, not model

* fix: types

* fix: again

* fix: @link tags with alt texts

* fix(website): cross-package links in @deprecated
2023-11-18 11:45:32 +01:00
Qjuh
5a715706df fix(website): search index generation (#9980)
* types: fix links in @deprecated tags

* Merge branch 'main' into fix/deprecated-links-d.ts

* fix: searchIndices

* refactor: apply review suggestions
2023-11-18 10:44:06 +00:00
Vlad Frangu
ae58053dc8 chore: release @discordjs/rest@2.2.0 & @discordjs/core@1.1.1 (#9978)
* chore(rest): release @discordjs/rest@2.2.0

* chore(core): release @discordjs/core@1.1.1

* chore: at this point might as well hand write
2023-11-18 00:01:40 +00:00
Jiralite
5da5be2bc9 fix(route): Conditionally prefix package names (#9975)
fix(route): conditionally prefix package names
2023-11-17 23:38:49 +01:00
Noel
55be1c901a ci: properly extract name from minified docs files 2023-11-17 23:37:14 +01:00
Qjuh
492f86af39 refactor: minify api.json by shortening keys (#9971)
* refactor: minify api.json by shortening keys

* fix: links to other packages

* refactor: get doclink from canonicalReference, not model

* fix: types

* fix: again

* fix: @link tags with alt texts
2023-11-17 23:26:48 +01:00
Qjuh
9868772b64 docs: fix links in @deprecated tags (#9976)
types: fix links in @deprecated tags
2023-11-17 20:44:39 +00:00
Vlad Frangu
6df233de14 feat: present x-ratelimit-scope for 429s hit (#9973)
* feat: present x-ratelimit-scope for 429s hit

* fix: get scope from headers for burst too
2023-11-16 10:49:05 +00:00
Qjuh
0aa7dc1b86 fix: replace Object< with Record< (#9970) 2023-11-15 20:20:21 +01:00
Qjuh
cab60142ff fix: type mapping for docgen methods/props (#9969)
* fix: minify mainlib docs json

* fix: minify them all

* fix: type mapping for docgen methods/props
2023-11-14 20:54:29 +00:00
Qjuh
4b88306dcb fix: minify mainlib docs json (#9963)
* fix: minify mainlib docs json

* fix: minify them all
2023-11-14 09:13:28 +01:00
iCrawl
f9177be61b fix: don't hardcode discordjs special case 2023-11-14 02:04:02 +01:00
iCrawl
75137bac6f refactor: don't prebuild on preview builds 2023-11-14 01:55:08 +01:00
iCrawl
00063912ee fix: conflict resolution 2023-11-14 01:35:08 +01:00
iCrawl
8f432400d8 build: multi-config build and dep update 2023-11-14 01:26:22 +01:00
iCrawl
75fc7f2454 ci: include secret 2023-11-13 23:21:35 +01:00
iCrawl
01c63d2e0f refactor: switch to vercel blob for docs 2023-11-13 23:15:16 +01:00
iCrawl
ffc3ea5c3f fix: hardcode redirect for main lib for now 2023-11-13 21:37:59 +01:00
iCrawl
1d2d01e1f5 ci: dont set the ci to failed on fail to upload docs 2023-11-13 21:31:46 +01:00
iCrawl
0063dae43b fix: use correct pkg variable 2023-11-13 21:30:05 +01:00
iCrawl
69c949ab28 fix: properly switch versions 2023-11-13 21:17:42 +01:00
iCrawl
25d552b318 fix: missing on conflict clause 2023-11-13 21:09:43 +01:00
iCrawl
c4767bacde refactor: switch to vercel pg 2023-11-13 21:07:01 +01:00
iCrawl
9a8110047e fix: cache nextjs cache output with turbo 2023-11-13 19:55:08 +01:00
iCrawl
d4ebc369ca fix: dont cache nextjs cache 2023-11-13 19:31:55 +01:00
iCrawl
b150d4ac27 fix: provide full path for pre-gen 2023-11-13 19:19:26 +01:00
iCrawl
81a892e27f fix: properly create index 2023-11-13 19:13:32 +01:00
iCrawl
bc8f83368a feat: reintroduce outline navigation 2023-11-13 18:03:23 +01:00
Qjuh
7c935dc84b feat: docs for mixin methods, examples (#9960) 2023-11-13 15:03:47 +01:00
iCrawl
8d04cbc203 chore: add loading page for suspense 2023-11-13 11:23:59 +01:00
iCrawl
356cadb382 chore: enable prefetch 2023-11-13 11:07:47 +01:00
iCrawl
978a39f6d3 chore: disable prefetch 2023-11-13 10:48:51 +01:00
iCrawl
516be87a87 fix: properly display all versions in selector 2023-11-13 10:22:44 +01:00
Qjuh
b79351ba99 fix(website): misc improvements (#9940)
* refactor: use tokenRange for typeParams in heritage

* fix: correct type param replacement

* fix: ae config, link builtin in summary, `: | T` => `: T`, mainlib tsdoc

* fix: requested changes and tests

* chore: better deprecation messages and code cleanup

* fix: cleanup optional chainings

---------

Co-authored-by: Almeida <almeidx@pm.me>
2023-11-13 09:55:23 +01:00
iCrawl
2d63d93558 ci: add readmes to build output for cache 2023-11-13 00:17:43 +01:00
iCrawl
b305194841 ci: revert deploying vercel with ci for now 2023-11-13 00:12:37 +01:00
Vlad Frangu
2550c7931d chore(discord.js): release discord.js@14.14.1 (#9957)
* chore(discord.js): release discord.js@14.14.1

* chore: actual changelog
2023-11-12 22:06:14 +00:00
Almeida
40726db722 refactor: use formatters (#9956)
* refactor: use formatters

* fix: imports

* fix: imports pt.2

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-12 21:56:10 +00:00
Aura
1e4ef35436 docs: use preferred nullable syntax (?T over T | null) (#9946)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-12 21:45:02 +00:00
Aura
4bc1dae36f types: use wrapper utilities (#9945)
* types: use `Awaitable<T>` instead of `Promise<T> | T`

* types: use `JSONEncodable<T>` over raw definition

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-12 21:40:59 +00:00
Almeida
cc07a28f12 fix(Emoji): id set as undefined edge case (#9953) 2023-11-12 21:34:24 +00:00
Jiralite
f93abf7e35 fix(BaseClient): Default in objects properly (#9952)
fix(BaseClient): default in objects properly
2023-11-12 21:14:09 +00:00
Jiralite
f0ec70dfda feat: bump package versions (#9951)
* feat: bump package versions

* chore(create-discord-bot): release create-discord-bot@0.2.3

---------

Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
2023-11-12 20:22:55 +00:00
Jaw0r3k
8a6045f600 fix: import picocolors as default (#9949) 2023-11-12 19:39:08 +00:00
Vlad Frangu
418032ae1f chore(ci): fix release workflow (#9947) 2023-11-12 19:12:13 +00:00
Vlad Frangu
dbb92e5bc4 chore(releases): release party (#9943)
* chore(brokers): release @discordjs/brokers@0.2.3

* chore(collection): release @discordjs/collection@2.0.0

* chore(formatters): release @discordjs/formatters@0.4.0

* chore(util): release @discordjs/util@1.0.2

* chore(voice): release @discordjs/voice@0.16.1

* chore(builders): release @discordjs/builders@1.7.0

* chore(rest): release @discordjs/rest@2.1.0

* chore(proxy): release @discordjs/proxy@2.0.2

* chore(ws): release @discordjs/ws@1.0.2

* chore(core): release @discordjs/core@1.1.0

* chore(discord.js): release discord.js@14.14.0

* chore: small borked changelogs

* chore(create-discord-bot): release create-discord-bot@0.2.2

* chore: bork

* chore: fix wrong bump

* chore: git cliff pls
2023-11-12 18:11:58 +00:00
Almeida
975d5f18ae chore: use descriptive type parameter names (#9937)
* chore: use descriptive type parameter names

* refactor: requested changes

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-12 17:21:51 +00:00
Jaw0r3k
4ff3ea4a1b feat: default select menu values (#9867)
* feat: default select menu values

* feat(Message): support

* fix: fix crashes when an array is supplied and remove assertion

* docs(transformResolved): `BaseChannel` is the correct type

* refactor: prefer assignment

* chore: export function again

* fix(Util): fix circular dependency

* refactor(MentionableSelectMenu): clone in method

* docs: remove semicolon

* feat(MentionableSelectMenu): add `addDefaultValues()`

* refactor: reduce overhead

* types: adjust `channel`

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-11-12 16:32:41 +00:00
Jiralite
b5e23ec2ec fix(Client): Ensure destroyed connections are not ready (#9942)
* fix(Client): ensure destroyed connections are not ready

* refactor(Client): prefer `!`

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

---------

Co-authored-by: Aura <kyradiscord@gmail.com>
2023-11-12 16:06:42 +00:00
Vlad Frangu
81e7866903 feat: expose Retry-After and sublimit timeouts in RatelimitData (#9864)
* feat: expose Retry-After and sublimit timeouts in RatelimitData

* chore: better docs?

* Apply suggestions from code review

Co-authored-by: ckohen <chaikohen@gmail.com>

---------

Co-authored-by: ckohen <chaikohen@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-12 14:36:12 +00:00
iCrawl
62e6573296 fix(website): caching and revalidation 2023-11-11 21:05:25 +01:00
David Malchin
cf49f405b0 fix(REST): strip webhook tokens (#9723)
* fix(REST): strip webhook tokens

* fix(REST): implement requested changes

Co-authored-by: ckohen <chaikohen@gmail.com>

---------

Co-authored-by: ckohen <chaikohen@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-11 18:31:39 +00:00
iCrawl
2a25eeaf13 chore: remove nextjs patch 2023-11-11 19:19:14 +01:00
Qjuh
5a4c9755c3 feat(api-extractor): replace type parameters with their actual values on inherited members (#9939)
* refactor: use tokenRange for typeParams in heritage

* fix: correct type param replacement
2023-11-11 15:18:08 +01:00
Aura
5b0aa92c81 refactor(utils): remove mergeDefault (#9938)
* refactor(utils): remove `mergeDefault`

`BaseClient` and `ShardingManager` not longer mutate options

* refactor(ShardingManager): avoid reassigning method argument
2023-11-11 09:50:50 +00:00
Almeida
d28814d869 fix: properly support multiple extends/implements (#9934)
* fix: properly support multiple extends/implements

* refactor: use flexbox instead of space util

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

---------

Co-authored-by: Noel <buechler.noel@outlook.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-10 22:01:30 +00:00
Almeida
ff24bc5729 build: rerun docs scripts on changes to api-extractor packages (#9935)
* build: rerun docs scripts on changes to api-extractor-*

* refactor: requested changes

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

---------

Co-authored-by: Noel <buechler.noel@outlook.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-10 17:42:55 +00:00
Almeida
81334a2a2c feat: link basic types to MDN/TS documentation (#9913)
* feat: link basic types to MDN/TS documentation

* refactor: requested changes
2023-11-10 14:50:25 +00:00
Almeida
6dca8013af chore: remove parameter list from events (#9933) 2023-11-09 00:38:13 +01:00
Suneet Tipirneni
a87b267fba fix: treat primitives as references instead of content (#9932)
* fix: treat primitives as references instead of content

* chore: add typeof keyword

* fix: add missing keywords
2023-11-09 00:37:50 +01:00
iCrawl
aad82f088b build: fix the messy dependency graph 2023-11-09 00:13:01 +01:00
iCrawl
e5f3f3130e fix: path generation for search 2023-11-08 19:01:32 +01:00
iCrawl
4a5e9fc1de fix: pin source-map dependency and clean up website 2023-11-08 18:43:02 +01:00
iCrawl
e72b552ae2 chore: remaining deps and lighthouse removal 2023-11-08 18:20:16 +01:00
iCrawl
34d0224b68 refactor: display readme correctly 2023-11-08 14:49:28 +01:00
iCrawl
fcfe5cf142 refactor: remove banner 2023-11-08 13:51:51 +01:00
iCrawl
fb2e7a0aac ci: correctly apply permissions 2023-11-08 13:36:55 +01:00
iCrawl
4575e49ea1 ci: deploy on vercel again 2023-11-08 13:27:04 +01:00
iCrawl
2bda883a0f fix: handle older generated docs better 2023-11-08 12:30:32 +01:00
Almeida
fffe70a039 feat(Client): AsyncIterator-returning method for fetching members (#9771)
* feat(Client): AsyncIterator-returning method for fetching members

* fix: requested changes

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-11-08 10:43:15 +00:00
iCrawl
413d6d67c5 ci: separate website deploy 2023-11-08 10:38:44 +01:00
Qjuh
da455bceea feat: mainlib docs on new website (#9930)
* fix(ExceptText): don't display import("d..-types/v10"). in return type

* Squashed 'packages/api-extractor-model/' content from commit 39ecb196c

git-subtree-dir: packages/api-extractor-model
git-subtree-split: 39ecb196ca210bdf84ba6c9cadb1bb93571849d7

* Squashed 'packages/api-extractor/' content from commit 341ad6c51

git-subtree-dir: packages/api-extractor
git-subtree-split: 341ad6c51b01656d4f73b74ad4bdb3095f9262c4

* feat(api-extractor): add api-extractor and -model

* fix: package.json docs script

* fix(SourcLink): use <> instead of function syntax

* fix: make packages private

* fix: rest params showing in docs, added labels

* fix: missed two files

* feat: merge docs.json from docgen and docs.api.json

* fix: cpy-cli & pnpm-lock

* fix: increase icon size

* fix: icon size again

* feat: run both docs on mainlib

* chore: website fixes

* fix: more website fixes

* fix: tests and dev database script

* chore: comment out old docs

* fix: increase max fetch cache

* fix: env should always be a string

* fix: try to reapply patches

* fix: remove prepare for docgen

* fix: temporary cosmetic fixes

* fix: horizontal scroll

* feat: generate index for new docs

---------

Co-authored-by: Noel <buechler.noel@outlook.com>
2023-11-08 10:16:54 +01:00
iCrawl
f713e47b0a fix: gracefully handle no docs 2023-11-08 03:23:51 +01:00
Neutron
defeee5eec feat: return entries instead of values in toJSON method (#9345)
* feat(collection): return entries instead of values in toJSON method

* test: adjust test

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-08 01:28:27 +00:00
iCrawl
67a2538b4d fix: handle errors gracefully 2023-11-08 02:22:51 +01:00
iCrawl
7208d69c05 ci: rename github deployment env 2023-11-08 02:04:22 +01:00
iCrawl
6b9f906b03 chore: properly rename folder 2023-11-08 00:44:39 +01:00
iCrawl
347df4e083 chore: typo 2023-11-08 00:38:35 +01:00
iCrawl
ee2afb0aae chore: update engine field in packages & deploy website manually 2023-11-08 00:25:38 +01:00
Qjuh
5c0fad3b2d build: package api-extractor and -model (#9920)
* fix(ExceptText): don't display import("d..-types/v10"). in return type

* Squashed 'packages/api-extractor-model/' content from commit 39ecb196c

git-subtree-dir: packages/api-extractor-model
git-subtree-split: 39ecb196ca210bdf84ba6c9cadb1bb93571849d7

* Squashed 'packages/api-extractor/' content from commit 341ad6c51

git-subtree-dir: packages/api-extractor
git-subtree-split: 341ad6c51b01656d4f73b74ad4bdb3095f9262c4

* feat(api-extractor): add api-extractor and -model

* fix: package.json docs script

* fix(SourcLink): use <> instead of function syntax

* fix: make packages private

* fix: rest params showing in docs, added labels

* fix: missed two files

* fix: cpy-cli & pnpm-lock

* fix: increase icon size

* fix: icon size again
2023-11-07 21:53:36 +01:00
Almeida
95c0b1a59f chore: pin @discordjs/collection version in discord.js (#9929) 2023-11-07 19:32:04 +01:00
Almeida
65966ae6ec feat: align some methods with the Change By Copy proposal (#9207)
BREAKING CHANGE: The `sorted` method has been renamed to `toSorted`
2023-11-07 18:26:48 +00:00
Almeida
3b8df63a5a feat: align some methods with the Set Methods proposal (#8890)
feat(collection): align/add methods with/from Set Methods proposal

BREAKING CHANGE: The `intersect` method has been renamed to `intersection`
BREAKING CHANGE: The `difference` method has been renamed to `symmetricDifference`
BREAKING CHANGE: The `subtract` method has been renamed to `difference`
2023-11-07 18:04:51 +00:00
Jaw0r3k
054eaec7d7 fix: update broken links (#9926)
fix: update some links

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-11-07 17:51:10 +00:00
iCrawl
c8227ca533 build(scripts): send correct data to meilisearch 2023-11-07 16:48:02 +01:00
iCrawl
1eee9dc257 build(scripts): use correct env vars 2023-11-07 16:44:08 +01:00
iCrawl
6a6c4bdcae build: make sure to cache bust tsup config changes in all packages 2023-11-07 16:41:15 +01:00
iCrawl
c39c94374a ci: fix building upload search indicies action 2023-11-07 16:27:07 +01:00
iCrawl
792840bae6 ci: update search with github actions 2023-11-07 16:22:17 +01:00
iCrawl
009c0a3bae refactor: use planetscale instead of custom api 2023-11-07 15:08:03 +01:00
iCrawl
344a3f9344 chore: @types/node and unocss fix 2023-11-06 23:55:13 +01:00
iCrawl
a1abc6b273 chore: fixup eslint 2023-11-06 22:29:20 +01:00
iCrawl
4f4dde2a09 chore: regen pnpm lock and patch itemLink component 2023-11-06 22:17:07 +01:00
iCrawl
0ca0254d83 chore: upgrade to nextjs canary 2023-11-06 21:49:58 +01:00
iCrawl
6cd3adf030 chore: update deps 2023-11-06 21:38:45 +01:00
Jacob Morrison
637e1a4ddb refactor: Move getNode/canEnableFFmpegOptimizations into a lazy loaded call (#9918)
* Move the getNode/canEnableFFMPEGOptimizations into a lazy loaded call the first time it's actually ever referenced

* PR feedback: Make initializeNodes return a map then nullably assign NODES, this removes an extra variable and cleans up the code

* chore: lint suggestion

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

* Use local map instead of recursive

* Run prettier

* Fix lint

---------

Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: Aura Román <kyradiscord@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-06 09:17:19 +00:00
Jaw0r3k
ac645084f0 feat: support findLast and reduceRight methods (#9573)
* feat(collection): findLast and reverseRight

* chore(collection): performance and tests change

Co-authored-by: kyra <kyradiscord@gmail.com>

* remove unnecessary code

* Update packages/collection/src/collection.ts

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

* Apply suggestions from code review

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

---------

Co-authored-by: kyra <kyradiscord@gmail.com>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-11-05 18:49:53 +00:00
Kin
c051ed9427 feat: add guild member (#9877)
* feat: add guild member

* slightly change the description for the guildId and userId parameters in the addMember function

* fix description syntax

* Update packages/core/src/api/guild.ts

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

* add jsdoc for options param

* fix formatting

* add missed semicolon

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

* style: prettier

---------

Co-authored-by: Jaw0r3k <jaworekwiadomosci@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-11-05 18:42:17 +00:00
Jaw0r3k
c2349d4be4 feat(cleanContent): add slash commands and emojis (#9809)
* feat(cleanContent): add missing commands and emojis

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

* fix: check for every possible name

* fix: use non capturing group

---------

Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-05 18:36:16 +00:00
Aura Román
31d914e44b fix(Webhook): do not call client.deleteWebhook in delete (#9786)
* fix(Webhook): do not call `client.deleteWebhook` in `delete`

Partially reverts #9777 which caused a regression (#9785) when using `WebhookClient`

* chore: add comment

Co-Authored-By: Souji <timoqueezle@gmail.com>

* fix: move `deleteWebhook` from `Client` to `BaseClient`

---------

Co-authored-by: Souji <timoqueezle@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-05 18:23:32 +00:00
Almeida
efbcda70fc docs: remove markdown (#9914)
docs(formatters): remove markdown

The documentation website does not support rendering markdown

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-05 18:18:23 +00:00
Jiralite
b6c762cb84 feat(Emoji): Add imageURL() (#9788)
feat(Emoji): add `imageURL()`
2023-11-05 18:01:45 +00:00
dank
85a78f96d4 docs(Message): remove duplicated word 'of' in description (#9923)
fix(Message): remove duplicated word 'of' in description

This commit removes the secondary 'of' in the description for the Message structure. This doesn't change anything drastically in terms of the actual code as it's just a JSDoc comment.

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-11-04 22:47:52 +00:00
Synbulat Biishev
85753a9d6f fix(GuildManager#fetch): inject shard id (#9921) 2023-11-04 22:43:11 +00:00
Jiralite
a9e1f6026c fix: Add extension (#9900)
fix: add extension
2023-11-01 16:10:15 +01:00
Almeida
e80194e3fb build: bump discord-api-types (#9908) 2023-10-23 13:09:35 +00:00
Renegade334
0e0b85b766 fix: prevent 'undefined' debug message on intentional shard closure (#9846)
* style: prevent 'undefined' debug message on intentional shard closure

addresses #9594

* refactor(WebSocketManager#destroy): improve debug messaging

cleaner stacktrace format
gracefully closing shards will display an appropriate debug `reason`

* style: unresumable debug messaging

---------

Co-authored-by: Almeida <almeidx@pm.me>
2023-10-21 13:53:41 +00:00
Jiralite
5b4a51945c build: Bump dependencies (#9899)
build: bump dependencies

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-17 20:47:47 +00:00
Almeida
7671a836f4 feat: onboarding mode and edit method (#9647)
* feat: onboarding mode and edit method

* feat(guild): add `editOnboarding`

* fix: use discord-api-types

* types: make arrays readonly

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

* fix: bring up to date

* docs: id is a snowflake

* fix: requested changes

* refactor: make most options optional

* refactor: provide GuildEmoji or Emoji instance

* revert: changes to Util

* fix: rebase leftovers

* fix: allow passing option id

* fix: requested changes

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-17 19:30:10 +00:00
Jiralite
e307581442 ci(labels): Use strings in values (#9883)
ci: quote needed `color`s
2023-10-17 18:16:57 +02:00
Jiralite
77be0f0f2d build: Fix create-package script (#9882)
build: fix create-package script
2023-10-17 18:16:21 +02:00
Bartek Szopka
e38d03fbe7 docs(GuildMember): clarify display color (#9891) 2023-10-17 15:52:31 +00:00
Nick
6a63c441fe fix: forward x-audit-log-reason header (#9889)
fix(proxy): forward x-audit-log-reason header
2023-10-16 05:10:19 +00:00
synicalsyntax
8964504d07 fix(website): generate right dapi-types URLs for enum members (#9865)
Fixes #9780

Co-authored-by: syn <hi@syn.gay>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-10-14 19:54:11 +00:00
Jiralite
7276e7c4b7 build: Fix search_indices script (#9869)
build: fix search_indicies script

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-10 14:14:41 +00:00
Jiralite
8cfadb6953 docs: Remove duplicate APIEmoji (#9880)
* types: remove duplicate type definition

* chore: add `Emoji` to method

* types(resolvePartialEmoji): overload method
2023-10-10 13:44:21 +00:00
Jan Parisek
7422d9f172 types(Partials): add toString() method to supported Partials (#9835)
* types(Partials): add toString() method to supported Partials

- includes `PartialDMChannel`, `PartialGuildMember` and `PartialUser`
- does not include
    - `PartialMessage`, since `<PartialMessage>.content` is always null
    - `PartialMessageReaction`, since `MessageReaction` has no `toString()` method
    - `PartialThreadMember`, since `ThreadMember` has no `toString()` method

* types(Partials): replace type of `toString()` methods with return type

* test(Partials): add tests

* types(Partialize): refactor Partialize

* test(PartialThreadMember): fix typo

* types(Partials): clean up unnecessary type overrides

* test(Partials): add tests for <Partials>.partial property

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-10-10 13:39:28 +00:00
Jiralite
1fe7247528 feat: Support new application properties and patch endpoint (#9709)
* feat: support new application endpoints

* chore: edit comment

* fix(ClientApplication): handle flags properly

* types: `readonly`

* chore: update route

* feat: add to core

* refactor(ClientApplication): add to user manager

* chore: remove comments

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-10 13:25:26 +00:00
Jiralite
44a3cbf39e docs: Consolidate API types (#9881)
docs: deduplicate API types

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-10 13:22:02 +00:00
Jiralite
332b624aed docs(stickers): Reveal link in the website (#9870)
docs(stickers): reveal link

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-10 13:19:52 +00:00
cobalt
699b232922 feat(BaseChannel): Add isThreadOnly() (#9847)
* add isThreadBased

* Update typings

* fix name

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-10 13:13:57 +00:00
Danial Raza
11f6955ed9 refactor: use proper variable names in callbacks (#9840)
* refactor: use proper variable names in callbacks

* refactor: change parameter names

* refactor: change remaining parameter names

* refactor: change remaining variable names

* refactor(GuildAuditLogsEntry): abstract reduce logic into a new function

* chore: undo unrelated changes

This undoes commit b2d93dce51 as it's unrelated

* refactor: more name changes

* chore: fix tests failing

* refactor: use option instead of opt

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-10-09 19:49:49 +00:00
Jiralite
2aa3250584 types(MessageEditOptions): Correct attachments type (#9874)
types(MessageEditOptions): fix `attachments` type

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-09 07:18:41 +00:00
Jiralite
ec47e72b41 ci: Use non-deprecated output parameters (#9878)
ci: update to output parameters
2023-10-07 23:35:11 +02:00
Jiralite
e1edba17c4 build: Bump discord-api-types to 0.37.60 (#9876)
build: bump discord-api-types

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-07 16:17:12 +00:00
Vlad Frangu
0529b2af95 fix(Role): calculate position correctly when rawPositions are equal (#9871)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-10-07 16:14:22 +00:00
Eray
f58628385c fix: update module to NodeNext in tsconfig.json (#9875)
an error was occurring due to the module resolution :3
2023-10-07 16:07:16 +00:00
Jiralite
a674989fe2 docs(collection): Minor article additions (#9868)
docs(collection): add articles
2023-10-04 04:43:23 +00:00
Jiralite
cd987b592b chore: No identifier base in development versions (#9848)
feat: no identifier base in development versions
2023-10-03 19:24:13 +00:00
Jiralite
ec63818bcf build: Disable import/extensions (#9849)
build: update eslint-config-neon
2023-10-03 21:01:31 +02:00
Jiralite
3e516e6e9b build: Bump discord-api-types to 0.37.59 (#9854)
build: bump discord-api-types
2023-10-03 20:06:22 +02:00
Jaw0r3k
5aeb6e1ae6 ci: Disable publishing multiple dev versions under the same commit (#9740)
* chore: disable publishing mutliple versions

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

* Update .github/workflows/publish-dev.yml

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

* fix: commit suggestion

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

* chore: add suggested changes

* style: add back line

---------

Co-authored-by: RedGuy12 <61329810+RedGuy12@users.noreply.github.com>
Co-authored-by: Rodrigo Leitão <38259440+ImRodry@users.noreply.github.com>
Co-authored-by: Aura Román <kyradiscord@gmail.com>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-10-03 20:05:22 +02:00
DD
93e5bed87d chore: update license files (#9862) 2023-09-30 00:42:43 +00:00
Jiralite
3c043d83a9 types(UserContextMenuCommandInteraction): Nullify targetMember (#9844)
types(UserContextMenuCommandInteraction): nullify `targetMember`

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-09-29 16:14:36 +00:00
Almeida
931c3ed593 feat(StageInstanceManager): add guildScheduledEvent to create() (#8885)
* feat(StageInstanceManager): add `guildScheduledEvent` to `create()`

* fix: requested changes

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-09-28 18:27:15 +00:00
Jiralite
eaabcdfda6 docs: Remove FileOptions (#9855)
docs: remove `FileOptions`
2023-09-26 19:44:09 +00:00
Danial Raza
19ea0baa00 refactor(GuildAuditLogsEntry): abstract reduce logic into a new function (#9845) 2023-09-23 22:40:45 +00:00
Jiralite
1e5c14b741 feat: Support default_thread_rate_limit_per_user in channel creation (#9273)
feat: support `default_thread_rate_limit_per_user` in channel creation
2023-09-19 18:11:46 +00:00
Jiralite
ec3bcb93a5 ci(publish-release): Use correct environment variable (#9838)
ci(publish-release): use correct environment variable for pnpm

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-09-19 17:49:51 +00:00
Jiralite
5a7b5b56ae ci: Deprecate step after publish & standalone file (#9837)
* ci: deprecate step after publish & standalone file

* docs: update contributing file

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-09-19 17:47:50 +00:00
Almeida
5bdb34b3be docs: remove broken markdown links (#9822)
chore: remove broken markdown links to documentation

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-09-18 15:24:49 +00:00
Jiralite
571aedd58a feat: Add media channels (#9662)
* feat: add media channels

* refactor: rename to `ThreadOnlyChannel`

* feat: support media channels more

* docs(ThreadOnlyChannel): update class description

* types: update references

* test: add more tests

* chore: update code

* refactor: `abstract`

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

---------

Co-authored-by: space <spaceeec@yahoo.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-09-18 07:35:47 +00:00
Jiralite
e02a59bbb6 refactor: Stickers are free (no more "premium" packs) (#9791)
refactor: stickers are free

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-09-18 07:29:47 +00:00
Jiralite
32d614ccd3 fix(GuildScheduledEvent): Use if...else pattern and handle partials (#9802)
fix: handle partial case

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-09-18 07:26:22 +00:00
Jiralite
4588e075c3 docs(DiscordjsErrorCodes): Deprecate unused properties (#9790)
docs(DiscordjsErrorCodes): deprecate unused properties

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-09-17 21:52:38 +00:00
Jiralite
b6a2441819 feat: Support widget image URL (#9782)
* feat: add widget image URL

* docs(GuildManager): correct parameter type

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

---------

Co-authored-by: space <spaceeec@yahoo.com>
2023-09-17 18:26:47 +00:00
Souji
310979808e feat(GuildAuditLogsEntry): expose extra integrationType in relevant log types (#9796)
* feat(GuildAuditLogsEntry): expose ingrationType

* fix: not optional, if extra is present on these types

not necessary, as it is conditionally assigned

* fix: remove non-extra approach

* fix(types): string is not guaranteed to be the known enum

* fix: adapt type tests to new extra properties

* fix: include null in type, since extra is not always populated

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-09-17 09:47:46 +00:00
Jaw0r3k
ed14135844 docs(ApplicationCommandManager): id parameter can take options (#9664)
* docs: mention about possible options

* chore: add suggested changes

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

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-09-17 09:42:36 +00:00
Danial Raza
85b24988a5 docs(Attachment): add MIME types link to contentType (#9824)
* docs(Attachment): add MIME types link to contentType

* docs: don't force locale

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-09-17 09:37:55 +00:00
Jiralite
7cdfc6c72a ci: Modify environment variable to fix development releases (#9826)
* ci: fix development releases

* build: remove .yarnrc.yml
2023-09-16 21:53:49 +02:00
Danial Raza
c66636da11 feat: add support for teams update (#9805)
* refactor(TeamMember): deprecate permissions property

* feat: add support for team member roles

* feat: add reference to external team member role enum

* docs: suggested changes

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

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-09-15 18:18:33 +00:00
Superchupu
9dbc9542c4 types: don't include dom types (#9831)
* types: don't include dom types

* types: try to fix websocket imports
2023-09-11 19:59:36 +00:00
DD
e68ab167c2 fix(WebSocketManager): available sessions check (#9823)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-09-10 12:42:38 +00:00
n1ck_pro
6404c013e7 types(Client): fix isReady narrowing (#9828)
* types(Client): fix isReady narrowing

* chore: add requested changes

* chore: test both ready cases

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-09-10 11:49:00 +00:00
Jiralite
c50809e206 docs: Fix "its" typo (#9825)
docs: fix "its" typo
2023-09-09 18:20:15 +00:00
Jeremy Rifkin
8d97e2d2c5 docs(GuildMember): Clarify timeout parameter wording (#9800)
* Update GuildMember.js

* Update GuildMember.js

* Update GuildMember.js

* Update GuildMember.js

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-09-08 07:33:09 +00:00
DD
ff1fda7b59 ci: fix npm dev release workflow (#9817)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-09-02 11:06:54 +00:00
Jiralite
ba31972d86 build: Bump discord-api-types to 0.37.56 (#9815)
build: bump discord-api-types to 0.37.56

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-09-02 11:04:25 +00:00
Jiralite
778df45166 feat(CDN): Support emoji size (#9787)
* feat(CDN): support emoji size

* refactor: try to warn in all environments

* feat: add prefix

* refactor: better feedback message

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-09-02 09:56:09 +00:00
Jiralite
23a6424261 docs(ApplicationsAPI): Fix getCurrent() options description (#9816)
docs(ApplicationsAPI): fix `getCurrent()` options description
2023-08-31 18:21:52 +00:00
Colin McDonnell
7157748fe3 docs(create-discord-bot): support bun in create-discord-bot (#9798) 2023-08-28 09:36:26 +02:00
Jiralite
85d03a3000 ci: Stop documentation upload for create-discord-bot (#9781)
ci: stop documentation upload for create-discord-bot
2023-08-28 09:34:38 +02:00
iCrawl
e1ae7b4d57 chore(create-discord-bot): disable eslint rule for ts 2023-08-27 21:08:42 +02:00
Noel
e96a8a977f build: pnpm (#9806) 2023-08-27 20:24:03 +02:00
Jaw0r3k
8325fa6540 feat: Add no-install option (#9604)
* chore: no install option + fix type

* chore: apply suggestions

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

---------

Co-authored-by: Jaw0r3k <jaw0r3k.git@gmail.com>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-08-26 21:31:22 +00:00
Souji
485dd718c5 feat(Presence): Expose sync_id in Activity (#9766)
* feat(Presence): Expose sync_id in Activity

* chore: mention non-documentation

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-08-25 19:53:53 +00:00
Almeida
566d5e2c81 feat(formatters): add guild navigation mentions (#9436)
* feat(formatters): add guild navigation mentions

* docs: dont force support article locale

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

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-08-25 12:01:58 +00:00
Danial Raza
0d787e9f79 feat: add new markdown formatters (#9613)
* feat: add new markdown formatters

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

* Update packages/formatters/src/formatters.ts

Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>

* refactor: remove unnecessary index tracking and rename 'array' to 'items'

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

* refactor: rename 'array' to 'items'

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

* refactor(heading): consolidate heading functions into a single function

Also correct param names from array to items.

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

* refactor: add HeadingLevel enum and use switch case

* fix: export HeadingLevel enum

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

* feat(heading): add missing documentation for level parameter

* refactor: update list formatters

* docs: correct heading formatter description

* refactor: update list formatters

* fix(heading): remove unnecessary space

* refactor: move list callback function to outer scope

* test: add tests

* refactor: requested changes

* refactor: suggested changes

* docs: add missing documentation

* style: suggested change

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

* refactor: use math max method instead

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

---------

Co-authored-by: Jaw0r3k <jaw0r3k.g@gmail.com>
Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>
Co-authored-by: Almeida <almeidx@pm.me>
Co-authored-by: Jaw0r3k <jaworekwiadomosci@gmail.com>
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: space <spaceeec@yahoo.com>
2023-08-25 10:06:13 +00:00
Jiralite
50106c77db feat: Implement GET current application (#9797)
* feat: implement current application route

* refactor: pluralisation

Co-authored-by: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com>

---------

Co-authored-by: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-08-25 09:33:33 +00:00
iCrawl
22011575cd build: fixup vscode-eslint 2023-08-24 23:44:35 +02:00
iCrawl
e3127a0735 build: fix linting 2023-08-24 23:08:29 +02:00
iCrawl
9811514deb build: ignores/swap/concurrency 2023-08-24 21:58:34 +02:00
iCrawl
6ea63d000b chore: regen lockfile 2023-08-24 20:33:50 +02:00
iCrawl
fb81f7befb build: refactor linting setup 2023-08-24 06:43:23 +02:00
White Wolf
788888ab9a fix(TransformerGraph): Explicitly include input args for readable input cases instead of just for string input cases (#9793)
Explicitly add input args for readable input cases instead of just for string input cases.
Change also ensures that constant arrays are passed by value instead of by reference, preventing them from accidentally being modified.

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-08-23 16:10:22 +00:00
iCrawl
f6c7c14c9e chore: cleanup from debug 2023-08-22 09:48:36 +02:00
iCrawl
d37632da05 build: refactor linting 2023-08-22 09:40:11 +02:00
iCrawl
2e40a05adf chore: fixup exports and move prettier/lintstaged to mjs 2023-08-22 01:58:54 +02:00
iCrawl
1e3aed0d97 chore: config overhaul 2023-08-22 01:33:47 +02:00
iCrawl
5d7c59c301 chore: deps 2023-08-22 00:30:08 +02:00
Jiralite
899bc5f78b build: bump Undici and discord-api-types (#9779)
* build: bump discord-api-types

* build: bump Undici too

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-08-21 21:00:14 +00:00
Noel
dd5e7453e8 feat(create-discord-bot): bun/deno templates (#9795) 2023-08-21 22:48:13 +02:00
iCrawl
8eb978d32c chore(discord.js): release discord.js@14.13.0 2023-08-17 21:45:00 +02:00
iCrawl
5d1b233047 chore(core): release @discordjs/core@1.0.1 2023-08-17 21:44:09 +02:00
iCrawl
4ab05e994e chore(ws): release @discordjs/ws@1.0.1 2023-08-17 21:43:19 +02:00
iCrawl
4bc2667a5f chore(proxy): release @discordjs/proxy@2.0.1 2023-08-17 21:42:44 +02:00
iCrawl
84ead6e554 chore(rest): release @discordjs/rest@2.0.1 2023-08-17 21:41:52 +02:00
iCrawl
0220fb7278 chore(builders): release @discordjs/builders@1.6.5 2023-08-17 21:40:56 +02:00
iCrawl
6da456767e chore(util): release @discordjs/util@1.0.1 2023-08-17 21:39:49 +02:00
iCrawl
67b30355ea chore(formatters): release @discordjs/formatters@0.3.2 2023-08-17 21:38:59 +02:00
iCrawl
58d9024245 chore(create-discord-bot): release create-discord-bot@0.2.1 2023-08-17 21:38:20 +02:00
iCrawl
5cd6382d1d chore(collection): release @discordjs/collection@1.5.3 2023-08-17 21:35:04 +02:00
iCrawl
fffe625a0c chore(brokers): release @discordjs/brokers@0.2.2 2023-08-17 21:34:23 +02:00
iCrawl
7321c291da chore: revert bump 2023-08-17 21:33:46 +02:00
iCrawl
ab3efb0211 chore(discord.js): release discord.js@14.13.0 2023-08-17 21:31:59 +02:00
iCrawl
7fa9ea3f0f chore: pin discord-api-deps, revert undici 2023-08-17 21:31:04 +02:00
iCrawl
af0f1aa765 chore(discord.js): release discord.js@14.13.0 2023-08-17 21:09:00 +02:00
iCrawl
99cadfd82b chore: deps 2023-08-17 21:08:09 +02:00
Jiralite
8f572a6bad docs(EmbedBuilder): @readonly length (#9778)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-08-17 19:07:02 +00:00
Jaw0r3k
d90ba8dce8 feat(Client): add deleteWebhook method (#9777)
* feat(Client): deleteWebhook method

* Update packages/discord.js/src/client/Client.js

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

* chore: suggested changes

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

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-08-17 16:12:05 +00:00
Jiralite
24fbb11ba2 fix(Action): Do not add the client user as a recipient (#9774)
fix(Action): do not add the client user as a recipient

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-08-14 17:24:00 +00:00
Jiralite
727dc094d5 types(GuildInvitableChannelResolvable): Allow forum channels (#9775)
types(GuildInvitableChannelResolvable): allow forum channels

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-08-14 17:19:47 +00:00
Jiralite
d5be4242c6 docs(WebhookEditOptions): Add all of the types (#9776)
docs(WebhookEditOptions): add all the types

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-08-14 17:16:24 +00:00
Jiralite
c1ff545bf1 fix(DMChannel): Correct partial typo (#9773)
fix(DMChannel): correct partial typo
2023-08-14 17:11:46 +00:00
Toast
188877c50a docs: Update Node.js requirement to 16.11.0 (#9764)
* Update Node.js requirement in README file

* chore: update the rest of files with nodejs 16.11.0

* Update 03-updating-to-v14.mdx

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2023-08-13 19:49:33 +00:00
Jiralite
a1605b3a5e build: Update vite and other related dependencies (#9772)
* build: update vite and other related dependencies

* chore: use `"errors-only"`
2023-08-13 21:36:23 +02:00
advaith
9ed1b59df6 feat(ClientPresence): allow setting activity state (#9743)
* feat(ClientPresence): allow setting activity state

* fix: add to map

* feat: use name as fallback state
2023-08-12 11:31:29 +00:00
Jaw0r3k
0a9a3ede29 typings: Make activity name required (#9765)
* fix: activity name is required

* chore: add suggested changes

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

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Aura Román <kyradiscord@gmail.com>
2023-08-12 11:12:33 +00:00
ckohen
346fa57f95 fix(CachedManager): allow overriding constructor for makeCache (#9763)
* fix(CachedManager): allow overriding constructor for makeCache

* feat: allow determining makeCache based on non-overriden constructor

* types: cleanup leftovers

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-08-12 07:08:47 +00:00
Lily Bergonzat
b3c85d34a6 fix(types): fixed CachedManager constructor arguments in type (#9761)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-08-11 10:04:13 +00:00
Jiralite
d8e37551ce fix(Action): Do not set undefined values (#9755)
fix(Action): do not set `undefined` values

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-08-11 07:19:59 +00:00
Jiralite
a30d46c5f5 types(BaseButtonComponentData): Narrow component type (#9735)
* types(BaseButtonComponentData): narrow `type`

* test: fix suddenly broken tests

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-08-11 07:15:05 +00:00
Jiralite
632a9b4965 feat(ClientApplication): Approximate guild count and new GET route (#9713)
* feat: add approx guild count and get route

* refactor: replace route

* docs: update description of class

The replacement route justifies this change.

* feat(ClientApplication): add `approximateGuildCount`

* refactor: revert now-unnecessary changes
2023-08-11 07:11:13 +00:00
n1ck_pro
3b18e5b08d feat(Role): add flags (#9694)
* feat(Role): add `flags`

* types: use RoleFlags enum

* Update packages/discord.js/typings/index.d.ts

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

---------

Co-authored-by: Jaw0r3k <jaworekwiadomosci@gmail.com>
2023-08-10 21:20:13 +00:00
Almeida
692f0fc96d feat(Attachment): add flags (#9686)
* feat(Attachment): add `flags`

* fix: import

* fix: flags casing

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

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-08-10 20:53:54 +00:00
Synbulat Biishev
0de071d0a5 feat: add Client#webhooksUpdate (#9732)
* feat: add `Client#webhooksUpdate`

* feat: add deprecation in the types

* docs: add full stops

* types: reference non-deprecated type

This helps with future-proofing (deduplication).

* docs(ClientEvents): fix reference link

This now hyperlinks correctly with IntelliSense.

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-08-09 14:15:00 +00:00
Jaw0r3k
99194fc270 fix(create-discord-bot): add shebang in main file (#9747)
* fix: no running in cmd

Co-authored-by: ROB0520 <ynoreyesminecraft@gmail.com>

* chore: delete in create-discord-bot file

---------

Co-authored-by: ROB0520 <ynoreyesminecraft@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-08-09 09:48:58 +00:00
Almeida
cf72d42ea5 ci: upload /formatters test coverage (#9753)
chore: upload /formatters test coverage
2023-08-08 06:44:27 +00:00
iCrawl
7295a3a94a chore(discord.js): release discord.js@14.12.1 2023-08-01 02:23:51 +02:00
n1ck_pro
1af7e5a0bb fix(BaseClient): fix destroy method (#9742) 2023-07-31 22:18:11 +00:00
iCrawl
3bc0dce04a chore: fix changelog 2023-07-31 22:17:37 +02:00
iCrawl
c40f7540cd chore(discord.js): release discord.js@15.0.0 2023-07-31 22:07:38 +02:00
iCrawl
1fc9308fef chore(builders): release @discordjs/builders@1.6.4 2023-07-31 21:35:26 +02:00
iCrawl
43d3b48565 chore(create-discord-bot): release create-discord-bot@0.2.0 2023-07-31 21:33:51 +02:00
1004 changed files with 83738 additions and 37064 deletions

View File

@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/commitlintrc.json",
"extends": ["@commitlint/config-angular"],
"rules": {
"type-enum": [

View File

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

1
.gitattributes vendored
View File

@@ -1 +1,2 @@
* text=auto eol=lf
pnpm-lock.yaml linguist-generated=true text=auto eol=lf

View File

@@ -2,7 +2,7 @@ version = 1
[merge]
require_automerge_label = false
blocking_labels = ['blocked']
blocking_labels = ['blocked', 'in review']
method = 'squash'
[merge.message]

View File

@@ -11,22 +11,20 @@ is a great boon to your development process.
To get ready to work on the codebase, please do the following:
1. Fork & clone the repository, and make sure you're on the **main** branch
2. Run `yarn --immutable` ([install](https://yarnpkg.com/getting-started/install))
3. Run `yarn build` to build local packages
2. Run `pnpm install --frozen-lockfile` ([install](https://pnpm.io/installation))
3. Run `pnpm run build` to build local packages
4. Code your heart out!
5. Run `yarn test` to run ESLint and ensure any JSDoc changes are valid
5. Run `pnpm run test` to run ESLint and ensure any JSDoc changes are valid
6. [Submit a pull request](https://github.com/discordjs/discord.js/compare) (Make sure you follow the [conventional commit format](https://github.com/discordjs/discord.js/blob/main/.github/COMMIT_CONVENTION.md))
## Testing changes locally
If you want to test changes you've made locally, you can do so by using `yarn link`. This will create a symlink to your local copy of the discord.js libraries.
If you want to test changes you've made locally, you can do so by using `pnpm link <package-you-want-to-link-to-your-current-package>`. This will create a symlink to your local copy of the discord.js libraries.
1. Create a new directory `mkdir discordjs-test` and move into it `cd discordjs-test`
2. Initialize a new yarn 3 project `yarn init -2`
3. Disable pnp `yarn config set nodeLinker node-modules`
4. Now link the local discord.js project you cloned earlier `yarn link -A {PATH_TO_DISCORDJS_REPO}`
5. Install packages you'd like to test locally `yarn add discord.js@latest`, `yarn add @discordjs/rest@latest`, etc. **Note: Make sure you use `latest` tag or else yarn will try to install the remote package from npm**
6. Import the package in your source code and test them out!
2. Initialize a new pnpm project `pnpm init`
3. Now link the discord.js package from the directory you cloned earlier `pnpm link {PATH_TO_DISCORDJS_REPO}/packages/<package>`. (e.g. `pnpm link ~/discord.js/packages/rest`)
4. Import the package in your source code and test them out!
### Working with TypeScript packages
@@ -34,15 +32,18 @@ When testing local changes, you may notice you need to manually recompile TypeSc
To avoid this you can use the `--watch` parameter in the package build script to automatically recompile the project when changes are detected.
For example, to automatically recompile the `@discordjs/rest` project when changes are detected, run `yarn turbo run build --filter=@discordjs/rest -- --watch` in the root folder of where you cloned the discord.js repo.
For example, to automatically recompile the `@discordjs/rest` project when changes are detected, run `pnpm turbo run build --filter='@discordjs/rest' -- --watch` in the root folder of where you cloned the discord.js repo.
## Adding new packages
If you'd like to create another package under the `@discordjs` organization run the following command:
```sh
yarn create-package <package-name> [package-description]
pnpm run 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. It may also be required to update the CODEOWNERS file.
This will create new package directory under `packages/` with the required configuration files. You may begin
to make changes within the `src/` directory. You may also need to:
- Update workflows that utilize packages
- Update the CODEOWNERS file

View File

@@ -61,9 +61,9 @@ body:
label: Versions
description: List necessary versions here. This includes your package version, runtime version, operating system etc.
placeholder: |
- discord.js 14.9.0 (`npm ls discord.js` or another package)
- Node.js 16.9.0 (`node --version`)
- TypeScript 5.0.4 (`npm ls typescript` if you use it)
- discord.js 14.12.1 (`npm ls discord.js` or another package)
- Node.js 16.11.0 (`node --version`)
- TypeScript 5.1.6 (`npm ls typescript` if you use it)
- macOS Ventura 13.3.1
validations:
required: true
@@ -123,6 +123,8 @@ body:
- GuildScheduledEvents
- AutoModerationConfiguration
- AutoModerationExecution
- GuildMessagePolls
- DirectMessagePolls
multiple: true
validations:
required: true

6
.github/labeler.yml vendored
View File

@@ -4,6 +4,12 @@ apps:guide:
apps:website:
- apps/website/*
- apps/website/**/*
packages:api-extractor:
- packages/api-extractor/*
- packages/api-extractor/**/*
packages:api-extractor-model:
- packages/api-extractor-model/*
- packages/api-extractor-model/**/*
packages:brokers:
- packages/brokers/*
- packages/brokers/**/*

12
.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
@@ -52,6 +52,10 @@
color: e4e669
- name: need repro
color: c66037
- name: packages:api-extractor
color: fbca04
- name: packages:api-extractor-model
color: fbca04
- name: packages:brokers
color: fbca04
- name: packages:builders

35
.github/workflows/cleanup-cache.yml vendored Normal file
View File

@@ -0,0 +1,35 @@
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries
name: Cleanup caches
on:
pull_request:
types:
- closed
workflow_dispatch:
jobs:
cleanup:
name: Cleanup caches
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Cleanup caches
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

34
.github/workflows/deploy-website.yml vendored Normal file
View File

@@ -0,0 +1,34 @@
name: Deploy website
on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
deploy-website:
name: Deploy website
runs-on: ubuntu-latest
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
if: github.repository_owner == 'discordjs'
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Node.js v18
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
uses: ./packages/actions/src/pnpmCache
- name: Pull vercel production environment
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build website artifacts
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy website artifacts to vercel
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}

50
.github/workflows/deprecate-version.yml vendored Normal file
View File

@@ -0,0 +1,50 @@
name: Deprecate version
on:
workflow_dispatch:
inputs:
package:
description: Package
required: true
type: choice
options:
- '@discordjs/brokers'
- '@discordjs/builders'
- '@discordjs/collection'
- '@discordjs/core'
- 'create-discord-bot'
- '@discordjs/formatters'
- 'discord.js'
- '@discordjs/next'
- '@discordjs/proxy'
- '@discordjs/rest'
- '@discordjs/util'
- '@discordjs/voice'
- '@discordjs/ws'
version:
description: Version(s)
required: true
type: string
message:
description: Deprecation message
required: false
type: string
jobs:
deprecate:
runs-on: ubuntu-latest
if: github.repository_owner == 'discordjs'
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Node.js v18
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
uses: ./packages/actions/src/pnpmCache
- name: Deprecate
run: pnpm exec npm-deprecate --name "${{inputs.version}}" --message "${{inputs.message || 'This version is deprecated. Please use a newer version.'}}" --package ${{inputs.package}}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

View File

@@ -5,6 +5,9 @@ on:
- 'main'
paths:
- 'packages/*/src/**'
- '!packages/create-discord-bot/**'
- '!packages/proxy-container/**'
- '!packages/ui/**'
tags:
- '**'
workflow_dispatch:
@@ -23,12 +26,13 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
build:
build-docs:
name: Build & upload documentation
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
REF_TYPE: ${{ inputs.ref_type || github.ref_type }}
if: github.repository_owner == 'discordjs'
steps:
- name: Checkout repository
@@ -42,13 +46,51 @@ jobs:
node-version: 18
- name: Install dependencies
uses: ./packages/actions/src/yarnCache
uses: ./packages/actions/src/pnpmCache
- name: Build dependencies
run: yarn build
run: pnpm run build
- name: Checkout main repository
if: ${{ inputs.ref && inputs.ref != 'main' }}
uses: actions/checkout@v3
with:
path: 'main'
- name: Build main
if: ${{ inputs.ref && inputs.ref != 'main' }}
shell: bash
run: |
cd main
pnpm install --frozen-lockfile --prefer-offline --loglevel error
pnpm run build
cd ..
- name: Extract package and semver from tag
if: ${{ env.REF_TYPE == 'tag' }}
id: extract-tag
uses: ./packages/actions/src/formatTag
with:
tag: ${{ inputs.ref || github.ref_name }}
- name: Apply tag to api-extractor config
if: ${{ env.REF_TYPE == 'tag' && !inputs.ref }}
run: sed -i 's!https://github.com/discordjs/discord.js/tree/main!https://github.com/discordjs/discord.js/tree/${{ steps.extract-tag.outputs.semver }}!' "packages/${{ steps.extract-tag.outputs.package}}/api-extractor.json"
- name: Build docs
run: yarn docs
run: pnpm run docs
- name: Build docs with main api-extractor
if: ${{ inputs.ref && inputs.ref != 'main' }}
run: |
declare -a PACKAGES=("brokers" "builders" "collection" "core" "discord.js" "formatters" "next" "proxy" "rest" "util" "voice" "ws")
for PACKAGE in "${PACKAGES[@]}"; do
cd "packages/${PACKAGE}"
sed -i 's!https://github.com/discordjs/discord.js/tree/main!https://github.com/discordjs/discord.js/tree/${{ inputs.ref }}!' api-extractor.json
../../main/packages/api-extractor/bin/api-extractor run --local --minify
../../main/packages/scripts/bin/generateSplitDocumentation.js
cd ../..
done
- name: Checkout docs repository
uses: actions/checkout@v3
@@ -57,24 +99,46 @@ jobs:
token: ${{ secrets.DJS_DOCS }}
path: 'out'
- name: Extract package and semver from tag
if: ${{ github.ref_type == 'tag' }}
id: extract-tag
uses: ./packages/actions/src/formatTag
with:
tag: ${{ github.ref_name }}
- name: Upload documentation to database
if: ${{ github.ref_type == 'tag' }}
if: ${{ env.REF_TYPE == 'tag' && (!inputs.ref || inputs.ref == 'main') }}
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
uses: ./packages/actions/src/uploadDocumentation
with:
package: ${{ steps.extract-tag.outputs.package }}
version: ${{ steps.extract-tag.outputs.semver }}
- name: Upload documentation to database
if: ${{ env.REF_TYPE == 'tag' && inputs.ref && inputs.ref != 'main' }}
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
uses: ./main/packages/actions/src/uploadDocumentation
with:
package: ${{ steps.extract-tag.outputs.package }}
version: ${{ steps.extract-tag.outputs.semver }}
- name: Upload split documentation to blob storage
if: ${{ env.REF_TYPE == 'tag' && (!inputs.ref || inputs.ref == 'main') }}
env:
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
uses: ./packages/actions/src/uploadSplitDocumentation
with:
package: ${{ steps.extract-tag.outputs.package }}
version: ${{ steps.extract-tag.outputs.semver }}
- name: Upload split documentation to blob storage
if: ${{ env.REF_TYPE == 'tag' && inputs.ref && inputs.ref != 'main' }}
env:
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
uses: ./main/packages/actions/src/uploadSplitDocumentation
with:
package: ${{ steps.extract-tag.outputs.package }}
version: ${{ steps.extract-tag.outputs.semver }}
- name: Move docs to correct directory
if: ${{ github.ref_type == 'tag' }}
if: ${{ env.REF_TYPE == 'tag' }}
env:
PACKAGE: ${{ steps.extract-tag.outputs.package }}
SEMVER: ${{ steps.extract-tag.outputs.semver }}
@@ -82,24 +146,46 @@ jobs:
mkdir -p "out/${PACKAGE}"
if [[ "${PACKAGE}" == "discord.js" ]]; then
mv "packages/${PACKAGE}/docs/docs.json" "out/${PACKAGE}/${SEMVER}.json"
mv "packages/${PACKAGE}/docs/docs.api.json" "out/${PACKAGE}/${SEMVER}.api.json"
else
mv "packages/${PACKAGE}/docs/docs.api.json" "out/${PACKAGE}/${SEMVER}.api.json"
fi
- name: Upload documentation to database
if: ${{ github.ref_type == 'branch' }}
if: ${{ env.REF_TYPE == 'branch' && (!inputs.ref || inputs.ref == 'main') }}
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
uses: ./packages/actions/src/uploadDocumentation
- name: Upload documentation to database
if: ${{ env.REF_TYPE == 'branch' && inputs.ref && inputs.ref != 'main' }}
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
uses: ./main/packages/actions/src/uploadDocumentation
- name: Upload split documentation to blob storage
if: ${{ env.REF_TYPE == 'branch' && (!inputs.ref || inputs.ref == 'main') }}
env:
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
uses: ./packages/actions/src/uploadSplitDocumentation
- name: Upload split documentation to blob storage
if: ${{ env.REF_TYPE == 'branch' && inputs.ref && inputs.ref != 'main' }}
env:
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}
uses: ./main/packages/actions/src/uploadSplitDocumentation
- name: Move docs to correct directory
if: ${{ github.ref_type == 'branch' }}
if: ${{ env.REF_TYPE == 'branch' }}
run: |
declare -a PACKAGES=("brokers" "builders" "collection" "core" "discord.js" "next" "formatters" "proxy" "rest" "util" "voice" "ws")
declare -a PACKAGES=("brokers" "builders" "collection" "core" "discord.js" "formatters" "next" "proxy" "rest" "util" "voice" "ws")
for PACKAGE in "${PACKAGES[@]}"; do
if [[ "${PACKAGE}" == "discord.js" ]]; then
mkdir -p "out/${PACKAGE}"
mv "packages/${PACKAGE}/docs/docs.json" "out/${PACKAGE}/${GITHUB_REF_NAME}.json"
mv "packages/${PACKAGE}/docs/docs.api.json" "out/${PACKAGE}/${GITHUB_REF_NAME}.api.json"
else
mkdir -p "out/${PACKAGE}"
mv "packages/${PACKAGE}/docs/docs.api.json" "out/${PACKAGE}/${GITHUB_REF_NAME}.api.json"
@@ -114,3 +200,33 @@ jobs:
git add .
git commit -m "Docs build for ${GITHUB_REF_TYPE} ${GITHUB_REF_NAME}: ${GITHUB_SHA}" || true
git push
build-indices:
needs: build-docs
name: Build & upload search indices
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
if: github.repository_owner == 'discordjs'
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install node.js v18
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
uses: ./packages/actions/src/pnpmCache
- name: Build dependencies
run: pnpm run build
- name: Upload search indices to meilisearch
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
SEARCH_API_URL: ${{ secrets.SEARCH_API_URL }}
SEARCH_API_KEY: ${{ secrets.SEARCH_API_KEY }}
uses: ./packages/actions/src/uploadSearchIndices

View File

@@ -6,7 +6,7 @@ jobs:
issue-triage:
runs-on: ubuntu-latest
steps:
- uses: github/issue-labeler@v3.1
- uses: github/issue-labeler@v3.2
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
configuration-path: .github/issue-labeler.yml

View File

@@ -1,20 +0,0 @@
name: 'Lighthouse Audit (main)'
on:
workflow_dispatch:
jobs:
lighthouse_audit_main:
name: 'Lighthouse Audit (main)'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Audit production URLs with Lighthouse
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@v9
with:
urls: |
https://discordjs.dev
https://guide.discordjs.dev
uploadArtifacts: true
temporaryPublicStorage: true

View File

@@ -1,88 +0,0 @@
name: 'Lighthouse Audit'
on:
issue_comment:
types: [created, edited]
jobs:
lighthouse_audit:
name: 'Lighthouse Audit'
if: ${{ github.event.issue.pull_request }}
runs-on: ubuntu-latest
steps:
- name: Get Vercel preview URL
id: get_preview_url
uses: actions/github-script@v6
with:
script: |
const comment = context.payload.comment;
const regex = /https:\/\/[a-z0-9-]+\.vercel\.app/g;
const matches = comment.body.match(regex);
let previewUrl = "";
if (matches && matches.length) {
previewUrl = matches[0];
console.log('Preview url found:', previewUrl);
}
console.log("No preview url found.");
core.setOutput('vercel_preview_url', previewUrl);
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Add comment to PR
if: ${{ steps.get_preview_url.outputs.vercel_preview_url != '' }}
id: loading_comment_to_pr
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.issue.number }}
header: lighthouse
message: |
Running Lighthouse audit...
- name: Checkout repository
if: ${{ steps.get_preview_url.outputs.vercel_preview_url != '' }}
uses: actions/checkout@v3
- name: Audit preview URL with Lighthouse
if: ${{ steps.get_preview_url.outputs.vercel_preview_url != '' }}
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@v9
with:
urls: |
${{ steps.get_preview_url.outputs.vercel_preview_url }}
uploadArtifacts: true
temporaryPublicStorage: true
- name: Format lighthouse score
if: ${{ steps.get_preview_url.outputs.vercel_preview_url != '' }}
id: format_lighthouse_score
uses: actions/github-script@v6
with:
script: |
const result = ${{ steps.lighthouse_audit.outputs.manifest }}[0].summary
const links = ${{ steps.lighthouse_audit.outputs.links }}
const formatResult = (res) => Math.round((res * 100))
Object.keys(result).forEach(key => result[key] = formatResult(result[key]))
const score = res => res >= 90 ? '🟢' : res >= 50 ? '🟠' : '🔴'
const comment = [
`⚡️ [Lighthouse report](${Object.values(links)[0]}) for the changes in this PR:`,
'| Category | Score |',
'| --- | --- |',
`| ${score(result.performance)} Performance | ${result.performance} |`,
`| ${score(result.accessibility)} Accessibility | ${result.accessibility} |`,
`| ${score(result['best-practices'])} Best practices | ${result['best-practices']} |`,
`| ${score(result.seo)} SEO | ${result.seo} |`,
`| ${score(result.pwa)} PWA | ${result.pwa} |`,
' ',
`*Lighthouse ran on [${Object.keys(links)[0]}](${Object.keys(links)[0]})*`
].join('\n')
core.setOutput("comment", comment);
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Add comment to PR
if: ${{ steps.get_preview_url.outputs.vercel_preview_url != '' }}
id: comment_to_pr
uses: marocchino/sticky-pull-request-comment@v2
with:
number: ${{ github.event.issue.number }}
header: lighthouse
message: |
${{ steps.format_lighthouse_score.outputs.comment }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -3,13 +3,13 @@ on:
schedule:
- cron: '0 16 * * *'
workflow_dispatch:
permissions:
issues: write
concurrency:
group: lock
jobs:
action:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: dessant/lock-threads@v4
with:

View File

@@ -1,26 +0,0 @@
name: npm auto deprecate
on:
schedule:
- cron: '0 1 * * *'
workflow_dispatch:
jobs:
npm-auto-deprecate:
name: npm auto deprecate
runs-on: ubuntu-latest
if: github.repository_owner == 'discordjs'
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install node.js v18
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
uses: ./packages/actions/src/yarnCache
- name: Deprecate versions
run: 'yarn npm-deprecate --name "*dev*" --package @discordjs/brokers @discordjs/builders @discordjs/collection @discordjs/core @discordjs/formatters discord.js @discordjs/next @discordjs/proxy @discordjs/rest @discordjs/util @discordjs/voice @discordjs/ws'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

View File

@@ -18,10 +18,7 @@ jobs:
node-version: 18
- name: Install dependencies
uses: ./packages/actions/src/yarnCache
- name: Build dependencies
run: yarn build
uses: ./packages/actions/src/pnpmCache
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
@@ -30,4 +27,4 @@ jobs:
run: echo ${{ secrets.DOCKER_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Build & push docker image
run: yarn docker build --buildkit @discordjs/proxy-container -t discordjs/proxy:latest --push
run: docker build -f packages/proxy-container/Dockerfile -t discordjs/proxy:latest --push .

View File

@@ -35,6 +35,8 @@ jobs:
- package: '@discordjs/ws'
folder: 'ws'
runs-on: ubuntu-latest
permissions:
id-token: write
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
@@ -51,15 +53,32 @@ jobs:
node-version: 18
registry-url: https://registry.npmjs.org/
- name: Check the current development version
id: release-check
run: |
if [[ $(npm view ${{ matrix.package }}@dev version | grep -e "$(git rev-parse --short HEAD)") ]]; \
then echo "RELEASE=0" >> "$GITHUB_OUTPUT"; \
else echo "RELEASE=1" >> "$GITHUB_OUTPUT"; \
fi
- name: Install dependencies
uses: ./packages/actions/src/yarnCache
if: steps.release-check.outputs.release == '1'
uses: ./packages/actions/src/pnpmCache
- name: Build dependencies
run: yarn build
if: steps.release-check.outputs.release == '1'
run: pnpm run build
- name: Publish package
if: steps.release-check.outputs.release == '1'
run: |
yarn workspace ${{ matrix.package }} release --preid "dev.$(date +%s)-$(git rev-parse --short HEAD)"
yarn workspace ${{ matrix.package }} npm publish --tag dev || true
pnpm --filter=${{ matrix.package }} run release --preid "dev.$(date +%s)-$(git rev-parse --short HEAD)"
pnpm --filter=${{ matrix.package }} publish --provenance --no-git-checks --tag dev || true
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
- name: Deprecate prior development releases
if: steps.release-check.outputs.release == '1'
run: pnpm exec npm-deprecate --name "*dev*" --message "This version is deprecated. Please use a newer version." --package ${{ matrix.package }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

View File

@@ -15,10 +15,7 @@ jobs:
node-version: 18
- name: Install dependencies
uses: ./packages/actions/src/yarnCache
- name: Build dependencies
run: yarn build
uses: ./packages/actions/src/pnpmCache
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
@@ -27,4 +24,4 @@ jobs:
run: echo ${{ secrets.DOCKER_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- 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
run: docker build -f packages/proxy-container/Dockerfile -t discordjs/proxy:$(cut -d '.' -f1 <<< $(jq --raw-output '.version' packages/proxy-container/package.json)) --push .

View File

@@ -6,6 +6,8 @@ jobs:
npm-publish:
name: npm publish
runs-on: ubuntu-latest
permissions:
id-token: write
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
@@ -21,10 +23,10 @@ jobs:
registry-url: https://registry.npmjs.org/
- name: Install dependencies
uses: ./packages/actions/src/yarnCache
uses: ./packages/actions/src/pnpmCache
- name: Build dependencies
run: yarn build
run: pnpm run build
- name: Extract package and semver from tag
id: extract-tag
@@ -34,6 +36,6 @@ jobs:
- name: Publish package
run: |
yarn workspace ${{ steps.extract-tag.outputs.subpackage == 'true' && '@discordjs/' || '' }}${{ steps.extract-tag.outputs.package }} npm publish
pnpm --filter=${{ steps.extract-tag.outputs.subpackage == 'true' && '@discordjs/' || '' }}${{ steps.extract-tag.outputs.package }} publish --provenance --no-git-checks
env:
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

View File

@@ -25,39 +25,39 @@ jobs:
node-version: 18
- name: Install dependencies
uses: ./packages/actions/src/yarnCache
uses: ./packages/actions/src/pnpmCache
- name: Build dependencies (PR)
if: ${{ github.event_name != 'push' }}
run: yarn build --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]"
run: pnpm exec turbo run build --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=4
- name: Build dependencies (Push)
if: ${{ github.event_name == 'push' }}
run: yarn build --filter="...[HEAD^1]"
- name: ESLint (PR)
if: ${{ github.event_name != 'push' }}
run: yarn lint --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" -- --format=compact
- name: ESLint (Push)
if: ${{ github.event_name == 'push' }}
run: yarn lint --filter="...[HEAD^1]" -- --format=compact
run: pnpm exec turbo run build --filter="...[HEAD^1]" --concurrency=4
- name: Tests (PR)
if: ${{ github.event_name != 'push' }}
run: yarn test --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]"
run: pnpm exec turbo run test --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=4
- name: Tests (Push)
if: ${{ github.event_name == 'push' }}
run: yarn test --filter="...[HEAD^1]"
run: pnpm exec turbo run test --filter="...[HEAD^1]" --concurrency=4
- name: ESLint (PR)
if: ${{ github.event_name != 'push' }}
run: pnpm exec turbo run lint --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=4 -- --format=compact
- name: ESLint (Push)
if: ${{ github.event_name == 'push' }}
run: pnpm exec turbo run lint --filter="...[HEAD^1]" --concurrency=4 -- --format=compact
- name: Docs (PR)
if: ${{ github.event_name != 'push' }}
run: yarn docs --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]"
run: pnpm exec turbo run docs --filter="...[origin/${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || 'main' }}]" --concurrency=4
- name: Docs (Push)
if: ${{ github.event_name == 'push' }}
run: yarn docs --filter="...[HEAD^1]"
run: pnpm exec turbo run docs --filter="...[HEAD^1]" --concurrency=4
- name: Upload Coverage
if: github.repository_owner == 'discordjs'

11
.gitignore vendored
View File

@@ -20,7 +20,7 @@ dist-docs
# Miscellaneous
.tmp
.vscode
.vscode/*
!.vscode/extensions.json
!.vscode/settings.json
.idea
@@ -29,6 +29,15 @@ dist-docs
tsconfig.tsbuildinfo
coverage
out
package.tgz
tsup.config.bundled*
vitest.config.ts.timestamp*
# Deno
deno.lock
# Bun
bun.lockb
# yarn
.pnp.*

View File

@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn commitlint --edit $1
pnpm exec commitlint --edit $1

View File

@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn build:affected && yarn lint-staged
pnpm run build:affected && pnpm exec lint-staged

View File

@@ -1,5 +1,6 @@
{
"$schema": "https://json.schemastore.org/lintstagedrc.schema.json",
"*": "prettier --ignore-unknown --write",
"{src/**,__tests__/**}.{mjs,js,cjs,ts,tsx}": "eslint --ext .mjs,.js,.cjs,.ts,.tsx --fix",
"{src/**,__tests__/**}.{mjs,js,cjs,ts,tsx}": "eslint --fix",
"src/**.ts": "vitest related --run --config ../../vitest.config.ts"
}

6
.npmrc Normal file
View File

@@ -0,0 +1,6 @@
auto-install-peers=false
resolution-mode=highest
public-hoist-pattern[]=*eslint*
public-hoist-pattern[]=*prettier*
public-hoist-pattern[]=*@rushstack/node-core-library*
public-hoist-pattern[]=*jju*

View File

@@ -1 +1,5 @@
CODEOWNERS
CHANGELOG.md
tsup.config.bundled*
vitest.config.ts.timestamp*
pnpm-lock.yaml

View File

@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/prettierrc.json",
"printWidth": 120,
"useTabs": true,
"singleQuote": true,

View File

@@ -8,7 +8,6 @@
"eamodio.gitlens",
"christian-kohler.npm-intellisense",
"christian-kohler.path-intellisense",
"antfu.unocss",
"unifiedjs.vscode-mdx"
]
}

29
.vscode/settings.json vendored
View File

@@ -1,18 +1,35 @@
{
"eslint.workingDirectories": [{ "pattern": "./apps/*" }, { "pattern": "./packages/*" }],
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
"eslint.experimental.useFlatConfig": true,
"eslint.workingDirectories": [
{ "directory": "${workspaceFolder}" },
{ "pattern": "./apps/*/" },
{ "pattern": "./packages/*/" }
],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": false
"source.organizeImports": "never",
"source.fixAll.eslint": "explicit",
"source.fixAll": "explicit"
},
"editor.trimAutoWhitespace": false,
"files.associations": {
"*.mdx": "markdown"
"api-extractor.json": "jsonc",
"api-extractor-docs.json": "jsonc",
"tsconfig.json": "jsonc",
"tsconfig.eslint.json": "jsonc",
"tsconfig.docs.json": "jsonc"
},
"files.insertFinalNewline": true,
"files.eol": "\n",
"npm.packageManager": "yarn",
"typescript.tsdk": "node_modules/typescript/lib"
"npm.packageManager": "pnpm",
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"unocss.disable": true,
"deno.enable": false,
"deno.enablePaths": ["./packages/create-discord-bot/template/Deno"],
"deno.lint": false,
"deno.unstable": false,
"deno.config": "./packages/create-discord-bot/template/Deno/deno.jsonc"
}

View File

@@ -1,18 +0,0 @@
diff --git a/package.json b/package.json
index fc35658a40f9ba3e3513c459ba9f4f6e1b3f59f5..bc35eda66f270c95ba52e721cb6976fd61622c58 100644
--- a/package.json
+++ b/package.json
@@ -26,11 +26,13 @@
},
"exports": {
".": {
+ "types": "./dist/index.d.ts",
"node": "./dist/index.js",
"default": "./browser/index.js"
},
"./package.json": "./package.json",
"./util": {
+ "types": "./dist/util.d.ts",
"node": "./dist/util.js",
"default": "./browser/dist/util.js"
}

View File

@@ -1,260 +0,0 @@
/* eslint-disable */
module.exports = {
name: '@yarnpkg/plugin-docker-build',
factory: function (require) {
var plugin;
(() => {
'use strict';
var t = {
d: (e, o) => {
for (var r in o) t.o(o, r) && !t.o(e, r) && Object.defineProperty(e, r, { enumerable: !0, get: o[r] });
},
o: (t, e) => Object.prototype.hasOwnProperty.call(t, e),
r: (t) => {
'undefined' != typeof Symbol &&
Symbol.toStringTag &&
Object.defineProperty(t, Symbol.toStringTag, { value: 'Module' }),
Object.defineProperty(t, '__esModule', { value: !0 });
},
},
e = {};
t.r(e), t.d(e, { default: () => u });
const o = require('@yarnpkg/cli'),
r = require('clipanion'),
i = require('@yarnpkg/core'),
a = require('@yarnpkg/plugin-patch'),
n = require('@yarnpkg/fslib');
const s = require('@yarnpkg/plugin-pack');
async function c({ workspace: t, destination: e, report: o }) {
await s.packUtils.prepareForPack(t, { report: o }, async () => {
const r = await s.packUtils.genPackList(t),
a = i.Report.progressViaCounter(r.length),
c = o.reportProgress(a);
try {
for (const i of r) {
const r = n.ppath.join(t.cwd, i),
s = n.ppath.join(e, t.relativeCwd, i);
o.reportInfo(null, i), await n.xfs.copyPromise(s, r, { overwrite: !0 }), a.tick();
}
} finally {
c.stop();
}
});
}
function p(t, e) {
const o = (0, n.toFilename)(e);
return n.ppath.isAbsolute(o) ? n.ppath.relative(t, o) : o;
}
const l = /^builtin<([^>]+)>$/;
var d = function (t, e, o, r) {
var i,
a = arguments.length,
n = a < 3 ? e : null === r ? (r = Object.getOwnPropertyDescriptor(e, o)) : r;
if ('object' == typeof Reflect && 'function' == typeof Reflect.decorate) n = Reflect.decorate(t, e, o, r);
else
for (var s = t.length - 1; s >= 0; s--)
(i = t[s]) && (n = (a < 3 ? i(n) : a > 3 ? i(e, o, n) : i(e, o)) || n);
return a > 3 && n && Object.defineProperty(e, o, n), n;
};
class f extends o.BaseCommand {
constructor() {
super(...arguments), (this.args = []);
}
async execute() {
const t = await i.Configuration.find(this.context.cwd, this.context.plugins),
{ project: e } = await i.Project.find(t, this.context.cwd),
o = e.getWorkspaceByIdent(i.structUtils.parseIdent(this.workspaceName)),
r = (function ({
project: t,
workspaces: e,
production: o = !1,
scopes: r = o ? ['dependencies'] : i.Manifest.hardDependencies,
}) {
const a = new Set([...e]);
for (const e of a)
for (const o of r) {
const r = e.manifest.getForScope(o).values();
for (const e of r) {
const o = t.tryWorkspaceByDescriptor(e);
o && a.add(o);
}
}
for (const e of t.workspaces)
a.has(e)
? o && e.manifest.devDependencies.clear()
: (e.manifest.dependencies.clear(),
e.manifest.devDependencies.clear(),
e.manifest.peerDependencies.clear());
return a;
})({ project: e, workspaces: [o], production: this.production }),
s = await (async function (t, e = 'Dockerfile') {
const o = (0, n.toFilename)(e);
if (n.ppath.isAbsolute(o)) return o;
const r = [n.ppath.join(t.cwd, o), n.ppath.join(t.project.cwd, o)];
for (const t of r) if (await n.xfs.existsPromise(t)) return t;
throw new Error('Dockerfile is required');
})(o, this.dockerFilePath),
d = await i.Cache.find(t);
return (
await i.StreamReport.start(
{ configuration: t, stdout: this.context.stdout, includeLogs: !this.context.quiet },
async (t) => {
await t.startTimerPromise('Resolution Step', async () => {
await e.resolveEverything({ report: t, cache: d });
}),
await t.startTimerPromise('Fetch Step', async () => {
await e.fetchEverything({ report: t, cache: d });
}),
await n.xfs.mktempPromise(async (o) => {
const f = n.ppath.join(o, (0, n.toFilename)('manifests')),
u = n.ppath.join(o, (0, n.toFilename)('packs'));
await t.startTimerPromise('Copy files', async () => {
await (async function ({ destination: t, project: e, report: o }) {
const r = e.configuration.get('rcFilename');
o.reportInfo(null, r),
await n.xfs.copyPromise(n.ppath.join(t, r), n.ppath.join(e.cwd, r), { overwrite: !0 });
})({ destination: f, project: e, report: t }),
await (async function ({ destination: t, project: e, report: o }) {
const r = n.ppath.join((0, n.toFilename)('.yarn'), (0, n.toFilename)('plugins'));
o.reportInfo(null, r),
await n.xfs.copyPromise(n.ppath.join(t, r), n.ppath.join(e.cwd, r), { overwrite: !0 });
})({ destination: f, project: e, report: t }),
await (async function ({ destination: t, project: e, report: o }) {
const r = e.configuration.get('yarnPath'),
i = n.ppath.relative(e.cwd, r),
a = n.ppath.join(t, i);
o.reportInfo(null, i), await n.xfs.copyPromise(a, r, { overwrite: !0 });
})({ destination: f, project: e, report: t }),
await (async function ({ destination: t, workspaces: e, report: o }) {
for (const r of e) {
const e = n.ppath.join(r.relativeCwd, i.Manifest.fileName),
a = n.ppath.join(t, e),
s = {};
r.manifest.exportTo(s),
o.reportInfo(null, e),
await n.xfs.mkdirpPromise(n.ppath.dirname(a)),
await n.xfs.writeJsonPromise(a, s);
}
})({ destination: f, workspaces: e.workspaces, report: t }),
await (async function ({ destination: t, report: e, project: o, parseDescriptor: r }) {
const a = new Set();
for (const s of o.storedDescriptors.values()) {
const c = r(
i.structUtils.isVirtualDescriptor(s) ? i.structUtils.devirtualizeDescriptor(s) : s,
);
if (!c) continue;
const { parentLocator: p, paths: d } = c;
for (const r of d) {
if (l.test(r)) continue;
if (n.ppath.isAbsolute(r)) continue;
const i = o.getWorkspaceByLocator(p),
s = n.ppath.join(i.relativeCwd, r);
if (a.has(s)) continue;
a.add(s);
const c = n.ppath.join(i.cwd, r),
d = n.ppath.join(t, s);
e.reportInfo(null, s),
await n.xfs.mkdirpPromise(n.ppath.dirname(d)),
await n.xfs.copyFilePromise(c, d);
}
}
})({
destination: f,
report: t,
project: e,
parseDescriptor: (t) => {
if (t.range.startsWith('exec:')) {
const e = (function (t) {
const { params: e, selector: o } = i.structUtils.parseRange(t),
r = n.npath.toPortablePath(o);
return {
parentLocator:
e && 'string' == typeof e.locator ? i.structUtils.parseLocator(e.locator) : null,
path: r,
};
})(t.range);
if (!e || !e.parentLocator) return;
return { parentLocator: e.parentLocator, paths: [e.path] };
}
if (t.range.startsWith('patch:')) {
const { parentLocator: e, patchPaths: o } = a.patchUtils.parseDescriptor(t);
if (!e) return;
return { parentLocator: e, paths: o };
}
},
}),
await (async function ({ destination: t, project: e, cache: o, report: r }) {
for (const i of o.markedFiles) {
const o = n.ppath.relative(e.cwd, i);
(await n.xfs.existsPromise(i)) &&
(r.reportInfo(null, o), await n.xfs.copyPromise(n.ppath.join(t, o), i));
}
})({ destination: f, project: e, cache: d, report: t }),
await (async function ({ destination: t, project: e, report: o }) {
const r = (0, n.toFilename)(e.configuration.get('lockfileFilename')),
i = n.ppath.join(t, r);
o.reportInfo(null, r),
await n.xfs.mkdirpPromise(n.ppath.dirname(i)),
await n.xfs.writeFilePromise(i, e.generateLockfile());
})({ destination: f, project: e, report: t }),
this.copyFiles &&
this.copyFiles.length &&
(await (async function ({ destination: t, files: e, dockerFilePath: o, report: r }) {
const i = n.ppath.dirname(o);
for (const o of e) {
const e = p(i, o),
a = n.ppath.join(i, e),
s = n.ppath.join(t, e);
r.reportInfo(null, e), await n.xfs.copyPromise(s, a);
}
})({ destination: f, files: this.copyFiles, dockerFilePath: s, report: t }));
});
for (const e of r) {
const o = e.manifest.name ? i.structUtils.stringifyIdent(e.manifest.name) : '';
await t.startTimerPromise('Pack workspace ' + o, async () => {
await c({ workspace: e, report: t, destination: u });
});
}
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,
stdout: this.context.stdout,
stderr: this.context.stderr,
});
});
},
)
).exitCode();
}
}
(f.usage = r.Command.Usage({
category: 'Docker-related commands',
description: 'Build a Docker image for a workspace',
details:
'\n This command will build a efficient Docker image which only contains necessary dependencies for the specified workspace.\n\n You have to create a Dockerfile in your workspace or your project. You can also specify the path to Dockerfile using the "-f, --file" option.\n\n Additional arguments can be passed to "docker build" directly, please check the Docker docs for more info: https://docs.docker.com/engine/reference/commandline/build/\n\n You can copy additional files or folders to a Docker image using the "--copy" option. This is useful for secret keys or configuration files. The files will be copied to "manifests" folder. The path can be either a path relative to the Dockerfile or an absolute path.\n ',
examples: [
['Build a Docker image for a workspace', 'yarn docker build @foo/bar'],
['Pass additional arguments to docker build command', 'yarn docker build @foo/bar -t image-tag'],
[
'Copy additional files to a Docker image',
'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),
d([r.Command.Proxy()], f.prototype, 'args', void 0),
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;
})();
return plugin;
},
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,27 +0,0 @@
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:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: '@yarnpkg/plugin-interactive-tools'
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: '@yarnpkg/plugin-workspace-tools'
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: '@yarnpkg/plugin-version'
- 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.1.cjs

View File

@@ -89,42 +89,50 @@
* DEFAULT VALUE: no overrideTsconfig section
*/
"overrideTsconfig": {
// Type Checking
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"useUnknownInCatchVariables": true,
"noUncheckedIndexedAccess": true,
"compilerOptions": {
// Type Checking
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": false,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
// Modules
"module": "ESNext",
"moduleResolution": "node",
"resolveJsonModule": true,
// Modules
"allowArbitraryExtensions": false,
"allowImportingTsExtensions": false,
"module": "ESNext",
"moduleResolution": "nodenext",
"resolveJsonModule": true,
"resolvePackageJsonExports": false,
"resolvePackageJsonImports": false,
// Emit
"declaration": true,
"declarationMap": true,
"importHelpers": true,
"inlineSources": true,
"newLine": "lf",
"noEmitHelpers": true,
"outDir": "dist",
"removeComments": false,
"sourceMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
// Emit
"declaration": true,
"declarationMap": true,
"importHelpers": false,
"newLine": "lf",
"noEmitHelpers": true,
"outDir": "dist",
"removeComments": false,
"sourceMap": true,
// Language and Environment
"experimentalDecorators": true,
"lib": ["ESNext"],
"target": "ES2021",
"useDefineForClassFields": true
// Interop Constraints
"esModuleInterop": false,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
// Language and Environment
"experimentalDecorators": true,
"lib": ["ESNext"],
"target": "ES2022",
"useDefineForClassFields": true
}
}
/**
* This option causes the compiler to be invoked with the --skipLibCheck option. This option is not recommended
@@ -216,7 +224,7 @@
/**
* (REQUIRED) Whether to generate the .d.ts rollup file.
*/
"enabled": true,
"enabled": false,
/**
* Specifies the output path for a .d.ts rollup file to be generated without any trimming.

View File

@@ -0,0 +1 @@
METADATA_BASE_URL=http://localhost:3000

View File

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

View File

@@ -1,12 +0,0 @@
{
"extends": ["../../.eslintrc.json", "neon/react", "neon/next", "neon/edge", "@unocss", "neon/prettier"],
"settings": {
"react": {
"version": "detect"
}
},
"rules": {
"react/react-in-jsx-scope": 0,
"react/jsx-filename-extension": [1, { "extensions": [".tsx"] }]
}
}

View File

@@ -1 +1,2 @@
/** @type {import('lint-staged').Config} */
module.exports = require('../../.lintstagedrc.json');

View File

@@ -1 +1,2 @@
/** @type {import('prettier').Config} */
module.exports = require('../../.prettierrc.json');

View File

@@ -13,12 +13,13 @@ module.exports = withBundleAnalyzer(
withContentlayer({
reactStrictMode: true,
experimental: {
appDir: true,
typedRoutes: true,
},
images: {
dangerouslyAllowSVG: true,
contentDispositionType: 'attachment',
contentSecurityPolicy: "default-src 'self'; frame-src 'none'; sandbox;",
},
poweredByHeader: false,
}),
);

View File

@@ -1,26 +1,26 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@discordjs/guide",
"version": "0.1.0",
"description": "Imagine a guide... that explores the many possibilities for your discord.js bot",
"private": true,
"scripts": {
"test": "vitest run",
"test:lighthouse": "lighthouse http://localhost:3000 --output-path=./lighthouse-results",
"build:local": "yarn build:prod",
"build:prod": "yarn build:css && yarn build:next",
"build:next": "next build",
"build:css": "yarn generate:css",
"build:analyze": "cross-env ANALYZE=true yarn build:prod",
"build:check": "tsc --noEmit",
"build:local": "pnpm run build:prod",
"build:prod": "next build",
"build:analyze": "cross-env ANALYZE=true pnpm run build:prod",
"preview": "next start",
"dev": "concurrently 'yarn dev:css' 'yarn dev:next'",
"dev:next": "next dev",
"dev:css": "yarn generate:css --watch",
"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",
"fmt": "yarn format"
"dev": "next dev",
"generate:contentlayer": "contentlayer build",
"lint": "pnpm run build:check && prettier --check . && cross-env TIMING=1 eslint --format=pretty src",
"format": "pnpm run build:check && prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src",
"fmt": "pnpm run format"
},
"type": "commonjs",
"directories": {
"lib": "src"
},
"contributors": [
"Crawl <icrawltogo@gmail.com>"
],
@@ -43,58 +43,58 @@
"url": "https://github.com/discordjs/discord.js/issues"
},
"homepage": "https://discord.js.org",
"funding": "https://github.com/discordjs/discord.js?sponsor",
"dependencies": {
"@code-hike/mdx": "^0.9.0",
"@discordjs/ui": "workspace:^",
"@react-icons/all-files": "^4.1.0",
"@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.1",
"next": "^13.4.12",
"next-contentlayer": "0.3.1",
"next-themes": "^0.2.1",
"@vercel/analytics": "^1.2.2",
"@vercel/edge-config": "^1.1.0",
"@vercel/og": "^0.6.2",
"ariakit": "2.0.0-next.44",
"cmdk": "^1.0.0",
"contentlayer": "^0.3.4",
"next": "14.2.1",
"next-contentlayer": "^0.3.4",
"next-themes": "^0.3.0",
"react": "^18.2.0",
"react-custom-scrollbars-2": "^4.5.0",
"react-dom": "^18.2.0",
"rehype-autolink-headings": "^6.1.1",
"rehype-slug": "^5.1.0",
"remark-gfm": "^3.0.1",
"sharp": "^0.32.4"
"sharp": "^0.33.3"
},
"devDependencies": {
"@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.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",
"@next/bundle-analyzer": "14.2.1",
"@testing-library/react": "^15.0.2",
"@testing-library/user-event": "^14.5.2",
"@types/html-escaper": "^3.0.2",
"@types/node": "18.18.8",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"@unocss/eslint-plugin": "^0.59.3",
"@unocss/postcss": "^0.58.5",
"@unocss/reset": "^0.59.3",
"@vitejs/plugin-react": "^4.2.1",
"@vitest/coverage-v8": "^1.5.0",
"cross-env": "^7.0.3",
"eslint": "^8.46.0",
"eslint-config-neon": "^0.1.47",
"eslint-formatter-pretty": "^5.0.0",
"happy-dom": "^10.5.2",
"eslint": "^8.57.0",
"eslint-config-neon": "^0.1.62",
"eslint-formatter-pretty": "^6.0.1",
"happy-dom": "^14.7.1",
"hast-util-to-string": "^2.0.0",
"hastscript": "^7.2.0",
"hastscript": "^8.0.0",
"html-escaper": "^3.0.3",
"lighthouse": "^10.4.0",
"prettier": "^2.8.8",
"turbo": "^1.10.12",
"typescript": "^5.1.6",
"unocss": "^0.54.0",
"vercel": "^31.2.0",
"vitest": "^0.33.0"
"postcss": "^8.4.38",
"prettier": "^3.2.5",
"turbo": "^1.13.2",
"typescript": "^5.4.5",
"unocss": "^0.59.3",
"vercel": "^34.0.0",
"vitest": "^1.5.0"
},
"engines": {
"node": ">=18.13.0"
"node": ">=18"
}
}

View File

@@ -0,0 +1,5 @@
module.exports = {
plugins: {
'@unocss/postcss': {},
},
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 290 KiB

View File

@@ -1,7 +1,10 @@
'use client';
import { Providers } from './providers';
import { inter } from '~/util/fonts';
import { Providers } from './providers';
import '~/styles/cmdk.css';
import '~/styles/main.css';
export default function GlobalError({ error }: { readonly error: Error }) {
console.error(error);

View File

@@ -1,5 +1,5 @@
import { allContents } from 'contentlayer/generated';
import { notFound } from 'next/navigation';
import { allContents } from 'contentlayer/generated';
import { Mdx } from '~/components/Mdx';
export async function generateStaticParams() {

View File

@@ -1,8 +1,8 @@
import type { PropsWithChildren } from 'react';
import { Providers } from './providers';
import Footer from '~/components/Footer';
import Header from '~/components/Header';
import { Nav } from '~/components/Nav';
import { Providers } from './providers';
export default function Layout({ children }: PropsWithChildren) {
return (

View File

@@ -1,25 +1,29 @@
import { Analytics } from '@vercel/analytics/react';
import type { Metadata } from 'next';
import type { Metadata, Viewport } from 'next';
import type { PropsWithChildren } from 'react';
import { Providers } from './providers';
import { DESCRIPTION } from '~/util/constants';
import { inter, jetBrainsMono } from '~/util/fonts';
import { Providers } from './providers';
import '@unocss/reset/tailwind-compat.css';
import '~/styles/unocss.css';
import '~/styles/cmdk.css';
import '@code-hike/mdx/styles.css';
import '~/styles/ch.css';
import '~/styles/main.css';
export const viewport: Viewport = {
themeColor: [
{ media: '(prefers-color-scheme: light)', color: '#f1f3f5' },
{ media: '(prefers-color-scheme: dark)', color: '#181818' },
],
colorScheme: 'light dark',
};
export const metadata: Metadata = {
metadataBase: new URL(
process.env.METADATA_BASE_URL ? process.env.METADATA_BASE_URL : `http://localhost:${process.env.PORT ?? 3_000}`,
),
title: 'discord.js',
description: DESCRIPTION,
viewport: {
minimumScale: 1,
initialScale: 1,
width: 'device-width',
},
icons: {
other: [
{
@@ -44,12 +48,6 @@ export const metadata: Metadata = {
manifest: '/site.webmanifest',
themeColor: [
{ media: '(prefers-color-scheme: light)', color: '#f1f3f5' },
{ media: '(prefers-color-scheme: dark)', color: '#181818' },
],
colorScheme: 'light dark',
appleWebApp: {
title: 'discord.js',
},

View File

@@ -6,7 +6,7 @@ export default function NotFound() {
<h1 className="text-[9rem] font-black leading-none md:text-[12rem]">404</h1>
<h2 className="text-[2rem] md:text-[3rem]">Not found.</h2>
<Link
className="h-11 flex flex-row transform-gpu cursor-pointer select-none appearance-none place-items-center border-0 rounded bg-blurple px-6 text-base font-semibold leading-none text-white no-underline outline-none active:translate-y-px focus:ring focus:ring-width-2 focus:ring-white"
className="h-11 flex flex-row transform-gpu cursor-pointer select-none appearance-none place-items-center border-0 rounded bg-blurple px-6 text-base text-white font-semibold leading-none no-underline outline-none active:translate-y-px focus:ring focus:ring-width-2 focus:ring-white"
href="/guide"
>
Take me back

View File

@@ -3,6 +3,7 @@
import { VscGithubInverted } from '@react-icons/all-files/vsc/VscGithubInverted';
import { VscMenu } from '@react-icons/all-files/vsc/VscMenu';
import { Button } from 'ariakit/button';
import type { Route } from 'next';
import dynamic from 'next/dynamic';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
@@ -23,7 +24,7 @@ export default function Header() {
.map((path, idx, original) => (
<Link
className="rounded outline-none hover:underline focus:ring focus:ring-width-2 focus:ring-blurple"
href={`/${original.slice(0, idx + 1).join('/')}`}
href={`/${original.slice(0, idx + 1).join('/')}` as Route}
key={`${path}-${idx}`}
>
{path}

View File

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

View File

@@ -1,8 +1,8 @@
'use client';
import { Scrollbars } from 'react-custom-scrollbars-2';
import { Sidebar } from './Sidebar';
import { useNav } from '~/contexts/nav';
import { Sidebar } from './Sidebar';
export function Nav() {
const { opened } = useNav();
@@ -23,7 +23,9 @@ export function Nav() {
)}
universal
>
<Sidebar />
<div className="flex flex-col gap-4 p-3">
<Sidebar />
</div>
</Scrollbars>
</nav>
);

View File

@@ -1,10 +1,11 @@
'use client';
import { allContents } from 'contentlayer/generated';
import type { Route } from 'next';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import { Section } from './Section';
import { allContents } from 'contentlayer/generated';
import { useNav } from '~/contexts/nav';
import { Section } from './Section';
const items = allContents.map((content) => ({
title: content.title,
@@ -31,7 +32,7 @@ export function Sidebar() {
const { setOpened } = useNav();
return (
<div className="flex flex-col gap-3 p-3">
<div className="flex flex-col gap-4">
{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 z-10"
@@ -40,12 +41,12 @@ export function Sidebar() {
>
{itemsByCategory[category]?.map((member, index) => (
<Link
className={`dark:border-dark-100 border-light-800 focus:ring-width-2 focus:ring-blurple ml-5 flex flex-col border-l p-[5px] pl-6 outline-none focus:rounded focus:border-0 focus:ring ${
className={`dark:border-dark-100 border-light-800 focus:ring-width-2 focus:ring-blurple ml-5 flex flex-col border-l first:mt-1 p-[5px] pl-6 outline-none focus:rounded focus:border-0 focus:ring ${
decodeURIComponent(pathname ?? '') === member.href
? 'bg-blurple text-white'
: 'dark:hover:bg-dark-200 dark:active:bg-dark-100 hover:bg-light-700 active:bg-light-800'
}`}
href={member.href}
href={member.href as Route}
key={`${member.title}-${index}`}
onClick={() => setOpened(false)}
title={member.title}

View File

@@ -8,15 +8,12 @@ category: Home
If you're reading this, it probably means you want to learn how to make a bot with discord.js. Awesome! You've come to the right place.
This guide will teach you things such as:
- How to get a bot [up and running](/preparations/) from scratch;
- How to properly [create](/creating-your-bot/), [organize](/creating-your-bot/command-handling.md), and expand on your commands;
- In-depth explanations and examples regarding popular topics (e.g. [reactions](/popular-topics/reactions.md), [embeds](/popular-topics/embeds.md), [canvas](/popular-topics/canvas.md));
- Working with databases (e.g. [sequelize](/sequelize/) and [keyv](/keyv/));
- Getting started with [sharding](/sharding/);
- How to get a bot [up and running](../getting-started/starting-out) from scratch;
- In-depth explanations regarding features and concepts of the API (e.g. [intents](../topics/intents), [threads](../topics/threads), [webhooks](../topics/webhooks));
- And much more.
This guide will also cover subjects like common errors and how to solve them, keeping your code clean, setting up a proper development environment, etc.
Sounds good? Great! Let's get started, then.
Sounds good? Great! Let's get started.
## Before you begin...
@@ -25,11 +22,11 @@ While you _can_ make a bot with very little JavaScript and programming knowledge
If you don't know JavaScript but would like to learn about it, here are a few links to help get you started:
- [Eloquent JavaScript, a free online book](http://eloquentjavascript.net/)
- [JavaScript.info, a modern javascript tutorial](https://javascript.info/)
- [Codecademy's interactive JavaScript course](https://www.codecademy.com/learn/introduction-to-javascript)
- [Nodeschool, for both JavaScript and Node.js lessons](https://nodeschool.io/)
- [MDN's JavaScript guide and full documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript)
- [Eloquent JavaScript, a free online book](http://eloquentjavascript.net)
- [JavaScript.info, a modern javascript tutorial](https://javascript.info)
- [Codecademy's interactive JavaScript course](https://codecademy.com/learn/introduction-to-javascript)
- [Nodeschool, for both JavaScript and Node.js lessons](https://nodeschool.io)
- [MDN's JavaScript guide and full documentation](https://developer.mozilla.org/docs/Web/JavaScript)
- [Google, your best friend](https://google.com)
Take your pick, learn some JavaScript, and once you feel like you're confident enough to make a bot, come back and get started!

View File

@@ -21,9 +21,7 @@ category: Home
time: 'Today at 21:00',
}}
>
discord.js v14 has released and the guide has been updated!
<br />
This includes additions and changes made in Discord, such as slash commands and message components.
This website is new! We will no longer be updating the old guide website.
</DiscordMessage>
</DiscordMessages>
@@ -33,25 +31,9 @@ We have moved from VuePress to [Next.js](https://nextjs.org/)! The source can be
## Pages
All content has been updated to use discord.js v14 syntax. The v13 version of the guide can be found at https://v13.discordjs.guide.
### New
- [Updating from v13 to v14](/additional-info/changes-in-v14.md): A list of the changes from discord.js v13 to v14
- [Slash commands](/interactions/slash-commands.md): Registering, replying to slash commands and permissions
- [Buttons](/interactions/buttons.md): Building, sending, and receiving buttons
- [Select menus](/interactions/select-menus.md): Building, sending, and receiving select menus
- [Threads](/popular-topics/threads.md): Creating and managing threads
- [Builders](/popular-topics/builders.md): A collection of builders to use with your bot
### Updated
- Commando: Replaced with [Sapphire](https://sapphirejs.dev/docs/Guide/getting-started/getting-started-with-sapphire)
- [Voice](/voice/): Rewritten to use the [_`@discordjs/voice`_](https://github.com/discordjs/discord.js/tree/main/packages/voice) package
- [Command handling](/creating-your-bot/command-handling.md/): Updated to use slash commands
- Obsolete sections removed
- _`client.on('message')`_ snippets updated to _`client.on(Events.InteractionCreate)`_
- [Message content became a privileged intent on August 31, 2022](https://support-dev.discord.com/hc/articles/4404772028055)
- Pages have been revamped to account for our new [create-discord-bot](https://github.com/discordjs/discord.js/tree/main/packages/create-discord-bot) command-line interface.
- Popular topic are now simply "topics" that detail usage of a particular concept of the API.
- Focus is primarily on discord.js, so irrelevant topics have been removed. It may be better to visit the documentation of the package you are using to learn how to use them.
<DiscordMessages rounded>
<DiscordMessage

View File

@@ -7,16 +7,16 @@ category: Home
Since this guide is made specifically for the discord.js community, we want to be sure to provide the most relevant and up-to-date content. We will, of course, make additions to the current pages and add new ones as we see fit, but fulfilling requests is how we know we're providing content you all want the most.
Requests may be as simple as "add an example to the [frequently asked questions](/popular-topics/faq.html) page", or as elaborate as "add a page regarding [sharding](/sharding/)". We'll do our best to fulfill all requests, as long as they're reasonable.
Requests may be as simple as "add an example to the [frequently asked questions](../topics/frequently-asked-questions) page", or as elaborate as "add a page regarding [sharding](../topics/sharding)". We'll do our best to fulfill all requests, as long as they're reasonable.
To make a request, simply head over to [the repository's issue tracker](https://github.com/discordjs/discord.js/issues) and [create a new issue](https://github.com/discordjs/discord.js/issues/new)! Title it appropriately, and let us know exactly what you mean inside the issue description. Make sure that you've looked around the site before making a request; what you want to request might already exist!
<Alert title="Tip" type="success">
<Alert title="Tip" type="info">
Remember that you can always [fork the repository](https://github.com/discordjs/discord.js/fork) and [make a pull
request](https://github.com/discordjs/discord.js/pulls) if you want to add anything to the guide yourself!
</Alert>
We'll also get into some of the more advanced features this guide does below.
We'll also get into some of the more advanced features this guide uses below. We recommended you have a look at the [source](https://github.com/discordjs/discord.js/blob/main/apps/guide/src/content/01-home/03-how-to-contribute.mdx) of this page to see exactly how they work.
## Components

View File

@@ -0,0 +1,64 @@
---
title: Starting out
category: Getting started
---
# Starting out
Our [create-discord-bot](https://github.com/discordjs/discord.js/tree/main/packages/create-discord-bot) command-line interface sets up a basic Discord bot to help you get started on your journey.
## Creating your bot
To use discord.js, you'll need to install [Node.js](https://nodejs.org), [Deno](https://deno.com), or [Bun](https://bun.sh). discord.js v14 requires Node.js v16.11.0 or higher, but the long-term support (LTS) version is always recommended. For the purposes of this guide, we will be using Node.js.
<Alert title="Tip" type="info">
To check if you already have Node.js installed, run _`node --version`_ in your terminal. If it outputs _`v16.11.0`_ or
higher, then you're good to go!
</Alert>
### Windows
- Download from the [Node.js website](https://nodejs.org).
- Use [fnm](https://github.com/Schniz/fnm).
- Use [Volta](https://volta.sh).
### macOS
- Download from the [Node.js website](https://nodejs.org/).
- Use [fnm](https://github.com/Schniz/fnm).
- Use [Homebrew](https://formulae.brew.sh/formula/node).
- Use [nvm](https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating).
- Use [Volta](https://volta.sh).
### Linux
- Visit [this page](https://nodejs.org/en/download/package-manager) to determine how you should install Node.js.
- Use [fnm](https://github.com/Schniz/fnm).
- Use [nvm](https://github.com/nvm-sh/nvm).
- Use [Volta](https://volta.sh).
After installing Node.js, you'll be able to create a new application from your desired package manager. If you're starting out fresh, installing Node.js will also install npm, a package manager for Node.js.
<CH.Code lineNumbers={false} showCopyButton={true}>
```sh npm
npm create discord-bot
```
```sh yarn
yarn create discord-bot
```
```sh pnpm
pnpm create discord-bot
```
```sh bun
bun create discord-bot
```
</CH.Code>
You'll be asked the directory to create the application in, as well as whether TypeScript should be used. Dependencies will automatically be installed for you. After this, you've just got your startup Discord bot template _nearly_ ready!
In the next section, we will explain how to create an application to interact with Discord's API.

View File

@@ -1,25 +1,28 @@
---
title: Setting up a bot application
category: Installations and preparations
title: Setting up an application
category: Getting started
---
# Setting up a bot application
# Setting up an application
## Creating your bot
You'll need to create an application on Discord's developer portal so your bot has a token to interact with Discord's API.
Now that you've installed Node, discord.js, and hopefully a linter, you're almost ready to start coding! The next step you need to take is setting up an actual Discord bot application via Discord's website.
## Creating the application
It's effortless to create one. The steps you need to take are as follows:
Follow these steps:
1. Open the [Discord developer portal](https://discord.com/developers/applications) and log into your account.
1. Open the [Discord developer portal](https://discord.com/developers/applications). You'll need to be logged in.
2. Click on the "New Application" button.
3. Enter a name and confirm the pop-up window by clicking the "Create" button.
- You'll need to agree to the [Developer Terms of Service](https://discord.com/developers/docs/policies-and-agreements/terms-of-service) and [Developer Policy](https://discord.com/developers/docs/policies-and-agreements/developer-policy).
You should see a page like this:
![Successfully created application](/assets/create-app.png)
You can edit your application's name, description, and avatar here. Once you've saved your changes, move on by selecting the "Bot" tab in the left pane.
You can edit your application's name, description, and avatar here. Copy the application id and paste it in the .env file after _`APPLICATION_ID=`_.
Once you've saved your changes, move on by selecting the "Bot" tab in the left pane.
## Your bot's token
@@ -32,9 +35,11 @@ On the bot tab, you'll see a section like this:
![Bot application](/assets/bot-user.png)
In this panel, you can give your bot a snazzy avatar, set its username, and make it public or private. Your bot's token will be revealed when you press the "Reset Token" button and confirm. When we ask you to paste your bot's token somewhere, this is the value that you need to put in. If you happen to lose your bot's token at some point, you need to come back to this page and reset your bot's token again which will reveal the new token, invalidating all old ones.
In this panel, you can give your bot a snazzy avatar, set its username, and make it public or private. Your bot's token will be revealed when you press the "Reset Token" button and confirm. Once you've done this, copy it and paste it in the .env file after _`DISCORD_TOKEN=`_.
### What is a token, anyway?
If you happen to lose this token at some point, you will need to come back to this page and reset it, which will reveal the new token, invalidating all old ones.
### Bot token explanation
A token is essentially your bot's password; it's what your bot uses to login to Discord. With that said, **it is vital that you do not ever share this token with anybody, purposely or accidentally**. If someone does manage to get a hold of your bot's token, they can use your bot as if it were theirs—this means they can perform malicious acts with it.
@@ -52,8 +57,6 @@ Let's imagine that you have a bot on over 1,000 servers, and it took you many, m
All that and much, much more. Sounds pretty terrible, right? So make sure to keep your bot's token as safe as possible!
In the [configuration files](../creating-your-bot/configuration-files) page of the guide, we cover how to safely store your bot's token in a configuration file.
<Alert title="Compromised tokens" type="danger">
If your bot token has been compromised by committing it to a public repository, posting it in discord.js support etc.
or otherwise see your bot's token in danger, return to this page and press "Reset Token". This will invalidate all old

View File

@@ -0,0 +1,48 @@
---
title: Adding your bot to a server
category: Getting started
---
# Adding your bot to a server
After you [set up an application](./setting-up-an-application), you'll notice it's not in any servers yet. So, how does that work?
Before you're able to see your bot in a server, you will need to add it by using an invite link.
## Bot invite links
The basic version of one such link looks like this:
<CH.Code lineNumbers={false}>
```
https://discord.com/api/oauth2/authorize?client_id=123456789012345678&permissions=0&scope=bot
```
</CH.Code>
The structure of the URL is quite simple:
- _`https://discord.com/api/oauth2/authorize`_ is Discord's standard structure for authorizing an OAuth2 application (such as your bot application) for entry to a Discord server.
- _`client_id=...`_ is to specify _which_ application you want to authorize. You'll need to replace this part with your client's id to create a valid invite link.
- _`permissions=...`_ describes the permissions that your bot will request to be granted by default upon joining the server you are adding it to.
- _`scope=bot`_ specifies that you want to add this application as a Discord bot with the ability to create slash commands.
<Alert title="Warning" type="warning">
If you get an error message saying "Bot requires a code grant", head over to your application's settings and disable
the "Requires OAuth2 Code Grant" option. You shouldn't enable this option unless you know why you need to.
</Alert>
## Creating and using your invite link
To create an invite link, head back to the [developer portal](https://discord.com/developers/applications), click on your bot application, and open the OAuth2 page.
In the sidebar, you'll find the URL generator. Select the _`bot`_ option. Once you select the _`bot`_ option, a list of permissions will appear, allowing you to configure the permissions your bot needs.
Grab the link via the "Copy" button and send it in a channel in Discord. Click on the link you just sent which should reveal this:
![Bot Authorization page](/assets/bot-auth-page.png)
Choose the server you want to add the bot to and click "Authorize". Congratulations! You've successfully added your bot to your Discord server.
At this point, you should have a Discord bot you created with [create-discord-bot](https://github.com/discordjs/discord.js/tree/main/packages/create-discord-bot) with your .env file populated and your Discord bot in a server. You are now ready to do what you like.

View File

@@ -1,102 +0,0 @@
---
title: Installing Node.js and discord.js
category: Installations and preparations
---
# Installing Node.js and discord.js
## Installing Node.js
To use discord.js, you'll need to install [Node.js](https://nodejs.org/). discord.js v14 requires Node v16.9.0 or higher.
<Alert title="Tip" type="success">
To check if you already have Node installed on your machine \(e.g., if you're using a VPS\), run _`node -v`_ in your
terminal. If it outputs _`v16.9.0`_ or higher, then you're good to go! Otherwise, continue reading.
</Alert>
On Windows, it's as simple as installing any other program. Download the latest version from [the Node.js website](https://nodejs.org/), open the downloaded file, and follow the steps from the installer.
On macOS, either:
- Download the latest version from [the Node.js website](https://nodejs.org/), open the package installer, and follow the instructions
- Use a package manager like [Homebrew](https://brew.sh/) with the command _`brew install node`_
On Linux, you can consult [this page](https://nodejs.org/en/download/package-manager/) to determine how you should install Node. Native package managers often default to outdated versions of Node, so make sure you follow the recommended approach for your chosen Linux distribution carefully.
## Preparing the essentials
To use discord.js, you'll need to install it via npm \(Node's package manager\). npm comes with every Node installation, so you don't have to worry about installing that. However, before you install anything, you should set up a new project folder.
Navigate to a suitable place on your machine and create a new folder named _`discord-bot`_ (or whatever you want). Next you'll need to open your terminal.
### Opening the terminal
<Alert title="Tip" type="success">
If you use [Visual Studio Code](https://code.visualstudio.com/), you can press <kbd>Ctrl + `</kbd> (backtick) to open
its integrated terminal.
</Alert>
On Windows, either:
- <kbd>Shift + Right-click</kbd> inside your project directory and choose the "Open command window here" option
- Press <kbd>Win + R</kbd> and run _`cmd.exe`_, and then _`cd`_ into your project directory
On macOS, either:
- Open Launchpad or Spotlight and search for "Terminal"
- In your "Applications" folder, under "Utilities", open the Terminal app
On Linux, you can quickly open the terminal with <kbd>Ctrl + Alt + T</kbd>.
With the terminal open, run the _`node -v`_ command to make sure you've successfully installed Node.js. If it outputs _`v16.9.0`_ or higher, great!
### Initiating a project folder
<CH.Code lineNumbers={false}>
```sh npm
npm init; npm pkg set type="module"
```
```sh yarn
yarn init
# You must go into your package.json file and add "type": "module"
```
```sh pnpm
pnpm init; pnpm pkg set type="module"
```
</CH.Code>
This is the next command you'll be running. This command creates a _`package.json`_ file for you, which will keep track of the dependencies your project uses, as well as other info.
This command will ask you a sequence of questionsyou should fill them out as you see fit. If you're not sure of something or want to skip it as a whole, leave it blank and press enter. Setting the package type as _`module`_ tells Node that you'll be writing this project using ESM \(ECMAScript modules\), supporting the latest JavaScript syntax and features.
Once you're done with that, you're ready to install discord.js!
## Installing discord.js
Now that you've installed Node.js and know how to open your console and run commands, you can finally install discord.js! Run the following command in your terminal:
<CH.Code lineNumbers={false}>
```sh npm
npm install discord.js
```
```sh yarn
yarn add discord.js
```
```sh pnpm
pnpm add discord.js
```
</CH.Code>
And that's it! With all the necessities installed, you're almost ready to start coding your bot.
## Installing a linter
While you are coding, it's possible to run into numerous syntax errors or code in an inconsistent style. You should [install a linter](./setting-up-a-linter) to ease these troubles. While code editors generally can point out syntax errors, linters coerce your code into a specific style as defined by the configuration. While this is not required, it is advised.

View File

@@ -1,6 +0,0 @@
---
title: Setting up a linter
category: Installations and preparations
---
TODO: Rewrite. Placeholder page for ordering.

View File

@@ -1,52 +0,0 @@
---
title: Adding your bot to servers
category: Installations and preparations
---
# Adding your bot to servers
After you [set up a bot application](./setting-up-a-bot-application), you'll notice that it's not in any servers yet. So how does that work?
Before you're able to see your bot in your own (or other) servers, you'll need to add it by creating and using a unique invite link using your bot application's client id.
## Bot invite links
The basic version of one such link looks like this:
<CH.Code lineNumbers={false}>
```
https://discord.com/api/oauth2/authorize?client_id=123456789012345678&permissions=0&scope=bot%20applications.commands
```
</CH.Code>
The structure of the URL is quite simple:
- _`https://discord.com/api/oauth2/authorize`_ is Discord's standard structure for authorizing an OAuth2 application (such as your bot application) for entry to a Discord server.
- _`client_id=...`_ is to specify _which_ application you want to authorize. You'll need to replace this part with your client's id to create a valid invite link.
- _`permissions=...`_ describes the permissions that your bot will request to be granted by default upon joining the server you are adding it to.
- _`scope=bot%20applications.commands`_ specifies that you want to add this application as a Discord bot, with the ability to create slash commands.
<Alert title="Warning" type="warning">
If you get an error message saying "Bot requires a code grant", head over to your application's settings and disable
the "Require OAuth2 Code Grant" option. You shouldn't enable this option unless you know why you need to.
</Alert>
## Creating and using your invite link
To create an invite link, head back to the [My Apps](https://discord.com/developers/applications/me) page under the "Applications" section, click on your bot application, and open the OAuth2 page.
In the sidebar, you'll find the OAuth2 URL generator. Select the _`bot`_ and _`applications.commands`_ options. Once you select the _`bot`_ option, a list of permissions will appear, allowing you to configure the permissions your bot needs.
Grab the link via the "Copy" button and enter it in your browser. You should see something like this (with your bot's username and avatar):
![Bot Authorization page](/assets/bot-auth-page.png)
Choose the server you want to add it to and click "Authorize". Do note that you'll need the "Manage Server" permission on a server to add your bot there. This should then present you a nice confirmation message:
![Bot authorized](/assets/bot-authorized.png)
Congratulations! You've successfully added your bot to your Discord server. It should show up in your server's member list somewhat like this:
![Bot in server's member list](/assets/bot-in-memberlist.png)

View File

@@ -1,132 +0,0 @@
---
title: Configuration files
category: Creating your bot
---
# Configuration files
Once you [add your bot to a server](../installations-and-preparations/adding-your-bot-to-servers), the next step is to start coding and get it online! Let's start by creating a config file to prepare the necessary values your client will need.
As explained in the ["What is a token, anyway?"](../installations-and-preparations/setting-up-a-bot-application.md#what-is-a-token-anyway) section, your token is essentially your bot's password, and you should protect it as best as possible. This can be done through a _`config.json`_ file or by using environment variables.
Open your application in the [Discord Developer Portal](https://discord.com/developers/applications) and go to the "Bot" page to copy your token.
## Using config.json
Storing data in a _`config.json`_ file is a common way of keeping your sensitive values safe. Create a _`config.json`_ file in your project directory and paste in your token. You can access your token inside other files by importing this file.
<CH.Code lineNumbers={false}>
```json config.json
{
"token": "your-token-goes-here"
}
```
```js index.js
import config from './config.json' assert { type: 'json' };
console.log(config.token);
```
</CH.Code>
<Alert title="Danger" type="danger">
If you're using Git, you should not commit this file and should [ignore it via `.gitignore`](#git-and-gitignore).
</Alert>
## Using environment variables
Environment variables are special values for your environment (e.g., terminal session, Docker container, or environment variable file). You can pass these values into your code's scope so that you can use them.
One way to pass in environment variables is via the command line interface. When starting your app, instead of _`node index.js`_, use _`TOKEN=your-token-goes-here node index.js`_. You can repeat this pattern to expose other values as well.
You can access the set values in your code via the _`process.env`_ global variable, accessible in any file. Note that values passed this way will always be strings and that you might need to parse them to a number, if using them to do calculations.
<CH.Code lineNumbers={false} rows={3}>
```sh Shell
A=123 B=456 DISCORD_TOKEN=your-token-goes-here node index.js
```
```js index.js
console.log(process.env.A);
console.log(process.env.B);
console.log(process.env.DISCORD_TOKEN);
```
</CH.Code>
### Using dotenv
Another common approach is storing these values in a _`.env`_ file. This spares you from always copying your token into the command line. Each line in a _`.env`_ file should hold a _`KEY=value`_ pair.
You can use the [`dotenv` package](https://www.npmjs.com/package/dotenv) for this. Once installed, require and use the package to load your _`.env`_ file and attach the variables to _`process.env`_:
<CH.Code lineNumbers={false}>
```sh npm
npm install dotenv
```
```sh yarn
yarn add dotenv
```
```sh pnpm
pnpm add dotenv
```
</CH.Code>
<CH.Code lineNumbers={false} rows={7}>
```sh .env
A=123
B=456
DISCORD_TOKEN=your-token-goes-here
```
```js index.js
import { config } from 'dotenv';
config();
console.log(process.env.A);
console.log(process.env.B);
console.log(process.env.DISCORD_TOKEN);
```
</CH.Code>
<Alert title="Danger" type="danger">
If you're using Git, you should not commit this file and should [ignore it via `.gitignore`](#git-and-gitignore).
</Alert>
<Alert title="Online editors (Glitch, Heroku, Replit, etc.)" type="info">
While we generally do not recommend using online editors as hosting solutions, but rather invest in a proper virtual private server, these services do offer ways to keep your credentials safe as well! Please see the respective service's documentation and help articles for more information on how to keep sensitive values safe:
- Glitch: [Storing secrets in .env](https://glitch.happyfox.com/kb/article/18)
- Heroku: [Configuration variables](https://devcenter.heroku.com/articles/config-vars)
- Replit: [Secrets and environment variables](https://docs.replit.com/repls/secrets-environment-variables)
</Alert>
## Git and .gitignore
Git is a fantastic tool to keep track of your code changes and allows you to upload progress to services like [GitHub](https://github.com/), [GitLab](https://about.gitlab.com/), or [Bitbucket](https://bitbucket.org/product). While this is super useful to share code with other developers, it also bears the risk of uploading your configuration files with sensitive values!
You can specify files that Git should ignore in its versioning systems with a*`.gitignore`* file. Create a _`.gitignore`_ file in your project directory and add the names of the files and folders you want to ignore:
```
node_modules
.env
config.json
```
<Alert title="Tip" type="success">
Aside from keeping credentials safe, _`node_modules`_ should be included here. Since this directory can be restored based on the entries in your _`package.json`_ and _`package-lock.json`_ files by running _`npm install`_, it does not need to be included in Git.
You can specify quite intricate patterns in _`.gitignore`_ files, check out the [Git documentation on `.gitignore`](https://git-scm.com/docs/gitignore) for more information!
</Alert>

View File

@@ -1,60 +0,0 @@
---
title: Creating the main file
category: Creating your bot
---
# Creating the main file
<Alert title="Tip" type="success">
This page assumes you've already prepared the [configuration files](./configuration-files) from the previous page.
We're using the _`config.json`_ approach, however feel free to substitute your own!
</Alert>
Open your code editor and create a new file. We suggest that you save the file as _`index.js`_, but you may name it whatever you wish.
Here's the base code to get you started:
<CH.Code>
```js
// Require the necessary discord.js classes
import { Client, Events, GatewayIntentBits } from 'discord.js';
import config from './config.json' assert { type: 'json' };
// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
// When the client is ready, run this code (only once)
// We use 'c' for the event parameter to keep it separate from the already defined 'client'
client.once(Events.ClientReady, (c) => {
console.log(`Ready! Logged in as ${c.user.tag}`);
});
// Log in to Discord with your client's token
client.login(config.token);
```
</CH.Code>
This is how you create a client instance for your Discord bot and log in to Discord. The _`GatewayIntentBits.Guilds`_ intents option is necessary for the discord.js client to work as you expect it to, as it ensures that the caches for guilds, channels, and roles are populated and available for internal use.
<Alert title="Tip" type="success">
The term "guild" is used by the Discord API and in discord.js to refer to a Discord server.
</Alert>
Intents also define which events Discord should send to your bot, and you may wish to enable more than just the minimum. You can read more about the other intents on the [Intents topic](../popular-topics/intents).
## Running your application
Open your terminal and run _`node index.js`_ to start the process. If you see "Ready!" after a few seconds, you're good to go! The next step is to start adding [slash commands](./adding-commands) to develop your bot's functionality.
<Alert title="Tip" type="success">
You can open your _`package.json`_ file and edit the _`"main": "index.js"`_ field to point to your main file. You can then run _`node .`_ in your terminal to start the process!
After closing the process with _`Ctrl + C`_, you can press the up arrow on your keyboard to bring up the latest commands you've run. Pressing up and then enter after closing the process is a quick way to start it up again.
</Alert>
#### Resulting code
<ResultingCode path="creating-your-bot/initial-files" />

View File

@@ -1,163 +0,0 @@
---
title: Adding commands
category: Creating your bot
---
# Creating slash commands
Discord allows developers to register [slash commands](https://discord.com/developers/docs/interactions/application-commands), which provide users a first-class way of interacting directly with your application.
Slash commands provide a huge number of benefits over manual message parsing, including:
- Integration with the Discord client interface.
- Automatic command detection and parsing of the associated options/arguments.
- Typed argument inputs for command options, e.g. "String", "User", or "Role".
- Validated or dynamic choices for command options.
- In-channel private responses (ephemeral messages).
- Pop-up form-style inputs for capturing additional information.
...and many more!
<Alert title="Read first!" type="info">
For fully functional slash commands, there are three important pieces of code that need to be written. They are:
1. The individual command files, containing their definitions and functionality.
2. The [command handler](command-handling.html), which dynamically reads the files and executes the commands.
3. The [command deployment script](command-deployment.html), to register your slash commands with Discord so they appear in the interface.
These steps can be done in any order, but **all are required** before the commands are fully functional.
On this page, you'll complete Step 1. Make sure to also complete the other pages linked above!
</Alert>
## Before you continue
Assuming you've followed the guide so far, your project directory should look something like this:
```:no-line-numbers
discord-bot/
├── node_modules
├── config.json
├── index.js
├── package-lock.json
└── package.json
```
## Individual command files
Create a new folder named _`commands`_, which is where you'll store all of your command files.
At a minimum, the definition of a slash command must have a name and a description. Slash command names must be between 1-32 characters and contain no capital letters, spaces, or symbols other than _`-`_ and _`_`_. Using the builder, a simple _`ping`\_ command definition would look like this:
<CH.Code>
```js
/** @type {import('discord.js').RESTPostAPIApplicationCommandsJSONBody} */
export const data = {
name: 'ping',
description: 'Replies with Pong!',
};
```
</CH.Code>
A slash command also requires a function to run when the command is used, to respond to the interaction. Using an interaction response method confirms to Discord that your bot successfully received the interaction, and has responded to the user. Discord enforces this to ensure that all slash commands provide a good user experience (UX). Failing to respond will cause Discord to show that the command failed, even if your bot is performing other actions as a result.
The simplest way to acknowledge and respond to an interaction is the _`interaction.reply()`_ method. Other methods of replying are covered on the [Response methods](../slash-commands/response-methods) page later in this section.
<CH.Code>
```js
/** @param {import('discord.js').CommandInteraction} interaction */
export async function execute(interaction) {
await interaction.reply('Pong!');
}
```
</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.
- The `execute` method, which will contain the functionality to run from our event handler when the command is used.
The _`export`_ keyword ensures these values can be imported and read by other files; namely the command loader and command deployment scripts mentioned earlier.
<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!');
}
```
</CH.Code>
<Alert title="Tip" type="success">
[`module.exports`](https://nodejs.org/api/modules.html#modules_module_exports) is how you export data in Node.js so that you can [`require()`](https://nodejs.org/api/modules.html#modules_require_id) it in other files.
If you need to access your client instance from inside a command file, you can access it via `interaction.client`. If you need to access external files, packages, etc., you should `require()` them at the top of the file.
</Alert>
That's it for your basic ping command. Below are examples of two more commands we're going to build upon throughout the guide, so create two more files for these before you continue reading.
<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
await interaction.reply(
`This command was run by ${interaction.user.username}, who joined on ${interaction.member.joinedAt}.`,
);
}
```
```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
${interaction.guild.memberCount} members.`);
}
```
</CH.Code>
#### Next steps
You can implement additional commands by creating additional files in the _`commands`_ folder, but these three are the ones we're going to use for the examples as we go on. For now let's move on to the code you'll need for command handling, to load the files and respond to incoming interactions.
#### Resulting code
<ResultingCode />

View File

@@ -1,297 +0,0 @@
---
title: Handling command interactions
category: Creating your bot
---
# Command handling
Unless your bot project is small, it's not a very good idea to have a single file with a giant _`if`_/_`else if`_ chain for commands. If you want to implement features into your bot and make your development process a lot less painful, you'll want to implement a command handler. Let's get started on that!
<Alert title="Read first!" type="info">
For fully functional slash commands, there are three important pieces of code that need to be written. They are:
1. The [individual command files](slash-commands), containing their definitions and functionality.
2. The command handler, which dynamically reads the files and executes the commands.
3. The [command deployment script](command-deployment), to register your slash commands with Discord so they appear in the interface.
These steps can be done in any order, but **all are required** before the commands are fully functional.
This page details how to complete **Step 2**. Make sure to also complete the other pages linked above!
</Alert>
## Loading command files
Now that your command files have been created, your bot needs to load these files on startup.
In your _`index.js`_ file, make these additions to the base template:
<CH.Code>
```js JavaScript mark=1:4,9
import { readdir } from 'node:fs/promises';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { Client, Collection, Events, GatewayIntentBits } from 'discord.js';
import config from './config.json' assert { type: 'json' };
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
const commands = new Collection();
client.once(Events.ClientReady, () => {
console.log('Ready!');
});
```
```ts TypeScript mark=1:11,16:21
import { readdir } from 'node:fs/promises';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import {
Client,
Collection,
Events,
GatewayIntentBits,
type RESTPostAPIChatInputApplicationCommandsJSONBody,
type ChatInputCommandInteraction,
} from 'discord.js';
import config from './config.json';
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
interface CommandModule {
data: RESTPostAPIChatInputApplicationCommandsJSONBody;
execute(interaction: ChatInputCommandInteraction): Promise<void>;
}
const commands = new Collection<string, CommandModule>();
client.once(Events.ClientReady, () => {
console.log('Ready!');
});
```
</CH.Code>
<Alert title="Tip" type="info">
- The [`fs`](https://nodejs.org/api/fs.html) module is Node's native file system module. _`readdir`_ is used to read
the _`commands`_ directory and identify our command files. - The [`path`](https://nodejs.org/api/path.html) module is
Node's native path utility module. _`join`_ helps construct paths to access files and directories. One of the
advantages of _`path.join`_ is that it automatically detects the operating system and uses the appropriate joiners. -
The [`url`](https://nodejs.org/api/url.html) module provides utilities for URL resolution and parsing.
_`fileURLToPath`_ ensuring a cross-platform valid absolute path string.
- The{' '}
<DocsLink type="class" parent="Collection" /> class extends JavaScript's native
[_`Map`_](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) class, and includes
more extensive, useful functionality. _`Collection`_ is used to store and efficiently retrieve commands for execution.
</Alert>
Next, using the modules imported above, dynamically retrieve your command files with a few more additions to the _`index.js`_ file:
<CH.Code>
```js JavaScript focus=3:15
const commands = new Collection();
const commandsPath = fileURLToPath(new URL('commands', import.meta.url));
const commandFiles = await readdir(commandsPath).then((files) => files.filter((file) => file.endsWith('.js')));
for (const file of commandFiles) {
const filePath = join(commandsPath, file);
const command = await import(filePath);
// Set a new item in the Collection with the key as the command name and the value as the exported module
if ('data' in command && 'execute' in command) {
commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
```
```ts TypeScript focus=3:15
const commands = new Collection<string, CommandModule>();
const commandsPath = fileURLToPath(new URL('commands', import.meta.url));
const commandFiles = await readdir(commandsPath).then((files) => files.filter((file) => file.endsWith('.js')));
for (const file of commandFiles) {
const filePath = join(commandsPath, file);
const command = await import(filePath);
// Set a new item in the Collection with the key as the command name and the value as the exported module
if ('data' in command && 'execute' in command) {
commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
```
</CH.Code>
First, [url.fileURLToPath()](https://nodejs.org/api/url.html) helps to construct a path to the _`commands`_ directory. The [fs.readdir()](https://nodejs.org/api/fs.html#fspromisesreaddirpath-options) method then reads the path to the directory and returns a Promise which resolves to an array of all the file names it contains, currently _`['ping.js', 'server.js', 'user.js']`_. To ensure only command files get processed, _`Array.filter()`_ removes any non-JavaScript files from the array.
With the correct files identified, the last step is to loop over the array and dynamically set each command into the _`commands`_ Collection. For each file being loaded, check that it has at least the _`data`_ and _`execute`_ properties. This helps to prevent errors resulting from loading empty, unfinished or otherwise incorrect command files while you're still developing.
## Receiving command interactions
Every slash command is an _`interaction`_, so to respond to a command, you need to create a listener for the <DocsLink type="class" parent="Client" symbol="e-interactionCreate" /> event that will execute code when your application receives an interaction. Place the code below in the _`index.js`_ file you created earlier.
<CH.Code>
```js
client.on(Events.InteractionCreate, (interaction) => {
console.log(interaction);
});
```
</CH.Code>
Not every interaction is a slash command (e.g. _`MessageComponent`_ interactions). Make sure to only handle slash commands in this function by making use of the <DocsLink type="class" parent="BaseInteraction" symbol="isChatInputCommand" brackets /> method to exit the handler if another type is encountered. This method also provides type guarding for TypeScript users, narrowing the type from _`BaseInteraction`_ to <DocsLink type="class" parent="ChatInputCommandInteraction" />.
<CH.Code>
```js focus=2
client.on(Events.InteractionCreate, (interaction) => {
if (!interaction.isChatInputCommand()) return;
console.log(interaction);
});
```
</CH.Code>
## Executing commands
When your bot receives a <DocsLink type="class" parent="Client" symbol="e-interactionCreate" /> event, the interaction object contains all the information you need to dynamically retrieve and execute your commands!
Let's take a look at the _`ping`_ command again. Note the _`execute()`_ function that will reply to the interaction with "Pong!".
<CH.Code>
```js
export const data = {
name: 'ping',
description: 'Replies with Pong!',
};
export async function execute(interaction) {
await interaction.reply('Pong!');
}
```
</CH.Code>
First, you need to get the matching command from the _`commands`_ Collection based on the _`interaction.commandName`_. If no matching command is found, log an error to the console and ignore the event.
With the right command identified, all that's left to do is call the command's _`.execute()`_ method and pass in the _`interaction`_ variable as its argument. Note that the event listener has been made _`async`_, allowing Promises to be awaited. In case something goes wrong and the Promise rejects, catch and log any error to the console.
<CH.Code>
```js focus=4:20
// focus[37:42]
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isChatInputCommand()) return;
const command = commands.get(interaction.commandName);
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
if (interaction.replied || interaction.deferred) {
await interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
} else {
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
}
});
```
</CH.Code>
## Command categories
So far, all of your command files are in a single _`commands`_ folder. This is fine at first, but as your project grows, the number of files in the _`commands`_ folder will too. Keeping track of that many files can be a little tough. To make this a little easier, you can categorize your commands and put them in subfolders inside the _`commands`_ folder. You will have to make a few changes to your existing code in _`index.js`_ for this to work out.
If you've been following along, your project structure should look something like this:
![Project structure before sorting](/assets/before-sorting.png)
After moving your commands into subfolders, it will look something like this:
![Project structure after sorting](/assets/after-sorting.png)
<Alert title="Warning" type="warning">
Make sure you put every command file you have inside one of the new subfolders. Leaving a command file directly under
the _`commands`_ folder will create problems.
</Alert>
It is not necessary to name your subfolders exactly like we have named them here. You can create any number of subfolders and name them whatever you want. Although, it is a good practice to name them according to the type of commands stored inside them.
Back in your _`index.js`_ file, where the code to [dynamically read command files](#loading-command-files) is, use the same pattern to read the subfolder directories, and then require each command inside them.
<CH.Code>
```js JavaScript focus=3:7,19
const commands = new Collection();
const foldersPath = fileURLToPath(new URL('commands', import.meta.url));
const commandFolders = await readdir(foldersPath);
for (const folder of commandFolders) {
const commandsPath = join(foldersPath, folder);
const commandFiles = await readdir(commandsPath).then((files) => files.filter((file) => file.endsWith('.js')));
for (const file of commandFiles) {
const filePath = join(commandsPath, file);
const command = await import(filePath);
// Set a new item in the Collection with the key as the command name and the value as the exported module
if ('data' in command && 'execute' in command) {
commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}
```
```ts Typescript mark=3:7,19
const commands = new Collection<string, CommandModule>();
const foldersPath = fileURLToPath(new URL('commands', import.meta.url));
const commandFolders = await readdir(foldersPath);
for (const folder of commandFolders) {
const commandsPath = join(foldersPath, folder);
const commandFiles = await readdir(commandsPath).then((files) => files.filter((file) => file.endsWith('.js')));
for (const file of commandFiles) {
const filePath = join(commandsPath, file);
const command = await import(filePath);
// Set a new item in the Collection with the key as the command name and the value as the exported module
if ('data' in command && 'execute' in command) {
commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}
```
</CH.Code>
That's it! When creating new files for commands, make sure you create them inside one of the subfolders (or a new one) in the _`commands`_ folder.
#### Next steps
Your command files are now loaded into your bot, and the event listener is prepared and ready to respond. In the next section, we cover the final step - a command deployment script you'll need to register your commands so they appear in the Discord client.
#### Resulting code
<ResultingCode />
It also includes some bonus commands!

View File

@@ -1,155 +0,0 @@
---
title: Registering slash commands
category: Creating your bot
---
# Registering slash commands
<Alert title="Read first!" type="info">
For fully functional slash commands, you need three important pieces of code:
1. The [individual command files](slash-commands), containing their definitions and functionality.
2. The [command handler](command-handling), which dynamically reads the files and executes the commands.
3. The command deployment script, to register your slash commands with Discord so they appear in the interface.
These steps can be done in any order, but **all are required** before the commands are fully functional.
This page details how to complete **Step 3**. Make sure to also complete the other pages linked above!
</Alert>
## Command registration
Slash commands can be registered in two ways; in one specific guild, or for every guild the bot is in. We're going to look at single-guild registration first, as this is a good way to develop and test your commands before a global deployment.
Your application will need the _`applications.commands`_ scope authorized in a guild for any of its slash commands to appear, and to be able to register them in a specific guild without error.
Slash commands only need to be registered once, and updated when the definition (description, options etc) is changed. As there is a daily limit on command creations, it's not necessary nor desirable to connect a whole client to the gateway or do this on every _`ClientReady`_ event. As such, a standalone script using the lighter REST manager is preferred.
This script is intended to be run separately, only when you need to make changes to your slash command **definitions** - you're free to modify parts such as the execute function as much as you like without redeployment.
### Guild commands
Create a _`deploy-commands.js`_ file in your project directory. This file will be used to register and update the slash commands for your bot application.
Add two more properties to your _`config.json`_ file, which we'll need in the deployment script:
- _`clientId`_: Your application's client id ([Discord Developer Portal](https://discord.com/developers/applications) > "General Information" > application id)
- _`guildId`_: Your development server's id ([Enable developer mode](https://support.discord.com/hc/en-us/articles/206346498) > Right-click the server title > "Copy Server ID")
<CH.Code lineNumbers={false}>
```json
{
"token": "your-token-goes-here",
"clientId": "your-application-id-goes-here",
"guildId": "your-server-id-goes-here"
}
```
</CH.Code>
With these defined, you can use the deployment script below:
<CH.Code>
```js deploy-commands.js
import { REST, Routes } from 'discord.js';
import { readdir } from 'node:fs/promises';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import config from './config.json' assert { type: 'json' };
const { clientId, guildId, token } = config;
const commands = [];
// Grab all the command files from the commands directory you created earlier
const foldersPath = fileURLToPath(new URL('commands', import.meta.url));
const commandFolders = await readdir(foldersPath);
for (const folder of commandFolders) {
// Grab all the command files from the commands directory you created earlier
const commandsPath = join(foldersPath, folder);
const commandFiles = await readdir(commandsPath).then((files) => files.filter((file) => file.endsWith('.js')));
// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
for (const file of commandFiles) {
const filePath = join(commandsPath, file);
const command = await import(filePath);
if ('data' in command && 'execute' in command) {
commands.push(command.data.toJSON());
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}
// Construct and prepare an instance of the REST module
const rest = new REST().setToken(token);
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);
// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands });
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
```
</CH.Code>
Once you fill in these values, run _`node deploy-commands.js`_ in your project directory to register your commands to the guild specified. If you see the success message, check for the commands in the server by typing _`/`_! If all goes well, you should be able to run them and see your bot's response in Discord!
### Global commands
Global application commands will be available in all the guilds your application has the _`applications.commands`_ scope authorized in, and in direct messages by default.
To deploy global commands, you can use the same script from the [guild commands](#guild-commands) section and simply adjust the route in the script to _`.applicationCommands(clientId)`_
Test
<CH.Code rows="focus">
```js focus=5
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);
// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(Routes.applicationCommands(clientId), { body: commands });
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
```
</CH.Code>
### Where to deploy
<Alert title="Tip" type="success">
Guild-based deployment of commands is best suited for development and testing in your own personal server. Once you're satisfied that it's ready, deploy the command globally to publish it to all guilds that your bot is in.
You may wish to have a separate application and token in the Discord Dev Portal for your dev application, to avoid duplication between your guild-based commands and the global deployment.
</Alert>
#### Further reading
You've successfully sent a response to a slash command! However, this is only the most basic of command event and response functionality. Much more is available to enhance the user experience including:
- applying this same dynamic, modular handling approach to events with an [Event handler](./event-handling).
- utilising the different [Response methods](../slash-commands/response-methods) that can be used for slash commands.
- expanding on these examples with additional validated option types in [Advanced command creation](../slash-commands/advanced-creation).
- adding formatted [Embeds](../popular-topics/embeds) to your responses.
- enhancing the command functionality with [Buttons](../interactions/buttons) and [Select Menus](../interactions/select-menus).
- prompting the user for more information with [Modals](../interactions/modals).
#### Resulting code
<ResultingCode path="creating-your-bot/command-deployment" />

View File

@@ -1,219 +0,0 @@
---
title: Event handling
category: Creating your bot
---
# Event handling
Node.js uses an event-driven architecture, making it possible to execute code when a specific event occurs. The discord.js library takes full advantage of this. You can visit the <DocsLink type="class" parent="Client" /> documentation to see the full list of events.
<Alert title="Tip" type="success">
This page assumes you've followed the guide up to this point, and created your _`index.js`_ and individual slash
commands according to those pages.
</Alert>
At this point, your `index.js` file has code for loading commands, and listeners for two events: `ClientReady` and `InteractionCreate`.
<CH.Code>
```js Commands
const commands = new Collection();
const foldersPath = fileURLToPath(new URL('commands', import.meta.url));
const commandFolders = await readdir(foldersPath);
for (const folder of commandFolders) {
const commandsPath = join(foldersPath, folder);
const commandFiles = await readdir(commandsPath).then((files) => files.filter((file) => file.endsWith('.js')));
for (const file of commandFiles) {
const filePath = join(commandsPath, file);
const command = await import(filePath);
// Set a new item in the Collection with the key as the command name and the value as the exported module
if ('data' in command && 'execute' in command) {
commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}
```
```js ClientReady
client.once(Events.ClientReady, (c) => {
console.log(`Ready! Logged in as ${c.user.tag}`);
});
```
```js InteractionCreate
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isChatInputCommand()) return;
const command = commands.get(interaction.commandName);
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
try {
await command.execute(interaction);
} catch (error) {
console.error(`Error executing ${interaction.commandName}`);
console.error(error);
}
});
```
</CH.Code>
Currently, all of this code is in the _`index.js`_ file. <DocsLink type="class" parent="Client" symbol="e-ready" /> emits once when the _`Client`_ becomes ready for use, and <DocsLink type="class" parent="Client" symbol="e-interactionCreate" /> emits whenever an interaction is received.
Moving the event listener code into individual files is simple, and we'll be taking a similar approach to the [command handler](./handling-command-interactions).
## Individual event files
Your project directory should look something like this:
```
discord-bot/
├── commands/
├── node_modules/
├── config.json
├── deploy-commands.js
├── index.js
├── package-lock.json
└── package.json
```
Create an _`events`_ folder in the same directory. You can then move the code from your event listeners in _`index.js`_ to separate files: _`events/ready.js`_ and _`events/interactionCreate.js`_. The _`InteractionCreate`_ event is responsible for command handling, so the command loading code will move here too.
<CH.Code>
```js events/interactionCreate.js
import { readdir } from 'node:fs/promises';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { Collection, Events } from 'discord.js';
const commands = new Collection();
const foldersPath = fileURLToPath(new URL('commands', import.meta.url));
const commandFolders = await readdir(foldersPath);
for (const folder of commandFolders) {
const commandsPath = join(foldersPath, folder);
const commandFiles = await readdir(commandsPath).then((files) => files.filter((file) => file.endsWith('.js')));
for (const file of commandFiles) {
const filePath = join(commandsPath, file);
const command = await import(filePath);
// Set a new item in the Collection with the key as the command name and the value as the exported module
if ('data' in command && 'execute' in command) {
commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}
export const data = {
name: Events.InteractionCreate,
};
export async function execute(interaction) {
if (!interaction.isChatInputCommand()) return;
const command = commands.get(interaction.commandName);
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
try {
await command.execute(interaction);
} catch (error) {
console.error(`Error executing ${interaction.commandName}`);
console.error(error);
}
}
```
```js events/ready.js
import { Events } from 'discord.js';
export const data = {
name: Events.ClientReady,
once = true,
};
export async function execute(client) {
console.log(`Ready! Logged in as ${client.user.tag}`);
}
```
```js index.js
import { readdir } from 'node:fs/promises';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { Client, GatewayIntentBits } from 'discord.js';
import config from './config.json' assert { type: 'json' };
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
client.login(config.token);
```
</CH.Code>
The _`name`_ property states which event this file is for, and the _`once`_ property holds a boolean value that specifies if the event should run only once. You don't need to specify this in _`interactionCreate.js`_ as the default behavior will be to run on every event instance. The _`execute`_ function holds your event logic, which will be called by the event handler whenever the event emits.
## Reading event files
Next, let's write the code for dynamically retrieving all the event files in the _`events`_ folder. We'll be taking a similar approach to our [command handler](./handling-command-interactions). Place the new code highlighted below in your _`index.js`_.
_`fs.readdir()`_ combined with _`array.filter()`_ returns an array of all the file names in the given directory and filters for only _`.js`_ files, i.e. _`['ready.js', 'interactionCreate.js']`_.
<CH.Code>
```js focus=9:20
import { readdir } from 'node:fs/promises';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { Client, GatewayIntentBits } from 'discord.js';
import config from './config.json' assert { type: 'json' };
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
const eventsPath = fileURLToPath(new URL('events', import.meta.url));
const eventFiles = await readdir(eventsPath).then((files) => files.filter((file) => file.endsWith('.js')));
for (const file of eventFiles) {
const filePath = join(eventsPath, file);
const event = await import(filePath);
if (event.data.once) {
client.once(event.data.name, (...args) => event.execute(...args));
} else {
client.on(event.data.name, (...args) => event.execute(...args));
}
}
client.login(config.token);
```
</CH.Code>
You'll notice the code looks very similar to the command loading above it - read the files in the events folder and load each one individually.
The <DocsLink type="class" parent="Client" /> class in discord.js extends the [`EventEmitter`](https://nodejs.org/api/events.html#events_class_eventemitter) class. Therefore, the _`client`_ object exposes the [`.on()`](https://nodejs.org/api/events.html#events_emitter_on_eventname_listener) and [`.once()`](https://nodejs.org/api/events.html#events_emitter_once_eventname_listener) methods that you can use to register event listeners. These methods take two arguments: the event name and a callback function. These are defined in your separate event files as _`name`_ and _`execute`_.
The callback function passed takes argument(s) returned by its respective event, collects them in an _`args`_ array using the _`...`_ [rest parameter syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters), then calls _`event.execute()`_ while passing in the _`args`_ array using the _`...`_ [spread syntax](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax). They are used here because different events in discord.js have different numbers of arguments. The rest parameter collects these variable number of arguments into a single array, and the spread syntax then takes these elements and passes them to the _`execute`_ function.
After this, listening for other events is as easy as creating a new file in the _`events`_ folder. The event handler will automatically retrieve and register it whenever you restart your bot.
<Alert title="Tip" type="success">
In most cases, you can access your _`client`_ instance in other files by obtaining it from one of the other discord.js
structures, e.g. _`interaction.client`_ in the _`InteractionCreate`_ event. You do not need to manually pass it to
your events.
</Alert>
## Resulting code
<ResultingCode />

View File

@@ -1,6 +1,6 @@
---
title: Frequently asked questions
category: Popular topics
category: Topics
---
# Frequently asked questions

View File

@@ -1,6 +1,6 @@
---
title: Audit logs
category: Popular topics
category: Topics
---
# Audit logs

View File

@@ -1,6 +1,6 @@
---
title: Collectors
category: Popular topics
category: Topics
---
# Collectors
@@ -31,9 +31,9 @@ collector.on('end', (collected) => {
</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.
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/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.
Note that the above example uses [implicit return](https://developer.mozilla.org/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/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.
@@ -103,7 +103,7 @@ try {
<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).
[here](https://developer.mozilla.org/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.

View File

@@ -1,6 +1,6 @@
---
title: Formatters
category: Popular topics
category: Topics
---
# Formatters

View File

@@ -0,0 +1,68 @@
---
title: Intents
category: Topics
---
# Intents
Intents are an important part of establishing a WebSocket connection, as they define behavior regarding gateway events and impact received data via the REST API.
## Usage
```js
import { Client, GatewayIntentBits } from 'discord.js';
const client = new Client({
intents: [GatewayIntentBits.Guilds],
});
```
This is the most basic usage of intents for discord.js. By specifying _`GatewayIntentBits.Guilds`_, your bot will receive gateway events regarding guilds. This includes receiving initial information about guilds it is in at startup, such as role data.
You can find the full list of _`GatewayIntentBits`_ <DiscordAPITypesLink type="enum" parent="GatewayIntentBits">on the documentation</DiscordAPITypesLink> and an explanation of what each intent does [on Discord's API documentation](https://discord.com/developers/docs/topics/gateway#list-of-intents).
## Considerations
In discord.js, some intents require an extra bit of consideration.
### _`GatewayIntentBits.Guilds`_
discord.js relies heavily on caching in the library. We recommend you set at least the _`GatewayIntentBits.Guilds`_ intent to avoid these pitfalls.
### _`GatewayIntentBits.GuildMembers`_
Fetching members in a guild via <DocsLink type="class" parent="GuildMemberManager" symbol="fetch" brackets /> requests them over the gateway. As such, this intent is required and you may receive a timeout error if this intent is not specified.
<Alert title="Info" type="info">
This is a privileged intent. Read on for more information.
</Alert>
### _`GatewayIntentBits.DirectMessages`_
This intent is required to receive direct messages. In discord.js however, you **must** specify partials as well. See the partials topic on how this is done.
### _`GatewayIntentBits.MessageContent`_
Unlike other intents, this only populates user-generated fields. See [Discord's documentation](https://discord.com/developers/docs/topics/gateway#message-content-intent) on what exactly this intent unveils.
It is a common mistake to not see the message content in a message—this is usually because this intent is not specified.
<Alert title="Info" type="info">
This is a privileged intent. Read on for more information.
</Alert>
## Privileged intents
Some gateway events are considered privileged. Currently, these are:
- _`GatewayIntentBits.GuildPresences`_
- _`GatewayIntentBits.GuildMembers`_
- _`GatewayIntentBits.MessageContent`_
To use these intents, you will need to enable them in the developer portal. If your bot is in over 75 guilds, you will need to verify it and request usage of your desired intents.
Carefully think if you need these intents. They are opt-in so users across the platform can enjoy a higher level of privacy. Presences can expose some personal information, such as the games being played and overall online time. You might find that it isn't necessary for your bot to have this level of information about all guild members at all times.
### Disallowed intents
Should you receive an error stating you are using disallowed intents, please review your developer dashboard settings for all privileged intents you use. Check the Discord API documentation for up-to-date information.

View File

@@ -1,6 +1,6 @@
---
title: Threads
category: Popular topics
category: Topics
---
# Threads

View File

@@ -1,6 +1,6 @@
---
title: Webhooks
category: Popular topics
category: Topics
---
# Webhooks

View File

@@ -164,7 +164,7 @@ client.on('interactionCreate', (interaction) => {
</CH.Code>
In this piece of code, the Promises are [chain resolved](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then#Chaining) with each other, and if one of the Promises gets rejected, the function passed to _`.catch()`_ gets called. Here's the same code but with async/await:
In this piece of code, the Promises are [chain resolved](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise/then#Chaining) with each other, and if one of the Promises gets rejected, the function passed to _`.catch()`_ gets called. Here's the same code but with async/await:
<CH.Code>

View File

@@ -10,10 +10,10 @@ It extends JavaScript's native _`Map`_ class, so it has all the _`Map`_ features
<Alert title="Warning" type="warning">
If you're not familiar with _`Map`_, read [MDN's page on
it](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) before continuing. You
should be familiar with _`Array`_
[methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) as well. We will
also use some ES6 features, so read up [here](/additional-info/es6-syntax.md) if you do not know what they are.
it](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map) before continuing. You should be
familiar with _`Array`_ [methods](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array) as
well. We will also use some ES6 features, so read up [here](/additional-info/es6-syntax.md) if you do not know what
they are.
</Alert>
A _`Map`_ allows for an association between unique keys and their values.
@@ -52,7 +52,7 @@ Methods that follow this philosophy of staying close to the _`Array`_ interface
## Converting to Array
Since _`Collection`_ extends _`Map`_, it is an [iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols), and can be converted to an _`Array`_ through either _`Array.from()`_ or spread syntax (_`...collection`_).
Since _`Collection`_ extends _`Map`_, it is an [iterable](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Iteration_protocols), and can be converted to an _`Array`_ through either _`Array.from()`_ or spread syntax (_`...collection`_).
<CH.Code>

View File

@@ -7,7 +7,7 @@ category: Additional info
## Before you start
v14 requires Node 16.9 or higher to use, so make sure you're up to date. To check your Node.js version, use _`node --version`_ in your terminal or command prompt, and if it's not high enough, update it! There are many resources online to help you with this step based on your host system.
v14 requires Node 16.11 or higher to use, so make sure you're up to date. To check your Node.js version, use _`node --version`_ in your terminal or command prompt, and if it's not high enough, update it! There are many resources online to help you with this step based on your host system.
### Various packages are now included in v14
@@ -27,6 +27,10 @@ yarn remove @discordjs/builders @discordjs/formatters @discordjs/rest discord-ap
pnpm remove @discordjs/builders @discordjs/formatters @discordjs/rest discord-api-types
```
```sh bun
bun remove @discordjs/builders @discordjs/formatters @discordjs/rest discord-api-types
```
</CH.Code>
## Breaking Changes

View File

@@ -1,3 +1,6 @@
@import '@unocss/reset/tailwind-compat.css';
@unocss all;
body {
font-family: var(--font-inter);
min-height: 100vh;

View File

@@ -15,9 +15,9 @@ export const PACKAGES = [
'collection',
'core',
'formatters',
'next',
'proxy',
'rest',
'next',
'util',
'voice',
'ws',
@@ -26,7 +26,7 @@ export const PACKAGES = [
/**
* The stable version of discord.js.
*/
export const VERSION = '14.11.0' as const;
export const VERSION = '14.13.0' as const;
/**
* The API version (for discord-api-types). This is prefixed with a "v".

View File

@@ -1,4 +0,0 @@
export const fetcher = async (url: string) => {
const res = await fetch(url);
return res.json();
};

View File

@@ -1,21 +1,26 @@
{
"$schema": "https://json.schemastore.org/tsconfig.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"allowJs": true
},
"include": [
"**/*.ts",
"**/*.tsx",
"**/*.js",
"**/*.cjs",
"**/*.mjs",
"**/*.jsx",
"**/*.test.ts",
"**/*.test.js",
"**/*.test.mjs",
"**/*.spec.ts",
"**/*.spec.js",
"**/*.spec.mjs"
"*.ts",
"*.tsx",
"*.js",
".jsx",
"*.cjs",
"*.mjs",
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.cjs",
"src/**/*.mjs",
"bin",
"scripts",
"__tests__",
"__mocks__"
],
"exclude": []
"exclude": ["node_modules"]
}

View File

@@ -1,15 +1,16 @@
{
"$schema": "https://json.schemastore.org/tsconfig.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"isolatedModules": true,
"jsx": "preserve",
"baseUrl": ".",
"outDir": "dist",
"noEmit": true,
"allowJs": false,
"esModuleInterop": true,
"allowJs": true,
"incremental": true,
"skipLibCheck": true,
"sourceMap": true,
"plugins": [
{
"name": "next"
@@ -18,10 +19,17 @@
"paths": {
"~/*": ["./src/*"],
"contentlayer/generated": ["./.contentlayer/generated"]
},
"strictNullChecks": true,
"moduleResolution": "node"
}
},
"include": ["src/**/*.ts", "src/**/*.tsx", "next-env.d.ts", ".next/types/**/*.ts", ".contentlayer/generated"],
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.cjs",
"src/**/*.mjs",
"next-env.d.ts",
".next/types/**/*.ts"
],
"exclude": ["node_modules"]
}

View File

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

View File

@@ -1,12 +0,0 @@
{
"extends": ["../../.eslintrc.json", "neon/react", "neon/next", "neon/edge", "@unocss", "neon/prettier"],
"settings": {
"react": {
"version": "detect"
}
},
"rules": {
"react/react-in-jsx-scope": 0,
"react/jsx-filename-extension": [1, { "extensions": [".tsx"] }]
}
}

View File

@@ -27,3 +27,6 @@ src/styles/unocss.css
.vscode
lighthouse-results
.vercel
old_src

View File

@@ -1 +1,2 @@
/** @type {import('lint-staged').Config} */
module.exports = require('../../.lintstagedrc.json');

View File

@@ -1 +1,5 @@
module.exports = require('../../.prettierrc.json');
/** @type {import('prettier').Config} */
module.exports = {
...require('../../.prettierrc.json'),
plugins: ['prettier-plugin-tailwindcss'],
};

View File

@@ -1,4 +1,5 @@
import bundleAnalyzer from '@next/bundle-analyzer';
import localesPlugin from '@react-aria/optimize-locales-plugin';
const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.ANALYZE === 'true',
@@ -6,15 +7,26 @@ const withBundleAnalyzer = bundleAnalyzer({
export default withBundleAnalyzer({
reactStrictMode: true,
experimental: {
appDir: true,
serverComponentsExternalPackages: ['@microsoft/api-extractor-model', 'jju'],
},
images: {
dangerouslyAllowSVG: true,
contentDispositionType: 'attachment',
contentSecurityPolicy: "default-src 'self'; frame-src 'none'; sandbox;",
},
logging: {
fetches: {
fullUrl: true,
},
},
experimental: {
ppr: false,
},
webpack(config, { isServer }) {
if (!isServer) {
config.plugins.push(localesPlugin.webpack({ locales: ['en-US'] }));
}
return config;
},
async redirects() {
return [
{

View File

@@ -1,28 +1,28 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@discordjs/website",
"version": "0.1.0",
"description": "Imagine a bot... the most popular way to build discord bots",
"private": true,
"scripts": {
"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": "cross-env NEXT_PUBLIC_LOCAL_DEV=true yarn build:prod",
"build:prod": "yarn build:copy_readme && yarn build:css && yarn build:next",
"build:copy_readme": "cpy \"../../packages/(discord.js|brokers|builders|collection|core|formatters|next|proxy|rest|util|voice|ws)/README.md\" \"src/assets/readme\" --rename='home-{{basename}}'",
"build:check": "tsc --noEmit",
"build:local": "cross-env NEXT_PUBLIC_LOCAL_DEV=true pnpm run build:prod",
"build:prod": "pnpm run build:copy_readme && pnpm run build:next",
"build:next": "next build",
"build:css": "yarn generate:css",
"build:search_indices": "yarn node scripts/generateAllIndices.js",
"build:analyze": "turbo run docs && cross-env ANALYZE=true NEXT_PUBLIC_LOCAL_DEV=true yarn build:prod",
"build:search_indices": "pnpm node scripts/generateAllIndices.js",
"build:analyze": "turbo run docs --filter='@discordjs/*' --concurrency=4 && cross-env ANALYZE=true NEXT_PUBLIC_LOCAL_DEV=true pnpm run build:prod",
"preview": "next start",
"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",
"format": "prettier --write . && cross-env TIMING=1 eslint src --ext .mjs,.js,.cjs,.ts,.tsx --fix --format=pretty",
"fmt": "yarn format"
"dev": "next dev",
"lint": "pnpm run build:check && prettier --check . && cross-env TIMING=1 eslint --format=pretty src",
"format": "pnpm run build:check && prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src",
"fmt": "pnpm run format"
},
"type": "module",
"directories": {
"lib": "src"
},
"contributors": [
"Crawl <icrawltogo@gmail.com>"
],
@@ -45,62 +45,64 @@
"url": "https://github.com/discordjs/discord.js/issues"
},
"homepage": "https://discord.js.org",
"funding": "https://github.com/discordjs/discord.js?sponsor",
"dependencies": {
"@discordjs/api-extractor-utils": "workspace:^",
"@discordjs/scripts": "workspace:^",
"@discordjs/ui": "workspace:^",
"@microsoft/api-extractor-model": "7.27.5",
"@microsoft/tsdoc": "0.14.2",
"@planetscale/database": "1.7.0",
"@radix-ui/react-collapsible": "^1.0.3",
"@react-icons/all-files": "^4.1.0",
"@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.4",
"class-variance-authority": "^0.7.0",
"cmdk": "^0.2.0",
"meilisearch": "^0.33.0",
"next": "^13.4.12",
"@vercel/analytics": "^1.2.2",
"@vercel/blob": "^0.22.3",
"@vercel/edge-config": "^1.1.0",
"@vercel/og": "^0.6.2",
"@vercel/postgres": "^0.8.0",
"cmdk": "^1.0.0",
"geist": "^1.3.0",
"jotai": "^2.8.0",
"lucide-react": "^0.368.0",
"meilisearch": "^0.38.0",
"next": "14.2.1",
"next-mdx-remote": "^4.4.1",
"next-themes": "^0.2.1",
"next-themes": "^0.3.0",
"overlayscrollbars": "^2.6.0",
"overlayscrollbars-react": "^0.5.6",
"react": "^18.2.0",
"react-custom-scrollbars-2": "^4.5.0",
"react-aria-components": "^1.1.1",
"react-dom": "^18.2.0",
"react-use": "^17.4.0",
"rehype-raw": "^6.1.1",
"rehype-slug": "^5.1.0",
"remark-gfm": "^3.0.1",
"sharp": "^0.32.4",
"swr": "^2.2.0"
"sharp": "^0.33.3",
"usehooks-ts": "^3.1.0",
"vaul": "^0.9.0"
},
"devDependencies": {
"@next/bundle-analyzer": "^13.4.12",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",
"@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",
"@next/bundle-analyzer": "14.2.1",
"@react-aria/optimize-locales-plugin": "^1.0.2",
"@shikijs/rehype": "1.1.7",
"@tailwindcss/typography": "^0.5.12",
"@testing-library/react": "^15.0.2",
"@testing-library/user-event": "^14.5.2",
"@types/node": "18.18.8",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"@vitejs/plugin-react": "^4.2.1",
"@vitest/coverage-v8": "^1.5.0",
"autoprefixer": "^10.4.19",
"cpy-cli": "^5.0.0",
"cross-env": "^7.0.3",
"eslint": "^8.46.0",
"eslint-config-neon": "^0.1.47",
"eslint-formatter-pretty": "^5.0.0",
"happy-dom": "^10.5.2",
"lighthouse": "^10.4.0",
"prettier": "^2.8.8",
"turbo": "^1.10.12",
"typescript": "^5.1.6",
"vercel": "^31.2.0",
"vitest": "^0.33.0"
"eslint": "^8.57.0",
"eslint-config-neon": "^0.1.62",
"eslint-formatter-pretty": "^6.0.1",
"happy-dom": "^14.7.1",
"postcss": "^8.4.38",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.14",
"remark-gfm": "^3.0.1",
"remark-rehype": "^11.1.0",
"shiki": "1.3.0",
"tailwindcss": "^3.4.3",
"turbo": "^1.13.2",
"typescript": "^5.4.5",
"vercel": "^34.0.0",
"vitest": "^1.5.0"
},
"engines": {
"node": ">=18.13.0"
"node": ">=18"
}
}

View File

@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};

View File

@@ -1,5 +1,14 @@
import { readFile } from 'node:fs/promises';
import { generateAllIndices } from '@discordjs/scripts';
console.log('Generating all indices...');
await generateAllIndices();
await generateAllIndices({
fetchPackageVersions: async (pkg) => {
return ['main'];
},
fetchPackageVersionDocs: async (pkg, version) => {
console.log(`Fetching data for ${pkg} ${version}...`);
return JSON.parse(await readFile(`${process.cwd()}/../../../docs/${pkg}/${version}.api.json`, 'utf8'));
},
});
console.log('Generated all indices.');

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