Skip to content

Commit

Permalink
Added missing documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
FedorLap2006 committed Jun 17, 2021
1 parent 6f38a70 commit ea6ac6f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
26 changes: 17 additions & 9 deletions components.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (r ActionsRow) MarshalJSON() ([]byte, error) {
}

// Type is a method to get the type of a component.
func (r ActionsRow) Type() ComponentType {
func (ActionsRow) Type() ComponentType {
return ActionsRowComponent
}

Expand Down Expand Up @@ -97,27 +97,35 @@ func (b Button) MarshalJSON() ([]byte, error) {
}

// Type is a method to get the type of a component.
func (b Button) Type() ComponentType {
func (Button) Type() ComponentType {
return ButtonComponent
}

// SelectMenuOption represents an option for a select menu.
type SelectMenuOption struct {
Label string `json:"label,omitempty"`
Value string `json:"value"`
Description string `json:"description"`
Emoji ComponentEmoji `json:"emoji"`
Default bool `json:"default"`
// Determines whenever option is selected by default or not.
Default bool `json:"default"`
}

// SelectMenu represents select menu component.
type SelectMenu struct {
CustomID string `json:"custom_id,omitempty"`
Placeholder string `json:"placeholder"`
MinValues int `json:"min_values,omitempty"`
MaxValues int `json:"max_values,omitempty"`
Options []SelectMenuOption `json:"options"`
CustomID string `json:"custom_id,omitempty"`
// The text which will be shown in the menu if there's no default options or all options was deselected and component was closed.
Placeholder string `json:"placeholder"`
// This value determines the minimal amount of selected items in the menu.
MinValues int `json:"min_values,omitempty"`
// This value determines the maximal amount of selected items in the menu.
// If MaxValues or MinValues are greater than one then the user can select multiple items in the component.
MaxValues int `json:"max_values,omitempty"`
Options []SelectMenuOption `json:"options"`
}

func (m SelectMenu) Type() ComponentType {
// Type is a method to get the type of a component.
func (SelectMenu) Type() ComponentType {
return SelectMenuComponent
}

Expand Down
4 changes: 3 additions & 1 deletion examples/components/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package main
import (
"flag"
"fmt"
"github.com/bwmarrin/discordgo"
"log"
"os"
"os/signal"
"sort"
"sync"

"github.com/bwmarrin/discordgo"
)

// Bot parameters
Expand All @@ -31,6 +32,7 @@ func init() {
}
}

// MessageVoteStats represents user votes for a particular message
type MessageVoteStats struct {
PeopleVoted map[string]string
Votes map[string]int
Expand Down
9 changes: 8 additions & 1 deletion restapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -2307,14 +2307,18 @@ func (s *Session) WebhookMessageEdit(webhookID, token, messageID string, data *W
// WebhookMessageDelete deletes a webhook message.
// webhookID : The ID of a webhook
// token : The auth token for the webhook
// messageID : The ID of message to edit
// messageID : The ID of a message to edit
func (s *Session) WebhookMessageDelete(webhookID, token, messageID string) (err error) {
uri := EndpointWebhookMessage(webhookID, token, messageID)

_, err = s.RequestWithBucketID("DELETE", uri, nil, EndpointWebhookToken("", ""))
return
}

// WebhookMessage retrieves and returnes the message sent by a webhook.
// webhookID : The webhook ID
// token : The auth token for the webhook
// messageID : The ID of a message to retrieve
func (s *Session) WebhookMessage(webhookID, token, messageID string) (st *Message, err error) {
uri := EndpointWebhookMessage(webhookID, token, messageID)

Expand Down Expand Up @@ -2634,6 +2638,9 @@ func (s *Session) InteractionResponseEdit(appID string, interaction *Interaction
return s.WebhookMessageEdit(appID, interaction.Token, "@original", newresp)
}

// InteractionResponse retrieves and returns the interaction response message.
// appID : The application ID.
// interaction : Interaction instance.
func (s *Session) InteractionResponse(appID string, interaction *Interaction) (*Message, error) {
return s.WebhookMessage(appID, interaction.Token, "@original")
}
Expand Down

0 comments on commit ea6ac6f

Please sign in to comment.