/
poll_create_builder.go
66 lines (56 loc) · 1.71 KB
/
poll_create_builder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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
}
// SetAnswers sets the answers of the Poll
func (b *PollCreateBuilder) SetAnswers(answers ...PollMedia) *PollCreateBuilder {
b.Answers = answers
return b
}
// AddAnswer adds an answer to the Poll
func (b *PollCreateBuilder) AddAnswer(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 hours)
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
}
// Build builds the PollCreateBuilder to a PollCreate struct
func (b *PollCreateBuilder) Build() PollCreate {
return b.PollCreate
}