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.
- 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
pip install pollcordOr if you’re testing locally / from source (should work right now):
git clone https://github.com/<yourname>/pollcord.git
cd pollcord
pip install -e .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())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 |
Tests are written with pytest and use async mocks for API responses. Run them with:
pytest -vCovered:
- Poll creation
- Fetching poll data
- Ending polls
- Error handling
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
Pollcord uses Python’s built-in logging module.
You can enable debug output to trace requests:
import logging
logging.basicConfig(level=logging.DEBUG)- Documentation that doesn’t completely suck 😅
- Request queuing
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
- Discord Server: https://discord.gg/gkc7dSS8Ef
- Myst1cS04p's discord:
@myst1cso4p - ChatGPT or smth idk
MIT License © 2025 [Myst1cS04p]
This project is unaffiliated with Discord Inc.
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