12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415 |
- // Discordgo - Discord bindings for Go
- // Available at https://github.com/bwmarrin/discordgo
- // Copyright 2015-2016 Bruce Marriner <bruce@sqls.net>. All rights reserved.
- // Use of this source code is governed by a BSD-style
- // license that can be found in the LICENSE file.
- // This file contains all structures for the discordgo package. These
- // may be moved about later into separate files but I find it easier to have
- // them all located together.
- package discordgo
- import (
- "encoding/json"
- "fmt"
- "math"
- "net/http"
- "regexp"
- "strings"
- "sync"
- "time"
- "github.com/gorilla/websocket"
- )
- // A Session represents a connection to the Discord API.
- type Session struct {
- sync.RWMutex
- // General configurable settings.
- // Authentication token for this session
- // TODO: Remove Below, Deprecated, Use Identify struct
- Token string
- MFA bool
- // Debug for printing JSON request/responses
- Debug bool // Deprecated, will be removed.
- LogLevel int
- // Should the session reconnect the websocket on errors.
- ShouldReconnectOnError bool
- // Identify is sent during initial handshake with the discord gateway.
- // https://discord.com/developers/docs/topics/gateway#identify
- Identify Identify
- // TODO: Remove Below, Deprecated, Use Identify struct
- // Should the session request compressed websocket data.
- Compress bool
- // Sharding
- ShardID int
- ShardCount int
- // Should state tracking be enabled.
- // State tracking is the best way for getting the the users
- // active guilds and the members of the guilds.
- StateEnabled bool
- // Whether or not to call event handlers synchronously.
- // e.g false = launch event handlers in their own goroutines.
- SyncEvents bool
- // Exposed but should not be modified by User.
- // Whether the Data Websocket is ready
- DataReady bool // NOTE: Maye be deprecated soon
- // Max number of REST API retries
- MaxRestRetries int
- // Status stores the currect status of the websocket connection
- // this is being tested, may stay, may go away.
- status int32
- // Whether the Voice Websocket is ready
- VoiceReady bool // NOTE: Deprecated.
- // Whether the UDP Connection is ready
- UDPReady bool // NOTE: Deprecated
- // Stores a mapping of guild id's to VoiceConnections
- VoiceConnections map[string]*VoiceConnection
- // Managed state object, updated internally with events when
- // StateEnabled is true.
- State *State
- // The http client used for REST requests
- Client *http.Client
- // The user agent used for REST APIs
- UserAgent string
- // Stores the last HeartbeatAck that was received (in UTC)
- LastHeartbeatAck time.Time
- // Stores the last Heartbeat sent (in UTC)
- LastHeartbeatSent time.Time
- // used to deal with rate limits
- Ratelimiter *RateLimiter
- // Event handlers
- handlersMu sync.RWMutex
- handlers map[string][]*eventHandlerInstance
- onceHandlers map[string][]*eventHandlerInstance
- // The websocket connection.
- wsConn *websocket.Conn
- // When nil, the session is not listening.
- listening chan interface{}
- // sequence tracks the current gateway api websocket sequence number
- sequence *int64
- // stores sessions current Discord Gateway
- gateway string
- // stores session ID of current Gateway connection
- sessionID string
- // used to make sure gateway websocket writes do not happen concurrently
- wsMutex sync.Mutex
- }
- // UserConnection is a Connection returned from the UserConnections endpoint
- type UserConnection struct {
- ID string `json:"id"`
- Name string `json:"name"`
- Type string `json:"type"`
- Revoked bool `json:"revoked"`
- Integrations []*Integration `json:"integrations"`
- }
- // Integration stores integration information
- type Integration struct {
- ID string `json:"id"`
- Name string `json:"name"`
- Type string `json:"type"`
- Enabled bool `json:"enabled"`
- Syncing bool `json:"syncing"`
- RoleID string `json:"role_id"`
- EnableEmoticons bool `json:"enable_emoticons"`
- ExpireBehavior ExpireBehavior `json:"expire_behavior"`
- ExpireGracePeriod int `json:"expire_grace_period"`
- User *User `json:"user"`
- Account IntegrationAccount `json:"account"`
- SyncedAt Timestamp `json:"synced_at"`
- }
- // ExpireBehavior of Integration
- // https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors
- type ExpireBehavior int
- // Block of valid ExpireBehaviors
- const (
- ExpireBehaviorRemoveRole ExpireBehavior = iota
- ExpireBehaviorKick
- )
- // IntegrationAccount is integration account information
- // sent by the UserConnections endpoint
- type IntegrationAccount struct {
- ID string `json:"id"`
- Name string `json:"name"`
- }
- // A VoiceRegion stores data for a specific voice region server.
- type VoiceRegion struct {
- ID string `json:"id"`
- Name string `json:"name"`
- Hostname string `json:"sample_hostname"`
- Port int `json:"sample_port"`
- }
- // A VoiceICE stores data for voice ICE servers.
- type VoiceICE struct {
- TTL string `json:"ttl"`
- Servers []*ICEServer `json:"servers"`
- }
- // A ICEServer stores data for a specific voice ICE server.
- type ICEServer struct {
- URL string `json:"url"`
- Username string `json:"username"`
- Credential string `json:"credential"`
- }
- // A Invite stores all data related to a specific Discord Guild or Channel invite.
- type Invite struct {
- Guild *Guild `json:"guild"`
- Channel *Channel `json:"channel"`
- Inviter *User `json:"inviter"`
- Code string `json:"code"`
- CreatedAt Timestamp `json:"created_at"`
- MaxAge int `json:"max_age"`
- Uses int `json:"uses"`
- MaxUses int `json:"max_uses"`
- Revoked bool `json:"revoked"`
- Temporary bool `json:"temporary"`
- Unique bool `json:"unique"`
- TargetUser *User `json:"target_user"`
- TargetUserType TargetUserType `json:"target_user_type"`
- // will only be filled when using InviteWithCounts
- ApproximatePresenceCount int `json:"approximate_presence_count"`
- ApproximateMemberCount int `json:"approximate_member_count"`
- }
- // TargetUserType is the type of the target user
- // https://discord.com/developers/docs/resources/invite#invite-object-target-user-types
- type TargetUserType int
- // Block contains known TargetUserType values
- const (
- TargetUserTypeStream TargetUserType = iota
- )
- // ChannelType is the type of a Channel
- type ChannelType int
- // Block contains known ChannelType values
- const (
- ChannelTypeGuildText ChannelType = iota
- ChannelTypeDM
- ChannelTypeGuildVoice
- ChannelTypeGroupDM
- ChannelTypeGuildCategory
- ChannelTypeGuildNews
- ChannelTypeGuildStore
- )
- // A Channel holds all data related to an individual Discord channel.
- type Channel struct {
- // The ID of the channel.
- ID string `json:"id"`
- // The ID of the guild to which the channel belongs, if it is in a guild.
- // Else, this ID is empty (e.g. DM channels).
- GuildID string `json:"guild_id"`
- // The name of the channel.
- Name string `json:"name"`
- // The topic of the channel.
- Topic string `json:"topic"`
- // The type of the channel.
- Type ChannelType `json:"type"`
- // The ID of the last message sent in the channel. This is not
- // guaranteed to be an ID of a valid message.
- LastMessageID string `json:"last_message_id"`
- // The timestamp of the last pinned message in the channel.
- // Empty if the channel has no pinned messages.
- LastPinTimestamp Timestamp `json:"last_pin_timestamp"`
- // Whether the channel is marked as NSFW.
- NSFW bool `json:"nsfw"`
- // Icon of the group DM channel.
- Icon string `json:"icon"`
- // The position of the channel, used for sorting in client.
- Position int `json:"position"`
- // The bitrate of the channel, if it is a voice channel.
- Bitrate int `json:"bitrate"`
- // The recipients of the channel. This is only populated in DM channels.
- Recipients []*User `json:"recipients"`
- // The messages in the channel. This is only present in state-cached channels,
- // and State.MaxMessageCount must be non-zero.
- Messages []*Message `json:"-"`
- // A list of permission overwrites present for the channel.
- PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites"`
- // The user limit of the voice channel.
- UserLimit int `json:"user_limit"`
- // The ID of the parent channel, if the channel is under a category
- ParentID string `json:"parent_id"`
- // Amount of seconds a user has to wait before sending another message (0-21600)
- // bots, as well as users with the permission manage_messages or manage_channel, are unaffected
- RateLimitPerUser int `json:"rate_limit_per_user"`
- // ID of the DM creator Zeroed if guild channel
- OwnerID string `json:"owner_id"`
- // ApplicationID of the DM creator Zeroed if guild channel or not a bot user
- ApplicationID string `json:"application_id"`
- }
- // Mention returns a string which mentions the channel
- func (c *Channel) Mention() string {
- return fmt.Sprintf("<#%s>", c.ID)
- }
- // A ChannelEdit holds Channel Field data for a channel edit.
- type ChannelEdit struct {
- Name string `json:"name,omitempty"`
- Topic string `json:"topic,omitempty"`
- NSFW bool `json:"nsfw,omitempty"`
- Position int `json:"position"`
- Bitrate int `json:"bitrate,omitempty"`
- UserLimit int `json:"user_limit,omitempty"`
- PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites,omitempty"`
- ParentID string `json:"parent_id,omitempty"`
- RateLimitPerUser int `json:"rate_limit_per_user,omitempty"`
- }
- // A ChannelFollow holds data returned after following a news channel
- type ChannelFollow struct {
- ChannelID string `json:"channel_id"`
- WebhookID string `json:"webhook_id"`
- }
- // PermissionOverwriteType represents the type of resource on which
- // a permission overwrite acts.
- type PermissionOverwriteType int
- // The possible permission overwrite types.
- const (
- PermissionOverwriteTypeRole PermissionOverwriteType = iota
- PermissionOverwriteTypeMember
- )
- // A PermissionOverwrite holds permission overwrite data for a Channel
- type PermissionOverwrite struct {
- ID string `json:"id"`
- Type PermissionOverwriteType `json:"type"`
- Deny int64 `json:"deny,string"`
- Allow int64 `json:"allow,string"`
- }
- // Emoji struct holds data related to Emoji's
- type Emoji struct {
- ID string `json:"id"`
- Name string `json:"name"`
- Roles []string `json:"roles"`
- User *User `json:"user"`
- RequireColons bool `json:"require_colons"`
- Managed bool `json:"managed"`
- Animated bool `json:"animated"`
- Available bool `json:"available"`
- }
- // EmojiRegex is the regex used to find and identify emojis in messages
- var (
- EmojiRegex = regexp.MustCompile(`<(a|):[A-z0-9_~]+:[0-9]{18}>`)
- )
- // MessageFormat returns a correctly formatted Emoji for use in Message content and embeds
- func (e *Emoji) MessageFormat() string {
- if e.ID != "" && e.Name != "" {
- if e.Animated {
- return "<a:" + e.APIName() + ">"
- }
- return "<:" + e.APIName() + ">"
- }
- return e.APIName()
- }
- // APIName returns an correctly formatted API name for use in the MessageReactions endpoints.
- func (e *Emoji) APIName() string {
- if e.ID != "" && e.Name != "" {
- return e.Name + ":" + e.ID
- }
- if e.Name != "" {
- return e.Name
- }
- return e.ID
- }
- // VerificationLevel type definition
- type VerificationLevel int
- // Constants for VerificationLevel levels from 0 to 4 inclusive
- const (
- VerificationLevelNone VerificationLevel = iota
- VerificationLevelLow
- VerificationLevelMedium
- VerificationLevelHigh
- VerificationLevelVeryHigh
- )
- // ExplicitContentFilterLevel type definition
- type ExplicitContentFilterLevel int
- // Constants for ExplicitContentFilterLevel levels from 0 to 2 inclusive
- const (
- ExplicitContentFilterDisabled ExplicitContentFilterLevel = iota
- ExplicitContentFilterMembersWithoutRoles
- ExplicitContentFilterAllMembers
- )
- // MfaLevel type definition
- type MfaLevel int
- // Constants for MfaLevel levels from 0 to 1 inclusive
- const (
- MfaLevelNone MfaLevel = iota
- MfaLevelElevated
- )
- // PremiumTier type definition
- type PremiumTier int
- // Constants for PremiumTier levels from 0 to 3 inclusive
- const (
- PremiumTierNone PremiumTier = iota
- PremiumTier1
- PremiumTier2
- PremiumTier3
- )
- // A Guild holds all data related to a specific Discord Guild. Guilds are also
- // sometimes referred to as Servers in the Discord client.
- type Guild struct {
- // The ID of the guild.
- ID string `json:"id"`
- // The name of the guild. (2–100 characters)
- Name string `json:"name"`
- // The hash of the guild's icon. Use Session.GuildIcon
- // to retrieve the icon itself.
- Icon string `json:"icon"`
- // The voice region of the guild.
- Region string `json:"region"`
- // The ID of the AFK voice channel.
- AfkChannelID string `json:"afk_channel_id"`
- // The user ID of the owner of the guild.
- OwnerID string `json:"owner_id"`
- // If we are the owner of the guild
- Owner bool `json:"owner"`
- // The time at which the current user joined the guild.
- // This field is only present in GUILD_CREATE events and websocket
- // update events, and thus is only present in state-cached guilds.
- JoinedAt Timestamp `json:"joined_at"`
- // The hash of the guild's discovery splash.
- DiscoverySplash string `json:"discovery_splash"`
- // The hash of the guild's splash.
- Splash string `json:"splash"`
- // The timeout, in seconds, before a user is considered AFK in voice.
- AfkTimeout int `json:"afk_timeout"`
- // The number of members in the guild.
- // This field is only present in GUILD_CREATE events and websocket
- // update events, and thus is only present in state-cached guilds.
- MemberCount int `json:"member_count"`
- // The verification level required for the guild.
- VerificationLevel VerificationLevel `json:"verification_level"`
- // Whether the guild is considered large. This is
- // determined by a member threshold in the identify packet,
- // and is currently hard-coded at 250 members in the library.
- Large bool `json:"large"`
- // The default message notification setting for the guild.
- DefaultMessageNotifications MessageNotifications `json:"default_message_notifications"`
- // A list of roles in the guild.
- Roles []*Role `json:"roles"`
- // A list of the custom emojis present in the guild.
- Emojis []*Emoji `json:"emojis"`
- // A list of the members in the guild.
- // This field is only present in GUILD_CREATE events and websocket
- // update events, and thus is only present in state-cached guilds.
- Members []*Member `json:"members"`
- // A list of partial presence objects for members in the guild.
- // This field is only present in GUILD_CREATE events and websocket
- // update events, and thus is only present in state-cached guilds.
- Presences []*Presence `json:"presences"`
- // The maximum number of presences for the guild (the default value, currently 25000, is in effect when null is returned)
- MaxPresences int `json:"max_presences"`
- // The maximum number of members for the guild
- MaxMembers int `json:"max_members"`
- // A list of channels in the guild.
- // This field is only present in GUILD_CREATE events and websocket
- // update events, and thus is only present in state-cached guilds.
- Channels []*Channel `json:"channels"`
- // A list of voice states for the guild.
- // This field is only present in GUILD_CREATE events and websocket
- // update events, and thus is only present in state-cached guilds.
- VoiceStates []*VoiceState `json:"voice_states"`
- // Whether this guild is currently unavailable (most likely due to outage).
- // This field is only present in GUILD_CREATE events and websocket
- // update events, and thus is only present in state-cached guilds.
- Unavailable bool `json:"unavailable"`
- // The explicit content filter level
- ExplicitContentFilter ExplicitContentFilterLevel `json:"explicit_content_filter"`
- // The list of enabled guild features
- Features []string `json:"features"`
- // Required MFA level for the guild
- MfaLevel MfaLevel `json:"mfa_level"`
- // The application id of the guild if bot created.
- ApplicationID string `json:"application_id"`
- // Whether or not the Server Widget is enabled
- WidgetEnabled bool `json:"widget_enabled"`
- // The Channel ID for the Server Widget
- WidgetChannelID string `json:"widget_channel_id"`
- // The Channel ID to which system messages are sent (eg join and leave messages)
- SystemChannelID string `json:"system_channel_id"`
- // The System channel flags
- SystemChannelFlags SystemChannelFlag `json:"system_channel_flags"`
- // The ID of the rules channel ID, used for rules.
- RulesChannelID string `json:"rules_channel_id"`
- // the vanity url code for the guild
- VanityURLCode string `json:"vanity_url_code"`
- // the description for the guild
- Description string `json:"description"`
- // The hash of the guild's banner
- Banner string `json:"banner"`
- // The premium tier of the guild
- PremiumTier PremiumTier `json:"premium_tier"`
- // The total number of users currently boosting this server
- PremiumSubscriptionCount int `json:"premium_subscription_count"`
- // The preferred locale of a guild with the "PUBLIC" feature; used in server discovery and notices from Discord; defaults to "en-US"
- PreferredLocale string `json:"preferred_locale"`
- // The id of the channel where admins and moderators of guilds with the "PUBLIC" feature receive notices from Discord
- PublicUpdatesChannelID string `json:"public_updates_channel_id"`
- // The maximum amount of users in a video channel
- MaxVideoChannelUsers int `json:"max_video_channel_users"`
- // Approximate number of members in this guild, returned from the GET /guild/<id> endpoint when with_counts is true
- ApproximateMemberCount int `json:"approximate_member_count"`
- // Approximate number of non-offline members in this guild, returned from the GET /guild/<id> endpoint when with_counts is true
- ApproximatePresenceCount int `json:"approximate_presence_count"`
- // Permissions of our user
- Permissions int64 `json:"permissions,string"`
- }
- // A GuildPreview holds data related to a specific public Discord Guild, even if the user is not in the guild.
- type GuildPreview struct {
- // The ID of the guild.
- ID string `json:"id"`
- // The name of the guild. (2–100 characters)
- Name string `json:"name"`
- // The hash of the guild's icon. Use Session.GuildIcon
- // to retrieve the icon itself.
- Icon string `json:"icon"`
- // The hash of the guild's splash.
- Splash string `json:"splash"`
- // The hash of the guild's discovery splash.
- DiscoverySplash string `json:"discovery_splash"`
- // A list of the custom emojis present in the guild.
- Emojis []*Emoji `json:"emojis"`
- // The list of enabled guild features
- Features []string `json:"features"`
- // Approximate number of members in this guild, returned from the GET /guild/<id> endpoint when with_counts is true
- ApproximateMemberCount int `json:"approximate_member_count"`
- // Approximate number of non-offline members in this guild, returned from the GET /guild/<id> endpoint when with_counts is true
- ApproximatePresenceCount int `json:"approximate_presence_count"`
- // the description for the guild
- Description string `json:"description"`
- }
- // MessageNotifications is the notification level for a guild
- // https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
- type MessageNotifications int
- // Block containing known MessageNotifications values
- const (
- MessageNotificationsAllMessages MessageNotifications = iota
- MessageNotificationsOnlyMentions
- )
- // SystemChannelFlag is the type of flags in the system channel (see SystemChannelFlag* consts)
- // https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags
- type SystemChannelFlag int
- // Block containing known SystemChannelFlag values
- const (
- SystemChannelFlagsSuppressJoin SystemChannelFlag = 1 << iota
- SystemChannelFlagsSuppressPremium
- )
- // IconURL returns a URL to the guild's icon.
- func (g *Guild) IconURL() string {
- if g.Icon == "" {
- return ""
- }
- if strings.HasPrefix(g.Icon, "a_") {
- return EndpointGuildIconAnimated(g.ID, g.Icon)
- }
- return EndpointGuildIcon(g.ID, g.Icon)
- }
- // A UserGuild holds a brief version of a Guild
- type UserGuild struct {
- ID string `json:"id"`
- Name string `json:"name"`
- Icon string `json:"icon"`
- Owner bool `json:"owner"`
- Permissions int64 `json:"permissions,string"`
- }
- // A GuildParams stores all the data needed to update discord guild settings
- type GuildParams struct {
- Name string `json:"name,omitempty"`
- Region string `json:"region,omitempty"`
- VerificationLevel *VerificationLevel `json:"verification_level,omitempty"`
- DefaultMessageNotifications int `json:"default_message_notifications,omitempty"` // TODO: Separate type?
- AfkChannelID string `json:"afk_channel_id,omitempty"`
- AfkTimeout int `json:"afk_timeout,omitempty"`
- Icon string `json:"icon,omitempty"`
- OwnerID string `json:"owner_id,omitempty"`
- Splash string `json:"splash,omitempty"`
- Banner string `json:"banner,omitempty"`
- }
- // A Role stores information about Discord guild member roles.
- type Role struct {
- // The ID of the role.
- ID string `json:"id"`
- // The name of the role.
- Name string `json:"name"`
- // Whether this role is managed by an integration, and
- // thus cannot be manually added to, or taken from, members.
- Managed bool `json:"managed"`
- // Whether this role is mentionable.
- Mentionable bool `json:"mentionable"`
- // Whether this role is hoisted (shows up separately in member list).
- Hoist bool `json:"hoist"`
- // The hex color of this role.
- Color int `json:"color"`
- // The position of this role in the guild's role hierarchy.
- Position int `json:"position"`
- // The permissions of the role on the guild (doesn't include channel overrides).
- // This is a combination of bit masks; the presence of a certain permission can
- // be checked by performing a bitwise AND between this int and the permission.
- Permissions int64 `json:"permissions,string"`
- }
- // Mention returns a string which mentions the role
- func (r *Role) Mention() string {
- return fmt.Sprintf("<@&%s>", r.ID)
- }
- // Roles are a collection of Role
- type Roles []*Role
- func (r Roles) Len() int {
- return len(r)
- }
- func (r Roles) Less(i, j int) bool {
- return r[i].Position > r[j].Position
- }
- func (r Roles) Swap(i, j int) {
- r[i], r[j] = r[j], r[i]
- }
- // A VoiceState stores the voice states of Guilds
- type VoiceState struct {
- UserID string `json:"user_id"`
- SessionID string `json:"session_id"`
- ChannelID string `json:"channel_id"`
- GuildID string `json:"guild_id"`
- Suppress bool `json:"suppress"`
- SelfMute bool `json:"self_mute"`
- SelfDeaf bool `json:"self_deaf"`
- Mute bool `json:"mute"`
- Deaf bool `json:"deaf"`
- }
- // A Presence stores the online, offline, or idle and game status of Guild members.
- type Presence struct {
- User *User `json:"user"`
- Status Status `json:"status"`
- Activities []*Activity `json:"activities"`
- Since *int `json:"since"`
- }
- // A TimeStamps struct contains start and end times used in the rich presence "playing .." Game
- type TimeStamps struct {
- EndTimestamp int64 `json:"end,omitempty"`
- StartTimestamp int64 `json:"start,omitempty"`
- }
- // UnmarshalJSON unmarshals JSON into TimeStamps struct
- func (t *TimeStamps) UnmarshalJSON(b []byte) error {
- temp := struct {
- End float64 `json:"end,omitempty"`
- Start float64 `json:"start,omitempty"`
- }{}
- err := json.Unmarshal(b, &temp)
- if err != nil {
- return err
- }
- t.EndTimestamp = int64(temp.End)
- t.StartTimestamp = int64(temp.Start)
- return nil
- }
- // An Assets struct contains assets and labels used in the rich presence "playing .." Game
- type Assets struct {
- LargeImageID string `json:"large_image,omitempty"`
- SmallImageID string `json:"small_image,omitempty"`
- LargeText string `json:"large_text,omitempty"`
- SmallText string `json:"small_text,omitempty"`
- }
- // A Member stores user information for Guild members. A guild
- // member represents a certain user's presence in a guild.
- type Member struct {
- // The guild ID on which the member exists.
- GuildID string `json:"guild_id"`
- // The time at which the member joined the guild, in ISO8601.
- JoinedAt Timestamp `json:"joined_at"`
- // The nickname of the member, if they have one.
- Nick string `json:"nick"`
- // Whether the member is deafened at a guild level.
- Deaf bool `json:"deaf"`
- // Whether the member is muted at a guild level.
- Mute bool `json:"mute"`
- // The underlying user on which the member is based.
- User *User `json:"user"`
- // A list of IDs of the roles which are possessed by the member.
- Roles []string `json:"roles"`
- // When the user used their Nitro boost on the server
- PremiumSince Timestamp `json:"premium_since"`
- // Is true while the member hasn't accepted the membership screen.
- Pending bool `json:"pending"`
- // Total permissions of the member in the channel, including overrides, returned when in the interaction object.
- Permissions int64 `json:"permissions,string"`
- }
- // Mention creates a member mention
- func (m *Member) Mention() string {
- return "<@!" + m.User.ID + ">"
- }
- // A Settings stores data for a specific users Discord client settings.
- type Settings struct {
- RenderEmbeds bool `json:"render_embeds"`
- InlineEmbedMedia bool `json:"inline_embed_media"`
- InlineAttachmentMedia bool `json:"inline_attachment_media"`
- EnableTTSCommand bool `json:"enable_tts_command"`
- MessageDisplayCompact bool `json:"message_display_compact"`
- ShowCurrentGame bool `json:"show_current_game"`
- ConvertEmoticons bool `json:"convert_emoticons"`
- Locale string `json:"locale"`
- Theme string `json:"theme"`
- GuildPositions []string `json:"guild_positions"`
- RestrictedGuilds []string `json:"restricted_guilds"`
- FriendSourceFlags *FriendSourceFlags `json:"friend_source_flags"`
- Status Status `json:"status"`
- DetectPlatformAccounts bool `json:"detect_platform_accounts"`
- DeveloperMode bool `json:"developer_mode"`
- }
- // Status type definition
- type Status string
- // Constants for Status with the different current available status
- const (
- StatusOnline Status = "online"
- StatusIdle Status = "idle"
- StatusDoNotDisturb Status = "dnd"
- StatusInvisible Status = "invisible"
- StatusOffline Status = "offline"
- )
- // FriendSourceFlags stores ... TODO :)
- type FriendSourceFlags struct {
- All bool `json:"all"`
- MutualGuilds bool `json:"mutual_guilds"`
- MutualFriends bool `json:"mutual_friends"`
- }
- // A Relationship between the logged in user and Relationship.User
- type Relationship struct {
- User *User `json:"user"`
- Type int `json:"type"` // 1 = friend, 2 = blocked, 3 = incoming friend req, 4 = sent friend req
- ID string `json:"id"`
- }
- // A TooManyRequests struct holds information received from Discord
- // when receiving a HTTP 429 response.
- type TooManyRequests struct {
- Bucket string `json:"bucket"`
- Message string `json:"message"`
- RetryAfter time.Duration `json:"retry_after"`
- }
- // UnmarshalJSON helps support translation of a milliseconds-based float
- // into a time.Duration on TooManyRequests.
- func (t *TooManyRequests) UnmarshalJSON(b []byte) error {
- u := struct {
- Bucket string `json:"bucket"`
- Message string `json:"message"`
- RetryAfter float64 `json:"retry_after"`
- }{}
- err := json.Unmarshal(b, &u)
- if err != nil {
- return err
- }
- t.Bucket = u.Bucket
- t.Message = u.Message
- whole, frac := math.Modf(u.RetryAfter)
- t.RetryAfter = time.Duration(whole)*time.Second + time.Duration(frac*1000)*time.Millisecond
- return nil
- }
- // A ReadState stores data on the read state of channels.
- type ReadState struct {
- MentionCount int `json:"mention_count"`
- LastMessageID string `json:"last_message_id"`
- ID string `json:"id"`
- }
- // An Ack is used to ack messages
- type Ack struct {
- Token string `json:"token"`
- }
- // A GuildRole stores data for guild roles.
- type GuildRole struct {
- Role *Role `json:"role"`
- GuildID string `json:"guild_id"`
- }
- // A GuildBan stores data for a guild ban.
- type GuildBan struct {
- Reason string `json:"reason"`
- User *User `json:"user"`
- }
- // A GuildEmbed stores data for a guild embed.
- type GuildEmbed struct {
- Enabled bool `json:"enabled"`
- ChannelID string `json:"channel_id"`
- }
- // A GuildAuditLog stores data for a guild audit log.
- // https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure
- type GuildAuditLog struct {
- Webhooks []*Webhook `json:"webhooks,omitempty"`
- Users []*User `json:"users,omitempty"`
- AuditLogEntries []*AuditLogEntry `json:"audit_log_entries"`
- Integrations []*Integration `json:"integrations"`
- }
- // AuditLogEntry for a GuildAuditLog
- // https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-entry-structure
- type AuditLogEntry struct {
- TargetID string `json:"target_id"`
- Changes []*AuditLogChange `json:"changes"`
- UserID string `json:"user_id"`
- ID string `json:"id"`
- ActionType *AuditLogAction `json:"action_type"`
- Options *AuditLogOptions `json:"options"`
- Reason string `json:"reason"`
- }
- // AuditLogChange for an AuditLogEntry
- type AuditLogChange struct {
- NewValue interface{} `json:"new_value"`
- OldValue interface{} `json:"old_value"`
- Key *AuditLogChangeKey `json:"key"`
- }
- // AuditLogChangeKey value for AuditLogChange
- // https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-key
- type AuditLogChangeKey string
- // Block of valid AuditLogChangeKey
- const (
- AuditLogChangeKeyName AuditLogChangeKey = "name"
- AuditLogChangeKeyIconHash AuditLogChangeKey = "icon_hash"
- AuditLogChangeKeySplashHash AuditLogChangeKey = "splash_hash"
- AuditLogChangeKeyOwnerID AuditLogChangeKey = "owner_id"
- AuditLogChangeKeyRegion AuditLogChangeKey = "region"
- AuditLogChangeKeyAfkChannelID AuditLogChangeKey = "afk_channel_id"
- AuditLogChangeKeyAfkTimeout AuditLogChangeKey = "afk_timeout"
- AuditLogChangeKeyMfaLevel AuditLogChangeKey = "mfa_level"
- AuditLogChangeKeyVerificationLevel AuditLogChangeKey = "verification_level"
- AuditLogChangeKeyExplicitContentFilter AuditLogChangeKey = "explicit_content_filter"
- AuditLogChangeKeyDefaultMessageNotification AuditLogChangeKey = "default_message_notifications"
- AuditLogChangeKeyVanityURLCode AuditLogChangeKey = "vanity_url_code"
- AuditLogChangeKeyRoleAdd AuditLogChangeKey = "$add"
- AuditLogChangeKeyRoleRemove AuditLogChangeKey = "$remove"
- AuditLogChangeKeyPruneDeleteDays AuditLogChangeKey = "prune_delete_days"
- AuditLogChangeKeyWidgetEnabled AuditLogChangeKey = "widget_enabled"
- AuditLogChangeKeyWidgetChannelID AuditLogChangeKey = "widget_channel_id"
- AuditLogChangeKeySystemChannelID AuditLogChangeKey = "system_channel_id"
- AuditLogChangeKeyPosition AuditLogChangeKey = "position"
- AuditLogChangeKeyTopic AuditLogChangeKey = "topic"
- AuditLogChangeKeyBitrate AuditLogChangeKey = "bitrate"
- AuditLogChangeKeyPermissionOverwrite AuditLogChangeKey = "permission_overwrites"
- AuditLogChangeKeyNSFW AuditLogChangeKey = "nsfw"
- AuditLogChangeKeyApplicationID AuditLogChangeKey = "application_id"
- AuditLogChangeKeyRateLimitPerUser AuditLogChangeKey = "rate_limit_per_user"
- AuditLogChangeKeyPermissions AuditLogChangeKey = "permissions"
- AuditLogChangeKeyColor AuditLogChangeKey = "color"
- AuditLogChangeKeyHoist AuditLogChangeKey = "hoist"
- AuditLogChangeKeyMentionable AuditLogChangeKey = "mentionable"
- AuditLogChangeKeyAllow AuditLogChangeKey = "allow"
- AuditLogChangeKeyDeny AuditLogChangeKey = "deny"
- AuditLogChangeKeyCode AuditLogChangeKey = "code"
- AuditLogChangeKeyChannelID AuditLogChangeKey = "channel_id"
- AuditLogChangeKeyInviterID AuditLogChangeKey = "inviter_id"
- AuditLogChangeKeyMaxUses AuditLogChangeKey = "max_uses"
- AuditLogChangeKeyUses AuditLogChangeKey = "uses"
- AuditLogChangeKeyMaxAge AuditLogChangeKey = "max_age"
- AuditLogChangeKeyTempoary AuditLogChangeKey = "temporary"
- AuditLogChangeKeyDeaf AuditLogChangeKey = "deaf"
- AuditLogChangeKeyMute AuditLogChangeKey = "mute"
- AuditLogChangeKeyNick AuditLogChangeKey = "nick"
- AuditLogChangeKeyAvatarHash AuditLogChangeKey = "avatar_hash"
- AuditLogChangeKeyID AuditLogChangeKey = "id"
- AuditLogChangeKeyType AuditLogChangeKey = "type"
- AuditLogChangeKeyEnableEmoticons AuditLogChangeKey = "enable_emoticons"
- AuditLogChangeKeyExpireBehavior AuditLogChangeKey = "expire_behavior"
- AuditLogChangeKeyExpireGracePeriod AuditLogChangeKey = "expire_grace_period"
- )
- // AuditLogOptions optional data for the AuditLog
- // https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info
- type AuditLogOptions struct {
- DeleteMemberDays string `json:"delete_member_days"`
- MembersRemoved string `json:"members_removed"`
- ChannelID string `json:"channel_id"`
- MessageID string `json:"message_id"`
- Count string `json:"count"`
- ID string `json:"id"`
- Type *AuditLogOptionsType `json:"type"`
- RoleName string `json:"role_name"`
- }
- // AuditLogOptionsType of the AuditLogOption
- // https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info
- type AuditLogOptionsType string
- // Valid Types for AuditLogOptionsType
- const (
- AuditLogOptionsTypeMember AuditLogOptionsType = "member"
- AuditLogOptionsTypeRole AuditLogOptionsType = "role"
- )
- // AuditLogAction is the Action of the AuditLog (see AuditLogAction* consts)
- // https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events
- type AuditLogAction int
- // Block contains Discord Audit Log Action Types
- const (
- AuditLogActionGuildUpdate AuditLogAction = 1
- AuditLogActionChannelCreate AuditLogAction = 10
- AuditLogActionChannelUpdate AuditLogAction = 11
- AuditLogActionChannelDelete AuditLogAction = 12
- AuditLogActionChannelOverwriteCreate AuditLogAction = 13
- AuditLogActionChannelOverwriteUpdate AuditLogAction = 14
- AuditLogActionChannelOverwriteDelete AuditLogAction = 15
- AuditLogActionMemberKick AuditLogAction = 20
- AuditLogActionMemberPrune AuditLogAction = 21
- AuditLogActionMemberBanAdd AuditLogAction = 22
- AuditLogActionMemberBanRemove AuditLogAction = 23
- AuditLogActionMemberUpdate AuditLogAction = 24
- AuditLogActionMemberRoleUpdate AuditLogAction = 25
- AuditLogActionRoleCreate AuditLogAction = 30
- AuditLogActionRoleUpdate AuditLogAction = 31
- AuditLogActionRoleDelete AuditLogAction = 32
- AuditLogActionInviteCreate AuditLogAction = 40
- AuditLogActionInviteUpdate AuditLogAction = 41
- AuditLogActionInviteDelete AuditLogAction = 42
- AuditLogActionWebhookCreate AuditLogAction = 50
- AuditLogActionWebhookUpdate AuditLogAction = 51
- AuditLogActionWebhookDelete AuditLogAction = 52
- AuditLogActionEmojiCreate AuditLogAction = 60
- AuditLogActionEmojiUpdate AuditLogAction = 61
- AuditLogActionEmojiDelete AuditLogAction = 62
- AuditLogActionMessageDelete AuditLogAction = 72
- AuditLogActionMessageBulkDelete AuditLogAction = 73
- AuditLogActionMessagePin AuditLogAction = 74
- AuditLogActionMessageUnpin AuditLogAction = 75
- AuditLogActionIntegrationCreate AuditLogAction = 80
- AuditLogActionIntegrationUpdate AuditLogAction = 81
- AuditLogActionIntegrationDelete AuditLogAction = 82
- )
- // A UserGuildSettingsChannelOverride stores data for a channel override for a users guild settings.
- type UserGuildSettingsChannelOverride struct {
- Muted bool `json:"muted"`
- MessageNotifications int `json:"message_notifications"`
- ChannelID string `json:"channel_id"`
- }
- // A UserGuildSettings stores data for a users guild settings.
- type UserGuildSettings struct {
- SupressEveryone bool `json:"suppress_everyone"`
- Muted bool `json:"muted"`
- MobilePush bool `json:"mobile_push"`
- MessageNotifications int `json:"message_notifications"`
- GuildID string `json:"guild_id"`
- ChannelOverrides []*UserGuildSettingsChannelOverride `json:"channel_overrides"`
- }
- // A UserGuildSettingsEdit stores data for editing UserGuildSettings
- type UserGuildSettingsEdit struct {
- SupressEveryone bool `json:"suppress_everyone"`
- Muted bool `json:"muted"`
- MobilePush bool `json:"mobile_push"`
- MessageNotifications int `json:"message_notifications"`
- ChannelOverrides map[string]*UserGuildSettingsChannelOverride `json:"channel_overrides"`
- }
- // An APIErrorMessage is an api error message returned from discord
- type APIErrorMessage struct {
- Code int `json:"code"`
- Message string `json:"message"`
- }
- // MessageReaction stores the data for a message reaction.
- type MessageReaction struct {
- UserID string `json:"user_id"`
- MessageID string `json:"message_id"`
- Emoji Emoji `json:"emoji"`
- ChannelID string `json:"channel_id"`
- GuildID string `json:"guild_id,omitempty"`
- }
- // GatewayBotResponse stores the data for the gateway/bot response
- type GatewayBotResponse struct {
- URL string `json:"url"`
- Shards int `json:"shards"`
- }
- // GatewayStatusUpdate is sent by the client to indicate a presence or status update
- // https://discord.com/developers/docs/topics/gateway#update-status-gateway-status-update-structure
- type GatewayStatusUpdate struct {
- Since int `json:"since"`
- Game Activity `json:"game"`
- Status string `json:"status"`
- AFK bool `json:"afk"`
- }
- // Activity defines the Activity sent with GatewayStatusUpdate
- // https://discord.com/developers/docs/topics/gateway#activity-object
- type Activity struct {
- Name string `json:"name"`
- Type ActivityType `json:"type"`
- URL string `json:"url,omitempty"`
- CreatedAt time.Time `json:"created_at"`
- ApplicationID string `json:"application_id,omitempty"`
- State string `json:"state,omitempty"`
- Details string `json:"details,omitempty"`
- Timestamps TimeStamps `json:"timestamps,omitempty"`
- Emoji Emoji `json:"emoji,omitempty"`
- Party Party `json:"party,omitempty"`
- Assets Assets `json:"assets,omitempty"`
- Secrets Secrets `json:"secrets,omitempty"`
- Instance bool `json:"instance,omitempty"`
- Flags int `json:"flags,omitempty"`
- }
- // UnmarshalJSON is a custom unmarshaljson to make CreatedAt a time.Time instead of an int
- func (activity *Activity) UnmarshalJSON(b []byte) error {
- temp := struct {
- Name string `json:"name"`
- Type ActivityType `json:"type"`
- URL string `json:"url,omitempty"`
- CreatedAt int64 `json:"created_at"`
- ApplicationID string `json:"application_id,omitempty"`
- State string `json:"state,omitempty"`
- Details string `json:"details,omitempty"`
- Timestamps TimeStamps `json:"timestamps,omitempty"`
- Emoji Emoji `json:"emoji,omitempty"`
- Party Party `json:"party,omitempty"`
- Assets Assets `json:"assets,omitempty"`
- Secrets Secrets `json:"secrets,omitempty"`
- Instance bool `json:"instance,omitempty"`
- Flags int `json:"flags,omitempty"`
- }{}
- err := json.Unmarshal(b, &temp)
- if err != nil {
- return err
- }
- activity.CreatedAt = time.Unix(0, temp.CreatedAt*1000000)
- activity.ApplicationID = temp.ApplicationID
- activity.Assets = temp.Assets
- activity.Details = temp.Details
- activity.Emoji = temp.Emoji
- activity.Flags = temp.Flags
- activity.Instance = temp.Instance
- activity.Name = temp.Name
- activity.Party = temp.Party
- activity.Secrets = temp.Secrets
- activity.State = temp.State
- activity.Timestamps = temp.Timestamps
- activity.Type = temp.Type
- activity.URL = temp.URL
- return nil
- }
- // Party defines the Party field in the Activity struct
- // https://discord.com/developers/docs/topics/gateway#activity-object
- type Party struct {
- ID string `json:"id,omitempty"`
- Size []int `json:"size,omitempty"`
- }
- // Secrets defines the Secrets field for the Activity struct
- // https://discord.com/developers/docs/topics/gateway#activity-object
- type Secrets struct {
- Join string `json:"join,omitempty"`
- Spectate string `json:"spectate,omitempty"`
- Match string `json:"match,omitempty"`
- }
- // ActivityType is the type of Activity (see ActivityType* consts) in the Activity struct
- // https://discord.com/developers/docs/topics/gateway#activity-object-activity-types
- type ActivityType int
- // Valid ActivityType values
- const (
- ActivityTypeGame ActivityType = iota
- ActivityTypeStreaming
- ActivityTypeListening
- // ActivityTypeWatching // not valid in this use case?
- ActivityTypeCustom = 4
- )
- // Identify is sent during initial handshake with the discord gateway.
- // https://discord.com/developers/docs/topics/gateway#identify
- type Identify struct {
- Token string `json:"token"`
- Properties IdentifyProperties `json:"properties"`
- Compress bool `json:"compress"`
- LargeThreshold int `json:"large_threshold"`
- Shard *[2]int `json:"shard,omitempty"`
- Presence GatewayStatusUpdate `json:"presence,omitempty"`
- GuildSubscriptions bool `json:"guild_subscriptions"`
- Intents Intent `json:"intents"`
- }
- // IdentifyProperties contains the "properties" portion of an Identify packet
- // https://discord.com/developers/docs/topics/gateway#identify-identify-connection-properties
- type IdentifyProperties struct {
- OS string `json:"$os"`
- Browser string `json:"$browser"`
- Device string `json:"$device"`
- Referer string `json:"$referer"`
- ReferringDomain string `json:"$referring_domain"`
- }
- // Constants for the different bit offsets of text channel permissions
- const (
- // Deprecated: PermissionReadMessages has been replaced with PermissionViewChannel for text and voice channels
- PermissionReadMessages = 0x0000000000000400
- PermissionSendMessages = 0x0000000000000800
- PermissionSendTTSMessages = 0x0000000000001000
- PermissionManageMessages = 0x0000000000002000
- PermissionEmbedLinks = 0x0000000000004000
- PermissionAttachFiles = 0x0000000000008000
- PermissionReadMessageHistory = 0x0000000000010000
- PermissionMentionEveryone = 0x0000000000020000
- PermissionUseExternalEmojis = 0x0000000000040000
- PermissionUseSlashCommands = 0x0000000080000000
- )
- // Constants for the different bit offsets of voice permissions
- const (
- PermissionVoicePrioritySpeaker = 0x0000000000000100
- PermissionVoiceStreamVideo = 0x0000000000000200
- PermissionVoiceConnect = 0x0000000000100000
- PermissionVoiceSpeak = 0x0000000000200000
- PermissionVoiceMuteMembers = 0x0000000000400000
- PermissionVoiceDeafenMembers = 0x0000000000800000
- PermissionVoiceMoveMembers = 0x0000000001000000
- PermissionVoiceUseVAD = 0x0000000002000000
- PermissionVoiceRequestToSpeak = 0x0000000100000000
- )
- // Constants for general management.
- const (
- PermissionChangeNickname = 0x0000000004000000
- PermissionManageNicknames = 0x0000000008000000
- PermissionManageRoles = 0x0000000010000000
- PermissionManageWebhooks = 0x0000000020000000
- PermissionManageEmojis = 0x0000000040000000
- )
- // Constants for the different bit offsets of general permissions
- const (
- PermissionCreateInstantInvite = 0x0000000000000001
- PermissionKickMembers = 0x0000000000000002
- PermissionBanMembers = 0x0000000000000004
- PermissionAdministrator = 0x0000000000000008
- PermissionManageChannels = 0x0000000000000010
- PermissionManageServer = 0x0000000000000020
- PermissionAddReactions = 0x0000000000000040
- PermissionViewAuditLogs = 0x0000000000000080
- PermissionViewChannel = 0x0000000000000400
- PermissionViewGuildInsights = 0x0000000000080000
- PermissionAllText = PermissionViewChannel |
- PermissionSendMessages |
- PermissionSendTTSMessages |
- PermissionManageMessages |
- PermissionEmbedLinks |
- PermissionAttachFiles |
- PermissionReadMessageHistory |
- PermissionMentionEveryone
- PermissionAllVoice = PermissionViewChannel |
- PermissionVoiceConnect |
- PermissionVoiceSpeak |
- PermissionVoiceMuteMembers |
- PermissionVoiceDeafenMembers |
- PermissionVoiceMoveMembers |
- PermissionVoiceUseVAD |
- PermissionVoicePrioritySpeaker
- PermissionAllChannel = PermissionAllText |
- PermissionAllVoice |
- PermissionCreateInstantInvite |
- PermissionManageRoles |
- PermissionManageChannels |
- PermissionAddReactions |
- PermissionViewAuditLogs
- PermissionAll = PermissionAllChannel |
- PermissionKickMembers |
- PermissionBanMembers |
- PermissionManageServer |
- PermissionAdministrator |
- PermissionManageWebhooks |
- PermissionManageEmojis
- )
- // Block contains Discord JSON Error Response codes
- const (
- ErrCodeUnknownAccount = 10001
- ErrCodeUnknownApplication = 10002
- ErrCodeUnknownChannel = 10003
- ErrCodeUnknownGuild = 10004
- ErrCodeUnknownIntegration = 10005
- ErrCodeUnknownInvite = 10006
- ErrCodeUnknownMember = 10007
- ErrCodeUnknownMessage = 10008
- ErrCodeUnknownOverwrite = 10009
- ErrCodeUnknownProvider = 10010
- ErrCodeUnknownRole = 10011
- ErrCodeUnknownToken = 10012
- ErrCodeUnknownUser = 10013
- ErrCodeUnknownEmoji = 10014
- ErrCodeUnknownWebhook = 10015
- ErrCodeUnknownBan = 10026
- ErrCodeBotsCannotUseEndpoint = 20001
- ErrCodeOnlyBotsCanUseEndpoint = 20002
- ErrCodeMaximumGuildsReached = 30001
- ErrCodeMaximumFriendsReached = 30002
- ErrCodeMaximumPinsReached = 30003
- ErrCodeMaximumGuildRolesReached = 30005
- ErrCodeTooManyReactions = 30010
- ErrCodeUnauthorized = 40001
- ErrCodeMissingAccess = 50001
- ErrCodeInvalidAccountType = 50002
- ErrCodeCannotExecuteActionOnDMChannel = 50003
- ErrCodeEmbedDisabled = 50004
- ErrCodeCannotEditFromAnotherUser = 50005
- ErrCodeCannotSendEmptyMessage = 50006
- ErrCodeCannotSendMessagesToThisUser = 50007
- ErrCodeCannotSendMessagesInVoiceChannel = 50008
- ErrCodeChannelVerificationLevelTooHigh = 50009
- ErrCodeOAuth2ApplicationDoesNotHaveBot = 50010
- ErrCodeOAuth2ApplicationLimitReached = 50011
- ErrCodeInvalidOAuthState = 50012
- ErrCodeMissingPermissions = 50013
- ErrCodeInvalidAuthenticationToken = 50014
- ErrCodeNoteTooLong = 50015
- ErrCodeTooFewOrTooManyMessagesToDelete = 50016
- ErrCodeCanOnlyPinMessageToOriginatingChannel = 50019
- ErrCodeCannotExecuteActionOnSystemMessage = 50021
- ErrCodeMessageProvidedTooOldForBulkDelete = 50034
- ErrCodeInvalidFormBody = 50035
- ErrCodeInviteAcceptedToGuildApplicationsBotNotIn = 50036
- ErrCodeReactionBlocked = 90001
- )
- // Intent is the type of a Gateway Intent
- // https://discord.com/developers/docs/topics/gateway#gateway-intents
- type Intent int
- // Constants for the different bit offsets of intents
- const (
- IntentsGuilds Intent = 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 Intent = 0
- )
- // MakeIntent used to help convert a gateway intent value for use in the Identify structure;
- // this was useful to help support the use of a pointer type when intents were optional.
- // This is now a no-op, and is not necessary to use.
- func MakeIntent(intents Intent) Intent {
- return intents
- }
|