-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction-row.go
43 lines (33 loc) · 872 Bytes
/
action-row.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
package discog
import (
"fmt"
"github.com/bwmarrin/discordgo"
)
type Component interface {
GetComponent() interface{}
}
// Represent a ActionRow
type ActionRow struct {
components []discordgo.MessageComponent
}
// Creates a new ActionRow
func NewActionRow() *ActionRow {
return &ActionRow{
components: []discordgo.MessageComponent{},
}
}
// Adds a component to the ActionRow
func (r *ActionRow) AddComponent(component Component) error {
isValid, ok := component.GetComponent().(discordgo.MessageComponent)
if !ok {
return fmt.Errorf("component is not a valid message component")
}
r.components = append(r.components, isValid)
return nil
}
// Method used to get the ActionRow components which represent a discordgo.ActionsRow structure
func (r *ActionRow) GetComponent() interface{} {
return discordgo.ActionsRow{
Components: r.components,
}
}