Observed since 20 Oct, 18:02 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
AI-powered Discord bot package integrating AccuralAI orchestration.
High-level abstraction for building AI-powered Discord bots with minimal boilerplate, integrating seamlessly with AccuralAI orchestration.
from accuralai_discord import DiscordBot
# Minimal example (10 lines)
bot = DiscordBot(
token="DISCORD_BOT_TOKEN",
personality="friendly assistant",
accuralai_config_path="config.toml"
)
bot.run()
Use the included test bot for quick testing:
Linux/Mac:
export DISCORD_BOT_TOKEN="your_bot_token_here"
python -m accuralai_discord.test_bot
Windows CMD:
set DISCORD_BOT_TOKEN=your_bot_token_here
set ACCURALAI_CONFIG_PATH=C:\path\to\config.toml
python -m accuralai_discord.test_bot
Windows PowerShell:
$env:DISCORD_BOT_TOKEN="your_bot_token_here"
$env:ACCURALAI_CONFIG_PATH="C:\path\to\config.toml"
python -m accuralai_discord.test_bot
Relative path (relative to current directory):
export DISCORD_BOT_TOKEN="your_token"
export ACCURALAI_CONFIG_PATH="config.toml" # or "./config.toml"
python -m accuralai_discord.test_bot
Or use the CLI command:
accuralai-discord-test
The test bot includes:
echo, calculate)/test, /analytics)See TEST_BOT.md for complete documentation and environment variable reference.
pip install accuralai-discord
/help, /reset, /personality, /statusbot = DiscordBot(
token="DISCORD_BOT_TOKEN",
personality="technical expert",
conversation_scope="per-user", # or "per-channel", "per-thread"
accuralai_config_path="accuralai-config.toml"
)
from accuralai_discord import DiscordBot, DiscordBotConfig
config = DiscordBotConfig(
token="DISCORD_BOT_TOKEN",
personality="helpful assistant",
conversation_scope="per-channel",
max_history_entries=50,
max_history_tokens=2000,
rate_limit_per_minute=20,
accuralai_config_path="config.toml",
accuralai_config_overrides={
"backends.ollama.options.model": "llama3"
}
)
bot = DiscordBot(config=config)
bot.run()
@bot.command("/weather", description="Get weather info")
async def weather_command(ctx):
return "It's sunny today!"
# Or register manually
async def custom_handler(ctx):
return f"Hello {ctx.user.name}!"
bot.add_command("/greet", custom_handler, "Greet a user")
Slash commands provide a modern Discord UI with autocomplete and better UX.
import discord
# Register a global slash command
async def ping_handler(interaction: discord.Interaction) -> str:
return "Pong! 🏓"
bot.add_slash_command("ping", "Ping the bot", ping_handler)
# Or use decorator-style
@bot.slash_command("ping", "Ping the bot")
async def ping_slash(interaction: discord.Interaction) -> str:
return "Pong! 🏓"
import discord
# Register a command for a specific guild (server)
async def admin_handler(interaction: discord.Interaction) -> str:
return "Admin command executed!"
GUILD_ID = 123456789012345678 # Your guild ID
bot.add_slash_command(
"admin",
"Admin-only command",
admin_handler,
guild_id=GUILD_ID
)
import discord
@app_commands.describe(user="The user to greet")
async def greet_handler(interaction: discord.Interaction, user: discord.Member) -> str:
return f"Hello {user.mention}!"
bot.add_slash_command("greet", "Greet a user", greet_handler)
Enable slash commands in your config:
from accuralai_discord import DiscordBot, DiscordBotConfig
config = DiscordBotConfig(
token="YOUR_TOKEN",
enable_slash_commands=True, # Enable slash commands
auto_sync_slash_commands=True, # Auto-sync on startup
sync_guild_commands=[123456789012345678], # Sync to specific guilds (optional)
)
bot = DiscordBot(config=config)
Note: Global commands can take up to 1 hour to propagate. Guild commands sync instantly.
@bot.on_message_preprocess
async def preprocess(message, context):
# Modify message before AI processing
return message.content.upper()
@bot.on_message_postprocess
async def postprocess(response, message, context):
# Modify AI response before sending
return f"[BOT] {response}"
orchestrator = bot.get_orchestrator()
# Use orchestrator directly for advanced use cases
Register custom tools that the AI can call during conversations:
bot.add_tool(
name="get_weather",
description="Get weather for a location",
parameters={
"type": "object",
"properties": {
"location": {"type": "string", "description": "City name"}
},
"required": ["location"]
},
handler=async def get_weather(location: str, context: dict):
# Your tool logic
return f"Weather in {location}: Sunny"
)
Handle images and file attachments:
bot = DiscordBot(
token="YOUR_TOKEN",
enable_multimodal=True, # Automatically processes images
accuralai_config_path="config.toml"
)
The bot automatically includes image attachments in AI requests.
Use Discord embeds for formatted responses:
bot = DiscordBot(
token="YOUR_TOKEN",
use_embeds=True, # Use embeds instead of plain text
accuralai_config_path="config.toml"
)
Bot automatically includes Discord context (roles, permissions, channel info):
bot = DiscordBot(
token="YOUR_TOKEN",
context_aware=True, # Include Discord metadata in prompts
accuralai_config_path="config.toml"
)
Track bot usage and performance:
analytics = bot.get_analytics()
summary = analytics.get_summary()
print(f"Total messages: {summary['total_messages']}")
print(f"Cache hit rate: {summary['cache_hit_rate']}")
Enable intelligent conversation history management:
bot = DiscordBot(
token="YOUR_TOKEN",
smart_history=True, # Enable summarization and relevance-based pruning
accuralai_config_path="config.toml"
)
Stream responses with typing indicators (requires backend support):
from accuralai_discord import stream_response
# In your custom handler
async def stream_handler(response_stream):
await stream_response(
channel=message.channel,
response_stream=response_stream,
show_typing=True
)
You can also run the bot from the command line:
accuralai-discord-bot --token YOUR_TOKEN --personality "friendly assistant"
Or with a configuration file:
accuralai-discord-bot --config bot-config.toml
The bot includes built-in error handling for:
Errors are automatically formatted into user-friendly messages.
The bot integrates with AccuralAI's orchestration pipeline:
discord.py[discord]
token = "${DISCORD_BOT_TOKEN}"
personality = "helpful assistant"
conversation_scope = "per-channel"
max_history_entries = 50
rate_limit_per_minute = 20
[discord.accuralai]
config_path = "accuralai-config.toml"
overrides = { "backends.ollama.options.model" = "llama3" }
from accuralai_discord import DiscordBot
bot = DiscordBot(
token="YOUR_TOKEN",
personality="knowledgeable assistant",
accuralai_config_path="config.toml"
)
bot.run()
from accuralai_discord import DiscordBot
bot = DiscordBot(
token="YOUR_TOKEN",
personality="helpful bot",
accuralai_config_path="config.toml"
)
@bot.command("/ping")
async def ping(ctx):
return "Pong!"
@bot.command("/info")
async def info(ctx):
return f"Hello {ctx.user.name}! I'm a helpful bot."
bot.run()
from accuralai_discord import DiscordBot
bot = DiscordBot(
token="YOUR_TOKEN",
personality="friendly assistant",
accuralai_config_path="config.toml"
)
@bot.on_message_preprocess
async def log_messages(message, context):
print(f"User {context['user_id']} said: {message.content}")
return None # Don't modify message
@bot.on_message_postprocess
async def add_prefix(response, message, context):
return f"🤖 {response}"
bot.run()
Run tests with:
pytest tests/
Apache-2.0
See the AccuralAI documentation for more details.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.2.1 | 26 Jan 2026 | 8 |
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 20 Oct, 18:02 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:f8750630bb03b0065facc4bd8a3ba865e8cc717417fd50779ddc38b7941ec90f