blob: c352c3a0e3f9f098f2fd3a931bbccfb9bdd027df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# Spotify Discord Profile Widget Bot
A Discord bot that connects Spotify accounts to update Discord Profile Identity widgets with real-time listening statistics (Top Songs, Top Artists, Top Albums, and Recently Liked tracks).
---

## Setup Guide
### 1. Install Dependencies
This project uses **uv** for fast dependency management.
Install the required packages into your virtual environment:
```bash
uv pip install discord.py spotipy aiohttp python-dotenv
```
*(If you are managing the project using a `pyproject.toml` file, you can run `uv sync` instead.)*
### 2. Environment Configuration
Create a `.env` file in the root directory and add your API credentials:
```env
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
SPOTIFY_REDIRECT_URI=http://localhost:8888/callback
DISCORD_BOT_TOKEN=your_discord_bot_token
DISCORD_APP_ID=your_discord_application_id
```
> **Note:** Ensure `http://localhost:8888/callback` is listed under the Redirect URIs in your Spotify Developer Dashboard settings.
---
## Running the Bot
Run the bot script directly using `uv`:
```bash
uv run main.py
```
---
## Bot Commands
| Command | Description |
| --- | --- |
| `/spotify_login` | Generates a Spotify authorization link to start account linking. |
| `/submit_code` | Submits the OAuth code or callback URL to finish linking your account. |
| `/range` | Sets the preferred timeframe for statistics (e.g. `7d`, `4w`, `6m`, `1y`). |
| `/update_widget` | Forces an immediate refresh of your Discord profile widget payload. |
|