From 2647267460c900e3cfcd10cd00c2664ca7bc8c31 Mon Sep 17 00:00:00 2001 From: Maximilian von Lindern Date: Mon, 30 Aug 2021 22:15:59 +0200 Subject: [PATCH] discord: Fix style issues (#272) * Discord: Fix comment style issues * Discord: use URL type alias for URls instead of string --- discord/component.go | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/discord/component.go b/discord/component.go index 258109c..21a25e8 100644 --- a/discord/component.go +++ b/discord/component.go @@ -72,7 +72,7 @@ type Component interface { Type() ComponentType } -// ActionRow is a row of components at the bottom of a message. +// ActionRowComponent is a row of components at the bottom of a message. type ActionRowComponent struct { Components []Component `json:"components"` } @@ -135,16 +135,17 @@ func (a *ActionRowComponent) UnmarshalJSON(b []byte) error { return nil } -// Button is a clickable button that may be added to an interaction response. +// ButtonComponent is a clickable button that may be added to an interaction +// response. type ButtonComponent struct { Label string `json:"label"` // CustomID attached to InteractionCreate event when clicked. CustomID string `json:"custom_id"` Style ButtonStyle `json:"style"` Emoji *ButtonEmoji `json:"emoji,omitempty"` - // Present on link-style buttons. - URL string `json:"url,omitempty"` - Disabled bool `json:"disabled,omitempty"` + // URL is only present on link-style buttons. + URL URL `json:"url,omitempty"` + Disabled bool `json:"disabled,omitempty"` } // Type implements the Component interface. @@ -157,11 +158,16 @@ type ButtonStyle uint // All types of ButtonStyle documented. const ( - PrimaryButton ButtonStyle = iota + 1 // Blurple button. - SecondaryButton // Grey button. - SuccessButton // Green button. - DangerButton // Red button. - LinkButton // Button that navigates to a URL. + // PrimaryButton is a blurple button. + PrimaryButton ButtonStyle = iota + 1 + // SecondaryButton is a grey button. + SecondaryButton + // SuccessButton is a green button. + SuccessButton + // DangerButton is a red button. + DangerButton + // LinkButton is a button that navigates to a URL. + LinkButton ) // ButtonEmoji is the emoji displayed on the button before the text. @@ -188,7 +194,8 @@ func (b ButtonComponent) MarshalJSON() ([]byte, error) { }) } -// Select is a clickable button that may be added to an interaction response. +// SelectComponent is a clickable button that may be added to an interaction +// response. type SelectComponent struct { CustomID string `json:"custom_id"` Options []SelectComponentOption `json:"options"`