Discord bots are usually either simple command-handlers or bloated webhook sinks. When building Prometheus Core, my goal was to create a modern conversational companion with deep server contextual memory and an accessible web dashboard where server admins could customize bot behavior in real time.
1. The System Architecture
The project is split into two complementary environments: a Node.js daemon running Discord.js with Gateway intents, and a Next.js web application for administration. Both connect to a shared MongoDB cluster and communicate asynchronously via webhooks.
2. Integrating Gemini 2.5 with Contextual Memory
One of the key engineering challenges was keeping conversation latency below 800ms while maintaining message history. I implemented a rolling token window cache per server channel to send conversation history to the Gemini API without exceeding token quotas.
// Channel message buffer with token limit
export async function generateBotResponse(channelId: string, userPrompt: string) {
const history = await getChannelContext(channelId, { limit: 8 });
const contents = [
...history.map(msg => ({
role: msg.isBot ? "model" : "user",
parts: [{ text: msg.content }]
})),
{ role: "user", parts: [{ text: userPrompt }] }
];
const response = await ai.models.generateContent({
model: "gemini-2.5-flash",
contents
});
return response.text;
}3. Real-Time Web Dashboard Sync
The Next.js dashboard uses Server-Sent Events (SSE) and SWR to monitor bot uptime, active guild counts, and server command analytics with sub-second responsiveness.
Conclusion & Takeaways
Building Prometheus taught me how to handle asynchronous event loops, rate limits on external LLM APIs, and clean data caching. It's fully live and open-source on GitHub.