It plays audio from youtube and other sources into Discord channels. Built using python 3 and discord.py.
The bot is limited to playing music and managing tags. It doesn't welcome people, moderate your chat, or take your temperature. While it has some playlist features, its mostly designed as a voiceclip spam bot, with every play being an instant stop and play the new song operation.
All audio playing commands work only if the user is in a voice channel. The bot will join the voice channel of the user.
It supports the following commands:
- !addtag <name> <value> - Adds a value to the bots db that can be fetched. Tags are associated with the user that created it.
- !tag <name> - Displays the value of the tag for the user.
- !taglist - Displays your tags
- !play <link or tag> [loop?] - Plays audio in a voice call. This wipes the playlist. If a tag name is given, the value will be used as the link. Use loop as an optional argument to make it replay the same song.
- !playlist <link> [loop?] [shuffle?]- Adds a youtube playlist to be played as a queue. Loop and shuffle are optional arguments
- !skip - skips to the next song if there is a queue
- !stop - Stops all songs and flushes any existing queues.
In order to use it, you must first register and create a discord bot account. You can create one at https://discordapp.com/developers/applications/me.
FFMpeg needs to be available in your system path. In Windows I recommend finding the binaries, dumping them into a bin folder somewhere, and adding that folder to your path. In Linux, install it using your package manager with something like sudo apt install ffmpeg
.
Opus also needs to be available in your path. In Windows the discord.py library I'm using already comes with opus included, but in Linux you have to install them. sudo apt install libopus0
should do the job.
- Make sure FFMpeg/Opus/pipenv are installed and ready to use
- Clone/download the project, copy
config.py.example
toconfig.py
and configure it - Open a terminal in the directory where you cloned/downloaded the repo
pyenv shell 3.6.3
# if applicablepipenv install
pipenv run python main.py
These notes are mostly for myself, but to run on a linux machine you can do the following. Python 3 may already be on your system as python3
, but I use pyenv and pipenv.
Some info is available in this askubuntu answer here.
prerequisites are:
sudo apt-get install -y build-essential libbz2-dev libssl-dev libreadline-dev \
libsqlite3-dev tk-dev
# optional scientific package headers (for Numpy, Matplotlib, SciPy, etc.)
sudo apt-get install -y libpng-dev libfreetype6-dev
Pyenv can be installed in the following way. Instructions from https://github.com/pyenv/pyenv-installer
Run the following command:
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
Then add the lines it tells you to add to ~/.bash_profile. Afterwards restart and run pyenv install 3.6.7
If you use screen, follow the instructions here as well. Specifically, add shell -$SHELL
to ~/.screenrc
.
Pipenv virtual environments are handled per directory. After using pyenv shell 3.6.7
, use pip install pipenv
to install pipenv. Afterwards follow the normal setup instructions, like using pipenv install
to setup dependencies. I use screen
to run it in the background, but I may run it in some sort of manager like pm2 in the future.