discord

package
v0.0.0-...-ce63ed4 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PermissionOverwriteTypeRole uint8 = iota
	PermissionOverwriteTypeMember
)

Deprecated: use PermissionOverwrite* instead (note the Type keyword is removed) PermissionOverwriteTypeMember => PermissionOverwriteMember

Constants for the different bit offsets of general permissions

View Source
const (
	MessageActivityTypeJoin
	MessageActivityTypeSpectate
	MessageActivityTypeListen
	MessageActivityTypeJoinRequest
)

different message activity types

View Source
const (
	AttachmentSpoilerPrefix = "SPOILER_"
)
View Source
const (
	EpochDiscord uint64 = 1420070400000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	Name          string             `json:"name"`
	Type          ActivityType       `json:"type"`
	URL           string             `json:"url,omitempty"`
	CreatedAt     int                `json:"created_at"`
	Timestamps    *ActivityTimestamp `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         ActivityFlag       `json:"flags,omitempty"`
}

Activity https://discord.com/developers/docs/topics/gateway#activity-object-activity-structure

type ActivityAssets

type ActivityAssets struct {
	LargeImage string `json:"large_image,omitempty"` // the id for a large asset of the activity, usually a snowflake
	LargeText  string `json:"large_text,omitempty"`  //text displayed when hovering over the large image of the activity
	SmallImage string `json:"small_image,omitempty"` // the id for a small asset of the activity, usually a snowflake
	SmallText  string `json:"small_text,omitempty"`  //	text displayed when hovering over the small image of the activity
}

ActivityAssets ...

type ActivityEmoji

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

ActivityEmoji ...

type ActivityFlag

type ActivityFlag uint

ActivityFlag https://discord.com/developers/docs/topics/gateway#activity-object-activity-flags

const (
	ActivityFlagInstance ActivityFlag = 1 << iota
	ActivityFlagJoin
	ActivityFlagSpectate
	ActivityFlagJoinRequest
	ActivityFlagSync
	ActivityFlagPlay
)

flags for the Activity object to signify the type of action taken place

type ActivityParty

type ActivityParty struct {
	ID   string `json:"id,omitempty"`   // the id of the party
	Size []int  `json:"size,omitempty"` // used to show the party's current and maximum size
}

ActivityParty ...

type ActivitySecrets

type ActivitySecrets struct {
	Join     string `json:"join,omitempty"`     // the secret for joining a party
	Spectate string `json:"spectate,omitempty"` // the secret for spectating a game
	Match    string `json:"match,omitempty"`    // the secret for a specific instanced match
}

ActivitySecrets ...

type ActivityTimestamp

type ActivityTimestamp struct {
	Start int `json:"start,omitempty"` // unix time (in milliseconds) of when the activity started
	End   int `json:"end,omitempty"`   // unix time (in milliseconds) of when the activity ends
}

ActivityTimestamp ...

type ActivityType

type ActivityType uint

ActivityType https://discord.com/developers/docs/topics/gateway#activity-object-activity-types

const (
	ActivityTypeGame ActivityType = iota
	ActivityTypeStreaming
	ActivityTypeListening

	ActivityTypeCustom
	ActivityTypeCompeting
)

type Attachment

type Attachment struct {
	ID       Snowflake `json:"id"`
	Filename string    `json:"filename"`
	Size     uint      `json:"size"`
	URL      string    `json:"url"`
	ProxyURL string    `json:"proxy_url"`
	Height   uint      `json:"height"`
	Width    uint      `json:"width"`

	SpoilerTag bool `json:"-"`
}

Attachment https://discord.com/developers/docs/resources/channel#attachment-object

func (Attachment) ToProto

type AttachmentArray

type AttachmentArray []*Attachment

func (AttachmentArray) ToProto

type Ban

type Ban struct {
	Reason string `json:"reason"`
	User   *User  `json:"user"`
}

Ban https://discord.com/developers/docs/resources/guild#ban-object

type Channel

type Channel struct {
	ID                   Snowflake             `json:"id"`
	Type                 ChannelType           `json:"type"`
	GuildID              Snowflake             `json:"guild_id,omitempty"`
	Position             int                   `json:"position,omitempty"` // can be less than 0
	PermissionOverwrites []PermissionOverwrite `json:"permission_overwrites,omitempty"`
	Name                 string                `json:"name,omitempty"`
	Topic                string                `json:"topic,omitempty"`
	NSFW                 bool                  `json:"nsfw,omitempty"`
	LastMessageID        Snowflake             `json:"last_message_id,omitempty"`
	Bitrate              uint                  `json:"bitrate,omitempty"`
	UserLimit            uint                  `json:"user_limit,omitempty"`
	RateLimitPerUser     uint                  `json:"rate_limit_per_user,omitempty"`
	Recipients           []*User               `json:"recipients,omitempty"` // empty if not DM/GroupDM
	Icon                 string                `json:"icon,omitempty"`
	OwnerID              Snowflake             `json:"owner_id,omitempty"`
	ApplicationID        Snowflake             `json:"application_id,omitempty"`
	ParentID             Snowflake             `json:"parent_id,omitempty"`
	LastPinTimestamp     Time                  `json:"last_pin_timestamp,omitempty"`
}

Channel ...

type ChannelType

type ChannelType uint

Channel types https://discord.com/developers/docs/resources/channel#channel-object-channel-types

const (
	ChannelTypeGuildText ChannelType = iota
	ChannelTypeDM
	ChannelTypeGuildVoice
	ChannelTypeGroupDM
	ChannelTypeGuildCategory
	ChannelTypeGuildNews
	ChannelTypeGuildStore
)

type ClientStatus

type ClientStatus struct {
	Desktop string `json:"desktop"`
	Mobile  string `json:"mobile"`
	Web     string `json:"web"`
}

type DefaultMessageNotificationLvl

type DefaultMessageNotificationLvl uint

DefaultMessageNotificationLvl ... https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level

const (
	DefaultMessageNotificationLvlAllMessages DefaultMessageNotificationLvl = iota
	DefaultMessageNotificationLvlOnlyMentions
)

different notification levels on new messages

func (*DefaultMessageNotificationLvl) AllMessages

func (dmnl *DefaultMessageNotificationLvl) AllMessages() bool

AllMessages ...

func (*DefaultMessageNotificationLvl) OnlyMentions

func (dmnl *DefaultMessageNotificationLvl) OnlyMentions() bool

OnlyMentions ...

type Discriminator

type Discriminator uint16

Discriminator value

func NewDiscriminator

func NewDiscriminator(d string) (discriminator Discriminator, err error)

NewDiscriminator Discord user discriminator hashtag

func (Discriminator) MarshalJSON

func (d Discriminator) MarshalJSON() (data []byte, err error)

MarshalJSON see interface json.Marshaler

func (Discriminator) NotSet

func (d Discriminator) NotSet() bool

NotSet checks if the discriminator is not set

func (Discriminator) String

func (d Discriminator) String() (str string)

func (*Discriminator) UnmarshalJSON

func (d *Discriminator) UnmarshalJSON(data []byte) error

UnmarshalJSON see interface json.Unmarshaler

type Embed

type Embed struct {
	Title       string          `json:"title,omitempty"`       // title of embed
	Type        EmbedType       `json:"type,omitempty"`        // type of embed (always "rich" for webhook embeds)
	Description string          `json:"description,omitempty"` // description of embed
	URL         string          `json:"url,omitempty"`         // url of embed
	Timestamp   Time            `json:"timestamp,omitempty"`   // timestamp	timestamp of embed content
	Color       int             `json:"color,omitempty"`       // color code of the embed
	Footer      *EmbedFooter    `json:"footer,omitempty"`      // embed footer object	footer information
	Image       *EmbedImage     `json:"image,omitempty"`       // embed image object	image information
	Thumbnail   *EmbedThumbnail `json:"thumbnail,omitempty"`   // embed thumbnail object	thumbnail information
	Video       *EmbedVideo     `json:"video,omitempty"`       // embed video object	video information
	Provider    *EmbedProvider  `json:"provider,omitempty"`    // embed provider object	provider information
	Author      *EmbedAuthor    `json:"author,omitempty"`      // embed author object	author information
	Fields      EmbedFieldArray `json:"fields,omitempty"`      //	array of embed field objects	fields information
}

Embed https://discord.com/developers/docs/resources/channel#embed-object

func (Embed) ToProto

type EmbedArray

type EmbedArray []*Embed

func (EmbedArray) ToProto

type EmbedAuthor

type EmbedAuthor struct {
	Name         string `json:"name,omitempty"`           // ?| , name of author
	URL          string `json:"url,omitempty"`            // ?| , url of author
	IconURL      string `json:"icon_url,omitempty"`       // ?| , url of author icon (only supports http(s) and attachments)
	ProxyIconURL string `json:"proxy_icon_url,omitempty"` // ?| , a proxied url of author icon
}

EmbedAuthor https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure

type EmbedField

type EmbedField struct {
	Name   string `json:"name"`             //  | , name of the field
	Value  string `json:"value"`            //  | , value of the field
	Inline bool   `json:"inline,omitempty"` // ?| , whether or not this field should display inline
}

EmbedField https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure

type EmbedFieldArray

type EmbedFieldArray []*EmbedField

type EmbedFooter

type EmbedFooter struct {
	Text         string `json:"text"`                     //  | , url of author
	IconURL      string `json:"icon_url,omitempty"`       // ?| , url of footer icon (only supports http(s) and attachments)
	ProxyIconURL string `json:"proxy_icon_url,omitempty"` // ?| , a proxied url of footer icon
}

EmbedFooter https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure

type EmbedImage

type EmbedImage struct {
	URL      string `json:"url,omitempty"`       // ?| , source url of image (only supports http(s) and attachments)
	ProxyURL string `json:"proxy_url,omitempty"` // ?| , a proxied url of the image
	Height   int    `json:"height,omitempty"`    // ?| , height of image
	Width    int    `json:"width,omitempty"`     // ?| , width of image
}

EmbedImage https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure

type EmbedProvider

type EmbedProvider struct {
	Name string `json:"name,omitempty"` // ?| , name of provider
	URL  string `json:"url,omitempty"`  // ?| , url of provider
}

EmbedProvider https://discord.com/developers/docs/resources/channel#embed-object-embed-provider-structure

type EmbedThumbnail

type EmbedThumbnail struct {
	URL      string `json:"url,omitempty"`       // ?| , source url of image (only supports http(s) and attachments)
	ProxyURL string `json:"proxy_url,omitempty"` // ?| , a proxied url of the image
	Height   int    `json:"height,omitempty"`    // ?| , height of image
	Width    int    `json:"width,omitempty"`     // ?| , width of image
}

EmbedThumbnail https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure

type EmbedType

type EmbedType string
const (
	EmbedTypeRich    EmbedType = "rich"
	EmbedTypeImage   EmbedType = "image"
	EmbedTypeVideo   EmbedType = "video"
	EmbedTypeGIFV    EmbedType = "gifv"
	EmbedTypeArticle EmbedType = "article"
	EmbedTypeLink    EmbedType = "link"
)

type EmbedVideo

type EmbedVideo struct {
	URL    string `json:"url,omitempty"`    // ?| , source url of video
	Height int    `json:"height,omitempty"` // ?| , height of video
	Width  int    `json:"width,omitempty"`  // ?| , width of video
}

EmbedVideo https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure

type Emoji

type Emoji struct {
	ID            Snowflake      `json:"id"`
	Name          string         `json:"name"`
	Roles         SnowflakeArray `json:"roles,omitempty"`
	User          *User          `json:"user,omitempty"` // the user who created the emoji
	RequireColons bool           `json:"require_colons,omitempty"`
	Managed       bool           `json:"managed,omitempty"`
	Animated      bool           `json:"animated,omitempty"`
	Available     bool           `json:"available,omitempty"`
}

Emoji ...

func (*Emoji) ToMessageProto

func (u *Emoji) ToMessageProto() *model.MessageData_MessageReactionEmojiData

func (*Emoji) ToProto

func (u *Emoji) ToProto(guildId Snowflake) *model.EmojiData

type EmojiArr

type EmojiArr []*Emoji

func (EmojiArr) ToProto

func (a EmojiArr) ToProto(guildId Snowflake) []*model.EmojiData

type ErrorUnsupportedType

type ErrorUnsupportedType struct {
	// contains filtered or unexported fields
}

ErrorUnsupportedType used when the given param type is not supported

func (*ErrorUnsupportedType) Error

func (e *ErrorUnsupportedType) Error() string

type ExplicitContentFilterLvl

type ExplicitContentFilterLvl uint

ExplicitContentFilterLvl ... https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level

const (
	ExplicitContentFilterLvlDisabled ExplicitContentFilterLvl = iota
	ExplicitContentFilterLvlMembersWithoutRoles
	ExplicitContentFilterLvlAllMembers
)

Explicit content filter levels

func (*ExplicitContentFilterLvl) AllMembers

func (ecfl *ExplicitContentFilterLvl) AllMembers() bool

AllMembers if the filter applies for all members regardles of them having a role or not

func (*ExplicitContentFilterLvl) Disabled

func (ecfl *ExplicitContentFilterLvl) Disabled() bool

Disabled if the content filter is disabled

func (*ExplicitContentFilterLvl) MembersWithoutRoles

func (ecfl *ExplicitContentFilterLvl) MembersWithoutRoles() bool

MembersWithoutRoles if the filter only applies for members without a role

type Guild

type Guild struct {
	ID                          Snowflake                     `json:"id"`
	ApplicationID               Snowflake                     `json:"application_id"` //   |?
	Name                        string                        `json:"name" merge:"true"`
	Icon                        string                        `json:"icon" merge:"true"`   //  |?, icon hash
	Splash                      string                        `json:"splash" merge:"true"` //  |?, image hash
	Owner                       bool                          `json:"owner,omitempty"`     // ?|
	OwnerID                     Snowflake                     `json:"owner_id" merge:"true"`
	Permissions                 PermissionBit                 `json:"permissions,omitempty"` // ?|, permission flags for connected user `/users/@me/guilds`
	Region                      string                        `json:"region" merge:"true"`
	AfkChannelID                Snowflake                     `json:"afk_channel_id" merge:"true"` // |?
	AfkTimeout                  uint                          `json:"afk_timeout" merge:"true"`
	VerificationLevel           VerificationLvl               `json:"verification_level" merge:"true"`
	DefaultMessageNotifications DefaultMessageNotificationLvl `json:"default_message_notifications" merge:"true"`
	ExplicitContentFilter       ExplicitContentFilterLvl      `json:"explicit_content_filter" merge:"true"`
	Roles                       []*Role                       `json:"roles"`
	Emojis                      []*Emoji                      `json:"emojis" merge:"true"`
	Features                    []string                      `json:"features" merge:"true"`
	MFALevel                    MFALvl                        `json:"mfa_level" merge:"true"`
	WidgetEnabled               bool                          `json:"widget_enabled,omit_empty" merge:"true"`    //   |
	WidgetChannelID             Snowflake                     `json:"widget_channel_id,omit_empty" merge:"true"` //   |?
	SystemChannelID             Snowflake                     `json:"system_channel_id,omitempty" merge:"true"`  //   |?
	DiscoverySplash             string                        `json:"discovery_splash,omitempty" merge:"true"`
	VanityUrl                   string                        `json:"vanity_url_code,omitempty" merge:"true"`
	Description                 string                        `json:"description,omitempty" merge:"true"`
	Banner                      string                        `json:"banner,omitempty" merge:"true"`
	PremiumTier                 PremiumTier                   `json:"premium_tier" merge:"true"`
	PremiumSubscriptionCount    uint                          `json:"premium_subscription_count,omitempty" merge:"true"`
	MaxPresences                uint                          `json:"max_presences,omitempty"  merge:"true"`
	MaxMembers                  uint                          `json:"max_members,omitempty" merge:"true"`
	PublicUpdatesChannel        Snowflake                     `json:"public_updates_channel_id,omitempty" merge:"true"`
	RulesChannel                Snowflake                     `json:"rules_channel_id,omitempty" merge:"true"`
	JoinedAt                    *Time                         `json:"joined_at,omitempty" merge:"true"` // ?*|
	Large                       bool                          `json:"large,omitempty" merge:"true"`     // ?*|
	Unavailable                 bool                          `json:"unavailable" merge:"true"`         // ?*| omitempty?
	MemberCount                 uint                          `json:"member_count,omitempty"`           // ?*|
	VoiceStates                 []*VoiceState                 `json:"voice_states,omitempty"`           // ?*|
	Members                     []*Member                     `json:"members,omitempty"`                // ?*|
	Channels                    []*Channel                    `json:"channels,omitempty"`               // ?*|
	Presences                   []*UserPresence               `json:"presences,omitempty"`              // ?*|
}

Guild Guilds in Discord represent an isolated collection of Users and Channels,

and are often referred to as "servers" in the UI.

https://discord.com/developers/docs/resources/guild#guild-object Fields with `*` are only sent within the GUILD_CREATE event reviewed: 2018-08-25 ++gen_merge

func (*Guild) Merge

func (dst *Guild) Merge(source *Guild)

func (Guild) ToProto

func (g Guild) ToProto() *model.GuildData

type GuildEmbed

type GuildEmbed struct {
	Enabled   bool      `json:"enabled"`
	ChannelID Snowflake `json:"channel_id"`
}

GuildEmbed https://discord.com/developers/docs/resources/guild#guild-embed-object

type GuildUnavailable

type GuildUnavailable struct {
	ID          Snowflake `json:"id"`
	Unavailable bool      `json:"unavailable"` // ?*|
}

GuildUnavailable is a partial Guild object.

func (GuildUnavailable) ToProto

func (g GuildUnavailable) ToProto() *model.GuildData

type ID

type ID = Snowflake

type Integration

type Integration struct {
	ID                Snowflake           `json:"id"`
	Name              string              `json:"name"`
	Type              string              `json:"type"`
	Enabled           bool                `json:"enabled"`
	Syncing           bool                `json:"syncing"`
	RoleID            Snowflake           `json:"role_id"`
	ExpireBehavior    int                 `json:"expire_behavior"`
	ExpireGracePeriod int                 `json:"expire_grace_period"`
	User              *User               `json:"user"`
	Account           *IntegrationAccount `json:"account"`
}

Integration https://discord.com/developers/docs/resources/guild#integration-object

type IntegrationAccount

type IntegrationAccount struct {
	ID   string `json:"id"`   // id of the account
	Name string `json:"name"` // name of the account
}

IntegrationAccount https://discord.com/developers/docs/resources/guild#integration-account-object

type MFALvl

type MFALvl uint

MFALvl ... https://discord.com/developers/docs/resources/guild#guild-object-mfa-level

const (
	MFALvlNone MFALvl = iota
	MFALvlElevated
)

Different MFA levels

func (*MFALvl) Elevated

func (mfal *MFALvl) Elevated() bool

Elevated ...

func (*MFALvl) None

func (mfal *MFALvl) None() bool

None ...

type Member

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

Member https://discord.com/developers/docs/resources/guild#guild-member-object

func (*Member) ToProto

func (m *Member) ToProto() *model.MemberData

func (*Member) ToProtoForMessageCreateOrUpdate

func (m *Member) ToProtoForMessageCreateOrUpdate(userId uint64) *model.MemberData

type MentionChannel

type MentionChannel struct {
	ID      Snowflake   `json:"id"`
	GuildID Snowflake   `json:"guild_id"`
	Type    ChannelType `json:"type"`
	Name    string      `json:"name"`
}

func (MentionChannel) ToProto

type MentionChannelArr

type MentionChannelArr []*MentionChannel

func (MentionChannelArr) ToProto

type Mentioner

type Mentioner interface {
	Mention() string
}

Mentioner can be implemented by any type that is mentionable. https://discord.com/developers/docs/reference#message-formatting-formats

type Message

type Message struct {
	ID              Snowflake      `json:"id"`
	ChannelID       Snowflake      `json:"channel_id"`
	GuildID         Snowflake      `json:"guild_id"`
	Author          *User          `json:"author"`
	Member          *Member        `json:"member"`
	Content         string         `json:"content"`
	Timestamp       Time           `json:"timestamp"`
	EditedTimestamp Time           `json:"edited_timestamp"` // ?
	Tts             bool           `json:"tts"`
	MentionEveryone bool           `json:"mention_everyone"`
	Mentions        UserArr        `json:"mentions"`
	MentionRoles    SnowflakeArray `json:"mention_roles"`
	// TODO: confirm this is being parsed correctly
	MentionChannels   MentionChannelArr  `json:"mention_channels"`
	Attachments       AttachmentArray    `json:"attachments"`
	Embeds            EmbedArray         `json:"embeds"`
	Reactions         ReactionArr        `json:"reactions"` // ?
	Nonce             interface{}        `json:"nonce"`     // NOT A SNOWFLAKE! DONT TOUCH!
	Pinned            bool               `json:"pinned"`
	WebhookID         Snowflake          `json:"webhook_id"` // ?
	Type              MessageType        `json:"type"`
	Activity          MessageActivity    `json:"activity"`
	Application       MessageApplication `json:"application"`
	MessageReference  *MessageReference  `json:"message_reference"`
	ReferencedMessage *Message           `json:"referenced_message"`
	Flags             MessageFlag        `json:"flags"`
	Stickers          MessageStickerArr  `json:"stickers"`

	// SpoilerTagContent is only true if the entire message text is tagged as a spoiler (aka completely wrapped in ||)
	SpoilerTagContent        bool `json:"-"`
	SpoilerTagAllAttachments bool `json:"-"`
	HasSpoilerImage          bool `json:"-"`
}

Message https://discord.com/developers/docs/resources/channel#message-object-message-structure

func (Message) ToPartialProto

func (m Message) ToPartialProto() *event2.MessageUpdateEvent_PayloadData

func (Message) ToProto

func (m Message) ToProto() *model.MessageData

func (Message) ToProtoForMessageCreateOrUpdate

func (m Message) ToProtoForMessageCreateOrUpdate() *model.MessageData

type MessageActivity

type MessageActivity struct {
	Type    int    `json:"type"`
	PartyID string `json:"party_id"`
}

MessageActivity https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure

func (MessageActivity) ToProto

type MessageApplication

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

MessageApplication https://discord.com/developers/docs/resources/channel#message-object-message-application-structure

func (MessageApplication) ToProto

type MessageFlag

type MessageFlag uint

MessageFlag https://discord.com/developers/docs/resources/channel#message-object-message-flags

const (
	MessageFlagCrossposted MessageFlag = 1 << iota
	MessageFlagIsCrosspost
	MessageFlagSupressEmbeds
	MessageFlagSourceMessageDeleted
	MessageFlagUrgent
)

type MessageReference

type MessageReference struct {
	MessageID Snowflake `json:"message_id"`
	ChannelID Snowflake `json:"channel_id"`
	GuildID   Snowflake `json:"guild_id"`
}

func (*MessageReference) ToProto

type MessageSticker

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

func (MessageSticker) ToProto

type MessageStickerArr

type MessageStickerArr []*MessageSticker

func (MessageStickerArr) ToProto

type MessageStickerFormatType

type MessageStickerFormatType int
const (
	MessageStickerFormatUnknown MessageStickerFormatType = iota
	MessageStickerFormatPNG
	MessageStickerFormatAPNG
	MessageStickerFormatLOTTIE
)

type MessageType

type MessageType uint // TODO: once auto generated, un-export this.

The different message types usually generated by Discord. eg. "a new user joined"

const (
	MessageTypeUnknown MessageType = iota
	MessageTypeDefault
	MessageTypeRecipientAdd
	MessageTypeRecipientRemove
	MessageTypeCall
	MessageTypeChannelNameChange
	MessageTypeChannelIconChange
	MessageTypeChannelPinnedMessage
	MessageTypeGuildMemberJoin
	MessageTypeUserPremiumGuildSubscription
	MessageTypeUserPremiumGuildSubscriptionTier1
	MessageTypeUserPremiumGuildSubscriptionTier2
	MessageTypeUserPremiumGuildSubscriptionTier3
	MessageTypeChannelFollowAdd

	MessageTypeGuildDiscoveryDisqualified
	MessageTypeGuildDiscoveryRequalified

	MessageTypeReply
	MessageTypeApplicationCommand
)

type PartialBan

type PartialBan struct {
	Reason                 string
	BannedUserID           Snowflake
	ModeratorResponsibleID Snowflake
}

PartialBan is used by audit logs

type PartialChannel

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

PartialChannel ... example of partial channel // "channel": { // "id": "165176875973476352", // "name": "illuminati", // "type": 0 // }

type PartialEmoji

type PartialEmoji = Emoji

type PermissionBit

type PermissionBit uint64

PermissionBit is used to define the permission bit(s) which are set.

const (
	PermissionReadMessages PermissionBit = 1 << (iota + 10)
	PermissionSendMessages
	PermissionSendTTSMessages
	PermissionManageMessages
	PermissionEmbedLinks
	PermissionAttachFiles
	PermissionReadMessageHistory
	PermissionMentionEveryone
	PermissionUseExternalEmojis
	PermissionViewGuildInsights
)

Constants for the different bit offsets of text channel permissions

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

Constants for the different bit offsets of voice permissions

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

Constants for general management.

func (PermissionBit) Contains

func (b PermissionBit) Contains(Bits PermissionBit) bool

Contains is used to check if the permission bits contains the bits specified.

func (*PermissionBit) MarshalJSON

func (b *PermissionBit) MarshalJSON() ([]byte, error)

func (*PermissionBit) UnmarshalJSON

func (b *PermissionBit) UnmarshalJSON(bytes []byte) error

type PermissionOverwrite

type PermissionOverwrite struct {
	ID    Snowflake               `json:"id"` // role or user id
	Type  PermissionOverwriteType `json:"type"`
	Allow PermissionBit           `json:"allow"`
	Deny  PermissionBit           `json:"deny"`
}

PermissionOverwrite https://discord.com/developers/docs/resources/channel#overwrite-object

WARNING! Discord is bugged, and the Type field needs to be a string to read Permission Overwrites from audit log

type PermissionOverwriteType

type PermissionOverwriteType uint8
const (
	PermissionOverwriteRole PermissionOverwriteType = iota
	PermissionOverwriteMember
)

type PremiumTier

type PremiumTier uint

PremiumTier ... https://discord.com/developers/docs/resources/guild#guild-object-premium-tier

const (
	PremiumTierNone PremiumTier = iota
	PremiumTier1
	PremiumTier2
	PremiumTier3
)

the different premium tier levels

type PremiumType

type PremiumType int
const (
	PremiumTypeNone PremiumType = iota
	PremiumTypeNitroClassic
	PremiumTypeNitro
)

func (PremiumType) String

func (p PremiumType) String() (t string)

type Reaction

type Reaction struct {
	Count uint          `json:"count"`
	Me    bool          `json:"me"`
	Emoji *PartialEmoji `json:"Emoji"`
}

Reaction ... https://discord.com/developers/docs/resources/channel#reaction-object

func (*Reaction) ToProto

type ReactionArr

type ReactionArr []*Reaction

func (ReactionArr) ToProto

type Role

type Role struct {
	ID          Snowflake     `json:"id"`
	Name        string        `json:"name"`
	Color       uint          `json:"color"`
	Hoist       bool          `json:"hoist"`
	Position    int           `json:"position"` // can be -1
	Permissions PermissionBit `json:"permissions"`
	Managed     bool          `json:"managed"`
	Mentionable bool          `json:"mentionable"`
	// contains filtered or unexported fields
}

Role https://discord.com/developers/docs/topics/permissions#role-object

type Snowflake

type Snowflake uint64

Snowflake twitter snowflake design

func NewSnowflake

func NewSnowflake(id uint64) Snowflake

NewID creates a new Snowflake Snowflake from a uint64.

func (Snowflake) Date

func (s Snowflake) Date() time.Time

func (Snowflake) HexPrettyString

func (s Snowflake) HexPrettyString() string

HexPrettyString converts the Snowflake into a hexadecimal string with the hex prefix 0x

func (Snowflake) HexString

func (s Snowflake) HexString() string

HexString converts the Snowflake into a hexadecimal string

func (Snowflake) IsZero

func (s Snowflake) IsZero() bool

IsZero since snowflake exists of several parts, including a timestamp,

I assume a valid snowflake Snowflake is never 0.

func (Snowflake) MarshalBinary

func (s Snowflake) MarshalBinary() (data []byte, err error)

MarshalBinary create a binary literal representation as a string

func (Snowflake) MarshalJSON

func (s Snowflake) MarshalJSON() (data []byte, err error)

func (Snowflake) MarshalText

func (s Snowflake) MarshalText() (text []byte, err error)

func (Snowflake) String

func (s Snowflake) String() string

String returns the decimal representation of the snowflake Snowflake.

func (Snowflake) ToOptionalProto

func (s Snowflake) ToOptionalProto() *model.SnowflakeValue

func (Snowflake) ToProto

func (s Snowflake) ToProto() uint64

func (*Snowflake) UnmarshalBinary

func (s *Snowflake) UnmarshalBinary(text []byte) (err error)

func (*Snowflake) UnmarshalJSON

func (s *Snowflake) UnmarshalJSON(data []byte) (err error)

func (*Snowflake) UnmarshalText

func (s *Snowflake) UnmarshalText(text []byte) (err error)

func (Snowflake) Valid

func (s Snowflake) Valid() bool

Valid makes sure the snowflake is after the fixed epoch

type SnowflakeArray

type SnowflakeArray []Snowflake

func (SnowflakeArray) ToOptionalProto

func (s SnowflakeArray) ToOptionalProto() *model.SnowflakeListValue

func (SnowflakeArray) ToProto

func (s SnowflakeArray) ToProto() []uint64

type Time

type Time struct {
	time.Time
}

Time handles Discord timestamps

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. error: https://stackoverflow.com/questions/28464711/go-strange-json-hyphen-unmarshall-error

func (Time) String

func (t Time) String() string

String returns the timestamp as a Discord formatted timestamp. Formatting with time.RFC3331 does not suffice.

func (Time) ToProto

func (t Time) ToProto() *timestamppb.Timestamp

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type User

type User struct {
	ID            Snowflake     `json:"id,omitempty"`
	Username      string        `json:"username,omitempty"`
	Discriminator Discriminator `json:"discriminator,omitempty"`
	Avatar        string        `json:"avatar"` // data:image/jpeg;base64,BASE64_ENCODED_JPEG_IMAGE_DATA
	Bot           bool          `json:"bot,omitempty"`
	System        bool          `json:"system,omitempty"`
	MFAEnabled    bool          `json:"mfa_enabled,omitempty"`
	Locale        string        `json:"locale,omitempty"`
	Verified      bool          `json:"verified,omitempty"`
	Email         string        `json:"email,omitempty"`
	Flags         UserFlag      `json:"flag,omitempty"`
	PremiumType   PremiumType   `json:"premium_type,omitempty"`
	PublicFlags   UserFlag      `json:"public_flag,omitempty"`
	PartialMember *Member       `json:"member"` // may be populated by Message
}

User the Discord user object which is reused in most other data structures.

func (*User) ToProto

func (u *User) ToProto() *model.UserData

type UserArr

type UserArr []*User

func (UserArr) ToMentionProto

func (a UserArr) ToMentionProto() []*model.MessageData_MessageMentionData

func (UserArr) ToProto

func (a UserArr) ToProto() []*model.UserData

type UserConnection

type UserConnection struct {
	ID      string `json:"id"`      // id of the connection account
	Name    string `json:"name"`    // the username of the connection account
	Type    string `json:"type"`    // the service of the connection (twitch, youtube)
	Revoked bool   `json:"revoked"` // whether the connection is revoked

}

UserConnection ...

type UserFlag

type UserFlag uint64
const (
	UserFlagNone            UserFlag = 0
	UserFlagDiscordEmployee UserFlag = 1 << iota
	UserFlagDiscordPartner
	UserFlagHypeSquadEvents
	UserFlagBugHunterLevel1

	UserFlagHouseBravery
	UserFlagHouseBrilliance
	UserFlagHouseBalance
	UserFlagEarlySupporter
	UserFlagTeamUser

	UserFlagSystem

	UserFlagBugHunterLevel2

	UserFlagVerifiedBot
	UserFlagVerifiedBotDeveloper
)

type UserPresence

type UserPresence struct {
	User    *User       `json:"user"`
	Roles   []Snowflake `json:"roles"`
	Game    *Activity   `json:"activity"`
	GuildID Snowflake   `json:"guild_id"`
	Nick    string      `json:"nick"`
	Status  string      `json:"status"`
}

UserPresence presence info for a guild member or friend/user in a DM

type VerificationLvl

type VerificationLvl uint

VerificationLvl ... https://discord.com/developers/docs/resources/guild#guild-object-verification-level

const (
	VerificationLvlNone VerificationLvl = iota
	VerificationLvlLow
	VerificationLvlMedium
	VerificationLvlHigh
	VerificationLvlVeryHigh
)

the different verification levels

func (*VerificationLvl) High

func (vl *VerificationLvl) High() bool

High (╯°□°)╯︵ ┻━┻ - must be a member of the server for longer than 10 minutes

func (*VerificationLvl) Low

func (vl *VerificationLvl) Low() bool

Low must have verified email on account

func (*VerificationLvl) Medium

func (vl *VerificationLvl) Medium() bool

Medium must be registered on Discord for longer than 5 minutes

func (*VerificationLvl) None

func (vl *VerificationLvl) None() bool

None unrestricted

func (*VerificationLvl) VeryHigh

func (vl *VerificationLvl) VeryHigh() bool

VeryHigh ┻━┻ミヽ(ಠ益ಠ)ノ彡┻━┻ - must have a verified phone number

type VoiceRegion

type VoiceRegion struct {
	// Snowflake unique Snowflake for the region
	ID string `json:"id"`

	// Name name of the region
	Name string `json:"name"`

	// SampleHostname an example hostname for the region
	SampleHostname string `json:"sample_hostname"`

	// SamplePort an example port for the region
	SamplePort uint `json:"sample_port"`

	// VIP true if this is a vip-only server
	VIP bool `json:"vip"`

	// Optimal true for a single server that is closest to the current user's Client
	Optimal bool `json:"optimal"`

	// Deprecated 	whether this is a deprecated voice region (avoid switching to these)
	Deprecated bool `json:"deprecated"`

	// Custom whether this is a custom voice region (used for events/etc)
	Custom bool `json:"custom"`
}

VoiceRegion voice region structure https://discord.com/developers/docs/resources/voice#voice-region

type VoiceState

type VoiceState struct {
	// GuildID the guild id this voice state is for
	GuildID Snowflake `json:"guild_id,omitempty"` // ? |

	// ChannelID the channel id this user is connected to
	ChannelID Snowflake `json:"channel_id"` // | ?

	// UserID the user id this voice state is for
	UserID Snowflake `json:"user_id"` // |

	// the guild member this voice state is for
	Member *Member `json:"member,omitempty"`

	// SessionID the session id for this voice state
	SessionID string `json:"session_id"` // |

	// Deaf whether this user is deafened by the server
	Deaf bool `json:"deaf"` // |

	// Mute whether this user is muted by the server
	Mute bool `json:"mute"` // |

	// SelfDeaf whether this user is locally deafened
	SelfDeaf bool `json:"self_deaf"` // |

	// SelfMute whether this user is locally muted
	SelfMute bool `json:"self_mute"` // |

	// Suppress whether this user is muted by the current user
	Suppress bool `json:"suppress"` // |
}

VoiceState Voice State structure https://discord.com/developers/docs/resources/voice#voice-state-object reviewed 2018-09-29

Jump to

Keyboard shortcuts

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