A lightweight Discord bot using Discord.js and OpenAI’s ChatGPT. Features thread-aware memory, persona/fine-tuned modes, cooldowns, emoji replacement, LaTeX rendering, image-and-file inputs, and rotating logs.
src/
├─ commands/ Slash commands (ask, setCooldown, stop, …)
├─ controllers/ Event handlers (messages, interactions)
├─ services/ Core logic (prompt builder, LaTeX renderer, persona)
├─ store/ In-memory + encrypted persistence (user & clone memory)
├─ utils/ Helpers (cooldown, file I/O, logging, Discord formatting)
└─ index.ts Entry point
-
Clone & install
git clone https://github.com/wobkobi/ChatGPT-Discord-Bot.git cd chatgpt-x-discord npm install
-
Configure
-
Copy the environment example and fill in your values:
-
On macOS/Linux:
cp .env.example .env
-
On Windows (PowerShell or CMD):
copy .env.example .env
-
-
Copy the persona template:
-
On macOS/Linux:
cp src/config/persona.example.json src/config/persona.json
-
On Windows (PowerShell or CMD):
copy src\config\persona.example.json src\config\persona.json
-
-
Edit
.env
andsrc/config/persona.json
in any text editor to set your credentials, keys, and persona text.
-
-
Run
npm run dev
- /ask – Ask the bot privately (ephemeral reply).
- /setCooldown – (Owner/Admin) Adjust rate limits per-guild.
- /stop – (Owner) Gracefully shut down the bot.
Mention the bot (or wait for a random interjection) in any channel to see persona-driven replies, math rendering (\[ … \]
→ attached images), and image/file support.
- Persona vs Fine-tune: Toggle with
USE_PERSONA
andUSE_FINE_TUNED_MODEL
in.env
. - Memory: Threads auto-summarise every 10 messages into long-term store.
- Logging: Daily-rotating logs in
logs/
, level set byLOG_LEVEL
.