Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default permissions to commands #24

Merged
merged 1 commit into from
Jan 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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