-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcommand_basics.go
104 lines (93 loc) · 2.63 KB
/
command_basics.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package gommand
type commandBasics struct {
Name string `json:"name"`
Aliases []string `json:"aliases"`
Description string `json:"description"`
Usage string `json:"usage"`
Category CategoryInterface `json:"category"`
Cooldown Cooldown `json:"cooldown"`
PermissionValidators []PermissionValidator `json:"-"`
ArgTransformers []ArgTransformer `json:"-"`
Middleware []Middleware `json:"-"`
parent *Command
}
// CommandBasics is the basic command structure minus Init and CommandFunction.
// The objective is that you can inherit this with your structs if you wish to make your own.
type CommandBasics = commandBasics
// GetName is used to get the name.
func (obj *commandBasics) GetName() string {
if obj.parent == nil {
return obj.Name
} else {
return obj.parent.Name
}
}
// GetAliases is used to get the aliases.
func (obj *commandBasics) GetAliases() []string {
var Aliases []string
if obj.parent == nil {
Aliases = obj.Aliases
} else {
Aliases = obj.parent.Aliases
}
if Aliases == nil {
return []string{}
}
return Aliases
}
// GetDescription is used to get the description.
func (obj *commandBasics) GetDescription() string {
if obj.parent == nil {
return obj.Description
} else {
return obj.parent.Description
}
}
// GetUsage is used to get the usage.
func (obj *commandBasics) GetUsage() string {
if obj.parent == nil {
return obj.Usage
} else {
return obj.parent.Usage
}
}
// GetCategory is used to get the category.
func (obj *commandBasics) GetCategory() CategoryInterface {
if obj.parent == nil {
return obj.Category
} else {
return obj.parent.Category
}
}
// GetPermissionValidators is used to get the permission validators.
func (obj *commandBasics) GetPermissionValidators() []PermissionValidator {
if obj.parent == nil {
return obj.PermissionValidators
} else {
return obj.parent.PermissionValidators
}
}
// GetArgTransformers is used to get the arg transformers.
func (obj *commandBasics) GetArgTransformers() []ArgTransformer {
if obj.parent == nil {
return obj.ArgTransformers
} else {
return obj.parent.ArgTransformers
}
}
// GetCooldown is used to get the cooldown.
func (obj *commandBasics) GetCooldown() Cooldown {
if obj.parent == nil {
return obj.Cooldown
} else {
return obj.parent.Cooldown
}
}
// GetMiddleware is used to get the middleware.
func (obj *commandBasics) GetMiddleware() []Middleware {
if obj.parent == nil {
return obj.Middleware
} else {
return obj.parent.Middleware
}
}