/
application_command_create.go
97 lines (80 loc) · 3.12 KB
/
application_command_create.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
package discord
import "github.com/disgoorg/disgo/json"
type ApplicationCommandCreate interface {
json.Marshaler
Type() ApplicationCommandType
CommandName() string
applicationCommandCreate()
}
type SlashCommandCreate struct {
Name string `json:"name"`
CommandNameLocalizations map[Locale]string `json:"name_localizations,omitempty"`
Description string `json:"description"`
DescriptionLocalizations map[Locale]string `json:"description_localizations,omitempty"`
Options []ApplicationCommandOption `json:"options,omitempty"`
DefaultMemberPermissions *json.Nullable[Permissions] `json:"default_member_permissions,omitempty"` // different behavior for 0 and null, optional
DMPermission *bool `json:"dm_permission,omitempty"`
}
func (c SlashCommandCreate) MarshalJSON() ([]byte, error) {
type slashCommandCreate SlashCommandCreate
return json.Marshal(struct {
Type ApplicationCommandType `json:"type"`
slashCommandCreate
}{
Type: c.Type(),
slashCommandCreate: slashCommandCreate(c),
})
}
func (SlashCommandCreate) Type() ApplicationCommandType {
return ApplicationCommandTypeSlash
}
func (c SlashCommandCreate) CommandName() string {
return c.Name
}
func (SlashCommandCreate) applicationCommandCreate() {}
type UserCommandCreate struct {
Name string `json:"name"`
CommandNameLocalizations map[Locale]string `json:"name_localizations,omitempty"`
DefaultMemberPermissions *json.Nullable[Permissions] `json:"default_member_permissions,omitempty"`
DMPermission *bool `json:"dm_permission,omitempty"`
}
func (c UserCommandCreate) MarshalJSON() ([]byte, error) {
type userCommandCreate UserCommandCreate
return json.Marshal(struct {
Type ApplicationCommandType `json:"type"`
userCommandCreate
}{
Type: c.Type(),
userCommandCreate: userCommandCreate(c),
})
}
func (UserCommandCreate) Type() ApplicationCommandType {
return ApplicationCommandTypeUser
}
func (c UserCommandCreate) CommandName() string {
return c.Name
}
func (UserCommandCreate) applicationCommandCreate() {}
type MessageCommandCreate struct {
Name string `json:"name"`
CommandNameLocalizations map[Locale]string `json:"name_localizations,omitempty"`
DefaultMemberPermissions *json.Nullable[Permissions] `json:"default_member_permissions,omitempty"`
DMPermission *bool `json:"dm_permission,omitempty"`
}
func (c MessageCommandCreate) MarshalJSON() ([]byte, error) {
type messageCommandCreate MessageCommandCreate
return json.Marshal(struct {
Type ApplicationCommandType `json:"type"`
messageCommandCreate
}{
Type: c.Type(),
messageCommandCreate: messageCommandCreate(c),
})
}
func (MessageCommandCreate) Type() ApplicationCommandType {
return ApplicationCommandTypeMessage
}
func (c MessageCommandCreate) CommandName() string {
return c.Name
}
func (MessageCommandCreate) applicationCommandCreate() {}