A Discord bot that analyzes the emotional content of song lyrics in real time using Spotify, Genius, & VADER sentiment analysis.
INFO 3510 Music as Information - CU Boulder, Fall 2025.
The Idea
My first project analyzed sentiment differences between living and deceased emo rap artists... but everything was hardcoded around my specific artist choices. If someone wanted to analyze a song they loved, they couldn't. For this project, I wanted to build something flexible and interactive: a Discord bot anyone could use to explore the emotional content of any song, in real time, right where people already talk about music.
How It Works
The bot connects three APIs to do its job. Spotify provides artist information and top tracks. Genius retrieves the actual lyrics, filtering out remixes and section headers like [Chorus] that would muddy the analysis. VADER: a sentiment tool designed for casual, informal text- analyzes the emotional tone of the lyrics.
Rather than averaging a whole song at once (which can hide a lot of emotional nuance), the bot breaks lyrics into 10-word chunks and analyzes each one individually. A song with a devastating verse and an uplifting chorus might average to "neutral"- but the chunk-by-chunk approach shows the actual emotional journey.
Commands
/toptracks [artist] — Returns an artist's top 10 songs from Spotify, sorted by popularity.
/lyrics [artist] + [song] — Fetches full lyrics from Genius, split into multiple Discord messages if needed.
/searchlyrics [snippet] — Reverse-searches Genius by lyric snippet and returns up to 5 matching songs.
/sentiment [artist] + [song] — Analyzes overall mood and returns a label (Positive, Negative, or Neutral) with a compound score.
/sentimentplot [artist] + [song] — Generates a line graph showing how sentiment shifts throughout the song and uploads it directly to Discord.
Sample Output
Sentiment progression through "Beach Baby" by Bon Iver — chunk by chunk.
Code Structure
The project is organized into four files following a separating concerns design principle. spotifyHelper.py handles all Spotify API calls. geniusHelper.py handles lyrics retrieval and lyric search. vaderHelper.py handles all sentiment analysis and visualization. musicBot.py ties everything together as the main bot with command handlers. When something broke, I only had to look in one place, which made debugging dramatically easier than one tangled file would have been.
What I Learned
This project was as much about how I wrote code as what I built. Coming off my first project, I knew I'd relied too heavily on AI assistance without fully understanding what I'd produced. This time I made a conscious decision to understand every line, even if that meant building something simpler. When Claude showed me a list comprehension I didn't fully grasp, I asked for the longer version, studied both, and made myself able to explain each one. The short version is cleaner, but I can now tell you exactly why it works.
VADER has real limitations... it was built for social media, not poetry, and misses sarcasm, irony, hip-hop slang, and songs where negative words carry a positive message. But it still achieves the core goal: making sentiment analysis interactive, visual, and accessible to anyone in a Discord server.
If I Kept Building
Future additions would include Spotify audio feature comparisons (do sad lyrics actually match minor keys?), database storage so repeat requests are instant, better sentiment models trained on lyrics specifically, and word frequency and rhyme scheme analysis. Maybe even triggering a YouTube or Spotify playback link alongside the analysis.