Archive Bot is a Discord bot that saves server messages to daily, per-channel text files. Server members can use slash commands to retrieve or summarize saved logs. Summaries are generated by an Ollama model running on a server you configure.
- Archives messages, including message text and references to attachments,
embeds, and stickers, under
logs/<server>/<channel>/<date>.txt. Dates and times are in UTC (see Dates and times). /logdisplays the saved log for one date or a date range of up to seven days./summarysummarizes a saved log for one date or a date range using Ollama./askanswers a question about the saved log and cites the relevant messages./findlists every date a word or phrase was mentioned, across all channels you can see or in one channel./clearlogpreviews log deletion and requires explicit confirmation before deleting a day's log.- Greets new members in an available text channel.
Logs are stored on the machine running the bot. Keep the logs/ directory on
persistent storage and restrict access to it: archived messages may contain
private information. Attachment files are not downloaded, but their names and
URLs are included in log entries.
- Node.js 22 or newer and npm.
- A Discord application and bot, with its token and application ID.
- An Ollama server and a model pulled on that server to use
/summaryand/ask.
The bot needs the Discord Guilds, GuildMembers, GuildMessages, and
MessageContent intents. Enable the privileged Server Members Intent and
Message Content Intent in the Discord Developer Portal. When inviting the
bot, grant it access to the channels it should archive and the permissions
needed to view channels, send messages, and attach files.
-
Install dependencies:
npm install
-
Copy
.env-sampleto.envand set the values:TOKEN=your_discord_bot_token CLIENT_ID=your_discord_application_id OLLAMA_URL=http://127.0.0.1:11434/api/chat OLLAMA_MODEL=your_pulled_model OLLAMA_NUM_CTX=8192 SUMMARY_CHUNK_CHARS=12000 OLLAMA_MAX_CONCURRENT=1 SUMMARY_TIME_LIMIT_SECONDS=720 LOAD_RECENT_MESSAGES=false LOAD_RECENT_DAYS=1 LOAD_RECENT_MAX_PER_CHANNEL=2000
OLLAMA_URLdefaults tohttp://127.0.0.1:11434if omitted; it accepts either the Ollama base URL or the full/api/chatendpoint. The context and chunk-size settings are optional.OLLAMA_MAX_CONCURRENT(default 1) is how many summaries can use the model at once; others are told the service is busy.SUMMARY_TIME_LIMIT_SECONDS(default 720, at most 840) stops a summary before Discord's 15-minute reply window closes, so the user gets a "timed out" message instead of no answer. All settings are read insrc/config.js; the bot stops at startup ifTOKENis missing and warns ifOLLAMA_MODELis missing.GUILD_IDis optional and registers commands to one test server instead of globally.CHANNEL_NAMEis optional and selects the preferred welcome channel.To fill in messages sent while the bot was offline, set
LOAD_RECENT_MESSAGES=true. On startup the bot then reads the lastLOAD_RECENT_DAYS× 24 hours (default 1, up to 30) from every channel and active thread it can read, and adds any messages that aren't logged yet, in time order and without duplicates.LOAD_RECENT_MAX_PER_CHANNEL(default 2000) limits how many messages it reads per channel. The bot needs Read Message History in a channel to load its messages. -
Start Ollama and pull the model named in
OLLAMA_MODEL. For example:ollama pull qwen2.5
-
Register the slash commands with Discord:
npm run deploy
Run this again when command names, descriptions, or options change. Global command registration can take time to appear; setting
GUILD_IDin.envis useful for testing in one server. -
Build and start the bot:
npm start
Do not commit .env or share your bot token. The repository ignores .env and
logs/.
| Command | Options | Access |
|---|---|---|
/log |
Required date; optional to and channel |
Members with Manage Messages |
/summary |
Required date; optional to and channel |
Members with Manage Messages |
/ask |
Required question and date; optional to and channel |
Members with Manage Messages |
/find |
Required topic; optional channel |
Members with Manage Messages |
/clearlog |
Required date; optional channel and confirm |
Members with Manage Server |
Dates can be YYYY-MM-DD, today, or yesterday, all in UTC. For /log, /summary, and /ask,
provide to to select an inclusive range of up to seven days. If channel is
omitted, the command uses the channel where it was run. /clearlog affects one
date only; without confirm: True, it previews the deletion.
Log files are named by UTC date, and each line's time is in UTC and labelled,
for example [2026-11-29 21:15:00 UTC]. today and yesterday also mean the
UTC date, so a date means the same thing wherever the bot is hosted. In Pacific
time, the UTC date changes at 4 PM (5 PM during daylight saving), so a message
sent at 8 PM Pacific on Nov 28 is in the 2026-11-29 log.
Upgrading from an earlier version: older logs use local time, with no
UTC label. They can still be read, searched, summarized and asked about, but
the recent message loader doesn't recognise them. Before starting the new
version, either move the old logs/ folder somewhere else to start fresh, or
start the bot once with LOAD_RECENT_MESSAGES=false, so recent messages aren't
logged twice.
Use /ask question:What did we decide about the demo? date:yesterday. The
question can be up to 500 characters. The private reply cites each source by
author and logged timestamp so you can check it with /log. If the saved
messages don't answer the question, the bot says it couldn't find the answer.
/ask and /summary share the Ollama concurrency limit.
After registering slash commands for your test server with npm run deploy,
ask about a decision in a saved test-channel log. Compare the reply's citations
with /log for that channel and date. Then ask about an absent decision and
try an unrelated request such as “Write me a poem.” Verify both receive a
private reply explaining the result.
npm run dev # Run with nodemon
npm run build # Build the application into build/
npm test # Run the Mocha test suite
npm run coverage # Run tests and generate coverage reportsFor container setup and the GitHub Actions image publishing workflow, see
DEPLOYMENT.md. The bot writes logs to /app/logs in the
container, so mount that directory on persistent storage.
For an overview of the application's modules and data flow, see ARCHITECTURE.md.