-
Notifications
You must be signed in to change notification settings - Fork 130
Add support for polls #534
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
425e660
Bump Credo to 1.7.5 to stop deprecation warnings
jb3 125bd92
Add structures for Discord polls
jb3 64f2848
Add the new `poll` attribute to Message types
jb3 d7a3f44
Meet Credo checks
jb3 7a14f9d
Add missing typespec to method Poll.create_poll/2
jb3 33fd626
Add democracy manifest propaganda
jb3 d346bbb
Add new gateway struct for poll vote changes
jb3 7414520
Add new dispatch logic for poll vote changes
jb3 11ba7e5
Add new gateway intents for poll vote changes
jb3 2ee7662
Update intents test with new values
jb3 a4ed73c
Add API route for fetching voters for a poll
jb3 594eb47
Add API route for expiring polls early
jb3 22ee041
Add new typing for new gateway events to consumer
jb3 09791c7
Add documentation for helper methods on Poll
jb3 c3e267e
Add tests for Poll helper methods
jb3 a6b897f
Update Polls API module naming and documentation
jb3 2774595
Documentation improvements in PollVoteChange
jb3 c79c6b8
Simplify Map creation in PollVoteChange
jb3 40c15c2
Documentation improvements in Poll struct
jb3 4528747
Further documentation improvements in Poll struct
jb3 109b0d4
Documentation and simplifications in MediaObject
jb3 83d1589
Documentation improvements in Poll Results struct
jb3 6c022f3
Update Api.get_poll_answer_voters!/4 with new name
jb3 29f11e9
mix format to remove whitespace
jb3 17049c8
Update documentation about pagination
jb3 abfed4b
Actually fix the get_poll_answer_voters!/4 method
jb3 ac62d3d
Replace types of PollVoteChange with ID types
jb3 879d5cb
Update PollVoteChange to link to Poll.answers type
jb3 a447c75
Correct typing in Message struct
jb3 f0fe367
Better document results attribute of Poll
jb3 4de7b2f
Simplify Map creation for Results struct
jb3 747119b
Stop Credo complaints about PollVoteChange
jb3 6733306
Add new `send_polls` permission
jb3 dd57fa1
Clarify pagination return value
jb3 688d558
Add clarification on layout_type attribute
jb3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add tests for Poll helper methods
- Loading branch information
commit c3e267e41166cf7ecd3e147360bce4a7c4dfb342
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
defmodule Nostrum.Struct.Message.PollTest do | ||
use ExUnit.Case, async: true | ||
|
||
alias Nostrum.Struct.Message.Poll | ||
|
||
doctest Poll | ||
|
||
test "Poll.create_poll/2" do | ||
assert Poll.create_poll("Craigs Cats!", duration: 1, allow_multiselect: true) == | ||
%Nostrum.Struct.Message.Poll{ | ||
question: %Nostrum.Struct.Message.Poll.MediaObject{ | ||
text: "Craigs Cats!", | ||
emoji: nil | ||
}, | ||
answers: [], | ||
expiry: nil, | ||
duration: 1, | ||
allow_multiselect: true, | ||
layout_type: 1, | ||
results: nil | ||
} | ||
end | ||
|
||
test "Poll.put_answer/2" do | ||
poll = | ||
Poll.create_poll("Craigs Cats!", duration: 1, allow_multiselect: true) | ||
|> Poll.put_answer("Yes!") | ||
|
||
assert Enum.at(poll.answers, 0).poll_media.text == "Yes!" | ||
end | ||
|
||
test "Poll.put_answer/3" do | ||
poll = | ||
Poll.create_poll("Craigs Cats!", duration: 1, allow_multiselect: true) | ||
|> Poll.put_answer("Yes!", custom_emoji: 112_233_445_566_778_899) | ||
|
||
assert Enum.at(poll.answers, 0).poll_media.text == "Yes!" | ||
assert Enum.at(poll.answers, 0).poll_media.emoji.id == 112_233_445_566_778_899 | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.