Skip to content

Commit

Permalink
Add default permissions to commands (#24)
Browse files Browse the repository at this point in the history
Signed-off-by: jolheiser <[email protected]>
  • Loading branch information
jolheiser authored Jan 12, 2022
1 parent 7b0ddf8 commit 1256161
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions register-commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,23 @@ func (c CreateOption) createOption() CreateOption {

// CreateCommand is a slash command that can be registered to discord
type CreateCommand struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Type CommandType `json:"type,omitempty"`
Options []CreateOptioner `json:"options,omitempty"`
}

// CreateCommand is a slash command that can be registered to discord
type SlashCommand struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Type CommandType `json:"type,omitempty"`
Options []CreateOptioner `json:"options,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Type CommandType `json:"type,omitempty"`
Options []CreateOptioner `json:"options,omitempty"`
DefaultPermissionDisabled bool `json:"default_permission"`
}

// MarshalJSON implements json.Marshaler
func (c CreateCommand) MarshalJSON() ([]byte, error) {
type createCommand CreateCommand
return json.Marshal(struct {
createCommand
DefaultPermission bool `json:"default_permission"`
}{
createCommand: createCommand(c),
DefaultPermission: !c.DefaultPermissionDisabled,
})
}

// NewSlashCommand returns a new slash command
Expand Down

0 comments on commit 1256161

Please sign in to comment.