Devlog 3:
I’ve made a lot of progress on the bot and changed how it tracks server activity and message data!
I moved the bot away from using the Discord API to scrape the data because that took way too long and wasn’t efficient. For the all-time command, it now dms the owner of the server to ask them for permission to get the data from the server (using discord api) then it adds that data into an sqlite database.
I set up an automatic table layout that tracks users by their permanent Discord user_id rather than their display name. This completely prevents leaderboard tracking bugs if a user decides to change their server nickname.
Next, I added into the real-time event system. The bot now logs and adds to message counts instantly as they are sent in real-time, meaning we don’t have to wait for slow api scrapes anymore. I also updated the /all-time command to pull directly from this local database instantly. I might update the other commands but for now its just using the discord api.
To make the system scaleable, I added a full-server data sync. When the bot joins a new server, it sends a DM to the owner with a green setup button. Clicking it runs a background scan across all text channels to build the database. I ran into two big bugs while setting this up:
- The bot was accidentally wiping out data from previous channels as it moved to the next one. I fixed this by making the bot compile everything across the entire server into a tracking dictionary first, and then saving it all to the database at the very end.
- I had to restructure the database schema to use a combined primary key of (guild_id, user_id). This keeps counts completely isolated so a user’s stats on one server never leak into another server.
Lastly, I added stats.db to the .gitignore file so it isn’t committed to github.
Next steps:
I might just ship it with these core features (definitely not for a sticker or anything 😂 🙏)
I will try and continue to work on it and somehow find away to integrate VC support. This would need me to:
- Build a VC tracking system to see who spends the most time in voice channels over days, weeks, and all-time.
I might also in the future update the leaderboard messages from the commands to have embeds so it looks cleaner and more professional using discord embeds.
Thank you for reading my 3rd devlog!
Edit:
OH YEAH I just remembered I’m gonna host it on a server so I don’t need it running locally all the time.