Skip to content

Discord bot which transforms your servers into hubs for limitless local AI-driven interaction and content creation. Features cutting-edge tools for professionals, and unlocks creative fun for casual users. Integrates text-generation-webui and Stable Diffusion Web UIs.

License

Notifications You must be signed in to change notification settings

altoiddealer/ad_discordbot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

altoiddealer's Discord Bot

Uniting text-generation-webui and Stable Diffusion (A1111 / Forge / ReForge) for casual fun, creativity & professional use.

  • Both text-generation-webui and Stable Diffusion are optional.
  • The features of both can be independently enabled/disabled in the main config file.

Screenshot 2023-09-22 224716

For support / discussion, visit the dedicated ad_discordbot channel on the TextGenWebUI Discord server.


What's new | Features | Installation | Usage | Updating


What's new:

click to expand

04/04/2025: Major rewrite of core install logic (can now be installed as a Standalone!) Update Wizards!

This bot has always required text-generation-webui to function. Now, the bot may installed as a standalone, or optionally with TGWUI integration.

This update also replaces the Update scripts with Update Wizards. From the wizard it is possible to change between Standalone and TGWUI integration.

Screenshot 2025-04-04 215229 Screenshot 2025-04-04 215515

08/19/2024: Major User Settings Enhancement: Per-Server Settings!

There is now an option to enable "Per-Server" settings:

  • Settings for new servers will be initialized as a copy of the "main" settings
  • All settings are managed separately (EXCLUDING config.yaml)
  • There are sub-options for "per-character settings" and "per-server ImdModels"
  • Note that basesettings.yaml applies to ALL settings.

08/12/2024: New /prompt command! Enhanced Post Active Settings feature!

There is now a /prompt command to add some advanced options to your message request.

Also, the Post Active Settings feature received a nice overhaul and is definitely worth trying out!

Requires using yet another new command, /set_server_settings_channel, in each server that you would like to share settings in.

This feature will automatically post a copy of your settings to the channel (EXCLUDING config.yaml)

Screenshot 2024-08-12 221633

08/02/2024: New Behavior - Streaming Responses!

  • Base Behavior / Character Behavior now have option to stream responses!

  • You no longer have to wait for the entire message to generate!

  • Actually works with all the other crazy features!


07/24/2024: New Behaviors to bring your characters to life!

Some new settings appeared recently... which were slightly buggy. Today, I announce that they are working very well!

These new behaviors can make your character more humanistic (or just be like a computer program, by default)

- Character can go idle, taking more time to respond
- Pause to "read messages" before writing
- Simulate typing at different speeds (does not actually generate text slower)
- *DOES NOT* throttle the bot's performance! All tasks running full speed on the backend!
- These behaviors will continue to improve in the coming days/weeks

351922166-c98883f4-143e-40af-b641-544d23c7452e


07/02/2024: New Behaviors "Spontaneous Messaging"

- Character can now be silently prompted to say something after inactivity
- A few settings control the behavior
- It can also serve as an "Auto-prompter" generating unlimited responses

06/18/2024: Per-Server Voice Channels (TTS)

- New command to set voice channels: /set_server_voice_channel
- The context menu commands (regen / continue / edit history) vastly improved
- The bot now reacts to messages to identify their status (hidden, etc)

06/14/2024: Direct Messages Support. Image model changes.

- The bot now supports Direct Messages, which have their own history!
- Most commands are disabled in DMs.
- Direct messaging can be disabled via config.yaml
- Img model "override settings" (checkpoint, vae, clip skip) are no longer saved.

06/11/2024: More Context Menu Commands!

Screenshot 2024-06-11 155926

06/06/2024: Context commands are now AMAZING

- "Continue" and "Regen" have been revised to work AMAZINGLY well!
- New "Edit History" command has been added, that also works AMAZINGLY well!
- You'll have to try these for yourself to see just how perfect they work.

Right click any message to invoke these context commands

Screenshot 2024-06-06 155152

06/04/2024: Launchers! Updaters! New History Manager!

Shoutout to @Artificiangel who coded an amazing new History Manager. Great new features are coming!

- We now have launcher and updater scripts (...look familiar?)
- New CMD_FLAGS.txt to add your custom launch flags (...look familiar?)
- bot.py no longer has to be moved! Correct location is now in main 'ad_discordbot' folder
- New history manager is much more flexible and unlocks new possibilities

05/28/2024: Per-Channel History!

- New setting 'per_channel_history' enables all channels to have their own chat history.
- Custom logging format puts chat history, server name, and channel name under each channel.id key.
- A utility .bat file is now included to split these custom logs into normal logs, if needed.
- New '/announce/ command allows channels to be assigned as Announcement channels.
  Announcement channels will receive Model / Character change announcements
  instead of interaction channels.

05/22/2024: Big Update - Easier to Update Moving Forward

Quick shoutout to @Artificiangel who has recently joined development and made stunning contributions.

- The directory '/internal/' which contains persistent settings (not intended to be modified by users)
  is no longer part of the bot package.  Instead, '/internal/' and its contents are created dynamically if missing.
- User settings are now present in a '/settings_templates/' which will be automatically copied into the root directory,
  if not done manually by users.  This allows the bot to be easily updated without conflicts due to modified files.

05/16/2024: Significant Changes to File Structure

- The main bot script has grown massive, so it is now split to modules (new '/modules/' subdirectory)
- activesettings.yaml is now in an '/internal/' subdirectory. Your settings will migrate automatically.
- 'bot.db' has been superceded by a 'database.yaml' file. Your settings will migrate automatically.
- Note: Changes to 'dict_base_settings.yaml' and 'activesettings.yaml' are just comment updates

04/29/2024: Huge Improvement to ControlNet in /image Command

- Options are now dynamically filtered and populated using the '/controlnet/control_type' API endpoint
- Sets almost identical default options as in SD WebUI interface
- This took a lot of time and effort, please try it out!
Screenshot 2024-04-29 145440

04/21/2024: Revamped Main Config. Made textgenwebui and SD WebUI Optional!

- replaced config.py with config.yaml
- Config.py will still work, but is now unsupported and will receive no updates.
- Textgenwebui and SD WebUI are now optional elements of the bot that can be disabled in config.yaml

04/19/2024: Overhauled Img Model handling. Now "API" Method only.

At first, there was only the '.YAML method' - each model required its own definition.

Later, fetching models via API became a secondary option.

Now, I noticed that all the improvements to API method have made the 'YAML method' obsolete:

- Filter / Exclusion settings to control models that get loaded
- Sophisticated calculations for 'Sizes' menu in '/image' command
- Apply model settings and 'Tags' based on intelligent filter matching
- Now, additional check for 'exact_match' if necessary.

Please take care migrating to this change:

- Fetch the new version of 'dict_imgmodels.yaml' which is now the settings panel for the API method.
- Migrate your 'imgmodel' settings from config.yaml
- Delete the whole 'imgmodels' block in config.yaml!

04/18/2024: New Feature: Dynamic Prompting.

Works exactly very similarly to the SD WebUI extension sd-dynamic-prompts

Read up on it here!

Screenshot 2024-04-20 202457

04/16/2024: Enhanced Flows and "Instant Tags". Many other improvements.

- Changed the 'Logging Level' from DEBUG to INFO - LESS SPAM!
- Performance may be more optimized... all settings were being stored in the discord client object.
  Now, they are stored in a dedicated class object.
- Characters can now be omitted from /character command with new parameter (see M1nty example char)
- The feature to create tags instantly from your text has been upgraded.
  ANY tag values can be created including dictionaries, lists, sublists... anything.
- The SD API "Guess imgmodel params" feature has much better success rate now.
- "Flows" feature can now use variables for tag values.
- Added a new "Flows" example in 'dict_tags.yaml'
- Added new forge-couple param.
- Better error handling when failure to change Img model
- Fixed img prompt insertions from Tags sometimes creating a line break.
Screenshot_2024-04-16_144136

04/12/2024: Changed user images dir. New Tags. Enhanced Image Selection.

 - All images now go into a root 'user_images' folder.
   There are no longer separate root folders for ReActor, ControlNet, Img2Img, Inpainting masks, etc.
   Users can organize their images in 'user_images' however they wish - just include path in Tags values.

 - New tags:
   - 'img2img'. Previous commit added img2img to /images cmd - now, it's also a Tag.
   - 'img2img_mask' (inpainting)...  and now also added to /image command!
   - 'send_user_image' - can send a local, non-AI generated image! Can be triggered to send an image after LLM Gen and/or after Img Gen.

- Enhanced image selection:
  When processing images from tags (ReActor, ControlNet, etc etc), if the value is a directory (does not include .jpg/.png/.txt),
  the function will recursively attempt to select a random image - if no images are in the directory, it will try picking a random directory, and so on,
  until an image is found or reaches an empty directory (error).  So rather than just picking a random image from a folder, it can now pick from a random folder.
example

04/10/2024: Upgraded '/image' cmd. Added Tags. Added sd-forge-couple extension support.

- Upgraded the /image command:

  - ControlNet and ReActor now only appear in the select options if enabled in config.yaml
  - 'img2img' has been added. If an image is attached, it will prompt for the Denoise Strength.
  - ControlNet now follows up asking for model/map if an image is attached, to simplify the main menu.

- Added 'sd_output_dir' tag, so now you can control the image save location in your tag definitions.

- Added extension support for SD Forge Couple.  Currently only useful for '/image' command unless you can get the LLM to reply with the correct format (I'm working on that!)
Screenshot_2024-04-10_140521

04/01/2024: Pretty massive update. Be sure to update textgen-webui, and take care updating settings files.

- Overhauled SD WebUI extension support (ControlNet, layerdiffuse, ReActor) to be much more powerful and manageable.

  - ControlNet support received a massive update in particular... multi-ControlNet is even supported!
  - These extensions each have a simple primary Tag to activate and apply.
  - **ALL** of their parameters are now easily controlled by the Tags system.

- Added a new method to create Tags on-the-fly using this syntax: [[key:value]] or [[key1:value1 | key2:value2]]. These go into immediate effect, particularly useful for controlling the extension settings.

- 4 older parameters were recently removed from textgen-webui - mirrored in this bot update.

03/07/2024: layerdiffuse support added to Tags feature!

Screenshot 2024-03-07 104132

02/13/2024: Major update introducing the Tags feature. Take care migrating your existing settings

Screenshot 2024-03-07 104231

12/11/2023: New "/speak" command! Silero and ElevenLabs TTS extensions now supported!

Screenshot 2024-03-07 104326

12/8/2023: TTS Support, and Character Specific Extension Settings now added!

Screenshot 2024-03-07 104503

Features:

  • Chat History for each channel!

    • Each channel has its chat history maintained seperately and cleanly.
    • History is gracefully loaded for all channels on startup.
    • /reset_conversation will reset history in interaction channel only.
  • Robust "Tags" system to manipulate bot behavior persistently or via trigger phrases, including:

    • Trigger Text and/or Image response
    • Image censoring settings (None / Spoiler / Block)
    • Powerful ControlNet, ReActor, Forge Couple, and layerdiffuse integration
    • Automatically apply loractl scaling (Currently ReForge/A1111 only)
    • Swapping / Changing LLM characters (ei: "draw... " can trigger character tailored for image prompting)
    • Swapping / Changing LLM models and Img models
    • Modifying LLM state (temperature, repetition penalty, etc) and image gen settings (width, height, cfg scale, etc)
    • Keep things spicy by factoring random variations to LLM state / img gen settings
    • Modifying the user's prompt and LLM's reply with delete/insert/replace text, img LORAs, etc
    • Manipulate LLM history (Suppress history, limit history, save or do-no-save reply, etc)
    • New Feature: Flexible, Instant-Tags by using syntax [[key:value]] or [[key1:value1 | key2:value2 ]]
    • New features being added frequently and easily due to the framework of the "Tags" system
  • TTS Support!

    • alltalk_tts, coqui_tts, silero_tts, edge_tts and elevenlabs_tts
    • Bot can speak on Voice channel, upload copy of audio file, or both!
    • Per-character TTS settings! Give each character a unique voice!
  • Sophisticated function to send text responses over Discord's 2,000 character limit

    • "chunks" messages by looking back to nearest line break or sentence completion.
    • Preserves syntax between chunks such as bold, italic, and even code formatting
  • Commands!

    • /character - Change character
    • /reset_conversation - Starts a new conversation in the current channel.
    • /image - Allows more controlled image prompting (positive prompt, neg prompt, Size settings, ControlNet, ReActor)
    • /speak - Bot can speak any text, using any voices (including user attach .mp3 or .wav for alltalk_tts)!
    • /imgmodel - Change image model along with any custom settings for it
    • /llmmodel - Change LLM model
    • /set_X_for_server - A number of commands to assign a specific channel in your servers (Voice channel for TTS, Announcement channel, Settings channel, Starboard channel, etc).
    • Plus many more!
  • Dynamic settings handling:

    • Core bot settings managed in config.yaml (bot behavior, discord features, extensions, etc.)
    • The "Tags" system is configured in dict_tags.yaml (global Tags, default Tag params, Tag presets, etc.)
    • Foundational layer of user settings configured in base_settings.yaml.
    • Character files can include custom Tags, TTS settings, LLM state parameters, and special behaviors, which prioritize over basesettings.
    • Custom Image models settings defined in dict_imgmodels.yaml (Tags, payload params) which prioritize over basesettings.
    • All user settings commit to internal/activesettings.yaml, which serves as a dashboard to view the bot's current state.
  • Automatic Img model changing:

    • Adjustable duration and mode (random / cycle)
    • Smart filters and settings to auto-update relavent settings (SD1.5, SDXL, Turbo, etc)
  • Powerful Context Menu commands (right-click on a message):

    338729061-92d1ef4f-56c2-46aa-be9e-5ce69284900e
    • Can target any message in chat history (not only the most recent one!), making Continue & Regenerate more powerful than native TGWUI.
    • Custom Regenerate methods:
      • regenerate replace works as everyone is familiar with (generates a new reply and replaces the original).
      • regenerate create makes a new generation while "hiding" the previous response. These can be easily toggled with toggle as hidden command, so you can choose your favorite reply!
    • edit history allows you to edit any message in history
    • toggle as hidden will hide or reveal the user/bot reply exchange in history.
    • The above are restricted to your own / the bot's messages (can't target other users' messages).
  • All tasks queue up and process elagently - go ahead, spam it with requests!

  • Built in Starboard feature

  • Feature to post current settings in a dedicated channel

  • ALWAYS MORE TO COME


Screenshot 2023-09-22 220802

Installation

  1. OPTIONAL FOR TGWUI INTEGRATION: Install oobabooga's text-generation-webui

  2. Create a Discord bot account, invite it to your server, and note its authentication token.

    !!! IMPORTANT: You must allow your bot to have "Privileged Intents" for "MESSAGE_CONTENT" !!!

    !!! Enabling Privileged Intents !!!

  3. Clone this repository anywhere.

    FOR TGWUI INTEGRATION: clone into /text-generation-webui/

    git clone https://github.com/altoiddealer/ad_discordbot
    
  4. Run the launcher for your OS (ex: start_windows.bat)

  5. Enter your bot token (from Step 2) into the CMD window

    Screenshot 2024-05-25 100216
  6. The bot should now be up and running!

    If a Welcome message does not appear in your main channel, you can use /helpmenu to see it.

    A number of user settings files will appear (copied in from /user_settings/) where you can customize the bot.

    config.yaml , dict_base_settings.yaml , dict_cmdoptions.yaml , dict_imgmodels.yaml , dict_tags.yaml


Running the bot

  1. Run the launcher for your OS (ex: start_windows.bat)
  • Optionally add launch flags to CMD_FLAGS.txt

EXAMPLE CMD Flags:

 --loader exllama --model airoboros-l2-13b-gpt4-2.0-GPTQ
  1. In Discord UI, use command /character to choose a character.

Usage:

Getting responses from the bot:

  • @ mention the bot

  • Use command /main to set a main channel. The bot won't need to be @ mentioned in main channels.

  • If you enclose your text in parenthesis (like this), the bot will not respond.

Getting image responses from the bot

(A1111 or sd-webui-forge must be running!)

  • By default, starting your request with "draw " or "generate " will trigger an image response via the Tags system (see dict_tags.yaml)

  • Use /image command to use your own prompt with advanced options

Getting TTS responses from the bot (Tested: alltalk_tts, coqui_tts, silero_tts, elevenlabs_tts)

  1. Install your TTS extension.

    Follow the specific instructions for your TTS extension!!

    Example instructions for coqui_tts:

    Run the .cmd file in text-generation-webui directory (ex: cmd_windows.bat), and performing the following commands:

    Linux / Mac:

    pip install -r extensions/coqui_tts/requirements.txt
    

    Windows:

    pip install -r extensions\coqui_tts\requirements.txt
    
  2. Ensure that your bot has sufficient permissions to access the Voice channel and/or upload files (From your bot invite/Discord Developer portal, and your Discord server/channel settings)

  3. Configure config.yaml in the section discord > tts_settings

  4. If necessary, model file(s) should download on first launch of the bot. If not, then first launch textgen-webui normally and enable the extension.

  5. Your characters can have their own settings including voices! See example character M1nty for usage


Updating

  1. Run the update-wizard for your OS (ex: update_wizard_windows.bat)
Screenshot 2025-04-04 215515

About

Discord bot which transforms your servers into hubs for limitless local AI-driven interaction and content creation. Features cutting-edge tools for professionals, and unlocks creative fun for casual users. Integrates text-generation-webui and Stable Diffusion Web UIs.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 96.0%
  • Shell 2.6%
  • Batchfile 1.4%