Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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,61 @@ | ||
package discord | ||
|
||
// PollCreateBuilder helps create PollCreate structs easier | ||
type PollCreateBuilder struct { | ||
PollCreate | ||
} | ||
|
||
// SetQuestion sets the question of the Poll | ||
func (b *PollCreateBuilder) SetQuestion(text string) *PollCreateBuilder { | ||
b.Question = PollMedia{ | ||
Text: &text, | ||
} | ||
return b | ||
} | ||
|
||
// SetPollAnswers sets the answers of the Poll | ||
func (b *PollCreateBuilder) SetPollAnswers(answers ...PollMedia) *PollCreateBuilder { | ||
b.Answers = answers | ||
return b | ||
} | ||
|
||
// AddPollAnswer adds an answer to the Poll | ||
func (b *PollCreateBuilder) AddPollAnswer(text string, emoji *PartialEmoji) *PollCreateBuilder { | ||
b.Answers = append(b.Answers, PollMedia{ | ||
Text: &text, | ||
Emoji: emoji, | ||
}) | ||
return b | ||
} | ||
|
||
// RemoveAnswer removes an answer from the Poll | ||
func (b *PollCreateBuilder) RemoveAnswer(i int) *PollCreateBuilder { | ||
if len(b.Answers) > i { | ||
b.Answers = append(b.Answers[:i], b.Answers[i+1:]...) | ||
} | ||
return b | ||
} | ||
|
||
// ClearAnswers removes all answers of the Poll | ||
func (b *PollCreateBuilder) ClearAnswers() *PollCreateBuilder { | ||
b.Answers = []PollMedia{} | ||
return b | ||
} | ||
|
||
// SetDuration sets the duration of the Poll (in seconds) | ||
func (b *PollCreateBuilder) SetDuration(duration int) *PollCreateBuilder { | ||
b.Duration = duration | ||
return b | ||
} | ||
|
||
// SetAllowMultiselect sets whether users will be able to vote for more than one answer of the Poll | ||
func (b *PollCreateBuilder) SetAllowMultiselect(multiselect bool) *PollCreateBuilder { | ||
b.AllowMultiselect = multiselect | ||
return b | ||
} | ||
|
||
// SetLayoutType sets the layout of the Poll | ||
func (b *PollCreateBuilder) SetLayoutType(layout PollLayoutType) *PollCreateBuilder { | ||
b.LayoutType = layout | ||
return b | ||
} |