Skip to content

feat(guide): port legacy guide #10938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

feat(guide): port legacy guide #10938

wants to merge 19 commits into from

Conversation

almostSouji
Copy link
Member

@almostSouji almostSouji commented Jun 17, 2025

Initial release:

  • Components: Docs links: removed, the component as it was is not particularly useful with the new docs setup
  • Remove resulting code
  • Port tabbed code: native
  • Ensure links work
  • Links should only open in new tab if external: abs link from root /guide/legacy/category/page.mdx
  • Page order in sidebar
  • Ensure MDX across the board
  • Separate contexts for main guide and voice
  • Enrich with new code block capabilities (shiki)
  • Update CONTRIBUTING.md
  • Update CONTRIBUTING.md

Considerations:

Note

serves /guide/legacy and /guide/voice

Copy link

vercel bot commented Jun 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
discord-js-guide ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 22, 2025 1:28pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Jun 22, 2025 1:28pm

@almostSouji almostSouji changed the title Port legacy guide feat(guide): port legacy guide Jun 20, 2025
style={
{
color,
backgroundColor: `color-mix(in oklab, ${color} 10%, transparent)`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this be a CSS class instead? To have all styling in one place instead of mixed into the code here.

- How to get a bot [up and running](/guide/legacy/preparations/app-setup) from scratch;
- How to properly [create](/guide/legacy/app-creation/project-setup), [organize](/guide/legacy/app-creation/handling-commands), and expand on your commands;
- In-depth explanations and examples regarding popular topics (e.g. [components](/guide/legacy/popular-topics/display-components) ,[reactions](/guide/legacy/popular-topics/reactions), [embeds](/guide/legacy/popular-topics/embeds), [canvas](/guide/legacy/popular-topics/canvas));
- Working with databases (e.g. [sequelize](/guide/legacy/sequelize/) and [keyv](/guide/legacy/keyv/));
Copy link
Member

@Qjuh Qjuh Jun 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Working with databases (e.g. [sequelize](/guide/legacy/sequelize/) and [keyv](/guide/legacy/keyv/));
- Working with databases (e.g. [sequelize](./sequelize/) and [keyv](./keyv/keyv));


<Callout>
If you want to learn more about reactions, check out [this dedicated guide on
reactions](/guide/legacy/popular-topics/reactions.md)!
Copy link
Member

@Qjuh Qjuh Jun 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
reactions](/guide/legacy/popular-topics/reactions.md)!
reactions](./reactions)!

{
"pages": [
"[Info][Introduction](/guide/legacy)",
"[MessageCircleQuestion][FAQ](/guide/legacy/popular-topics/faq)",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move this down, as it feels weird when using the "Next page" navigation in the guide to go from introduction to FAQ. I always felt the same on the old guide, it should jump right into the actual "Getting Started" instead of information that a new user won't need/understand.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, but also the POI people will be trying to find - and if just to reference - when visiting the guide


<Callout title="Danger" type="error">
If you're using Git, you should not commit this file and should [ignore it via
`.gitignore`](/creating-your-bot/#git-and-gitignore).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`.gitignore`](/creating-your-bot/#git-and-gitignore).
`.gitignore`](#git-and-gitignore).

<Callout>
You can find the methods available for the ShardingManager class `ShardingManager`. Though, you may not be making much
use of this section, unlike the next feature we will explore, which you may learn about by clicking [this
link](/sharding/additional-information.md).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
link](/sharding/additional-information.md).
link](./additional-information).

<Callout>
**Voice connections can be subscribed to one audio player at most.** If you try to subscribe to another audio player while already subscribed to one, the current audio player is unsubscribed and replaced with the new one.

It is also worth noting that the **GuildVoiceStates** [gateway intent](/popular-topics/intents.md#gateway-intents) is required. Without it, the connection will permanently stay in the `signalling` state, and you'll be unable to play audio.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It is also worth noting that the **GuildVoiceStates** [gateway intent](/popular-topics/intents.md#gateway-intents) is required. Without it, the connection will permanently stay in the `signalling` state, and you'll be unable to play audio.
It is also worth noting that the **GuildVoiceStates** [gateway intent](/guide/legacy/popular-topics/intents#gateway-intents) is required. Without it, the connection will permanently stay in the `signalling` state, and you'll be unable to play audio.


## Life cycle

Voice connections have their own life cycle, with five distinct states. You can follow the methods discussed in the [life cycles](/voice/life-cycles.md) section to subscribe to changes to voice connections.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Voice connections have their own life cycle, with five distinct states. You can follow the methods discussed in the [life cycles](/voice/life-cycles.md) section to subscribe to changes to voice connections.
Voice connections have their own life cycle, with five distinct states. You can follow the methods discussed in the [life cycles](./life-cycles) section to subscribe to changes to voice connections.


### Playing audio

You can create [audio resources](./audio-resources.md) and then play them on an audio player.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can create [audio resources](./audio-resources.md) and then play them on an audio player.
You can create [audio resources](./audio-resources) and then play them on an audio player.


## Life cycle

Voice connections have their own life cycle, with five distinct states. You can follow the methods discussed in the [life cycles](/voice/life-cycles.md) section to subscribe to changes to voice connections.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Voice connections have their own life cycle, with five distinct states. You can follow the methods discussed in the [life cycles](/voice/life-cycles.md) section to subscribe to changes to voice connections.
Voice connections have their own life cycle, with five distinct states. You can follow the methods discussed in the [life cycles](./life-cycles) section to subscribe to changes to voice connections.

Copy link

codecov bot commented Jun 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 42.70%. Comparing base (2852a52) to head (4f23fb2).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10938   +/-   ##
=======================================
  Coverage   42.69%   42.70%           
=======================================
  Files         262      262           
  Lines       16086    16084    -2     
  Branches     1545     1543    -2     
=======================================
  Hits         6868     6868           
+ Misses       9206     9204    -2     
  Partials       12       12           
Flag Coverage Δ
core 0.89% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines +69 to +70
- Whitelist -> Allowlist
- Blacklist -> Denylist
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a fan of this butchering to have 1 word that represents a list of allowed/disallowed values, imo a phrase is better but 🤷

Spam is something you generally want to avoid, especially if one of your commands require calls to other APIs or takes a bit of time to build/send.

<Callout>
This section assumes you followed the [Command Handling](/guide/legacy/app-creation/handling-commands) part of the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use relative paths wherever possible?

When writing your commands, you may find it tedious to restart your bot every time for testing the smallest changes. With a command handler, you can eliminate this issue and reload your commands while your bot is running.

<Callout>
ESM does not support require and clearing import cache. You can use [hot-esm](https://www.npmjs.com/package/hot-esm)
Copy link
Member

@vladfrangu vladfrangu Jun 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean there's always import(`./file.mjs?d=${Date.now()}`) but that has the disadvantage of leaking small amounts of memory per reload

Comment on lines +69 to +70
<File name="packge-lock.json" />
<File name="packge.json" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Find packge -> replace package


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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep in mind this will only work on unix systems. Windows will throw if you try this, maybe we can add a callout for using cross-env?

Comment on lines +16 to +28
<Cards>
<Card icon={<Grid2x2 />} title="Windows">
Download the latest version from [the Node.js website](https://nodejs.org/), open the downloaded file, and follow
the steps from the installer.
</Card>
<Card icon={<Apple />} title="macOS">
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`
</Card>
<Card icon={<Cpu />} title="Linux">
Consult [this page](https://nodejs.org/en/download/package-manager/) to determine how you should install Node.
</Card>
</Cards>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is for legacy docs but I feel like even here we should point people towards fnm/volta/nvm

Comment on lines +13 to +27
```sh tab="npm"
npm install @discordjs/voice libsodium-wrappers
```

```sh tab="yarn"
yarn add @discordjs/voice libsodium-wrappers
```

```sh tab="pnpm"
pnpm add @discordjs/voice libsodium-wrappers
```

```sh tab="bun"
bun add @discordjs/voice libsodium-wrappers
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nowadays, libsodium-wrappers isn't required
Google Chrome Beta - 2025-06-22 at 12-23-44-UTC

Comment on lines +38 to +48
- An Opus encoding library
- [`@discordjs/opus`](https://github.com/discordjs/opus) (best performance)
- [`opusscript`](https://github.com/abalabahaha/opusscript/)
- FFmpeg – allows you to play a range of media (e.g. MP3s).
- [`ffmpeg`](https://ffmpeg.org/) - install and add to your system environment
- [`ffmpeg-static`](https://www.npmjs.com/package/ffmpeg-static) - to install FFmpeg via npm
- Encryption packages
- [`sodium`](https://www.npmjs.com/package/sodium) (best performance)
- [`sodium-native`](https://www.npmjs.com/package/sodium-native)
- [`libsodium-wrappers`](https://www.npmjs.com/package/libsodium-wrappers)
- [`tweetnacl`](https://www.npmjs.com/package/tweetnacl)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs an update to add the new libs supported

Comment on lines +52 to +68
If you're struggling to install these dependencies, make sure you have build tools installed first. On Windows, this is as easy as running the following command!

```sh tab="npm"
npm install --global --production --add-python-to-path windows-build-tools
```

```sh tab="yarn"
yarn global add --production --add-python-to-path windows-build-tools
```

```sh tab="pnpm"
pnpm add --global --production --add-python-to-path windows-build-tools
```

```sh tab="bun"
bun add --global --production --add-python-to-path windows-build-tools
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not recommend this anymore, instead just telling users to install vs with c++ (winget install "Visual Studio Community 2022" --override "--add Microsoft.VisualStudio.Workload.NativeDesktop " -s msstore) and python

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But its also not required since some modules have prebuilts, and most systems have aed encryption already and will work out of the box

{
color,
backgroundColor: `color-mix(in oklab, ${color} 10%, transparent)`,
} as object
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cast feels redundant, it is an object, whats the ts error without it?

Co-authored-by: Naiyar <137700126+imnaiyar@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Review in Progress
Development

Successfully merging this pull request may close these issues.

5 participants