Async Python wrapper for Discord's native polling API.
Project description
Pollcord
Pollcord is a lightweight asynchronous Python wrapper for Discord’s poll API.
It handles poll creation, fetching, and expiration — while giving you a clean, extensible framework for running polls in bots or automation scripts.
Features
- Async-first design – fully
async/awaitcompatible - Modular structure – clean separation of client, models, and errors
- Context-managed sessions – automatic setup/teardown
- Built-in rate limiting
- Meaningful error hierarchy
- Retries on transient failures (planned)
- Extensible – easy to plug into your existing bot framework
Installation
NOTE: Not yet on PyPi, this is for post-release
pip install pollcord
Or if you’re testing locally / from source (should work right now):
git clone https://github.com/<yourname>/pollcord.git
cd pollcord
pip install -e .
Quickstart
Here’s a minimal example showing how to create and end a poll.
import asyncio
from pollcord import PollClient
TOKEN = "your_bot_token_here"
async def main():
async with PollClient(TOKEN) as client:
# Create a poll
poll = await client.create_poll(
channel_id=123456789012345678,
question="What should we build next?",
options=["Mega base", "PvP arena", "Mob farm"]
)
print(f"Created poll: {poll.message_id}")
# Fetch results
votes = await client.get_vote_counts(poll)
print("Current votes:", votes)
# End the poll manually
await poll.end(client)
print("Poll ended!")
asyncio.run(main())
Architecture Overview
Pollcord is built around three core layers:
| Layer | Description |
|---|---|
| PollClient | The main entry point — handles auth, rate limiting, and session context |
| Poll | A high-level model representing a poll, with helper methods for interacting with it |
| errors | Custom exceptions with Discord response context for debugging |
Testing
Tests are written with pytest and use async mocks for API responses. Run them with:
pytest -v
Covered:
- Poll creation
- Fetching poll data
- Ending polls
- Error handling
Example Scripts
NOTE: This section isn't actually implemented yet.
See the examples/ directory for working demos:
basic.py— Basic poll creation, termination, and vote fetchingconcurrency.py— Demonstration of concurrent poll handlingrate_limit.py— Demonstrates rate limit handlinglifecycle.py— Poll creation and periodic fetching of data
Logging
Pollcord uses Python’s built-in logging module.
You can enable debug output to trace requests:
import logging
logging.basicConfig(level=logging.DEBUG)
Roadmap
- Documentation that doesn’t completely suck 😅
- Request queuing
Contributing
Contributions are welcome! If you’d like to help with tests, documentation, or feature ideas:
- Fork the repo
- Create a feature branch (
git checkout -b feature/my-improvement) - Submit a PR with clear commit messages
Support
- Discord Server: https://discord.gg/gkc7dSS8Ef
- Myst1cS04p's discord:
@myst1cso4p - ChatGPT or smth idk
License
MIT License © 2025 [Myst1cS04p]
This project is unaffiliated with Discord Inc.
Credits
Inspired by real bot-development pain.
Developed by Myst1cS04p
Development assistance by Github Copilot
README, examples, and tests written by ChatGPT cuz I'm lazy
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 pollcord-0.1b1.tar.gz.
File metadata
- Download URL: pollcord-0.1b1.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3feb693d60e642b21422d6c94533667960bc9d87f1538842279b161ff093849e
|
|
| MD5 |
acdc33db83f6095115053bf0f3f277b8
|
|
| BLAKE2b-256 |
0924e1f0efe222862f66b73da1358cd8382846777f621ec055a79825e8caf6d9
|
File details
Details for the file pollcord-0.1b1-py3-none-any.whl.
File metadata
- Download URL: pollcord-0.1b1-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df3117b49357bb488e1f561fa211c100eb5a4041c2146c9be25282d079bf3340
|
|
| MD5 |
88986f1b7eed1e9434ffcb4facfc796d
|
|
| BLAKE2b-256 |
0222dcc12ee279217869c19edcdec27d9c4d2881a8e2b931bff6aa0d6add79c9
|