Documentation ¶
Index ¶
- Constants
- func RestoreCustomID(ctx context.Context, redisApp redis.Client, prefix, customID string, ...) (url.Values, error)
- func SaveCustomID(ctx context.Context, redisApp redis.Client, prefix string, values url.Values) (string, error)
- type AllowedMentions
- type Attachment
- type Author
- type Command
- type CommandOption
- type Component
- type Config
- type Embed
- type Field
- type Image
- type InteractionCallbackType
- type InteractionDataResponse
- type InteractionRequest
- type InteractionResponse
- func (i InteractionResponse) AddAttachment(filename, filepath string, size int64) InteractionResponse
- func (i InteractionResponse) AddComponent(component Component) InteractionResponse
- func (i InteractionResponse) AddEmbed(embed Embed) InteractionResponse
- func (i InteractionResponse) Ephemeral() InteractionResponse
- type Member
- type OnMessage
- type Service
Constants ¶
const ( // ApplicationCommandInteraction occurs when user enter a slash command ApplicationCommandInteraction interactionType = 2 // MessageComponentInteraction occurs when user interact with an action MessageComponentInteraction interactionType = 3 )
const ( // PrimaryButton is green PrimaryButton buttonStyle = 1 // SecondaryButton is grey SecondaryButton buttonStyle = 2 // DangerButton is red DangerButton buttonStyle = 4 )
const (
// ActionRowType for row
ActionRowType componentType = 1
)
const ( // EphemeralMessage int value EphemeralMessage int = 1 << 6 )
Variables ¶
This section is empty.
Functions ¶
func RestoreCustomID ¶ added in v0.2.1
Types ¶
type AllowedMentions ¶
type AllowedMentions struct {
Parse []string `json:"parse"`
}
AllowedMentions list
type Attachment ¶
type Attachment struct { Filename string `json:"filename"` ID int `json:"id"` Size int64 `json:"size,omitempty"` Ephemeral bool `json:"ephemeral,omitempty"` // contains filtered or unexported fields }
Attachment for file upload
type Command ¶
type Command struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Options []CommandOption `json:"options,omitempty"` Guilds []string `json:"-"` }
Command configuration
type CommandOption ¶
type CommandOption struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Value string `json:"value,omitempty"` Type int `json:"type,omitempty"` Required bool `json:"required,omitempty"` }
CommandOption configuration option
type Component ¶
type Component struct { Label string `json:"label,omitempty"` CustomID string `json:"custom_id,omitempty"` Components []Component `json:"components,omitempty"` Type componentType `json:"type,omitempty"` Style buttonStyle `json:"style,omitempty"` }
Component describes an interactive component
type Embed ¶
type Embed struct { Thumbnail *Image `json:"thumbnail,omitempty"` Image *Image `json:"image,omitempty"` Author *Author `json:"author,omitempty"` Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` URL string `json:"url,omitempty"` Fields []Field `json:"fields,omitempty"` Color int `json:"color,omitempty"` }
Embed of content
type Field ¶
type Field struct { Name string `json:"name"` Value string `json:"value"` Inline bool `json:"inline,omitempty"` }
Field for embed
type InteractionCallbackType ¶
type InteractionCallbackType uint
InteractionCallbackType defines types of possible answer
const ( // ChannelMessageWithSource answer ChannelMessageWithSource InteractionCallbackType = 4 // DeferredChannelMessageWithSource deferred answer DeferredChannelMessageWithSource InteractionCallbackType = 5 // DeferredUpdateMessage deferred in-place DeferredUpdateMessage InteractionCallbackType = 6 // UpdateMessageCallback in place UpdateMessageCallback InteractionCallbackType = 7 )
type InteractionDataResponse ¶
type InteractionDataResponse struct { Content string `json:"content,omitempty"` AllowedMentions AllowedMentions `json:"allowed_mentions"` Embeds []Embed `json:"embeds"` // no `omitempty` to pass empty array when cleared Components []Component `json:"components"` // no `omitempty` to pass empty array when cleared Attachments []Attachment `json:"attachments"` // no `omitempty` to pass empty array when cleared Flags int `json:"flags"` }
InteractionDataResponse for responding to user
func NewDataResponse ¶ added in v0.0.3
func NewDataResponse(content string) InteractionDataResponse
NewDataResponse create a data response
func (InteractionDataResponse) AddEmbed ¶ added in v0.0.3
func (d InteractionDataResponse) AddEmbed(embed Embed) InteractionDataResponse
AddEmbed add given embed to response
type InteractionRequest ¶
type InteractionRequest struct { Member Member `json:"member"` ID string `json:"id"` GuildID string `json:"guild_id"` Token string `json:"token"` ApplicationID string `json:"application_id"` Message struct { Interaction struct { Name string `json:"name"` } `json:"interaction"` } `json:"message"` Data struct { Name string `json:"name"` CustomID string `json:"custom_id"` Options []CommandOption `json:"options"` } `json:"data"` Type interactionType `json:"type"` }
InteractionRequest when user perform an action
type InteractionResponse ¶
type InteractionResponse struct { Data InteractionDataResponse `json:"data,omitempty"` Type InteractionCallbackType `json:"type,omitempty"` }
InteractionResponse for responding to user
func AsyncResponse ¶
func AsyncResponse(replace, ephemeral bool) InteractionResponse
AsyncResponse to the user
func NewEphemeral ¶
func NewEphemeral(replace bool, content string) InteractionResponse
NewEphemeral creates an ephemeral response
func NewError ¶
func NewError(replace bool, err error) InteractionResponse
NewError creates an error response
func NewResponse ¶
func NewResponse(iType InteractionCallbackType, content string) InteractionResponse
NewResponse creates a response
func (InteractionResponse) AddAttachment ¶
func (i InteractionResponse) AddAttachment(filename, filepath string, size int64) InteractionResponse
AddAttachment add given attachment to response
func (InteractionResponse) AddComponent ¶ added in v0.0.3
func (i InteractionResponse) AddComponent(component Component) InteractionResponse
AddComponent add given component to response
func (InteractionResponse) AddEmbed ¶
func (i InteractionResponse) AddEmbed(embed Embed) InteractionResponse
AddEmbed add given embed to response
func (InteractionResponse) Ephemeral ¶
func (i InteractionResponse) Ephemeral() InteractionResponse
Ephemeral set response to ephemeral
type Member ¶
type Member struct { User struct { ID string `json:"id,omitempty"` Username string `json:"username,omitempty"` } `json:"user,omitempty"` }
Member of discord
type OnMessage ¶
type OnMessage func(context.Context, InteractionRequest) (InteractionResponse, func(context.Context) InteractionResponse)
OnMessage handle message event