Documentation
¶
Index ¶
- Constants
- Variables
- type ActionRow
- type AllowedMentionType
- type AllowedMentions
- type Attachment
- type Button
- func NewButton(style ButtonStyle, label string, customID string, url string, emoji *Emoji, ...) Button
- func NewDangerButton(label string, customID string, emoji *Emoji) Button
- func NewLinkButton(label string, url string, emoji *Emoji, disabled bool) Button
- func NewPrimaryButton(label string, customID string, emoji *Emoji) Button
- func NewSecondaryButton(label string, customID string, emoji *Emoji) Button
- func NewSuccessButton(label string, customID string, emoji *Emoji) Button
- func (b Button) AsDisabled() Button
- func (b Button) AsEnabled() Button
- func (b Button) WithCustomID(customID string) Button
- func (b Button) WithDisabled(disabled bool) Button
- func (b Button) WithEmoji(emoji *Emoji) Button
- func (b Button) WithLabel(label string) Button
- func (b Button) WithStyle(style ButtonStyle) Button
- func (b Button) WithURL(url string) Button
- type ButtonStyle
- type Component
- type ComponentImpl
- type ComponentType
- type DeconstructedSnowflake
- type Embed
- type EmbedAuthor
- type EmbedBuilder
- func (b *EmbedBuilder) AddField(name string, value string, inline bool) *EmbedBuilder
- func (b *EmbedBuilder) AddFields(field *EmbedField, fields ...*EmbedField) *EmbedBuilder
- func (b *EmbedBuilder) Build() Embed
- func (b *EmbedBuilder) ClearFields() *EmbedBuilder
- func (b *EmbedBuilder) RemoveField(i int) *EmbedBuilder
- func (b *EmbedBuilder) SetAuthor(name string, url string, iconURL string) *EmbedBuilder
- func (b *EmbedBuilder) SetAuthorIcon(iconURL string) *EmbedBuilder
- func (b *EmbedBuilder) SetAuthorName(name string) *EmbedBuilder
- func (b *EmbedBuilder) SetAuthorURL(url string) *EmbedBuilder
- func (b *EmbedBuilder) SetColor(color int) *EmbedBuilder
- func (b *EmbedBuilder) SetDescription(description string) *EmbedBuilder
- func (b *EmbedBuilder) SetDescriptionf(description string, a ...interface{}) *EmbedBuilder
- func (b *EmbedBuilder) SetEmbedAuthor(author *EmbedAuthor) *EmbedBuilder
- func (b *EmbedBuilder) SetEmbedFooter(footer *EmbedFooter) *EmbedBuilder
- func (b *EmbedBuilder) SetField(i int, name string, value string, inline bool) *EmbedBuilder
- func (b *EmbedBuilder) SetFields(fields ...*EmbedField) *EmbedBuilder
- func (b *EmbedBuilder) SetFooter(text string, iconURL string) *EmbedBuilder
- func (b *EmbedBuilder) SetFooterIcon(iconURL string) *EmbedBuilder
- func (b *EmbedBuilder) SetFooterText(text string) *EmbedBuilder
- func (b *EmbedBuilder) SetImage(url string) *EmbedBuilder
- func (b *EmbedBuilder) SetThumbnail(url string) *EmbedBuilder
- func (b *EmbedBuilder) SetTitle(title string) *EmbedBuilder
- func (b *EmbedBuilder) SetTitlef(title string, a ...interface{}) *EmbedBuilder
- func (b *EmbedBuilder) SetURL(url string) *EmbedBuilder
- type EmbedField
- type EmbedFooter
- type EmbedProvider
- type EmbedResource
- type EmbedType
- type Emoji
- type MessageFlags
- func (f MessageFlags) Add(bits ...MessageFlags) MessageFlags
- func (f MessageFlags) Has(bit MessageFlags) bool
- func (f MessageFlags) HasAll(bits ...MessageFlags) bool
- func (f MessageFlags) Missing(bit MessageFlags) bool
- func (f MessageFlags) MissingAny(bits ...MessageFlags) bool
- func (f MessageFlags) Remove(bits ...MessageFlags) MessageFlags
- type RestClient
- type SelectMenu
- func (m SelectMenu) AddOptions(options ...SelectOption) SelectMenu
- func (m SelectMenu) RemoveOption(index int) SelectMenu
- func (m SelectMenu) SetOption(value string, option SelectOption) SelectMenu
- func (m SelectMenu) SetOptions(options ...SelectOption) SelectMenu
- func (m SelectMenu) WithCustomID(customID string) SelectMenu
- func (m SelectMenu) WithMaxValues(maxValue int) SelectMenu
- func (m SelectMenu) WithMinValues(minValue int) SelectMenu
- func (m SelectMenu) WithPlaceholder(placeholder string) SelectMenu
- type SelectOption
- func (o SelectOption) WithDefault(defaultOption bool) SelectOption
- func (o SelectOption) WithDescription(description string) SelectOption
- func (o SelectOption) WithEmoji(emoji *Emoji) SelectOption
- func (o SelectOption) WithLabel(label string) SelectOption
- func (o SelectOption) WithValue(value string) SelectOption
- type Snowflake
- type UnmarshalComponent
- type User
- type Webhook
- type WebhookClient
- type WebhookMessage
- func (m *WebhookMessage) ActionRows() []ActionRow
- func (m *WebhookMessage) ButtonByID(customID string) *Button
- func (m *WebhookMessage) Buttons() []Button
- func (m *WebhookMessage) ComponentByID(customID string) Component
- func (m *WebhookMessage) Delete() error
- func (m *WebhookMessage) Edit(WebhookMessage WebhookMessageUpdate) (*WebhookMessage, error)
- func (m *WebhookMessage) Marshal() ([]byte, error)
- func (m *WebhookMessage) SelectMenuByID(customID string) *SelectMenu
- func (m *WebhookMessage) SelectMenus() []SelectMenu
- func (m *WebhookMessage) Unmarshal(data []byte) error
- type WebhookMessageCreate
- type WebhookMessageCreateBuilder
- func (b *WebhookMessageCreateBuilder) AddComponents(components ...Component) *WebhookMessageCreateBuilder
- func (b *WebhookMessageCreateBuilder) AddEmbeds(embeds ...Embed) *WebhookMessageCreateBuilder
- func (b *WebhookMessageCreateBuilder) AddFile(name string, reader io.Reader, flags ...restclient.FileFlags) *WebhookMessageCreateBuilder
- func (b *WebhookMessageCreateBuilder) AddFiles(files ...restclient.File) *WebhookMessageCreateBuilder
- func (b *WebhookMessageCreateBuilder) Build() WebhookMessageCreate
- func (b *WebhookMessageCreateBuilder) ClearEmbeds() *WebhookMessageCreateBuilder
- func (b *WebhookMessageCreateBuilder) ClearFiles() *WebhookMessageCreateBuilder
- func (b *WebhookMessageCreateBuilder) RemoveEmbed(index int) *WebhookMessageCreateBuilder
- func (b *WebhookMessageCreateBuilder) RemoveFiles(i int) *WebhookMessageCreateBuilder
- func (b *WebhookMessageCreateBuilder) SetAllowedMentions(allowedMentions *AllowedMentions) *WebhookMessageCreateBuilder
- func (b *WebhookMessageCreateBuilder) SetAllowedMentionsEmpty() *WebhookMessageCreateBuilder
- func (b *WebhookMessageCreateBuilder) SetComponents(components ...Component) *WebhookMessageCreateBuilder
- func (b *WebhookMessageCreateBuilder) SetContent(content string) *WebhookMessageCreateBuilder
- func (b *WebhookMessageCreateBuilder) SetContentf(content string, a ...interface{}) *WebhookMessageCreateBuilder
- func (b *WebhookMessageCreateBuilder) SetEmbeds(embeds ...Embed) *WebhookMessageCreateBuilder
- func (b *WebhookMessageCreateBuilder) SetEphemeral(ephemeral bool) *WebhookMessageCreateBuilder
- func (b *WebhookMessageCreateBuilder) SetFiles(files ...restclient.File) *WebhookMessageCreateBuilder
- func (b *WebhookMessageCreateBuilder) SetFlags(flags MessageFlags) *WebhookMessageCreateBuilder
- func (b *WebhookMessageCreateBuilder) SetTTS(tts bool) *WebhookMessageCreateBuilder
- type WebhookMessageUpdate
- type WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) AddComponents(components ...Component) *WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) AddEmbeds(embeds ...Embed) *WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) AddFile(name string, reader io.Reader, flags ...restclient.FileFlags) *WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) AddFiles(files ...restclient.File) *WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) Build() WebhookMessageUpdate
- func (b *WebhookMessageUpdateBuilder) ClearAllowedMentions() *WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) ClearComponents() *WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) ClearEmbeds() *WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) ClearFiles() *WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) RemoveComponent(i int) *WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) RemoveEmbed(index int) *WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) RemoveFiles(i int) *WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) RetainAttachments(attachments ...Attachment) *WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) RetainAttachmentsByID(attachmentIDs ...Snowflake) *WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) SetAllowedMentions(allowedMentions *AllowedMentions) *WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) SetComponents(components ...Component) *WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) SetContent(content string) *WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) SetContentf(content string, a ...interface{}) *WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) SetEmbeds(embeds ...Embed) *WebhookMessageUpdateBuilder
- func (b *WebhookMessageUpdateBuilder) SetFiles(files ...restclient.File) *WebhookMessageUpdateBuilder
- type WebhookType
- type WebhookUpdate
Constants ¶
const ( ButtonStylePrimary = iota + 1 ButtonStyleSecondary ButtonStyleSuccess ButtonStyleDanger ButtonStyleLink )
Supported ButtonStyle(s)
const ( ComponentTypeActionRow = iota + 1 ComponentTypeButton ComponentTypeSelectMenu )
Supported ComponentType(s)
const Github = "https://github.com/DisgoOrg/disgohook"
Github is the disgohook github url
Variables ¶
var DefaultAllowedMentions = AllowedMentions{ Parse: []AllowedMentionType{AllowedMentionTypeUsers, AllowedMentionTypeRoles, AllowedMentionTypeEveryone}, Roles: []string{}, Users: []string{}, RepliedUser: true, }
DefaultAllowedMentions gives you the default AllowedMentions
var ErrMalformedWebhookToken = errors.New("malformed webhook token <id>/<token>")
ErrMalformedWebhookToken is returned for invalid webhook tokens
var Version = getVersion()
Version returns the current used disgohook version in the format vx.x.x
var WebhookURLPattern = regexp.MustCompile("(?:https?://)?(?:\\w+\\.)?discord(?:app)?\\.com/api(?:/v\\d+)?/webhooks/(\\d+)/([\\w-]+)(?:/(?:\\w+)?)?")
WebhookURLPattern is the URL pattern for Webhook(s)
Functions ¶
This section is empty.
Types ¶
type ActionRow ¶ added in v1.2.0
type ActionRow struct { ComponentImpl Components []Component `json:"components"` }
ActionRow holds up to 5 Component(s) in a row
func NewActionRow ¶ added in v1.2.0
NewActionRow creates a new ActionRow holding th provided Component(s)
func (ActionRow) AddComponents ¶ added in v1.4.0
AddComponents returns a new ActionRow with the provided Component(s) added
func (ActionRow) RemoveComponent ¶ added in v1.4.0
RemoveComponent returns a new ActionRow with the provided Component at the index removed
func (ActionRow) SetComponent ¶ added in v1.4.0
SetComponent returns a new ActionRow with the Component which has the customID replaced
func (ActionRow) SetComponents ¶ added in v1.4.0
SetComponents returns a new ActionRow with the provided Component(s)
type AllowedMentionType ¶
type AllowedMentionType string
AllowedMentionType ?
const ( AllowedMentionTypeRoles AllowedMentionType = "roles" AllowedMentionTypeUsers AllowedMentionType = "users" AllowedMentionTypeEveryone AllowedMentionType = "everyone" )
All AllowedMentionType(s)
type AllowedMentions ¶
type AllowedMentions struct { Parse []AllowedMentionType `json:"parse"` Roles []string `json:"roles"` Users []string `json:"users"` RepliedUser bool `json:"replied_user"` }
AllowedMentions are used for avoiding mentioning users in Message and Interaction
type Attachment ¶ added in v1.2.1
type Attachment struct { ID Snowflake `json:"id,omitempty"` Filename string `json:"filename"` Size int `json:"size"` URL string `json:"url"` ProxyURL string `json:"proxy_url"` Height *int `json:"height"` Width *int `json:"width"` }
Attachment is used for files sent in a WebhookMessage
type Button ¶ added in v1.2.0
type Button struct { ComponentImpl Style ButtonStyle `json:"style,omitempty"` 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 can be attacked to all messages & be clicked by a User. If clicked it fires a events.ButtonClickEvent with the declared customID
func NewButton ¶ added in v1.2.0
func NewButton(style ButtonStyle, label string, customID string, url string, emoji *Emoji, disabled bool) Button
NewButton creates a new Button with the provided parameters. Link Button(s) need a url and other Button(s) need a customID
func NewDangerButton ¶ added in v1.2.0
NewDangerButton creates a new Button with ButtonStyleDanger & the provided parameters
func NewLinkButton ¶ added in v1.2.0
NewLinkButton creates a new link Button with ButtonStyleLink & the provided parameters
func NewPrimaryButton ¶ added in v1.2.0
NewPrimaryButton creates a new Button with ButtonStylePrimary & the provided parameters
func NewSecondaryButton ¶ added in v1.2.0
NewSecondaryButton creates a new Button with ButtonStyleSecondary & the provided parameters
func NewSuccessButton ¶ added in v1.2.0
NewSuccessButton creates a new Button with ButtonStyleSuccess & the provided parameters
func (Button) AsDisabled ¶ added in v1.4.0
AsDisabled returns a new Button but disabled
func (Button) WithCustomID ¶ added in v1.4.0
WithCustomID returns a new Button with the provided custom id
func (Button) WithDisabled ¶ added in v1.4.0
WithDisabled returns a new Button but disabled/enabled
func (Button) WithStyle ¶ added in v1.4.0
func (b Button) WithStyle(style ButtonStyle) Button
WithStyle returns a new Button with the provided style
type ButtonStyle ¶ added in v1.2.0
type ButtonStyle int
ButtonStyle defines how the Button looks like (https://discord.com/assets/7bb017ce52cfd6575e21c058feb3883b.png)
type Component ¶ added in v1.2.0
type Component interface {
Type() ComponentType
}
Component is a general interface each Component needs to implement
type ComponentImpl ¶ added in v1.2.0
type ComponentImpl struct {
ComponentType ComponentType `json:"type"`
}
ComponentImpl is used to embed in each different ComponentType
func (ComponentImpl) Type ¶ added in v1.2.0
func (t ComponentImpl) Type() ComponentType
Type returns the ComponentType of this Component
type ComponentType ¶ added in v1.2.0
type ComponentType int
ComponentType defines different Component(s)
type DeconstructedSnowflake ¶ added in v1.1.0
type DeconstructedSnowflake struct { Timestamp int64 WorkerID int64 ProcessID int64 Increment int64 Binary string }
DeconstructedSnowflake contains the properties used by Discord for each ID
type Embed ¶
type Embed struct { Title *string `json:"title,omitempty"` Type *EmbedType `json:"type,omitempty"` Description *string `json:"description,omitempty"` URL *string `json:"url,omitempty"` Timestamp *time.Time `json:"timestamp,omitempty"` Color *int `json:"color,omitempty"` Image *EmbedResource `json:"image,omitempty"` Thumbnail *EmbedResource `json:"thumbnail,omitempty"` Video *EmbedResource `json:"video,omitempty"` Provider *EmbedProvider `json:"provider,omitempty"` Author *EmbedAuthor `json:"author,omitempty"` Fields []*EmbedField `json:"fields,omitempty"` }
Embed allows you to send embeds to discord
type EmbedAuthor ¶
type EmbedAuthor struct { Name *string `json:"name,omitempty"` URL *string `json:"url,omitempty"` IconURL *string `json:"icon_url,omitempty"` ProxyIconURL *string `json:"proxy_icon_url,omitempty"` }
The EmbedAuthor of an Embed
type EmbedBuilder ¶
type EmbedBuilder struct {
Embed
}
EmbedBuilder allows you to create embeds and use methods to set values
func NewEmbedBuilder ¶
func NewEmbedBuilder() *EmbedBuilder
NewEmbedBuilder returns a new embed builder
func (*EmbedBuilder) AddField ¶
func (b *EmbedBuilder) AddField(name string, value string, inline bool) *EmbedBuilder
AddField adds a field to the EmbedBuilder by name and value
func (*EmbedBuilder) AddFields ¶
func (b *EmbedBuilder) AddFields(field *EmbedField, fields ...*EmbedField) *EmbedBuilder
AddFields adds multiple fields to the EmbedBuilder
func (*EmbedBuilder) ClearFields ¶
func (b *EmbedBuilder) ClearFields() *EmbedBuilder
ClearFields removes all of the fields from the EmbedBuilder
func (*EmbedBuilder) RemoveField ¶
func (b *EmbedBuilder) RemoveField(i int) *EmbedBuilder
RemoveField removes a field from the EmbedBuilder
func (*EmbedBuilder) SetAuthor ¶
func (b *EmbedBuilder) SetAuthor(name string, url string, iconURL string) *EmbedBuilder
SetAuthor sets the author of the EmbedBuilder without an Icon URL
func (*EmbedBuilder) SetAuthorIcon ¶ added in v1.0.4
func (b *EmbedBuilder) SetAuthorIcon(iconURL string) *EmbedBuilder
SetAuthorIcon sets the author of the EmbedBuilder with all properties
func (*EmbedBuilder) SetAuthorName ¶ added in v1.0.4
func (b *EmbedBuilder) SetAuthorName(name string) *EmbedBuilder
SetAuthorName sets the author of the EmbedBuilder
func (*EmbedBuilder) SetAuthorURL ¶ added in v1.0.4
func (b *EmbedBuilder) SetAuthorURL(url string) *EmbedBuilder
SetAuthorURL sets the author of the EmbedBuilder with an URL
func (*EmbedBuilder) SetColor ¶
func (b *EmbedBuilder) SetColor(color int) *EmbedBuilder
SetColor sets the color of the EmbedBuilder
func (*EmbedBuilder) SetDescription ¶
func (b *EmbedBuilder) SetDescription(description string) *EmbedBuilder
SetDescription sets the description of the EmbedBuilder
func (*EmbedBuilder) SetDescriptionf ¶
func (b *EmbedBuilder) SetDescriptionf(description string, a ...interface{}) *EmbedBuilder
SetDescriptionf sets the description of the EmbedBuilder with format
func (*EmbedBuilder) SetEmbedAuthor ¶
func (b *EmbedBuilder) SetEmbedAuthor(author *EmbedAuthor) *EmbedBuilder
SetEmbedAuthor sets the author of the EmbedBuilder using an EmbedAuthor struct
func (*EmbedBuilder) SetEmbedFooter ¶ added in v1.0.4
func (b *EmbedBuilder) SetEmbedFooter(footer *EmbedFooter) *EmbedBuilder
SetEmbedFooter sets the footer of the EmbedBuilder
func (*EmbedBuilder) SetField ¶
func (b *EmbedBuilder) SetField(i int, name string, value string, inline bool) *EmbedBuilder
SetField sets a field to the EmbedBuilder by name and value
func (*EmbedBuilder) SetFields ¶
func (b *EmbedBuilder) SetFields(fields ...*EmbedField) *EmbedBuilder
SetFields sets fields of the EmbedBuilder
func (*EmbedBuilder) SetFooter ¶
func (b *EmbedBuilder) SetFooter(text string, iconURL string) *EmbedBuilder
SetFooter sets the footer of the EmbedBuilder
func (*EmbedBuilder) SetFooterIcon ¶ added in v1.0.4
func (b *EmbedBuilder) SetFooterIcon(iconURL string) *EmbedBuilder
SetFooterIcon sets the footer of the EmbedBuilder by iconURL
func (*EmbedBuilder) SetFooterText ¶ added in v1.0.4
func (b *EmbedBuilder) SetFooterText(text string) *EmbedBuilder
SetFooterText sets the footer of the EmbedBuilder by text
func (*EmbedBuilder) SetImage ¶
func (b *EmbedBuilder) SetImage(url string) *EmbedBuilder
SetImage sets the image of the EmbedBuilder
func (*EmbedBuilder) SetThumbnail ¶
func (b *EmbedBuilder) SetThumbnail(url string) *EmbedBuilder
SetThumbnail sets the thumbnail of the EmbedBuilder
func (*EmbedBuilder) SetTitle ¶
func (b *EmbedBuilder) SetTitle(title string) *EmbedBuilder
SetTitle sets the title of the EmbedBuilder
func (*EmbedBuilder) SetTitlef ¶ added in v1.0.4
func (b *EmbedBuilder) SetTitlef(title string, a ...interface{}) *EmbedBuilder
SetTitlef sets the title of the EmbedBuilder with format
func (*EmbedBuilder) SetURL ¶
func (b *EmbedBuilder) SetURL(url string) *EmbedBuilder
SetURL sets the URL of the EmbedBuilder
type EmbedField ¶
type EmbedField struct { Name string `json:"name"` Value string `json:"value"` Inline *bool `json:"inline,omitempty"` }
EmbedField (s) of an Embed
type EmbedProvider ¶
type EmbedProvider struct { Name *string `json:"name,omitempty"` URL *string `json:"url,omitempty"` }
The EmbedProvider of an Embed
type EmbedResource ¶
type EmbedResource struct { URL *string `json:"url,omitempty"` ProxyURL *string `json:"proxy_url,omitempty"` Height *int `json:"height,omitempty"` Width *int `json:"width,omitempty"` }
The EmbedResource of an Embed.Image/Embed.Thumbnail/Embed.Video
type Emoji ¶ added in v1.2.0
type Emoji struct { Name string `json:"name,omitempty"` ID Snowflake `json:"id,omitempty"` Animated bool `json:"animated,omitempty"` }
Emoji allows you to interact with emojis & emotes
type MessageFlags ¶ added in v1.2.0
type MessageFlags int64
The MessageFlags of a Message
const ( MessageFlagCrossposted MessageFlags = 1 << iota MessageFlagIsCrosspost MessageFlagSuppressEmbeds MessageFlagSourceMessageDeleted MessageFlagUrgent MessageFlagEphemeral MessageFlagLoading // Message is an interaction of type 5, awaiting further response MessageFlagNone MessageFlags = 0 )
Constants for MessageFlags
func (MessageFlags) Add ¶ added in v1.2.0
func (f MessageFlags) Add(bits ...MessageFlags) MessageFlags
Add allows you to add multiple bits together, producing a new bit
func (MessageFlags) Has ¶ added in v1.2.0
func (f MessageFlags) Has(bit MessageFlags) bool
Has will check whether the Bit contains another bit
func (MessageFlags) HasAll ¶ added in v1.2.0
func (f MessageFlags) HasAll(bits ...MessageFlags) bool
HasAll will ensure that the bit includes all of the bits entered
func (MessageFlags) Missing ¶ added in v1.2.0
func (f MessageFlags) Missing(bit MessageFlags) bool
Missing will do the inverse of Bit.Has
func (MessageFlags) MissingAny ¶ added in v1.2.0
func (f MessageFlags) MissingAny(bits ...MessageFlags) bool
MissingAny will check whether the bit is missing any one of the bits
func (MessageFlags) Remove ¶ added in v1.2.0
func (f MessageFlags) Remove(bits ...MessageFlags) MessageFlags
Remove allows you to subtract multiple bits from the first, producing a new bit
type RestClient ¶
type RestClient interface { restclient.RestClient WebhookClient() WebhookClient GetWebhook(webhookID Snowflake, webhookToken string) (*Webhook, restclient.RestError) UpdateWebhook(webhookID Snowflake, webhookToken string, webhookUpdate WebhookUpdate) (*Webhook, restclient.RestError) DeleteWebhook(webhookID Snowflake, webhookToken string) restclient.RestError CreateWebhookMessage(webhookID Snowflake, webhookToken string, messageCreate WebhookMessageCreate, wait bool, threadID Snowflake) (*WebhookMessage, restclient.RestError) UpdateWebhookMessage(webhookID Snowflake, webhookToken string, messageID Snowflake, messageUpdate WebhookMessageUpdate) (*WebhookMessage, restclient.RestError) DeleteWebhookMessage(webhookID Snowflake, webhookToken string, messageID Snowflake) restclient.RestError }
RestClient is a manager for all of disgohook's HTTP requests
type SelectMenu ¶ added in v1.4.0
type SelectMenu struct { ComponentImpl CustomID string `json:"custom_id"` Placeholder string `json:"placeholder"` MinValues int `json:"min_values,omitempty"` MaxValues int `json:"max_values,omitempty"` Options []SelectOption `json:"options"` }
SelectMenu is a Component which lets the User select from various options
func NewSelectMenu ¶ added in v1.4.0
func NewSelectMenu(customID string, placeholder string, minValues int, maxValues int, options ...SelectOption) SelectMenu
NewSelectMenu builds a new SelectMenu from the provided values
func (SelectMenu) AddOptions ¶ added in v1.4.0
func (m SelectMenu) AddOptions(options ...SelectOption) SelectMenu
AddOptions returns a new SelectMenu with the provided SelectOption(s) added
func (SelectMenu) RemoveOption ¶ added in v1.4.0
func (m SelectMenu) RemoveOption(index int) SelectMenu
RemoveOption returns a new SelectMenu with the provided SelectOption at the index removed
func (SelectMenu) SetOption ¶ added in v1.4.0
func (m SelectMenu) SetOption(value string, option SelectOption) SelectMenu
SetOption returns a new SelectMenu with the SelectOption which has the value replaced
func (SelectMenu) SetOptions ¶ added in v1.4.0
func (m SelectMenu) SetOptions(options ...SelectOption) SelectMenu
SetOptions returns a new SelectMenu with the provided SelectOption(s)
func (SelectMenu) WithCustomID ¶ added in v1.4.0
func (m SelectMenu) WithCustomID(customID string) SelectMenu
WithCustomID returns a new SelectMenu with the provided customID
func (SelectMenu) WithMaxValues ¶ added in v1.4.0
func (m SelectMenu) WithMaxValues(maxValue int) SelectMenu
WithMaxValues returns a new SelectMenu with the provided maxValue
func (SelectMenu) WithMinValues ¶ added in v1.4.0
func (m SelectMenu) WithMinValues(minValue int) SelectMenu
WithMinValues returns a new SelectMenu with the provided minValue
func (SelectMenu) WithPlaceholder ¶ added in v1.4.0
func (m SelectMenu) WithPlaceholder(placeholder string) SelectMenu
WithPlaceholder returns a new SelectMenu with the provided placeholder
type SelectOption ¶ added in v1.4.0
type SelectOption struct { Label string `json:"label"` Value string `json:"value"` Description string `json:"description,omitempty"` Default bool `json:"default,omitempty"` Emoji *Emoji `json:"emoji,omitempty"` }
SelectOption represents an option in a SelectMenu
func NewSelectOption ¶ added in v1.4.0
func NewSelectOption(label string, value string) SelectOption
NewSelectOption builds a new SelectOption
func (SelectOption) WithDefault ¶ added in v1.4.0
func (o SelectOption) WithDefault(defaultOption bool) SelectOption
WithDefault returns a new SelectOption as default/non-default
func (SelectOption) WithDescription ¶ added in v1.4.0
func (o SelectOption) WithDescription(description string) SelectOption
WithDescription returns a new SelectOption with the provided description
func (SelectOption) WithEmoji ¶ added in v1.4.0
func (o SelectOption) WithEmoji(emoji *Emoji) SelectOption
WithEmoji returns a new SelectOption with the provided Emoji
func (SelectOption) WithLabel ¶ added in v1.4.0
func (o SelectOption) WithLabel(label string) SelectOption
WithLabel returns a new SelectOption with the provided label
func (SelectOption) WithValue ¶ added in v1.4.0
func (o SelectOption) WithValue(value string) SelectOption
WithValue returns a new SelectOption with the provided value
type Snowflake ¶ added in v1.1.0
type Snowflake string
Snowflake is a general utility class around discord's IDs
func (Snowflake) Deconstruct ¶ added in v1.1.0
func (s Snowflake) Deconstruct() DeconstructedSnowflake
Deconstruct returns DeconstructedSnowflake
type UnmarshalComponent ¶ added in v1.2.0
type UnmarshalComponent struct { ComponentType ComponentType `json:"type"` // Button && SelectMenu CustomID string `json:"custom_id"` // Button Style ButtonStyle `json:"style"` Label string `json:"label"` Emoji *Emoji `json:"emoji"` URL string `json:"url"` Disabled bool `json:"disabled"` // ActionRow Components []UnmarshalComponent `json:"components"` // SelectMenu Placeholder string `json:"placeholder"` MinValues int `json:"min_values,omitempty"` MaxValues int `json:"max_values,omitempty"` Options []SelectOption `json:"options"` }
UnmarshalComponent is used for easier unmarshalling of different Component(s)
type User ¶
type User struct { ID string `json:"id"` Discriminator string `json:"discriminator"` Bot bool `json:"bot"` Username string `json:"username"` Avatar *string `json:"avatar"` }
User represents a Discord User
type Webhook ¶
type Webhook struct { ID Snowflake `json:"id"` Type WebhookType `json:"type"` GuildID *Snowflake `json:"guild_id"` ChannelID *Snowflake `json:"channel_id"` Name string `json:"name"` Avatar string `json:"avatar"` Token *string `json:"token"` ApplicationID Snowflake `json:"application_id"` }
Webhook represents a Discord Webhook
type WebhookClient ¶ added in v1.1.0
type WebhookClient interface { RestClient() RestClient Logger() log.Logger DefaultAllowedMentions() *AllowedMentions SetDefaultAllowedMentions(allowedMentions *AllowedMentions) GetWebhook() (*Webhook, restclient.RestError) EditWebhook(webhookUpdate WebhookUpdate) (*Webhook, restclient.RestError) DeleteWebhook() restclient.RestError SendMessage(message WebhookMessageCreate) (*WebhookMessage, restclient.RestError) SendContent(content string) (*WebhookMessage, restclient.RestError) SendEmbeds(embeds ...Embed) (*WebhookMessage, restclient.RestError) EditMessage(messageID Snowflake, message WebhookMessageUpdate) (*WebhookMessage, restclient.RestError) EditContent(messageID Snowflake, content string) (*WebhookMessage, restclient.RestError) EditEmbeds(messageID Snowflake, embeds ...Embed) (*WebhookMessage, restclient.RestError) DeleteMessage(id Snowflake) restclient.RestError Token() string ID() Snowflake URL() string }
WebhookClient lets you edit/send WebhookMessage(s) or update/delete the Webhook
type WebhookMessage ¶
type WebhookMessage struct { Webhook WebhookClient ID Snowflake `json:"id"` WebhookID Snowflake `json:"webhook_id"` ChannelID Snowflake `json:"channel_id"` GuildID Snowflake `json:"guild_id"` TTS bool `json:"tts"` Author *User `json:"author"` CreatedAt time.Time `json:"timestamp"` EditedAt *time.Time `json:"edited_timestamp"` Content *string `json:"content,omitempty"` Embeds []Embed `json:"embeds,omitempty"` Components []Component `json:"-"` Attachments []Attachment `json:"attachments,omitempty"` Mentions []interface{} `json:"mentions"` MentionEveryone bool `json:"mention_everyone"` MentionRoles []string `json:"mention_roles"` }
WebhookMessage represents a message created by a Webhook
func (*WebhookMessage) ActionRows ¶ added in v1.4.0
func (m *WebhookMessage) ActionRows() []ActionRow
ActionRows returns all ActionRow(s) from this WebhookMessage
func (*WebhookMessage) ButtonByID ¶ added in v1.4.0
func (m *WebhookMessage) ButtonByID(customID string) *Button
ButtonByID returns a Button with the specific customID from this WebhookMessage
func (*WebhookMessage) Buttons ¶ added in v1.4.0
func (m *WebhookMessage) Buttons() []Button
Buttons returns all Button(s) from this WebhookMessage
func (*WebhookMessage) ComponentByID ¶ added in v1.4.0
func (m *WebhookMessage) ComponentByID(customID string) Component
ComponentByID returns the first Component with the specific customID
func (*WebhookMessage) Delete ¶ added in v1.0.4
func (m *WebhookMessage) Delete() error
Delete allows you to delete an existing WebhookMessage sent by you
func (*WebhookMessage) Edit ¶ added in v1.0.4
func (m *WebhookMessage) Edit(WebhookMessage WebhookMessageUpdate) (*WebhookMessage, error)
Edit allows you to edit an existing WebhookMessage sent by you
func (*WebhookMessage) Marshal ¶ added in v1.4.0
func (m *WebhookMessage) Marshal() ([]byte, error)
Marshal is used to marshal a WebhookMessage we send to discord
func (*WebhookMessage) SelectMenuByID ¶ added in v1.4.0
func (m *WebhookMessage) SelectMenuByID(customID string) *SelectMenu
SelectMenuByID returns a SelectMenu with the specific customID from this WebhookMessage
func (*WebhookMessage) SelectMenus ¶ added in v1.4.0
func (m *WebhookMessage) SelectMenus() []SelectMenu
SelectMenus returns all SelectMenu(s) from this WebhookMessage
func (*WebhookMessage) Unmarshal ¶ added in v1.4.0
func (m *WebhookMessage) Unmarshal(data []byte) error
Unmarshal is used to unmarshal a WebhookMessage we received from discord
type WebhookMessageCreate ¶
type WebhookMessageCreate struct { Content string `json:"content,omitempty"` TTS bool `json:"tts,omitempty"` Embeds []Embed `json:"embeds,omitempty"` Components []Component `json:"components,omitempty"` Files []restclient.File `json:"-"` AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"` Flags MessageFlags `json:"flags,omitempty"` }
WebhookMessageCreate is used to add additional messages to an Interaction after you've responded initially
func (WebhookMessageCreate) ToBody ¶ added in v1.2.1
func (m WebhookMessageCreate) ToBody() (interface{}, error)
ToBody returns the WebhookMessageCreate ready for body
type WebhookMessageCreateBuilder ¶ added in v1.2.0
type WebhookMessageCreateBuilder struct {
WebhookMessageCreate
}
WebhookMessageCreateBuilder allows you to create an WebhookMessageCreate with ease
func NewWebhookMessageCreateBuilder ¶ added in v1.2.0
func NewWebhookMessageCreateBuilder() *WebhookMessageCreateBuilder
NewWebhookMessageCreateBuilder returns a new WebhookMessageCreateBuilder
func (*WebhookMessageCreateBuilder) AddComponents ¶ added in v1.2.0
func (b *WebhookMessageCreateBuilder) AddComponents(components ...Component) *WebhookMessageCreateBuilder
AddComponents adds the Component(s) to the WebhookMessageCreate
func (*WebhookMessageCreateBuilder) AddEmbeds ¶ added in v1.2.0
func (b *WebhookMessageCreateBuilder) AddEmbeds(embeds ...Embed) *WebhookMessageCreateBuilder
AddEmbeds adds multiple embeds to the WebhookMessageCreate
func (*WebhookMessageCreateBuilder) AddFile ¶ added in v1.2.1
func (b *WebhookMessageCreateBuilder) AddFile(name string, reader io.Reader, flags ...restclient.FileFlags) *WebhookMessageCreateBuilder
AddFile adds a file to the WebhookMessageCreate
func (*WebhookMessageCreateBuilder) AddFiles ¶ added in v1.2.1
func (b *WebhookMessageCreateBuilder) AddFiles(files ...restclient.File) *WebhookMessageCreateBuilder
AddFiles adds the files to the WebhookMessageCreate
func (*WebhookMessageCreateBuilder) Build ¶ added in v1.2.0
func (b *WebhookMessageCreateBuilder) Build() WebhookMessageCreate
Build returns your built WebhookMessageCreate
func (*WebhookMessageCreateBuilder) ClearEmbeds ¶ added in v1.2.0
func (b *WebhookMessageCreateBuilder) ClearEmbeds() *WebhookMessageCreateBuilder
ClearEmbeds removes all of the embeds from the WebhookMessageCreate
func (*WebhookMessageCreateBuilder) ClearFiles ¶ added in v1.2.1
func (b *WebhookMessageCreateBuilder) ClearFiles() *WebhookMessageCreateBuilder
ClearFiles removes all files of this WebhookMessageCreate
func (*WebhookMessageCreateBuilder) RemoveEmbed ¶ added in v1.2.0
func (b *WebhookMessageCreateBuilder) RemoveEmbed(index int) *WebhookMessageCreateBuilder
RemoveEmbed removes an embed from the WebhookMessageCreate
func (*WebhookMessageCreateBuilder) RemoveFiles ¶ added in v1.2.1
func (b *WebhookMessageCreateBuilder) RemoveFiles(i int) *WebhookMessageCreateBuilder
RemoveFiles removes the file at this index
func (*WebhookMessageCreateBuilder) SetAllowedMentions ¶ added in v1.2.0
func (b *WebhookMessageCreateBuilder) SetAllowedMentions(allowedMentions *AllowedMentions) *WebhookMessageCreateBuilder
SetAllowedMentions sets the allowed mentions of the WebhookMessageCreate
func (*WebhookMessageCreateBuilder) SetAllowedMentionsEmpty ¶ added in v1.2.0
func (b *WebhookMessageCreateBuilder) SetAllowedMentionsEmpty() *WebhookMessageCreateBuilder
SetAllowedMentionsEmpty sets the allowed mentions of the WebhookMessageCreate to nothing
func (*WebhookMessageCreateBuilder) SetComponents ¶ added in v1.2.0
func (b *WebhookMessageCreateBuilder) SetComponents(components ...Component) *WebhookMessageCreateBuilder
SetComponents sets the Component(s) of the WebhookMessageCreate
func (*WebhookMessageCreateBuilder) SetContent ¶ added in v1.2.0
func (b *WebhookMessageCreateBuilder) SetContent(content string) *WebhookMessageCreateBuilder
SetContent sets the content of the WebhookMessageCreate
func (*WebhookMessageCreateBuilder) SetContentf ¶ added in v1.2.0
func (b *WebhookMessageCreateBuilder) SetContentf(content string, a ...interface{}) *WebhookMessageCreateBuilder
SetContentf sets the content of the WebhookMessageCreate with format
func (*WebhookMessageCreateBuilder) SetEmbeds ¶ added in v1.2.0
func (b *WebhookMessageCreateBuilder) SetEmbeds(embeds ...Embed) *WebhookMessageCreateBuilder
SetEmbeds sets the embeds of the WebhookMessageCreate
func (*WebhookMessageCreateBuilder) SetEphemeral ¶ added in v1.2.0
func (b *WebhookMessageCreateBuilder) SetEphemeral(ephemeral bool) *WebhookMessageCreateBuilder
SetEphemeral adds/removes MessageFlagEphemeral to the message flags
func (*WebhookMessageCreateBuilder) SetFiles ¶ added in v1.2.1
func (b *WebhookMessageCreateBuilder) SetFiles(files ...restclient.File) *WebhookMessageCreateBuilder
SetFiles sets the files for this WebhookMessageCreate
func (*WebhookMessageCreateBuilder) SetFlags ¶ added in v1.2.0
func (b *WebhookMessageCreateBuilder) SetFlags(flags MessageFlags) *WebhookMessageCreateBuilder
SetFlags sets the message flags of the WebhookMessageCreate
func (*WebhookMessageCreateBuilder) SetTTS ¶ added in v1.2.0
func (b *WebhookMessageCreateBuilder) SetTTS(tts bool) *WebhookMessageCreateBuilder
SetTTS sets if the WebhookMessageCreate is a tts message
type WebhookMessageUpdate ¶
type WebhookMessageUpdate struct { Content string `json:"content"` Embeds []Embed `json:"embeds"` Components []Component `json:"components"` Attachments []Attachment `json:"attachments"` Files []restclient.File `json:"-"` AllowedMentions *AllowedMentions `json:"allowed_mentions"` Flags MessageFlags `json:"flags"` // contains filtered or unexported fields }
WebhookMessageUpdate is used to edit a WebhookMessage
func (WebhookMessageUpdate) MarshalJSON ¶ added in v1.2.0
func (m WebhookMessageUpdate) MarshalJSON() ([]byte, error)
MarshalJSON marshals the WebhookMessageUpdate into json
func (WebhookMessageUpdate) ToBody ¶ added in v1.2.1
func (m WebhookMessageUpdate) ToBody() (interface{}, error)
ToBody returns the WebhookMessageUpdate ready for body
type WebhookMessageUpdateBuilder ¶ added in v1.2.0
type WebhookMessageUpdateBuilder struct {
WebhookMessageUpdate
}
WebhookMessageUpdateBuilder helper to build WebhookMessageUpdate easier
func NewWebhookMessageUpdateBuilder ¶ added in v1.2.0
func NewWebhookMessageUpdateBuilder() *WebhookMessageUpdateBuilder
NewWebhookMessageUpdateBuilder creates a new WebhookMessageUpdateBuilder to be built later
func (*WebhookMessageUpdateBuilder) AddComponents ¶ added in v1.2.0
func (b *WebhookMessageUpdateBuilder) AddComponents(components ...Component) *WebhookMessageUpdateBuilder
AddComponents adds the Component(s) to the WebhookMessage
func (*WebhookMessageUpdateBuilder) AddEmbeds ¶ added in v1.2.0
func (b *WebhookMessageUpdateBuilder) AddEmbeds(embeds ...Embed) *WebhookMessageUpdateBuilder
AddEmbeds adds multiple embeds to the WebhookMessage
func (*WebhookMessageUpdateBuilder) AddFile ¶ added in v1.2.1
func (b *WebhookMessageUpdateBuilder) AddFile(name string, reader io.Reader, flags ...restclient.FileFlags) *WebhookMessageUpdateBuilder
AddFile adds a file to the WebhookMessage
func (*WebhookMessageUpdateBuilder) AddFiles ¶ added in v1.2.1
func (b *WebhookMessageUpdateBuilder) AddFiles(files ...restclient.File) *WebhookMessageUpdateBuilder
AddFiles adds the files to the WebhookMessage
func (*WebhookMessageUpdateBuilder) Build ¶ added in v1.2.0
func (b *WebhookMessageUpdateBuilder) Build() WebhookMessageUpdate
Build builds the WebhookMessageUpdateBuilder to a WebhookMessageUpdate struct
func (*WebhookMessageUpdateBuilder) ClearAllowedMentions ¶ added in v1.2.0
func (b *WebhookMessageUpdateBuilder) ClearAllowedMentions() *WebhookMessageUpdateBuilder
ClearAllowedMentions clears the allowed mentions of the Message
func (*WebhookMessageUpdateBuilder) ClearComponents ¶ added in v1.2.0
func (b *WebhookMessageUpdateBuilder) ClearComponents() *WebhookMessageUpdateBuilder
ClearComponents removes all of the Component(s) of the WebhookMessage
func (*WebhookMessageUpdateBuilder) ClearEmbeds ¶ added in v1.2.0
func (b *WebhookMessageUpdateBuilder) ClearEmbeds() *WebhookMessageUpdateBuilder
ClearEmbeds removes all of the embeds from the WebhookMessage
func (*WebhookMessageUpdateBuilder) ClearFiles ¶ added in v1.2.1
func (b *WebhookMessageUpdateBuilder) ClearFiles() *WebhookMessageUpdateBuilder
ClearFiles removes all files of this WebhookMessage
func (*WebhookMessageUpdateBuilder) RemoveComponent ¶ added in v1.2.0
func (b *WebhookMessageUpdateBuilder) RemoveComponent(i int) *WebhookMessageUpdateBuilder
RemoveComponent removes a Component from the WebhookMessage
func (*WebhookMessageUpdateBuilder) RemoveEmbed ¶ added in v1.2.0
func (b *WebhookMessageUpdateBuilder) RemoveEmbed(index int) *WebhookMessageUpdateBuilder
RemoveEmbed removes an embed from the WebhookMessage
func (*WebhookMessageUpdateBuilder) RemoveFiles ¶ added in v1.2.1
func (b *WebhookMessageUpdateBuilder) RemoveFiles(i int) *WebhookMessageUpdateBuilder
RemoveFiles removes the file at this index
func (*WebhookMessageUpdateBuilder) RetainAttachments ¶ added in v1.2.1
func (b *WebhookMessageUpdateBuilder) RetainAttachments(attachments ...Attachment) *WebhookMessageUpdateBuilder
RetainAttachments removes all Attachment(s) from this WebhookMessage except the ones provided
func (*WebhookMessageUpdateBuilder) RetainAttachmentsByID ¶ added in v1.2.1
func (b *WebhookMessageUpdateBuilder) RetainAttachmentsByID(attachmentIDs ...Snowflake) *WebhookMessageUpdateBuilder
RetainAttachmentsByID removes all Attachment(s) from this WebhookMessage except the ones provided
func (*WebhookMessageUpdateBuilder) SetAllowedMentions ¶ added in v1.2.0
func (b *WebhookMessageUpdateBuilder) SetAllowedMentions(allowedMentions *AllowedMentions) *WebhookMessageUpdateBuilder
SetAllowedMentions sets the AllowedMentions of the Message
func (*WebhookMessageUpdateBuilder) SetComponents ¶ added in v1.2.0
func (b *WebhookMessageUpdateBuilder) SetComponents(components ...Component) *WebhookMessageUpdateBuilder
SetComponents sets the Component(s) of the WebhookMessage
func (*WebhookMessageUpdateBuilder) SetContent ¶ added in v1.2.0
func (b *WebhookMessageUpdateBuilder) SetContent(content string) *WebhookMessageUpdateBuilder
SetContent sets content of the WebhookMessage
func (*WebhookMessageUpdateBuilder) SetContentf ¶ added in v1.2.0
func (b *WebhookMessageUpdateBuilder) SetContentf(content string, a ...interface{}) *WebhookMessageUpdateBuilder
SetContentf sets content of the WebhookMessage
func (*WebhookMessageUpdateBuilder) SetEmbeds ¶ added in v1.2.0
func (b *WebhookMessageUpdateBuilder) SetEmbeds(embeds ...Embed) *WebhookMessageUpdateBuilder
SetEmbeds sets the embeds of the WebhookMessage
func (*WebhookMessageUpdateBuilder) SetFiles ¶ added in v1.2.1
func (b *WebhookMessageUpdateBuilder) SetFiles(files ...restclient.File) *WebhookMessageUpdateBuilder
SetFiles sets the files for this WebhookMessage
type WebhookType ¶ added in v1.1.0
type WebhookType int
WebhookType indicates the Webhook type
const ( WebhookTypeIncoming WebhookType = iota + 1 WebhookTypeChannelFollower WebhookTypeApplication )
all WebhookType(s)
type WebhookUpdate ¶ added in v1.1.0
type WebhookUpdate struct { Name *string `json:"name,omitempty"` Avatar io.Reader `json:"avatar,omitempty"` }
WebhookUpdate is used to update a Webhook