Skip to content

Commit

Permalink
docs: add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
FedorLap2006 committed May 7, 2024
1 parent 1efec2e commit 2958762
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions restapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -3458,6 +3458,10 @@ func (s *Session) UserApplicationRoleConnectionUpdate(appID string, rconn *Appli
// Functions specific to polls
// ----------------------------------------------------------------------

// PollAnswerVoters returns users who voted for a particular answer in a poll on the specified message.
// channelID : ID of the channel.
// messageID : ID of the message.
// answerID : ID of the answer.
func (s *Session) PollAnswerVoters(channelID, messageID, answerID string) (voters []*User, err error) {
endpoint := EndpointPollAnswerVoters(channelID, messageID, answerID)

Expand All @@ -3480,6 +3484,9 @@ func (s *Session) PollAnswerVoters(channelID, messageID, answerID string) (voter
return
}

// PollExpire expires poll on the specified message.
// channelID : ID of the channel.
// messageID : ID of the message.
func (s *Session) PollExpire(channelID, messageID string) (msg *Message, err error) {
endpoint := EndpointPollExpire(channelID, messageID)

Expand Down
12 changes: 11 additions & 1 deletion structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2300,39 +2300,49 @@ const (
StageInstancePrivacyLevelGuildOnly StageInstancePrivacyLevel = 2
)

// PollLayoutType represents the layout of a poll.
type PollLayoutType int

// Valid PollLayoutType values.
const (
PollLayoutTypeDefault PollLayoutType = 1
)

// PollMedia contains common data used by question and answers.
type PollMedia struct {
Text string `json:"text,omitempty"`
Emoji *ComponentEmoji `json:"emoji,omitempty"` // TODO: rename the type
}

// PollAnswer represents a single answer in a poll.
type PollAnswer struct {
AnswerID int `json:"answer_id"`
Media *PollMedia `json:"poll_media"`
}

// PollAnswerCount stores counted poll votes for a single answer.
type PollAnswerCount struct {
ID int `json:"id"`
Count int `json:"count"`
MeVoted bool `json:"me_voted"`
}

// PollResults contains voting results on a poll.
type PollResults struct {
Finalized bool `json:"is_finalized"`
AnswerCounts []*PollAnswerCount `json:"answer_count"`
}

// Poll contains all poll related data.
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,omitempty"`

// NOTE: available only when fetching.
Results *PollResults `json:"results,omitempty"`
}

// Constants for the different bit offsets of text channel permissions
Expand Down

0 comments on commit 2958762

Please sign in to comment.