Skip to content

feat: add polls #1691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jun 20, 2024
Merged

feat: add polls #1691

merged 16 commits into from
Jun 20, 2024

Conversation

AstreaTSS
Copy link
Member

@AstreaTSS AstreaTSS commented Jun 7, 2024

Pull Request Type

  • Feature addition
  • Bugfix
  • Documentation update
  • Code refactor
  • Tests improvement
  • CI/CD pipeline enhancement
  • Other: [Replace with a description]

Description

This PR finally adds support for Discord Polls to interactions.py.

Changes

  • Created poll objects.
    • A decent bit of attention went into creating polls. As such, the UX is pretty flexible.
  • Added poll parameter to the various sends.
  • Add poll to Message.
  • Add methods of getting users for answers of polls, and for ending polls.
  • Updated docs.

Related Issues

N/A

Test Scenarios

from interactions import slash_command, SlashContext, Poll, PollMedia

@slash_command()
async def test(ctx: SlashContext):
    # method 1
    poll = Poll.create("Test?", duration=1)
    poll.add_answer("Yes!")
    poll.add_answer("No.")

    # method 2
    poll = Poll.create("Test?", duration=1).add_answer("Yes!").add_answer("No.")

    # method 3
    poll = Poll.create("Test?", duration=1, answers=["Yes!", "No."])

    # method 4 (mostly for emojis)
    poll = Poll.create("Test?", duration=1, answers=[PollMedia.create(text="Yes!"), PollMedia.create(text="No.")])

    await ctx.send(poll=poll)

Python Compatibility

  • I've ensured my code works on Python 3.10.x
  • I've ensured my code works on Python 3.11.x

Checklist

  • I've run the pre-commit code linter over all edited files
  • I've tested my changes on supported Python versions
  • I've added tests for my code, if applicable
  • I've updated / added documentation, where applicable

@AstreaTSS AstreaTSS marked this pull request as ready for review June 7, 2024 21:59
@silasary silasary merged commit 59471c4 into interactions-py:unstable Jun 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants