mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
* feat: initial attempt at porting legacy guide * feat: completion of legacy guide backport * chore: lockfile shenanigans * fix: handle svgs * fix: replace svg with mermaid integration * chore: format * chore: remove unnecssary bullet * chore: cleanup code highlights * chore: explicit return * chore: move display components after interactive components in sidebar * chore: voice * top link should be installation * add docs link to sidebar * feat: subguide-based accent styles * chore: don't list faq twice * chore: mention display components in interactive components * fix: remove unoccs/order rule from guide * chore: redirect to legacy guide instead of /guide root * refactor: use `<kbd>` * refactor: more kbd use * Update apps/guide/content/docs/legacy/app-creation/handling-events.mdx Co-authored-by: Naiyar <137700126+imnaiyar@users.noreply.github.com> * chore: fix typos Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> * chore: fix typos * chore: fix links regarding secret stores across coding platforms * chore: fix typo * chore: link node method directly Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> * chore: typos Co-authored-by: Vlad Frangu <me@vladfrangu.dev> * chore: typo Co-authored-by: Vlad Frangu <me@vladfrangu.dev> * fix: prevent v14 changes from being listed twice * chore: prefer relative links * chore: missed link conversion * chore: missed link conversion * chore: fix link * chore: remove legacy code highlight markers * chore: rephrase and extend contributing guidelines * feat(setup): suggest cli flag over dotenv package * chore: move introduction in sidebar better navigation experience if the 'next page' in intro refers to getting started vs. updating/faq * fix: replace outdated link * fix: update voice dependencies * chore: update node install instructions * fix: list in missing access callout * chore: match bun env file format * chore: restore ffmpeg disclaimer * fix: lockfile conflict * chore: action row typo Co-authored-by: Vlad Frangu <me@vladfrangu.dev> * chore: no longer use at-next for pino --------- Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: Qjuh <76154676+Qjuh@users.noreply.github.com> Co-authored-by: Naiyar <137700126+imnaiyar@users.noreply.github.com> Co-authored-by: Vlad Frangu <me@vladfrangu.dev>
107 lines
3.9 KiB
Plaintext
107 lines
3.9 KiB
Plaintext
---
|
||
title: Installation
|
||
---
|
||
|
||
"Voice" refers to Discord bots being able to send audio in voice channels. This is supported in discord.js via @discordjs/voice](https://github.com/discordjs/discord.js/tree/main/packages/voice), a standalone library made by the developers of discord.js. While you can use it with any Node.js Discord API library, this guide will focus on using it with discord.js.
|
||
|
||
## Installation
|
||
|
||
### Barebones
|
||
|
||
To add voice functionality to your discord.js bot, you will need the `@discordjs/voice` package, as well as one of the encryption packages listed below. For example:
|
||
|
||
```sh tab="npm"
|
||
npm install @discordjs/voice
|
||
```
|
||
|
||
```sh tab="yarn"
|
||
yarn add @discordjs/voice
|
||
```
|
||
|
||
```sh tab="pnpm"
|
||
pnpm add @discordjs/voice
|
||
```
|
||
|
||
```sh tab="bun"
|
||
bun add @discordjs/voice
|
||
```
|
||
|
||
After this, you'll be able to play Ogg and WebM Opus files without any other dependencies. If you want to play audio from other sources, or want to improve performance, consider installing some of the extra dependencies listed below.
|
||
|
||
<Callout>
|
||
This guide assumes you have installed at least FFmpeg for all the examples to work. You can find more information
|
||
about extra dependencies in the next section.
|
||
</Callout>
|
||
|
||
### Extra Dependencies
|
||
|
||
#### Opus encoding
|
||
|
||
- [`@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 libraries
|
||
|
||
<Callout>
|
||
You only need to install one of these libraries if your system does not support `aes-256-gcm`. You can verify this by
|
||
running `require('node:crypto').getCiphers().includes('aes-256-gcm')`
|
||
</Callout>
|
||
|
||
- [`sodium-native`](https://www.npmjs.com/package/sodium-native)
|
||
- [`sodium`](https://www.npmjs.com/package/sodium) (best performance)
|
||
- [`@stablelib/xchacha20poly1305`](https://www.npmjs.com/package/@stablelib/xchacha20poly1305)
|
||
- [`@noble/ciphers`](https://www.npmjs.com/package/@noble/ciphers)
|
||
- [`libsodium-wrappers`](https://www.npmjs.com/package/libsodium-wrappers)
|
||
|
||
<Callout>
|
||
If you are facing issues when installing these dependencies, make sure you ticked the box to install optional build
|
||
tools when installing Node.js or try manually installing build tools and python: ```sh winget install "Visual Studio
|
||
Community 2022" --override "--add Microsoft.VisualStudio.Workload.NativeDesktop " -s msstore ```
|
||
</Callout>
|
||
|
||
## Debugging Dependencies
|
||
|
||
The library includes a helper function that helps you to find out which dependencies you've successfully installed. This information is also very helpful if you ever need to submit an issue on the `@discordjs/voice` issue tracker.
|
||
|
||
```js
|
||
const { generateDependencyReport } = require('@discordjs/voice');
|
||
|
||
console.log(generateDependencyReport());
|
||
|
||
/*
|
||
--------------------------------------------------
|
||
Core Dependencies
|
||
- @discordjs/voice: 0.3.1
|
||
- prism-media: 1.2.9
|
||
|
||
Opus Libraries
|
||
- @discordjs/opus: 0.5.3
|
||
- opusscript: not found
|
||
|
||
Encryption Libraries
|
||
- sodium: 3.0.2
|
||
- libsodium-wrappers: not found
|
||
- tweetnacl: not found
|
||
|
||
FFmpeg
|
||
- version: 4.2.4-1ubuntu0.1
|
||
- libopus: yes
|
||
--------------------------------------------------
|
||
*/
|
||
```
|
||
|
||
- **Core Dependencies**
|
||
- These are dependencies that should definitely be available.
|
||
- **Opus Libraries**
|
||
- If you want to play audio from many different file types, or alter volume in real-time, you will need to have one of these.
|
||
- **Encryption Libraries**
|
||
- You should have at least one encryption library installed to use `@discordjs/voice`.
|
||
- **FFmpeg**
|
||
- If you want to play audio from many different file types, you will need to have FFmpeg installed.
|
||
- If `libopus` is enabled, you will be able to benefit from increased performance if real-time volume alteration is disabled.
|