PollBot is a feature-rich, image-generating Discord polling bot built with TypeScript, Discord.js, and Playwright. It moves beyond simple text embeds to create beautiful, shareable images for your polls, complete with live statistics, internationalization support, and robust management tools.
- 🎨 Image-Based Polls: Renders high-quality images for every poll, displaying options, descriptions, and creators in a clean, professional format.
- 🔢 Flexible Voting:
- Single & Multi-Select: Configure minimum and maximum votes per user (
min_votes,max_votes). - 🔒 Role Restrictions: Limit voting to specific roles (e.g.,
@Membersonly). - ⚖️ Weighted Voting: Assign voting power to roles (e.g.,
@Adminvotes count as 5). - Dynamic Updates: Images and vote counts update in real-time.
- Single & Multi-Select: Configure minimum and maximum votes per user (
- 🌍 Internationalization (i18n): Fully localized UI and messages. Supports multiple languages (configurable per server).
- 🛠️ Advanced Management:
- Slash Commands:
/poll,/close,/reopen,/config. - Interactive Components: Options to add "Close Poll" buttons directly to the poll message.
- Thread Integration: Automatically create a thread for discussion when a poll is created.
- Slash Commands:
- 📊 Visual Statistics: View system performance and usage metrics with the
/statscommand. - 💾 Persistence: Powered by Supabase for reliable data storage and state management.
PollBot generates a card for your poll, handling mentions, emojis, and long text gracefully.
/poll title: Which feature did you like more? items: Feature 1, Feature 2, Feature 3 max_votes: 2
Example: A multi-select poll asking for feedback, rendered as an image.
Monitor your bot's health with a generated dashboard image.
Example: The /stats command output showing server count, uptime, and resource usage.
- Node.js (v18 or higher)
- Supabase Project (PostgreSQL database)
- Discord Bot Token & Client ID
-
Clone the repository
git clone https://github.com/yourusername/pollbot.git cd pollbot -
Install Dependencies This project uses
playwrightfor rendering, so we need to install browser binaries as well.npm install # The postinstall script should run automatically, but if not: npx playwright install chromium --with-deps -
Configuration Copy the example environment file and fill in your credentials.
cp .env.example .env
.envvariables:DISCORD_TOKEN: Your bot token.DISCORD_CLIENT_ID: Application ID.SUPABASE_URL: Your Supabase project URL.SUPABASE_KEY: Your Supabase service_role or anon key (ensure row level security is configured if using anon, otherwise service_role for backend).DEV_ONLY_MODE:trueorfalse(limits commands to a specific guild for testing).DEV_GUILD_ID: ID of the testing guild (required if DEV_ONLY_MODE is true).
-
Database Setup Execute the
schema.sqlfile in your Supabase SQL editor to create the necessary tables (polls,guild_settings,global_stats, etc.). -
Deploy Commands Register the slash commands with Discord.
npm run deploy
-
Start the Bot
# Development npm run dev # Production npm run build npm start
| Command | Description | Options |
|---|---|---|
/poll |
Create a new poll | title, items, description, max_votes, min_votes, public, thread, allowed_role, close_button |
/stats |
View bot statistics | None |
/config |
Manage server settings | poll-buttons, locale, weights (set/remove/view/clear) |
/close |
Close an active poll | id (Message ID of the poll) |
/reopen |
Reopen a closed poll | id (Message ID of the poll) |
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
title |
String | Yes | - | The main title of your poll text (max 256 chars). |
items |
String | Yes | - | A comma-separated list of voting options (e.g., "Yes, No, Maybe"). Max 25 items. |
max_votes |
Integer | No | 1 |
The maximum number of choices a user can select (e.g., 2 for "Pick 2"). |
min_votes |
Integer | No | 1 |
The minimum number of choices a user must select. |
description |
String | No | - | Additional context or details. |
public |
Boolean | No | True |
If False, vote counts are hidden from the results image until the poll is closed. |
thread |
Boolean | No | False |
If True, automatically starts a Discord thread. |
allowed_role |
Role | No | - | Only users with this role can vote. |
close_button |
Boolean | No | True* |
If True, adds a "Close Poll" button. Subject to server-wide /config settings. |
- Mentions: You can mention users
@useror roles@rolein the description and they will be properly rendered in the image. - Customization: Use
/config locale lang:esto switch the bot's language to Spanish (or other supported languages) for your server. - Management: If you accidentally close a poll, use
/reopenwith the message ID to resume voting.
This project is licensed under the MIT License.

