This is a Discord bot I write in my free time. Following my last bot, since Discord is adding a fancy "slash command" thingy, I decided to rewrite the bot, as well as using new libraries.
You would need these python packages before you can run this bot:
- orjson
- pafy
- py-cord
- PyNaCl
- youtube-dl (Not recommended since it is pretty out of date, check below for alternatives)
- youtube_search
- pytube
You would also need ffmpeg installed.
To install these packages, you can use pip:
$ pip uninstall discord
$ pip install orjson pafy py-cord PyNaCl youtube-dl youtube-search pytube
$ pip install -U "py-cord[voice]"
# Optional for performance
$ pip install -U "py-cord[speed]"Apart from using outdated youtube-dl, you can use pafy's backend:
$ export PAFY_BACKEND="internal"However, as the backend is not well maintained and not tested, I strongly disrecommend you use it.
Another alternative is to use forks. This project is actually developed with yt-dlp. However for this to work you have to tweak pafy .py files:
- Install
yt-dlp:
$ pip install yt-dlp- Find out where
pafyis installed:
>>> import pafy
>>> pafy.__file__- Visit the folder and change
import youtube_dlintoimport yt_dlp as youtube_dlin all of the.pyfiles.
If you encountered any problem with this, feel free to join the Discord server and ask for help.
Follow the steps to deploy the bot on your server/computer:
- Clone the repository:
$ git clone https://github.com/3underscoreN/3_n-s-slash-Music-Bot.git-
Create your own discord bot and fetch your discord token here. You also need to obtain your own user ID.
-
Get a YouTube Data v3 API key for playlist parsing (optional, but if you want to use addplaylist, you need this). You can get one here.
-
Set up these environment variables:
$ export TOKEN='<your token here>'
$ export OWNER='<your user ID here>'
$ export YT_API_KEY='<your youtube api key here>'- Run the bot:
$ python3 main.pyThere might be some errors if you are using youtube-dl or yt-dlp as the backend:
KeyError: 'dislike_count'
Since YouTube has deperecated the dislike count, calling dislike_count will result in an error. If you experience this error, open pafy/backend_youtube_dl.py and comment out this line (on line 54):
self._dislikes = self._ydl_info['dislike_count']You might also get Opus/FFmpeg related errors:
discord.errors.ClientException: ffmpeg was not found.
Please ensure ffmpeg is installed and added to your PATH. Installation of ffmpeg differs from platform to platform, and you can find the installation guide here.
If you encountered any undesirable behaviour, please open an issue on this repository.
If you would like to contribute to this project, please open a pull request. I will review it as soon as possible.
This project is licensed under BSD 2-Clause. See the LICENSE file for details.