api

package
v0.5.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ButtonStylePrimary = iota + 1
	ButtonStyleSecondary
	ButtonStyleSuccess
	ButtonStyleDanger
	ButtonStyleLink
)

Supported ButtonStyle(s)

View Source
const (
	CommandPermissionTypeRole = iota + 1
	CommandPermissionTypeUser
)

types of CommandPermissionType

View Source
const (
	ComponentTypeActionRow = iota + 1
	ComponentTypeButton
)

Supported ComponentType(s)

View Source
const Github = "https://github.com/DisgoOrg/disgo"

Github is the disgo github url

Variables

View Source
var (
	ErrNoGateway     = errors.New("no gateway initialized")
	ErrNoGatewayConn = errors.New("no active gateway connection found")
)

errors returned when no gateway or ws conn exists

View Source
var DefaultInteractionAllowedMentions = AllowedMentions{
	Parse:       []AllowedMentionType{AllowedMentionTypeUsers},
	Roles:       []Snowflake{},
	Users:       []Snowflake{},
	RepliedUser: false,
}

DefaultInteractionAllowedMentions gives you the default AllowedMentions for an Interaction

View Source
var DefaultMessageAllowedMentions = AllowedMentions{
	Parse:       []AllowedMentionType{AllowedMentionTypeUsers, AllowedMentionTypeRoles, AllowedMentionTypeEveryone},
	Roles:       []Snowflake{},
	Users:       []Snowflake{},
	RepliedUser: true,
}

DefaultMessageAllowedMentions gives you the default AllowedMentions for a Message

View Source
var ErrDMChannelToYourself = errors.New("can't open a dm channel to yourself")

ErrDMChannelToYourself occurs when opening a DMChannel to yourself

View Source
var ErrMaxCommands = errors.New("you can provide a max of 100 application commands")

ErrMaxCommands returned if a Guild reached max of 100 Command(s)

View Source
var UserAgent = "DiscordBot (" + Github + ", " + Version + ")"

UserAgent is the global useragent disgo uses for all its requests

View Source
var Version = getVersion()

Version returns the current used disgo version in the format vx.x.x

Functions

func GetOS

func GetOS() string

GetOS returns the simplified version of the operating system for sending to Discord in the IdentifyCommandDataProperties.OS payload

func Verify

func Verify(disgo Disgo, r *http.Request, key ed25519.PublicKey) bool

Verify implements the verification side of the discord interactions api signing algorithm, as documented here: https://discord.com/developers/docs/interactions/slash-commands#security-and-authorization Credit: https://github.com/bsdlp/discord-interactions-go/blob/main/interactions/verify.go

Types

type ActionRow added in v0.4.0

type ActionRow struct {
	ComponentImpl
	Components []Component `json:"components"`
}

ActionRow holds up to 5 Component(s) in a row

func NewActionRow added in v0.4.0

func NewActionRow(components ...Component) ActionRow

NewActionRow creates a new ActionRow holding th provided Component(s)

type Activity

type Activity struct {
	Name          string              `json:"name"`
	Type          ActivityType        `json:"type"`
	URL           *string             `json:"url"`
	CreatedAt     time.Time           `json:"created_at"`
	Timestamps    *ActivityTimestamps `json:"timestamps,omitempty"`
	ApplicationID Snowflake           `json:"application_id,omitempty"`
	Details       *string             `json:"details,omitempty"`
	State         *string             `json:"state,omitempty"`
	Emoji         *ActivityEmoji      `json:"emoji,omitempty"`
	Party         *ActivityParty      `json:"party,omitempty"`
	Assets        *ActivityAssets     `json:"assets,omitempty"`
	Secrets       *ActivitySecrets    `json:"secrets,omitempty"`
	Instance      *bool               `json:"instance,omitempty"`
	Flags         int                 `json:"flags,omitempty"`
}

Activity represents the fields of a user's presence

type ActivityAssets

type ActivityAssets struct {
	LargeImage string `json:"large_image,omitempty"`
	LargeText  string `json:"large_text,omitempty"`
	SmallImage string `json:"small_image,omitempty"`
	SmallText  string `json:"small_text,omitempty"`
}

ActivityAssets are the images for the presence and hover texts

type ActivityEmoji

type ActivityEmoji struct {
	Name     string     `json:"name"`
	ID       *Snowflake `json:"id,omitempty"`
	Animated *bool      `json:"animated,omitempty"`
}

ActivityEmoji is an Emoji object for an Activity

type ActivityParty

type ActivityParty struct {
	ID   Snowflake `json:"id,omitempty"`
	Size []int     `json:"size,omitempty"`
}

ActivityParty is information about the party of the player

type ActivitySecrets

type ActivitySecrets struct {
	Join     string `json:"join,omitempty"`
	Spectate string `json:"spectate,omitempty"`
	Match    string `json:"match,omitempty"`
}

ActivitySecrets contain secrets for Rich Presence joining and spectating

type ActivityTimestamps

type ActivityTimestamps struct {
	Start *time.Time `json:"start,omitempty"`
	End   *time.Time `json:"end,omitempty"`
}

ActivityTimestamps represents when a user started and ended their activity

type ActivityType

type ActivityType int

ActivityType represents the status of a user, one of Game, Streaming, Listening, Watching, Custom or Competing

const (
	Game ActivityType = iota
	Streaming
	Listening
	Watching
	Custom
	Competing
)

Constants for activities

type AddGuildMemberData

type AddGuildMemberData struct {
	AccessToken string      `json:"access_token"`
	Nick        *string     `json:"nick,omitempty"`
	Roles       []Snowflake `json:"roles,omitempty"`
	Mute        *bool       `json:"mute,omitempty"`
	Deaf        *bool       `json:"deaf,omitempty"`
}

AddGuildMemberData is used to add a member via the oauth2 access token to a guild

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       []Snowflake          `json:"roles"`
	Users       []Snowflake          `json:"users"`
	RepliedUser bool                 `json:"replied_user"`
}

AllowedMentions are used for avoiding mentioning users in Message and Interaction

type Attachment added in v0.4.3

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 Message

type AudioController added in v0.2.0

type AudioController interface {
	Disgo() Disgo
	Connect(guildID Snowflake, channelID Snowflake) error
	Disconnect(guildID Snowflake) error
}

AudioController lets you Connect / Disconnect from a VoiceChannel

type Button added in v0.4.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 v0.4.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 v0.4.0

func NewDangerButton(label string, customID string, emoji *Emoji, disabled bool) Button

NewDangerButton creates a new Button with ButtonStyleDanger & the provided parameters

func NewLinkButton added in v0.4.0

func NewLinkButton(label string, url string, emoji *Emoji, disabled bool) Button

NewLinkButton creates a new link Button with ButtonStyleLink & the provided parameters

func NewPrimaryButton added in v0.4.0

func NewPrimaryButton(label string, customID string, emoji *Emoji, disabled bool) Button

NewPrimaryButton creates a new Button with ButtonStylePrimary & the provided parameters

func NewSecondaryButton added in v0.4.0

func NewSecondaryButton(label string, customID string, emoji *Emoji, disabled bool) Button

NewSecondaryButton creates a new Button with ButtonStyleSecondary & the provided parameters

func NewSuccessButton added in v0.4.0

func NewSuccessButton(label string, customID string, emoji *Emoji, disabled bool) Button

NewSuccessButton creates a new Button with ButtonStyleSuccess & the provided parameters

type ButtonInteraction added in v0.4.0

type ButtonInteraction struct {
	*Interaction
	Message *Message               `json:"message,omitempty"`
	Data    *ButtonInteractionData `json:"data,omitempty"`
}

ButtonInteraction is a specific Interaction when CLicked on Button(s)

func (*ButtonInteraction) DeferEdit added in v0.4.0

func (i *ButtonInteraction) DeferEdit() error

DeferEdit replies to the api.ButtonInteraction with api.InteractionResponseTypeDeferredUpdateMessage and cancels the loading state

func (*ButtonInteraction) Edit added in v0.4.3

func (i *ButtonInteraction) Edit(messageCreate MessageCreate) error

Edit replies to the api.ButtonInteraction with api.InteractionResponseTypeUpdateMessage & api.MessageCreate which edits the original api.Message

type ButtonInteractionData added in v0.4.0

type ButtonInteractionData struct {
	CustomID      string        `json:"custom_id"`
	ComponentType ComponentType `json:"component_type"`
}

ButtonInteractionData is the command data payload

type ButtonStyle added in v0.4.0

type ButtonStyle int

ButtonStyle defines how the Button looks like (https://discord.com/assets/7bb017ce52cfd6575e21c058feb3883b.png)

type Cache

type Cache interface {
	Disgo() Disgo
	Close()
	DoCleanup()
	CacheFlags() CacheFlags

	Command(commandID Snowflake) *Command
	GuildCommandCache(guildID Snowflake) map[Snowflake]*Command
	AllGuildCommandCache() map[Snowflake]map[Snowflake]*Command
	GlobalCommandCache() map[Snowflake]*Command
	CacheGlobalCommand(command *Command) *Command
	CacheGuildCommand(command *Command) *Command
	UncacheCommand(commandID Snowflake)

	User(Snowflake) *User
	UserByTag(string) *User
	UsersByName(string, bool) []*User
	Users() []*User
	UserCache() map[Snowflake]*User
	CacheUser(*User) *User
	UncacheUser(Snowflake)
	FindUser(func(*User) bool) *User
	FindUsers(func(*User) bool) []*User

	Guild(Snowflake) *Guild
	GuildsByName(string, bool) []*Guild
	Guilds() []*Guild
	GuildCache() map[Snowflake]*Guild
	CacheGuild(*Guild) *Guild
	UncacheGuild(Snowflake)

	Message(channelID Snowflake, messageID Snowflake) *Message
	Messages(channelID Snowflake) []*Message
	MessageCache(channelID Snowflake) map[Snowflake]*Message
	AllMessageCache() map[Snowflake]map[Snowflake]*Message
	CacheMessage(message *Message) *Message
	UncacheMessage(channelID Snowflake, messageID Snowflake)

	Member(Snowflake, Snowflake) *Member
	MemberByTag(Snowflake, string) *Member
	MembersByName(Snowflake, string, bool) []*Member
	Members(Snowflake) []*Member
	AllMembers() []*Member
	MemberCache(Snowflake) map[Snowflake]*Member
	AllMemberCache() map[Snowflake]map[Snowflake]*Member
	CacheMember(member *Member) *Member
	UncacheMember(Snowflake, Snowflake)
	FindMember(Snowflake, func(*Member) bool) *Member
	FindMembers(Snowflake, func(*Member) bool) []*Member

	VoiceState(guildID Snowflake, userID Snowflake) *VoiceState
	VoiceStates(guildID Snowflake) []*VoiceState
	VoiceStateCache(guildID Snowflake) map[Snowflake]*VoiceState
	CacheVoiceState(voiceState *VoiceState) *VoiceState
	UncacheVoiceState(guildID Snowflake, userID Snowflake)

	Role(roleID Snowflake) *Role
	RolesByName(Snowflake, string, bool) []*Role
	Roles(Snowflake) []*Role
	AllRoles() []*Role
	RoleCache(Snowflake) map[Snowflake]*Role
	AllRoleCache() map[Snowflake]map[Snowflake]*Role
	CacheRole(*Role) *Role
	UncacheRole(Snowflake, Snowflake)
	FindRole(Snowflake, func(*Role) bool) *Role
	FindRoles(Snowflake, func(*Role) bool) []*Role

	DMChannel(Snowflake) *DMChannel
	DMChannels() []*DMChannel
	DMChannelCache() map[Snowflake]*DMChannel
	CacheDMChannel(*DMChannel) *DMChannel
	UncacheDMChannel(dmChannelID Snowflake)
	FindDMChannel(func(*DMChannel) bool) *DMChannel
	FindDMChannels(func(*DMChannel) bool) []*DMChannel

	Channel(Snowflake) *Channel
	MessageChannel(Snowflake) *MessageChannel
	GuildChannel(Snowflake) *GuildChannel

	TextChannel(Snowflake) *TextChannel
	TextChannelsByName(Snowflake, string, bool) []*TextChannel
	TextChannels(Snowflake) []*TextChannel
	TextChannelCache(Snowflake) map[Snowflake]*TextChannel
	CacheTextChannel(*TextChannel) *TextChannel
	UncacheTextChannel(Snowflake, Snowflake)
	FindTextChannel(Snowflake, func(*TextChannel) bool) *TextChannel
	FindTextChannels(Snowflake, func(*TextChannel) bool) []*TextChannel

	StoreChannel(Snowflake) *StoreChannel
	StoreChannelsByName(Snowflake, string, bool) []*StoreChannel
	StoreChannels(Snowflake) []*StoreChannel
	StoreChannelCache(Snowflake) map[Snowflake]*StoreChannel
	CacheStoreChannel(*StoreChannel) *StoreChannel
	UncacheStoreChannel(Snowflake, Snowflake)
	FindStoreChannel(Snowflake, func(*StoreChannel) bool) *StoreChannel
	FindStoreChannels(Snowflake, func(*StoreChannel) bool) []*StoreChannel

	VoiceChannel(Snowflake) *VoiceChannel
	VoiceChannelsByName(Snowflake, string, bool) []*VoiceChannel
	VoiceChannels(Snowflake) []*VoiceChannel
	VoiceChannelCache(Snowflake) map[Snowflake]*VoiceChannel
	CacheVoiceChannel(*VoiceChannel) *VoiceChannel
	UncacheVoiceChannel(Snowflake, Snowflake)
	FindVoiceChannel(Snowflake, func(*VoiceChannel) bool) *VoiceChannel
	FindVoiceChannels(Snowflake, func(*VoiceChannel) bool) []*VoiceChannel

	Category(Snowflake) *Category
	CategoriesByName(Snowflake, string, bool) []*Category
	Categories(Snowflake) []*Category
	AllCategories() []*Category
	CategoryCache(Snowflake) map[Snowflake]*Category
	AllCategoryCache() map[Snowflake]map[Snowflake]*Category
	CacheCategory(*Category) *Category
	UncacheCategory(Snowflake, Snowflake)
	FindCategory(Snowflake, func(*Category) bool) *Category
	FindCategories(Snowflake, func(*Category) bool) []*Category

	Emote(emoteID Snowflake) *Emoji
	EmotesByName(guildID Snowflake, name string, ignoreCase bool) []*Emoji
	Emotes(guildID Snowflake) []*Emoji
	EmoteCache(guildID Snowflake) map[Snowflake]*Emoji
	AllEmoteCache() map[Snowflake]map[Snowflake]*Emoji
	CacheEmote(*Emoji) *Emoji
	UncacheEmote(guildID Snowflake, emoteID Snowflake)
}

Cache allows you to access the objects that are stored in-memory by Discord

type CacheFlags added in v0.2.0

type CacheFlags int

CacheFlags are used to enable/disable certain internal caches

const (
	CacheFlagsNone      CacheFlags = 0
	CacheFlagDMChannels CacheFlags = 1 << iota
	CacheFlagCategories
	CacheFlagTextChannels
	CacheFlagVoiceChannels
	CacheFlagStoreChannels
	CacheFlagRoles
	CacheFlagRoleTags
	CacheFlagEmotes
	CacheFlagVoiceState
	CacheFlagCommands
	CacheFlagCommandPermissions

	CacheFlagsDefault = CacheFlagDMChannels |
		CacheFlagCategories |
		CacheFlagTextChannels |
		CacheFlagVoiceChannels |
		CacheFlagStoreChannels |
		CacheFlagRoles |
		CacheFlagEmotes
)

values for CacheFlags

func (CacheFlags) Add added in v0.2.0

func (c CacheFlags) Add(bits ...CacheFlags) CacheFlags

Add allows you to add multiple bits together, producing a new bit

func (CacheFlags) Has added in v0.2.0

func (c CacheFlags) Has(bit CacheFlags) bool

Has will check whether the Bit contains another bit

func (CacheFlags) HasAll added in v0.2.0

func (c CacheFlags) HasAll(bits ...CacheFlags) bool

HasAll will ensure that the bit includes all of the bits entered

func (CacheFlags) Missing added in v0.2.0

func (c CacheFlags) Missing(bit CacheFlags) bool

Missing will do the inverse of Bit.Has

func (CacheFlags) MissingAny added in v0.2.0

func (c CacheFlags) MissingAny(bits ...CacheFlags) bool

MissingAny will check whether the bit is missing any one of the bits

func (CacheFlags) Remove added in v0.2.0

func (c CacheFlags) Remove(bits ...CacheFlags) CacheFlags

Remove allows you to subtract multiple bits from the first, producing a new bit

type CacheStrategy added in v0.2.0

type CacheStrategy func(disgo Disgo) bool

CacheStrategy is used to determine whether something should be cached when making an api request. When using the gateway, you'll receive the event shortly afterwards if you have the correct GatewayIntents.

var (
	CacheStrategyYes  CacheStrategy = func(disgo Disgo) bool { return true }
	CacheStrategyNo   CacheStrategy = func(disgo Disgo) bool { return true }
	CacheStrategyNoWs CacheStrategy = func(disgo Disgo) bool { return disgo.HasGateway() }
)

Default cache strategy choices

type Category

type Category struct {
	GuildChannel
}

Category groups text & voice channels in servers together

type Channel

type Channel struct {
	Disgo            Disgo
	ID               Snowflake    `json:"id"`
	Name             *string      `json:"name,omitempty"`
	Type             ChannelType  `json:"type"`
	LastMessageID    *Snowflake   `json:"last_message_id,omitempty"`
	GuildID          *Snowflake   `json:"guild_id,omitempty"`
	Position         *int         `json:"position,omitempty"`
	Topic            *string      `json:"topic,omitempty"`
	NSFW             *bool        `json:"nsfw,omitempty"`
	Bitrate          *int         `json:"bitrate,omitempty"`
	UserLimit        *int         `json:"user_limit,omitempty"`
	RateLimitPerUser *int         `json:"rate_limit_per_user,omitempty"`
	Recipients       []*User      `json:"recipients,omitempty"`
	Icon             *string      `json:"icon,omitempty"`
	OwnerID          *Snowflake   `json:"owner_id,omitempty"`
	ApplicationID    *Snowflake   `json:"application_id,omitempty"`
	ParentID         *Snowflake   `json:"parent_id,omitempty"`
	Permissions      *Permissions `json:"permissions,omitempty"`
}

Channel is a generic discord channel object

type ChannelType

type ChannelType int

ChannelType for interacting with discord's channels

const (
	ChannelTypeText ChannelType = iota
	ChannelTypeDM
	ChannelTypeVoice
	ChannelTypeGroupDM
	ChannelTypeCategory
	ChannelTypeNews
	ChannelTypeStore
)

Channel constants

type Command added in v0.2.0

type Command struct {
	Disgo             Disgo
	GuildPermissions  map[Snowflake]*GuildCommandPermissions
	GuildID           *Snowflake      `json:"guild_id"`
	ID                Snowflake       `json:"id,omitempty"`
	ApplicationID     Snowflake       `json:"application_id,omitempty"`
	Name              string          `json:"name"`
	Description       string          `json:"description"`
	DefaultPermission bool            `json:"default_permission,omitempty"`
	Options           []CommandOption `json:"options,omitempty"`
}

Command is the base "command" model that belongs to an application.

func (Command) Delete added in v0.2.0

func (c Command) Delete() error

Delete deletes the Command from discord

func (*Command) Fetch added in v0.2.0

func (c *Command) Fetch() error

Fetch updates/fetches the current Command from discord

func (*Command) FetchPermissions added in v0.2.0

func (c *Command) FetchPermissions(guildID Snowflake) (*GuildCommandPermissions, error)

FetchPermissions fetched the GuildCommandPermissions for a specific Guild from discord

func (Command) FromGuild added in v0.2.0

func (c Command) FromGuild() bool

FromGuild returns true if this is a guild Command else false

func (Command) GetPermissions added in v0.2.0

func (c Command) GetPermissions(guildID Snowflake) *GuildCommandPermissions

GetPermissions returns the GuildCommandPermissions for the specific Guild from the Cache

func (Command) Guild added in v0.2.0

func (c Command) Guild() *Guild

Guild returns the Guild the Command is from from the Cache or nil if it is a global Command

func (*Command) SetPermissions added in v0.2.0

func (c *Command) SetPermissions(guildID Snowflake, permissions ...CommandPermission) error

SetPermissions sets the GuildCommandPermissions for a specific Guild. this overrides all existing CommandPermission(s). thx discord for that

func (*Command) ToCreate added in v0.4.2

func (c *Command) ToCreate() CommandCreate

ToCreate return the CommandCreate for this Command

func (*Command) Update added in v0.2.0

func (c *Command) Update(command CommandUpdate) error

Update updates the current Command with the given fields

type CommandCreate added in v0.3.0

type CommandCreate struct {
	Name              string          `json:"name,omitempty"`
	Description       string          `json:"description,omitempty"`
	DefaultPermission bool            `json:"default_permission,omitempty"`
	Options           []CommandOption `json:"options,omitempty"`
}

CommandCreate is used to create an Command. all fields are optional

type CommandInteraction added in v0.4.0

type CommandInteraction struct {
	*Interaction
	Data *CommandInteractionData `json:"data,omitempty"`
}

CommandInteraction is a specific Interaction when using Command(s)

type CommandInteractionData added in v0.4.0

type CommandInteractionData struct {
	ID       Snowflake     `json:"id"`
	Name     string        `json:"name"`
	Resolved *Resolved     `json:"resolved,omitempty"`
	Options  []*OptionData `json:"options,omitempty"`
}

CommandInteractionData is the command data payload

type CommandOption

type CommandOption struct {
	Type        CommandOptionType `json:"type"`
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Required    bool              `json:"required,omitempty"`
	Choices     []OptionChoice    `json:"choices,omitempty"`
	Options     []CommandOption   `json:"options,omitempty"`
}

CommandOption are the arguments used in Command.Options

func NewBooleanOption added in v0.4.2

func NewBooleanOption(name string, description string, options ...CommandOption) CommandOption

NewBooleanOption creates a new CommandOption with CommandOptionTypeSubCommand

func NewChannelOption added in v0.4.2

func NewChannelOption(name string, description string, options ...CommandOption) CommandOption

NewChannelOption creates a new CommandOption with CommandOptionTypeSubCommand

func NewCommandOption added in v0.4.2

func NewCommandOption(optionType CommandOptionType, name string, description string, options ...CommandOption) CommandOption

NewCommandOption creates a new CommandOption with the provided params

func NewIntegerOption added in v0.4.2

func NewIntegerOption(name string, description string, options ...CommandOption) CommandOption

NewIntegerOption creates a new CommandOption with CommandOptionTypeSubCommand

func NewMentionableOption added in v0.4.2

func NewMentionableOption(name string, description string, options ...CommandOption) CommandOption

NewMentionableOption creates a new CommandOption with CommandOptionTypeUser or CommandOptionTypeRole

func NewRoleOption added in v0.4.3

func NewRoleOption(name string, description string, options ...CommandOption) CommandOption

NewRoleOption creates a new CommandOption with CommandOptionTypeRole

func NewStringOption added in v0.4.2

func NewStringOption(name string, description string, options ...CommandOption) CommandOption

NewStringOption creates a new CommandOption with CommandOptionTypeSubCommand

func NewSubCommand added in v0.4.2

func NewSubCommand(name string, description string, options ...CommandOption) CommandOption

NewSubCommand creates a new CommandOption with CommandOptionTypeSubCommand

func NewSubCommandGroup added in v0.4.2

func NewSubCommandGroup(name string, description string, options ...CommandOption) CommandOption

NewSubCommandGroup creates a new CommandOption with CommandOptionTypeSubCommandGroup

func NewUserOption added in v0.4.2

func NewUserOption(name string, description string, options ...CommandOption) CommandOption

NewUserOption creates a new CommandOption with CommandOptionTypeSubCommand

func (*CommandOption) AddChoice added in v0.4.2

func (o *CommandOption) AddChoice(name string, value interface{}) *CommandOption

AddChoice adds a new choice to the the CommandOption

func (*CommandOption) AddOptions added in v0.4.2

func (o *CommandOption) AddOptions(options ...CommandOption) *CommandOption

AddOptions adds multiple choices to the the CommandOption

func (*CommandOption) SetRequired added in v0.4.2

func (o *CommandOption) SetRequired(required bool) *CommandOption

SetRequired sets if the CommandOption is required

type CommandOptionType added in v0.2.0

type CommandOptionType int

CommandOptionType specifies the type of the arguments used in Command.Options

const (
	CommandOptionTypeSubCommand CommandOptionType = iota + 1
	CommandOptionTypeSubCommandGroup
	CommandOptionTypeString
	CommandOptionTypeInteger
	CommandOptionTypeBoolean
	CommandOptionTypeUser
	CommandOptionTypeChannel
	CommandOptionTypeRole
	CommandOptionTypeMentionable
)

Constants for each slash command option type

type CommandPermission added in v0.2.0

type CommandPermission struct {
	ID         Snowflake             `json:"id"`
	Type       CommandPermissionType `json:"type"`
	Permission bool                  `json:"permission"`
}

CommandPermission holds a User or Role and if they are allowed to use the Command

type CommandPermissionType added in v0.2.0

type CommandPermissionType int

CommandPermissionType is the type of the CommandPermission

type CommandUpdate added in v0.3.0

type CommandUpdate struct {
	Name              *string         `json:"name,omitempty"`
	Description       *string         `json:"description,omitempty"`
	DefaultPermission *bool           `json:"default_permission,omitempty"`
	Options           []CommandOption `json:"options,omitempty"`
}

CommandUpdate is used to update an existing Command. all fields are optional

type Component added in v0.4.0

type Component interface {
	Type() ComponentType
}

Component is a general interface each Component needs to implement

type ComponentImpl added in v0.4.0

type ComponentImpl struct {
	ComponentType ComponentType `json:"type"`
}

ComponentImpl is used to embed in each different ComponentType

func (ComponentImpl) Type added in v0.4.0

func (t ComponentImpl) Type() ComponentType

Type returns the ComponentType of this Component

type ComponentType added in v0.4.0

type ComponentType int

ComponentType defines different Component(s)

type DMChannel

type DMChannel struct {
	MessageChannel
}

DMChannel is used for interacting in private Message(s) with users

type DeconstructedSnowflake

type DeconstructedSnowflake struct {
	Timestamp int64
	WorkerID  int64
	ProcessID int64
	Increment int64
	Binary    string
}

DeconstructedSnowflake contains the properties used by Discord for each ID

type Disgo

type Disgo interface {
	Logger() log.Logger
	Connect() error
	Start()
	Close()
	Token() string
	Gateway() Gateway
	RestClient() RestClient
	WebhookServer() WebhookServer
	Cache() Cache
	GatewayIntents() GatewayIntents
	RawGatewayEventsEnabled() bool
	ApplicationID() Snowflake
	SelfUser() *SelfUser
	SelfUserID() Snowflake
	EntityBuilder() EntityBuilder
	EventManager() EventManager
	VoiceDispatchInterceptor() VoiceDispatchInterceptor
	SetVoiceDispatchInterceptor(voiceInterceptor VoiceDispatchInterceptor)
	AudioController() AudioController
	HeartbeatLatency() time.Duration
	LargeThreshold() int
	HasGateway() bool

	GetCommand(commandID Snowflake) (*Command, error)
	GetCommands() ([]*Command, error)
	CreateCommand(command CommandCreate) (*Command, error)
	EditCommand(commandID Snowflake, command CommandUpdate) (*Command, error)
	DeleteCommand(commandID Snowflake) error
	SetCommands(commands ...CommandCreate) ([]*Command, error)

	GetGuildCommand(guildID Snowflake, commandID Snowflake) (*Command, error)
	GetGuildCommands(guildID Snowflake) ([]*Command, error)
	CreateGuildCommand(guildID Snowflake, command CommandCreate) (*Command, error)
	EditGuildCommand(guildID Snowflake, commandID Snowflake, command CommandUpdate) (*Command, error)
	DeleteGuildCommand(guildID Snowflake, commandID Snowflake) error
	SetGuildCommands(guildID Snowflake, commands ...CommandCreate) ([]*Command, error)

	GetGuildCommandsPermissions(guildID Snowflake) ([]*GuildCommandPermissions, error)
	GetGuildCommandPermissions(guildID Snowflake, commandID Snowflake) (*GuildCommandPermissions, error)
	SetGuildCommandsPermissions(guildID Snowflake, commandPermissions ...SetGuildCommandPermissions) ([]*GuildCommandPermissions, error)
	SetGuildCommandPermissions(guildID Snowflake, commandID Snowflake, permissions SetGuildCommandPermissions) (*GuildCommandPermissions, error)
}

Disgo is the main discord interface

type DisgoBuilder

type DisgoBuilder interface {
	SetLogger(level log.Logger) DisgoBuilder
	SetToken(token string) DisgoBuilder
	SetHTTPClient(httpClient *http.Client) DisgoBuilder
	SetGatewayIntents(GatewayIntents ...GatewayIntents) DisgoBuilder
	SetRawGatewayEventsEnabled(enabled bool) DisgoBuilder
	SetVoiceDispatchInterceptor(voiceDispatchInterceptor VoiceDispatchInterceptor) DisgoBuilder
	SetEntityBuilder(entityBuilder EntityBuilder) DisgoBuilder
	SetEventManager(eventManager EventManager) DisgoBuilder
	AddEventListeners(eventsListeners ...EventListener) DisgoBuilder
	SetWebhookServer(webhookServer WebhookServer) DisgoBuilder
	SetWebhookServerProperties(listenURL string, listenPort int, publicKey string) DisgoBuilder
	SetRestClient(restClient RestClient) DisgoBuilder
	SetCache(cache Cache) DisgoBuilder
	SetMemberCachePolicy(memberCachePolicy MemberCachePolicy) DisgoBuilder
	SetMessageCachePolicy(messageCachePolicy MessageCachePolicy) DisgoBuilder
	SetCacheFlags(cacheFlags CacheFlags) DisgoBuilder
	SetGateway(gateway Gateway) DisgoBuilder
	Build() (Disgo, error)
}

DisgoBuilder allows you to create a Disgo client through a series of methods

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"`
	Footer      *EmbedFooter   `json:"footer,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) Build

func (b *EmbedBuilder) Build() Embed

Build returns your built Embed

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 v0.3.0

func (b *EmbedBuilder) SetAuthorIcon(iconURL string) *EmbedBuilder

SetAuthorIcon sets the author of the EmbedBuilder with all properties

func (*EmbedBuilder) SetAuthorName added in v0.3.0

func (b *EmbedBuilder) SetAuthorName(name string) *EmbedBuilder

SetAuthorName sets the author of the EmbedBuilder

func (*EmbedBuilder) SetAuthorURL added in v0.3.0

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 added in v0.2.0

func (b *EmbedBuilder) SetEmbedAuthor(author *EmbedAuthor) *EmbedBuilder

SetEmbedAuthor sets the author of the EmbedBuilder using an EmbedAuthor struct

func (*EmbedBuilder) SetEmbedFooter added in v0.3.0

func (b *EmbedBuilder) SetEmbedFooter(footer *EmbedFooter) *EmbedBuilder

SetEmbedFooter sets the footer of the EmbedBuilder

func (*EmbedBuilder) SetField added in v0.2.0

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 v0.3.0

func (b *EmbedBuilder) SetFooterIcon(iconURL string) *EmbedBuilder

SetFooterIcon sets the footer of the EmbedBuilder by iconURL

func (*EmbedBuilder) SetFooterText added in v0.3.0

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 v0.3.0

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 EmbedFooter

type EmbedFooter struct {
	Text         string  `json:"text"`
	IconURL      *string `json:"icon_url,omitempty"`
	ProxyIconURL *string `json:"proxy_icon_url,omitempty"`
}

The EmbedFooter 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 EmbedType

type EmbedType string

EmbedType is the type of an Embed

const (
	EmbedTypeRich    EmbedType = "rich"
	EmbedTypeImage   EmbedType = "image"
	EmbedTypeVideo   EmbedType = "video"
	EmbedTypeGifV    EmbedType = "rich"
	EmbedTypeArticle EmbedType = "article"
	EmbedTypeLink    EmbedType = "link"
)

Constants for EmbedType

type Emoji added in v0.4.3

type Emoji struct {
	Disgo    Disgo
	GuildID  Snowflake `json:"guild_id,omitempty"`
	Name     string    `json:"name,omitempty"`
	ID       Snowflake `json:"id,omitempty"`
	Animated bool      `json:"animated,omitempty"`
}

Emoji allows you to interact with emojis & emotes

func NewEmoji added in v0.4.0

func NewEmoji(name string) *Emoji

NewEmoji creates a new emoji with the given unicode

func NewEmote added in v0.4.0

func NewEmote(name string, emoteID Snowflake, animated bool) *Emoji

NewEmote creates a new custom Emoji with the given parameters

func (*Emoji) Guild added in v0.4.3

func (e *Emoji) Guild() *Guild

Guild returns the Guild of the Emoji from the Cache

func (*Emoji) Mention added in v0.4.3

func (e *Emoji) Mention() string

Mention returns the string used to send the Emoji

func (*Emoji) Reaction added in v0.4.3

func (e *Emoji) Reaction() string

Reaction returns the identifier used for adding and removing reactions for messages in discord

func (*Emoji) String added in v0.4.3

func (e *Emoji) String() string

String formats the Emoji as string

type EntityBuilder added in v0.2.0

type EntityBuilder interface {
	Disgo() Disgo

	CreateButtonInteraction(fullInteraction *FullInteraction, c chan InteractionResponse, updateCache CacheStrategy) *ButtonInteraction
	CreateCommandInteraction(fullInteraction *FullInteraction, c chan InteractionResponse, updateCache CacheStrategy) *CommandInteraction

	CreateGlobalCommand(command *Command, updateCache CacheStrategy) *Command

	CreateUser(user *User, updateCache CacheStrategy) *User

	CreateMessage(message *FullMessage, updateCache CacheStrategy) *Message

	CreateGuild(guild *Guild, updateCache CacheStrategy) *Guild
	CreateMember(guildID Snowflake, member *Member, updateCache CacheStrategy) *Member
	CreateGuildCommand(guildID Snowflake, command *Command, updateCache CacheStrategy) *Command
	CreateGuildCommandPermissions(guildCommandPermissions *GuildCommandPermissions, updateCache CacheStrategy) *GuildCommandPermissions
	CreateRole(guildID Snowflake, role *Role, updateCache CacheStrategy) *Role
	CreateVoiceState(guildID Snowflake, voiceState *VoiceState, updateCache CacheStrategy) *VoiceState

	CreateTextChannel(channel *Channel, updateCache CacheStrategy) *TextChannel
	CreateVoiceChannel(channel *Channel, updateCache CacheStrategy) *VoiceChannel
	CreateStoreChannel(channel *Channel, updateCache CacheStrategy) *StoreChannel
	CreateCategory(channel *Channel, updateCache CacheStrategy) *Category
	CreateDMChannel(channel *Channel, updateCache CacheStrategy) *DMChannel

	CreateEmoji(guildID Snowflake, emoji *Emoji, updateCache CacheStrategy) *Emoji
}

EntityBuilder is used to create structs for disgo's cache

type ErrorResponse

type ErrorResponse struct {
	Code    int
	Message string
}

ErrorResponse contains custom errors from discord

type Event

type Event interface {
	Disgo() Disgo
	SequenceNumber() int
}

Event the basic interface each event implement

type EventHandler

type EventHandler interface {
	Event() GatewayEventType
	New() interface{}
}

EventHandler provides info about the EventHandler

type EventListener

type EventListener interface {
	OnEvent(event interface{})
}

EventListener is used to create new EventListener to listen to events

type EventManager

type EventManager interface {
	Disgo() Disgo
	Close()
	AddEventListeners(eventListeners ...EventListener)
	Handle(eventType GatewayEventType, replyChannel chan InteractionResponse, sequenceNumber int, payload json.RawMessage)
	Dispatch(event Event)
}

EventManager lets you listen for specific events triggered by raw gateway events

type ExpandedInvite added in v0.2.0

type ExpandedInvite struct {
	Invite
	Uses      int       `json:"uses"`
	MaxUses   int       `json:"max_uses"`
	MaxAge    int       `json:"max_age"`
	Temporary bool      `json:"temporary"`
	CreatedAt time.Time `json:"created_at"`
}

ExpandedInvite is a full Invite struct

type ExplicitContentFilterLevel

type ExplicitContentFilterLevel int

The ExplicitContentFilterLevel of a Guild

const (
	ExplicitContentFilterLevelDisabled ExplicitContentFilterLevel = iota
	ExplicitContentFilterLevelMembersWithoutRoles
	ExplicitContentFilterLevelAllMembers
)

Constants for ExplicitContentFilterLevel

type FullGuild added in v0.2.0

type FullGuild struct {
	*Guild
	Roles       []*Role       `json:"roles"`
	Emojis      []*Emoji      `json:"emojis"`
	Members     []*Member     `json:"members"`
	Channels    []*Channel    `json:"channels"`
	VoiceStates []*VoiceState `json:"voice_states"`
}

FullGuild represents a Guild objects sent by discord with the GatewayEventGuildCreate

type FullInteraction added in v0.4.0

type FullInteraction struct {
	ID          Snowflake       `json:"id"`
	Type        InteractionType `json:"type"`
	GuildID     *Snowflake      `json:"guild_id,omitempty"`
	ChannelID   *Snowflake      `json:"channel_id,omitempty"`
	FullMessage *FullMessage    `json:"message,omitempty"`
	Member      *Member         `json:"member,omitempty"`
	User        *User           `json:"User,omitempty"`
	Token       string          `json:"token"`
	Version     int             `json:"version"`
	Data        json.RawMessage `json:"data,omitempty"`
}

FullInteraction is used for easier unmarshalling of different Interaction(s)

type FullMessage added in v0.4.0

type FullMessage struct {
	*Message
	UnmarshalComponents []UnmarshalComponent `json:"components,omitempty"`
}

FullMessage is used for easier unmarshalling of Component(s) in Message(s)

type Gateway

type Gateway interface {
	Disgo() Disgo
	Open() error
	Status() GatewayStatus
	Close()
	Conn() *websocket.Conn
	Latency() time.Duration
}

Gateway is what is used to connect to discord

type GatewayBotRs

type GatewayBotRs struct {
	URL               string `json:"url"`
	Shards            int    `json:"shards"`
	SessionStartLimit struct {
		Total          int `json:"total"`
		Remaining      int `json:"remaining"`
		ResetAfter     int `json:"reset_after"`
		MaxConcurrency int `json:"max_concurrency"`
	} `json:"session_start_limit"`
}

GatewayBotRs contains the response for GET /gateway/bot

type GatewayCommand

type GatewayCommand struct {
	GatewayPacket
	D interface{} `json:"d"`
}

GatewayCommand object is used when sending data to discord's websocket, it's recommended that you don't use these

func NewGatewayCommand added in v0.2.0

func NewGatewayCommand(op GatewayOp, d interface{}) GatewayCommand

NewGatewayCommand returns a new GatewayCommand struct with the given payload

type GatewayEventHandler

type GatewayEventHandler interface {
	EventHandler
	HandleGatewayEvent(disgo Disgo, eventManager EventManager, sequenceNumber int, payload interface{})
}

GatewayEventHandler is used to handle raw gateway events

type GatewayEventType added in v0.2.0

type GatewayEventType string

GatewayEventType wraps all GatewayEventType types

const (
	GatewayEventHello                         GatewayEventType = "HELLO"
	GatewayEventReady                         GatewayEventType = "READY"
	GatewayEventResumed                       GatewayEventType = "RESUMED"
	GatewayEventReconnect                     GatewayEventType = "RECONNECT"
	GatewayEventInvalidSession                GatewayEventType = "INVALID_SESSION"
	GatewayEventCommandCreate                 GatewayEventType = "APPLICATION_COMMAND_CREATE"
	GatewayEventCommandUpdate                 GatewayEventType = "APPLICATION_COMMAND_UPDATE"
	GatewayEventCommandDelete                 GatewayEventType = "APPLICATION_COMMAND_DELETE"
	GatewayEventChannelCreate                 GatewayEventType = "CHANNEL_CREATE"
	GatewayEventChannelUpdate                 GatewayEventType = "CHANNEL_UPDATE"
	GatewayEventChannelDelete                 GatewayEventType = "CHANNEL_DELETE"
	GatewayEventChannelPinsUpdate             GatewayEventType = "CHANNEL_PINS_UPDATE"
	GatewayEventGuildCreate                   GatewayEventType = "GUILD_CREATE"
	GatewayEventGuildUpdate                   GatewayEventType = "GUILD_UPDATE"
	GatewayEventGuildDelete                   GatewayEventType = "GUILD_DELETE"
	GatewayEventGuildBanAdd                   GatewayEventType = "GUILD_BAN_ADD"
	GatewayEventGuildBanRemove                GatewayEventType = "GUILD_BAN_REMOVE"
	GatewayEventGuildEmojisUpdate             GatewayEventType = "GUILD_EMOJIS_UPDATE"
	GatewayEventGuildIntegrationsUpdate       GatewayEventType = "GUILD_INTEGRATIONS_UPDATE"
	GatewayEventGuildMemberAdd                GatewayEventType = "GUILD_MEMBER_ADD"
	GatewayEventGuildMemberRemove             GatewayEventType = "GUILD_MEMBER_REMOVE"
	GatewayEventGuildMemberUpdate             GatewayEventType = "GUILD_MEMBER_UPDATE"
	GatewayEventGuildMembersChunk             GatewayEventType = "GUILD_MEMBERS_CHUNK"
	GatewayEventGuildRoleCreate               GatewayEventType = "GUILD_ROLE_CREATE"
	GatewayEventGuildRoleUpdate               GatewayEventType = "GUILD_ROLE_UPDATE"
	GatewayEventGuildRoleDelete               GatewayEventType = "GUILD_ROLE_DELETE"
	GatewayEventIntegrationCreate             GatewayEventType = "INTEGRATION_CREATE"
	GatewayEventIntegrationUpdate             GatewayEventType = "INTEGRATION_UPDATE"
	GatewayEventIntegrationDelete             GatewayEventType = "INTEGRATION_DELETE"
	GatewayEventInteractionCreate             GatewayEventType = "INTERACTION_CREATE"
	WebhookEventInteractionCreate             GatewayEventType = "WEBHOOK_INTERACTION_CREATE"
	GatewayEventInviteCreate                  GatewayEventType = "INVITE_CREATE"
	GatewayEventInviteDelete                  GatewayEventType = "INVITE_DELETE"
	GatewayEventMessageCreate                 GatewayEventType = "MESSAGE_CREATE"
	GatewayEventMessageUpdate                 GatewayEventType = "MESSAGE_UPDATE"
	GatewayEventMessageDelete                 GatewayEventType = "MESSAGE_DELETE"
	GatewayEventMessageDeleteBulk             GatewayEventType = "MESSAGE_DELETE_BULK"
	GatewayEventMessageReactionAdd            GatewayEventType = "MESSAGE_REACTION_ADD"
	GatewayEventMessageReactionRemove         GatewayEventType = "MESSAGE_REACTION_REMOVE"
	GatewayEventMessageReactionRemoveAll      GatewayEventType = "MESSAGE_REACTION_REMOVE_ALL"
	GatewayEventMessageReactionRemoveAllEmoji GatewayEventType = "MESSAGE_REACTION_REMOVE_ALL_EMOJI"
	GatewayEventPresenceUpdate                GatewayEventType = "PRESENCE_UPDATE"
	GatewayEventTypingStart                   GatewayEventType = "TYPING_START"
	GatewayEventUserUpdate                    GatewayEventType = "USER_UPDATE"
	GatewayEventVoiceStateUpdate              GatewayEventType = "VOICE_STATE_UPDATE"
	GatewayEventVoiceServerUpdate             GatewayEventType = "VOICE_SERVER_UPDATE"
	GatewayEventWebhooksUpdate                GatewayEventType = "WEBHOOKS_UPDATE"
)

Constants for the gateway events

type GatewayIntents added in v0.3.3

type GatewayIntents int64

GatewayIntents is an extension of the Bit structure used when identifying with discord

const (
	GatewayIntentsGuilds GatewayIntents = 1 << iota
	GatewayIntentsGuildMembers
	GatewayIntentsGuildBans
	GatewayIntentsGuildEmojis
	GatewayIntentsGuildIntegrations
	GatewayIntentsGuildWebhooks
	GatewayIntentsGuildInvites
	GatewayIntentsGuildVoiceStates
	GatewayIntentsGuildPresences
	GatewayIntentsGuildMessages
	GatewayIntentsGuildMessageReactions
	GatewayIntentsGuildMessageTyping
	GatewayIntentsDirectMessages
	GatewayIntentsDirectMessageReactions
	GatewayIntentsDirectMessageTyping

	GatewayIntentsNonPrivileged = GatewayIntentsGuilds |
		GatewayIntentsGuildBans |
		GatewayIntentsGuildEmojis |
		GatewayIntentsGuildIntegrations |
		GatewayIntentsGuildWebhooks |
		GatewayIntentsGuildInvites |
		GatewayIntentsGuildVoiceStates |
		GatewayIntentsGuildMessages |
		GatewayIntentsGuildMessageReactions |
		GatewayIntentsGuildMessageTyping |
		GatewayIntentsDirectMessages |
		GatewayIntentsDirectMessageReactions |
		GatewayIntentsDirectMessageTyping
	GatewayIntentsPrivileged = GatewayIntentsGuildMembers |
		GatewayIntentsGuildPresences
	GatewayIntentsAll = GatewayIntentsNonPrivileged |
		GatewayIntentsPrivileged
	GatewayIntentsNone GatewayIntents = 0
)

Constants for the different bit offsets of GatewayIntents

func (GatewayIntents) Add added in v0.3.3

Add allows you to add multiple bits together, producing a new bit

func (GatewayIntents) Has added in v0.3.3

func (p GatewayIntents) Has(bit GatewayIntents) bool

Has will check whether the Bit contains another bit

func (GatewayIntents) HasAll added in v0.3.3

func (p GatewayIntents) HasAll(bits ...GatewayIntents) bool

HasAll will ensure that the bit includes all of the bits entered

func (GatewayIntents) Missing added in v0.3.3

func (p GatewayIntents) Missing(bit GatewayIntents) bool

Missing will do the inverse of Bit.Has

func (GatewayIntents) MissingAny added in v0.3.3

func (p GatewayIntents) MissingAny(bits ...GatewayIntents) bool

MissingAny will check whether the bit is missing any one of the bits

func (GatewayIntents) Remove added in v0.3.3

func (p GatewayIntents) Remove(bits ...GatewayIntents) GatewayIntents

Remove allows you to subtract multiple bits from the first, producing a new bit

type GatewayOp

type GatewayOp int

GatewayOp are opcodes used by discord

const (
	OpDispatch GatewayOp = iota
	OpHeartbeat
	OpIdentify
	OpPresenceUpdate
	OpVoiceStateUpdate

	OpResume
	OpReconnect
	OpRequestGuildMembers
	OpInvalidSession
	OpHello
	OpHeartbeatACK
)

Constants for the gateway opcodes

type GatewayPacket added in v0.2.0

type GatewayPacket struct {
	Op GatewayOp         `json:"op"`
	S  *int              `json:"s,omitempty"`
	T  *GatewayEventType `json:"t,omitempty"`
}

GatewayPacket raw GatewayEvent type

type GatewayRs

type GatewayRs struct {
	URL string `json:"url"`
}

GatewayRs contains the response for GET /gateway

type GatewayStatus added in v0.2.0

type GatewayStatus int

GatewayStatus is the state that the client is currently in

const (
	Ready GatewayStatus = iota
	Unconnected
	Connecting
	Reconnecting
	WaitingForHello
	WaitingForReady
	Disconnected
	WaitingForGuilds
	Identifying
	Resuming
)

Indicates how far along the client is to connecting

type Guild

type Guild struct {
	Disgo                       Disgo
	Ready                       bool
	ID                          Snowflake                  `json:"id"`
	Name                        string                     `json:"name"`
	Icon                        *string                    `json:"icon"`
	Region                      string                     `json:"region"`
	OwnerID                     Snowflake                  `json:"owner_id"`
	JoinedAt                    *time.Time                 `json:"joined_at"`
	DiscoverySplash             *string                    `json:"discovery_splash"`
	Splash                      *string                    `json:"splash"`
	AfkChannelID                *Snowflake                 `json:"afk_channel_id"`
	AfkTimeout                  int                        `json:"afk_timeout"`
	MemberCount                 *int                       `json:"member_count"`
	VerificationLevel           VerificationLevel          `json:"verification_level"`
	Large                       *bool                      `json:"large"`
	DefaultMessageNotifications MessageNotifications       `json:"default_message_notifications"`
	MaxPresences                *int                       `json:"max_presences"`
	MaxMembers                  *int                       `json:"max_members"`
	Unavailable                 bool                       `json:"unavailable"`
	ExplicitContentFilter       ExplicitContentFilterLevel `json:"explicit_content_filter"`
	Features                    []GuildFeature             `json:"features"`
	MfaLevel                    MFALevel                   `json:"mfa_level"`
	ApplicationID               Snowflake                  `json:"application_id"`
	WidgetEnabled               bool                       `json:"widget_enabled"`
	WidgetChannelID             Snowflake                  `json:"widget_channel_id"`
	SystemChannelID             Snowflake                  `json:"system_channel_id"`
	SystemChannelFlags          SystemChannelFlag          `json:"system_channel_flags"`
	RulesChannelID              Snowflake                  `json:"rules_channel_id"`
	VanityURLCode               *string                    `json:"vanity_url_code"`
	Description                 *string                    `json:"description"`
	Banner                      *string                    `json:"banner"`
	PremiumTier                 PremiumTier                `json:"premium_tier"`
	PremiumSubscriptionCount    *int                       `json:"premium_subscription_count"`
	PreferredLocale             string                     `json:"preferred_locale"`
	PublicUpdatesChannelID      *Snowflake                 `json:"public_updates_channel_id"`
	MaxVideoChannelUsers        *int                       `json:"max_video_channel_users"`
	ApproximateMemberCount      *int                       `json:"approximate_member_count"`
	ApproximatePresenceCount    *int                       `json:"approximate_presence_count"`
	WelcomeScreen               *GuildWelcomeScreen        `json:"welcome_screen"`
}

Guild represents a discord Guild

func (*Guild) AddMember

func (g *Guild) AddMember(userID Snowflake, addGuildMemberData AddGuildMemberData) (*Member, error)

AddMember adds a member to the Guild with the oauth2 access token

func (*Guild) CreateCommand

func (g *Guild) CreateCommand(command CommandCreate) (*Command, error)

CreateCommand creates a new Command for this Guild

func (*Guild) CreateRole

func (g *Guild) CreateRole(role UpdateRole) (*Role, error)

CreateRole allows you to create a new Role

func (*Guild) DeleteCommand

func (g *Guild) DeleteCommand(commandID Snowflake) error

DeleteCommand creates a new Command for this Guild

func (*Guild) Disconnect added in v0.2.0

func (g *Guild) Disconnect() error

Disconnect sends a api.GatewayCommand to disconnect from this Guild

func (*Guild) EditCommand

func (g *Guild) EditCommand(commandID Snowflake, command CommandUpdate) (*Command, error)

EditCommand edits a specific Guild Command

func (*Guild) GetCommand

func (g *Guild) GetCommand(commandID Snowflake) (*Command, error)

GetCommand fetches a specific Guild Command

func (*Guild) GetCommandPermissions added in v0.2.0

func (g *Guild) GetCommandPermissions(commandID Snowflake) (*GuildCommandPermissions, error)

GetCommandPermissions returns the GuildCommandPermissions for a specific Command in a Guild

func (*Guild) GetCommands

func (g *Guild) GetCommands() ([]*Command, error)

GetCommands fetches all Guild Command(s)

func (*Guild) GetCommandsPermissions added in v0.2.0

func (g *Guild) GetCommandsPermissions() ([]*GuildCommandPermissions, error)

GetCommandsPermissions returns the GuildCommandPermissions for a all Command(s) in a Guild

func (*Guild) GetSelfMember added in v0.4.3

func (g *Guild) GetSelfMember() *SelfMember

GetSelfMember returns the Member for the current logged in User for this Guild

func (*Guild) IconURL

func (g *Guild) IconURL(size int) *string

IconURL returns the Icon of a Guild

func (*Guild) SetCommandPermissions added in v0.2.0

func (g *Guild) SetCommandPermissions(commandID Snowflake, permissions SetGuildCommandPermissions) (*GuildCommandPermissions, error)

SetCommandPermissions sets the GuildCommandPermissions for a specific Command

func (*Guild) SetCommands

func (g *Guild) SetCommands(commands ...CommandCreate) ([]*Command, error)

SetCommands overrides all Command(s) for this Guild

func (*Guild) SetCommandsPermissions added in v0.2.0

func (g *Guild) SetCommandsPermissions(commandPermissions ...SetGuildCommandPermissions) ([]*GuildCommandPermissions, error)

SetCommandsPermissions sets the GuildCommandPermissions for a all Command(s)

type GuildChannel

type GuildChannel struct {
	Channel
}

GuildChannel is a generic type for all server channels

func (GuildChannel) Guild

func (c GuildChannel) Guild() *Guild

Guild returns the channel's Guild

type GuildCommandPermissions added in v0.2.0

type GuildCommandPermissions struct {
	Disgo         Disgo
	ID            Snowflake           `json:"id"`
	ApplicationID Snowflake           `json:"application_id"`
	GuildID       Snowflake           `json:"guild_id"`
	Permissions   []CommandPermission `json:"permissions"`
}

GuildCommandPermissions holds all permissions for a Command

type GuildFeature

type GuildFeature string

The GuildFeature (s) that a Guild contains

const (
	GuildFeatureInviteSplash                  GuildFeature = "INVITE_SPLASH"
	GuildFeatureVipRegions                    GuildFeature = "VIP_REGIONS"
	GuildFeatureVanityURL                     GuildFeature = "VANITY_URL"
	GuildFeatureVERIFIED                      GuildFeature = "VERIFIED"
	GuildFeaturePARTNERED                     GuildFeature = "PARTNERED"
	GuildFeatureCOMMUNITY                     GuildFeature = "COMMUNITY"
	GuildFeatureCOMMERCE                      GuildFeature = "COMMERCE"
	GuildFeatureNews                          GuildFeature = "NEWS"
	GuildFeatureDiscoverable                  GuildFeature = "DISCOVERABLE"
	GuildFeatureFeaturable                    GuildFeature = "FEATURABLE"
	GuildFeatureAnimatedIcon                  GuildFeature = "ANIMATED_ICON"
	GuildFeatureBANNER                        GuildFeature = "BANNER"
	GuildFeatureWelcomeScreenEnabled          GuildFeature = "WELCOME_SCREEN_ENABLED"
	GuildFeatureMemberVerificationGateEnabled GuildFeature = "MEMBER_VERIFICATION_GATE_ENABLED"
	GuildFeaturePreviewEnabled                GuildFeature = "PREVIEW_ENABLED"
)

Constants for GuildFeature

type GuildPreview added in v0.2.0

type GuildPreview struct {
	Disgo                    Disgo
	ID                       Snowflake      `json:"id"`
	Name                     string         `json:"name"`
	Icon                     *string        `json:"icon"`
	DiscoverySplash          *string        `json:"discovery_splash"`
	Splash                   *string        `json:"splash"`
	Features                 []GuildFeature `json:"features"`
	Description              *string        `json:"description"`
	ApproximateMemberCount   *int           `json:"approximate_member_count"`
	ApproximatePresenceCount *int           `json:"approximate_presence_count"`
	Emojis                   []*Emoji       `json:"emojis"`
}

GuildPreview is used for previewing public Guild(s) before joining them

type GuildWelcomeChannel added in v0.2.0

type GuildWelcomeChannel struct {
	ChannelID   Snowflake  `json:"channel_id"`
	Description string     `json:"description"`
	EmojiID     *Snowflake `json:"emoji_id,omitempty"`
	EmojiName   *string    `json:"emoji_name,omitempty"`
}

GuildWelcomeChannel is one of the channels in a GuildWelcomeScreen

type GuildWelcomeScreen added in v0.2.0

type GuildWelcomeScreen struct {
	Description     *string                `json:"description,omitempty"`
	WelcomeChannels []*GuildWelcomeChannel `json:"welcome_channels"`
}

GuildWelcomeScreen is the Welcome Screen of a Guild

type HeartbeatCommand

type HeartbeatCommand struct {
	D *int `json:"d"`
}

HeartbeatCommand is used to ensure the websocket connection remains open, and disconnect if not.

type HelloGatewayEventData added in v0.2.0

type HelloGatewayEventData struct {
	HeartbeatInterval time.Duration `json:"heartbeat_interval"`
}

HelloGatewayEventData is sent when we connect to the gateway

type IdentifyCommand

type IdentifyCommand struct {
	Token          string                        `json:"token"`
	Properties     IdentifyCommandDataProperties `json:"properties"`
	Compress       bool                          `json:"compress,omitempty"`
	LargeThreshold int                           `json:"large_threshold,omitempty"`
	GatewayIntents GatewayIntents                `json:"intents"`
}

IdentifyCommand is the data used in IdentifyCommand

type IdentifyCommandDataProperties

type IdentifyCommandDataProperties struct {
	OS      string `json:"$os"`      // user OS
	Browser string `json:"$browser"` // library name
	Device  string `json:"$device"`  // library name
}

IdentifyCommandDataProperties is used for specifying to discord which library and OS the bot is using, is automatically handled by the library and should rarely be used.

type Interaction

type Interaction struct {
	Disgo           Disgo
	ResponseChannel chan InteractionResponse
	Replied         bool
	ID              Snowflake       `json:"id"`
	Type            InteractionType `json:"type"`
	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"`
}

Interaction holds the general parameters of each Interaction

func (*Interaction) DMChannel added in v0.3.3

func (i *Interaction) DMChannel() *DMChannel

DMChannel returns the api.DMChannel from the api.Cache

func (*Interaction) DeferReply added in v0.4.3

func (i *Interaction) DeferReply(ephemeral bool) error

DeferReply replies to the api.Interaction with api.InteractionResponseTypeDeferredChannelMessageWithSource and shows a loading state

func (*Interaction) DeleteFollowup added in v0.3.3

func (i *Interaction) DeleteFollowup(messageID Snowflake) error

DeleteFollowup used to delete a api.Message from an api.Interaction

func (*Interaction) DeleteOriginal added in v0.3.3

func (i *Interaction) DeleteOriginal() error

DeleteOriginal deletes the original api.InteractionResponse

func (*Interaction) EditFollowup added in v0.3.3

func (i *Interaction) EditFollowup(messageID Snowflake, messageUpdate MessageUpdate) (*Message, error)

EditFollowup used to edit a api.Message from an api.Interaction

func (*Interaction) EditOriginal added in v0.3.3

func (i *Interaction) EditOriginal(messageUpdate MessageUpdate) (*Message, error)

EditOriginal edits the original api.InteractionResponse

func (*Interaction) FromWebhook added in v0.4.0

func (i *Interaction) FromWebhook() bool

FromWebhook returns is the Interaction was made via http

func (*Interaction) Guild added in v0.3.3

func (i *Interaction) Guild() *Guild

Guild returns the api.Guild from the api.Cache

func (*Interaction) GuildChannel added in v0.3.3

func (i *Interaction) GuildChannel() *GuildChannel

GuildChannel returns the api.GuildChannel from the api.Cache

func (*Interaction) MessageChannel added in v0.3.3

func (i *Interaction) MessageChannel() *MessageChannel

MessageChannel returns the api.MessageChannel from the api.Cache

func (*Interaction) Reply added in v0.4.0

func (i *Interaction) Reply(messageCreate MessageCreate) error

Reply replies to the api.Interaction with api.InteractionResponseTypeDeferredChannelMessageWithSource & api.MessageCreate

func (*Interaction) Respond added in v0.4.3

func (i *Interaction) Respond(responseType InteractionResponseType, data interface{}) error

Respond responds to the api.Interaction with the provided api.InteractionResponse

func (*Interaction) SendFollowup added in v0.3.3

func (i *Interaction) SendFollowup(messageCreate MessageCreate) (*Message, error)

SendFollowup used to send a api.MessageCreate to an api.Interaction

func (*Interaction) TextChannel added in v0.3.3

func (i *Interaction) TextChannel() *TextChannel

TextChannel returns the api.TextChannel from the api.Cache

type InteractionResponse

type InteractionResponse struct {
	Type InteractionResponseType `json:"type"`
	Data interface{}             `json:"data,omitempty"`
}

InteractionResponse is how you answer interactions. If an answer is not sent within 3 seconds of receiving it, the interaction is failed, and you will be unable to respond to it.

func (InteractionResponse) ToBody added in v0.4.3

func (r InteractionResponse) ToBody() (interface{}, error)

ToBody returns the InteractionResponse ready for body

type InteractionResponseType

type InteractionResponseType int

InteractionResponseType indicates the type of slash command response, whether it's responding immediately or deferring to edit your response later

const (
	InteractionResponseTypePong InteractionResponseType = iota + 1

	InteractionResponseTypeChannelMessageWithSource
	InteractionResponseTypeDeferredChannelMessageWithSource
	InteractionResponseTypeDeferredUpdateMessage
	InteractionResponseTypeUpdateMessage
)

Constants for the InteractionResponseType(s)

type InteractionType

type InteractionType int

InteractionType is the type of Interaction

const (
	InteractionTypePing InteractionType = iota + 1
	InteractionTypeCommand
	InteractionTypeComponent
)

Supported InteractionType(s)

type Invite added in v0.2.0

type Invite struct {
	Disgo                    Disgo
	Code                     string        `json:"code"`
	Guild                    *InviteGuild  `json:"guild"`
	Channel                  InviteChannel `json:"channel"`
	Inviter                  *User         `json:"inviter"`
	TargetUser               *InviteUser   `json:"target_user"`
	TargetType               *TargetType   `json:"target_user_type"`
	ApproximatePresenceCount *int          `json:"approximate_presence_count"`
	ApproximateMemberCount   *int          `json:"approximate_member_count"`
}

Invite is a partial invite struct

func (*Invite) URL added in v0.2.0

func (i *Invite) URL() string

URL returns the invite url in format like https://discord.gg/{code}

type InviteChannel added in v0.2.0

type InviteChannel struct {
	ID   string      `json:"id"`
	Name string      `json:"name"`
	Type ChannelType `json:"type"`
}

InviteChannel is the Channel of an invite

type InviteGuild added in v0.2.0

type InviteGuild struct {
	ID                Snowflake         `json:"id"`
	Name              string            `json:"name"`
	Splash            *string           `json:"splash"`
	Banner            *string           `json:"banner"`
	Description       *string           `json:"description"`
	Icon              *string           `json:"icon"`
	Features          []GuildFeature    `json:"features"`
	VerificationLevel VerificationLevel `json:"verification_level"`
	VanityURLCode     *string           `json:"vanity_url_code"`
}

An InviteGuild is the Guild of an Invite

type InviteUser added in v0.2.0

type InviteUser struct {
	ID            string `json:"id"`
	Username      string `json:"username"`
	Avatar        string `json:"avatar"`
	Discriminator string `json:"discriminator"`
}

InviteUser is the user who created an invite

type MFALevel

type MFALevel int

The MFALevel of a Guild

const (
	MFALevelNone MFALevel = iota
	MFALevelElevated
)

Constants for MFALevel

type Member

type Member struct {
	Disgo        Disgo
	GuildID      Snowflake    `json:"guild_id"`
	User         *User        `json:"user"`
	Nick         *string      `json:"nick"`
	Roles        []Snowflake  `json:"roles,omitempty"`
	JoinedAt     time.Time    `json:"joined_at"`
	PremiumSince *time.Time   `json:"premium_since,omitempty"`
	Deaf         *bool        `json:"deaf,omitempty"`
	Mute         *bool        `json:"mute,omitempty"`
	Pending      bool         `json:"pending"`
	Permissions  *Permissions `json:"permissions,omitempty"`
}

Member is a discord GuildMember

func (Member) AddRole

func (m Member) AddRole(roleID Snowflake) error

AddRole adds a specific role the member

func (Member) EffectiveName added in v0.3.0

func (m Member) EffectiveName() string

EffectiveName returns either the nickname or username depending on if the user has a nickname

func (Member) Guild

func (m Member) Guild() *Guild

Guild returns the members guild from the cache

func (Member) IsOwner

func (m Member) IsOwner() bool

IsOwner returns whether the member is the owner of the guild_events that it belongs to

func (Member) Move

func (m Member) Move(channelID *Snowflake) (*Member, error)

Move moves/kicks the member to/from a voice channel

func (Member) RemoveRole

func (m Member) RemoveRole(roleID Snowflake) error

RemoveRole removes a specific role the member

func (Member) Update

func (m Member) Update(updateGuildMemberData UpdateGuildMemberData) (*Member, error)

Update updates the member

func (Member) VoiceState added in v0.3.0

func (m Member) VoiceState() *VoiceState

VoiceState returns the VoiceState for this Member from the Cache(requires CacheFlagVoiceState and GatewayIntentsGuildVoiceStates)

type MemberCachePolicy

type MemberCachePolicy func(*Member) bool

MemberCachePolicy can be used to define your own policy for caching members

var (
	MemberCachePolicyNone    MemberCachePolicy = func(_ *Member) bool { return false }
	MemberCachePolicyAll     MemberCachePolicy = func(_ *Member) bool { return true }
	MemberCachePolicyOwner   MemberCachePolicy = func(member *Member) bool { return member.IsOwner() }
	MemberCachePolicyOnline  MemberCachePolicy = func(_ *Member) bool { return false }
	MemberCachePolicyVoice   MemberCachePolicy = func(member *Member) bool { return false }
	MemberCachePolicyPending MemberCachePolicy = func(member *Member) bool { return member.Pending }
	MemberCachePolicyDefault                   = MemberCachePolicyOwner.Or(MemberCachePolicyVoice)
)

Default member cache policies

func MemberCachePolicyAllOf

func MemberCachePolicyAllOf(policy MemberCachePolicy, policies ...MemberCachePolicy) MemberCachePolicy

MemberCachePolicyAllOf is a shorthand for MemberCachePolicy.And(MemberCachePolicy).And(MemberCachePolicy) etc.

func MemberCachePolicyAnyOf

func MemberCachePolicyAnyOf(policy MemberCachePolicy, policies ...MemberCachePolicy) MemberCachePolicy

MemberCachePolicyAnyOf is a shorthand for MemberCachePolicy.Or(MemberCachePolicy).Or(MemberCachePolicy) etc.

func (MemberCachePolicy) And

And allows you to require both policies to be true for the member to be cached

func (MemberCachePolicy) Or

Or allows you to combine that policy with another, meaning either needs to be true

type Mentionable

type Mentionable interface {
	Mention() string
}

Mentionable is a struct for Mention parsing and AllowedMentions

type Message

type Message struct {
	Disgo             Disgo
	ID                Snowflake           `json:"id"`
	GuildID           *Snowflake          `json:"guild_id"`
	Reactions         []MessageReaction   `json:"reactions"`
	Attachments       []Attachment        `json:"attachments"`
	TTS               bool                `json:"tts"`
	Embeds            []Embed             `json:"embeds,omitempty"`
	Components        []Component         `json:"components,omitempty"`
	CreatedAt         time.Time           `json:"timestamp"`
	Mentions          []interface{}       `json:"mentions"`
	MentionEveryone   bool                `json:"mention_everyone"`
	MentionRoles      []*Role             `json:"mention_roles"`
	MentionChannels   []*Channel          `json:"mention_channels"`
	Pinned            bool                `json:"pinned"`
	EditedTimestamp   *time.Time          `json:"edited_timestamp"`
	Author            *User               `json:"author"`
	Member            *Member             `json:"member"`
	Content           *string             `json:"content,omitempty"`
	ChannelID         Snowflake           `json:"channel_id"`
	Type              MessageType         `json:"type"`
	Flags             MessageFlags        `json:"flags"`
	MessageReference  *MessageReference   `json:"message_reference,omitempty"`
	Interaction       *MessageInteraction `json:"message_interaction,omitempty"`
	WebhookID         *Snowflake          `json:"webhook_id,omitempty"`
	Activity          *MessageActivity    `json:"activity,omitempty"`
	Application       *MessageApplication `json:"application,omitempty"`
	Stickers          []*MessageSticker   `json:"stickers,omitempty"`
	ReferencedMessage *Message            `json:"referenced_message,omitempty"`
	LastUpdated       *time.Time          `json:"last_updated,omitempty"`
}

Message is a struct for messages sent in discord text-based channels

func (*Message) AddReaction

func (m *Message) AddReaction(emoji string) error

AddReaction allows you to add a reaction to a message_events from a string, for example a custom emoji ID, or a native emoji

func (*Message) AddReactionByEmote

func (m *Message) AddReactionByEmote(emote Emoji) error

AddReactionByEmote allows you to add an Emoji to a message_events via reaction

func (*Message) Channel

func (m *Message) Channel() *MessageChannel

Channel gets the channel the message_events was sent in

func (*Message) Crosspost added in v0.2.0

func (m *Message) Crosspost() (*Message, error)

Crosspost crossposts an existing message

func (*Message) Delete added in v0.2.0

func (m *Message) Delete() error

Delete allows you to edit an existing Message sent by you

func (*Message) Edit added in v0.2.0

func (m *Message) Edit(message MessageUpdate) (*Message, error)

Edit allows you to edit an existing Message sent by you

func (*Message) Guild

func (m *Message) Guild() *Guild

Guild gets the guild_events the message_events was sent in

func (*Message) Reply

func (m *Message) Reply(message MessageCreate) (*Message, error)

Reply allows you to reply to an existing Message

type MessageActivity added in v0.2.0

type MessageActivity struct {
	Type    MessageActivityType `json:"type"`
	PartyID *string             `json:"party_id,omitempty"`
}

MessageActivity is used for rich presence-related chat embeds in a Message

type MessageActivityType added in v0.2.0

type MessageActivityType int

MessageActivityType is the type of MessageActivity

const (
	MessageActivityTypeJoin MessageActivityType = iota + 1
	MessageActivityTypeSpectate
	MessageActivityTypeListen

	MessageActivityTypeJoinRequest
)

Constants for MessageActivityType

type MessageApplication added in v0.2.0

type MessageApplication struct {
	ID          Snowflake `json:"id"`
	CoverImage  *string   `json:"cover_image,omitempty"`
	Description string    `json:"description"`
	Icon        *string   `json:"icon,omitempty"`
	Name        string    `json:"name"`
}

MessageApplication is used for rich presence-related chat embeds in a Message

type MessageBulkDelete added in v0.2.0

type MessageBulkDelete struct {
	Messages []Snowflake `json:"messages"`
}

MessageBulkDelete is used to bulk delete Message(s)

type MessageCachePolicy

type MessageCachePolicy func(*Message) bool

MessageCachePolicy can be used to define your own policy for caching messages

var (
	MessageCachePolicyNone    MessageCachePolicy = func(_ *Message) bool { return false }
	MessageCachePolicyDefault                    = MessageCachePolicyNone
)

Default member cache policies

func MessageCachePolicyAll

func MessageCachePolicyAll(policy MessageCachePolicy, policies ...MessageCachePolicy) MessageCachePolicy

MessageCachePolicyAll is a shorthand for MessageCachePolicy.And(MessageCachePolicy).And(MessageCachePolicy) etc.

func MessageCachePolicyAny

func MessageCachePolicyAny(policy MessageCachePolicy, policies ...MessageCachePolicy) MessageCachePolicy

MessageCachePolicyAny is a shorthand for MessageCachePolicy.Or(MessageCachePolicy).Or(MessageCachePolicy) etc.

func MessageCachePolicyDuration

func MessageCachePolicyDuration(duration time.Duration) MessageCachePolicy

MessageCachePolicyDuration creates a new MessageCachePolicy which caches messages for the give duration

func (MessageCachePolicy) And

And allows you to require both policies to be true for the member to be cached

func (MessageCachePolicy) Or

Or allows you to combine that policy with another, meaning either needs to be true

type MessageChannel

type MessageChannel struct {
	Channel
}

MessageChannel is used for sending Message(s) to User(s)

func (MessageChannel) BulkDeleteMessages added in v0.2.0

func (c MessageChannel) BulkDeleteMessages(messageIDs ...Snowflake) error

BulkDeleteMessages allows you bulk delete Message(s)

func (MessageChannel) CrosspostMessage added in v0.2.0

func (c MessageChannel) CrosspostMessage(messageID Snowflake) (*Message, error)

CrosspostMessage crossposts an existing Message

func (MessageChannel) DeleteMessage added in v0.2.0

func (c MessageChannel) DeleteMessage(messageID Snowflake) error

DeleteMessage allows you to edit an existing Message sent by you

func (MessageChannel) EditMessage added in v0.2.0

func (c MessageChannel) EditMessage(messageID Snowflake, message MessageUpdate) (*Message, error)

EditMessage edits a Message in this TextChannel

func (MessageChannel) SendMessage

func (c MessageChannel) SendMessage(message MessageCreate) (*Message, error)

SendMessage sends a Message to a TextChannel

type MessageCreate

type MessageCreate struct {
	Nonce            string            `json:"nonce,omitempty"`
	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"`
	MessageReference *MessageReference `json:"message_reference,omitempty"`
	Flags            MessageFlags      `json:"flags,omitempty"`
}

MessageCreate is the struct to create a new Message with

func (MessageCreate) ToBody added in v0.4.3

func (m MessageCreate) ToBody() (interface{}, error)

ToBody returns the MessageCreate ready for body

type MessageCreateBuilder added in v0.4.3

type MessageCreateBuilder struct {
	MessageCreate
}

MessageCreateBuilder helper to build Message(s) easier

func NewMessageBuilderByMessage added in v0.4.0

func NewMessageBuilderByMessage(message *Message) *MessageCreateBuilder

NewMessageBuilderByMessage returns a new MessageCreateBuilder and takes an existing Message

func NewMessageCreateBuilder added in v0.4.3

func NewMessageCreateBuilder() *MessageCreateBuilder

NewMessageCreateBuilder creates a new MessageCreateBuilder to be built later

func (*MessageCreateBuilder) AddComponents added in v0.4.3

func (b *MessageCreateBuilder) AddComponents(components ...Component) *MessageCreateBuilder

AddComponents adds the Component(s) to the Message

func (*MessageCreateBuilder) AddEmbeds added in v0.4.3

func (b *MessageCreateBuilder) AddEmbeds(embeds ...Embed) *MessageCreateBuilder

AddEmbeds adds multiple embeds to the Message

func (*MessageCreateBuilder) AddFile added in v0.4.3

func (b *MessageCreateBuilder) AddFile(name string, reader io.Reader, flags ...restclient.FileFlags) *MessageCreateBuilder

AddFile adds a file to the WebhookMessageCreate

func (*MessageCreateBuilder) AddFiles added in v0.4.3

AddFiles adds the files to the WebhookMessageCreate

func (*MessageCreateBuilder) Build added in v0.4.3

Build builds the MessageCreateBuilder to a MessageCreate struct

func (*MessageCreateBuilder) ClearAllowedMentions added in v0.4.3

func (b *MessageCreateBuilder) ClearAllowedMentions() *MessageCreateBuilder

ClearAllowedMentions clears the allowed mentions of the Message

func (*MessageCreateBuilder) ClearComponents added in v0.4.3

func (b *MessageCreateBuilder) ClearComponents() *MessageCreateBuilder

ClearComponents removes all of the Component(s) of the Message

func (*MessageCreateBuilder) ClearEmbeds added in v0.4.3

func (b *MessageCreateBuilder) ClearEmbeds() *MessageCreateBuilder

ClearEmbeds removes all of the embeds from the Message

func (*MessageCreateBuilder) ClearFiles added in v0.4.3

func (b *MessageCreateBuilder) ClearFiles() *MessageCreateBuilder

ClearFiles removes all files of this WebhookMessageCreate

func (*MessageCreateBuilder) RemoveComponent added in v0.4.3

func (b *MessageCreateBuilder) RemoveComponent(i int) *MessageCreateBuilder

RemoveComponent removes a Component from the Message

func (*MessageCreateBuilder) RemoveEmbed added in v0.4.3

func (b *MessageCreateBuilder) RemoveEmbed(index int) *MessageCreateBuilder

RemoveEmbed removes an embed from the Message

func (*MessageCreateBuilder) RemoveFiles added in v0.4.3

func (b *MessageCreateBuilder) RemoveFiles(i int) *MessageCreateBuilder

RemoveFiles removes the file at this index

func (*MessageCreateBuilder) SetAllowedMentions added in v0.4.3

func (b *MessageCreateBuilder) SetAllowedMentions(allowedMentions *AllowedMentions) *MessageCreateBuilder

SetAllowedMentions sets the AllowedMentions of the Message

func (*MessageCreateBuilder) SetComponents added in v0.4.3

func (b *MessageCreateBuilder) SetComponents(components ...Component) *MessageCreateBuilder

SetComponents sets the Component(s) of the Message

func (*MessageCreateBuilder) SetContent added in v0.4.3

func (b *MessageCreateBuilder) SetContent(content string) *MessageCreateBuilder

SetContent sets content of the Message

func (*MessageCreateBuilder) SetContentf added in v0.4.3

func (b *MessageCreateBuilder) SetContentf(content string, a ...interface{}) *MessageCreateBuilder

SetContentf sets content of the Message

func (*MessageCreateBuilder) SetEmbeds added in v0.4.3

func (b *MessageCreateBuilder) SetEmbeds(embeds ...Embed) *MessageCreateBuilder

SetEmbeds sets the embeds of the Message

func (*MessageCreateBuilder) SetEphemeral added in v0.4.3

func (b *MessageCreateBuilder) SetEphemeral(ephemeral bool) *MessageCreateBuilder

SetEphemeral adds/removes MessageFlagEphemeral to the Message flags

func (*MessageCreateBuilder) SetFiles added in v0.4.3

SetFiles sets the files for this WebhookMessageCreate

func (*MessageCreateBuilder) SetFlags added in v0.4.3

SetFlags sets the message flags of the Message

func (*MessageCreateBuilder) SetMessageReference added in v0.4.3

func (b *MessageCreateBuilder) SetMessageReference(messageReference *MessageReference) *MessageCreateBuilder

SetMessageReference allows you to specify a MessageReference to reply to

func (*MessageCreateBuilder) SetMessageReferenceByID added in v0.4.3

func (b *MessageCreateBuilder) SetMessageReferenceByID(messageID Snowflake) *MessageCreateBuilder

SetMessageReferenceByID allows you to specify a Message ID to reply to

func (*MessageCreateBuilder) SetTTS added in v0.4.3

SetTTS sets the text to speech of the Message

type MessageFlags

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

func (f MessageFlags) Add(bits ...MessageFlags) MessageFlags

Add allows you to add multiple bits together, producing a new bit

func (MessageFlags) Has

func (f MessageFlags) Has(bit MessageFlags) bool

Has will check whether the Bit contains another bit

func (MessageFlags) HasAll

func (f MessageFlags) HasAll(bits ...MessageFlags) bool

HasAll will ensure that the bit includes all of the bits entered

func (MessageFlags) Missing

func (f MessageFlags) Missing(bit MessageFlags) bool

Missing will do the inverse of Bit.Has

func (MessageFlags) MissingAny

func (f MessageFlags) MissingAny(bits ...MessageFlags) bool

MissingAny will check whether the bit is missing any one of the bits

func (MessageFlags) Remove

func (f MessageFlags) Remove(bits ...MessageFlags) MessageFlags

Remove allows you to subtract multiple bits from the first, producing a new bit

type MessageInteraction

type MessageInteraction struct {
	ID   Snowflake       `json:"id"`
	Type InteractionType `json:"type"`
	Name string          `json:"name"`
	User User            `json:"user"`
}

MessageInteraction is sent on the Message object when the message_events is a response to an interaction

type MessageNotifications

type MessageNotifications int

MessageNotifications indicates whether users receive @ mentions on a new message

const (
	MessageNotificationsAllMessages MessageNotifications = iota
	MessageNotificationsOnlyMentions
)

Constants for MessageNotifications

type MessageReaction added in v0.2.0

type MessageReaction struct {
	Count int   `json:"count"`
	Me    bool  `json:"me"`
	Emoji Emoji `json:"emoji"`
}

MessageReaction contains information about the reactions of a message_events

type MessageReference

type MessageReference struct {
	MessageID       *Snowflake `json:"message_id"`
	ChannelID       *Snowflake `json:"channel_id,omitempty"`
	GuildID         *Snowflake `json:"guild_id,omitempty"`
	FailIfNotExists *bool      `json:"fail_if_not_exists,omitempty"`
}

MessageReference is a reference to another message

type MessageSticker added in v0.2.0

type MessageSticker struct {
	ID          Snowflake                `json:"id"`
	PackID      Snowflake                `json:"pack_id"`
	Name        string                   `json:"name"`
	Description string                   `json:"description"`
	Tags        *string                  `json:"tags"`
	FormatType  MessageStickerFormatType `json:"format_type"`
}

MessageSticker is a sticker sent with a Message

type MessageStickerFormatType added in v0.2.0

type MessageStickerFormatType int

MessageStickerFormatType is the Format Type of a MessageSticker

const (
	MessageStickerFormatPNG MessageStickerFormatType = iota + 1
	MessageStickerFormatAPNG
	MessageStickerFormatLottie
)

Constants for MessageStickerFormatType

type MessageType

type MessageType int

The MessageType indicates the Message type

const (
	MessageTypeDefault MessageType = iota
	MessageTypeRecipientAdd
	MessageTypeRecipientRemove
	MessageTypeCall
	MessageTypeChannelNameChange
	MessageTypeChannelIconChange
	ChannelPinnedMessage
	MessageTypeGuildMemberJoin
	MessageTypeUserPremiumGuildSubscription
	MessageTypeUserPremiumGuildSubscriptionTier1
	MMessageTypeUserPremiumGuildSubscriptionTier2
	MessageTypeUserPremiumGuildSubscriptionTier3
	MessageTypeChannelFollowAdd

	MessageTypeGuildDiscoveryDisqualified
	MessageTypeGuildDiscoveryRequalified
	MessageTypeGuildDiscoveryInitialWarning
	MessageTypeGuildDiscoveryFinalWarning

	MessageTypeReply
	MessageTypeCommand
)

Constants for the MessageType

type MessageUpdate added in v0.2.0

type MessageUpdate 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
}

MessageUpdate is used to edit a Message

func (MessageUpdate) MarshalJSON added in v0.4.3

func (m MessageUpdate) MarshalJSON() ([]byte, error)

MarshalJSON marshals the MessageUpdate into json

func (MessageUpdate) ToBody added in v0.4.3

func (m MessageUpdate) ToBody() (interface{}, error)

ToBody returns the MessageUpdate ready for body

type MessageUpdateBuilder added in v0.4.3

type MessageUpdateBuilder struct {
	MessageUpdate
}

MessageUpdateBuilder helper to build MessageUpdate easier

func NewMessageUpdateBuilder added in v0.4.3

func NewMessageUpdateBuilder() *MessageUpdateBuilder

NewMessageUpdateBuilder creates a new MessageUpdateBuilder to be built later

func (*MessageUpdateBuilder) AddComponents added in v0.4.3

func (b *MessageUpdateBuilder) AddComponents(components ...Component) *MessageUpdateBuilder

AddComponents adds the Component(s) to the Message

func (*MessageUpdateBuilder) AddEmbeds added in v0.4.3

func (b *MessageUpdateBuilder) AddEmbeds(embeds ...Embed) *MessageUpdateBuilder

AddEmbeds adds multiple embeds to the Message

func (*MessageUpdateBuilder) AddFile added in v0.4.3

func (b *MessageUpdateBuilder) AddFile(name string, reader io.Reader, flags ...restclient.FileFlags) *MessageUpdateBuilder

AddFile adds a file to the Message

func (*MessageUpdateBuilder) AddFiles added in v0.4.3

AddFiles adds the files to the Message

func (*MessageUpdateBuilder) Build added in v0.4.3

Build builds the MessageUpdateBuilder to a MessageUpdate struct

func (*MessageUpdateBuilder) ClearAllowedMentions added in v0.4.3

func (b *MessageUpdateBuilder) ClearAllowedMentions() *MessageUpdateBuilder

ClearAllowedMentions clears the allowed mentions of the Message

func (*MessageUpdateBuilder) ClearComponents added in v0.4.3

func (b *MessageUpdateBuilder) ClearComponents() *MessageUpdateBuilder

ClearComponents removes all of the Component(s) of the Message

func (*MessageUpdateBuilder) ClearEmbeds added in v0.4.3

func (b *MessageUpdateBuilder) ClearEmbeds() *MessageUpdateBuilder

ClearEmbeds removes all of the embeds from the Message

func (*MessageUpdateBuilder) ClearFiles added in v0.4.3

func (b *MessageUpdateBuilder) ClearFiles() *MessageUpdateBuilder

ClearFiles removes all files of this Message

func (*MessageUpdateBuilder) RemoveComponent added in v0.4.3

func (b *MessageUpdateBuilder) RemoveComponent(i int) *MessageUpdateBuilder

RemoveComponent removes a Component from the Message

func (*MessageUpdateBuilder) RemoveEmbed added in v0.4.3

func (b *MessageUpdateBuilder) RemoveEmbed(index int) *MessageUpdateBuilder

RemoveEmbed removes an embed from the Message

func (*MessageUpdateBuilder) RemoveFiles added in v0.4.3

func (b *MessageUpdateBuilder) RemoveFiles(i int) *MessageUpdateBuilder

RemoveFiles removes the file at this index

func (*MessageUpdateBuilder) RetainAttachments added in v0.4.3

func (b *MessageUpdateBuilder) RetainAttachments(attachments ...Attachment) *MessageUpdateBuilder

RetainAttachments removes all Attachment(s) from this Message except the ones provided

func (*MessageUpdateBuilder) RetainAttachmentsByID added in v0.4.3

func (b *MessageUpdateBuilder) RetainAttachmentsByID(attachmentIDs ...Snowflake) *MessageUpdateBuilder

RetainAttachmentsByID removes all Attachment(s) from this Message except the ones provided

func (*MessageUpdateBuilder) SetAllowedMentions added in v0.4.3

func (b *MessageUpdateBuilder) SetAllowedMentions(allowedMentions *AllowedMentions) *MessageUpdateBuilder

SetAllowedMentions sets the AllowedMentions of the Message

func (*MessageUpdateBuilder) SetComponents added in v0.4.3

func (b *MessageUpdateBuilder) SetComponents(components ...Component) *MessageUpdateBuilder

SetComponents sets the Component(s) of the Message

func (*MessageUpdateBuilder) SetContent added in v0.4.3

func (b *MessageUpdateBuilder) SetContent(content string) *MessageUpdateBuilder

SetContent sets content of the Message

func (*MessageUpdateBuilder) SetContentf added in v0.4.3

func (b *MessageUpdateBuilder) SetContentf(content string, a ...interface{}) *MessageUpdateBuilder

SetContentf sets content of the Message

func (*MessageUpdateBuilder) SetEmbeds added in v0.4.3

func (b *MessageUpdateBuilder) SetEmbeds(embeds ...Embed) *MessageUpdateBuilder

SetEmbeds sets the embeds of the Message

func (*MessageUpdateBuilder) SetFiles added in v0.4.3

SetFiles sets the files for this Message

func (*MessageUpdateBuilder) SetFlags added in v0.4.3

SetFlags sets the MessageFlags of the Message

type MoveGuildMemberData

type MoveGuildMemberData struct {
	ChannelID *Snowflake `json:"channel_id"`
}

MoveGuildMemberData is used to move a member

type Option added in v0.2.0

type Option struct {
	Resolved *Resolved
	Name     string
	Type     CommandOptionType
	Value    interface{}
}

Option holds info about an Option.Value

func (Option) Bool added in v0.2.0

func (o Option) Bool() bool

Bool returns the Option.Value as bool

func (Option) Category added in v0.2.0

func (o Option) Category() *Category

Category returns the Option.Value as Category

func (Option) Channel added in v0.2.0

func (o Option) Channel() *Channel

Channel returns the Option.Value as Channel

func (Option) GuildChannel added in v0.2.0

func (o Option) GuildChannel() *GuildChannel

GuildChannel returns the Option.Value as GuildChannel

func (Option) Integer added in v0.3.0

func (o Option) Integer() int

Integer returns the Option.Value as int

func (Option) Member added in v0.2.0

func (o Option) Member() *Member

Member returns the Option.Value as Member

func (Option) MessageChannel added in v0.2.0

func (o Option) MessageChannel() *MessageChannel

MessageChannel returns the Option.Value as MessageChannel

func (Option) Role added in v0.2.0

func (o Option) Role() *Role

Role returns the Option.Value as Role

func (Option) Snowflake added in v0.2.0

func (o Option) Snowflake() Snowflake

Snowflake returns the Option.Value as Snowflake

func (Option) StoreChannel added in v0.2.0

func (o Option) StoreChannel() *StoreChannel

StoreChannel returns the Option.Value as StoreChannel

func (Option) String added in v0.2.0

func (o Option) String() string

String returns the Option.Value as string

func (Option) TextChannel added in v0.2.0

func (o Option) TextChannel() *TextChannel

TextChannel returns the Option.Value as TextChannel

func (Option) User added in v0.2.0

func (o Option) User() *User

User returns the Option.Value as User

func (Option) VoiceChannel added in v0.2.0

func (o Option) VoiceChannel() *VoiceChannel

VoiceChannel returns the Option.Value as VoiceChannel

type OptionChoice

type OptionChoice struct {
	Name  string      `json:"name"`
	Value interface{} `json:"value"`
}

OptionChoice contains the data for a user using your command

type OptionData

type OptionData struct {
	Name    string            `json:"name"`
	Type    CommandOptionType `json:"type"`
	Value   interface{}       `json:"value,omitempty"`
	Options []*OptionData     `json:"options,omitempty"`
}

OptionData is used for options or subcommands in your slash commands

type Options

type Options struct {
	Logger                    log.Logger
	GatewayIntents            GatewayIntents
	RestTimeout               int
	EnableWebhookInteractions bool
	ListenPort                int
	ListenURL                 string
	PublicKey                 string
	LargeThreshold            int
	RawGatewayEventsEnabled   bool
	HTTPClient                *http.Client
}

Options is the configuration used when creating the client

type PermissionOverwrite added in v0.2.0

type PermissionOverwrite struct {
	ID    Snowflake               `json:"id"`
	Type  PermissionOverwriteType `json:"type"`
	Allow Permissions             `json:"allow,string"`
	Deny  Permissions             `json:"deny,string"`
}

PermissionOverwrite is used to determine who can perform particular actions in a GuildChannel

type PermissionOverwriteType added in v0.2.0

type PermissionOverwriteType int

PermissionOverwriteType is the type of a PermissionOverwrite

const (
	PermissionOverwriteTypeRole PermissionOverwriteType = iota
	PermissionOverwriteTypeMember
)

Constants for PermissionOverwriteType

type Permissions

type Permissions int64

Permissions extends the Bit structure, and is used within roles and channels

const (
	PermissionSendMessages Permissions = 1 << (iota + 11)
	PermissionSendTTSMessages
	PermissionManageMessages
	PermissionEmbedLinks
	PermissionAttachFiles
	PermissionReadMessageHistory
	PermissionMentionEveryone
	PermissionUseExternalEmojis
)

Constants for the different bit offsets of text channel permissions

const (
	PermissionVoiceConnect Permissions = 1 << (iota + 20)
	PermissionVoiceSpeak
	PermissionVoiceMuteMembers
	PermissionVoiceDeafenMembers
	PermissionVoiceMoveMembers
	PermissionVoiceUseVAD
	PermissionVoicePrioritySpeaker Permissions = 1 << (iota + 2)
)

Constants for the different bit offsets of voice permissions

const (
	PermissionChangeNickname Permissions = 1 << (iota + 26)
	PermissionManageNicknames
	PermissionManageRoles
	PermissionManageWebhooks
	PermissionManageEmojis
	PermissionUseCommands
)

Constants for general management.

Constants for the different bit offsets of general permissions

func (Permissions) Add

func (p Permissions) Add(bits ...Permissions) Permissions

Add allows you to add multiple bits together, producing a new bit

func (Permissions) Has

func (p Permissions) Has(bit Permissions) bool

Has will check whether the Bit contains another bit

func (Permissions) HasAll

func (p Permissions) HasAll(bits ...Permissions) bool

HasAll will ensure that the bit includes all of the bits entered

func (Permissions) MarshalJSON

func (p Permissions) MarshalJSON() ([]byte, error)

MarshalJSON marshals permissions into a string

func (Permissions) Missing

func (p Permissions) Missing(bit Permissions) bool

Missing will do the inverse of Bit.Has

func (Permissions) MissingAny

func (p Permissions) MissingAny(bits ...Permissions) bool

MissingAny will check whether the bit is missing any one of the bits

func (Permissions) Remove

func (p Permissions) Remove(bits ...Permissions) Permissions

Remove allows you to subtract multiple bits from the first, producing a new bit

func (*Permissions) UnmarshalJSON

func (p *Permissions) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshalls permissions into an int64

type PremiumTier

type PremiumTier int

PremiumTier tells you the boost level of a Guild

const (
	PremiumTierNone PremiumTier = iota
	PremiumTier1
	PremiumTier2
	PremiumTier3
)

Constants for PremiumTier

type RawGatewayEvent added in v0.2.0

type RawGatewayEvent struct {
	GatewayPacket
	D json.RawMessage `json:"d"`
}

RawGatewayEvent specifies the data for the GatewayCommand payload that is being sent

type ReadyGatewayEvent

type ReadyGatewayEvent struct {
	Version   int      `json:"v"`
	SelfUser  User     `json:"user"`
	Guilds    []*Guild `json:"guilds"`
	SessionID string   `json:"session_id"`
	Shard     *[2]int  `json:"shard,omitempty"`
}

ReadyGatewayEvent is the event sent by discord when you successfully Identify

type RequestGuildMembersCommand

type RequestGuildMembersCommand struct {
	GuildID   Snowflake   `json:"guild_id"`
	Query     string      `json:"query"` //If specified, user_ids must not be entered
	Limit     int         `json:"limit"` //Must be >=1 if query/user_ids is used, otherwise 0
	Presences bool        `json:"presences,omitempty"`
	UserIDs   []Snowflake `json:"user_ids"`        //If specified, query must not be entered
	Nonce     string      `json:"nonce,omitempty"` //All responses are hashed with this nonce, optional
}

RequestGuildMembersCommand is used for fetching all of the members of a guild_events. It is recommended you have a strict member caching policy when using this.

type Resolved

type Resolved struct {
	Users    map[Snowflake]*User    `json:"users,omitempty"`
	Members  map[Snowflake]*Member  `json:"members,omitempty"`
	Roles    map[Snowflake]*Role    `json:"roles,omitempty"`
	Channels map[Snowflake]*Channel `json:"channels,omitempty"`
}

Resolved contains resolved mention data

type RestClient

type RestClient interface {
	restclient.RestClient
	Close()
	Disgo() Disgo

	SendMessage(channelID Snowflake, message MessageCreate) (*Message, error)
	EditMessage(channelID Snowflake, messageID Snowflake, messageUpdate MessageUpdate) (*Message, error)
	DeleteMessage(channelID Snowflake, messageID Snowflake) error
	BulkDeleteMessages(channelID Snowflake, messageIDs ...Snowflake) error
	CrosspostMessage(channelID Snowflake, messageID Snowflake) (*Message, error)

	OpenDMChannel(userID Snowflake) (*DMChannel, error)

	UpdateSelfNick(guildID Snowflake, nick *string) (*string, error)

	GetUser(userID Snowflake) (*User, error)
	GetMember(guildID Snowflake, userID Snowflake) (*Member, error)
	GetMembers(guildID Snowflake) ([]*Member, error)
	AddMember(guildID Snowflake, userID Snowflake, addGuildMemberData AddGuildMemberData) (*Member, error)
	KickMember(guildID Snowflake, userID Snowflake, reason *string) error
	UpdateMember(guildID Snowflake, userID Snowflake, updateGuildMemberData UpdateGuildMemberData) (*Member, error)
	MoveMember(guildID Snowflake, userID Snowflake, channelID *Snowflake) (*Member, error)
	AddMemberRole(guildID Snowflake, userID Snowflake, roleID Snowflake) error
	RemoveMemberRole(guildID Snowflake, userID Snowflake, roleID Snowflake) error

	GetRoles(guildID Snowflake) ([]*Role, error)
	CreateRole(guildID Snowflake, role UpdateRole) (*Role, error)
	UpdateRole(guildID Snowflake, roleID Snowflake, role UpdateRole) (*Role, error)
	UpdateRolePositions(guildID Snowflake, roleUpdates ...UpdateRolePosition) ([]*Role, error)
	DeleteRole(guildID Snowflake, roleID Snowflake) error

	AddReaction(channelID Snowflake, messageID Snowflake, emoji string) error
	RemoveOwnReaction(channelID Snowflake, messageID Snowflake, emoji string) error
	RemoveUserReaction(channelID Snowflake, messageID Snowflake, emoji string, userID Snowflake) error

	GetGlobalCommands(applicationID Snowflake) ([]*Command, error)
	GetGlobalCommand(applicationID Snowflake, commandID Snowflake) (*Command, error)
	CreateGlobalCommand(applicationID Snowflake, command CommandCreate) (*Command, error)
	SetGlobalCommands(applicationID Snowflake, commands ...CommandCreate) ([]*Command, error)
	EditGlobalCommand(applicationID Snowflake, commandID Snowflake, command CommandUpdate) (*Command, error)
	DeleteGlobalCommand(applicationID Snowflake, commandID Snowflake) error

	GetGuildCommands(applicationID Snowflake, guildID Snowflake) ([]*Command, error)
	GetGuildCommand(applicationID Snowflake, guildID Snowflake, commandID Snowflake) (*Command, error)
	CreateGuildCommand(applicationID Snowflake, guildID Snowflake, command CommandCreate) (*Command, error)
	SetGuildCommands(applicationID Snowflake, guildID Snowflake, commands ...CommandCreate) ([]*Command, error)
	EditGuildCommand(applicationID Snowflake, guildID Snowflake, commandID Snowflake, command CommandUpdate) (*Command, error)
	DeleteGuildCommand(applicationID Snowflake, guildID Snowflake, commandID Snowflake) error

	GetGuildCommandsPermissions(applicationID Snowflake, guildID Snowflake) ([]*GuildCommandPermissions, error)
	GetGuildCommandPermissions(applicationID Snowflake, guildID Snowflake, commandID Snowflake) (*GuildCommandPermissions, error)
	SetGuildCommandsPermissions(applicationID Snowflake, guildID Snowflake, commandPermissions ...SetGuildCommandPermissions) ([]*GuildCommandPermissions, error)
	SetGuildCommandPermissions(applicationID Snowflake, guildID Snowflake, commandID Snowflake, commandPermissions SetGuildCommandPermissions) (*GuildCommandPermissions, error)

	SendInteractionResponse(interactionID Snowflake, interactionToken string, interactionResponse InteractionResponse) error
	EditInteractionResponse(applicationID Snowflake, interactionToken string, messageUpdate MessageUpdate) (*Message, error)
	DeleteInteractionResponse(applicationID Snowflake, interactionToken string) error

	SendFollowupMessage(applicationID Snowflake, interactionToken string, messageCreate MessageCreate) (*Message, error)
	EditFollowupMessage(applicationID Snowflake, interactionToken string, messageID Snowflake, messageUpdate MessageUpdate) (*Message, error)
	DeleteFollowupMessage(applicationID Snowflake, interactionToken string, followupMessageID Snowflake) error
}

RestClient is a manager for all of disgo's HTTP requests

type ResumeCommand

type ResumeCommand struct {
	Token     string `json:"token"`
	SessionID string `json:"session_id"`
	Seq       int    `json:"seq"`
}

ResumeCommand is used to resume a connection to discord in the case that you are disconnected. Is automatically handled by the library and should rarely be used.

type Role

type Role struct {
	Disgo       Disgo
	GuildID     Snowflake
	ID          Snowflake   `json:"id"`
	Name        string      `json:"name"`
	Color       int         `json:"color"`
	Hoist       bool        `json:"hoist"`
	Position    int         `json:"position"`
	Permissions Permissions `json:"permissions"`
	Managed     bool        `json:"managed"`
	Mentionable bool        `json:"mentionable"`
	Tags        *RoleTag    `json:"tags,omitempty"`
}

Role is a Guild Role object

func (*Role) Delete

func (r *Role) Delete() error

Delete deletes the Role

func (*Role) Guild

func (r *Role) Guild() *Guild

Guild returns the Guild of this role from the Cache

func (*Role) Mention

func (r *Role) Mention() string

Mention parses the Role as a Mention

func (*Role) SetPosition

func (r *Role) SetPosition(rolePositionUpdate UpdateRolePosition) ([]*Role, error)

SetPosition sets the position of the Role

func (*Role) String

func (r *Role) String() string

String parses the Role to a String representation

func (*Role) Update

func (r *Role) Update(roleUpdate UpdateRole) (*Role, error)

Update updates the Role with specific values

type RoleTag

type RoleTag struct {
	BotID             *Snowflake `json:"bot_id,omitempty"`
	IntegrationID     *Snowflake `json:"integration_id,omitempty"`
	PremiumSubscriber bool       `json:"premium_subscriber"`
}

RoleTag are tags a Role has

type SelfMember added in v0.4.3

type SelfMember struct {
	*Member
}

SelfMember represents the current logged in Member for a specific Guild

type SelfUser added in v0.4.3

type SelfUser struct {
	*User
}

SelfUser represents the current logged in User

func (*SelfUser) OpenDMChannel added in v0.4.3

func (u *SelfUser) OpenDMChannel() (*DMChannel, error)

OpenDMChannel creates a DMChannel between the user and the Disgo client

type SetGuildCommandPermissions added in v0.2.0

type SetGuildCommandPermissions struct {
	ID          Snowflake           `json:"id,omitempty"`
	Permissions []CommandPermission `json:"permissions"`
}

SetGuildCommandPermissions is used to update CommandPermission ID should be omitted fro bulk update

type SetGuildCommandsPermissions added in v0.2.0

type SetGuildCommandsPermissions []SetGuildCommandPermissions

SetGuildCommandsPermissions holds a slice of SetGuildCommandPermissions

type Snowflake

type Snowflake string

Snowflake is a general utility class around discord's IDs

func (Snowflake) Binary

func (s Snowflake) Binary() string

Binary converts the snowflake to binary

func (Snowflake) Deconstruct

func (s Snowflake) Deconstruct() DeconstructedSnowflake

Deconstruct returns DeconstructedSnowflake

func (Snowflake) String

func (s Snowflake) String() string

func (Snowflake) Timestamp

func (s Snowflake) Timestamp() time.Time

Timestamp returns a Time value of the snowflake

type StoreChannel

type StoreChannel struct {
	GuildChannel
}

StoreChannel allows you to interact with discord's store channels

type SystemChannelFlag

type SystemChannelFlag int

SystemChannelFlag contains the settings for the Guild(s) system channel

const (
	SystemChannelFlagSuppressJoinNotifications SystemChannelFlag = 1 << iota
	SystemChannelFlagSuppressPremiumSubscriptions
)

Constants for SystemChannelFlag

type TargetType added in v0.2.0

type TargetType int

TargetType is type of target an Invite uses

const (
	TargetTypeStream TargetType = iota + 1
	TargetTypeEmbeddedApplication
)

Constants for TargetType

type TextChannel

type TextChannel struct {
	GuildChannel
	MessageChannel
}

TextChannel allows you to interact with discord's text channels

type UnmarshalComponent added in v0.4.0

type UnmarshalComponent struct {
	ComponentType ComponentType        `json:"type"`
	Style         ButtonStyle          `json:"style"`
	Label         *string              `json:"label"`
	Emoji         *Emoji               `json:"emoji"`
	CustomID      string               `json:"custom_id"`
	URL           string               `json:"url"`
	Disabled      bool                 `json:"disabled"`
	Components    []UnmarshalComponent `json:"components"`
}

UnmarshalComponent is used for easier unmarshalling of different Component(s)

type UpdateGuildMemberData

type UpdateGuildMemberData struct {
	Nick  *string     `json:"nick,omitempty"`
	Roles []Snowflake `json:"roles,omitempty"`
	Mute  *bool       `json:"mute,omitempty"`
	Deaf  *bool       `json:"deaf,omitempty"`
}

UpdateGuildMemberData is used to modify

type UpdateRole

type UpdateRole struct {
	Name        *string      `json:"name,omitempty"`
	Permissions *Permissions `json:"permissions,omitempty"`
	Color       *int         `json:"color,omitempty"`
	Hoist       *bool        `json:"hoist,omitempty"`
	Mentionable *bool        `json:"mentionable,omitempty"`
}

UpdateRole is the payload to update a Role

type UpdateRolePosition

type UpdateRolePosition struct {
	ID       Snowflake `json:"id"`
	Position *int      `json:"position"`
}

UpdateRolePosition is the payload to update a Role(s) position

type UpdateSelfNick

type UpdateSelfNick struct {
	Nick *string `json:"nick"`
}

UpdateSelfNick is used to update your own nick

type UpdateStatusCommand

type UpdateStatusCommand struct {
	Since      *int       `json:"since"`
	Activities []Activity `json:"activities"`
	Status     bool       `json:"status"`
	AFK        bool       `json:"afk"`
}

UpdateStatusCommand is used for updating Disgo's presence

type UpdateVoiceStateCommand

type UpdateVoiceStateCommand struct {
	GuildID   Snowflake  `json:"guild_id"`
	ChannelID *Snowflake `json:"channel_id"`
	SelfMute  bool       `json:"self_mute"`
	SelfDeaf  bool       `json:"self_deaf"`
}

UpdateVoiceStateCommand is used for updating the bots voice state in a guild_events

type User

type User struct {
	Disgo         Disgo
	ID            Snowflake `json:"id"`
	Username      string    `json:"username"`
	Discriminator string    `json:"discriminator"`
	Avatar        *string   `json:"avatar"`
	IsBot         bool      `json:"bot"`
	System        *bool     `json:"system"`
	MfaEnabled    *bool     `json:"mfa_enabled"`
	Locale        *string   `json:"locale"`
	Verified      *bool     `json:"verified"`
	Email         *string   `json:"email"`
	Flags         *int      `json:"flags"`
	PremiumType   *int      `json:"premium_type"`
	PublicFlags   *int      `json:"public_flags"`
}

User is a struct for interacting with discord's users

func (*User) AvatarURL added in v0.3.0

func (u *User) AvatarURL(size int) string

AvatarURL returns the Avatar URL of the User

func (*User) Mention

func (u *User) Mention() string

Mention returns the user as a mention

func (*User) OpenDMChannel

func (u *User) OpenDMChannel() (*DMChannel, error)

OpenDMChannel creates a DMChannel between the user and the Disgo client

func (*User) String

func (u *User) String() string

func (*User) Tag

func (u *User) Tag() string

Tag returns the user's Username and Discriminator

type VerificationLevel

type VerificationLevel int

The VerificationLevel of a Guild that members must be to send messages

const (
	VerificationLevelNone VerificationLevel = iota
	VerificationLevelLow
	VerificationLevelMedium
	VerificationLevelHigh
	VerificationLevelVeryHigh
)

Constants for VerificationLevel

type VoiceChannel

type VoiceChannel struct {
	GuildChannel
}

VoiceChannel adds methods specifically for interacting with discord's voice

func (*VoiceChannel) Connect added in v0.2.0

func (c *VoiceChannel) Connect() error

Connect sends a api.GatewayCommand to connect to this VoiceChannel

type VoiceDispatchInterceptor added in v0.2.0

type VoiceDispatchInterceptor interface {
	OnVoiceServerUpdate(voiceServerUpdateEvent *VoiceServerUpdateEvent)
	OnVoiceStateUpdate(voiceStateUpdateEvent *VoiceStateUpdateEvent)
}

VoiceDispatchInterceptor lets you listen to VoiceServerUpdate & VoiceStateUpdate

type VoiceServerUpdate added in v0.2.0

type VoiceServerUpdate struct {
	Token    string    `json:"token"`
	GuildID  Snowflake `json:"guild_id"`
	Endpoint *string   `json:"endpoint"`
}

VoiceServerUpdate from Discord

type VoiceServerUpdateEvent added in v0.2.0

type VoiceServerUpdateEvent struct {
	VoiceServerUpdate
	Disgo Disgo
}

VoiceServerUpdateEvent sent when a guilds voice server is updated

func (*VoiceServerUpdateEvent) Guild added in v0.2.0

func (u *VoiceServerUpdateEvent) Guild() *Guild

Guild returns the Guild for this VoiceServerUpdate from the Cache

type VoiceState

type VoiceState struct {
	Disgo         Disgo
	GuildID       Snowflake  `json:"guild_id"`
	ChannelID     *Snowflake `json:"channel_id"`
	UserID        Snowflake  `json:"user_id"`
	SessionID     string     `json:"session_id"`
	GuildDeafened bool       `json:"deaf"`
	GuildMuted    bool       `json:"mute"`
	SelfDeafened  bool       `json:"self_deaf"`
	SelfMuted     bool       `json:"self_mute"`
	Stream        bool       `json:"self_stream"`
	Video         bool       `json:"self_video"`
	Suppressed    bool       `json:"suppress"`
}

VoiceState from Discord

func (*VoiceState) Deafened added in v0.2.0

func (s *VoiceState) Deafened() bool

Deafened returns if the Member is deafened

func (*VoiceState) Guild added in v0.2.0

func (s *VoiceState) Guild() *Guild

Guild returns the Guild of this VoiceState from the Cache

func (*VoiceState) Member

func (s *VoiceState) Member() *Member

Member returns the Member of this VoiceState from the Cache

func (*VoiceState) Muted added in v0.2.0

func (s *VoiceState) Muted() bool

Muted returns if the Member is muted

func (*VoiceState) User added in v0.2.0

func (s *VoiceState) User() *User

User returns the User of this VoiceState from the Cache

func (*VoiceState) VoiceChannel added in v0.2.0

func (s *VoiceState) VoiceChannel() *VoiceChannel

VoiceChannel returns the VoiceChannel of this VoiceState from the Cache

type VoiceStateUpdateEvent added in v0.2.0

type VoiceStateUpdateEvent struct {
	*VoiceState
	Member *Member `json:"member"`
}

VoiceStateUpdateEvent sent when someone joins/leaves/moves voice channels

func (*VoiceStateUpdateEvent) Guild added in v0.2.0

func (u *VoiceStateUpdateEvent) Guild() *Guild

Guild returns the Guild for this VoiceStateUpdate from the Cache

func (*VoiceStateUpdateEvent) VoiceChannel added in v0.2.0

func (u *VoiceStateUpdateEvent) VoiceChannel() *VoiceChannel

VoiceChannel returns the VoiceChannel for this VoiceStateUpdate from the Cache

type WebhookEventHandler

type WebhookEventHandler interface {
	EventHandler
	HandleWebhookEvent(disgo Disgo, eventManager EventManager, replyChannel chan InteractionResponse, payload interface{})
}

WebhookEventHandler is used to handle raw webhook events

type WebhookServer

type WebhookServer interface {
	Disgo() Disgo
	PublicKey() ed25519.PublicKey
	ListenURL() string
	Router() *mux.Router
	Start()
	Close()
}

WebhookServer is used for receiving an Interaction over http

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL