A Discord bot built with .NET that tracks Spotify listening statistics for server members and posts weekly summaries.
Listenfy integrates Spotify with Discord to provide members with personalized listening statistics. Users can link their Spotify accounts, view their stats, and enjoy weekly summaries of their music listening habits. Server admins can configure where stats are posted.
- Language: C# (.NET 10.0)
- Discord Integration: NetCord - Modern Discord bot library
- Database: PostgreSQL with Entity Framework Core
- .NET 10.0 SDK
- PostgreSQL database
- Spotify API credentials (Client ID & Secret)
- Discord bot token
Copy .env.example to .env and update with your values:
cp .env.example .env- Clone the repository:
git clone https://github.com/henrychris/listenfy.git
cd listenfy- Navigate to src directory:
cd src- Restore dependencies:
dotnet restore- Update database:
dotnet ef database update- Run the application:
dotnet runThe application will start at http://localhost:5051. The solitary callback endpoint is available at http://localhost:5051/scalar/v1.
For local development, you can use Docker to run a PostgreSQL instance:
docker run --name listenfy-postgres \
-e POSTGRES_PASSWORD=mysecretpassword \
-e POSTGRES_USER=postgres \
-e POSTGRES_DB=ListenfyDb \
-p 5430:5432 \
-d postgresThis creates a PostgreSQL container with settings matching the .env.example file.
dotnet buildEnsure your .env file is configured and the database is running, then:
dotnet runThe bot will connect to Discord and be ready to use. Add the bot to your server using the OAuth2 URL with appropriate permissions:
- Send Messages
- Send Messages In Threads
- Embed Links
- Use Slash Commands
- Read Message History
This project uses CSharpier for code formatting. To check formatting:
dotnet tool restore
dotnet csharpier --check .To format code:
dotnet csharpier .Contributions are welcome! Whether it's bug fixes, new features, or documentation improvements, feel free to:
- Open pull requests for new features or improvements
- Report issues on GitHub
- Suggest enhancements
- Pull Requests: PRs are squash merged, so ensure the PR title clearly describes the changes. The description should provide detailed context about what's being added or modified. Branch off dev when building features and use
masteras the base/target branch. - Commits: Each commit within a PR should have an informative title. Please squash trivial commits before submitting.
- Code Style: Run
dotnet csharpier .before committing to ensure code is properly formatted. The CI will check this automatically.