2020-08-04 12:18:28 +02:00
# Plex-Bot
2020-08-10 10:42:13 +02:00
[![Codacy Badge ](https://api.codacy.com/project/badge/Grade/c93b8ff976ce4205a95046487917476b )](https://app.codacy.com/manual/jarulsamy/Plex-Bot?utm_source=github.com& utm_medium=referral& utm_content=jarulsamy/Plex-Bot& utm_campaign=Badge_Grade_Dashboard)
2020-08-09 23:24:15 +02:00
[![GPLv3 license ](https://img.shields.io/badge/License-GPLv3-blue.svg )](http://perso.crans.org/besson/LICENSE.html)
![docker pulls ](https://img.shields.io/docker/pulls/jarulsamy/plex-bot )
![docker img size ](https://img.shields.io/docker/image-size/jarulsamy/plex-bot )
2020-08-10 04:12:31 +02:00
![black badge ](https://img.shields.io/badge/code%20style-black-000000.svg )
2020-08-09 23:24:15 +02:00
2020-08-04 12:18:28 +02:00
A Python-based Plex music bot for discord.
2020-08-09 23:24:15 +02:00
![screenshot ](assets/screenshot.png )
2020-08-04 12:18:28 +02:00
## Setup
Plex-Bot runs entirely in a Docker container. Ensure you have Docker and docker-compose installed according to the official Docker [documentation ](https://docs.docker.com/get-docker/ ).
2020-08-10 04:12:31 +02:00
1. Create a new folder and `cd` into it:
2020-08-04 12:18:28 +02:00
2020-08-10 04:12:31 +02:00
```bash
mkdir Plex-Bot
cd Plex-Bot
```
2020-08-04 12:18:28 +02:00
2020-08-10 04:12:31 +02:00
2. Make a `docker-compose.yml` file or use this sample:
2020-08-04 12:18:28 +02:00
2020-08-10 04:12:31 +02:00
```yml
version: "3"
services:
plex-bot:
container_name: "PlexBot"
image: jarulsamy/plex-bot:latest
environment:
- PUID=1000
- PGID=1000
- TZ=America/Denver
# Required dir for configuration files
volumes:
- "./config:/config:ro"
restart: "unless-stopped"
```
2020-08-09 23:24:15 +02:00
2020-08-10 04:12:31 +02:00
3. Create a new `config` folder and create a config file like this::
2020-08-04 12:18:28 +02:00
2020-08-10 04:12:31 +02:00
```bash
mkdir config
cd config
touch config.yaml
```
2020-08-09 23:24:15 +02:00
2020-08-10 04:12:31 +02:00
```yml
# Create a file called config.yaml with the following contents
2020-08-09 23:24:15 +02:00
2020-08-10 04:12:31 +02:00
root:
log_level: "info"
2020-08-09 23:24:15 +02:00
2020-08-10 04:12:31 +02:00
discord:
prefix: "?"
token: "< BOT_TOKEN > "
log_level: "debug"
2020-08-09 23:24:15 +02:00
2020-08-10 04:12:31 +02:00
plex:
base_url: "< BASE_URL > "
token: "< PLEX_TOKEN > "
library_name: "< LIBRARY_NAME > "
log_level: "debug"
```
2020-08-04 12:18:28 +02:00
2020-08-10 04:12:31 +02:00
4. Create a Discord bot application:
2020-08-04 12:18:28 +02:00
2020-08-10 04:12:31 +02:00
1. Go to the Discord developer portal, [here ](https://discord.com/developers/applications ).
2020-08-04 12:18:28 +02:00
2020-08-10 04:12:31 +02:00
2. Log in or create an account
2020-08-04 12:18:28 +02:00
2020-08-10 04:12:31 +02:00
3. Click New App
2020-08-04 12:18:28 +02:00
2020-08-10 04:12:31 +02:00
4. Fill in App Name and anything else you'd like to include
2020-08-04 12:18:28 +02:00
2020-08-10 04:12:31 +02:00
5. Click Create App
2020-08-04 12:18:28 +02:00
This will provide you with your Client ID and Client Secret
2020-08-10 04:12:31 +02:00
6. Click Create Bot User
2020-08-04 12:18:28 +02:00
This will provide you with your bot Username and Token
2020-08-10 04:12:31 +02:00
7. Fill in the bot token in `config/config.yaml`
2020-08-04 12:18:28 +02:00
2020-08-10 04:12:31 +02:00
5. Get your plex token:
2020-08-04 12:18:28 +02:00
2020-08-09 23:24:15 +02:00
* Refer to the official [plex documentation ](https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/ ).
2020-08-04 12:18:28 +02:00
2020-08-09 23:24:15 +02:00
* Add it to `config/config.yaml` in the appropiate spot.
2020-08-04 12:18:28 +02:00
2020-09-06 23:33:25 +02:00
6. Get your Lyrics Genius token (Optional):
If you wanty to disable this feature, set token to `None` in `config/config.yaml`
If you would like to enable the lyrics feature of the bot, you need to signup for a free GeniusLyrics account, [here ](https://genius.com/api-clients ).
After you make an account:
1. Click New API Client
2. Set the app website url to: `https://github.com/jarulsamy/Plex-Bot`
3. Set the redirect url to: `http://localhost`
4. Copy the **Client Access Token** to `config/config.yaml`
7. Customize remaining settings
2020-08-09 23:24:15 +02:00
Set any remaining settings in the config file that you would like. Such as music library, and base url of the Plex server.
2020-09-06 23:33:25 +02:00
8. Start the service:
2020-08-09 23:24:15 +02:00
2020-08-10 04:12:31 +02:00
```bash
docker-compose up -d
```
2020-08-09 23:24:15 +02:00
## Logs
You can view the logs with the following command
2020-08-04 12:18:28 +02:00
2020-08-10 04:12:31 +02:00
```bash
docker-compose logs -f CONTAINER_NAME_OR_ID
2020-08-09 23:24:15 +02:00
# For example
2020-08-10 04:12:31 +02:00
docker-compose logs -f PlexBot
2020-08-04 12:18:28 +02:00
```
## Usage
2020-08-10 04:12:31 +02:00
```text
2020-08-04 12:18:28 +02:00
General:
2020-08-13 10:51:34 +02:00
kill [silent] - Halt the bot [silently].
help - Print this help message.
cleanup - Delete old messages from the bot.
2020-08-04 12:18:28 +02:00
Plex:
2020-08-13 10:51:34 +02:00
play < SONG_NAME > - Play a song from the plex server.
album < ALBUM_NAME > - Queue an entire album to play.
2021-05-27 17:11:02 +02:00
playlist < PLAYLIST_NAME > - Queue an entire playlist to play.
2020-09-06 23:33:25 +02:00
lyrics - Print the lyrics of the song (Requires Genius API)
2020-08-13 10:51:34 +02:00
np - Print the current playing song.
stop - Halt playback and leave vc.
pause - Pause playback.
resume - Resume playback.
clear - Clear play queue.
[] - Optional args.
2020-08-04 12:18:28 +02:00
```
2020-07-23 00:17:16 +02:00
* * *