-
Notifications
You must be signed in to change notification settings - Fork 51
Add polls #346
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
Add polls #346
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f842904
Add polls
05382f1
fix AnswerID type
43f6126
remove omitempty for now
a04c409
add current intent requirement
e2d7f3a
add PollCreate
d2d286b
fix ExpirePoll endpoint route
8a73887
add intents
e25946c
split poll events into DM and guild
3479848
consistent wording
c7e441c
add answer votes paging
d2c169d
make Expiry a pointer
d771026
add permission
b666515
fix Results type
c51764a
add PollCreateBuilder
6f85c0f
address review
fef1c94
you might wanna build the builder idk
fce3f55
add ClearPoll instead of accepting a pointer
c812a4f
Update discord/poll_create_builder.go
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
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
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,43 @@ | ||
package discord | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/disgoorg/snowflake/v2" | ||
) | ||
|
||
type Poll struct { | ||
Question PollMedia `json:"question"` | ||
Answers []PollAnswer `json:"answers"` | ||
Expiry time.Time `json:"expiry"` | ||
AllowMultiselect bool `json:"allow_multiselect"` | ||
LayoutType PollLayoutType `json:"layout_type"` | ||
Results []PollResults `json:"results"` | ||
} | ||
|
||
type PollMedia struct { | ||
Text *string `json:"text"` | ||
Emoji *PartialEmoji `json:"emoji"` | ||
} | ||
|
||
type PollAnswer struct { | ||
AnswerID *snowflake.ID `json:"answer_id"` | ||
PollMedia PollMedia `json:"poll_media"` | ||
} | ||
|
||
type PollResults struct { | ||
IsFinalized bool `json:"is_finalized"` | ||
AnswerCounts []PollAnswerCount `json:"answer_counts"` | ||
} | ||
|
||
type PollAnswerCount struct { | ||
ID snowflake.ID `json:"id"` | ||
Count int `json:"count"` | ||
MeVoted bool `json:"me_voted"` | ||
} | ||
|
||
type PollLayoutType int | ||
|
||
const ( | ||
PollLayoutTypeDefault PollLayoutType = iota + 1 | ||
) |
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
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
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
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,33 @@ | ||
package handlers | ||
|
||
import ( | ||
"github.com/disgoorg/disgo/bot" | ||
"github.com/disgoorg/disgo/events" | ||
"github.com/disgoorg/disgo/gateway" | ||
) | ||
|
||
func gatewayHandlerMessagePollVoteAdd(client bot.Client, sequenceNumber int, shardID int, event gateway.EventMessagePollVoteAdd) { | ||
client.EventManager().DispatchEvent(&events.MessagePollVoteAdd{ | ||
GenericMessagePoll: &events.GenericMessagePoll{ | ||
GenericEvent: events.NewGenericEvent(client, sequenceNumber, shardID), | ||
UserID: event.UserID, | ||
ChannelID: event.ChannelID, | ||
MessageID: event.MessageID, | ||
GuildID: event.GuildID, | ||
AnswerID: event.AnswerID, | ||
}, | ||
}) | ||
} | ||
|
||
func gatewayHandlerMessagePollVoteRemove(client bot.Client, sequenceNumber int, shardID int, event gateway.EventMessagePollVoteRemove) { | ||
client.EventManager().DispatchEvent(&events.MessagePollVoteRemove{ | ||
GenericMessagePoll: &events.GenericMessagePoll{ | ||
GenericEvent: events.NewGenericEvent(client, sequenceNumber, shardID), | ||
UserID: event.UserID, | ||
ChannelID: event.ChannelID, | ||
MessageID: event.MessageID, | ||
GuildID: event.GuildID, | ||
AnswerID: event.AnswerID, | ||
}, | ||
}) | ||
} |
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
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.