-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from DisgoOrg/development
buttons release
- Loading branch information
Showing
45 changed files
with
1,048 additions
and
1,050 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: gomod | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
open-pull-requests-limit: 10 | ||
target-branch: development | ||
- package-ecosystem: gomod | ||
directory: "/example" | ||
schedule: | ||
interval: daily | ||
open-pull-requests-limit: 10 | ||
- package-ecosystem: gomod | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
open-pull-requests-limit: 10 | ||
target-branch: development | ||
- package-ecosystem: gomod | ||
directory: "/example" | ||
schedule: | ||
interval: daily | ||
open-pull-requests-limit: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package api | ||
|
||
// NewActionRow creates a new ActionRow holding th provided Component(s) | ||
func NewActionRow(components ...Component) *ActionRow { | ||
return &ActionRow{ | ||
ComponentImpl: newComponentImpl(ComponentTypeActionRow), | ||
Components: components, | ||
} | ||
} | ||
|
||
// ActionRow holds up to 5 Component(s) in a row | ||
type ActionRow struct { | ||
ComponentImpl | ||
Components []Component `json:"components"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package api | ||
|
||
// ButtonStyle defines how the Button looks like (https://discord.com/assets/7bb017ce52cfd6575e21c058feb3883b.png) | ||
type ButtonStyle int | ||
|
||
// Supported ButtonStyle(s) | ||
const ( | ||
ButtonStylePrimary = iota + 1 | ||
ButtonStyleSecondary | ||
ButtonStyleSuccess | ||
ButtonStyleDanger | ||
ButtonStyleLink | ||
) | ||
|
||
// NewButton creates a new Button with the provided parameters. Link Button(s) need a url and other Button(s) need a customID | ||
func NewButton(style ButtonStyle, label *string, customID string, url string, emote *Emote, disabled bool) *Button { | ||
return &Button{ | ||
ComponentImpl: newComponentImpl(ComponentTypeButton), | ||
Style: style, | ||
CustomID: customID, | ||
URL: url, | ||
Label: label, | ||
Emote: emote, | ||
Disabled: disabled, | ||
} | ||
} | ||
|
||
// NewPrimaryButton creates a new Button with ButtonStylePrimary & the provided parameters | ||
func NewPrimaryButton(label string, customID string, emote *Emote, disabled bool) *Button { | ||
return NewButton(ButtonStylePrimary, &label, customID, "", emote, disabled) | ||
} | ||
|
||
// NewSecondaryButton creates a new Button with ButtonStyleSecondary & the provided parameters | ||
func NewSecondaryButton(label string, customID string, emote *Emote, disabled bool) *Button { | ||
return NewButton(ButtonStyleSecondary, &label, customID, "", emote, disabled) | ||
} | ||
|
||
// NewSuccessButton creates a new Button with ButtonStyleSuccess & the provided parameters | ||
func NewSuccessButton(label string, customID string, emote *Emote, disabled bool) *Button { | ||
return NewButton(ButtonStyleSuccess, &label, customID, "", emote, disabled) | ||
} | ||
|
||
// NewDangerButton creates a new Button with ButtonStyleDanger & the provided parameters | ||
func NewDangerButton(label string, customID string, emote *Emote, disabled bool) *Button { | ||
return NewButton(ButtonStyleDanger, &label, customID, "", emote, disabled) | ||
} | ||
|
||
// NewLinkButton creates a new link Button with ButtonStyleLink & the provided parameters | ||
func NewLinkButton(label string, url string, emote *Emote, disabled bool) *Button { | ||
return NewButton(ButtonStyleLink, &label, "", url, emote, disabled) | ||
} | ||
|
||
// Button can be attacked to all messages & be clicked by a User. If clicked it fires a events.ButtonClickEvent with the declared customID | ||
type Button struct { | ||
ComponentImpl | ||
Style ButtonStyle `json:"style,omitempty"` | ||
Label *string `json:"label,omitempty"` | ||
Emote *Emote `json:"emoji,omitempty"` | ||
CustomID string `json:"custom_id,omitempty"` | ||
URL string `json:"url,omitempty"` | ||
Disabled bool `json:"disabled,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package api | ||
|
||
// ComponentType defines different Component(s) | ||
type ComponentType int | ||
|
||
// Supported ComponentType(s) | ||
const ( | ||
ComponentTypeActionRow = iota + 1 | ||
ComponentTypeButton | ||
) | ||
|
||
// Component is a general interface each Component needs to implement | ||
type Component interface { | ||
Type() ComponentType | ||
} | ||
|
||
func newComponentImpl(componentType ComponentType) ComponentImpl { | ||
return ComponentImpl{ComponentType: componentType} | ||
} | ||
|
||
// ComponentImpl is used to embed in each different ComponentType | ||
type ComponentImpl struct { | ||
ComponentType ComponentType `json:"type"` | ||
} | ||
|
||
// Type returns the ComponentType of this Component | ||
func (t ComponentImpl) Type() ComponentType { | ||
return t.ComponentType | ||
} | ||
|
||
// UnmarshalComponent is used for easier unmarshalling of different Component(s) | ||
type UnmarshalComponent struct { | ||
ComponentType ComponentType `json:"type"` | ||
Style ButtonStyle `json:"style"` | ||
Label *string `json:"label"` | ||
Emote *Emote `json:"emoji"` | ||
CustomID string `json:"custom_id"` | ||
URL string `json:"url"` | ||
Disabled bool `json:"disabled"` | ||
Components []*UnmarshalComponent `json:"components"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.