-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(Wiki): add wiki for contributors' pr
- Loading branch information
Showing
9 changed files
with
749 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Wiki | ||
on: | ||
push: | ||
branches: [main] | ||
paths: | ||
- wiki/** | ||
- .github/workflows/wiki.yml | ||
permissions: | ||
contents: write | ||
jobs: | ||
wiki: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: Andrew-Chen-Wang/github-wiki-action@v4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
> [!WARNING] | ||
> DisTube Guide is Working in Process | ||
> [!NOTE] | ||
> This guide follows [discordjs.guide notation](https://discordjs.guide/additional-info/notation.html) | ||
# Introduction | ||
|
||
Welcome to the guide on creating a Discord bot with DisTube! Whether you're a seasoned developer or just starting, this step-by-step tutorial will walk you through the process of setting up a Discord bot capable of handling music commands with ease. DisTube, a powerful Discord.js module, simplifies the integration of music playback functionality, making your bot not only versatile but also enjoyable for your server members. | ||
|
||
Let's dive in and bring your Discord bot to life with the magic of DisTube! 🤖🎵 | ||
|
||
[![Support me on ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/skick) | ||
|
||
# Prerequisites | ||
|
||
To create a Discord music bot with DisTube, you should have a solid understanding of JavaScript. You can make a music bot with very little JS, programming knowledge by using DisTube. But you may get stuck on many uncomplicated issues, and struggle with solutions to incredibly easy problems. | ||
|
||
# Preparations | ||
|
||
Before diving into this guide, you have to create a Discord bot using Discord.js. If you haven't already, visit [discordjs.guide](https://discordjs.guide/) to familiarize yourself with the process of setting up a basic Discord bot. | ||
|
||
This guide is a continuation of your [discordjs.guide](https://discordjs.guide/) development journey, focusing on seamlessly integrating DisTube for advanced music functionality. | ||
The code written follows command handling setup from [discordjs.guide](https://discordjs.guide/), so adjustments may be necessary based on your command handler's structure. | ||
If you encounter any issues, refer to your command handler's documentation or seek assistance in the Discord.js community. | ||
|
||
# Installation | ||
|
||
Install DisTube in your bot project folder | ||
|
||
```sh | ||
npm install distube | ||
``` | ||
|
||
And you need to install all the [requirements](https://github.com/skick1234/DisTube#requirement) too. | ||
|
||
```sh | ||
npm install @discordjs/voice @discordjs/opus sodium-native | ||
``` | ||
|
||
FFmpeg installation guide: [Windows](http://blog.gregzaal.com/how-to-install-ffmpeg-on-windows/) - [Linux (Ubuntu, Mint,...)](https://www.tecmint.com/install-ffmpeg-in-linux/) | ||
\ | ||
Download FFmpeg from [this repo](https://github.com/BtbN/FFmpeg-Builds/releases) if the download links in the guide are not available. | ||
|
||
> [!WARNING] | ||
> While `ffmpeg-static` may function, it's important to note that its stability can vary across different machines, potentially leading to issues.\ | ||
> Do NOT install `ffmpeg` npm package. Uninstall it if installed with `npm uninstall ffmpeg`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
# DisTube | ||
|
||
## 1. Budget VPS Hosting | ||
|
||
Blazingly fast, reliable VMs in 16 global locations at an extremely affordable price! | ||
|
||
> Available locations: 🇺🇸 🇳🇱 🇸🇪 🇦🇹 🇳🇴 🇬🇧 🇨🇭 🇭🇰 🇸🇬 🇯🇵 🇦🇺\ | ||
> Premium DisTube Bots are hosted on this provider in Chicago 🇺🇸 | ||
> | ||
### [Order Now!](https://skick.xyz/vps) | ||
|
||
All plans, even **4$** plan, use the below specification: | ||
|
||
- CPU: **AMD EPYC Milan** | ||
- SSD: **Samsung Enterprise NVMe Storage** | ||
- Public Network Port: **10Gbps | 40Gbps** (depends on location) | ||
|
||
| CPU<br/>vCore | RAM<br/>GB | Storage<br/>GB | Price<br/>US$ | | ||
| :-----------: | :--------: | :------------: | ------------: | | ||
| 1 | 2 | 10 | $4 | | ||
| 2 | 4 | 20 | $6 | | ||
| 2 | 8 | 35 | $9 | | ||
| 4 | 12 | 50 | $12 | | ||
| 6 | 24 | 100 | $22 | | ||
| 8 | 32 | 125 | $29 | | ||
| 8 | 48 | 150 | $39 | | ||
| 12 | 64 | 200 | $49 | | ||
| 16 | 96 | 250 | $69 | | ||
|
||
## 2. FFMPEG_NOT_INSTALLED | ||
|
||
### Reason | ||
|
||
- FFmpeg is not installed | ||
|
||
### Solution | ||
|
||
- Install FFmpeg on: [Windows](http://blog.gregzaal.com/how-to-install-ffmpeg-on-windows/) - [Linux (Ubuntu, Mint,...)](https://www.tecmint.com/install-ffmpeg-in-linux/) | ||
> Download FFmpeg from [this repo](https://github.com/BtbN/FFmpeg-Builds/releases) if the download links are not available | ||
- If you want to run FFmpeg from a custom path, or `ffmpeg-static`.path, e.t.c., you can use [`ffmpeg.path`](https://distube.js.org/types/DisTubeOptions.html) option. | ||
|
||
## 3.1 The song ends instantly without any errors<br/>3.2 Error: write EPIPE | ||
|
||
### Reason | ||
|
||
- This is due to FFmpeg error. | ||
|
||
### Solution: | ||
|
||
- Check the FFmpeg log to check why it happens with [`ffmpegDebug`](https://distube.js.org/classes/DisTube.html#ffmpegDebug) event | ||
|
||
```ts | ||
import { Events } from "distube"; | ||
distube.on(Events.FFMPEG_DEBUG, console.log); | ||
``` | ||
|
||
## 4.1 Error: Cannot find module '@discordjs/opus'<br/>4.2 RangeError: Source is too large<br/>4.3 RangeError: offset is out of bounds | ||
|
||
### Reason | ||
|
||
- `@discordjs/opus` package is not installed, or you installed `node-opus` or `opusscript` package (which is not stable) | ||
|
||
### Solution | ||
|
||
- Install `@discordjs/opus` package. Uninstall `node-opus`, `opusscript` if installed | ||
|
||
```sh | ||
npm uninstall opusscript node-opus | ||
npm install @discordjs/opus | ||
``` | ||
|
||
## 5. Error: VOICE_CONNECTION_TIMEOUT | ||
|
||
### Reason | ||
|
||
- It is due to your hosting/VPS network connection | ||
|
||
### Solution | ||
|
||
1. Try to join the voice channel with `<DisTube>.voices.join(voiceChannel)` before using `DisTube.play()`.\ | ||
You can retry if this function throws the above error. | ||
|
||
2. Use a better network service (like the above VPS) | ||
|
||
## 6.1 My bot plays a random song after finishing all the queue<br/>6.2 How to turn off autoplay<br/>6.3 How to change queue's default properties | ||
|
||
### Reason | ||
|
||
- Autoplay is on by default. | ||
|
||
### Solution | ||
|
||
- To turn it on/off by a command, use [toggleAutoplay()](https://distube.js.org/#/docs/DisTube/main/class/DisTube?scrollTo=toggleAutoplay). | ||
- To change the queue's default setting, use [initQueue](https://distube.js.org/#/docs/DisTube/main/class/DisTube?scrollTo=e-initQueue) event. | ||
|
||
# YouTubePlugin | ||
|
||
## 1. Error: Status code: 429 | ||
|
||
### Reason | ||
|
||
- It is caused by requesting YouTube videos too fast. | ||
|
||
### Solution | ||
|
||
- Use `cookies` option (Guide: [[YouTube-Cookies]]). | ||
> You have to sign in before getting the cookie. | ||
> You may have to wait for YouTube to unblock your IP after getting this error. | ||
## 2.1 Sign in to confirm you're not a bot<br/>2.2 Get the best YouTube experience | ||
|
||
### Reason | ||
|
||
- You are literally a Discord bot | ||
|
||
### Solution | ||
|
||
- Use `cookies` option (Guide: [[YouTube-Cookies]]). | ||
> You have to sign in before getting the cookie. | ||
## 3. Sign in to confirm your age | ||
|
||
### Reason | ||
|
||
- Playing YouTube age-restricted videos | ||
|
||
### Solution | ||
|
||
- Use `cookies` option (Guide: [[YouTube-Cookies]]). | ||
> You have to sign in before getting the cookie. | ||
> Your account information must be at least 18 years old. | ||
## 4. Error checking for updates: Status code 403 | ||
|
||
### Reason | ||
|
||
- You are requested to github to many times (maybe due to restarting your bot). YouTubePlugin deps check their versions with github api so it can be rate-limited | ||
|
||
### Solution | ||
|
||
- Disable check for updates temporarily with their env variables | ||
|
||
```ts | ||
process.env.YTSR_NO_UPDATE = 1; | ||
process.env.YTDL_NO_UPDATE = 1; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
There are a few ways to handle discord.js events | ||
|
||
## Leave the voice channel if there is no user in it | ||
|
||
```ts | ||
import { isVoiceChannelEmpty } from "distube"; | ||
client.on("voiceStateUpdate", oldState => { | ||
if (!oldState?.channel) return; | ||
const voice = this.voices.get(oldState); | ||
if (voice && isVoiceChannelEmpty(oldState)) { | ||
voice.leave(); | ||
} | ||
}); | ||
``` | ||
|
||
## Pause the queue if there is no user in the voice channel and resume it if there is | ||
|
||
```ts | ||
import { isVoiceChannelEmpty } from "distube"; | ||
client.on("voiceStateUpdate", oldState => { | ||
if (!oldState?.channel) return; | ||
const queue = this.queues.get(oldState); | ||
if (!queue) return; | ||
if (isVoiceChannelEmpty(oldState)) { | ||
queue.pause(); | ||
} else if (queue.paused) { | ||
queue.resume(); | ||
} | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Welcome to DisTube.js.org Wiki | ||
|
||
A collection of information about the [distube](https://www.npmjs.com/package/distube) package. | ||
|
||
## Getting started with DisTube | ||
|
||
- [[DisTube Guide]] is the optimal starting point for mastering the usage of DisTube. | ||
- Explore the [DisTube Documentation](https://distube.js.org/) to acquaint yourself with the standard library. | ||
- Explore a range of open-source projects leveraging DisTube featured on the [[Projects Hub]]. | ||
- For upgrading from a lower version, refer to the [[Major Upgrade Guide]]. | ||
- Prior to seeking assistance, please review the [[Frequently Asked Questions]] section for potential resolutions to your issue. | ||
- If you still require assistance, feel free to visit our [Discord](https://discord.gg/feaDd9h) community for support. |
Oops, something went wrong.