Documentation ¶
Index ¶
- Constants
- Variables
- func CheckInSlice[T comparable](slice *[]T, item T) bool
- func JsonReshape[T interface{}](object interface{}) T
- func PrettyStructPrint(v any)
- func Reshape[T any](value any) (T, bool)
- type AutoCompleteInteraction
- type ButtonComponent
- type ButtonStyle
- type ChannelType
- type Choice
- type Client
- func (client Client) AwaitComponent(componentCustomIds []string, timeout time.Duration) (chan *Interaction, func())
- func (client Client) CrosspostMessage(channelId Snowflake, messageId Snowflake) error
- func (client Client) DeleteMessage(channelId Snowflake, messageId Snowflake) error
- func (client Client) EditMessage(channelId Snowflake, messageId Snowflake, content Message) error
- func (client Client) FetchMember(guildId Snowflake, memberId Snowflake) (Member, error)
- func (client Client) FetchUser(id Snowflake) (User, error)
- func (client Client) ListenAndServe(address string) error
- func (client Client) Ping() time.Duration
- func (client Client) RegisterCommand(command Command) error
- func (client Client) RegisterSubCommand(subCommand Command, rootCommandName string) error
- func (client Client) SendLinearMessage(channelId Snowflake, content string) (Message, error)
- func (client Client) SendMessage(channelId Snowflake, content Message) (Message, error)
- func (client Client) SyncCommands(guildIds []Snowflake, whitelist []string, switchToBlacklist bool) error
- type ClientCooldownOptions
- type ClientOptions
- type Command
- type CommandInteraction
- func (itx CommandInteraction) Defer(ephemeral bool) error
- func (itx CommandInteraction) DeleteFollowUp(messageId Snowflake, content ResponseData) error
- func (itx CommandInteraction) DeleteReply() error
- func (itx CommandInteraction) EditFollowUp(messageId Snowflake, content ResponseData) error
- func (itx CommandInteraction) EditReply(content ResponseData, ephemeral bool) error
- func (itx CommandInteraction) GetOptionValue(name string) (any, bool)
- func (itx CommandInteraction) ResolveMember(id Snowflake) *Member
- func (itx CommandInteraction) ResolveRole(id Snowflake) *Role
- func (itx CommandInteraction) ResolveUser(id Snowflake) *User
- func (itx CommandInteraction) SendFollowUp(content ResponseData, ephemeral bool) (Message, error)
- func (itx CommandInteraction) SendLinearReply(content string, ephemeral bool) error
- func (itx CommandInteraction) SendReply(content ResponseData, ephemeral bool) error
- type CommandType
- type Component
- type ComponentType
- type Embed
- type EmbedAuthor
- type EmbedField
- type EmbedFooter
- type EmbedImage
- type EmbedProvider
- type EmbedThumbnail
- type EmbedVideo
- type Emoji
- type Interaction
- type InteractionData
- type InteractionDataResolved
- type InteractionOption
- type InteractionType
- type Member
- type Message
- type MessageReference
- type Option
- type OptionType
- type PartialEmoji
- type Response
- type ResponseChoice
- type ResponseChoiceData
- type ResponseData
- type ResponseType
- type Rest
- type Role
- type RoleTag
- type SelectMenuComponent
- type SelectMenuOption
- type Snowflake
- type TextInputComponent
- type TextInputStyle
- type User
Constants ¶
const ( TEXT_INPUT_SHORT = iota + 1 // A single-line input. TEXT_INPUT_PARAGRAPH // A multi-line input. )
const ( DISCORD_API_URL string = "https://discord.com/api/v10" DISCORD_CDN_URL string = "https://cdn.discordapp.com" )
Variables ¶
var REST_NULL_SLICE_FIND []byte = []byte("[null]")
var REST_NULL_SLICE_REPLACE []byte = []byte("[]")
Functions ¶
func CheckInSlice ¶
func CheckInSlice[T comparable](slice *[]T, item T) bool
func JsonReshape ¶
func JsonReshape[T interface{}](object interface{}) T
Makes Go's compiler thing be whatever type you want. You should avoid relying on it!
func PrettyStructPrint ¶
func PrettyStructPrint(v any)
Types ¶
type AutoCompleteInteraction ¶
type AutoCompleteInteraction Interaction
func (AutoCompleteInteraction) GetFocusedValue ¶
func (itx AutoCompleteInteraction) GetFocusedValue() (string, any)
Returns option name and its value of triggered option. Option name is always of string type but you'll need to check type of value.
type ButtonComponent ¶
type ButtonComponent struct { CustomId string `json:"custom_id"` Type ComponentType `json:"type"` // It gonna always be = 2 for button components. Style ButtonStyle `json:"style"` Label string `json:"label,omitempty"` // Text label that appears on the button, max 80 characters. Emoji *PartialEmoji `json:"emoji,omitempty"` Url string `json:"url,omitempty"` // A url for link-style buttons. Disabled bool `json:"disabled,omitempty"` }
type ButtonStyle ¶
type ButtonStyle uint8
const ( BUTTON_PRIMARY ButtonStyle = iota + 1 // BUTTON_PRIMARY blurple BUTTON_SECONDARY // BUTTON_SECONDARY grey BUTTON_SUCCESS // BUTTON_SUCCESS green BUTTON_DANGER // BUTTON_DANGER red BUTTON_LINK // BUTTON_LINK grey, navigate to URL )
type ChannelType ¶
type ChannelType uint8
const ( CHANNEL_GUILD_TEXT ChannelType = iota CHANNEL_DM CHANNEL_GUILD_VOICE CHANNEL_GROUP_DM CHANNEL_GUILD_CATEGORY CHANNEL_GUILD_NEWS CHANNEL_GUILD_NEWS_THREAD CHANNEL_GUILD_PUBLIC_THREAD CHANNEL_GUILD_PRIVATE_THREAD CHANNEL_GUILD_STAGE_VOICE CHANNEL_GUILD_DIRECTORY CHANNEL_GUILD_FORUM // (still in development) Channel that can only contain threads. )
func (ChannelType) MarshalJSON ¶
func (ct ChannelType) MarshalJSON() (p []byte, err error)
type Client ¶
type Client struct { Rest Rest User User ApplicationId Snowflake PublicKey ed25519.PublicKey MaxCooldownsBeforeSweep uint16 // contains filtered or unexported fields }
Please avoid creating raw Client struct unless you know what you're doing. Use CreateClient function instead.
func CreateClient ¶
func CreateClient(options ClientOptions) Client
func (Client) AwaitComponent ¶
func (client Client) AwaitComponent(componentCustomIds []string, timeout time.Duration) (chan *Interaction, func())
Makes client "listen" incoming component type interactions. When component custom id matches - it'll send back interaction through channel. On timeout - client will send <nil> through channel and automatically call close function.
Warning! Don't try to acknowledge any component passed to this method, it'll be handled automatically.
Warning! Listener will continue to work unless it timeouts or when calling close function that is returned to you with channel.
Set timeout equal to 0 to make it last infinitely.
func (Client) CrosspostMessage ¶
func (Client) DeleteMessage ¶
func (Client) EditMessage ¶
func (Client) FetchMember ¶
func (Client) ListenAndServe ¶
func (Client) RegisterCommand ¶
func (Client) RegisterSubCommand ¶
func (Client) SendLinearMessage ¶
Use that for simple text messages that won't be modified.
func (Client) SendMessage ¶
func (Client) SyncCommands ¶
func (client Client) SyncCommands(guildIds []Snowflake, whitelist []string, switchToBlacklist bool) error
Sync currently cached slash commands to discord API. By default it'll try to make (bulk) global update (limit 100 updates per day), provide array with guild id snowflakes to update data only for specific guilds. You can also add second param -> slice with all command names you want to update (whitelist). There's also third, boolean param that when = true will reverse wishlist to work as blacklist.
type ClientCooldownOptions ¶
type ClientCooldownOptions struct { Duration time.Duration Ephemeral bool // Whether message about being on cooldown should be ephemeral. CooldownResponse func(user User, timeLeft time.Duration) ResponseData // Response object to reply to member/user on cooldown. MaxCooldownsBeforeSweep uint16 // The maximum number of cooldown entries to keep after which app start clearing memory. Majority of Discord applications can hold it on default 100 but if your app handles like hundreds of commands each second then it's recommend increasing that limit. Increasing it will result in higher memory usage but reduce CPU usage. (default: 100) }
type ClientOptions ¶
type ClientOptions struct { ApplicationId Snowflake // The app's user id. (default: <nil>) PublicKey string // Hash like key used to verify incoming payloads from Discord. (default: <nil>) Token string // The auth token to use. Bot tokens should be prefixed with Bot (e.g. "Bot MTExIHlvdSAgdHJpZWQgMTEx.O5rKAA.dQw4w9WgXcQ_wpV-gGA4PSk_bm8"). Prefix-less bot tokens are deprecated. (default: <nil>) GlobalRequestLimit uint16 // The maximum number of requests app can make to Discord API before reaching global rate limit. Default limit is 50 but big bots (over 100,000 guilds) receives bigger limits. (default: 50) MaxRequestsBeforeSweep uint16 // The maximum number of REST requests after which app start clearing memory. Majority of Discord applications can hold it on default 100 but if your app handles like hundreds of commands each second then it's recommend increasing that limit. Increasing it will result in higher memory usage but reduce CPU usage. (default: 100) Cooldowns *ClientCooldownOptions // The built-in cooldown mechanic for commands. Skip this field if you don't want to use automatic cooldown system (it won't allocate any extra memory if it's not used). (default: <nil>) PreCommandExecutionHandler func(itx CommandInteraction) *ResponseData // Function to call after doing initial processing but before executing slash command. Allows to attach own, global logic to all slash commands (similar to routing). Return pointer to ResponseData struct if you want to send messageand stop execution or <nil> to continue. (default: <nil>) InteractionHandler func(itx Interaction) // Function to call on all unhandled interactions. (default: <nil>) }
type Command ¶
type Command struct { Id Snowflake `json:"id,omitempty"` ApplicationId Snowflake `json:"application_id,omitempty"` GuildId Snowflake `json:"guild_id,omitempty"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Type CommandType `json:"type,omitempty"` Options []Option `json:"options,omitempty"` DefaultPermissions uint64 `json:"default_member_permissions,string,omitempty"` // Set of permissions represented as a bit set. Set it to 0 to make command unavailable for regular members. AvailableInDM bool `json:"dm_permission,omitempty"` // Whether command should be visible (usable) from private, dm channels. Works only for global commands! Version Snowflake `json:"version,omitempty"` // Autoincrementing version identifier updated during substantial record changes AutoCompleteHandler func(itx AutoCompleteInteraction) []Choice `json:"-"` // Custom handler for auto complete interactions. It's a Tempest specific field. SlashCommandHandler func(itx CommandInteraction) `json:"-"` // Custom handler for slash command interactions. It's a Tempest specific field. Warning! Library will panic if command can be triggered but doesn't have this handler. }
type CommandInteraction ¶
type CommandInteraction Interaction
func (CommandInteraction) Defer ¶
func (itx CommandInteraction) Defer(ephemeral bool) error
Use to let user/member know that bot is processing command. Make ephemeral = true to make notification visible only to target.
func (CommandInteraction) DeleteFollowUp ¶
func (itx CommandInteraction) DeleteFollowUp(messageId Snowflake, content ResponseData) error
Deletes a followup message for an Interaction. It does not support ephemeral followups.
func (CommandInteraction) DeleteReply ¶
func (itx CommandInteraction) DeleteReply() error
func (CommandInteraction) EditFollowUp ¶
func (itx CommandInteraction) EditFollowUp(messageId Snowflake, content ResponseData) error
Edits a followup message for an Interaction.
func (CommandInteraction) EditReply ¶
func (itx CommandInteraction) EditReply(content ResponseData, ephemeral bool) error
func (CommandInteraction) GetOptionValue ¶
func (itx CommandInteraction) GetOptionValue(name string) (any, bool)
Returns value of any type. Check second value to check whether option was provided or not (true if yes). Use this method when working with Command-like interactions.
func (CommandInteraction) ResolveMember ¶
func (itx CommandInteraction) ResolveMember(id Snowflake) *Member
Returns pointer to member if present in interaction.data.resolved and binds member.user. It'll return <nil> if there's no resolved member.
func (CommandInteraction) ResolveRole ¶
func (itx CommandInteraction) ResolveRole(id Snowflake) *Role
Returns pointer to guild role if present in interaction.data.resolved. It'll return <nil> if there's no resolved role.
func (CommandInteraction) ResolveUser ¶
func (itx CommandInteraction) ResolveUser(id Snowflake) *User
Returns pointer to user if present in interaction.data.resolved. It'll return <nil> if there's no resolved user.
func (CommandInteraction) SendFollowUp ¶
func (itx CommandInteraction) SendFollowUp(content ResponseData, ephemeral bool) (Message, error)
Create a followup message for an Interaction.
func (CommandInteraction) SendLinearReply ¶
func (itx CommandInteraction) SendLinearReply(content string, ephemeral bool) error
Use that for simple text messages that won't be modified.
func (CommandInteraction) SendReply ¶
func (itx CommandInteraction) SendReply(content ResponseData, ephemeral bool) error
Acknowledges the interaction with a message. Set ephemeral = true to make message visible only to target.
type CommandType ¶
type CommandType uint8
const ( COMMAND_CHAT_INPUT CommandType = iota + 1 COMMAND_USER COMMAND_MESSAGE )
type Component ¶
type Component struct { CustomId string `json:"custom_id,omitempty"` Type ComponentType `json:"type"` Style ButtonStyle `json:"style,omitempty"` Label string `json:"label,omitempty"` Emoji *PartialEmoji `json:"emoji,omitempty"` Url string `json:"url,omitempty"` Disabled bool `json:"disabled,omitempty"` Placeholder string `json:"placeholder,omitempty"` MinValues uint64 `json:"min_values,omitempty"` MaxValues uint64 `json:"max_values,omitempty"` Required bool `json:"required,omitempty"` Options []*SelectMenuOption `json:"options,omitempty"` Components []*Component `json:"components,omitempty"` }
Generic Component super struct! Use "ButtonComponent", "SelectMenuComponent" or "TextInputComponent" whenever possible and this super struct as "any" component.
type ComponentType ¶
type ComponentType uint8
const ( COMPONENT_ROW ComponentType = iota + 1 COMPONENT_BUTTON COMPONENT_SELECT_MENU COMPONENT_TEXT_INPUT )
type Embed ¶
type Embed struct { Title string `json:"title,omitempty"` Url string `json:"url,omitempty"` Author *EmbedAuthor `json:"author,omitempty"` Color uint32 `json:"color,omitempty"` Thumbnail *EmbedThumbnail `json:"thumbnail,omitempty"` Description string `json:"description,omitempty"` Fields []*EmbedField `json:"fields,omitempty"` Image *EmbedImage `json:"image,omitempty"` Video *EmbedVideo `json:"video,omitempty"` Provider *EmbedProvider `json:"provider,omitempty"` Timestamp *time.Time `json:"timestamp,omitempty"` }
type EmbedAuthor ¶
type EmbedField ¶
type EmbedFooter ¶
type EmbedFooter struct {}
type EmbedImage ¶
type EmbedProvider ¶
type EmbedThumbnail ¶
type EmbedVideo ¶
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"` }
type Interaction ¶
type Interaction struct { Id Snowflake `json:"id"` ApplicationId Snowflake `json:"application_id"` Type InteractionType `json:"type"` Data *InteractionData `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"` // Continuation token for responding to the interaction. It's not the same as bot/app token! Version uint8 `json:"version"` // Read-only property, always = 1. Message *Message `json:"message,omitempty"` // For components, the message they were attached to. PermissionFlags uint64 `json:"app_permissions,string"` // Bitwise set of permissions the app or bot has within the channel the interaction was sent from. Locale string `json:"locale,omitempty"` // Selected language of the invoking user. GuildLocale string `json:"guild_locale,omitempty"` // Guild's preferred locale, available if invoked in a guild. Client *Client `json:"-"` // Client pointer is required for all "higher" structs methods that inherits Interaction data. }
func (Interaction) SendCustomCallback ¶
func (itx Interaction) SendCustomCallback(method string, callback Response) error
Use that if you need to make a call that is not already supported by Tempest.
type InteractionData ¶
type InteractionData struct { Id Snowflake `json:"id,omitempty"` CustomId string `json:"custom_id,omitempty"` // Present only for components. Name string `json:"name"` // In case of commands it'll be name of command. If that's a subcommand then it'll be in format "rootCommand@subCommand". Type CommandType `json:"type"` Options []*InteractionOption `json:"options,omitempty"` GuildId Snowflake `json:"guild_id,omitempty"` TargetId Snowflake `json:"target_id,omitempty"` // Id of either user or message targeted. Depends whether it was user command or message command. ComponentType ComponentType `json:"component_type,omitempty"` Resolved *InteractionDataResolved `json:"resolved,omitempty"` }
type InteractionDataResolved ¶
type InteractionOption ¶
type InteractionOption struct { Name string `json:"name"` Value any `json:"value,omitempty"` Type OptionType `json:"type"` Options []*InteractionOption `json:"options,omitempty"` Focused bool `json:"focused,omitempty"` // Will be set to "true" if this option is the currently focused option for autocomplete. }
type InteractionType ¶
type InteractionType uint8
const ( PING_TYPE InteractionType = iota + 1 APPLICATION_COMMAND_TYPE MESSAGE_COMPONENT_TYPE APPLICATION_COMMAND_AUTO_COMPLETE_TYPE MODAL_SUBMIT_TYPE )
type Member ¶
type Member struct { User *User `json:"user,omitempty"` // Struct with general user data. In theory it may be empty but I never seen such payload. GuildId Snowflake `json:"-"` GuildAvatarHash string `json:"avatar,omitempty"` // Hash code used to access member's custom, guild profile. Call Member.FetchGuildAvatarUrl to get direct url. Nickname string `json:"nick,omitempty"` JoinedAt string `json:"joined_at"` BoostedSince string `json:"premium_since,omitempty"` RoleIds []Snowflake `json:"roles"` PermissionFlags uint64 `json:"permissions,string"` }
func (Member) FetchGuildAvatarUrl ¶
Returns a direct url to members's guild specific avatar. It'll return empty string if targeted member don't use custom avatar for that server.
type Message ¶
type Message struct { Id Snowflake `json:"id"` ChannelId Snowflake `json:"channel_id"` GuildId Snowflake `json:"guild_id,omitempty"` TTS bool `json:"tts"` Pinned bool `json:"pinned"` MentionEveryone bool `json:"mention_everyone"` Mentions []*User `json:"mentions"` MentionRoleIds []Snowflake `json:"mention_roles"` Author *User `json:"author"` Content string `json:"content"` Timestamp *time.Time `json:"timestamp,omitempty"` EditedTimestamp *time.Time `json:"edited_timestamp,omitempty"` Embeds []*Embed `json:"embeds"` Components []*Component `json:"components,omitempty"` Reference *MessageReference `json:"message_reference,omitempty"` // Reference data sent with crossposted messages and inline replies. ReferencedMessage *Message `json:"referenced_message,omitempty"` // ReferencedMessage is the message that was replied to. }
type MessageReference ¶
type Option ¶
type Option struct { Name string `json:"name"` Type OptionType `json:"type"` Description string `json:"description,omitempty"` Required bool `json:"required,omitempty"` MinValue int `json:"min_value,omitempty"` // Declares min value for integer/number option. MaxValue int `json:"max_value,omitempty"` // Declares max value for integer/number option. MinLength uint `json:"min_length,omitempty"` // Declares min length for string option. MaxLength uint `json:"max_length,omitempty"` // Declares max length for string option. ChannelTypes []ChannelType `json:"channel_types,omitempty"` Options []Option `json:"options,omitempty"` Choices []Choice `json:"choices,omitempty"` AutoComplete bool `json:"autocomplete,omitempty"` // Required to be = true if you want to catch it later in auto complete handler. Focused bool `json:"focused,omitempty"` }
Option is an option for an application Command
type OptionType ¶
type OptionType uint8
const ( OPTION_SUB_COMMAND OptionType = iota + 1 OPTION_STRING OPTION_INTEGER OPTION_BOOLEAN OPTION_USER OPTION_CHANNEL OPTION_ROLE OPTION_MENTIONABLE OPTION_NUMBER OPTION_ATTACHMENT )
type PartialEmoji ¶
type Response ¶
type Response struct { Type ResponseType `json:"type"` Data *ResponseData `json:"data,omitempty"` }
Similar to Message struct but used only for replying on interactions (mostly commands).
type ResponseChoice ¶
type ResponseChoice struct { Type ResponseType `json:"type"` Data ResponseChoiceData `json:"data,omitempty"` }
Unique to auto complete interaction.
type ResponseChoiceData ¶
type ResponseChoiceData struct {
Choices []Choice `json:"choices,omitempty"`
}
Unique to auto complete interaction.
type ResponseData ¶
type ResponseData struct { TTS bool `json:"tts,omitempty"` Content string `json:"content,omitempty"` Embeds []*Embed `json:"embeds,omitempty"` Components []*Component `json:"components,omitempty"` Flags uint64 `json:"flags,omitempty"` }
Similar to Message struct - check: https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-messages
type ResponseType ¶
type ResponseType uint8
const ( PONG_RESPONSE ResponseType = iota + 1 ACKNOWLEDGE_RESPONSE CHANNEL_MESSAGE_RESPONSE CHANNEL_MESSAGE_WITH_SOURCE_RESPONSE DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE_RESPONSE DEFERRED_UPDATE_MESSAGE_RESPONSE // Only valid for component-based interactions. UPDATE_MESSAGE_RESPONSE // Only valid for component-based interactions. AUTOCOMPLETE_RESPONSE MODAL_RESPONSE // Not available for MODAL_SUBMIT and PING interactions. )
type Rest ¶
type Rest struct { Token string // Discord Bot/App token. Remember to add "Bot" prefix. MaxRequestsBeforeSweep uint16 GlobalRequestLimit uint16 // contains filtered or unexported fields }
Please avoid creating raw Rest struct unless you know what you're doing. Use CreateRest function instead.
func CreateRest ¶
Creates standalone REST instance. Use CreateClient function if you want to create regular Discord App.
type Role ¶
type Role struct { Id Snowflake `json:"id"` Name string `json:"name"` Color uint32 `json:"color"` // Integer representation of hexadecimal color code. Roles without colors (color == 0) do not count towards the final computed color in the user list. Hoist bool `json:"hoist"` // Whether this role is pinned in the user listing. IconHash string `json:"icon,omitempty"` UnicodeEmoji string `json:"unicode_emoji,omitempty"` Position uint8 `json:"position"` PermissionFlags uint64 `json:"permissions,string"` Managed bool `json:"managed"` // Whether this role is managed by an integration. Mentionable bool `json:"mentionable"` // Whether this role is mentionable. Tags []*RoleTag `json:"tags,omitempty"` }
type SelectMenuComponent ¶
type SelectMenuComponent struct { CustomId string `json:"custom_id"` Type ComponentType `json:"type"` // It gonna always be = 3 for select menu components. Placeholder string `json:"placeholder,omitempty"` // Custom placeholder text if nothing is selected, max 150 characters. MinValues uint64 `json:"min_values,omitempty"` MaxValues uint64 `json:"max_values,omitempty"` Options []*SelectMenuOption `json:"options"` Disabled bool `json:"disabled,omitempty"` }
type SelectMenuOption ¶
type SelectMenuOption struct { Label string `json:"label,omitempty"` // Text label that appears on the option label, max 80 characters. Description string `json:"description,omitempty"` // An additional description of the option, max 100 characters. Emoji *PartialEmoji `json:"emoji,omitempty"` Value string `json:"value"` // Value to return back to app once clicked, max 100 characters. Default bool `json:"default"` // Whether to render this option as selected by default. }
type Snowflake ¶
type Snowflake uint64
Snowflake represents a Discord's id snowflake.
func StringToSnowflake ¶
func (Snowflake) MarshalJSON ¶
func (*Snowflake) UnmarshalJSON ¶
type TextInputComponent ¶
type TextInputComponent struct { CustomId string `json:"custom_id"` Type ComponentType `json:"type"` // It gonna always be = 4 for text input components. Style TextInputStyle `json:"style"` Label string `json:"label"` // Text label for text input, max 45 characters. Placeholder string `json:"placeholder,omitempty"` // Custom placeholder text if the input is empty, max 100 characters. Value string `json:"value,omitempty"` // A pre-filled value for this component, max 4000 characters. MinValues uint64 `json:"min_values,omitempty"` MaxValues uint64 `json:"max_values,omitempty"` Required bool `json:"required,omitempty"` // Whether this component is required to be filled, default = true. }
type TextInputStyle ¶
type TextInputStyle uint8
type User ¶
type User struct { Id Snowflake `json:"id"` Username string `json:"username"` Discriminator string `json:"discriminator"` IsBot bool `json:"bot,omitempty"` AvatarHash string `json:"avatar,omitempty"` // Hash code used to access user's profile. Call User.FetchAvatarUrl to get direct url. BannerHash string `json:"banner,omitempty"` // Hash code used to access user's baner. Call User.FetchBannerUrl to get direct url. PublicFlags uint64 `json:"public_flags,omitempty"` AccentColor uint32 `json:"accent_color,omitempty"` // User's banner color, encoded as an integer representation of hexadecimal color code. PremiumType uint8 `json:"premium_type,omitempty"` }
func (User) FetchAvatarUrl ¶
Returns a direct url to user's avatar. It'll return url to default Discord's avatar if targeted user don't use avatar.
func (User) FetchBannerUrl ¶
Returns a direct url to user's banner. It'll return empty string if targeted user don't use avatar.