A modern, powerful, and type-safe Discord API wrapper for Python
Project description
Auric
A modern, fully type-safe Discord API wrapper for Python 3.11+
Auric is an asynchronous Python library for Discord bot development. It combines modern Python features with a clean, intuitive API to make bot creation straightforward and maintainable.
Key characteristics:
- Full type hints with mypy strict mode support
- Async/await architecture using aiohttp
- Comprehensive Discord API v10 coverage
- Built-in collectors, builders, and utilities
- Plugin system for modular bot organization
Features
Core Functionality
- Application commands (slash, user, message context menus)
- Message components (buttons, select menus, modals)
- Voice connections and audio streaming
- Thread and forum channel support
- Auto-moderation rules and filters
- Scheduled events and stage instances
- Guild templates and discovery
- Application subscriptions and monetization
Developer Tools
- Fluent builder pattern for embeds, commands, and components
- Message and component collectors with timeout handling
- Plugin architecture for code organization
- Intelligent caching with configurable strategies
- Automatic sharding for large bots
- Comprehensive error handling and rate limit management
Performance
- Optional orjson for faster JSON parsing
- aiodns for improved DNS resolution
- Connection pooling and request batching
- Memory-efficient caching system
Installation
Install from PyPI:
pip install auric
With optional dependencies:
# Voice support (PyNaCl)
pip install auric[voice]
# Performance optimizations (orjson, aiodns)
pip install auric[speed]
# All optional dependencies
pip install auric[voice,speed]
Development version:
pip install git+https://github.com/Auric-Team/auric.git
Requirements: Python 3.11 or higher
Quick Start
Basic Bot
import auric
client = auric.Client(intents=auric.Intents.default())
@client.event
async def on_ready():
print(f"Logged in as {client.user.username}")
@client.event
async def on_message(message):
if message.author.bot:
return
if message.content == "!ping":
await message.reply("Pong!")
client.run("YOUR_BOT_TOKEN")
Slash Commands
import auric
from auric.builders import EmbedBuilder
client = auric.Client(intents=auric.Intents.default())
@client.slash_command(name="greet", description="Greet a user")
async def greet(interaction: auric.Interaction, username: str):
embed = (
EmbedBuilder()
.set_title(f"Hello, {username}!")
.set_color(0x5865F2)
.build()
)
await interaction.reply(embed=embed)
client.run("YOUR_BOT_TOKEN")
Interactive Components
from auric.builders import ButtonBuilder, ActionRowBuilder
@client.slash_command(name="vote", description="Create a poll")
async def vote(interaction: auric.Interaction):
yes_btn = ButtonBuilder().set_label("Yes").set_custom_id("vote_yes").build()
no_btn = ButtonBuilder().set_label("No").set_custom_id("vote_no").build()
row = ActionRowBuilder().add_component(yes_btn).add_component(no_btn).build()
await interaction.reply("Vote now:", components=[row])
@client.event
async def on_interaction(interaction):
if interaction.type == auric.InteractionType.COMPONENT:
if interaction.data.custom_id.startswith("vote_"):
choice = interaction.data.custom_id.split("_")[1]
await interaction.reply(f"You voted: {choice}", ephemeral=True)
Advanced Usage
Using Collectors
from auric.collectors import MessageCollector
@client.slash_command(name="quiz", description="Start a quiz")
async def quiz(interaction: auric.Interaction):
await interaction.reply("What is 2 + 2? (You have 30 seconds)")
collector = MessageCollector(
client,
channel=interaction.channel,
filter=lambda m: m.author == interaction.user,
max_messages=1,
timeout=30.0
)
async for message in collector:
if message.content == "4":
await message.reply("Correct!")
else:
await message.reply("Wrong answer!")
Plugin System
from auric.plugins import Plugin
class ModerationPlugin(Plugin):
def __init__(self, client):
super().__init__(client)
@Plugin.listener()
async def on_message(self, message):
if self.check_spam(message):
await message.delete()
await message.channel.send(f"{message.author.mention}, please don't spam!")
def check_spam(self, message):
# Your spam detection logic
return False
# Load the plugin
client.load_plugin(ModerationPlugin)
Auto-Sharding
from auric.core import AutoShardedClient
client = AutoShardedClient(intents=auric.Intents.default())
@client.event
async def on_ready():
print(f"Bot ready with {client.shard_count} shards")
for shard_id, shard in client.shards.items():
print(f"Shard {shard_id}: {len(shard.guilds)} guilds")
Documentation
The library is fully type-hinted and includes comprehensive docstrings. Use your IDE's autocomplete or Python's built-in help:
help(auric.Client)
help(auric.EmbedBuilder)
help(auric.Intents)
Full documentation site coming soon.
Contributing
Contributions are welcome. Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes with appropriate tests
- Run linters:
black auricandflake8 auric - Commit:
git commit -m "Description of changes" - Push and create a pull request
See CONTRIBUTING.md for detailed guidelines.
Development Setup
git clone https://github.com/Auric-Team/auric.git
cd auric
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -e ".[dev]"
pytest
Project Status
Auric is in active development (v0.0.2). The API may change between minor versions until v1.0.0.
Current focus:
- Stabilizing core API
- Expanding test coverage
- Documentation improvements
- Performance optimization
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
License
MIT License - see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file auric-0.0.3.tar.gz.
File metadata
- Download URL: auric-0.0.3.tar.gz
- Upload date:
- Size: 235.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cff2c1a6f5c585434d5afc8452fa0eafb822de937516ba57c95af1ef77eb130c
|
|
| MD5 |
62f237a700b5b768f95b2dc7e2b3ee35
|
|
| BLAKE2b-256 |
19b4eb4133b1bde60567b7de1d02c2c9ede7eb33fe6d9e836f5df184664ec581
|
File details
Details for the file auric-0.0.3-py3-none-any.whl.
File metadata
- Download URL: auric-0.0.3-py3-none-any.whl
- Upload date:
- Size: 299.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69a9f636896899f530db48a53b500dd0631426861ad5fa6fb3110146fe7127f4
|
|
| MD5 |
02c8523e1f297cb1c5545f57b3876ef7
|
|
| BLAKE2b-256 |
e5363dff23c2cc07920111d52f35ad51023cba22822b2e12b8445ce759b8d99a
|