Inspiration

I have spent years in Discord communities where useful knowledge slowly disappears into thousands of old messages. I would often remember who said something and roughly what it was about, but not the exact wording, channel, or date. Discord’s normal search works well when you know the right keywords, but not when you only remember the meaning. I built Discord History Bot to solve that problem: describe the message you half remember and get linked back to the original conversation.

Another use case would be to ask the bot if there is anything about a certain topic that perhaps you haven't witnessed it was actually discussed.

What it does

Discord History Bot indexes selected channels and lets members search their server history using natural language. A user can describe an old message using clues such as the author, topic, approximate date, channel, or attachment, and the bot returns up to three likely matches with confidence levels and explanations.

Every result includes a link to the original Discord message, so the answer can be verified instead of trusted blindly. The bot also respects Discord permissions: users only receive results from channels they can currently access. Replies and ordinary conversation are ignored so the bot does not interrupt people unnecessarily.

How I built it

I built the bot in TypeScript using Discord.js, SQLite, Railway, and the OpenAI API. Messages from configured channels are indexed into a persistent database, along with searchable text, metadata, and embeddings generated with text-embedding-3-small.

Search uses a hybrid retrieval system that combines exact text matching with semantic similarity. GPT-4.1-mini extracts useful search clues, classifies whether a message is genuinely a search request, and re-ranks the best candidates using the original query. Permission checks happen before candidates are processed and again before results are returned. I also added slash commands for server setup, backfilling existing history, checking indexing status, and managing the bot.

Challenges I into

One major challenge was preventing Historybot from treating every message as a search. Replies and ordinary conversation in the search channel could accidentally activate the bot. I solved this in two stages: replies are ignored using a simple internal rule that requires no API call, while remaining standalone messages are classified by GPT-4.1-mini to determine whether they are genuine history-search queries.

I also encountered a cross-language retrieval problem. An English query about “overripe bananas tasting better from the fridge” initially missed the original Croatian message and returned weaker English keyword matches. Although multilingual embeddings understood the meaning, keyword-heavy candidates crowded out the correct message, while GPT’s interpretation could occasionally drift from the original query. Codex fixed this by preserving the original wording, searching both the original and interpreted meanings, reserving candidate slots for semantic matches, and merging the results before reranking.

Accomplishments I am proud of

I deployed a working multi-server private beta that administrators can install without creating their own Railway account or supplying an OpenAI API key. In the first live server, Historybot successfully indexed 17,424 messages across 15 channels with zero failures.

I am especially proud that the bot can recover a Croatian message from an English description, link directly to the original source, avoid triggering on replies, and enforce each member’s Discord permissions throughout the search pipeline. These are small details individually, but together they make the bot feel trustworthy and usable in a real community.

What I learned

I also learned that deciding when an AI feature should remain silent is as important as generating a good response. Combining deterministic rules, such as "ignore a reply to a direct message" with sending the rest to GPT mini produced better results than just asking the AI to take care of everything.

What's next for Discord History Bot

My next step is expanding the private beta to more Discord communities and using real searches to improve relevance, latency, and onboarding. I want to give administrators clearer controls over which channels are indexed, retention limits, deletion, and privacy information.

I also plan to improve support for dates, attachments, multilingual communities, and conversational follow-up searches. Longer term, I want Historybot to become a reliable memory layer for Discord communities: helping people recover useful knowledge without replacing or inventing the original conversation.

Built With

Share this project:

Updates