-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommands.go
More file actions
32 lines (25 loc) · 746 Bytes
/
Copy pathcommands.go
File metadata and controls
32 lines (25 loc) · 746 Bytes
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
package guildedgo
type CommandsBuilder struct {
Commands []Command
}
type Command struct {
CommandName string
Action func(client *Client, v *ChatMessageCreated)
}
type CommandService interface {
AddCommand(command *Command)
AddCommands(commands *CommandsBuilder)
}
type commandService struct {
client *Client
}
var _ CommandService = &commandService{}
func (service *commandService) AddCommand(command *Command) {
service.client.Command(command.CommandName, command.Action)
}
func (service *commandService) AddCommands(builder *CommandsBuilder) {
// Is this the best way to do this? I'm not sure. - Thanks, Copilot
for _, command := range builder.Commands {
service.client.Command(command.CommandName, command.Action)
}
}