Skip to content
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
af2ae08
Cleanup
238SAMIxD Feb 12, 2025
331e0a6
Rewrite to typescript
238SAMIxD Feb 12, 2025
7017e85
Fix Dockerfile
238SAMIxD Feb 13, 2025
d99ce54
Added channels handling
238SAMIxD Feb 13, 2025
b146ade
Added channels command
238SAMIxD Feb 13, 2025
2d9cd51
Remove unused code
238SAMIxD Feb 14, 2025
3a30b0c
Add tests placeholders
238SAMIxD Feb 14, 2025
7328dc0
Added consts
238SAMIxD Feb 16, 2025
718590c
Fixed max files for message
238SAMIxD Feb 16, 2025
f24d813
Fixed a typo
238SAMIxD Feb 27, 2025
a3bde3d
Improved command finding
238SAMIxD Feb 27, 2025
283d8f3
Added info about mutex
238SAMIxD Feb 27, 2025
1e98a3a
Code review improvements
238SAMIxD Feb 27, 2025
755b243
Added system prompts and fixed discord limits (#37)
238SAMIxD Mar 22, 2025
a519b57
Added missing .env options
238SAMIxD Mar 22, 2025
41c3c32
Implemented chat history and changed chat endpoint (#38)
238SAMIxD Mar 22, 2025
39930f4
Created generate command (#39)
238SAMIxD Mar 22, 2025
ea0d6a5
Added channels info
238SAMIxD Mar 22, 2025
1fb575b
Created text attachments handler (#40)
238SAMIxD Mar 23, 2025
9e3efe4
Created image attachments handler (#41)
238SAMIxD Mar 23, 2025
1e770df
Created PDF attachments handler (#42)
238SAMIxD Mar 23, 2025
95e2312
Updated docker (#43)
238SAMIxD Mar 24, 2025
90866b3
Fixed system prompt
238SAMIxD Mar 25, 2025
0808d6f
Created unit tests (#44)
238SAMIxD Mar 25, 2025
d54e513
Added GitHub workflows (#45)
238SAMIxD Mar 26, 2025
32145b2
Refactor: Use TypeScript for ESLint and Jest configurations (#47)
238SAMIxD May 21, 2025
fc6217f
Cached command name
238SAMIxD May 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 10 additions & 21 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# Discord bot token
TOKEN=
# Discord bot token https://discord.com/developers/applications/<ID>/bot
DISCORD_TOKEN=

# What language model to use, orca is one of the lower-end models that doesn't require as much computer power as llama2
MODEL=orca

# Ollama URL
# Ollama URL (only one sever)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix typo in environment docs comment.

Line 4 says “sever” instead of “server”.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.env.example at line 4, Fix the typo in the environment example comment by
changing the text "# Ollama URL (only one sever)" to use the correct word
"server" so the comment reads "# Ollama URL (only one server)"; locate this
exact comment string in the .env.example and update it accordingly.

OLLAMA=http://localhost:11434

# Stable diffusion URL
# Stable Diffusion URL (only one server)
STABLE_DIFFUSION=http://localhost:7860

# What Discord channels to enable it in (by ID)
CHANNELS=123456789,987654321
# List of channels IDs bot will respond in (separated by commas)
# Obtain them by right-clicking on the channel and clicking "Copy ID" (ensure Developer Mode is enabled in Discord settings)
# Leave empty to respond in all channels
CHANNELS=123,356,238

# System message that the language model can understand
# Feel free to change this
Expand Down Expand Up @@ -46,15 +45,5 @@ USE_SYSTEM=true
# Use the model's system message? (true/false) If both are specified, model system message will be first
USE_MODEL_SYSTEM=true

# Require users to mention the bot to interact with it? (true/false)
REQUIRES_MENTION=true

# Whether to show a message at the start of a conversation
SHOW_START_OF_CONVERSATION=true

# Whether to use a random Ollama server or use the first available one
RANDOM_SERVER=false

# Whether to add a message before the first prompt of the conversation
INITIAL_PROMPT=""
USE_INITIAL_PROMPT=false
# Maximum number of attachments to send to the model
MAX_ATTACHMENTS=3
52 changes: 0 additions & 52 deletions .eslintrc.json

This file was deleted.

3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist

*.md
12 changes: 12 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"plugins": [],
"arrowParens": "avoid",
"bracketSameLine": true,
"bracketSpacing": true,
"singleQuote": false,
"trailingComma": "es5",
"tabWidth": 2,
"useTabs": false,
"semi": true,
"printWidth": 100
}
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM node:20

COPY . .
RUN npm i --omit=dev --no-package-lock
RUN npm run build
USER node

CMD ["node","./src/index.js"]
CMD ["npm","start"]
37 changes: 25 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
<div align="center">
<h1>Discord AI Bot</h1>
<h2>Repository is now in maintanance mode - rewriting project to Typescript on <a href="https://github.com/238SAMIxD/discord-ai-bot/tree/typescript">typescript</a> branch</h2>
<h3 align="center">Discord bot to interact with <a href="https://github.com/jmorganca/ollama">Ollama</a> and <a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui">AUTOMATIC1111 Stable Diffusion</a> as a chatbot</h3>
<h3><img alt="Stars" src="https://img.shields.io/github/stars/mekb-turtle/discord-ai-bot?display_name=tag&style=for-the-badge" /></h3>
<h3><img alt="Discord chat with the bot" src="assets/screenshot.png" /></h3>
<h1>Discord AI Bot</h1>
<h2>Repository is now in maintenance mode - rewriting project to Typescript</h2>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (typo): Use the conventional capitalization "TypeScript" instead of "Typescript".

This keeps the heading consistent with the official project name and common usage.

Suggested change
<h2>Repository is now in maintenance mode - rewriting project to Typescript</h2>
<h2>Repository is now in maintenance mode - rewriting project to TypeScript</h2>

<h3 align="center">Discord bot to interact with <a href="https://github.com/jmorganca/ollama">Ollama</a> and <a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui">AUTOMATIC1111 Stable Diffusion</a> as a chatbot</h3>
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/238samixd/discord-ai-bot?style=social">
</div>

The project started thanks to [mekb](https://github.com/mekb-turtle).

### Set-up instructions
## Roadmap

- Handle pdf attachments
- Implement multiple servers support (copying commands?)
- Check (and fix if necessary) `Dockerfile` and `docker-compose` setup
- Review installation and usage instructions
- Create docs with examples for the bot
- Add slow mode option to prevent spam and GPU overload
- Write unit tests
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 16 mentions "Write unit tests" in the roadmap, but unit tests have already been written in this PR (tests/utils/). This roadmap item should be updated to reflect the current state.

Suggested change
- Write unit tests
- Expand and maintain unit test coverage

Copilot uses AI. Check for mistakes.
- Create a RAG to extract information from _PDFs_ and/or docs
- Implement [OpenWebUI](https://github.com/open-webui/open-webui) interactions (web search, youtube loader)
- ? Implement [fabric](https://github.com/danielmiessler/fabric) integration (patterns, youtube video extraction if needed)
Comment on lines +18 to +19
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (typo): Capitalize "YouTube" as a proper noun in roadmap bullets.

Specifically, update “youtube loader” and “youtube video extraction” to “YouTube loader” and “YouTube video extraction.”

Suggested implementation:

- Implement [OpenWebUI](https://github.com/open-webui/open-webui) interactions (web search, YouTube loader)

- ? Implement [fabric](https://github.com/danielmiessler/fabric) integration (patterns, YouTube video extraction if needed)

- Fix streaming issues `/chat ... stream: True` (handle race - `async-mutex`)

### Set-up instructions (TO BE REVIEWED)

1. Install [Node.js](https://nodejs.org) (if you have a package manager, use that instead to install this)
- Make sure to install at least v14 of Node.js
2. Install [Ollama](https://github.com/jmorganca/ollama) (ditto)
3. Pull (download) a model, e.g `ollama pull orca` or `ollama pull llama2`
4. Start Ollama by running `ollama serve`
- Make sure to install at least v18 of Node.js (v20+ recommended)
2. Install [Ollama](https://github.com/ollama/ollama)
3. Pull (download) a model, `ollama pull MODEL` e.g `ollama pull llama3.1` - [Model list](https://ollama.com/search)
4. Start Ollama by running `ollama serve` if not already running
5. [Create a Discord bot](https://discord.com/developers/applications)
- Under Application » Bot
- Enable Message Content Intent
Expand All @@ -36,10 +49,10 @@ The project started thanks to [mekb](https://github.com/mekb-turtle).
8. Install the required dependencies with `npm i`
9. Start the bot with `npm start`
10. You can interact with the bot by @mentioning it with your message
11. Install <a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui">Stable Diffusion</a>
11. Install [Stable Diffusion](https://github.com/AUTOMATIC1111/stable-diffusion-webui)
12. Run the script `./webui.sh --api --listen`

### Set-up instructions with Docker
### Set-up instructions with Docker (TO BE CHECKED)

1. Install [Docker](https://docs.docker.com/get-docker/)
- Should be atleast compatible with version 3 of compose (docker engine 1.13.0+)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (typo): Fix the typo "atleast" → "at least".

Expand Down
Binary file removed assets/screenshot.png
Binary file not shown.
19 changes: 19 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import js from "@eslint/js";
import globals from "globals";
import tseslint from "typescript-eslint";

export default tseslint.config(
{ ignores: ["dist"] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ["**/*.ts"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {},
rules: {
"@typescript-eslint/no-unused-vars": "error",
},
}
);
99 changes: 0 additions & 99 deletions eslint.config.mjs

This file was deleted.

64 changes: 46 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,48 @@
{
"name": "discord-ai-bot",
"main": "src/index.js",
"scripts": {
"start": "node src/index.js"
},
"dependencies": {
"axios": "^1.6.3",
"discord.js": "^14.14.1",
"dotenv": "^16.3.1",
"meklog": "^1.0.2"
},
"type": "module",
"devDependencies": {
"@eslint/js": "^9.7.0",
"@types/eslint__js": "^8.42.3",
"eslint": "^9.7.0",
"globals": "^15.8.0"
}
"name": "discord-bot-template",
"version": "1.0.0",
"description": "A basic Discord bot template using TypeScript and discord.js",
"main": "dist/index.js",
"scripts": {
"start": "node dist/index.js",
"build": "tsc",
"dev": "ts-node src/index.ts",
"test": "npm run test:lint && npm run test:prettier && npm run test:jest",
"test:jest": "jest",
"test:lint": "eslint src",
"test:prettier": "prettier --check src",
"lint": "eslint src --fix",
"prettier": "prettier --write src"
},
"keywords": [
"discord",
"bot",
"typescript",
"discord.js"
],
"author": "238SAMIxD",
"license": "ISC",
"dependencies": {
"axios": "^1.7.9",
"discord.js": "^14.14.1",
"dotenv": "^16.4.5",
"meklog": "^1.0.2"
},
"devDependencies": {
"@eslint/js": "^9.20.0",
"@jest/globals": "^29.7.0",
"@types/eslint__js": "^8.42.3",
"@types/jest": "^29.5.14",
"@types/node": "^20.11.24",
"eslint": "^9.20.1",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-prettier": "^5.2.3",
"globals": "^15.15.0",
"jest": "^29.7.0",
"prettier": "^3.5.0",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.4.2",
"typescript-eslint": "^8.24.0"
}
}
Loading