Skip to content

3underscoreN/3_n-s-slash-Music-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

3_n's Music Bot (slash command)

Content

Introduction

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.

Dependencies

You would need these python packages before you can run this bot:

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]"

Alternatives

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:

  1. Install yt-dlp:
$ pip install yt-dlp
  1. Find out where pafy is installed:
>>> import pafy
>>> pafy.__file__
  1. Visit the folder and change import youtube_dl into import yt_dlp as youtube_dl in all of the .py files.

If you encountered any problem with this, feel free to join the Discord server and ask for help.

Deploy

Follow the steps to deploy the bot on your server/computer:

  1. Clone the repository:
$ git clone https://github.com/3underscoreN/3_n-s-slash-Music-Bot.git
  1. Create your own discord bot and fetch your discord token here. You also need to obtain your own user ID.

  2. 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.

  3. 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>'
  1. Run the bot:
$ python3 main.py

Error Handling

There 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.

Issues

If you encountered any undesirable behaviour, please open an issue on this repository.

Contribution

If you would like to contribute to this project, please open a pull request. I will review it as soon as possible.

License

This project is licensed under BSD 2-Clause. See the LICENSE file for details.

About

A random discord music bot written by 3_n. Supports slash command.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages