Documentation
¶
Index ¶
- Constants
- func GuildOpt(guildID Snowflake) func(*CommandsOpt)
- type Activity
- type AllowedMentions
- type Application
- type Attachment
- type Author
- type AutocompleteInteractionData
- type BoolOption
- type Button
- type ButtonInteractionData
- type Channel
- type ChannelOption
- type ChannelType
- type Choice
- type Command
- type CommandType
- type CommandsOpt
- type Component
- type ComponentType
- type CreateCommand
- type CreateCommander
- type CreateOption
- type CreateOptioner
- type Embed
- type EmbedB
- func (e *EmbedB) Author(a Author) *EmbedB
- func (e *EmbedB) Color(i uint32) *EmbedB
- func (e *EmbedB) Description(s string) *EmbedB
- func (e *EmbedB) Descriptionf(format string, a ...any) *EmbedB
- func (e *EmbedB) Embed() Embed
- func (e *EmbedB) Field(name, value string) *EmbedB
- func (e *EmbedB) FieldInline(name, value string) *EmbedB
- func (e *EmbedB) Fields(f ...Field) *EmbedB
- func (e *EmbedB) Footer(f Footer) *EmbedB
- func (e *EmbedB) Image(i Image) *EmbedB
- func (e *EmbedB) ImageURL(s string) *EmbedB
- func (e *EmbedB) InteractionRespData() *InteractionRespData
- func (e *EmbedB) Message() Message
- func (e *EmbedB) Provider(name string, url string) *EmbedB
- func (e *EmbedB) Thumbnail(i Image) *EmbedB
- func (e *EmbedB) Timestamp(t time.Time) *EmbedB
- func (e *EmbedB) Title(s string) *EmbedB
- func (e *EmbedB) Titlef(format string, a ...any) *EmbedB
- func (e *EmbedB) URL(s string) *EmbedB
- func (e *EmbedB) Video(v Video) *EmbedB
- type Embedder
- type Emoji
- type Field
- type Footer
- type Handlers
- type Hash
- type Image
- type InnerInteractionType
- type IntOption
- type IntResponseFlags
- type Interaction
- type InteractionDataConstraint
- type InteractionRespData
- type InteractionResponder
- type InteractionType
- type JsonRaw
- type Member
- type MentionableOption
- type Message
- type MessageActivity
- type MessageCommandInteractionData
- func (i MessageCommandInteractionData) OptionsMember(k string) (Member, error)
- func (i MessageCommandInteractionData) OptionsMessage(k string) (Message, error)
- func (i MessageCommandInteractionData) OptionsRole(k string) (Role, error)
- func (i MessageCommandInteractionData) OptionsUser(k string) (User, error)
- type MessageFlag
- type MessageReference
- type MessageType
- type Modal
- type ModalInteractionData
- type Mux
- func (m *Mux) Autocomplete(route string, ...)
- func (m *Mux) BulkRegisterCommand(c []CreateCommander, options ...func(*CommandsOpt)) error
- func (m *Mux) ButtonComponent(route string, ...)
- func (m *Mux) CreateMessage(channelID Snowflake, data Message) (*Message, error)
- func (m *Mux) DeleteCommand(ID Snowflake, options ...func(*CommandsOpt)) error
- func (m *Mux) DeleteFollowUpInteraction(token string, messageID Snowflake) error
- func (m *Mux) DeleteOriginalInteraction(token string) error
- func (m *Mux) EditFollowUpInteraction(token string, messageID Snowflake, data InteractionResponder) error
- func (m *Mux) EditOriginalInteraction(token string, data InteractionResponder) error
- func (m *Mux) FollowUpInteraction(token string, data InteractionResponder) error
- func (m *Mux) GetCommands(options ...func(*CommandsOpt)) ([]Command, error)
- func (m *Mux) GetFollowUpInteraction(token string, messageID Snowflake) (*InteractionRespData, error)
- func (m *Mux) GetOriginalInteraction(token string) (*InteractionRespData, error)
- func (m *Mux) GetUser(id Snowflake) (User, error)
- func (m *Mux) ListenAndServe(addr string) error
- func (m *Mux) Lock()
- func (m *Mux) Me() (User, error)
- func (m *Mux) MessageCommand(route string, ...)
- func (m *Mux) Modal(route string, ...)
- func (m *Mux) Mount(typ InnerInteractionType, route string, handler any)
- func (m *Mux) RegisterCommand(c CreateCommander, options ...func(*CommandsOpt)) error
- func (m *Mux) Route(pattern string, fn func(m *Mux))
- func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (m *Mux) SlashCommand(route string, ...)
- func (m *Mux) Unlock()
- func (m *Mux) UserCommand(route string, ...)
- type NumberOption
- type Option
- type OptionType
- type OptionsInteractions
- func (o OptionsInteractions) Any(k string) (any, error)
- func (o OptionsInteractions) Bool(k string) (bool, error)
- func (o OptionsInteractions) Float32(k string) (float32, error)
- func (o OptionsInteractions) Float64(k string) (float64, error)
- func (o OptionsInteractions) Int(k string) (int, error)
- func (o OptionsInteractions) Int32(k string) (int32, error)
- func (o OptionsInteractions) Int64(k string) (int64, error)
- func (o OptionsInteractions) MarshalJSON() ([]byte, error)
- func (o OptionsInteractions) Snowflake(k string) (Snowflake, error)
- func (o OptionsInteractions) String(k string) (string, error)
- func (o OptionsInteractions) Uint(k string) (uint, error)
- func (o OptionsInteractions) Uint32(k string) (uint32, error)
- func (o OptionsInteractions) Uint64(k string) (uint64, error)
- func (o *OptionsInteractions) UnmarshalJSON(b []byte) error
- type Overwrite
- type PartialCommandInteraction
- type PartialRoutingType
- type Provider
- type Reaction
- type Resolved
- type ResolvedData
- type ResolvedDataConstraint
- type RespB
- func (b *RespB) ActionRow(c ...Component) *RespB
- func (r *RespB) AllowedMentions(a *AllowedMentions) *RespB
- func (b *RespB) Attachment(body io.Reader, filename string) *RespB
- func (b *RespB) Attachments(a ...Attachment) *RespB
- func (b *RespB) Choice(name string, value any) *RespB
- func (b *RespB) Choices(c ...Choice[any]) *RespB
- func (b *RespB) Components(c ...Component) *RespB
- func (r *RespB) Content(s string) *RespB
- func (r *RespB) Contentf(s string, args ...any) *RespB
- func (r *RespB) Embeds(e ...Embedder) *RespB
- func (r *RespB) Ephemeral() *RespB
- func (r *RespB) Flags(i IntResponseFlags) *RespB
- func (r *RespB) InteractionRespData() *InteractionRespData
- func (r *RespB) TTS(tts bool) *RespB
- type Responder
- type ResponseWriter
- type Role
- type RoleOption
- type SelectInteractionData
- type SelectOption
- type SlashCommandInteractionData
- func (i SlashCommandInteractionData) OptionsMember(k string) (Member, error)
- func (i SlashCommandInteractionData) OptionsMessage(k string) (Message, error)
- func (i SlashCommandInteractionData) OptionsRole(k string) (Role, error)
- func (i SlashCommandInteractionData) OptionsUser(k string) (User, error)
- type Snowflake
- type Sticker
- type StickerFormat
- type StickerItem
- type StringOption
- type Style
- type SubcommandGroupOption
- type SubcommandOption
- type Team
- type TeamMember
- type TextInputComponent
- type TextInputInteractionData
- type Thumbnail
- type Timestamp
- type User
- type UserCommandInteractionData
- type UserOption
- type Video
Constants ¶
const ( // RouteInteractionSubcommandGroup represents the map key for a subcommand group route RouteInteractionSubcommandGroup = "$group" // RouteInteractionSubcommand reprensents the map key for a subcommand route RouteInteractionSubcommand = "$command" // RouteInteractionFocused represents the map key for a focused route. // This is useful for autocomplete interactions so we can route on focused keys // Such, we route on `$group/$command/$focused`, RouteInteractionFocused = "$focused" )
const ( CHANNEL_GUILD_TEXT ChannelType = iota CHANNEL_DM CHANNEL_GUILD_VOICE CHANNEL_GROUP_DM CHANNEL_GUILD_CATEGORY CHANNEL_GUILD_NEWS CHANNEL_GUILD_STORE CHANNEL_GUILD_NEWS_THREAD = iota + 3 CHANNEL_GUILD_PUBLIC_THREAD CHANNEL_GUILD_PRIVATE_THREAD CHANNEL_GUILD_STAGE_VOICE )
const ( MESSAGE_ACTIVITY_JOIN = 1 MESSAGE_ACTIVITY_SPECTATE = 2 MESSAGE_ACTIVITY_LISTEN = 3 MESSAGE_ACTIVITY_JOIN_REQUEST = 5 )
https://regex101.com/r/Sj1ZLk/1
const ( // MESSAGE_FLAG_CROSSPOSTED means this message has been published to subscribed channels (via Channel Following) MESSAGE_FLAG_CROSSPOSTED = 1 << 0 // MESSAGE_FLAG_IS_CROSSPOST means this message originated from a message in another channel (via Channel Following) MESSAGE_FLAG_IS_CROSSPOST = 1 << 1 // MESSAGE_FLAG_SUPPRESS_EMBEDS means do not include any embeds when serializing this message MESSAGE_FLAG_SUPPRESS_EMBEDS = 1 << 2 // MESSAGE_FLAG_SOURCE_MESSAGE_DELETED means the source message for this crosspost has been deleted (via Channel Following) MESSAGE_FLAG_SOURCE_MESSAGE_DELETED = 1 << 3 // MESSAGE_FLAG_URGENT means this message came from the urgent message system MESSAGE_FLAG_URGENT = 1 << 4 // MESSAGE_FLAG_HAS_THREAD means this message has an associated thread, with the same id as the message MESSAGE_FLAG_HAS_THREAD = 1 << 5 // MESSAGE_FLAG_EPHEMERAL means this message is only visible to the user who invoked the Interaction MESSAGE_FLAG_EPHEMERAL = 1 << 6 // MESSAGE_FLAG_LOADING means this message is an Interaction Response and the bot is "thinking" MESSAGE_FLAG_LOADING = 1 << 7 )
Variables ¶
This section is empty.
Functions ¶
func GuildOpt ¶
func GuildOpt(guildID Snowflake) func(*CommandsOpt)
GuildOpt is an option for setting the guild of a Command
Types ¶
type Activity ¶
type Activity struct { Type int `json:"type,omitempty"` PartyID string `json:"party_id,omitempty"` }
Activity https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure
type AllowedMentions ¶
type AllowedMentions struct {
Parse []string `json:"parse"`
}
type Application ¶
type Application struct { ID Snowflake `json:"id"` Name string `json:"name"` Icon string `json:"icon"` Description string `json:"description"` RPCOrigins []string `json:"rpc_origins,omitempty"` BotPublic bool `json:"bot_public"` BotRequireCodeGrant bool `json:"bot_require_code_grant"` TermsOfServiceURL string `json:"terms_of_service_url,omitempty"` PrivacyPolicyURL string `json:"privacy_policy_url,omitempty"` Owner User `json:"owner,omitempty"` Summary string `json:"summary"` VerifyKey string `json:"verify_key"` Team Team `json:"team,omitempty"` GuildID Snowflake `json:"guild_id,omitempty"` PrimarySKUID Snowflake `json:"primary_sku_id,omitempty"` Slug string `json:"slug,omitempty"` CoverImage string `json:"cover_image,omitempty"` Flags int `json:"flags,omitempty"` }
Application https://discord.com/developers/docs/resources/application#application-object-application-structure
type Attachment ¶
type Attachment struct { Body io.Reader `json:"-"` ID Snowflake `json:"id"` Filename string `json:"filename"` Description string `json:"description,omitempty"` ContentType string `json:"content_type,omitempty"` Size int `json:"size,omitempty"` URL string `json:"url,omitempty"` ProxyURL string `json:"proxy_url,omitempty"` Height int `json:"height,omitempty"` Width int `json:"width,omitempty"` Ephemeral bool `json:"ephemeral,omitempty"` }
Attachement is the files attached to the request
type Author ¶
type Author struct { Name string `json:"name"` URL string `json:"url,omitempty"` IconURL string `json:"icon_url,omitempty"` ProxyIconURL string `json:"proxy_icon_url,omitempty"` }
Author is the author object
type AutocompleteInteractionData ¶ added in v0.8.0
type AutocompleteInteractionData struct { ID Snowflake `json:"id"` Name string `json:"name"` Type int `json:"type"` Options OptionsInteractions `json:"options,omitempty"` }
type BoolOption ¶
type BoolOption struct { Name string Description string Required bool Choices []Choice[any] ChannelTypes []ChannelType Autocomplete bool }
BoolOption represents a bool option
func NewBoolOption ¶
func NewBoolOption(name string, description string, required bool, choices ...Choice[bool]) *BoolOption
NewBoolOption returns a new BoolOption
func (*BoolOption) ChanTypes ¶
func (o *BoolOption) ChanTypes(typs ...ChannelType) *BoolOption
ChanTypes sets the options channel types
func (*BoolOption) MarshalJSON ¶
func (o *BoolOption) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of the option
type Button ¶
type Button struct { Type ComponentType `json:"type"` Style Style `json:"style"` Label string `json:"label,omitempty"` Emoji Emoji `json:"emoji,omitempty"` CustomID string `json:"custom_id,omitempty"` URL string `json:"url,omitempty"` Disabled bool `json:"disabled,omitempty"` }
Button https://discord.com/developers/docs/interactions/message-components#button-object
type ButtonInteractionData ¶ added in v0.8.0
type ButtonInteractionData struct { CustomID string `json:"custom_id,omitempty"` ComponentType ComponentType `json:"component_type"` }
type Channel ¶
type Channel struct { ID Snowflake `json:"id"` Name string `json:"name"` Type ChannelType `json:"type"` GuildID Snowflake `json:"guild_id"` Position int `json:"position"` PermissionOverwrites []Overwrite `json:"permission_overwrites"` Topic string `json:"topic,omitempty"` NSFW bool `json:"nsfw,omitempty"` LastMessageID Snowflake `json:"last_message_id,omitempty"` Bitrate int `json:"bitrate,omitempty"` UserLimit int `json:"user_limit,omitempty"` RateLimitPerUser int `json:"rate_limit_per_user,omitempty"` LastPinTimestamp Timestamp `json:"last_pin_timestamp,omitempty"` OwnerID Snowflake `json:"owner_id,omitempty"` }
Channel https://discord.com/developers/docs/resources/channel#channel-object
type ChannelOption ¶
type ChannelOption struct { Name string Description string Required bool Choices []Choice[any] ChannelTypes []ChannelType Autocomplete bool }
ChannelOption represents a Snowflake option
func NewChannelOption ¶
func NewChannelOption(name string, description string, required bool, choices ...Choice[Snowflake]) *ChannelOption
NewChannelOption returns a new ChannelOption
func (*ChannelOption) ChanTypes ¶
func (o *ChannelOption) ChanTypes(typs ...ChannelType) *ChannelOption
ChanTypes sets the options channel types
func (*ChannelOption) MarshalJSON ¶
func (o *ChannelOption) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of the option
type ChannelType ¶
type ChannelType int
ChannelType is the type of a channel https://discord.com/developers/docs/resources/channel#channel-object-channel-types
type Command ¶
type Command struct { Name string `json:"name,omitempty"` ID Snowflake `json:"id,omitempty"` Type CommandType `json:"type,omitempty"` ApplicationID Snowflake `json:"application_id,omitempty"` GuildID Snowflake `json:"guild_id,omitempty"` Description string `json:"description,omitempty"` Options []Option `json:"options,omitempty"` DefaultPermission bool `json:"default_permission,omitempty"` Version Snowflake `json:"version,omitempty"` }
Command is a Discord application command
type CommandType ¶
type CommandType int
const ( COMMAND_CHAT_INPUT CommandType = iota + 1 COMMAND_USER COMMAND_MESSAGE )
type CommandsOpt ¶
type CommandsOpt struct {
// contains filtered or unexported fields
}
CommandsOpt is an option for a Command
type Component ¶
type Component struct { Type ComponentType `json:"type"` CustomID string `json:"custom_id"` Style Style `json:"style,omitempty"` Disabled bool `json:"disabled,omitempty"` Label string `json:"label,omitempty"` Emoji *Emoji `json:"emoji,omitempty"` URL string `json:"url,omitempty"` Placeholder string `json:"placeholder,omitempty"` MinValues int `json:"min_values,omitempty"` MaxValues int `json:"max_values,omitempty"` MinLength int `json:"min_length,omitempty"` MaxLength int `json:"max_length,omitempty"` Required bool `json:"required,omitempty"` Value string `json:"value,omitempty"` Options []Option `json:"options,omitempty"` Components []Component `json:"components,omitempty"` }
Component
https://discord.com/developers/docs/interactions/message-components#component-object-component-types
type ComponentType ¶
type ComponentType int
ComponentType https://discord.com/developers/docs/interactions/message-components#button-object
const ( COMPONENT_ACTION_ROW ComponentType = iota + 1 COMPONENT_BUTTON COMPONENT_SELECT_MENU COMPONENT_TEXT_INPUT )
type CreateCommand ¶
type CreateCommand struct { 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"` }
CreateCommand is a slash command that can be registered to discord
func NewMessageCommand ¶
func NewMessageCommand(name string) CreateCommand
NewMessageCommand returns a new message command
func NewSlashCommand ¶
func NewSlashCommand(name string, description string, options ...CreateOptioner) CreateCommand
NewSlashCommand returns a new slash command
func NewUserCommand ¶
func NewUserCommand(name string) CreateCommand
NewUserCommand returns a new user command
func (CreateCommand) MarshalJSON ¶
func (c CreateCommand) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler
type CreateCommander ¶
type CreateCommander interface {
// contains filtered or unexported methods
}
CreateCommander is a command that can be registered
type CreateOption ¶
type CreateOption struct { Name string `json:"name"` Type OptionType `json:"type"` Description string `json:"description,omitempty"` Required bool `json:"required,omitempty"` Choices []Choice[any] `json:"choices,omitempty"` Options []CreateOptioner `json:"options,omitempty"` ChannelTypes []ChannelType `json:"channel_types,omitempty"` MinValue float64 `json:"min_value,omitempty"` MaxValue float64 `json:"max_value,omitempty"` Autocomplete bool `json:"autocomplete,omitempty"` }
CreateOption is the base option type for creating any sort of option
type CreateOptioner ¶
type CreateOptioner interface {
// contains filtered or unexported methods
}
CreateOptioner is an interface for all options
type Embed ¶
type Embed struct { Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` URL string `json:"url,omitempty"` Timestamp *Timestamp `json:"timestamp,omitempty"` Color uint32 `json:"color,omitempty"` Image Image `json:"image,omitempty"` Thumbnail Image `json:"thumbnail,omitempty"` Video Video `json:"video,omitempty"` Provider Provider `json:"provider,omitempty"` Author Author `json:"author,omitempty"` Fields []Field `json:"fields,omitempty"` }
Embed is the embed object https://discord.com/developers/docs/resources/channel#embed-object
func (Embed) InteractionRespData ¶
func (e Embed) InteractionRespData() *InteractionRespData
InteractionRespData implements InteractionResponder
type EmbedB ¶
type EmbedB struct {
// contains filtered or unexported fields
}
EmbedB is an Embed builder https://regex101.com/r/gmVH2A/4
func (*EmbedB) Description ¶
Description adds the description to the Embed
func (*EmbedB) Descriptionf ¶
Descriptionf adds the description to the Embed
func (*EmbedB) FieldInline ¶
FieldInline adds an inline field to the Embed
func (*EmbedB) InteractionRespData ¶
func (e *EmbedB) InteractionRespData() *InteractionRespData
InteractionRespData implements InteractionResponder
type Emoji ¶
type Emoji struct { ID Snowflake `json:"id,omitempty"` Name string `json:"name"` Roles []Snowflake `json:"roles,omitempty"` User User `json:"user,omitempty"` RequireColons bool `json:"require_colons,omitempty"` Managed bool `json:"managed,omitempty"` Animated bool `json:"animated,omitempty"` Available bool `json:"available,omitempty"` }
Emoji https://discord.com/developers/docs/resources/emoji#emoji-object
type Field ¶
type Field struct { Name string `json:"name"` Value string `json:"value"` Inline bool `json:"inline,omitempty"` }
Field is the field object inside an embed
type Handlers ¶ added in v0.8.0
type Handlers map[InnerInteractionType]any
Handlers handles incoming requests
type Hash ¶
type Hash string
Hash is a discord profile picture hash https://discord.com/developers/docs/reference#image-formatting
type Image ¶
type Image struct { URL string `json:"url,omitempty"` ProxyURL string `json:"proxy_url,omitempty"` Height int `json:"height,omitempty"` Width int `json:"width,omitempty"` }
Image is an image possibly contained inside the embed
type InnerInteractionType ¶ added in v0.8.0
type InnerInteractionType int
InnerInteractionType is the inner type of interactions, and not just command, component, autocomplete etc.
const ( // components ActionRowInteraction InnerInteractionType = iota + 1 ButtonInteraction SelectMenuInteraction TextInputInteraction // autocomplete AutocompleteInteraction // commands SlashCommandInteraction UserCommandInteraction MessageCommandInteraction ModalInteraction )
type IntOption ¶
type IntOption struct { Name string Description string Required bool Choices []Choice[any] ChannelTypes []ChannelType Autocomplete bool }
IntOption represents a int option
func NewIntOption ¶
func NewIntOption(name string, description string, required bool, choices ...Choice[int]) *IntOption
NewIntOption returns a new IntOption
func (*IntOption) CanAutocomplete ¶
CanAutocomplete sets the option as autocomplete-able
func (*IntOption) ChanTypes ¶
func (o *IntOption) ChanTypes(typs ...ChannelType) *IntOption
ChanTypes sets the options channel types
func (*IntOption) MarshalJSON ¶
MarshalJSON returns the JSON representation of the option
type IntResponseFlags ¶
type IntResponseFlags uint
const (
RESPONSE_FLAGS_EPHEMERAL IntResponseFlags = 64
)
type Interaction ¶
type Interaction[T InteractionDataConstraint] struct { ID Snowflake `json:"id"` ApplicationID Snowflake `json:"application_id"` Type InteractionType `json:"type"` Data T `json:"data,omitempty"` GuildID Snowflake `json:"guild_id,omitempty"` ChannelID Snowflake `json:"channel_id,omitempty"` Member Member `json:"member,omitempty"` User *User `json:"user,omitempty"` Token string `json:"token"` Version int `json:"version"` Message *Message `json:"message,omitempty"` Locale string `json:"locale,omitempty"` GuildLocale string `json:"guild_locale,omitempty"` Route string `json:"-"` InnerInteractionType InnerInteractionType `json:"-"` }
Interaction is a Discord Interaction https://discord.com/developers/docs/interactions/receiving-and-responding#interactions
type InteractionDataConstraint ¶ added in v0.8.0
type InteractionDataConstraint interface { JsonRaw | ButtonInteractionData | SelectInteractionData | TextInputInteractionData | ModalInteractionData | UserCommandInteractionData | MessageCommandInteractionData | SlashCommandInteractionData | AutocompleteInteractionData | PartialCommandInteraction }
InteractionDataConstraint is the constraint for the interaction data It contains all the possible values for interaction data
type InteractionRespData ¶
type InteractionRespData struct { Content string `json:"content,omitempty"` TTS bool `json:"tts,omitempty"` Embeds []Embed `json:"embeds,omitempty"` AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"` Flags IntResponseFlags `json:"flags,omitempty"` Components []Component `json:"components,omitempty"` Attachments []Attachment `json:"attachments,omitempty"` Choices []Choice[any] `json:"choices,omitempty"` }
InteractionRespData is the payload for responding to an interaction https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-data-structure
func (*InteractionRespData) InteractionRespData ¶
func (i *InteractionRespData) InteractionRespData() *InteractionRespData
InteractionRespData implements InteractionResponder interface
type InteractionResponder ¶
type InteractionResponder interface {
InteractionRespData() *InteractionRespData
}
InteractionResponder returns InteractionRespData
type InteractionType ¶
type InteractionType int
InteractionType is the type of interaction
const ( INTERACTION_TYPE_PING InteractionType = iota + 1 INTERACTION_TYPE_APPLICATION_COMMAND INTERACTION_TYPE_MESSAGE_COMPONENT INTERACTION_TYPE_APPLICATION_COMMAND_AUTOCOMPLETE INTERACTION_TYPE_MODAL )
type JsonRaw ¶
type JsonRaw []byte
JsonRaw is a raw json value
func (JsonRaw) MarshalJSON ¶
MarshalJSON returns m as the JSON encoding of m.
func (*JsonRaw) UnmarshalJSON ¶
UnmarshalJSON sets *m to a copy of data.
func (JsonRaw) UnmarshalTo ¶
UnmarshalTo unmarshals the JSON-encoded data and stores the result in the value pointed to by v.
type Member ¶
type Member struct { User User `json:"user"` Nick string `json:"nick,omitempty"` RoleIDs []Snowflake `json:"roles,omitempty"` Avatar Hash `json:"avatar,omitempty"` Joined Timestamp `json:"joined_at"` BoostedSince Timestamp `json:"premium_since,omitempty"` CommunicationDisabledUntil Timestamp `json:"communication_disabled_until,omitempty"` Deaf bool `json:"deaf,omitempty"` Mute bool `json:"mute,omitempty"` IsPending bool `json:"pending,omitempty"` Permissions string `json:"permissions,omitempty"` }
Member is a Discord Member https://discord.com/developers/docs/resources/guild#guild-member-object
type MentionableOption ¶
type MentionableOption struct { Name string Description string Required bool Choices []Choice[any] ChannelTypes []ChannelType Autocomplete bool }
MentionableOption represents a Snowflake option
func NewMentionableOption ¶
func NewMentionableOption(name string, description string, required bool, choices ...Choice[Snowflake]) *MentionableOption
NewMentionableOption returns a new MentionableOption
func (*MentionableOption) ChanTypes ¶
func (o *MentionableOption) ChanTypes(typs ...ChannelType) *MentionableOption
ChanTypes sets the options channel types
func (*MentionableOption) MarshalJSON ¶
func (o *MentionableOption) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of the option
type Message ¶
type Message struct { ID Snowflake `json:"id"` ChannelID Snowflake `json:"channel_id"` GuildID Snowflake `json:"guild_id,omitempty"` Author User `json:"user,omitempty"` Member Member `json:"member,omitempty"` Content string `json:"content"` Timestamp Timestamp `json:"timestamp"` Edited Timestamp `json:"edited_timestamp,omitempty"` TTS bool `json:"tts"` Mention bool `json:"mention_everyone"` Mentions []User `json:"mentions,omitempty"` MentionRoles []Snowflake `json:"mention_roles,omitempty"` MentionChannels []Channel `json:"mention_channels,omitempty"` Attachments []Attachment `json:"attachments,omitempty"` Embeds []Embed `json:"embeds,omitempty"` Reactions []Reaction `json:"reactions,omitempty"` Nonce string `json:"nonce,omitempty"` Pinned bool `json:"pinned,omitempty"` WebhookID Snowflake `json:"webhook_id,omitempty"` Type MessageType `json:"type"` Activity *Activity `json:"activity,omitempty"` Application Application `json:"application,omitempty"` ApplicationID Snowflake `json:"application_id,omitempty"` MessageReference *MessageReference `json:"message_reference,omitempty"` Flags MessageFlag `json:"flags,omitempty"` ReferencedMessage *Message `json:"referenced_message,omitempty"` Interaction *Interaction[JsonRaw] `json:"interaction,omitempty"` Thread Channel `json:"thread,omitempty"` Components []Component `json:"components,omitempty"` StickerItems []StickerItem `json:"sticker_items,omitempty"` Stickers []Sticker `json:"stickers,omitempty"` }
Message is a Discord Message https://discord.com/developers/docs/resources/channel#message-object
type MessageActivity ¶
type MessageActivity int
MessageActivity https://discord.com/developers/docs/resources/channel#message-object-message-activity-types
type MessageCommandInteractionData ¶ added in v0.8.0
type MessageCommandInteractionData struct { ID Snowflake `json:"id"` TargetID Snowflake `json:"target_id,omitempty"` Name string `json:"name"` Type int `json:"type"` // contains filtered or unexported fields }
func (MessageCommandInteractionData) OptionsMember ¶ added in v0.8.0
OptionsMember returns the resolved Member (and User) for an Option
func (MessageCommandInteractionData) OptionsMessage ¶ added in v0.8.0
OptionsMessage returns the resolved Message for an Option
func (MessageCommandInteractionData) OptionsRole ¶ added in v0.8.0
OptionsRole returns the resolved Role for an Option
func (MessageCommandInteractionData) OptionsUser ¶ added in v0.8.0
OptionsUser returns the resolved User for an Option
type MessageFlag ¶
type MessageFlag int
MessageFlag https://discord.com/developers/docs/resources/channel#message-object-message-flags
type MessageReference ¶
type MessageReference struct {
MessageID Snowflake `json:"message_id"`
}
type MessageType ¶
type MessageType int
MessageType https://discord.com/developers/docs/resources/channel#message-object-message-types
const ( MESSAGE_TYPE_DEFAULT MessageType = 0 MESSAGE_TYPE_RECIPIENT_ADD MessageType = 1 MESSAGE_TYPE_RECIPIENT_REMOVE MessageType = 2 MESSAGE_TYPE_CALL MessageType = 3 MESSAGE_TYPE_CHANNEL_NAME_CHANGE MessageType = 4 MESSAGE_TYPE_CHANNEL_ICON_CHANGE MessageType = 5 MESSAGE_TYPE_CHANNEL_PINNED_MESSAGE MessageType = 6 MESSAGE_TYPE_GUILD_MEMBER_JOIN MessageType = 7 MESSAGE_TYPE_USER_PREMIUM_GUILD_SUBSCRIPTION MessageType = 8 MESSAGE_TYPE_USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1 MessageType = 9 MESSAGE_TYPE_USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2 MessageType = 10 MESSAGE_TYPE_USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 MessageType = 11 MESSAGE_TYPE_CHANNEL_FOLLOW_ADD MessageType = 12 MESSAGE_TYPE_GUILD_DISCOVERY_DISQUALIFIED MessageType = 14 MESSAGE_TYPE_GUILD_DISCOVERY_REQUALIFIED MessageType = 15 MESSAGE_TYPE_GUILD_DISCOVERY_GRACE_PERIOD_INITIAL_WARNING MessageType = 16 MESSAGE_TYPE_GUILD_DISCOVERY_GRACE_PERIOD_FINAL_WARNING MessageType = 17 MESSAGE_TYPE_THREAD_CREATED MessageType = 18 MESSAGE_TYPE_REPLY MessageType = 19 MESSAGE_TYPE_CHAT_INPUT_COMMAND MessageType = 20 MESSAGE_TYPE_THREAD_STARTER_MESSAGE MessageType = 21 MESSAGE_TYPE_GUILD_INVITE_REMINDER MessageType = 22 MESSAGE_TYPE_CONTEXT_MENU_COMMAND MessageType = 23 )
We could have used iota, but this scales better https://regex101.com/r/a3XWNs/1
type Modal ¶ added in v0.8.0
type Modal struct { Title string `json:"title"` CustomID string `json:"custom_id"` Components []Component `json:"components"` }
Modal represents a discord modal. when marshalled, it is wrapped in an action row. Thus, the components it should contain are the actual components you want displayed, rather than an action row wrapping them.
https://discord.com/developers/docs/interactions/message-components#text-inputs-text-input-styles
func (Modal) MarshalJSON ¶ added in v0.8.0
type ModalInteractionData ¶ added in v0.8.0
type Mux ¶
type Mux struct { PublicKey string // the hex public key provided by discord BasePath string // base route path, default is "/" OnNotFound func(context.Context, ResponseWriter, *Interaction[JsonRaw]) Client *http.Client AppID Snowflake BotToken string // contains filtered or unexported fields }
Mux is a discord gateway muxer, which handles the routing
func NewMux ¶
NewMux returns a new mux for routing slash commands
When you mount a command on the mux, it's prefix based routed, which means you can route to a button like `/list/next/456132153` having mounted `/list/next`
func (*Mux) Autocomplete ¶
func (m *Mux) Autocomplete(route string, handler func(context.Context, ResponseWriter, *Interaction[AutocompleteInteractionData]))
Autocomplete mounts an autocomplete route on the mux
func (*Mux) BulkRegisterCommand ¶
func (m *Mux) BulkRegisterCommand(c []CreateCommander, options ...func(*CommandsOpt)) error
BulkRegisterCommand registers a slice of Command on discord
func (*Mux) ButtonComponent ¶ added in v0.8.0
func (m *Mux) ButtonComponent(route string, handler func(context.Context, ResponseWriter, *Interaction[ButtonInteractionData]))
ButtonComponent mounts a button route on the mux
func (*Mux) CreateMessage ¶ added in v0.8.1
CreateMessage creates a new message in a channel
https://discord.com/developers/docs/resources/channel#create-message
func (*Mux) DeleteCommand ¶
func (m *Mux) DeleteCommand(ID Snowflake, options ...func(*CommandsOpt)) error
DeleteCommand deletes a Command from discord
func (*Mux) DeleteFollowUpInteraction ¶
DeleteFollowUpInteraction to delete a response to a FollowUpInteraction
https://discord.com/developers/docs/interactions/receiving-and-responding#delete-followup-message
func (*Mux) DeleteOriginalInteraction ¶
DeleteOriginalInteraction to delete your initial response to an Interaction
func (*Mux) EditFollowUpInteraction ¶
func (m *Mux) EditFollowUpInteraction(token string, messageID Snowflake, data InteractionResponder) error
EditFollowUpInteraction to edit a response to a FollowUpInteraction
https://discord.com/developers/docs/interactions/receiving-and-responding#edit-followup-message
func (*Mux) EditOriginalInteraction ¶
func (m *Mux) EditOriginalInteraction(token string, data InteractionResponder) error
EditOriginalInteraction to edit your initial response to an Interaction
func (*Mux) FollowUpInteraction ¶
func (m *Mux) FollowUpInteraction(token string, data InteractionResponder) error
FollowUpInteraction follows up a response to an Interaction
https://discord.com/developers/docs/interactions/receiving-and-responding#followup-messages
func (*Mux) GetCommands ¶
func (m *Mux) GetCommands(options ...func(*CommandsOpt)) ([]Command, error)
GetCommands returns a slice of Command from the Mux
func (*Mux) GetFollowUpInteraction ¶
func (m *Mux) GetFollowUpInteraction(token string, messageID Snowflake) (*InteractionRespData, error)
GetFollowUpInteraction returns the response to a FollowUpInteraction
https://discord.com/developers/docs/interactions/receiving-and-responding#get-followup-message
func (*Mux) GetOriginalInteraction ¶
func (m *Mux) GetOriginalInteraction(token string) (*InteractionRespData, error)
GetOriginalInteraction returns the original response to an Interaction
func (*Mux) ListenAndServe ¶
ListenAndServe starts the gateway listening to events
func (*Mux) MessageCommand ¶ added in v0.8.0
func (m *Mux) MessageCommand(route string, handler func(context.Context, ResponseWriter, *Interaction[MessageCommandInteractionData]))
MessageCommand mounts a message command on the mux
func (*Mux) Modal ¶ added in v0.8.0
func (m *Mux) Modal(route string, handler func(context.Context, ResponseWriter, *Interaction[ModalInteractionData]))
Modal mounts a modal interaction response on the mux
func (*Mux) Mount ¶
func (m *Mux) Mount(typ InnerInteractionType, route string, handler any)
Mount is for mounting a Handler on the Mux
func (*Mux) RegisterCommand ¶
func (m *Mux) RegisterCommand(c CreateCommander, options ...func(*CommandsOpt)) error
RegisterCommand registers a new Command on discord
func (*Mux) ServeHTTP ¶
func (m *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP will serve HTTP requests with discord public key validation
func (*Mux) SlashCommand ¶ added in v0.8.0
func (m *Mux) SlashCommand(route string, handler func(context.Context, ResponseWriter, *Interaction[SlashCommandInteractionData]))
SlashCommand mounts a slash command route on the mux
func (*Mux) UserCommand ¶ added in v0.8.0
func (m *Mux) UserCommand(route string, handler func(context.Context, ResponseWriter, *Interaction[UserCommandInteractionData]))
UserCommand mounts a user command on the mux
type NumberOption ¶
type NumberOption struct { Name string Description string Required bool Choices []Choice[any] ChannelTypes []ChannelType Autocomplete bool }
NumberOption represents a float64 option
func NewNumberOption ¶
func NewNumberOption(name string, description string, required bool, choices ...Choice[float64]) *NumberOption
NewNumberOption returns a new NumberOption
func (*NumberOption) CanAutocomplete ¶
func (o *NumberOption) CanAutocomplete() *NumberOption
CanAutocomplete sets the option as autocomplete-able
func (*NumberOption) ChanTypes ¶
func (o *NumberOption) ChanTypes(typs ...ChannelType) *NumberOption
ChanTypes sets the options channel types
func (*NumberOption) MarshalJSON ¶
func (o *NumberOption) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of the option
type Option ¶
type Option struct { Name string `json:"name"` Type OptionType `json:"type"` Value JsonRaw `json:"value"` Description string `json:"description,omitempty"` Required bool `json:"required,omitempty"` Options []Option `json:"options,omitempty"` Choices []Choice[any] `json:"choices,omitempty"` Focused bool `json:"focused,omitempty"` }
Option is an option for an application Command
type OptionType ¶
type OptionType int
const ( OPTION_SUB_COMMAND OptionType = iota + 1 OPTION_SUB_COMMAND_GROUP OPTION_STRING OPTION_INTEGER OPTION_BOOLEAN OPTION_USER OPTION_CHANNEL OPTION_ROLE OPTION_MENTIONABLE OPTION_NUMBER )
type OptionsInteractions ¶
OptionsInteractions is the options for an Interaction
func (OptionsInteractions) Any ¶
func (o OptionsInteractions) Any(k string) (any, error)
Any returns the Option with key k of type any
func (OptionsInteractions) Bool ¶
func (o OptionsInteractions) Bool(k string) (bool, error)
Bool returns the Option with key k of type bool
func (OptionsInteractions) Float32 ¶
func (o OptionsInteractions) Float32(k string) (float32, error)
Float32 returns the Option with key k of type float32
func (OptionsInteractions) Float64 ¶
func (o OptionsInteractions) Float64(k string) (float64, error)
Float64 returns the Option with key k of type float64
func (OptionsInteractions) Int ¶
func (o OptionsInteractions) Int(k string) (int, error)
Int returns the Option with key k of type int
func (OptionsInteractions) Int32 ¶
func (o OptionsInteractions) Int32(k string) (int32, error)
Int32 returns the Option with key k of type int32
func (OptionsInteractions) Int64 ¶
func (o OptionsInteractions) Int64(k string) (int64, error)
Int64 returns the Option with key k of type int64
func (OptionsInteractions) MarshalJSON ¶
func (o OptionsInteractions) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler
func (OptionsInteractions) Snowflake ¶
func (o OptionsInteractions) Snowflake(k string) (Snowflake, error)
Snowflake returns the Option with key k of type Snowflake
func (OptionsInteractions) String ¶
func (o OptionsInteractions) String(k string) (string, error)
String returns the Option with key k of type string
func (OptionsInteractions) Uint ¶
func (o OptionsInteractions) Uint(k string) (uint, error)
Uint returns the Option with key k of type uint
func (OptionsInteractions) Uint32 ¶
func (o OptionsInteractions) Uint32(k string) (uint32, error)
Uint32 returns the Option with key k of type uint32
func (OptionsInteractions) Uint64 ¶
func (o OptionsInteractions) Uint64(k string) (uint64, error)
Uint64 returns the Option with key k of type uint64
func (*OptionsInteractions) UnmarshalJSON ¶
func (o *OptionsInteractions) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler
type Overwrite ¶
type Overwrite struct { ID Snowflake `json:"id"` // Type: 0 = @role, 1 = @user Type int `json:"type"` // Permission bit set Allow string `json:"allow"` // Permission bit set Deny string `json:"deny"` }
Overwrite https://discord.com/developers/docs/resources/channel#overwrite-object
type PartialCommandInteraction ¶ added in v0.8.0
type PartialRoutingType ¶ added in v0.8.0
type PartialRoutingType struct { ID Snowflake `json:"id"` Type int `json:"type"` ComponentType int `json:"component_type"` Name string `json:"name"` CustomID string `json:"custom_id"` // contains filtered or unexported fields }
func (PartialRoutingType) OptionsMember ¶ added in v0.8.0
OptionsMember returns the resolved Member (and User) for an Option
func (PartialRoutingType) OptionsMessage ¶ added in v0.8.0
OptionsMessage returns the resolved Message for an Option
func (PartialRoutingType) OptionsRole ¶ added in v0.8.0
OptionsRole returns the resolved Role for an Option
func (PartialRoutingType) OptionsUser ¶ added in v0.8.0
OptionsUser returns the resolved User for an Option
type Resolved ¶
type Resolved struct { Users ResolvedData[User] `json:"users,omitempty"` Members ResolvedData[Member] `json:"members,omitempty"` Roles ResolvedData[Role] `json:"roles,omitempty"` Messages ResolvedData[Message] `json:"messages,omitempty"` }
type ResolvedData ¶
type ResolvedData[T ResolvedDataConstraint] map[Snowflake]T
ResolvedData is a generic mapping of Snowflakes to resolved data structs
func (ResolvedData[T]) First ¶
func (r ResolvedData[T]) First() T
First returns the first resolved data ResolvedData is a map (which is unordered), so First should only be used when ResolvedData has a single element.
type ResolvedDataConstraint ¶
type RespB ¶
type RespB struct {
// contains filtered or unexported fields
}
RespB is an InteractionRespData builder
func (*RespB) AllowedMentions ¶
func (r *RespB) AllowedMentions(a *AllowedMentions) *RespB
AllowedMentions adds the allowed mentions to the InteractionRespData
func (*RespB) Attachment ¶
Attachement adds an attachment to the InteractionRespData
func (*RespB) Attachments ¶
func (b *RespB) Attachments(a ...Attachment) *RespB
Attachments adds attachments to the InteractionRespData
func (*RespB) Components ¶
Components adds components to the InteractionRespData
func (*RespB) Flags ¶
func (r *RespB) Flags(i IntResponseFlags) *RespB
Flags adds the flags to the InteractionRespData
func (*RespB) InteractionRespData ¶
func (r *RespB) InteractionRespData() *InteractionRespData
InteractionRespData implements InteractionResponder
type Responder ¶
type Responder struct {
// contains filtered or unexported fields
}
Responder loosely maps to the discord gateway response https://discord.com/developers/docs/interactions/receiving-and-responding#responding-to-an-interaction
func (*Responder) Ack ¶ added in v0.8.0
func (r *Responder) Ack()
Pong responds to pings on the gateway
func (*Responder) Autocomplete ¶
func (r *Responder) Autocomplete(i InteractionResponder)
Autocomplete responds to the interaction with autocomplete data
func (*Responder) DeferedRespond ¶
func (r *Responder) DeferedRespond()
DeferedRespond responds in defered
func (*Responder) DeferedUpdate ¶
func (r *Responder) DeferedUpdate()
DeferedUpdate updates the target message in defered
func (*Responder) Respond ¶
func (r *Responder) Respond(i InteractionResponder)
Respond responds to the interaction directly
func (*Responder) Update ¶
func (r *Responder) Update(i InteractionResponder)
Update updates the target message
type ResponseWriter ¶
type ResponseWriter interface { Ack() Respond(InteractionResponder) DeferedRespond() Update(InteractionResponder) DeferedUpdate() Autocomplete(InteractionResponder) Modal(Modal) }
ResponseWriter handles responding to interactions https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-interaction-callback-type
type Role ¶
type Role struct { ID Snowflake `json:"id"` Name string `json:"name"` Permissions uint64 `json:"permissions,string"` Position int `json:"position"` Color uint32 `json:"color"` Hoist bool `json:"hoist"` Managed bool `json:"managed"` Mentionable bool `json:"mentionable"` }
Role is a user's role https://discord.com/developers/docs/topics/permissions#role-object
type RoleOption ¶
type RoleOption struct { Name string Description string Required bool Choices []Choice[any] ChannelTypes []ChannelType Autocomplete bool }
RoleOption represents a Snowflake option
func NewRoleOption ¶
func NewRoleOption(name string, description string, required bool, choices ...Choice[Snowflake]) *RoleOption
NewRoleOption returns a new RoleOption
func (*RoleOption) ChanTypes ¶
func (o *RoleOption) ChanTypes(typs ...ChannelType) *RoleOption
ChanTypes sets the options channel types
func (*RoleOption) MarshalJSON ¶
func (o *RoleOption) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of the option
type SelectInteractionData ¶ added in v0.8.0
type SelectInteractionData struct { CustomID string `json:"custom_id,omitempty"` ComponentType ComponentType `json:"component_type"` Values []any `json:"values,omitempty"` }
type SelectOption ¶
type SelectOption struct { Label string `json:"label"` Value string `json:"value"` Description string `json:"description,omitempty"` Emoji *Emoji `json:"emoji,omitempty"` Default bool `json:"default,omitempty"` }
SelectOption https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-option-structure
type SlashCommandInteractionData ¶ added in v0.8.0
type SlashCommandInteractionData struct { ID Snowflake `json:"id"` Name string `json:"name"` Type int `json:"type"` // contains filtered or unexported fields }
func (SlashCommandInteractionData) OptionsMember ¶ added in v0.8.0
OptionsMember returns the resolved Member (and User) for an Option
func (SlashCommandInteractionData) OptionsMessage ¶ added in v0.8.0
OptionsMessage returns the resolved Message for an Option
func (SlashCommandInteractionData) OptionsRole ¶ added in v0.8.0
OptionsRole returns the resolved Role for an Option
func (SlashCommandInteractionData) OptionsUser ¶ added in v0.8.0
OptionsUser returns the resolved User for an Option
type Snowflake ¶
type Snowflake uint64
Snowflake is a DiscordSnowflake ID
func SnowflakeFromString ¶
corde.SnowflakeFromString returns aSnowflake from a string
func (Snowflake) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*Snowflake) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type Sticker ¶
type Sticker struct { ID Snowflake `json:"id"` Name string `json:"name"` Tags string `json:"tags"` Asset string `json:"asset"` Type int `json:"type"` FormatType StickerFormat `json:"format_type"` Description string `json:"description,omitempty"` PackID Snowflake `json:"pack_id,omitempty"` Available bool `json:"available,omitempty"` GuildID Snowflake `json:"guild_id,omitempty"` User User `json:"user,omitempty"` SortValue int `json:"sort_value,omitempty"` }
Sticker https://discord.com/developers/docs/resources/sticker#sticker-object
type StickerFormat ¶
type StickerFormat int
https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types
const ( STICKER_FORMAT_PNG StickerFormat = iota + 1 STICKER_FORMAT_APNG STICKER_FORMAT_LOTTIE )
type StickerItem ¶
type StickerItem struct { ID Snowflake `json:"id"` Name string `json:"name"` FormatType StickerFormat `json:"format_type"` }
StickerItem
type StringOption ¶
type StringOption struct { Name string Description string Required bool Choices []Choice[any] ChannelTypes []ChannelType Autocomplete bool }
StringOption represents a string option
func NewStringOption ¶
func NewStringOption(name string, description string, required bool, choices ...Choice[string]) *StringOption
NewStringOption returns a new StringOption
func (*StringOption) CanAutocomplete ¶
func (o *StringOption) CanAutocomplete() *StringOption
CanAutocomplete sets the option as autocomplete-able
func (*StringOption) ChanTypes ¶
func (o *StringOption) ChanTypes(typs ...ChannelType) *StringOption
ChanTypes sets the options channel types
func (*StringOption) MarshalJSON ¶
func (o *StringOption) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of the option
type SubcommandGroupOption ¶
type SubcommandGroupOption struct { Name string Description string Options []CreateOptioner }
SubcommandGroupOption is an option that is a subcommand group
func NewSubcommandGroup ¶
func NewSubcommandGroup(name string, description string, options ...CreateOptioner) *SubcommandGroupOption
NewSubcommandGroup returns a new subcommand group
func (*SubcommandGroupOption) MarshalJSON ¶
func (o *SubcommandGroupOption) MarshalJSON() ([]byte, error)
type SubcommandOption ¶
type SubcommandOption struct { Name string Description string Options []CreateOptioner }
SubcommandOption is an option that is a subcommand
func NewSubcommand ¶
func NewSubcommand(name string, description string, options ...CreateOptioner) *SubcommandOption
NewSubcommand returns a new subcommand
func (*SubcommandOption) MarshalJSON ¶
func (o *SubcommandOption) MarshalJSON() ([]byte, error)
type Team ¶
type Team struct { Icon string `json:"icon,omitempty"` ID Snowflake `json:"id"` Members []TeamMember `json:"members"` Name string `json:"name"` OwnerUserID Snowflake `json:"owner_user_id"` }
Team https://discord.com/developers/docs/topics/teams#data-models-team-object
type TeamMember ¶
type TeamMember struct { MembershipState int `json:"membership_state"` // will always be ["*"] Permissions []string `json:"permissions"` TeamID Snowflake `json:"team_id"` User User `json:"user"` }
TeamMember https://discord.com/developers/docs/topics/teams#data-models-team-member-object
type TextInputComponent ¶ added in v0.8.0
type TextInputComponent struct { CustomID string `json:"custom_id"` Style Style `json:"style"` Label string `json:"label"` MinLength int `json:"min_length,omitempty"` MaxLength int `json:"max_length,omitempty"` Required bool `json:"required,omitempty"` Value string `json:"value,omitempty"` Placeholder string `json:"place_holder,omitempty"` }
TextInputComponent
https://discord.com/developers/docs/interactions/message-components#text-inputs-text-input-structure
func (TextInputComponent) Component ¶ added in v0.8.0
func (t TextInputComponent) Component() Component
type TextInputInteractionData ¶ added in v0.8.0
type TextInputInteractionData struct { CustomID string `json:"custom_id"` Title string `json:"title"` Style int `json:"style"` Label string `json:"label"` MinLenght int `json:"min_length,omitempty"` MaxLenght int `json:"max_length,omitempty"` Required bool `json:"required,omitempty"` Value string `json:"value,omitempty"` Placeholder string `json:"placeholder,omitempty"` Components []Component `json:"components"` }
type Timestamp ¶
Timestamp is a discord timestamp It is represented as a string in the ISO 8601 format
func (Timestamp) MarshalJSON ¶
func (*Timestamp) UnmarshalJSON ¶
type User ¶
type User struct { ID Snowflake `json:"id"` Username string `json:"username"` Discriminator string `json:"discriminator"` Avatar Hash `json:"avatar,omitempty"` Bot bool `json:"bot,omitempty"` System bool `json:"system,omitempty"` MFAEnabled bool `json:"mfa_enabled,omitempty"` Verified bool `json:"verified,omitempty"` Email string `json:"email,omitempty"` Flags int `json:"flags,omitempty"` Locale string `json:"locale,omitempty"` Banner string `json:"banner,omitempty"` AccentColor uint32 `json:"accent_color,omitempty"` PremiumType int `json:"premium_type,omitempty"` PublicFlags int `json:"public_flags,omitempty"` }
User is a Discord User
type UserCommandInteractionData ¶ added in v0.8.0
type UserCommandInteractionData struct { ID Snowflake `json:"id"` TargetID Snowflake `json:"target_id,omitempty"` Name string `json:"name"` Type int `json:"type"` // contains filtered or unexported fields }
func (UserCommandInteractionData) OptionsMember ¶ added in v0.8.0
OptionsMember returns the resolved Member (and User) for an Option
func (UserCommandInteractionData) OptionsMessage ¶ added in v0.8.0
OptionsMessage returns the resolved Message for an Option
func (UserCommandInteractionData) OptionsRole ¶ added in v0.8.0
OptionsRole returns the resolved Role for an Option
func (UserCommandInteractionData) OptionsUser ¶ added in v0.8.0
OptionsUser returns the resolved User for an Option
type UserOption ¶
type UserOption struct { Name string Description string Required bool Choices []Choice[any] ChannelTypes []ChannelType Autocomplete bool }
UserOption represents a Snowflake option
func NewUserOption ¶
func NewUserOption(name string, description string, required bool, choices ...Choice[Snowflake]) *UserOption
NewUserOption returns a new UserOption
func (*UserOption) ChanTypes ¶
func (o *UserOption) ChanTypes(typs ...ChannelType) *UserOption
ChanTypes sets the options channel types
func (*UserOption) MarshalJSON ¶
func (o *UserOption) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON representation of the option
Source Files
¶
- buttons.go
- commands.go
- embed-builder.go
- hash.go
- interaction-opt.gen.go
- interaction-response-builder.go
- interaction-responses.go
- interactions-api.go
- interactions.go
- json.go
- members.go
- messages-api.go
- messages.go
- mux-routes.go
- mux.go
- options.go
- register-cmd.gen.go
- register-commands.go
- resolved.go
- responder.go
- router.go
- snowflake.go
- users.go
Directories
¶
Path | Synopsis |
---|---|
0_example
|
|
Package format https://discord.com/developers/docs/reference#message-formatting
|
Package format https://discord.com/developers/docs/reference#message-formatting |
internal
|
|