# Discord Multi-Agent Kit 🤖

A lightweight Python library for creating multi-agent systems that communicate through Discord webhooks. Perfect for building AI teams, automated workflows, and collaborative bot systems.

Created by **Rika Company** 🎀

## ✨ Features

- **Simple API** - Create team members with just a few lines of code
- **Discord Integration** - Send messages via webhooks with custom avatars and names
- **Team Management** - Organize agents into teams with role-based channels
- **No Dependencies** - Only requires the `requests` library
- **Customizable** - Easy to extend and adapt to your needs
- **Cross-Talk** - Agents can communicate with each other across channels

## 📦 Installation

```bash
pip install requests
```

That's it! Just copy the library into your project.

## 🚀 Quick Start

```python
from rika_team import TeamMember, RikaTeam

# Create a team member
kai = TeamMember(
    name="Kai",
    role="Developer",
    avatar="💻",
    webhook_url="https://discord.com/api/webhooks/YOUR_WEBHOOK_URL"
)

# Send a message
kai.say("Hello! I'm Kai, the developer. Ready to code! 🚀")
```

## 📖 API Reference

### TeamMember

Represents an individual agent in the system.

```python
TeamMember(name, role, avatar, webhook_url)
```

| Parameter | Type | Description |
|-----------|------|-------------|
| `name` | str | Display name of the agent |
| `role` | str | Role/title of the agent |
| `avatar` | str | Emoji or avatar URL |
| `webhook_url` | str | Discord webhook URL |

#### Methods

| Method | Description |
|--------|-------------|
| `say(message)` | Send a message to the configured channel |
| `say_to(webhook_url, message)` | Send a message to a different channel |
| `announce(message)` | Send a formatted announcement |

### RikaTeam

Manages a collection of team members.

```python
RikaTeam()
```

#### Methods

| Method | Description |
|--------|-------------|
| `add_member(member)` | Add a TeamMember to the team |
| `get_member(name)` | Get a member by name |
| `broadcast(message)` | Send message to all members' channels |
| `list_members()` | Return list of all member names |

## ⚙️ Configuration

### Setting Up Discord Webhooks

1. Open your Discord server
2. Go to **Server Settings** → **Integrations** → **Webhooks**
3. Click **New Webhook**
4. Copy the webhook URL

### Organizing Channels by Department

```python
# Define webhooks for different departments
WEBHOOKS = {
    "engineering": "https://discord.com/api/webhooks/...",
    "operations": "https://discord.com/api/webhooks/...",
    "quality": "https://discord.com/api/webhooks/...",
}

# Create department-specific agents
dev = TeamMember("Kai", "Developer", "💻", WEBHOOKS["engineering"])
ops = TeamMember("Hana", "DevOps", "🚀", WEBHOOKS["operations"])
qa = TeamMember("Yuki", "QA Lead", "🔍", WEBHOOKS["quality"])
```

## 💡 Examples

### Basic Team Setup

```python
from rika_team import TeamMember, RikaTeam

# Initialize team
team = RikaTeam()

# Add members
team.add_member(TeamMember(
    name="Rika",
    role="CEO",
    avatar="🎀",
    webhook_url="https://discord.com/api/webhooks/..."
))

team.add_member(TeamMember(
    name="Mika",
    role="CTO",
    avatar="🔧",
    webhook_url="https://discord.com/api/webhooks/..."
))

# Get a member and send message
ceo = team.get_member("Rika")
ceo.say("Good morning team! Let's ship some features today! 🚀")
```

### Cross-Channel Communication

```python
# Kai sends to his own channel
kai.say("Just finished the new feature!")

# Kai also notifies the QA channel
kai.say_to(
    WEBHOOKS["quality"],
    "Hey @Yuki, the feature is ready for testing! 🧪"
)
```

### Team Broadcast

```python
# Send announcement to all channels
team.broadcast("🎉 Version 2.0 has been released!")
```

### Formatted Announcements

```python
kai.announce("""
## 📢 New API Endpoint Available

**Endpoint:** `/api/v2/users`
**Method:** GET, POST
**Auth:** Bearer token required

See docs for details!
""")
```

### Automated Status Updates

```python
import time

def daily_standup():
    members = ["Rika", "Mika", "Kai", "Hana", "Yuki"]
    
    for name in members:
        member = team.get_member(name)
        if member:
            member.say(f"📋 Daily standup check-in from {name}")
        time.sleep(1)  # Respect rate limits
```

## 🔒 Best Practices

1. **Rate Limiting** - Discord has rate limits. Add delays between bulk messages.
2. **Secure Webhooks** - Never commit webhook URLs to public repos. Use environment variables.
3. **Error Handling** - Wrap API calls in try/except blocks.

```python
import os

# Use environment variables for webhooks
webhook = os.getenv("DISCORD_WEBHOOK_ENG")

try:
    kai.say("Deploying to production...")
except Exception as e:
    print(f"Failed to send message: {e}")
```

## 🤝 Contributing

Contributions are welcome! Feel free to:

- Report bugs
- Suggest features
- Submit pull requests

## 📄 License

MIT License

```
MIT License

Copyright (c) 2026 Rika Company

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```

## 🙏 Credits

**Rika Company** 🎀

Built with ❤️ by the Rika Team:
- **Rika** - CEO 🎀
- **Sora** - Project Manager 📋
- **Mika** - CTO 🔧
- **Kai** - Developer 💻
- **Hana** - DevOps 🚀
- **Ryu** - SysAdmin 🖥️
- **Yuki** - QA Lead 🔍

---

*Made for humans and AI agents alike* 🤖✨
