Skip to content

Commit

Permalink
add PollCreate
Browse files Browse the repository at this point in the history
  • Loading branch information
sebm253 committed Mar 22, 2024
1 parent a04c409 commit e2d7f3a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
6 changes: 3 additions & 3 deletions discord/emoji.go
Expand Up @@ -66,9 +66,9 @@ type EmojiUpdate struct {
}

type PartialEmoji struct {
ID *snowflake.ID `json:"id"`
Name *string `json:"name"`
Animated bool `json:"animated"`
ID *snowflake.ID `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Animated bool `json:"animated,omitempty"`
}

// Reaction returns a string used for manipulating with reactions. May be empty if the Name is nil
Expand Down
2 changes: 1 addition & 1 deletion discord/message_create.go
Expand Up @@ -18,7 +18,7 @@ type MessageCreate struct {
MessageReference *MessageReference `json:"message_reference,omitempty"`
Flags MessageFlags `json:"flags,omitempty"`
EnforceNonce bool `json:"enforce_nonce,omitempty"`
Poll Poll `json:"poll,omitempty"`
Poll PollCreate `json:"poll,omitempty"`
}

func (MessageCreate) interactionCallbackData() {}
Expand Down
2 changes: 1 addition & 1 deletion discord/message_create_builder.go
Expand Up @@ -252,7 +252,7 @@ func (b *MessageCreateBuilder) SetSuppressEmbeds(suppressEmbeds bool) *MessageCr
}

// SetPoll sets the Poll of the Message
func (b *MessageCreateBuilder) SetPoll(poll Poll) *MessageCreateBuilder {
func (b *MessageCreateBuilder) SetPoll(poll PollCreate) *MessageCreateBuilder {
b.Poll = poll
return b
}
Expand Down
12 changes: 10 additions & 2 deletions discord/poll.go
Expand Up @@ -15,13 +15,21 @@ type Poll struct {
Results []PollResults `json:"results"`
}

type PollCreate struct {
Question PollMedia `json:"question"`
Answers []PollAnswer `json:"answers"`
Duration int `json:"duration"`
AllowMultiselect bool `json:"allow_multiselect"`
LayoutType PollLayoutType `json:"layout_type,omitempty"`
}

type PollMedia struct {
Text *string `json:"text"`
Emoji *PartialEmoji `json:"emoji"`
Emoji *PartialEmoji `json:"emoji,omitempty"`
}

type PollAnswer struct {
AnswerID *int `json:"answer_id"`
AnswerID *int `json:"answer_id,omitempty"`
PollMedia PollMedia `json:"poll_media"`
}

Expand Down
2 changes: 1 addition & 1 deletion discord/webhook_message_create.go
Expand Up @@ -15,7 +15,7 @@ type WebhookMessageCreate struct {
Flags MessageFlags `json:"flags,omitempty"`
ThreadName string `json:"thread_name,omitempty"`
AppliedTags []snowflake.ID `json:"applied_tags,omitempty"`
Poll Poll `json:"poll,omitempty"`
Poll PollCreate `json:"poll,omitempty"`
}

// ToBody returns the MessageCreate ready for body
Expand Down
2 changes: 1 addition & 1 deletion discord/webhook_message_create_builder.go
Expand Up @@ -211,7 +211,7 @@ func (b *WebhookMessageCreateBuilder) SetThreadName(threadName string) *WebhookM
}

// SetPoll sets the Poll of the webhook Message
func (b *WebhookMessageCreateBuilder) SetPoll(poll Poll) *WebhookMessageCreateBuilder {
func (b *WebhookMessageCreateBuilder) SetPoll(poll PollCreate) *WebhookMessageCreateBuilder {
b.Poll = poll
return b
}
Expand Down

0 comments on commit e2d7f3a

Please sign in to comment.