4.0 KiB
Plex-Bot
A Python-based Plex music bot for discord.
Setup
Plex-Bot runs entirely in a Docker container. Ensure you have Docker and docker-compose installed according to the official Docker documentation.
-
Create a new folder and
cd
into it:mkdir Plex-Bot cd Plex-Bot
-
Make a
docker-compose.yml
file or use this sample: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"
-
Create a new
config
folder and create a config file like this::mkdir config cd config touch config.yaml
# Create a file called config.yaml with the following contents root: log_level: "info" discord: prefix: "?" token: "<BOT_TOKEN>" log_level: "debug" plex: base_url: "<BASE_URL>" token: "<PLEX_TOKEN>" library_name: "<LIBRARY_NAME>" log_level: "debug"
-
Create a Discord bot application:
-
Go to the Discord developer portal, here.
-
Log in or create an account
-
Click New App
-
Fill in App Name and anything else you'd like to include
-
Click Create App This will provide you with your Client ID and Client Secret
-
Click Create Bot User This will provide you with your bot Username and Token
-
Fill in the bot token in
config/config.yaml
-
-
Get your plex token:
-
Refer to the official plex documentation.
-
Add it to
config/config.yaml
in the appropiate spot.
-
-
Get your Lyrics Genius token (Optional):
If you wanty to disable this feature, set token to
None
inconfig/config.yaml
If you would like to enable the lyrics feature of the bot, you need to signup for a free GeniusLyrics account, here.
After you make an account:
-
Click New API Client
-
Set the app website url to:
https://github.com/jarulsamy/Plex-Bot
-
Set the redirect url to:
http://localhost
-
Copy the Client Access Token to
config/config.yaml
-
-
Customize remaining settings
Set any remaining settings in the config file that you would like. Such as music library, and base url of the Plex server.
-
Start the service:
docker-compose up -d
Logs
You can view the logs with the following command
docker-compose logs -f CONTAINER_NAME_OR_ID
# For example
docker-compose logs -f PlexBot
Usage
General:
kill [silent] - Halt the bot [silently].
help - Print this help message.
cleanup - Delete old messages from the bot.
Plex:
play <SONG_NAME> - Play a song from the plex server.
album <ALBUM_NAME> - Queue an entire album to play.
playlist <PLAYLIST_NAME> - Queue an entire playlist to play.
lyrics - Print the lyrics of the song (Requires Genius API)
np - Print the current playing song.
stop - Halt playback and leave vc.
pause - Pause playback.
resume - Resume playback.
clear - Clear play queue.
[] - Optional args.