A Discord bot that outputs formatted, color-coordinated images of your currently playing Last.fm song.
Use .set [last.fm username]
to associate your Last.fm username with your Discord account
Use .fmi
to output your currently playing Last.fm song
Use .cd
to start a 10 second countdown (for synchronizing listening parties)
- Dominant colors are found through k-means clustering via the scikit-learn package
- Uses the CIELAB color space for more accurate clustering, as well as the CIEDE2000 Color-Difference Formula to pick a secondary color.
If you'd like to run your own instance, you can do it with the instructions below:
- Make sure you are running Python 3.8 or higher
- Clone the repository
- Set up venv with
python3.8 -m venv venv
and activate it withsource venv/bin/activate
- Install dependencies with
python3.8 -m pip install -U -r requirements.txt
- Create a
.env
file in the base directory with four variables,LASTFM_API_KEY
,DISCORD_TOKEN
,BOT_DEBUG
, andBOT_PREFIX
:LASTFM_API_KEY: Your Last.fm API key DISCORD_TOKEN: Your Discord bot's private token BOT_DEBUG: (0 or 1) Whether you want errors to print to the console. Set this to 1 if you are running this locally, 0 if you are in a production environment BOT_PREFIX: The prefix for the bot commands. If set to "?", "?fmi" will be the command to output an fmi
- Using PostgreSQL 10 or higher and using the psql tool, create a database
cosmo
under the default userpostgres
, then create a table calleddiscord
within it:
CREATE DATABASE cosmo;
CREATE TABLE discord ( id bigint PRIMARY KEY UNIQUE, username TEXT NOT NULL );
- Set the Postgres authentication method to "trust"
- Start the PostgreSQL server. On Linux, the command is:
sudo service postgresql start
- Run the bot with
python3 launcher.py
- Font issues should be fixed as of 5/6/2024. We are using imagetext-py, which contains font fallbacks. If there are issues with languages I haven't added yet, please open an issue and I can look into adding them.
- Arabic fonts do not render properly (the glyphs are shown from left-to-right instead of right-to-left).