Skip to content

walterwhite-69/Discord-C.AI-Wrapper

Repository files navigation

Character.AI

C.AI Wrapper for Discord

Bring any Character.AI persona to life inside Discord — as a real webhook with its name, avatar, and personality.

Python discord.py curl_cffi License



✨ Features

🪝 Webhook Personas Characters spawn as real Discord webhooks — correct name, avatar, everything.
🔍 Interactive Search Paginated search UI with image cards directly inside Discord.
🎛️ Follow Modes Auto (every message) or Reply-only (only when users reply to bot messages).
🔄 Regeneration Re-roll any tracked bot reply with /regenerate.
💾 Persistent Sessions Logins and active characters survive bot restarts via session_store.json.
📡 Streaming Replies Partial message edits show the character "typing" in real time.

🤖 Commands

Command Description
/login <email> Link your Character.AI account via magic-link email auth
/logout Remove your saved session
/search <query> Search characters, browse results, pick one, choose channel & follow mode
/spawn <char_id> Spawn a character by ID into the current channel
/chat <message> Send a message directly to the active character
/regenerate [message_id] Regenerate the latest tracked reply, or a specific one by message ID
/despawn Remove the active character webhook from this channel
/delete Alias for /despawn

🚀 Setup

1. Install dependencies

pip install -r requirements.txt

2. Create your environment file

cp .env.example .env

3. Add your Discord bot token

DISCORD_TOKEN=your_discord_bot_token_here

4. Run the bot

python bot.py

🔐 Discord Bot Requirements

Enable in the Developer Portal:

  • Message Content Intent

Invite scopes:

  • bot · applications.commands

Required permissions:

  • Send Messages · Manage Webhooks · Read Message History

🔄 How Regeneration Works

The bot tracks a message_id → turn_id mapping for every webhook reply it sends.

  • /regenerate — targets the most recent tracked reply in the channel
  • /regenerate message_id:<id> — targets a specific tracked webhook reply by Discord message ID

📁 Project Structure

CharacterAI-Discord-Bot/
├── bot.py               # Discord slash commands & event loop
├── cai_client.py        # Character.AI WebSocket client
├── login.py             # Android mobile auth flow
├── recaptcha.py         # reCAPTCHA Enterprise solver
├── session_manager.py   # Persistent session & channel state
├── webhook_manager.py   # Webhook creation, sending, streaming
├── config.py            # Environment variable loader
├── requirements.txt
├── .env.example
└── session_store.json   # Auto-generated runtime state

🛡️ Security

Caution

session_store.json contains user auth tokens. Keep it private and out of version control.

  • Rotate your Discord bot token immediately if it leaks
  • Keep .env in .gitignore (already included)

Built fully alone by Walter using discord.py · curl_cffi · Character.AI

About

Bring any Character.AI persona into Discord as a real webhook — with its name, avatar, and personality. Supports search, follow modes, streaming replies, and regeneration.

Topics

Resources

Contributing

Stars

Watchers

Forks

Contributors

Languages