interactions-py / interactions.py

A highly extensible, easy to use, and feature complete bot framework for Discord
https://interactions-py.github.io/interactions.py/
MIT License
839 stars 184 forks source link

feat: add polls #1691

Closed AstreaTSS closed 4 months ago

AstreaTSS commented 4 months ago

Pull Request Type

Description

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

Changes

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

Checklist