This README.md provides instructions on how to set up and run the Discord Spotify Presence Tracker Bot. This bot tracks when members of a Discord server are listening to Spotify and records the songs they are listening to in a MongoDB database.
Before setting up the bot, make sure you have the following:
- Python 3.x installed on your machine.
- MongoDB installed locally or access to a remote MongoDB server.
- A Discord Developer account to create a bot and obtain a token.
Clone this repository to your local machine using the following command:
git clone https://github.com/Josephfallen/Spotify_Scout.git
Navigate to the cloned directory and install the required Python packages using pip:
cd Spotify_Scout
pip install -r requirements.txt
Open the main.py file in a text editor and update the following configurations:
# Discord bot configuration
intents = discord.Intents.default()
intents.guilds = True
intents.guild_messages = True
intents.message_content = True
intents.members = True
intents.presences = True
client = commands.Bot(command_prefix='!', intents=intents)
# MongoDB configuration
mongo_client = pymongo.MongoClient("mongodb://localhost:27017/") # Change if connecting to a remote MongoDB server
db = mongo_client["YOUR_DATABASE_NAME"] # Name this whatever you like, the bot will auto-create the database
collection = db["YOUR_COLLECTION_NAME"] # Name this whatever you like, the bot will auto-create the collection
Replace 'YOUR_TOKEN_HERE' with your Discord bot token obtained from the Discord Developer Portal:
# Start the bot
client.run('YOUR_TOKEN_HERE')
Execute the following command to run the bot:
python spotify.py
!query: Fetches and displays the top 20 most listened to Spotify songs from the database.
- The bot listens for presence updates from Discord members.
- When a member is listening to Spotify, the bot records the song details (title, artist, album, track URL, etc.) in the MongoDB database.
- You can query the database to see the top 20 most listened to Spotify songs by using the
!querycommand.
If you would like to contribute to this project, please fork the repository and submit a pull request. We welcome any contributions!
Go to the Support server to ask questions, talk to other developers, or if you need any help!
This project is licensed under the MIT License. See LICENSE for more information.