Skip to content

Local AI chat bot for Discord with web interface for start and configuration

License

Notifications You must be signed in to change notification settings

RafiBG/AIChatDiscordBotWeb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

34 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

AIChatDiscordBotWeb

.NET

AIChatDiscordBotWeb is a local AI-powered Discord bot running on ASP.NET Core. It integrates local LLMs (via Ollama), web search, and image generation into a seamless chat experience.

โœจ Features

What can this local AI do in Discord?

  • ๐Ÿ’ฌ Chat: Natural conversation with context awareness.
  • ๐Ÿ“„ File Analysis: Upload PDF, TXT, or DOCX files, and the bot will read and answer questions based on them.
  • ๐Ÿ‘๏ธ Vision: Upload images and ask the bot to describe or analyze them (requires a Vision model).
  • ๐ŸŒ Web Search: The bot can search the internet for the latest news and real-time information (requires Serper web api key).
  • ๐ŸŽจ Image Generation: The bot can generate images locally using ComfyUI (requires installed ComfyUI).
  • ๐Ÿ—ฃ๏ธ Speaking: The bot can speak in voice channels (requires installed second Discord bot).

๐Ÿ› ๏ธ Tech Stack & Libraries

Built with C# ASP.NET Core Web App (MVC) on .NET 9.0.

Nuget Libraries used:

  • DSharpPlus (4.5.1)
  • DSharpPlus.Interactivity (4.5.1)
  • DSharpPlus.SlashCommands (4.5.1)
  • Microsoft.SemanticKernel (1.66.0)
  • Microsoft.SemanticKernel.Connectors.Ollama (1.66.0-alpha)
  • Microsoft.KernelMemory.Core (0.98.250508.3)
  • Microsoft.KernelMemory.AI.Ollama (0.98.250508.3)
  • DocumentFormat.OpenXml (3.3.0)
  • PdfPig (0.1.11)

โš™๏ธ Installation & Setup

1. Discord Developer Portal

  1. Go to the Discord Developer Portal.
  2. Create a new application and go to the Bot tab.
  3. Privileged Gateway Intents: Scroll down and enable the intents shown below: privilage
  4. Installation: Ensure the bot has the following permissions enabled: bot
  5. Copy your Bot Token. You will need this for the config.

2. Ollama Setup (The Brain)

  1. Download and install Ollama.
  2. Open your console/terminal and run:
    ollama serve
    
    This must be running in the background for the bot to work.
  3. Note the port number (usually the last 5 digits in the error/status message) to put in your config. comm
  4. Download a model (e.g., ollama pull PetrosStav/gemma3-tools:4b) via the command line.
  5. Run the list command to get the exact name:
    ollama list
    
    ModelName
  6. Copy the full model name into your config page.

3. Web Search (Optional)

To enable internet access for the bot:

  1. Get a free or paid API key from Serper.dev.
  2. Paste the API Key into the AIChatDiscordBotWeb Configuration.
serper config serper settings

4. ComfyUI - Image Generation (Optional)

To enable image generation:

  1. Download ComfyUI.
  2. Recommended Models (Text-to-Image):
  3. Place models in: C:\Users\YourPCName\Documents\ComfyUI\models\checkpoints.
  4. Important: Go to ComfyUI Settings and enable Dev Mode.
    dev mode
  5. Add your ComfyUI image directory path in the AIChatDiscordBotWeb Configuration. comfy config

5. Speaking Discord Bot (Optional)

To enable voice capabilities (Voice-to-Text and Text-to-Speech), you must run the secondary Python bot alongside this one.

  • Repository: RafiBG/AITalkingDiscordBot
  • Role: Handles microphone input and generates voice audio using Whisper STT and Piper TTS.
  • Setup: Follow the detailed instructions in the link above to install FFmpeg and Piper TTS.

๐ŸŽฎ Slash Commands

Command Description
/ask [message] (file) (image) Main command. Chat with AI. Optionally attach a file (PDF/TXT/DOCX) for context or an image for vision analysis.
/ask_multi Ask three AI models the same question and the main one will summaries the answer.
/forgetme Starts a fresh conversation loop only for you (clears short-term user memory).
/reset Global Reset. Resets all chats and starts a new conversation for everyone.
/help Shows the help menu with these commands.

๐Ÿ“ธ Gallery & Examples

Chat & Vision Capabilities

File Analysis & Web Search

Image Generation

Long term memory