Skip to content

Add periodic poll feature for icebreaker/dilemma discussions#290

Open
Copilot wants to merge 3 commits intomainfrom
copilot/add-custom-url-poll-feature
Open

Add periodic poll feature for icebreaker/dilemma discussions#290
Copilot wants to merge 3 commits intomainfrom
copilot/add-custom-url-poll-feature

Conversation

Copy link
Contributor

Copilot AI commented Feb 14, 2026

Summary

Adds a feature that periodically posts Discord native polls from URL-based sources (copied to database) with optional role pinging to spark community discussions.

Implementation

Services & Models

  • PollService: Manages cron-scheduled poll posting, fetches content from URLs and stores in DB, creates Discord native polls
  • PollItem Model: Stores individual poll questions with smart rotation logic (cooldown tracking, usage counts)
  • PollSchedule Model: Stores poll schedule configurations (channel, cron, duration, role ping settings)

Command Interface

/poll command with 8 subcommands:

  • create - Configure poll schedule (channel, cron, duration, optional role ping)
  • list - View active schedules
  • delete - Remove schedule
  • test - Post immediate test poll
  • add-item - Add poll to database manually
  • list-items - View stored polls
  • delete-item - Remove a poll question
  • import-url - Import polls from YAML/JSON URL (copies to database)

Poll Sources

URL Import: Fetches YAML/JSON from remote endpoint and copies all polls to database for local management

YAML Format:

polls:
  - question: "Fight 100 duck-sized horses or 1 horse-sized duck?"
    answers: ["100 duck-sized horses", "1 horse-sized duck"]
    multiselect: false
    tags: ["funny", "absurd"]

JSON Format:

{
  "polls": [
    {
      "question": "What's your favorite season?",
      "answers": ["Spring", "Summer", "Fall", "Winter"],
      "multiselect": false,
      "tags": ["general"]
    }
  ]
}

Database Storage: All polls stored in MongoDB with smart rotation that avoids repeats within cooldown period

Configuration

"polls.enabled": boolean
"polls.default_duration_hours": number  // Default: 24
"polls.cooldown_days": number           // Default: 7

Technical Details

  • Uses Discord.js 14.25 native poll API (PollData structure, no PollBuilder or reaction-based workarounds)
  • Follows existing ScheduledAnnouncementService pattern for cron jobs
  • Added js-yaml dependency for YAML parsing support
  • Smart poll rotation: filters by cooldown, prioritizes low usage, randomizes from top 20%, fallback to oldest
  • Comprehensive documentation in COMMANDS.md and SETTINGS.md

Features Included

✅ Cron-based scheduling (e.g., daily at noon)
✅ URL import with YAML/JSON support
✅ Automatic database storage for all polls
✅ Smart rotation avoiding recent repeats
✅ Multi-select poll support
✅ Optional role pinging
✅ Manual poll management
✅ Test mode for immediate posting

Features Excluded

❌ Poll statistics/result tracking (per user request)
❌ Poll result announcements (per user request)

Quality Checks

  • ✅ TypeScript compilation passes
  • ✅ ESLint passes (only pre-existing warnings)
  • ✅ Prettier formatting passes
  • ✅ Markdown linting passes
  • ✅ Build succeeds without errors

Future Work

  • Setup wizard integration for easier initial configuration
  • Unit tests for poll service and commands
Original prompt

I would like a feature that allows a custom url to be used as the basis for the bot to periodically host a poll for absurd/funny/icebreaker moments. In other words server owner should point to a url to a text file that contains a formatted (markdown/yml ) file with dilemmas then the discord bot creates the poll in discord and (optionally pings a configured role) to spark a discussion. The source could also be locally stored in the db I guess. Create a clear plan on what to do and get users explicit approval prior to and implementation. (Also ensure we can actually do it)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@lonix lonix added enhancement New feature or request minor labels Feb 14, 2026
Copilot AI changed the title [WIP] Add custom URL option for hosting polls Add periodic poll feature for icebreaker/dilemma discussions Feb 14, 2026
Copilot AI requested a review from lonix February 14, 2026 19:49
@lonix lonix marked this pull request as ready for review February 14, 2026 19:53
@lonix
Copy link
Owner

lonix commented Feb 14, 2026

@copilot 1. /poll is fine. 2. copy to db perhaps ? 3. yaml is fine 4. yes 5. I don't see any value in that

Copilot AI and others added 2 commits February 14, 2026 20:33
- Install js-yaml for YAML parsing support
- Create PollItem model for storing poll questions
- Create PollSchedule model for poll scheduling
- Implement PollService with cron-based scheduling
- Add /poll command with 8 subcommands (create, list, delete, test, add-item, list-items, delete-item, import-url)
- URL import with YAML/JSON support
- Smart poll rotation with cooldown tracking
- Integration with Discord native poll API
- Register poll command in CommandManager
- Add poll configuration schema entries
- Initialize poll service in main index

Co-authored-by: lonix <2330355+lonix@users.noreply.github.com>
- Add /poll command documentation to COMMANDS.md with examples
- Add poll configuration settings to SETTINGS.md
- Include YAML/JSON format examples
- Document all 8 subcommands
- Explain smart poll rotation logic
- Add use cases and tips

Co-authored-by: lonix <2330355+lonix@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 14, 2026

@copilot 1. /poll is fine. 2. copy to db perhaps ? 3. yaml is fine 4. yes 5. I don't see any value in that

Implementation complete! (commit cd7f419)

✅ Command name: /poll
✅ URL import: Copies to database for local management
✅ YAML support: Installed js-yaml for parsing
✅ Setup wizard: Will be added in next phase
✅ Poll statistics: Not included as requested

The feature is ready with:

  • 8 subcommands (create, list, delete, test, add-item, list-items, delete-item, import-url)
  • Smart poll rotation with cooldown tracking
  • Discord native poll support
  • YAML/JSON URL import with automatic database storage
  • Comprehensive documentation in COMMANDS.md and SETTINGS.md

Next steps: Add setup wizard integration and write tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants