Inspiration

On the night before the exam, rather than stopping learning, students panic-message on Discord. The messy conversations announcing confusions and clearing misconceptions are often a useful source of learning that puts the students close to the same level with each other. Instead of requiring an individual to explain a misconeption direcly to AI, what if it could just be there, on standby, waiting to address the misconceptions and unknown gaps in knowledge, targeting multiple students at the same time.

What it does

Our Discord bot, Panikbot, is an ambient AI study companion living within the students discord server to monitor conversations and provide a set of tools:

!saveus - Scrapes the last X hours of chat (customisable), runs it through Gemini 2.5 Pro to detect academic misconceptions vs procrastination and either roasts the group into "locking in" or offers to generate a deep-dive study guide on the whole scraped chat. !helpus - Generates a targeted, visually stunning HTML study guide on the desired topic, informed by what the group has uploaded (notes). !analyse - Lets users pick a custom date range via calendar-style dropdowns and analyses the chat between those timestamps - perfect for reviewing a full week of revision or the conversation on the night before the exam. !quiz - Generates a 5-question multiple-choice quiz based on the most recent study session. After polls close, !answers analyses who got what wrong, shows a scoreboard, identifies weak topics, and offers to generate a focused study guide. !battle - A real-time speed quiz where students race to type the correct answer first and are awarded points with a leaderboard at the end. Community-Driven RAG - When students answer questions in threads and their answers get an upvote reaction, those explanations are automatically embedded and stored in a local ChromaDB vector database. Future study guides pull from this knowledge base, crediting the original authors with Community Spotlight callouts, offering a more personalised and rewarding environment for certain topics. !ragsync backfills historical data on new deployments. !rag - Shows how many community-contributed entries exist in the knowledge base. All generated study guides are uploaded to AWS S3 and served as dark-mode, responsive HTML pages with animated sections, print-friendly layouts, and the PanikBot branding.

How we built it

Python 3.12 with discord.py for the bot framework, handling custom commands, events, reactions, modals, buttons, and dropdowns. Google Gemini 2.5 Pro via the google-genai SDK for all AI chat analysis (structured JSON output via Pydantic schemas), HTML study guide generation, quiz generation, battle question generation, and text embeddings for RAG. ChromaDB is running locally as the vector database for our community RAG pipeline. We use Gemini's text-embedding-004 model to generate 768-dimensional embeddings, enabling semantic similarity search across community-contributed explanations, including it in study guides. AWS S3 (eu-west-2) for hosting HTML study guides that are automatically generated, served via presigned URLs. Wikipedia API for sourcing relevant educational images (diagrams, charts, SVG illustrations) — filtered to exclude irrelevant photos, icons, and logos. Tailwind CSS + AOS.js embedded via CDN in all generated study guides for an animated, responsive design with glassmorphism cards, scroll-triggered animations, and a gold/black design system matching our brand.

Challenges we ran into

Discord API character limits - Poll answer options have a strict character limit that our detailed quiz answers kept exceeding. We solved this by restructuring polls to show the full question and answers in the question field itself, with only A,B,C,D as the selectable options. For questions exceeding 300 characters, we split them into a rich embed and a short poll. Context cross-contamination - Early versions of our Gemini prompts would combine topics from different Discord channels and threads, attributing misconceptions from one conversation to another. We added strict context boundary rules to every prompt, instructing the AI to treat each Channel and Thread as an isolated conversation. ChromaDB and Python 3.14 incompatibility - ChromaDB's Pydantic v1 dependency broke on Python 3.14, a bug with no fix available. We downgraded to Python 3.12, which resolved it cleanly. Wikimedia 403 errors - Our image search was getting blocked because we weren't sending a User-Agent header, which the Wikimedia's API requires. We also switched from raw Commons search to the Wikipedia article API for far more relevant educational images and added aggressive filtering to skip icons, logos, portraits, and other irrelevant media. RAG portability - ChromaDB stores data locally, so switching machines means losing the knowledge base. We built !ragsync to scan all historical threads for upvoted messages and backfill the database on any new deployment. Empty message errors - The bot kept crashing trying to send empty Discord messages after stripping bot commands from chat history. Added defensive checks throughout to fix this.

Accomplishments that we're proud of

The competitive and enabling environment that we have turned messy discord conversations into, through our quiz and battle feature. The RAG utilises the community's responses to certain questions and includes them in the study guides to offer a personal response. The study guides offer a premium look with dark-mode glassmorphism, an animated scroll effect, embedded animated diagrams and print-friendly styles.

What we learned

What makes a good study guide a great study guide is its focus on adding community and tailored responses. Often, AI responses to student misconceptions may contain unnecessary information; students feel more comfortable if such responses are tuned based on the material that the students' examinations may be based on.

What's next for PanikBot

Our intention is to publish this as a usable, easily integrable freemium product with rate limits to preserve the cost element. We intend to offer a £10 unlimited use license aswell, with users being able to add the bot to one group chat with the license. We have begun development on the website, and are in the process of acquiring the domain "panikbot.io" to host the website and payment platform, using technologies like stripe.

Built With

  • amazon-web-services
  • chromadb
  • discord-api
  • discord.py
  • git
  • google-gemini-2.5-flash
  • google-genai-sdk
  • json
  • pydantic
  • python-3.12
  • python-dotenv
  • vscode
  • wikipedia-api
Share this project:

Updates