Skip to content

Repository files navigation

🤖 Gemini Discord Bot

A Discord bot backed by Google's Gemini models with built-in Google Search grounding — so when you ask about news, prices, or anything current, it searches the web and answers from live results instead of guessing. Pick a model per channel with !listen, then just type to talk, or @mention the bot anywhere for a one-off answer.

Screenshot of the bot answering a question in a Discord channel

License: MIT Python Powered by Gemini Buy Me a Coffee


✨ What it does

  • Grounded answers. Free-form chat automatically uses Google Search so answers about current events are based on live results, not stale training data.
  • Per-channel model picker. !listen lets each channel choose a Gemini model — 2.5 Flash-Lite (fast/cheap), 2.5 Flash, or 2.5 Pro — and remembers it. Add or change models by editing one list in bot.py.
  • Just type to talk. Once a channel is in chat mode, plain messages go to the model. Or @mention the bot in any channel without entering chat mode.
  • Server-aware helpers. !summarize summarizes any channel; !server answers a question from the last 3 days of activity across the whole server.
  • Maps on request. Ask for directions/a place and the model can drop a clickable Google Maps link.
  • Short per-channel memory and automatic splitting of long replies to fit Discord's limit.

🧩 What you need (required vs. optional)

🔴 Required

🟢 Optional

  • Safety filters are configurable. By default the bot uses Google's standard safety filtering; you can set SAFETY_FILTERS=off in .env to disable them on a private server (see notes below).

Unlike a local-model bot, this one sends your prompts to Google's Gemini API to generate answers — that's how it works. Nothing else leaves your machine.


🚀 Quick start

Mac: download this project (green Code button → Download ZIP), unzip it, double-click install-mac.command (first time: right-click → OpenOpen), paste your token + key into the new .env file, then double-click start-mac.command.

Windows: unzip, double-click install-windows.bat, edit .env, then double-click start-windows.bat.

Any OS:

python -m venv .venv && source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env      # then edit .env with your token + key
python bot.py

The full walkthrough — creating the Discord bot, enabling intents, inviting it, and getting a Gemini key — is in INSTALL.md.


💬 Commands

Command What it does
!listen Put this channel into chat mode; reply with a number to pick a Gemini model. Then just type to talk.
!summarize Summarize the recent history of a channel you pick.
!server <question> Answer using the last 3 days of activity across the server.

You can also @mention the bot in any channel to ask a one-off question (with web grounding on).


⚙️ Configuration

All settings live in a .env file (the installer creates it from .env.example):

DISCORD_TOKEN=your_bot_token_here
GEMINI_API_KEY=your_gemini_api_key_here
GEMINI_MODEL=gemini-2.5-flash-lite
SAFETY_FILTERS=on

DISCORD_TOKEN and GEMINI_API_KEY are required. Your .env stays on your machine and is never uploaded. To change the models offered by !listen, edit the MODELS dict near the top of bot.py.


🔒 Security & safety notes

  • Both keys are passwords. They live only in .env, which is git-ignored. If a key leaks, rotate it: Discord (Bot → Reset Token) or Gemini (delete the key in AI Studio and make a new one).
  • Safety filters: SAFETY_FILTERS=on (the default) uses Google's default content filtering. Setting it to off disables all filters (BLOCK_NONE) — only do that on a private server you control, and understand you're turning off Gemini's guardrails.
  • The bot reads message content in servers it joins (required for a prefix bot), so add it only to servers you trust.

📄 License

Released under the MIT License — free to use, modify, and share. See LICENSE.


☕ Support

I build and share these tools for free in my spare time. If this bot is useful to you, you can buy me a coffee — genuinely appreciated, and it helps me keep making things like this. Enjoy! 🙌

About

Discord bot linked to your gemini API key utilizing Gemini models

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages