Building a Discord Gallery Bot: Leaderboard & Automatic Favorites


Running a photo gallery channel on Discord is exhausting when done manually. Good photos sink, and nobody knows who the most active contributors are. So I built Galeri Kito — a Python (discord.py) + SQLite Discord bot that automates everything.
Every photo posted to a gallery channel instantly gets 1 automatic like from the bot. All likes are counted as running totals from day one, and the Top 10 Likes + Top 10 Uploads leaderboard refreshes every 10 minutes.
Once a post crosses 5 likes, the bot reposts it to a dedicated favorites channel, complete with a button linking to the original post. An anti-duplicate table guarantees each post appears only once.
# 4 user likes + 1 bot love = featured FAVORITE_THRESHOLD = 5
if likes >= FAVORITE_THRESHOLD and not featured(msg_id): repost_to_favorites(msg) mark_featured(msg_id)
The bot also assigns automatic roles per channel — selfies earn Bujang Belagak/Bidadari Kito, OOTD posts become Fashionista — and every post automatically gets a comment thread so the main channel stays clean. Gallery channels are strictly guarded: text without a photo gets deleted instantly.
The bot runs as a systemd service with a watchdog cron every 5 minutes, so it survives server restarts.
