api

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChannelCreateGatewayEvent            = "CHANNEL_CREATE"
	ChannelDeleteGatewayEvent            = "CHANNEL_DELETE"
	ChannelPinsUpdateGatewayEvent        = "CHANNEL_PINS_UPDATE"
	ChannelUpdateGatewayEvent            = "CHANNEL_UPDATE"
	GuildBanAddGatewayEvent              = "GUILD_BAN_ADD"
	GuildBanRemoveGatewayEvent           = "GUILD_BAN_REMOVE"
	GuildCreateGatewayEvent              = "GUILD_CREATE"
	GuildDeleteGatewayEvent              = "GUILD_DELETE"
	GuildEmojisUpdateGatewayEvent        = "GUILD_EMOJIS_UPDATE"
	GuildIntegrationsUpdateGatewayEvent  = "GUILD_INTEGRATIONS_UPDATE"
	GuildMemberAddGatewayEvent           = "GUILD_MEMBER_ADD"
	GuildMemberRemoveGatewayEvent        = "GUILD_MEMBER_REMOVE"
	GuildMemberUpdateGatewayEvent        = "GUILD_MEMBER_UPDATE"
	GuildMembersChunkGatewayEvent        = "GUILD_MEMBERS_CHUNK"
	GuildRoleCreateGatewayEvent          = "GUILD_ROLE_CREATE"
	GuildRoleDeleteGatewayEvent          = "GUILD_ROLE_DELETE"
	GuildRoleUpdateGatewayEvent          = "GUILD_ROLE_UPDATE"
	GuildUpdateGatewayEvent              = "GUILD_UPDATE"
	InteractionCreateGatewayEvent        = "INTERACTION_CREATE"
	InteractionCreateWebhookEvent        = "INTERACTION_WEBHOOK_CREATE"
	MessageAckGatewayEvent               = "MESSAGE_ACK"
	MessageCreateGatewayEvent            = "MESSAGE_CREATE"
	MessageDeleteGatewayEvent            = "MESSAGE_DELETE"
	MessageDeleteBulkGatewayEvent        = "MESSAGE_DELETE_BULK"
	MessageReactionAddGatewayEvent       = "MESSAGE_REACTION_ADD"
	MessageReactionRemoveGatewayEvent    = "MESSAGE_REACTION_REMOVE"
	MessageReactionRemoveAllGatewayEvent = "MESSAGE_REACTION_REMOVE_ALL"
	MessageUpdateGatewayEvent            = "MESSAGE_UPDATE"
	PresenceUpdateGatewayEvent           = "PRESENCE_UPDATE"
	PresencesReplaceGatewayEvent         = "PRESENCES_REPLACE"
	ReadyGatewayEvent                    = "READY"
	ResumedGatewayEvent                  = "RESUMED"
	TypingStartGatewayEvent              = "TYPING_START"
	UserGuildSettingsUpdateGatewayEvent  = "USER_GUILD_SETTINGS_UPDATE"
	UserNoteUpdateGatewayEvent           = "USER_NOTE_UPDATE"
	UserSettingsUpdateGatewayEvent       = "USER_SETTINGS_UPDATE"
	UserUpdateGatewayEvent               = "USER_UPDATE"
	VoiceServerUpdateGatewayEvent        = "VOICE_SERVER_UPDATE"
	VoiceStateUpdateGatewayEvent         = "VOICE_STATE_UPDATE"
	WebhooksUpdateGatewayEvent           = "WEBHOOKS_UPDATE"
)

Constants for the gateway events

Variables

View Source
var (
	ErrBadGateway                 = errors.New("bad gateway could not reach discord")
	ErrUnauthorized               = errors.New("not authorized for this endpoint")
	ErrBadRequest                 = errors.New("bad request please check your request")
	ErrRatelimited                = errors.New("too many requests")
	ErrTooMuchApplicationCommands = errors.New("you can provide a max of 100 application commands")
)

Errors when connecting to discord

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

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(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 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, Custom or Competing

const (
	Game ActivityType = iota
	Streaming
	Listening

	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 Bit

type Bit interface {
	Add(bits ...Bit) Bit
	Remove(bits ...Bit) Bit
	HasAll(bits ...Bit) bool
	Has(bit Bit) bool
	MissingAny(bits ...Bit) bool
	Missing(bit Bit) bool
}

Bit is a utility for interacting with bitfields

type Cache

type Cache interface {
	Close()
	DoCleanup()

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

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

	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)
	UncacheMember(Snowflake, Snowflake)
	FindMember(Snowflake, func(*Member) bool) *Member
	FindMembers(Snowflake, func(*Member) bool) []*Member

	Role(Snowflake, 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)
	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)
	UncacheDMChannel(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)
	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)
	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)
	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)
	UncacheCategory(Snowflake, Snowflake)
	FindCategory(Snowflake, func(*Category) bool) *Category
	FindCategories(Snowflake, func(*Category) bool) []*Category
}

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

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 Color

type Color int

Color is used for specifying colors in an Embed

type CommandOption

type CommandOption struct {
	Type        SlashCommandOptionType `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 SlashCommand.Options

type ConnectionStatus

type ConnectionStatus int

ConnectionStatus is the state that the client is currently in

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

Indicates how far along the client is to connecting

type DMChannel

type DMChannel struct {
	MessageChannel
	Users []User `json:"recipients"`
}

DMChannel is used for interacting in private messages 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 {
	Connect() error
	Start() error
	Close()
	Token() string
	Gateway() Gateway
	RestClient() RestClient
	WebhookServer() WebhookServer
	Cache() Cache
	Intents() Intents
	ApplicationID() Snowflake
	SelfUser() *User
	SetSelfUser(*User)
	EventManager() EventManager
	HeartbeatLatency() time.Duration

	GetCommand(commandID Snowflake) (*SlashCommand, error)
	GetCommands() ([]*SlashCommand, error)
	CreateCommand(command SlashCommand) (*SlashCommand, error)
	EditCommand(commandID Snowflake, command SlashCommand) (*SlashCommand, error)
	DeleteCommand(command SlashCommand) (*SlashCommand, error)
	SetCommands(commands ...SlashCommand) ([]*SlashCommand, error)
}

Disgo is the main discord interface

type DisgoBuilder

type DisgoBuilder interface {
	SetLogLevel(level log.Level) DisgoBuilder
	SetToken(token string) DisgoBuilder
	SetIntents(intents Intents) 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
	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(f *EmbedField, fs ...*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(index int) *EmbedBuilder

RemoveField removes a field from the EmbedBuilder

func (*EmbedBuilder) SetAuthor

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

SetAuthor sets the author of the EmbedBuilder

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) SetFields

func (b *EmbedBuilder) SetFields(fs ...*EmbedField) *EmbedBuilder

SetFields sets fields of the EmbedBuilder

func (*EmbedBuilder) SetFooter

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

SetFooter sets the footer of the EmbedBuilder

func (*EmbedBuilder) SetFooterBy

func (b *EmbedBuilder) SetFooterBy(text string, iconURL *string) *EmbedBuilder

SetFooterBy sets the footer of the EmbedBuilder by text and iconURL

func (*EmbedBuilder) SetImage

func (b *EmbedBuilder) SetImage(i *string) *EmbedBuilder

SetImage sets the image of the EmbedBuilder

func (*EmbedBuilder) SetThumbnail

func (b *EmbedBuilder) SetThumbnail(i *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) SetURL

func (b *EmbedBuilder) SetURL(u *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 Emote

type Emote struct {
	ID       Snowflake
	Name     string
	Animated bool
}

An Emote allows you to interact with custom emojis in discord.

func (Emote) Mention

func (e Emote) Mention() string

Mention returns the string used to send the emoji

func (Emote) Reaction

func (e Emote) Reaction() string

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

func (Emote) String

func (e Emote) String() string

type ErrorResponse

type ErrorResponse struct {
	Code    int
	Message string
}

ErrorResponse contains custom errors from discord

type Event

type Event struct {
	Disgo Disgo
}

Event the base event structure

type EventHandler

type EventHandler interface {
	Name() string
	New() interface{}
}

EventHandler provides info about the EventHandler

type EventListener

type EventListener interface {
	OnEvent(interface{})
}

EventListener is used to create new EventListener to listen to events

type EventManager

type EventManager interface {
	AddEventListeners(...EventListener)
	Handle(string, json.RawMessage, chan interface{})
	Dispatch(GenericEvent)
}

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

type ExplicitContentFilterLevel

type ExplicitContentFilterLevel int

The ExplicitContentFilterLevel of a Guild

const (
	ExplicitContentFilterLevelDisabled ExplicitContentFilterLevel = iota
	ExplicitContentFilterLevelMembersWithoutRoles
	ExplicitContentFilterLevelAllMembers
)

Constants for ExplicitContentFilterLevel

type FollowupMessage

type FollowupMessage struct {
}

FollowupMessage is used to add additional messages to an Interaction after you've responded initially

type Gateway

type Gateway interface {
	Disgo() Disgo
	Open() error
	Status() ConnectionStatus
	Close()
	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 {
	Op GatewayOp `json:"op"`
	S  *int      `json:"s,omitempty"`
	T  *string   `json:"t,omitempty"`
}

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

type GatewayEventHandler

type GatewayEventHandler interface {
	EventHandler
	Handle(Disgo, EventManager, interface{})
}

GatewayEventHandler is used to handle raw gateway events

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 GatewayRs

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

GatewayRs contains the response for GET /gateway

type GenericEvent

type GenericEvent interface{}

GenericEvent the basic interface each event implement

type Guild

type Guild struct {
	Disgo                       Disgo
	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"`
	Roles                       []*Role                    `json:"roles"`
	Emojis                      []*Emote                   `json:"emojis"`
	Members                     []*Member                  `json:"members"`
	MaxPresences                *int                       `json:"max_presences"`
	MaxMembers                  *int                       `json:"max_members"`
	Channels                    []*GuildChannel            `json:"channels"`
	VoiceStates                 []*VoiceState              `json:"voice_states"`
	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"`
}

Guild represents a discord guild_events

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 SlashCommand) (*SlashCommand, 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(command SlashCommand) (*SlashCommand, error)

DeleteCommand creates a new command for this guild

func (Guild) EditCommand

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

EditCommand edits a specific guild command

func (Guild) GetCommand

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

GetCommand fetches a specific guild command

func (Guild) GetCommands

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

GetCommands fetches all guild commands

func (Guild) IconURL

func (g Guild) IconURL() *string

IconURL returns the Icon of a guild_events

func (Guild) SetCommands

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

SetCommands overrides all commands for this guild

type GuildChannel

type GuildChannel struct {
	Channel
	GuildID Snowflake `json:"guild_id"`
}

GuildChannel is a generic type for all server channels

func (GuildChannel) Guild

func (c GuildChannel) Guild() *Guild

Guild returns the channel's Guild

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 HeartbeatCommand

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

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

type HelloEvent

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

HelloEvent is used when

type IdentifyCommand

type IdentifyCommand struct {
	GatewayCommand
	D IdentifyCommandData `json:"d"`
}

IdentifyCommand is used for Identifying to discord

type IdentifyCommandData

type IdentifyCommandData struct {
	Token              string                        `json:"token"`
	Properties         IdentifyCommandDataProperties `json:"properties"`
	Compress           bool                          `json:"compress,omitempty"`
	LargeThreshold     int                           `json:"large_threshold,omitempty"`
	GuildSubscriptions bool                          `json:"guild_subscriptions,omitempty"` // Deprecated, should not be specified when using intents
	Intents            Intents                       `json:"intents"`
}

IdentifyCommandData 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 Intents

type Intents int64

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

const (
	IntentsGuilds Intents = 1 << iota
	IntentsGuildMembers
	IntentsGuildBans
	IntentsGuildEmojis
	IntentsGuildIntegrations
	IntentsGuildWebhooks
	IntentsGuildInvites
	IntentsGuildVoiceStates
	IntentsGuildPresences
	IntentsGuildMessages
	IntentsGuildMessageReactions
	IntentsGuildMessageTyping
	IntentsDirectMessages
	IntentsDirectMessageReactions
	IntentsDirectMessageTyping

	IntentsAllWithoutPrivileged = IntentsGuilds |
		IntentsGuildBans |
		IntentsGuildEmojis |
		IntentsGuildIntegrations |
		IntentsGuildWebhooks |
		IntentsGuildInvites |
		IntentsGuildVoiceStates |
		IntentsGuildMessages |
		IntentsGuildMessageReactions |
		IntentsGuildMessageTyping |
		IntentsDirectMessages |
		IntentsDirectMessageReactions |
		IntentsDirectMessageTyping
	IntentsAll = IntentsAllWithoutPrivileged |
		IntentsGuildMembers |
		IntentsGuildPresences
	IntentsNone Intents = 0
)

Constants for the different bit offsets of intents

func (Intents) Add

func (p Intents) Add(bits ...Bit) Bit

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

func (Intents) Has

func (p Intents) Has(bit Bit) bool

Has will check whether the Bit contains another bit

func (Intents) HasAll

func (p Intents) HasAll(bits ...Bit) bool

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

func (Intents) Missing

func (p Intents) Missing(bit Bit) bool

Missing will do the inverse of Bit.Has

func (Intents) MissingAny

func (p Intents) MissingAny(bits ...Bit) bool

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

func (Intents) Remove

func (p Intents) Remove(bits ...Bit) Bit

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

type Interaction

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

An Interaction is the slash command object you receive when a user uses one of your commands

type InteractionData

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

InteractionData is the command data payload

type InteractionResponse

type InteractionResponse struct {
	Type InteractionResponseType  `json:"type"`
	Data *InteractionResponseData `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.

type InteractionResponseBuilder

type InteractionResponseBuilder struct {
	InteractionResponse
}

InteractionResponseBuilder allows you to create an InteractionResponse with ease

func NewInteractionResponseBuilder

func NewInteractionResponseBuilder() *InteractionResponseBuilder

NewInteractionResponseBuilder returns a new InteractionResponseBuilder

func (*InteractionResponseBuilder) AddEmbeds

AddEmbeds adds multiple embeds to the InteractionResponse

func (*InteractionResponseBuilder) Build

Build returns your built InteractionResponse

func (*InteractionResponseBuilder) ClearEmbeds

ClearEmbeds removes all of the embeds from the InteractionResponse

func (*InteractionResponseBuilder) RemoveEmbed

RemoveEmbed removes an embed from the InteractionResponse

func (*InteractionResponseBuilder) SetAllowedMentions

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

SetAllowedMentions sets the allowed mentions of the InteractionResponse

func (*InteractionResponseBuilder) SetAllowedMentionsEmpty

func (b *InteractionResponseBuilder) SetAllowedMentionsEmpty() *InteractionResponseBuilder

SetAllowedMentionsEmpty sets the allowed mentions of the InteractionResponse to nothing

func (*InteractionResponseBuilder) SetContent

SetContent sets the content of the InteractionResponse

func (*InteractionResponseBuilder) SetData

SetData sets the InteractionResponseData of the InteractionResponse

func (*InteractionResponseBuilder) SetEmbeds

SetEmbeds sets the embeds of the InteractionResponse

func (*InteractionResponseBuilder) SetEphemeral

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

SetEphemeral adds/removes MessageFlagEphemeral to the message flags

func (*InteractionResponseBuilder) SetFlags

SetFlags sets the message flags of the InteractionResponse

func (*InteractionResponseBuilder) SetTTS

SetTTS sets if the InteractionResponse is a tts message

func (*InteractionResponseBuilder) SetType

SetType sets the InteractionResponseType of the InteractionResponse

type InteractionResponseData

type InteractionResponseData struct {
	TTS             bool             `json:"tts,omitempty"`
	Content         string           `json:"content,omitempty"`
	Embeds          []Embed          `json:"embeds,omitempty"`
	AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"`
	Flags           MessageFlags     `json:"flags,omitempty"`
}

The InteractionResponseData is used to specify the message_events options when creating an InteractionResponse

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
)

Constants for the InteractionResponseType(s)

type InteractionType

type InteractionType int

InteractionType is the type of Interaction

const (
	InteractionTypePing InteractionType = iota + 1
	InteractionTypeApplicationCommand
)

Constants for InteractionType

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) 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

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        []Reactions       `json:"reactions"`
	Attachments      []interface{}     `json:"attachments"`
	Tts              bool              `json:"tts"`
	Embeds           []*Embed          `json:"embeds,omitempty"`
	CreatedAt        time.Time         `json:"timestamp"`
	MentionEveryone  bool              `json:"mention_everyone"`
	Pinned           bool              `json:"pinned"`
	EditedTimestamp  interface{}       `json:"edited_timestamp"`
	Author           User              `json:"author"`
	MentionRoles     []interface{}     `json:"mention_roles"`
	Content          *string           `json:"content,omitempty"`
	ChannelID        Snowflake         `json:"channel_id"`
	Mentions         []interface{}     `json:"mentions"`
	MessageType      MessageType       `json:"type"`
	MessageReference *MessageReference `json:"message_reference,omitempty"`
	LastUpdated      *time.Time
}

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 Emote) error

AddReactionByEmote allows you to add an Emote 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) 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 MessageBuilder

type MessageBuilder struct {
	MessageCreate
}

MessageBuilder helper to build Message(s) easier

func NewMessageBuilder

func NewMessageBuilder() *MessageBuilder

NewMessageBuilder creates a new MessageBuilder to be built later

func (*MessageBuilder) Build

func (b *MessageBuilder) Build() MessageCreate

Build builds the MessageBuilder to a MessageCreate struct

func (*MessageBuilder) SetAllowedMentions

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

SetAllowedMentions sets the AllowedMentions of the Message

func (*MessageBuilder) SetAllowedMentionsEmpty

func (b *MessageBuilder) SetAllowedMentionsEmpty() *MessageBuilder

SetAllowedMentionsEmpty sets the allowed mentions of the Message to nothing

func (*MessageBuilder) SetContent

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

SetContent sets content of the Message

func (*MessageBuilder) SetEmbed

func (b *MessageBuilder) SetEmbed(embed *Embed) *MessageBuilder

SetEmbed sets the Embed of the Message

func (*MessageBuilder) SetMessageReference

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

SetMessageReference allows you to specify a MessageReference to reply to

func (*MessageBuilder) SetMessageReferenceByMessageID

func (b *MessageBuilder) SetMessageReferenceByMessageID(messageID Snowflake) *MessageBuilder

SetMessageReferenceByMessageID allows you to specify a Message ID to reply to

func (*MessageBuilder) SetTTS

func (b *MessageBuilder) SetTTS(tts bool) *MessageBuilder

SetTTS sets the text to speech of the Message

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 messages to user

func (MessageChannel) SendMessage

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

SendMessage a Message to a TextChannel

type MessageCreate

type MessageCreate struct {
	Content          string            `json:"content,omitempty"`
	TTS              bool              `json:"tts,omitempty"`
	Embed            *Embed            `json:"embed,omitempty"`
	AllowedMentions  *AllowedMentions  `json:"allowed_mentions,omitempty"`
	MessageReference *MessageReference `json:"message_reference,omitempty"`
}

MessageCreate is the struct to create a new Message with

type MessageFlags

type MessageFlags int64

The MessageFlags of a Message

const (
	MessageFlagNone        MessageFlags = 0
	MessageFlagCrossposted MessageFlags = 1 << iota
	MessageFlagIsCrosspost
	MessageFlagSuppressEmbeds
	MessageFlagSourceMessageDeleted
	MessageFlagUrgent

	MessageFlagEphemeral
)

Constants for MessageFlags

func (MessageFlags) Add

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

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

func (MessageFlags) Has

func (f MessageFlags) Has(bit Bit) bool

Has will check whether the Bit contains another bit

func (MessageFlags) HasAll

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

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

func (MessageFlags) Missing

func (f MessageFlags) Missing(bit Bit) bool

Missing will do the inverse of Bit.Has

func (MessageFlags) MissingAny

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

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

func (MessageFlags) Remove

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

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 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 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

	MessageTypeReply
	MessageTypeApplicationCommand
)

Constants for the MessageType

type MoveGuildMemberData

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

MoveGuildMemberData is used to move a member

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    SlashCommandOptionType `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 {
	Intents                   Intents
	RestTimeout               int
	EnableWebhookInteractions bool
	ListenPort                int
	ListenURL                 string
	PublicKey                 string
}

Options is the configuration used when creating the client

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
)

Constants for general management.

func (Permissions) Add

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

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

func (Permissions) Has

func (p Permissions) Has(bit Bit) bool

Has will check whether the Bit contains another bit

func (Permissions) HasAll

func (p Permissions) HasAll(bits ...Bit) 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 Bit) bool

Missing will do the inverse of Bit.Has

func (Permissions) MissingAny

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

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

func (Permissions) Remove

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

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 unmarshals permissions into a 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 RawGatewayCommand

type RawGatewayCommand struct {
	GatewayCommand
	D json.RawMessage `json:"d"`
}

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

type Reactions

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

Reactions contains information about the reactions of a message_events

type ReadyEvent

type ReadyEvent struct {
	GatewayCommand
	D ReadyEventData `json:"d"`
}

ReadyEvent is the event sent by discord when you successfully Identify

type ReadyEventData

type ReadyEventData struct {
	User            User        `json:"user"`
	PrivateChannels []DMChannel `json:"channel"`
	Guilds          []Guild     `json:"guild_events"`
	SessionID       string      `json:"session_id"`
	Shard           [2]int      `json:"shard,omitempty"`
}

ReadyEventData is the ReadyEvent.D payload

type RequestGuildMembersCommand

type RequestGuildMembersCommand struct {
	GatewayCommand
	D RequestGuildMembersCommandData `json:"d"`
}

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 RequestGuildMembersCommandData

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

RequestGuildMembersCommandData is the RequestGuildMembersCommand.D payload

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 {
	Close()
	Disgo() Disgo

	UserAgent() string
	Request(route endpoints.CompiledAPIRoute, rqBody interface{}, rsBody interface{}) error

	SendMessage(channelID Snowflake, message MessageCreate) (*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) ([]*SlashCommand, error)
	CreateGlobalCommand(applicationID Snowflake, command SlashCommand) (*SlashCommand, error)
	SetGlobalCommands(applicationID Snowflake, commands ...SlashCommand) ([]*SlashCommand, error)
	GetGlobalCommand(applicationID Snowflake, commandID Snowflake) (*SlashCommand, error)
	EditGlobalCommand(applicationID Snowflake, commandID Snowflake, command SlashCommand) (*SlashCommand, error)
	DeleteGlobalCommand(applicationID Snowflake, commandID Snowflake) error

	GetGuildCommands(applicationID Snowflake, guildID Snowflake) ([]*SlashCommand, error)
	CreateGuildGuildCommand(applicationID Snowflake, guildID Snowflake, command SlashCommand) (*SlashCommand, error)
	SetGuildCommands(applicationID Snowflake, guildID Snowflake, commands ...SlashCommand) ([]*SlashCommand, error)
	GetGuildCommand(applicationID Snowflake, guildID Snowflake, commandID Snowflake) (*SlashCommand, error)
	EditGuildCommand(applicationID Snowflake, guildID Snowflake, commandID Snowflake, command SlashCommand) (*SlashCommand, error)
	DeleteGuildCommand(applicationID Snowflake, guildID Snowflake, commandID Snowflake) error

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

	SendFollowupMessage(applicationID Snowflake, interactionToken string, followupMessage FollowupMessage) (*Message, error)
	EditFollowupMessage(applicationID Snowflake, interactionToken string, messageID Snowflake, followupMessage FollowupMessage) (*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 {
	GatewayCommand
	D struct {
		Token     string `json:"token"`
		SessionID string `json:"session_id"`
		Seq       int    `json:"seq"`
	} `json:"d"`
}

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       Color       `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 SlashCommand

type SlashCommand struct {
	ID            Snowflake        `json:"id,omitempty"`
	ApplicationID Snowflake        `json:"application_id,omitempty"`
	Name          string           `json:"name"`
	Description   string           `json:"description"`
	Options       []*CommandOption `json:"options,omitempty"`
}

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

type SlashCommandOptionType

type SlashCommandOptionType int

SlashCommandOptionType specifies the type of the arguments used in SlashCommand.Options

const (
	OptionTypeSubCommand SlashCommandOptionType = iota + 1
	OptionTypeSubCommandGroup
	OptionTypeString
	OptionTypeInteger
	OptionTypeBoolean
	OptionTypeUser
	OptionTypeChannel
	OptionTypeRole
)

Constants for each slash command option type

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 guilds system channel

const (
	SystemChannelFlagSuppressJoinNotifications SystemChannelFlag = 1 << iota
	SystemChannelFlagSuppressPremiumSubscriptions
)

Constants for SystemChannelFlag

type TextChannel

type TextChannel struct {
	GuildChannel
	MessageChannel
}

TextChannel allows you to interact with discord's text channels

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 UpdateMessage

type UpdateMessage struct {
	Content         *string          `json:"content,omitempty"`
	Embed           *Embed           `json:"embed,omitempty"`
	Flags           *MessageFlags    `json:"flags,omitempty"`
	AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"`
}

UpdateMessage is used to edit a message

type UpdateRole

type UpdateRole struct {
	Name        *string      `json:"name,omitempty"`
	Permissions *Permissions `json:"permissions,omitempty"`
	Color       *Color       `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 {
	GatewayCommand
	D UpdateStatusCommandData `json:"d"`
}

UpdateStatusCommand is used for updating Disgo's presence

type UpdateStatusCommandData

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

UpdateStatusCommandData is the UpdateStatusCommand.D payload

type UpdateVoiceStateCommand

type UpdateVoiceStateCommand struct {
	GatewayCommand
	D UpdateVoiceStateCommandData `json:"d"`
}

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

type UpdateVoiceStateCommandData

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

UpdateVoiceStateCommandData is the UpdateVoiceStateCommand.D payload

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) 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

type VoiceState

type VoiceState struct {
	GuildID    *Snowflake `json:"guild_id,omitempty"`
	ChannelID  *Snowflake `json:"channel_id"`
	UserID     Snowflake  `json:"user_id"`
	Member     *Member    `json:"member,omitempty"`
	SessionID  string     `json:"session_id"`
	Deaf       bool       `json:"deaf"`
	Mute       bool       `json:"mute"`
	SelfDeaf   bool       `json:"self_deaf"`
	SelfMute   bool       `json:"self_mute"`
	SelfStream *bool      `json:"self_stream,omitempty"`
	SelfVideo  bool       `json:"self_video"`
	Suppress   bool       `json:"suppress"`
}

A VoiceState from Discord

type WebhookEventHandler

type WebhookEventHandler interface {
	EventHandler
	Handle(Disgo, EventManager, chan interface{}, 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() error
	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