structs.go 83 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038
  1. // Discordgo - Discord bindings for Go
  2. // Available at https://github.com/bwmarrin/discordgo
  3. // Copyright 2015-2016 Bruce Marriner <bruce@sqls.net>. All rights reserved.
  4. // Use of this source code is governed by a BSD-style
  5. // license that can be found in the LICENSE file.
  6. // This file contains all structures for the discordgo package. These
  7. // may be moved about later into separate files but I find it easier to have
  8. // them all located together.
  9. package discordgo
  10. import (
  11. "encoding/json"
  12. "fmt"
  13. "math"
  14. "net/http"
  15. "regexp"
  16. "strings"
  17. "sync"
  18. "time"
  19. "github.com/gorilla/websocket"
  20. )
  21. // A Session represents a connection to the Discord API.
  22. type Session struct {
  23. sync.RWMutex
  24. // General configurable settings.
  25. // Authentication token for this session
  26. // TODO: Remove Below, Deprecated, Use Identify struct
  27. Token string
  28. MFA bool
  29. // Debug for printing JSON request/responses
  30. Debug bool // Deprecated, will be removed.
  31. LogLevel int
  32. // Should the session reconnect the websocket on errors.
  33. ShouldReconnectOnError bool
  34. // Identify is sent during initial handshake with the discord gateway.
  35. // https://discord.com/developers/docs/topics/gateway#identify
  36. Identify Identify
  37. // TODO: Remove Below, Deprecated, Use Identify struct
  38. // Should the session request compressed websocket data.
  39. Compress bool
  40. // Sharding
  41. ShardID int
  42. ShardCount int
  43. // Should state tracking be enabled.
  44. // State tracking is the best way for getting the the users
  45. // active guilds and the members of the guilds.
  46. StateEnabled bool
  47. // Whether or not to call event handlers synchronously.
  48. // e.g false = launch event handlers in their own goroutines.
  49. SyncEvents bool
  50. // Exposed but should not be modified by User.
  51. // Whether the Data Websocket is ready
  52. DataReady bool // NOTE: Maye be deprecated soon
  53. // Max number of REST API retries
  54. MaxRestRetries int
  55. // Status stores the currect status of the websocket connection
  56. // this is being tested, may stay, may go away.
  57. status int32
  58. // Whether the Voice Websocket is ready
  59. VoiceReady bool // NOTE: Deprecated.
  60. // Whether the UDP Connection is ready
  61. UDPReady bool // NOTE: Deprecated
  62. // Stores a mapping of guild id's to VoiceConnections
  63. VoiceConnections map[string]*VoiceConnection
  64. // Managed state object, updated internally with events when
  65. // StateEnabled is true.
  66. State *State
  67. // The http client used for REST requests
  68. Client *http.Client
  69. // The user agent used for REST APIs
  70. UserAgent string
  71. // Stores the last HeartbeatAck that was received (in UTC)
  72. LastHeartbeatAck time.Time
  73. // Stores the last Heartbeat sent (in UTC)
  74. LastHeartbeatSent time.Time
  75. // used to deal with rate limits
  76. Ratelimiter *RateLimiter
  77. // Event handlers
  78. handlersMu sync.RWMutex
  79. handlers map[string][]*eventHandlerInstance
  80. onceHandlers map[string][]*eventHandlerInstance
  81. // The websocket connection.
  82. wsConn *websocket.Conn
  83. // When nil, the session is not listening.
  84. listening chan interface{}
  85. // sequence tracks the current gateway api websocket sequence number
  86. sequence *int64
  87. // stores sessions current Discord Gateway
  88. gateway string
  89. // stores session ID of current Gateway connection
  90. sessionID string
  91. // used to make sure gateway websocket writes do not happen concurrently
  92. wsMutex sync.Mutex
  93. }
  94. // Application stores values for a Discord Application
  95. type Application struct {
  96. ID string `json:"id,omitempty"`
  97. Name string `json:"name"`
  98. Icon string `json:"icon,omitempty"`
  99. Description string `json:"description,omitempty"`
  100. RPCOrigins []string `json:"rpc_origins,omitempty"`
  101. BotPublic bool `json:"bot_public,omitempty"`
  102. BotRequireCodeGrant bool `json:"bot_require_code_grant,omitempty"`
  103. TermsOfServiceURL string `json:"terms_of_service_url"`
  104. PrivacyProxyURL string `json:"privacy_policy_url"`
  105. Owner *User `json:"owner"`
  106. Summary string `json:"summary"`
  107. VerifyKey string `json:"verify_key"`
  108. Team *Team `json:"team"`
  109. GuildID string `json:"guild_id"`
  110. PrimarySKUID string `json:"primary_sku_id"`
  111. Slug string `json:"slug"`
  112. CoverImage string `json:"cover_image"`
  113. Flags int `json:"flags,omitempty"`
  114. }
  115. // UserConnection is a Connection returned from the UserConnections endpoint
  116. type UserConnection struct {
  117. ID string `json:"id"`
  118. Name string `json:"name"`
  119. Type string `json:"type"`
  120. Revoked bool `json:"revoked"`
  121. Integrations []*Integration `json:"integrations"`
  122. }
  123. // Integration stores integration information
  124. type Integration struct {
  125. ID string `json:"id"`
  126. Name string `json:"name"`
  127. Type string `json:"type"`
  128. Enabled bool `json:"enabled"`
  129. Syncing bool `json:"syncing"`
  130. RoleID string `json:"role_id"`
  131. EnableEmoticons bool `json:"enable_emoticons"`
  132. ExpireBehavior ExpireBehavior `json:"expire_behavior"`
  133. ExpireGracePeriod int `json:"expire_grace_period"`
  134. User *User `json:"user"`
  135. Account IntegrationAccount `json:"account"`
  136. SyncedAt time.Time `json:"synced_at"`
  137. }
  138. // ExpireBehavior of Integration
  139. // https://discord.com/developers/docs/resources/guild#integration-object-integration-expire-behaviors
  140. type ExpireBehavior int
  141. // Block of valid ExpireBehaviors
  142. const (
  143. ExpireBehaviorRemoveRole ExpireBehavior = 0
  144. ExpireBehaviorKick ExpireBehavior = 1
  145. )
  146. // IntegrationAccount is integration account information
  147. // sent by the UserConnections endpoint
  148. type IntegrationAccount struct {
  149. ID string `json:"id"`
  150. Name string `json:"name"`
  151. }
  152. // A VoiceRegion stores data for a specific voice region server.
  153. type VoiceRegion struct {
  154. ID string `json:"id"`
  155. Name string `json:"name"`
  156. Hostname string `json:"sample_hostname"`
  157. Port int `json:"sample_port"`
  158. }
  159. // A VoiceICE stores data for voice ICE servers.
  160. type VoiceICE struct {
  161. TTL string `json:"ttl"`
  162. Servers []*ICEServer `json:"servers"`
  163. }
  164. // A ICEServer stores data for a specific voice ICE server.
  165. type ICEServer struct {
  166. URL string `json:"url"`
  167. Username string `json:"username"`
  168. Credential string `json:"credential"`
  169. }
  170. // InviteTargetType indicates the type of target of an invite
  171. // https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types
  172. type InviteTargetType uint8
  173. // Invite target types
  174. const (
  175. InviteTargetStream InviteTargetType = 1
  176. InviteTargetEmbeddedAppliction InviteTargetType = 2
  177. )
  178. // A Invite stores all data related to a specific Discord Guild or Channel invite.
  179. type Invite struct {
  180. Guild *Guild `json:"guild"`
  181. Channel *Channel `json:"channel"`
  182. Inviter *User `json:"inviter"`
  183. Code string `json:"code"`
  184. CreatedAt time.Time `json:"created_at"`
  185. MaxAge int `json:"max_age"`
  186. Uses int `json:"uses"`
  187. MaxUses int `json:"max_uses"`
  188. Revoked bool `json:"revoked"`
  189. Temporary bool `json:"temporary"`
  190. Unique bool `json:"unique"`
  191. TargetUser *User `json:"target_user"`
  192. TargetType InviteTargetType `json:"target_type"`
  193. TargetApplication *Application `json:"target_application"`
  194. // will only be filled when using InviteWithCounts
  195. ApproximatePresenceCount int `json:"approximate_presence_count"`
  196. ApproximateMemberCount int `json:"approximate_member_count"`
  197. }
  198. // ChannelType is the type of a Channel
  199. type ChannelType int
  200. // Block contains known ChannelType values
  201. const (
  202. ChannelTypeGuildText ChannelType = 0
  203. ChannelTypeDM ChannelType = 1
  204. ChannelTypeGuildVoice ChannelType = 2
  205. ChannelTypeGroupDM ChannelType = 3
  206. ChannelTypeGuildCategory ChannelType = 4
  207. ChannelTypeGuildNews ChannelType = 5
  208. ChannelTypeGuildStore ChannelType = 6
  209. ChannelTypeGuildNewsThread ChannelType = 10
  210. ChannelTypeGuildPublicThread ChannelType = 11
  211. ChannelTypeGuildPrivateThread ChannelType = 12
  212. )
  213. // A Channel holds all data related to an individual Discord channel.
  214. type Channel struct {
  215. // The ID of the channel.
  216. ID string `json:"id"`
  217. // The ID of the guild to which the channel belongs, if it is in a guild.
  218. // Else, this ID is empty (e.g. DM channels).
  219. GuildID string `json:"guild_id"`
  220. // The name of the channel.
  221. Name string `json:"name"`
  222. // The topic of the channel.
  223. Topic string `json:"topic"`
  224. // The type of the channel.
  225. Type ChannelType `json:"type"`
  226. // The ID of the last message sent in the channel. This is not
  227. // guaranteed to be an ID of a valid message.
  228. LastMessageID string `json:"last_message_id"`
  229. // The timestamp of the last pinned message in the channel.
  230. // nil if the channel has no pinned messages.
  231. LastPinTimestamp *time.Time `json:"last_pin_timestamp"`
  232. // An approximate count of messages in a thread, stops counting at 50
  233. MessageCount int `json:"message_count"`
  234. // An approximate count of users in a thread, stops counting at 50
  235. MemberCount int `json:"member_count"`
  236. // Whether the channel is marked as NSFW.
  237. NSFW bool `json:"nsfw"`
  238. // Icon of the group DM channel.
  239. Icon string `json:"icon"`
  240. // The position of the channel, used for sorting in client.
  241. Position int `json:"position"`
  242. // The bitrate of the channel, if it is a voice channel.
  243. Bitrate int `json:"bitrate"`
  244. // The recipients of the channel. This is only populated in DM channels.
  245. Recipients []*User `json:"recipients"`
  246. // The messages in the channel. This is only present in state-cached channels,
  247. // and State.MaxMessageCount must be non-zero.
  248. Messages []*Message `json:"-"`
  249. // A list of permission overwrites present for the channel.
  250. PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites"`
  251. // The user limit of the voice channel.
  252. UserLimit int `json:"user_limit"`
  253. // The ID of the parent channel, if the channel is under a category. For threads - id of the channel thread was created in.
  254. ParentID string `json:"parent_id"`
  255. // Amount of seconds a user has to wait before sending another message or creating another thread (0-21600)
  256. // bots, as well as users with the permission manage_messages or manage_channel, are unaffected
  257. RateLimitPerUser int `json:"rate_limit_per_user"`
  258. // ID of the creator of the group DM or thread
  259. OwnerID string `json:"owner_id"`
  260. // ApplicationID of the DM creator Zeroed if guild channel or not a bot user
  261. ApplicationID string `json:"application_id"`
  262. // Thread-specific fields not needed by other channels
  263. ThreadMetadata *ThreadMetadata `json:"thread_metadata,omitempty"`
  264. // Thread member object for the current user, if they have joined the thread, only included on certain API endpoints
  265. Member *ThreadMember `json:"thread_member"`
  266. // All thread members. State channels only.
  267. Members []*ThreadMember `json:"-"`
  268. }
  269. // Mention returns a string which mentions the channel
  270. func (c *Channel) Mention() string {
  271. return fmt.Sprintf("<#%s>", c.ID)
  272. }
  273. // IsThread is a helper function to determine if channel is a thread or not
  274. func (c *Channel) IsThread() bool {
  275. return c.Type == ChannelTypeGuildPublicThread || c.Type == ChannelTypeGuildPrivateThread || c.Type == ChannelTypeGuildNewsThread
  276. }
  277. // A ChannelEdit holds Channel Field data for a channel edit.
  278. type ChannelEdit struct {
  279. Name string `json:"name,omitempty"`
  280. Topic string `json:"topic,omitempty"`
  281. NSFW bool `json:"nsfw,omitempty"`
  282. Position int `json:"position"`
  283. Bitrate int `json:"bitrate,omitempty"`
  284. UserLimit int `json:"user_limit,omitempty"`
  285. PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites,omitempty"`
  286. ParentID string `json:"parent_id,omitempty"`
  287. RateLimitPerUser int `json:"rate_limit_per_user,omitempty"`
  288. // NOTE: threads only
  289. Archived bool `json:"archived,omitempty"`
  290. AutoArchiveDuration int `json:"auto_archive_duration,omitempty"`
  291. Locked bool `json:"locked,bool"`
  292. Invitable bool `json:"invitable,omitempty"`
  293. }
  294. // A ChannelFollow holds data returned after following a news channel
  295. type ChannelFollow struct {
  296. ChannelID string `json:"channel_id"`
  297. WebhookID string `json:"webhook_id"`
  298. }
  299. // PermissionOverwriteType represents the type of resource on which
  300. // a permission overwrite acts.
  301. type PermissionOverwriteType int
  302. // The possible permission overwrite types.
  303. const (
  304. PermissionOverwriteTypeRole PermissionOverwriteType = 0
  305. PermissionOverwriteTypeMember PermissionOverwriteType = 1
  306. )
  307. // A PermissionOverwrite holds permission overwrite data for a Channel
  308. type PermissionOverwrite struct {
  309. ID string `json:"id"`
  310. Type PermissionOverwriteType `json:"type"`
  311. Deny int64 `json:"deny,string"`
  312. Allow int64 `json:"allow,string"`
  313. }
  314. // ThreadStart stores all parameters you can use with MessageThreadStartComplex or ThreadStartComplex
  315. type ThreadStart struct {
  316. Name string `json:"name"`
  317. AutoArchiveDuration int `json:"auto_archive_duration,omitempty"`
  318. Type ChannelType `json:"type,omitempty"`
  319. Invitable bool `json:"invitable"`
  320. RateLimitPerUser int `json:"rate_limit_per_user,omitempty"`
  321. }
  322. // ThreadMetadata contains a number of thread-specific channel fields that are not needed by other channel types.
  323. type ThreadMetadata struct {
  324. // Whether the thread is archived
  325. Archived bool `json:"archived"`
  326. // Duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080
  327. AutoArchiveDuration int `json:"auto_archive_duration"`
  328. // Timestamp when the thread's archive status was last changed, used for calculating recent activity
  329. ArchiveTimestamp time.Time `json:"archive_timestamp"`
  330. // Whether the thread is locked; when a thread is locked, only users with MANAGE_THREADS can unarchive it
  331. Locked bool `json:"locked"`
  332. // Whether non-moderators can add other non-moderators to a thread; only available on private threads
  333. Invitable bool `json:"invitable"`
  334. }
  335. // ThreadMember is used to indicate whether a user has joined a thread or not.
  336. // NOTE: ID and UserID are empty (omitted) on the member sent within each thread in the GUILD_CREATE event.
  337. type ThreadMember struct {
  338. // The id of the thread
  339. ID string `json:"id,omitempty"`
  340. // The id of the user
  341. UserID string `json:"user_id,omitempty"`
  342. // The time the current user last joined the thread
  343. JoinTimestamp time.Time `json:"join_timestamp"`
  344. // Any user-thread settings, currently only used for notifications
  345. Flags int
  346. }
  347. // ThreadsList represents a list of threads alongisde with thread member objects for the current user.
  348. type ThreadsList struct {
  349. Threads []*Channel `json:"threads"`
  350. Members []*ThreadMember `json:"members"`
  351. HasMore bool `json:"has_more"`
  352. }
  353. // AddedThreadMember holds information about the user who was added to the thread
  354. type AddedThreadMember struct {
  355. *ThreadMember
  356. Member *Member `json:"member"`
  357. Presence *Presence `json:"presence"`
  358. }
  359. // Emoji struct holds data related to Emoji's
  360. type Emoji struct {
  361. ID string `json:"id"`
  362. Name string `json:"name"`
  363. Roles []string `json:"roles"`
  364. User *User `json:"user"`
  365. RequireColons bool `json:"require_colons"`
  366. Managed bool `json:"managed"`
  367. Animated bool `json:"animated"`
  368. Available bool `json:"available"`
  369. }
  370. // EmojiRegex is the regex used to find and identify emojis in messages
  371. var (
  372. EmojiRegex = regexp.MustCompile(`<(a|):[A-z0-9_~]+:[0-9]{18}>`)
  373. )
  374. // MessageFormat returns a correctly formatted Emoji for use in Message content and embeds
  375. func (e *Emoji) MessageFormat() string {
  376. if e.ID != "" && e.Name != "" {
  377. if e.Animated {
  378. return "<a:" + e.APIName() + ">"
  379. }
  380. return "<:" + e.APIName() + ">"
  381. }
  382. return e.APIName()
  383. }
  384. // APIName returns an correctly formatted API name for use in the MessageReactions endpoints.
  385. func (e *Emoji) APIName() string {
  386. if e.ID != "" && e.Name != "" {
  387. return e.Name + ":" + e.ID
  388. }
  389. if e.Name != "" {
  390. return e.Name
  391. }
  392. return e.ID
  393. }
  394. // StickerFormat is the file format of the Sticker.
  395. type StickerFormat int
  396. // Defines all known Sticker types.
  397. const (
  398. StickerFormatTypePNG StickerFormat = 1
  399. StickerFormatTypeAPNG StickerFormat = 2
  400. StickerFormatTypeLottie StickerFormat = 3
  401. )
  402. // StickerType is the type of sticker.
  403. type StickerType int
  404. // Defines Sticker types.
  405. const (
  406. StickerTypeStandard StickerType = 1
  407. StickerTypeGuild StickerType = 2
  408. )
  409. // Sticker represents a sticker object that can be sent in a Message.
  410. type Sticker struct {
  411. ID string `json:"id"`
  412. PackID string `json:"pack_id"`
  413. Name string `json:"name"`
  414. Description string `json:"description"`
  415. Tags string `json:"tags"`
  416. Type StickerType `json:"type"`
  417. FormatType StickerFormat `json:"format_type"`
  418. Available bool `json:"available"`
  419. GuildID string `json:"guild_id"`
  420. User *User `json:"user"`
  421. SortValue int `json:"sort_value"`
  422. }
  423. // StickerPack represents a pack of standard stickers.
  424. type StickerPack struct {
  425. ID string `json:"id"`
  426. Stickers []*Sticker `json:"stickers"`
  427. Name string `json:"name"`
  428. SKUID string `json:"sku_id"`
  429. CoverStickerID string `json:"cover_sticker_id"`
  430. Description string `json:"description"`
  431. BannerAssetID string `json:"banner_asset_id"`
  432. }
  433. // VerificationLevel type definition
  434. type VerificationLevel int
  435. // Constants for VerificationLevel levels from 0 to 4 inclusive
  436. const (
  437. VerificationLevelNone VerificationLevel = 0
  438. VerificationLevelLow VerificationLevel = 1
  439. VerificationLevelMedium VerificationLevel = 2
  440. VerificationLevelHigh VerificationLevel = 3
  441. VerificationLevelVeryHigh VerificationLevel = 4
  442. )
  443. // ExplicitContentFilterLevel type definition
  444. type ExplicitContentFilterLevel int
  445. // Constants for ExplicitContentFilterLevel levels from 0 to 2 inclusive
  446. const (
  447. ExplicitContentFilterDisabled ExplicitContentFilterLevel = 0
  448. ExplicitContentFilterMembersWithoutRoles ExplicitContentFilterLevel = 1
  449. ExplicitContentFilterAllMembers ExplicitContentFilterLevel = 2
  450. )
  451. // MfaLevel type definition
  452. type MfaLevel int
  453. // Constants for MfaLevel levels from 0 to 1 inclusive
  454. const (
  455. MfaLevelNone MfaLevel = 0
  456. MfaLevelElevated MfaLevel = 1
  457. )
  458. // PremiumTier type definition
  459. type PremiumTier int
  460. // Constants for PremiumTier levels from 0 to 3 inclusive
  461. const (
  462. PremiumTierNone PremiumTier = 0
  463. PremiumTier1 PremiumTier = 1
  464. PremiumTier2 PremiumTier = 2
  465. PremiumTier3 PremiumTier = 3
  466. )
  467. // A Guild holds all data related to a specific Discord Guild. Guilds are also
  468. // sometimes referred to as Servers in the Discord client.
  469. type Guild struct {
  470. // The ID of the guild.
  471. ID string `json:"id"`
  472. // The name of the guild. (2–100 characters)
  473. Name string `json:"name"`
  474. // The hash of the guild's icon. Use Session.GuildIcon
  475. // to retrieve the icon itself.
  476. Icon string `json:"icon"`
  477. // The voice region of the guild.
  478. Region string `json:"region"`
  479. // The ID of the AFK voice channel.
  480. AfkChannelID string `json:"afk_channel_id"`
  481. // The user ID of the owner of the guild.
  482. OwnerID string `json:"owner_id"`
  483. // If we are the owner of the guild
  484. Owner bool `json:"owner"`
  485. // The time at which the current user joined the guild.
  486. // This field is only present in GUILD_CREATE events and websocket
  487. // update events, and thus is only present in state-cached guilds.
  488. JoinedAt time.Time `json:"joined_at"`
  489. // The hash of the guild's discovery splash.
  490. DiscoverySplash string `json:"discovery_splash"`
  491. // The hash of the guild's splash.
  492. Splash string `json:"splash"`
  493. // The timeout, in seconds, before a user is considered AFK in voice.
  494. AfkTimeout int `json:"afk_timeout"`
  495. // The number of members in the guild.
  496. // This field is only present in GUILD_CREATE events and websocket
  497. // update events, and thus is only present in state-cached guilds.
  498. MemberCount int `json:"member_count"`
  499. // The verification level required for the guild.
  500. VerificationLevel VerificationLevel `json:"verification_level"`
  501. // Whether the guild is considered large. This is
  502. // determined by a member threshold in the identify packet,
  503. // and is currently hard-coded at 250 members in the library.
  504. Large bool `json:"large"`
  505. // The default message notification setting for the guild.
  506. DefaultMessageNotifications MessageNotifications `json:"default_message_notifications"`
  507. // A list of roles in the guild.
  508. Roles []*Role `json:"roles"`
  509. // A list of the custom emojis present in the guild.
  510. Emojis []*Emoji `json:"emojis"`
  511. // A list of the custom stickers present in the guild.
  512. Stickers []*Sticker `json:"stickers"`
  513. // A list of the members in the guild.
  514. // This field is only present in GUILD_CREATE events and websocket
  515. // update events, and thus is only present in state-cached guilds.
  516. Members []*Member `json:"members"`
  517. // A list of partial presence objects for members in the guild.
  518. // This field is only present in GUILD_CREATE events and websocket
  519. // update events, and thus is only present in state-cached guilds.
  520. Presences []*Presence `json:"presences"`
  521. // The maximum number of presences for the guild (the default value, currently 25000, is in effect when null is returned)
  522. MaxPresences int `json:"max_presences"`
  523. // The maximum number of members for the guild
  524. MaxMembers int `json:"max_members"`
  525. // A list of channels in the guild.
  526. // This field is only present in GUILD_CREATE events and websocket
  527. // update events, and thus is only present in state-cached guilds.
  528. Channels []*Channel `json:"channels"`
  529. // A list of all active threads in the guild that current user has permission to view
  530. // This field is only present in GUILD_CREATE events and websocket
  531. // update events and thus is only present in state-cached guilds.
  532. Threads []*Channel `json:"threads"`
  533. // A list of voice states for the guild.
  534. // This field is only present in GUILD_CREATE events and websocket
  535. // update events, and thus is only present in state-cached guilds.
  536. VoiceStates []*VoiceState `json:"voice_states"`
  537. // Whether this guild is currently unavailable (most likely due to outage).
  538. // This field is only present in GUILD_CREATE events and websocket
  539. // update events, and thus is only present in state-cached guilds.
  540. Unavailable bool `json:"unavailable"`
  541. // The explicit content filter level
  542. ExplicitContentFilter ExplicitContentFilterLevel `json:"explicit_content_filter"`
  543. // The list of enabled guild features
  544. Features []string `json:"features"`
  545. // Required MFA level for the guild
  546. MfaLevel MfaLevel `json:"mfa_level"`
  547. // The application id of the guild if bot created.
  548. ApplicationID string `json:"application_id"`
  549. // Whether or not the Server Widget is enabled
  550. WidgetEnabled bool `json:"widget_enabled"`
  551. // The Channel ID for the Server Widget
  552. WidgetChannelID string `json:"widget_channel_id"`
  553. // The Channel ID to which system messages are sent (eg join and leave messages)
  554. SystemChannelID string `json:"system_channel_id"`
  555. // The System channel flags
  556. SystemChannelFlags SystemChannelFlag `json:"system_channel_flags"`
  557. // The ID of the rules channel ID, used for rules.
  558. RulesChannelID string `json:"rules_channel_id"`
  559. // the vanity url code for the guild
  560. VanityURLCode string `json:"vanity_url_code"`
  561. // the description for the guild
  562. Description string `json:"description"`
  563. // The hash of the guild's banner
  564. Banner string `json:"banner"`
  565. // The premium tier of the guild
  566. PremiumTier PremiumTier `json:"premium_tier"`
  567. // The total number of users currently boosting this server
  568. PremiumSubscriptionCount int `json:"premium_subscription_count"`
  569. // The preferred locale of a guild with the "PUBLIC" feature; used in server discovery and notices from Discord; defaults to "en-US"
  570. PreferredLocale string `json:"preferred_locale"`
  571. // The id of the channel where admins and moderators of guilds with the "PUBLIC" feature receive notices from Discord
  572. PublicUpdatesChannelID string `json:"public_updates_channel_id"`
  573. // The maximum amount of users in a video channel
  574. MaxVideoChannelUsers int `json:"max_video_channel_users"`
  575. // Approximate number of members in this guild, returned from the GET /guild/<id> endpoint when with_counts is true
  576. ApproximateMemberCount int `json:"approximate_member_count"`
  577. // Approximate number of non-offline members in this guild, returned from the GET /guild/<id> endpoint when with_counts is true
  578. ApproximatePresenceCount int `json:"approximate_presence_count"`
  579. // Permissions of our user
  580. Permissions int64 `json:"permissions,string"`
  581. }
  582. // A GuildPreview holds data related to a specific public Discord Guild, even if the user is not in the guild.
  583. type GuildPreview struct {
  584. // The ID of the guild.
  585. ID string `json:"id"`
  586. // The name of the guild. (2–100 characters)
  587. Name string `json:"name"`
  588. // The hash of the guild's icon. Use Session.GuildIcon
  589. // to retrieve the icon itself.
  590. Icon string `json:"icon"`
  591. // The hash of the guild's splash.
  592. Splash string `json:"splash"`
  593. // The hash of the guild's discovery splash.
  594. DiscoverySplash string `json:"discovery_splash"`
  595. // A list of the custom emojis present in the guild.
  596. Emojis []*Emoji `json:"emojis"`
  597. // The list of enabled guild features
  598. Features []string `json:"features"`
  599. // Approximate number of members in this guild, returned from the GET /guild/<id> endpoint when with_counts is true
  600. ApproximateMemberCount int `json:"approximate_member_count"`
  601. // Approximate number of non-offline members in this guild, returned from the GET /guild/<id> endpoint when with_counts is true
  602. ApproximatePresenceCount int `json:"approximate_presence_count"`
  603. // the description for the guild
  604. Description string `json:"description"`
  605. }
  606. // GuildScheduledEvent is a representation of a scheduled event in a guild. Only for retrieval of the data.
  607. // https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event
  608. type GuildScheduledEvent struct {
  609. // The ID of the scheduled event
  610. ID string `json:"id"`
  611. // The guild id which the scheduled event belongs to
  612. GuildID string `json:"guild_id"`
  613. // The channel id in which the scheduled event will be hosted, or null if scheduled entity type is EXTERNAL
  614. ChannelID string `json:"channel_id"`
  615. // The id of the user that created the scheduled event
  616. CreatorID string `json:"creator_id"`
  617. // The name of the scheduled event (1-100 characters)
  618. Name string `json:"name"`
  619. // The description of the scheduled event (1-1000 characters)
  620. Description string `json:"description"`
  621. // The time the scheduled event will start
  622. ScheduledStartTime time.Time `json:"scheduled_start_time"`
  623. // The time the scheduled event will end, required only when entity_type is EXTERNAL
  624. ScheduledEndTime *time.Time `json:"scheduled_end_time"`
  625. // The privacy level of the scheduled event
  626. PrivacyLevel GuildScheduledEventPrivacyLevel `json:"privacy_level"`
  627. // The status of the scheduled event
  628. Status GuildScheduledEventStatus `json:"status"`
  629. // Type of the entity where event would be hosted
  630. // See field requirements
  631. // https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-field-requirements-by-entity-type
  632. EntityType GuildScheduledEventEntityType `json:"entity_type"`
  633. // The id of an entity associated with a guild scheduled event
  634. EntityID string `json:"entity_id"`
  635. // Additional metadata for the guild scheduled event
  636. EntityMetadata GuildScheduledEventEntityMetadata `json:"entity_metadata"`
  637. // The user that created the scheduled event
  638. Creator *User `json:"creator"`
  639. // The number of users subscribed to the scheduled event
  640. UserCount int `json:"user_count"`
  641. // The cover image hash of the scheduled event
  642. // see https://discord.com/developers/docs/reference#image-formatting for more
  643. // information about image formatting
  644. Image string `json:"image"`
  645. }
  646. // GuildScheduledEventParams are the parameters allowed for creating or updating a scheduled event
  647. // https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event
  648. type GuildScheduledEventParams struct {
  649. // The channel id in which the scheduled event will be hosted, or null if scheduled entity type is EXTERNAL
  650. ChannelID string `json:"channel_id,omitempty"`
  651. // The name of the scheduled event (1-100 characters)
  652. Name string `json:"name,omitempty"`
  653. // The description of the scheduled event (1-1000 characters)
  654. Description string `json:"description,omitempty"`
  655. // The time the scheduled event will start
  656. ScheduledStartTime *time.Time `json:"scheduled_start_time,omitempty"`
  657. // The time the scheduled event will end, required only when entity_type is EXTERNAL
  658. ScheduledEndTime *time.Time `json:"scheduled_end_time,omitempty"`
  659. // The privacy level of the scheduled event
  660. PrivacyLevel GuildScheduledEventPrivacyLevel `json:"privacy_level,omitempty"`
  661. // The status of the scheduled event
  662. Status GuildScheduledEventStatus `json:"status,omitempty"`
  663. // Type of the entity where event would be hosted
  664. // See field requirements
  665. // https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-field-requirements-by-entity-type
  666. EntityType GuildScheduledEventEntityType `json:"entity_type,omitempty"`
  667. // Additional metadata for the guild scheduled event
  668. EntityMetadata *GuildScheduledEventEntityMetadata `json:"entity_metadata,omitempty"`
  669. // The cover image hash of the scheduled event
  670. // see https://discord.com/developers/docs/reference#image-formatting for more
  671. // information about image formatting
  672. Image string `json:"image,omitempty"`
  673. }
  674. // MarshalJSON is a helper function to marshal GuildScheduledEventParams
  675. func (p GuildScheduledEventParams) MarshalJSON() ([]byte, error) {
  676. type guildScheduledEventParams GuildScheduledEventParams
  677. if p.EntityType == GuildScheduledEventEntityTypeExternal && p.ChannelID == "" {
  678. return json.Marshal(struct {
  679. guildScheduledEventParams
  680. ChannelID json.RawMessage `json:"channel_id"`
  681. }{
  682. guildScheduledEventParams: guildScheduledEventParams(p),
  683. ChannelID: json.RawMessage("null"),
  684. })
  685. }
  686. return json.Marshal(guildScheduledEventParams(p))
  687. }
  688. // GuildScheduledEventEntityMetadata holds additional metadata for guild scheduled event.
  689. type GuildScheduledEventEntityMetadata struct {
  690. // location of the event (1-100 characters)
  691. // required for events with 'entity_type': EXTERNAL
  692. Location string `json:"location"`
  693. }
  694. // GuildScheduledEventPrivacyLevel is the privacy level of a scheduled event.
  695. // https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-privacy-level
  696. type GuildScheduledEventPrivacyLevel int
  697. const (
  698. // GuildScheduledEventPrivacyLevelGuildOnly makes the scheduled
  699. // event is only accessible to guild members
  700. GuildScheduledEventPrivacyLevelGuildOnly GuildScheduledEventPrivacyLevel = 2
  701. )
  702. // GuildScheduledEventStatus is the status of a scheduled event
  703. // Valid Guild Scheduled Event Status Transitions :
  704. // SCHEDULED --> ACTIVE --> COMPLETED
  705. // SCHEDULED --> CANCELED
  706. // https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-status
  707. type GuildScheduledEventStatus int
  708. const (
  709. // GuildScheduledEventStatusScheduled represents the current event is in scheduled state
  710. GuildScheduledEventStatusScheduled = 1
  711. // GuildScheduledEventStatusActive represents the current event is in active state
  712. GuildScheduledEventStatusActive = 2
  713. // GuildScheduledEventStatusCompleted represents the current event is in completed state
  714. GuildScheduledEventStatusCompleted = 3
  715. // GuildScheduledEventStatusCanceled represents the current event is in canceled state
  716. GuildScheduledEventStatusCanceled = 4
  717. )
  718. // GuildScheduledEventEntityType is the type of entity associated with a guild scheduled event.
  719. // https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-entity-types
  720. type GuildScheduledEventEntityType int
  721. const (
  722. // GuildScheduledEventEntityTypeStageInstance represents a stage channel
  723. GuildScheduledEventEntityTypeStageInstance = 1
  724. // GuildScheduledEventEntityTypeVoice represents a voice channel
  725. GuildScheduledEventEntityTypeVoice = 2
  726. // GuildScheduledEventEntityTypeExternal represents an external event
  727. GuildScheduledEventEntityTypeExternal = 3
  728. )
  729. // GuildScheduledEventUser is a user subscribed to a scheduled event.
  730. // https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-user-object
  731. type GuildScheduledEventUser struct {
  732. GuildScheduledEventID string `json:"guild_scheduled_event_id"`
  733. User *User `json:"user"`
  734. Member *Member `json:"member"`
  735. }
  736. // A GuildTemplate represents
  737. type GuildTemplate struct {
  738. // The unique code for the guild template
  739. Code string `json:"code"`
  740. // The name of the template
  741. Name string `json:"name"`
  742. // The description for the template
  743. Description string `json:"description"`
  744. // The number of times this template has been used
  745. UsageCount string `json:"usage_count"`
  746. // The ID of the user who created the template
  747. CreatorID string `json:"creator_id"`
  748. // The user who created the template
  749. Creator *User `json:"creator"`
  750. // The timestamp of when the template was created
  751. CreatedAt time.Time `json:"created_at"`
  752. // The timestamp of when the template was last synced
  753. UpdatedAt time.Time `json:"updated_at"`
  754. // The ID of the guild the template was based on
  755. SourceGuildID string `json:"source_guild_id"`
  756. // The guild 'snapshot' this template contains
  757. SerializedSourceGuild *Guild `json:"serialized_source_guild"`
  758. // Whether the template has unsynced changes
  759. IsDirty bool `json:"is_dirty"`
  760. }
  761. // MessageNotifications is the notification level for a guild
  762. // https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
  763. type MessageNotifications int
  764. // Block containing known MessageNotifications values
  765. const (
  766. MessageNotificationsAllMessages MessageNotifications = 0
  767. MessageNotificationsOnlyMentions MessageNotifications = 1
  768. )
  769. // SystemChannelFlag is the type of flags in the system channel (see SystemChannelFlag* consts)
  770. // https://discord.com/developers/docs/resources/guild#guild-object-system-channel-flags
  771. type SystemChannelFlag int
  772. // Block containing known SystemChannelFlag values
  773. const (
  774. SystemChannelFlagsSuppressJoin SystemChannelFlag = 1 << 0
  775. SystemChannelFlagsSuppressPremium SystemChannelFlag = 1 << 1
  776. )
  777. // IconURL returns a URL to the guild's icon.
  778. func (g *Guild) IconURL() string {
  779. if g.Icon == "" {
  780. return ""
  781. }
  782. if strings.HasPrefix(g.Icon, "a_") {
  783. return EndpointGuildIconAnimated(g.ID, g.Icon)
  784. }
  785. return EndpointGuildIcon(g.ID, g.Icon)
  786. }
  787. // BannerURL returns a URL to the guild's banner.
  788. func (g *Guild) BannerURL() string {
  789. if g.Banner == "" {
  790. return ""
  791. }
  792. return EndpointGuildBanner(g.ID, g.Banner)
  793. }
  794. // A UserGuild holds a brief version of a Guild
  795. type UserGuild struct {
  796. ID string `json:"id"`
  797. Name string `json:"name"`
  798. Icon string `json:"icon"`
  799. Owner bool `json:"owner"`
  800. Permissions int64 `json:"permissions,string"`
  801. }
  802. // A GuildParams stores all the data needed to update discord guild settings
  803. type GuildParams struct {
  804. Name string `json:"name,omitempty"`
  805. Region string `json:"region,omitempty"`
  806. VerificationLevel *VerificationLevel `json:"verification_level,omitempty"`
  807. DefaultMessageNotifications int `json:"default_message_notifications,omitempty"` // TODO: Separate type?
  808. AfkChannelID string `json:"afk_channel_id,omitempty"`
  809. AfkTimeout int `json:"afk_timeout,omitempty"`
  810. Icon string `json:"icon,omitempty"`
  811. OwnerID string `json:"owner_id,omitempty"`
  812. Splash string `json:"splash,omitempty"`
  813. Banner string `json:"banner,omitempty"`
  814. }
  815. // A Role stores information about Discord guild member roles.
  816. type Role struct {
  817. // The ID of the role.
  818. ID string `json:"id"`
  819. // The name of the role.
  820. Name string `json:"name"`
  821. // Whether this role is managed by an integration, and
  822. // thus cannot be manually added to, or taken from, members.
  823. Managed bool `json:"managed"`
  824. // Whether this role is mentionable.
  825. Mentionable bool `json:"mentionable"`
  826. // Whether this role is hoisted (shows up separately in member list).
  827. Hoist bool `json:"hoist"`
  828. // The hex color of this role.
  829. Color int `json:"color"`
  830. // The position of this role in the guild's role hierarchy.
  831. Position int `json:"position"`
  832. // The permissions of the role on the guild (doesn't include channel overrides).
  833. // This is a combination of bit masks; the presence of a certain permission can
  834. // be checked by performing a bitwise AND between this int and the permission.
  835. Permissions int64 `json:"permissions,string"`
  836. }
  837. // Mention returns a string which mentions the role
  838. func (r *Role) Mention() string {
  839. return fmt.Sprintf("<@&%s>", r.ID)
  840. }
  841. // Roles are a collection of Role
  842. type Roles []*Role
  843. func (r Roles) Len() int {
  844. return len(r)
  845. }
  846. func (r Roles) Less(i, j int) bool {
  847. return r[i].Position > r[j].Position
  848. }
  849. func (r Roles) Swap(i, j int) {
  850. r[i], r[j] = r[j], r[i]
  851. }
  852. // A VoiceState stores the voice states of Guilds
  853. type VoiceState struct {
  854. UserID string `json:"user_id"`
  855. SessionID string `json:"session_id"`
  856. ChannelID string `json:"channel_id"`
  857. GuildID string `json:"guild_id"`
  858. Suppress bool `json:"suppress"`
  859. SelfMute bool `json:"self_mute"`
  860. SelfDeaf bool `json:"self_deaf"`
  861. Mute bool `json:"mute"`
  862. Deaf bool `json:"deaf"`
  863. }
  864. // A Presence stores the online, offline, or idle and game status of Guild members.
  865. type Presence struct {
  866. User *User `json:"user"`
  867. Status Status `json:"status"`
  868. Activities []*Activity `json:"activities"`
  869. Since *int `json:"since"`
  870. }
  871. // A TimeStamps struct contains start and end times used in the rich presence "playing .." Game
  872. type TimeStamps struct {
  873. EndTimestamp int64 `json:"end,omitempty"`
  874. StartTimestamp int64 `json:"start,omitempty"`
  875. }
  876. // UnmarshalJSON unmarshals JSON into TimeStamps struct
  877. func (t *TimeStamps) UnmarshalJSON(b []byte) error {
  878. temp := struct {
  879. End float64 `json:"end,omitempty"`
  880. Start float64 `json:"start,omitempty"`
  881. }{}
  882. err := json.Unmarshal(b, &temp)
  883. if err != nil {
  884. return err
  885. }
  886. t.EndTimestamp = int64(temp.End)
  887. t.StartTimestamp = int64(temp.Start)
  888. return nil
  889. }
  890. // An Assets struct contains assets and labels used in the rich presence "playing .." Game
  891. type Assets struct {
  892. LargeImageID string `json:"large_image,omitempty"`
  893. SmallImageID string `json:"small_image,omitempty"`
  894. LargeText string `json:"large_text,omitempty"`
  895. SmallText string `json:"small_text,omitempty"`
  896. }
  897. // A Member stores user information for Guild members. A guild
  898. // member represents a certain user's presence in a guild.
  899. type Member struct {
  900. // The guild ID on which the member exists.
  901. GuildID string `json:"guild_id"`
  902. // The time at which the member joined the guild.
  903. JoinedAt time.Time `json:"joined_at"`
  904. // The nickname of the member, if they have one.
  905. Nick string `json:"nick"`
  906. // Whether the member is deafened at a guild level.
  907. Deaf bool `json:"deaf"`
  908. // Whether the member is muted at a guild level.
  909. Mute bool `json:"mute"`
  910. // The hash of the avatar for the guild member, if any.
  911. Avatar string `json:"avatar"`
  912. // The underlying user on which the member is based.
  913. User *User `json:"user"`
  914. // A list of IDs of the roles which are possessed by the member.
  915. Roles []string `json:"roles"`
  916. // When the user used their Nitro boost on the server
  917. PremiumSince *time.Time `json:"premium_since"`
  918. // Is true while the member hasn't accepted the membership screen.
  919. Pending bool `json:"pending"`
  920. // Total permissions of the member in the channel, including overrides, returned when in the interaction object.
  921. Permissions int64 `json:"permissions,string"`
  922. // The time at which the member's timeout will expire.
  923. // Time in the past or nil if the user is not timed out.
  924. CommunicationDisabledUntil *time.Time `json:"communication_disabled_until"`
  925. }
  926. // Mention creates a member mention
  927. func (m *Member) Mention() string {
  928. return "<@!" + m.User.ID + ">"
  929. }
  930. // AvatarURL returns the URL of the member's avatar
  931. // size: The size of the user's avatar as a power of two
  932. // if size is an empty string, no size parameter will
  933. // be added to the URL.
  934. func (m *Member) AvatarURL(size string) string {
  935. if m.Avatar == "" {
  936. return m.User.AvatarURL(size)
  937. }
  938. // The default/empty avatar case should be handled by the above condition
  939. return avatarURL(m.Avatar, "", EndpointGuildMemberAvatar(m.GuildID, m.User.ID, m.Avatar),
  940. EndpointGuildMemberAvatarAnimated(m.GuildID, m.User.ID, m.Avatar), size)
  941. }
  942. // A Settings stores data for a specific users Discord client settings.
  943. type Settings struct {
  944. RenderEmbeds bool `json:"render_embeds"`
  945. InlineEmbedMedia bool `json:"inline_embed_media"`
  946. InlineAttachmentMedia bool `json:"inline_attachment_media"`
  947. EnableTTSCommand bool `json:"enable_tts_command"`
  948. MessageDisplayCompact bool `json:"message_display_compact"`
  949. ShowCurrentGame bool `json:"show_current_game"`
  950. ConvertEmoticons bool `json:"convert_emoticons"`
  951. Locale string `json:"locale"`
  952. Theme string `json:"theme"`
  953. GuildPositions []string `json:"guild_positions"`
  954. RestrictedGuilds []string `json:"restricted_guilds"`
  955. FriendSourceFlags *FriendSourceFlags `json:"friend_source_flags"`
  956. Status Status `json:"status"`
  957. DetectPlatformAccounts bool `json:"detect_platform_accounts"`
  958. DeveloperMode bool `json:"developer_mode"`
  959. }
  960. // Status type definition
  961. type Status string
  962. // Constants for Status with the different current available status
  963. const (
  964. StatusOnline Status = "online"
  965. StatusIdle Status = "idle"
  966. StatusDoNotDisturb Status = "dnd"
  967. StatusInvisible Status = "invisible"
  968. StatusOffline Status = "offline"
  969. )
  970. // FriendSourceFlags stores ... TODO :)
  971. type FriendSourceFlags struct {
  972. All bool `json:"all"`
  973. MutualGuilds bool `json:"mutual_guilds"`
  974. MutualFriends bool `json:"mutual_friends"`
  975. }
  976. // A Relationship between the logged in user and Relationship.User
  977. type Relationship struct {
  978. User *User `json:"user"`
  979. Type int `json:"type"` // 1 = friend, 2 = blocked, 3 = incoming friend req, 4 = sent friend req
  980. ID string `json:"id"`
  981. }
  982. // A TooManyRequests struct holds information received from Discord
  983. // when receiving a HTTP 429 response.
  984. type TooManyRequests struct {
  985. Bucket string `json:"bucket"`
  986. Message string `json:"message"`
  987. RetryAfter time.Duration `json:"retry_after"`
  988. }
  989. // UnmarshalJSON helps support translation of a milliseconds-based float
  990. // into a time.Duration on TooManyRequests.
  991. func (t *TooManyRequests) UnmarshalJSON(b []byte) error {
  992. u := struct {
  993. Bucket string `json:"bucket"`
  994. Message string `json:"message"`
  995. RetryAfter float64 `json:"retry_after"`
  996. }{}
  997. err := json.Unmarshal(b, &u)
  998. if err != nil {
  999. return err
  1000. }
  1001. t.Bucket = u.Bucket
  1002. t.Message = u.Message
  1003. whole, frac := math.Modf(u.RetryAfter)
  1004. t.RetryAfter = time.Duration(whole)*time.Second + time.Duration(frac*1000)*time.Millisecond
  1005. return nil
  1006. }
  1007. // A ReadState stores data on the read state of channels.
  1008. type ReadState struct {
  1009. MentionCount int `json:"mention_count"`
  1010. LastMessageID string `json:"last_message_id"`
  1011. ID string `json:"id"`
  1012. }
  1013. // An Ack is used to ack messages
  1014. type Ack struct {
  1015. Token string `json:"token"`
  1016. }
  1017. // A GuildRole stores data for guild roles.
  1018. type GuildRole struct {
  1019. Role *Role `json:"role"`
  1020. GuildID string `json:"guild_id"`
  1021. }
  1022. // A GuildBan stores data for a guild ban.
  1023. type GuildBan struct {
  1024. Reason string `json:"reason"`
  1025. User *User `json:"user"`
  1026. }
  1027. // A GuildEmbed stores data for a guild embed.
  1028. type GuildEmbed struct {
  1029. Enabled bool `json:"enabled"`
  1030. ChannelID string `json:"channel_id"`
  1031. }
  1032. // A GuildAuditLog stores data for a guild audit log.
  1033. // https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure
  1034. type GuildAuditLog struct {
  1035. Webhooks []*Webhook `json:"webhooks,omitempty"`
  1036. Users []*User `json:"users,omitempty"`
  1037. AuditLogEntries []*AuditLogEntry `json:"audit_log_entries"`
  1038. Integrations []*Integration `json:"integrations"`
  1039. }
  1040. // AuditLogEntry for a GuildAuditLog
  1041. // https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-entry-structure
  1042. type AuditLogEntry struct {
  1043. TargetID string `json:"target_id"`
  1044. Changes []*AuditLogChange `json:"changes"`
  1045. UserID string `json:"user_id"`
  1046. ID string `json:"id"`
  1047. ActionType *AuditLogAction `json:"action_type"`
  1048. Options *AuditLogOptions `json:"options"`
  1049. Reason string `json:"reason"`
  1050. }
  1051. // AuditLogChange for an AuditLogEntry
  1052. type AuditLogChange struct {
  1053. NewValue interface{} `json:"new_value"`
  1054. OldValue interface{} `json:"old_value"`
  1055. Key *AuditLogChangeKey `json:"key"`
  1056. }
  1057. // AuditLogChangeKey value for AuditLogChange
  1058. // https://discord.com/developers/docs/resources/audit-log#audit-log-change-object-audit-log-change-key
  1059. type AuditLogChangeKey string
  1060. // Block of valid AuditLogChangeKey
  1061. const (
  1062. // AuditLogChangeKeyAfkChannelID is sent when afk channel changed (snowflake) - guild
  1063. AuditLogChangeKeyAfkChannelID AuditLogChangeKey = "afk_channel_id"
  1064. // AuditLogChangeKeyAfkTimeout is sent when afk timeout duration changed (int) - guild
  1065. AuditLogChangeKeyAfkTimeout AuditLogChangeKey = "afk_timeout"
  1066. // AuditLogChangeKeyAllow is sent when a permission on a text or voice channel was allowed for a role (string) - role
  1067. AuditLogChangeKeyAllow AuditLogChangeKey = "allow"
  1068. // AudirChangeKeyApplicationID is sent when application id of the added or removed webhook or bot (snowflake) - channel
  1069. AuditLogChangeKeyApplicationID AuditLogChangeKey = "application_id"
  1070. // AuditLogChangeKeyArchived is sent when thread was archived/unarchived (bool) - thread
  1071. AuditLogChangeKeyArchived AuditLogChangeKey = "archived"
  1072. // AuditLogChangeKeyAsset is sent when asset is changed (string) - sticker
  1073. AuditLogChangeKeyAsset AuditLogChangeKey = "asset"
  1074. // AuditLogChangeKeyAutoArchiveDuration is sent when auto archive duration changed (int) - thread
  1075. AuditLogChangeKeyAutoArchiveDuration AuditLogChangeKey = "auto_archive_duration"
  1076. // AuditLogChangeKeyAvailable is sent when availability of sticker changed (bool) - sticker
  1077. AuditLogChangeKeyAvailable AuditLogChangeKey = "available"
  1078. // AuditLogChangeKeyAvatarHash is sent when user avatar changed (string) - user
  1079. AuditLogChangeKeyAvatarHash AuditLogChangeKey = "avatar_hash"
  1080. // AuditLogChangeKeyBannerHash is sent when guild banner changed (string) - guild
  1081. AuditLogChangeKeyBannerHash AuditLogChangeKey = "banner_hash"
  1082. // AuditLogChangeKeyBitrate is sent when voice channel bitrate changed (int) - channel
  1083. AuditLogChangeKeyBitrate AuditLogChangeKey = "bitrate"
  1084. // AuditLogChangeKeyChannelID is sent when channel for invite code or guild scheduled event changed (snowflake) - invite or guild scheduled event
  1085. AuditLogChangeKeyChannelID AuditLogChangeKey = "channel_id"
  1086. // AuditLogChangeKeyCode is sent when invite code changed (string) - invite
  1087. AuditLogChangeKeyCode AuditLogChangeKey = "code"
  1088. // AuditLogChangeKeyColor is sent when role color changed (int) - role
  1089. AuditLogChangeKeyColor AuditLogChangeKey = "color"
  1090. // AuditLogChangeKeyCommunicationDisabledUntil is sent when member timeout state changed (ISO8601 timestamp) - member
  1091. AuditLogChangeKeyCommunicationDisabledUntil AuditLogChangeKey = "communication_disabled_until"
  1092. // AuditLogChangeKeyDeaf is sent when user server deafened/undeafened (bool) - member
  1093. AuditLogChangeKeyDeaf AuditLogChangeKey = "deaf"
  1094. // AuditLogChangeKeyDefaultAutoArchiveDuration is sent when default auto archive duration for newly created threads changed (int) - channel
  1095. AuditLogChangeKeyDefaultAutoArchiveDuration AuditLogChangeKey = "default_auto_archive_duration"
  1096. // AuditLogChangeKeyDefaultMessageNotification is sent when default message notification level changed (int) - guild
  1097. AuditLogChangeKeyDefaultMessageNotification AuditLogChangeKey = "default_message_notifications"
  1098. // AuditLogChangeKeyDeny is sent when a permission on a text or voice channel was denied for a role (string) - role
  1099. AuditLogChangeKeyDeny AuditLogChangeKey = "deny"
  1100. // AuditLogChangeKeyDescription is sent when description changed (string) - guild, sticker, or guild scheduled event
  1101. AuditLogChangeKeyDescription AuditLogChangeKey = "description"
  1102. // AuditLogChangeKeyDiscoverySplashHash is sent when discovery splash changed (string) - guild
  1103. AuditLogChangeKeyDiscoverySplashHash AuditLogChangeKey = "discovery_splash_hash"
  1104. // AuditLogChangeKeyEnableEmoticons is sent when integration emoticons enabled/disabled (bool) - integration
  1105. AuditLogChangeKeyEnableEmoticons AuditLogChangeKey = "enable_emoticons"
  1106. // AuditLogChangeKeyEntityType is sent when entity type of guild scheduled event was changed (int) - guild scheduled event
  1107. AuditLogChangeKeyEntityType AuditLogChangeKey = "entity_type"
  1108. // AuditLogChangeKeyExpireBehavior is sent when integration expiring subscriber behavior changed (int) - integration
  1109. AuditLogChangeKeyExpireBehavior AuditLogChangeKey = "expire_behavior"
  1110. // AuditLogChangeKeyExpireGracePeriod is sent when integration expire grace period changed (int) - integration
  1111. AuditLogChangeKeyExpireGracePeriod AuditLogChangeKey = "expire_grace_period"
  1112. // AuditLogChangeKeyExplicitContentFilter is sent when change in whose messages are scanned and deleted for explicit content in the server is made (int) - guild
  1113. AuditLogChangeKeyExplicitContentFilter AuditLogChangeKey = "explicit_content_filter"
  1114. // AuditLogChangeKeyFormatType is sent when format type of sticker changed (int - sticker format type) - sticker
  1115. AuditLogChangeKeyFormatType AuditLogChangeKey = "format_type"
  1116. // AuditLogChangeKeyGuildID is sent when guild sticker is in changed (snowflake) - sticker
  1117. AuditLogChangeKeyGuildID AuditLogChangeKey = "guild_id"
  1118. // AuditLogChangeKeyHoist is sent when role is now displayed/no longer displayed separate from online users (bool) - role
  1119. AuditLogChangeKeyHoist AuditLogChangeKey = "hoist"
  1120. // AuditLogChangeKeyIconHash is sent when icon changed (string) - guild or role
  1121. AuditLogChangeKeyIconHash AuditLogChangeKey = "icon_hash"
  1122. // AuditLogChangeKeyID is sent when the id of the changed entity - sometimes used in conjunction with other keys (snowflake) - any
  1123. AuditLogChangeKeyID AuditLogChangeKey = "id"
  1124. // AuditLogChangeKeyInvitable is sent when private thread is now invitable/uninvitable (bool) - thread
  1125. AuditLogChangeKeyInvitable AuditLogChangeKey = "invitable"
  1126. // AuditLogChangeKeyInviterID is sent when person who created invite code changed (snowflake) - invite
  1127. AuditLogChangeKeyInviterID AuditLogChangeKey = "inviter_id"
  1128. // AuditLogChangeKeyLocation is sent when channel id for guild scheduled event changed (string) - guild scheduled event
  1129. AuditLogChangeKeyLocation AuditLogChangeKey = "location"
  1130. // AuditLogChangeKeyLocked is sent when thread was locked/unlocked (bool) - thread
  1131. AuditLogChangeKeyLocked AuditLogChangeKey = "locked"
  1132. // AuditLogChangeKeyMaxAge is sent when invite code expiration time changed (int) - invite
  1133. AuditLogChangeKeyMaxAge AuditLogChangeKey = "max_age"
  1134. // AuditLogChangeKeyMaxUses is sent when max number of times invite code can be used changed (int) - invite
  1135. AuditLogChangeKeyMaxUses AuditLogChangeKey = "max_uses"
  1136. // AuditLogChangeKeyMentionable is sent when role is now mentionable/unmentionable (bool) - role
  1137. AuditLogChangeKeyMentionable AuditLogChangeKey = "mentionable"
  1138. // AuditLogChangeKeyMfaLevel is sent when two-factor auth requirement changed (int - mfa level) - guild
  1139. AuditLogChangeKeyMfaLevel AuditLogChangeKey = "mfa_level"
  1140. // AuditLogChangeKeyMute is sent when user server muted/unmuted (bool) - member
  1141. AuditLogChangeKeyMute AuditLogChangeKey = "mute"
  1142. // AuditLogChangeKeyName is sent when name changed (string) - any
  1143. AuditLogChangeKeyName AuditLogChangeKey = "name"
  1144. // AuditLogChangeKeyNick is sent when user nickname changed (string) - member
  1145. AuditLogChangeKeyNick AuditLogChangeKey = "nick"
  1146. // AuditLogChangeKeyNSFW is sent when channel nsfw restriction changed (bool) - channel
  1147. AuditLogChangeKeyNSFW AuditLogChangeKey = "nsfw"
  1148. // AuditLogChangeKeyOwnerID is sent when owner changed (snowflake) - guild
  1149. AuditLogChangeKeyOwnerID AuditLogChangeKey = "owner_id"
  1150. // AuditLogChangeKeyPermissionOverwrite is sent when permissions on a channel changed (array of channel overwrite objects) - channel
  1151. AuditLogChangeKeyPermissionOverwrite AuditLogChangeKey = "permission_overwrites"
  1152. // AuditLogChangeKeyPermissions is sent when permissions for a role changed (string) - role
  1153. AuditLogChangeKeyPermissions AuditLogChangeKey = "permissions"
  1154. // AuditLogChangeKeyPosition is sent when text or voice channel position changed (int) - channel
  1155. AuditLogChangeKeyPosition AuditLogChangeKey = "position"
  1156. // AuditLogChangeKeyPreferredLocale is sent when preferred locale changed (string) - guild
  1157. AuditLogChangeKeyPreferredLocale AuditLogChangeKey = "preferred_locale"
  1158. // AuditLogChangeKeyPrivacylevel is sent when privacy level of the stage instance changed (integer - privacy level) - stage instance or guild scheduled event
  1159. AuditLogChangeKeyPrivacylevel AuditLogChangeKey = "privacy_level"
  1160. // AuditLogChangeKeyPruneDeleteDays is sent when number of days after which inactive and role-unassigned members are kicked changed (int) - guild
  1161. AuditLogChangeKeyPruneDeleteDays AuditLogChangeKey = "prune_delete_days"
  1162. // AuditLogChangeKeyPulibUpdatesChannelID is sent when id of the public updates channel changed (snowflake) - guild
  1163. AuditLogChangeKeyPulibUpdatesChannelID AuditLogChangeKey = "public_updates_channel_id"
  1164. // AuditLogChangeKeyRateLimitPerUser is sent when amount of seconds a user has to wait before sending another message changed (int) - channel
  1165. AuditLogChangeKeyRateLimitPerUser AuditLogChangeKey = "rate_limit_per_user"
  1166. // AuditLogChangeKeyRegion is sent when region changed (string) - guild
  1167. AuditLogChangeKeyRegion AuditLogChangeKey = "region"
  1168. // AuditLogChangeKeyRulesChannelID is sent when id of the rules channel changed (snowflake) - guild
  1169. AuditLogChangeKeyRulesChannelID AuditLogChangeKey = "rules_channel_id"
  1170. // AuditLogChangeKeySplashHash is sent when invite splash page artwork changed (string) - guild
  1171. AuditLogChangeKeySplashHash AuditLogChangeKey = "splash_hash"
  1172. // AuditLogChangeKeyStatus is sent when status of guild scheduled event was changed (int - guild scheduled event status) - guild scheduled event
  1173. AuditLogChangeKeyStatus AuditLogChangeKey = "status"
  1174. // AuditLogChangeKeySystemChannelID is sent when id of the system channel changed (snowflake) - guild
  1175. AuditLogChangeKeySystemChannelID AuditLogChangeKey = "system_channel_id"
  1176. // AuditLogChangeKeyTags is sent when related emoji of sticker changed (string) - sticker
  1177. AuditLogChangeKeyTags AuditLogChangeKey = "tags"
  1178. // AuditLogChangeKeyTemporary is sent when invite code is now temporary or never expires (bool) - invite
  1179. AuditLogChangeKeyTemporary AuditLogChangeKey = "temporary"
  1180. // TODO: remove when compatibility is not required
  1181. AuditLogChangeKeyTempoary = AuditLogChangeKeyTemporary
  1182. // AuditLogChangeKeyTopic is sent when text channel topic or stage instance topic changed (string) - channel or stage instance
  1183. AuditLogChangeKeyTopic AuditLogChangeKey = "topic"
  1184. // AuditLogChangeKeyType is sent when type of entity created (int or string) - any
  1185. AuditLogChangeKeyType AuditLogChangeKey = "type"
  1186. // AuditLogChangeKeyUnicodeEmoji is sent when role unicode emoji changed (string) - role
  1187. AuditLogChangeKeyUnicodeEmoji AuditLogChangeKey = "unicode_emoji"
  1188. // AuditLogChangeKeyUserLimit is sent when new user limit in a voice channel set (int) - voice channel
  1189. AuditLogChangeKeyUserLimit AuditLogChangeKey = "user_limit"
  1190. // AuditLogChangeKeyUses is sent when number of times invite code used changed (int) - invite
  1191. AuditLogChangeKeyUses AuditLogChangeKey = "uses"
  1192. // AuditLogChangeKeyVanityURLCode is sent when guild invite vanity url changed (string) - guild
  1193. AuditLogChangeKeyVanityURLCode AuditLogChangeKey = "vanity_url_code"
  1194. // AuditLogChangeKeyVerificationLevel is sent when required verification level changed (int - verification level) - guild
  1195. AuditLogChangeKeyVerificationLevel AuditLogChangeKey = "verification_level"
  1196. // AuditLogChangeKeyWidgetChannelID is sent when channel id of the server widget changed (snowflake) - guild
  1197. AuditLogChangeKeyWidgetChannelID AuditLogChangeKey = "widget_channel_id"
  1198. // AuditLogChangeKeyWidgetEnabled is sent when server widget enabled/disabled (bool) - guild
  1199. AuditLogChangeKeyWidgetEnabled AuditLogChangeKey = "widget_enabled"
  1200. // AuditLogChangeKeyRoleAdd is sent when new role added (array of partial role objects) - guild
  1201. AuditLogChangeKeyRoleAdd AuditLogChangeKey = "$add"
  1202. // AuditLogChangeKeyRoleRemove is sent when role removed (array of partial role objects) - guild
  1203. AuditLogChangeKeyRoleRemove AuditLogChangeKey = "$remove"
  1204. )
  1205. // AuditLogOptions optional data for the AuditLog
  1206. // https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info
  1207. type AuditLogOptions struct {
  1208. DeleteMemberDays string `json:"delete_member_days"`
  1209. MembersRemoved string `json:"members_removed"`
  1210. ChannelID string `json:"channel_id"`
  1211. MessageID string `json:"message_id"`
  1212. Count string `json:"count"`
  1213. ID string `json:"id"`
  1214. Type *AuditLogOptionsType `json:"type"`
  1215. RoleName string `json:"role_name"`
  1216. }
  1217. // AuditLogOptionsType of the AuditLogOption
  1218. // https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info
  1219. type AuditLogOptionsType string
  1220. // Valid Types for AuditLogOptionsType
  1221. const (
  1222. AuditLogOptionsTypeMember AuditLogOptionsType = "member"
  1223. AuditLogOptionsTypeRole AuditLogOptionsType = "role"
  1224. )
  1225. // AuditLogAction is the Action of the AuditLog (see AuditLogAction* consts)
  1226. // https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-audit-log-events
  1227. type AuditLogAction int
  1228. // Block contains Discord Audit Log Action Types
  1229. const (
  1230. AuditLogActionGuildUpdate AuditLogAction = 1
  1231. AuditLogActionChannelCreate AuditLogAction = 10
  1232. AuditLogActionChannelUpdate AuditLogAction = 11
  1233. AuditLogActionChannelDelete AuditLogAction = 12
  1234. AuditLogActionChannelOverwriteCreate AuditLogAction = 13
  1235. AuditLogActionChannelOverwriteUpdate AuditLogAction = 14
  1236. AuditLogActionChannelOverwriteDelete AuditLogAction = 15
  1237. AuditLogActionMemberKick AuditLogAction = 20
  1238. AuditLogActionMemberPrune AuditLogAction = 21
  1239. AuditLogActionMemberBanAdd AuditLogAction = 22
  1240. AuditLogActionMemberBanRemove AuditLogAction = 23
  1241. AuditLogActionMemberUpdate AuditLogAction = 24
  1242. AuditLogActionMemberRoleUpdate AuditLogAction = 25
  1243. AuditLogActionMemberMove AuditLogAction = 26
  1244. AuditLogActionMemberDisconnect AuditLogAction = 27
  1245. AuditLogActionBotAdd AuditLogAction = 28
  1246. AuditLogActionRoleCreate AuditLogAction = 30
  1247. AuditLogActionRoleUpdate AuditLogAction = 31
  1248. AuditLogActionRoleDelete AuditLogAction = 32
  1249. AuditLogActionInviteCreate AuditLogAction = 40
  1250. AuditLogActionInviteUpdate AuditLogAction = 41
  1251. AuditLogActionInviteDelete AuditLogAction = 42
  1252. AuditLogActionWebhookCreate AuditLogAction = 50
  1253. AuditLogActionWebhookUpdate AuditLogAction = 51
  1254. AuditLogActionWebhookDelete AuditLogAction = 52
  1255. AuditLogActionEmojiCreate AuditLogAction = 60
  1256. AuditLogActionEmojiUpdate AuditLogAction = 61
  1257. AuditLogActionEmojiDelete AuditLogAction = 62
  1258. AuditLogActionMessageDelete AuditLogAction = 72
  1259. AuditLogActionMessageBulkDelete AuditLogAction = 73
  1260. AuditLogActionMessagePin AuditLogAction = 74
  1261. AuditLogActionMessageUnpin AuditLogAction = 75
  1262. AuditLogActionIntegrationCreate AuditLogAction = 80
  1263. AuditLogActionIntegrationUpdate AuditLogAction = 81
  1264. AuditLogActionIntegrationDelete AuditLogAction = 82
  1265. AuditLogActionStageInstanceCreate AuditLogAction = 83
  1266. AuditLogActionStageInstanceUpdate AuditLogAction = 84
  1267. AuditLogActionStageInstanceDelete AuditLogAction = 85
  1268. AuditLogActionStickerCreate AuditLogAction = 90
  1269. AuditLogActionStickerUpdate AuditLogAction = 91
  1270. AuditLogActionStickerDelete AuditLogAction = 92
  1271. AuditLogGuildScheduledEventCreate AuditLogAction = 100
  1272. AuditLogGuildScheduledEventUpdare AuditLogAction = 101
  1273. AuditLogGuildScheduledEventDelete AuditLogAction = 102
  1274. AuditLogActionThreadCreate AuditLogAction = 110
  1275. AuditLogActionThreadUpdate AuditLogAction = 111
  1276. AuditLogActionThreadDelete AuditLogAction = 112
  1277. )
  1278. // A UserGuildSettingsChannelOverride stores data for a channel override for a users guild settings.
  1279. type UserGuildSettingsChannelOverride struct {
  1280. Muted bool `json:"muted"`
  1281. MessageNotifications int `json:"message_notifications"`
  1282. ChannelID string `json:"channel_id"`
  1283. }
  1284. // A UserGuildSettings stores data for a users guild settings.
  1285. type UserGuildSettings struct {
  1286. SupressEveryone bool `json:"suppress_everyone"`
  1287. Muted bool `json:"muted"`
  1288. MobilePush bool `json:"mobile_push"`
  1289. MessageNotifications int `json:"message_notifications"`
  1290. GuildID string `json:"guild_id"`
  1291. ChannelOverrides []*UserGuildSettingsChannelOverride `json:"channel_overrides"`
  1292. }
  1293. // A UserGuildSettingsEdit stores data for editing UserGuildSettings
  1294. type UserGuildSettingsEdit struct {
  1295. SupressEveryone bool `json:"suppress_everyone"`
  1296. Muted bool `json:"muted"`
  1297. MobilePush bool `json:"mobile_push"`
  1298. MessageNotifications int `json:"message_notifications"`
  1299. ChannelOverrides map[string]*UserGuildSettingsChannelOverride `json:"channel_overrides"`
  1300. }
  1301. // An APIErrorMessage is an api error message returned from discord
  1302. type APIErrorMessage struct {
  1303. Code int `json:"code"`
  1304. Message string `json:"message"`
  1305. }
  1306. // MessageReaction stores the data for a message reaction.
  1307. type MessageReaction struct {
  1308. UserID string `json:"user_id"`
  1309. MessageID string `json:"message_id"`
  1310. Emoji Emoji `json:"emoji"`
  1311. ChannelID string `json:"channel_id"`
  1312. GuildID string `json:"guild_id,omitempty"`
  1313. }
  1314. // GatewayBotResponse stores the data for the gateway/bot response
  1315. type GatewayBotResponse struct {
  1316. URL string `json:"url"`
  1317. Shards int `json:"shards"`
  1318. SessionStartLimit SessionInformation `json:"session_start_limit"`
  1319. }
  1320. // SessionInformation provides the information for max concurrency sharding
  1321. type SessionInformation struct {
  1322. Total int `json:"total,omitempty"`
  1323. Remaining int `json:"remaining,omitempty"`
  1324. ResetAfter int `json:"reset_after,omitempty"`
  1325. MaxConcurrency int `json:"max_concurrency,omitempty"`
  1326. }
  1327. // GatewayStatusUpdate is sent by the client to indicate a presence or status update
  1328. // https://discord.com/developers/docs/topics/gateway#update-status-gateway-status-update-structure
  1329. type GatewayStatusUpdate struct {
  1330. Since int `json:"since"`
  1331. Game Activity `json:"game"`
  1332. Status string `json:"status"`
  1333. AFK bool `json:"afk"`
  1334. }
  1335. // Activity defines the Activity sent with GatewayStatusUpdate
  1336. // https://discord.com/developers/docs/topics/gateway#activity-object
  1337. type Activity struct {
  1338. Name string `json:"name"`
  1339. Type ActivityType `json:"type"`
  1340. URL string `json:"url,omitempty"`
  1341. CreatedAt time.Time `json:"created_at"`
  1342. ApplicationID string `json:"application_id,omitempty"`
  1343. State string `json:"state,omitempty"`
  1344. Details string `json:"details,omitempty"`
  1345. Timestamps TimeStamps `json:"timestamps,omitempty"`
  1346. Emoji Emoji `json:"emoji,omitempty"`
  1347. Party Party `json:"party,omitempty"`
  1348. Assets Assets `json:"assets,omitempty"`
  1349. Secrets Secrets `json:"secrets,omitempty"`
  1350. Instance bool `json:"instance,omitempty"`
  1351. Flags int `json:"flags,omitempty"`
  1352. }
  1353. // UnmarshalJSON is a custom unmarshaljson to make CreatedAt a time.Time instead of an int
  1354. func (activity *Activity) UnmarshalJSON(b []byte) error {
  1355. temp := struct {
  1356. Name string `json:"name"`
  1357. Type ActivityType `json:"type"`
  1358. URL string `json:"url,omitempty"`
  1359. CreatedAt int64 `json:"created_at"`
  1360. ApplicationID string `json:"application_id,omitempty"`
  1361. State string `json:"state,omitempty"`
  1362. Details string `json:"details,omitempty"`
  1363. Timestamps TimeStamps `json:"timestamps,omitempty"`
  1364. Emoji Emoji `json:"emoji,omitempty"`
  1365. Party Party `json:"party,omitempty"`
  1366. Assets Assets `json:"assets,omitempty"`
  1367. Secrets Secrets `json:"secrets,omitempty"`
  1368. Instance bool `json:"instance,omitempty"`
  1369. Flags int `json:"flags,omitempty"`
  1370. }{}
  1371. err := json.Unmarshal(b, &temp)
  1372. if err != nil {
  1373. return err
  1374. }
  1375. activity.CreatedAt = time.Unix(0, temp.CreatedAt*1000000)
  1376. activity.ApplicationID = temp.ApplicationID
  1377. activity.Assets = temp.Assets
  1378. activity.Details = temp.Details
  1379. activity.Emoji = temp.Emoji
  1380. activity.Flags = temp.Flags
  1381. activity.Instance = temp.Instance
  1382. activity.Name = temp.Name
  1383. activity.Party = temp.Party
  1384. activity.Secrets = temp.Secrets
  1385. activity.State = temp.State
  1386. activity.Timestamps = temp.Timestamps
  1387. activity.Type = temp.Type
  1388. activity.URL = temp.URL
  1389. return nil
  1390. }
  1391. // Party defines the Party field in the Activity struct
  1392. // https://discord.com/developers/docs/topics/gateway#activity-object
  1393. type Party struct {
  1394. ID string `json:"id,omitempty"`
  1395. Size []int `json:"size,omitempty"`
  1396. }
  1397. // Secrets defines the Secrets field for the Activity struct
  1398. // https://discord.com/developers/docs/topics/gateway#activity-object
  1399. type Secrets struct {
  1400. Join string `json:"join,omitempty"`
  1401. Spectate string `json:"spectate,omitempty"`
  1402. Match string `json:"match,omitempty"`
  1403. }
  1404. // ActivityType is the type of Activity (see ActivityType* consts) in the Activity struct
  1405. // https://discord.com/developers/docs/topics/gateway#activity-object-activity-types
  1406. type ActivityType int
  1407. // Valid ActivityType values
  1408. const (
  1409. ActivityTypeGame ActivityType = 0
  1410. ActivityTypeStreaming ActivityType = 1
  1411. ActivityTypeListening ActivityType = 2
  1412. ActivityTypeWatching ActivityType = 3
  1413. ActivityTypeCustom ActivityType = 4
  1414. ActivityTypeCompeting ActivityType = 5
  1415. )
  1416. // Identify is sent during initial handshake with the discord gateway.
  1417. // https://discord.com/developers/docs/topics/gateway#identify
  1418. type Identify struct {
  1419. Token string `json:"token"`
  1420. Properties IdentifyProperties `json:"properties"`
  1421. Compress bool `json:"compress"`
  1422. LargeThreshold int `json:"large_threshold"`
  1423. Shard *[2]int `json:"shard,omitempty"`
  1424. Presence GatewayStatusUpdate `json:"presence,omitempty"`
  1425. GuildSubscriptions bool `json:"guild_subscriptions"`
  1426. Intents Intent `json:"intents"`
  1427. }
  1428. // IdentifyProperties contains the "properties" portion of an Identify packet
  1429. // https://discord.com/developers/docs/topics/gateway#identify-identify-connection-properties
  1430. type IdentifyProperties struct {
  1431. OS string `json:"$os"`
  1432. Browser string `json:"$browser"`
  1433. Device string `json:"$device"`
  1434. Referer string `json:"$referer"`
  1435. ReferringDomain string `json:"$referring_domain"`
  1436. }
  1437. // Constants for the different bit offsets of text channel permissions
  1438. const (
  1439. // Deprecated: PermissionReadMessages has been replaced with PermissionViewChannel for text and voice channels
  1440. PermissionReadMessages = 0x0000000000000400
  1441. PermissionSendMessages = 0x0000000000000800
  1442. PermissionSendTTSMessages = 0x0000000000001000
  1443. PermissionManageMessages = 0x0000000000002000
  1444. PermissionEmbedLinks = 0x0000000000004000
  1445. PermissionAttachFiles = 0x0000000000008000
  1446. PermissionReadMessageHistory = 0x0000000000010000
  1447. PermissionMentionEveryone = 0x0000000000020000
  1448. PermissionUseExternalEmojis = 0x0000000000040000
  1449. PermissionUseSlashCommands = 0x0000000080000000
  1450. PermissionManageThreads = 0x0000000400000000
  1451. PermissionCreatePublicThreads = 0x0000000800000000
  1452. PermissionCreatePrivateThreads = 0x0000001000000000
  1453. PermissionSendMessagesInThreads = 0x0000004000000000
  1454. )
  1455. // Constants for the different bit offsets of voice permissions
  1456. const (
  1457. PermissionVoicePrioritySpeaker = 0x0000000000000100
  1458. PermissionVoiceStreamVideo = 0x0000000000000200
  1459. PermissionVoiceConnect = 0x0000000000100000
  1460. PermissionVoiceSpeak = 0x0000000000200000
  1461. PermissionVoiceMuteMembers = 0x0000000000400000
  1462. PermissionVoiceDeafenMembers = 0x0000000000800000
  1463. PermissionVoiceMoveMembers = 0x0000000001000000
  1464. PermissionVoiceUseVAD = 0x0000000002000000
  1465. PermissionVoiceRequestToSpeak = 0x0000000100000000
  1466. )
  1467. // Constants for general management.
  1468. const (
  1469. PermissionChangeNickname = 0x0000000004000000
  1470. PermissionManageNicknames = 0x0000000008000000
  1471. PermissionManageRoles = 0x0000000010000000
  1472. PermissionManageWebhooks = 0x0000000020000000
  1473. PermissionManageEmojis = 0x0000000040000000
  1474. )
  1475. // Constants for the different bit offsets of general permissions
  1476. const (
  1477. PermissionCreateInstantInvite = 0x0000000000000001
  1478. PermissionKickMembers = 0x0000000000000002
  1479. PermissionBanMembers = 0x0000000000000004
  1480. PermissionAdministrator = 0x0000000000000008
  1481. PermissionManageChannels = 0x0000000000000010
  1482. PermissionManageServer = 0x0000000000000020
  1483. PermissionAddReactions = 0x0000000000000040
  1484. PermissionViewAuditLogs = 0x0000000000000080
  1485. PermissionViewChannel = 0x0000000000000400
  1486. PermissionViewGuildInsights = 0x0000000000080000
  1487. PermissionModerateMembers = 0x0000010000000000
  1488. PermissionAllText = PermissionViewChannel |
  1489. PermissionSendMessages |
  1490. PermissionSendTTSMessages |
  1491. PermissionManageMessages |
  1492. PermissionEmbedLinks |
  1493. PermissionAttachFiles |
  1494. PermissionReadMessageHistory |
  1495. PermissionMentionEveryone
  1496. PermissionAllVoice = PermissionViewChannel |
  1497. PermissionVoiceConnect |
  1498. PermissionVoiceSpeak |
  1499. PermissionVoiceMuteMembers |
  1500. PermissionVoiceDeafenMembers |
  1501. PermissionVoiceMoveMembers |
  1502. PermissionVoiceUseVAD |
  1503. PermissionVoicePrioritySpeaker
  1504. PermissionAllChannel = PermissionAllText |
  1505. PermissionAllVoice |
  1506. PermissionCreateInstantInvite |
  1507. PermissionManageRoles |
  1508. PermissionManageChannels |
  1509. PermissionAddReactions |
  1510. PermissionViewAuditLogs
  1511. PermissionAll = PermissionAllChannel |
  1512. PermissionKickMembers |
  1513. PermissionBanMembers |
  1514. PermissionManageServer |
  1515. PermissionAdministrator |
  1516. PermissionManageWebhooks |
  1517. PermissionManageEmojis
  1518. )
  1519. // Block contains Discord JSON Error Response codes
  1520. const (
  1521. ErrCodeGeneralError = 0
  1522. ErrCodeUnknownAccount = 10001
  1523. ErrCodeUnknownApplication = 10002
  1524. ErrCodeUnknownChannel = 10003
  1525. ErrCodeUnknownGuild = 10004
  1526. ErrCodeUnknownIntegration = 10005
  1527. ErrCodeUnknownInvite = 10006
  1528. ErrCodeUnknownMember = 10007
  1529. ErrCodeUnknownMessage = 10008
  1530. ErrCodeUnknownOverwrite = 10009
  1531. ErrCodeUnknownProvider = 10010
  1532. ErrCodeUnknownRole = 10011
  1533. ErrCodeUnknownToken = 10012
  1534. ErrCodeUnknownUser = 10013
  1535. ErrCodeUnknownEmoji = 10014
  1536. ErrCodeUnknownWebhook = 10015
  1537. ErrCodeUnknownWebhookService = 10016
  1538. ErrCodeUnknownSession = 10020
  1539. ErrCodeUnknownBan = 10026
  1540. ErrCodeUnknownSKU = 10027
  1541. ErrCodeUnknownStoreListing = 10028
  1542. ErrCodeUnknownEntitlement = 10029
  1543. ErrCodeUnknownBuild = 10030
  1544. ErrCodeUnknownLobby = 10031
  1545. ErrCodeUnknownBranch = 10032
  1546. ErrCodeUnknownStoreDirectoryLayout = 10033
  1547. ErrCodeUnknownRedistributable = 10036
  1548. ErrCodeUnknownGiftCode = 10038
  1549. ErrCodeUnknownStream = 10049
  1550. ErrCodeUnknownPremiumServerSubscribeCooldown = 10050
  1551. ErrCodeUnknownGuildTemplate = 10057
  1552. ErrCodeUnknownDiscoveryCategory = 10059
  1553. ErrCodeUnknownSticker = 10060
  1554. ErrCodeUnknownInteraction = 10062
  1555. ErrCodeUnknownApplicationCommand = 10063
  1556. ErrCodeUnknownApplicationCommandPermissions = 10066
  1557. ErrCodeUnknownStageInstance = 10067
  1558. ErrCodeUnknownGuildMemberVerificationForm = 10068
  1559. ErrCodeUnknownGuildWelcomeScreen = 10069
  1560. ErrCodeUnknownGuildScheduledEvent = 10070
  1561. ErrCodeUnknownGuildScheduledEventUser = 10071
  1562. ErrCodeBotsCannotUseEndpoint = 20001
  1563. ErrCodeOnlyBotsCanUseEndpoint = 20002
  1564. ErrCodeExplicitContentCannotBeSentToTheDesiredRecipients = 20009
  1565. ErrCodeYouAreNotAuthorizedToPerformThisActionOnThisApplication = 20012
  1566. ErrCodeThisActionCannotBePerformedDueToSlowmodeRateLimit = 20016
  1567. ErrCodeOnlyTheOwnerOfThisAccountCanPerformThisAction = 20018
  1568. ErrCodeMessageCannotBeEditedDueToAnnouncementRateLimits = 20022
  1569. ErrCodeChannelHasHitWriteRateLimit = 20028
  1570. ErrCodeTheWriteActionYouArePerformingOnTheServerHasHitTheWriteRateLimit = 20029
  1571. ErrCodeStageTopicContainsNotAllowedWordsForPublicStages = 20031
  1572. ErrCodeGuildPremiumSubscriptionLevelTooLow = 20035
  1573. ErrCodeMaximumGuildsReached = 30001
  1574. ErrCodeMaximumPinsReached = 30003
  1575. ErrCodeMaximumNumberOfRecipientsReached = 30004
  1576. ErrCodeMaximumGuildRolesReached = 30005
  1577. ErrCodeMaximumNumberOfWebhooksReached = 30007
  1578. ErrCodeMaximumNumberOfEmojisReached = 30008
  1579. ErrCodeTooManyReactions = 30010
  1580. ErrCodeMaximumNumberOfGuildChannelsReached = 30013
  1581. ErrCodeMaximumNumberOfAttachmentsInAMessageReached = 30015
  1582. ErrCodeMaximumNumberOfInvitesReached = 30016
  1583. ErrCodeMaximumNumberOfAnimatedEmojisReached = 30018
  1584. ErrCodeMaximumNumberOfServerMembersReached = 30019
  1585. ErrCodeMaximumNumberOfGuildDiscoverySubcategoriesReached = 30030
  1586. ErrCodeGuildAlreadyHasATemplate = 30031
  1587. ErrCodeMaximumNumberOfThreadParticipantsReached = 30033
  1588. ErrCodeMaximumNumberOfBansForNonGuildMembersHaveBeenExceeded = 30035
  1589. ErrCodeMaximumNumberOfBansFetchesHasBeenReached = 30037
  1590. ErrCodeMaximumNumberOfUncompletedGuildScheduledEventsReached = 30038
  1591. ErrCodeMaximumNumberOfStickersReached = 30039
  1592. ErrCodeMaximumNumberOfPruneRequestsHasBeenReached = 30040
  1593. ErrCodeMaximumNumberOfGuildWidgetSettingsUpdatesHasBeenReached = 30042
  1594. ErrCodeMaximumNumberOfEditsToMessagesOlderThanOneHourReached = 30046
  1595. ErrCodeUnauthorized = 40001
  1596. ErrCodeActionRequiredVerifiedAccount = 40002
  1597. ErrCodeOpeningDirectMessagesTooFast = 40003
  1598. ErrCodeSendMessagesHasBeenTemporarilyDisabled = 40004
  1599. ErrCodeRequestEntityTooLarge = 40005
  1600. ErrCodeFeatureTemporarilyDisabledServerSide = 40006
  1601. ErrCodeUserIsBannedFromThisGuild = 40007
  1602. ErrCodeTargetIsNotConnectedToVoice = 40032
  1603. ErrCodeMessageAlreadyCrossposted = 40033
  1604. ErrCodeAnApplicationWithThatNameAlreadyExists = 40041
  1605. ErrCodeInteractionHasAlreadyBeenAcknowledged = 40060
  1606. ErrCodeMissingAccess = 50001
  1607. ErrCodeInvalidAccountType = 50002
  1608. ErrCodeCannotExecuteActionOnDMChannel = 50003
  1609. ErrCodeEmbedDisabled = 50004
  1610. ErrCodeGuildWidgetDisabled = 50004
  1611. ErrCodeCannotEditFromAnotherUser = 50005
  1612. ErrCodeCannotSendEmptyMessage = 50006
  1613. ErrCodeCannotSendMessagesToThisUser = 50007
  1614. ErrCodeCannotSendMessagesInVoiceChannel = 50008
  1615. ErrCodeChannelVerificationLevelTooHigh = 50009
  1616. ErrCodeOAuth2ApplicationDoesNotHaveBot = 50010
  1617. ErrCodeOAuth2ApplicationLimitReached = 50011
  1618. ErrCodeInvalidOAuthState = 50012
  1619. ErrCodeMissingPermissions = 50013
  1620. ErrCodeInvalidAuthenticationToken = 50014
  1621. ErrCodeTooFewOrTooManyMessagesToDelete = 50016
  1622. ErrCodeCanOnlyPinMessageToOriginatingChannel = 50019
  1623. ErrCodeInviteCodeWasEitherInvalidOrTaken = 50020
  1624. ErrCodeCannotExecuteActionOnSystemMessage = 50021
  1625. ErrCodeCannotExecuteActionOnThisChannelType = 50024
  1626. ErrCodeInvalidOAuth2AccessTokenProvided = 50025
  1627. ErrCodeMissingRequiredOAuth2Scope = 50026
  1628. ErrCodeInvalidWebhookTokenProvided = 50027
  1629. ErrCodeInvalidRole = 50028
  1630. ErrCodeInvalidRecipients = 50033
  1631. ErrCodeMessageProvidedTooOldForBulkDelete = 50034
  1632. ErrCodeInvalidFormBody = 50035
  1633. ErrCodeInviteAcceptedToGuildApplicationsBotNotIn = 50036
  1634. ErrCodeInvalidAPIVersionProvided = 50041
  1635. ErrCodeFileUploadedExceedsTheMaximumSize = 50045
  1636. ErrCodeInvalidFileUploaded = 50046
  1637. ErrCodeInvalidGuild = 50055
  1638. ErrCodeInvalidMessageType = 50068
  1639. ErrCodeCannotDeleteAChannelRequiredForCommunityGuilds = 50074
  1640. ErrCodeInvalidStickerSent = 50081
  1641. ErrCodePerformedOperationOnArchivedThread = 50083
  1642. ErrCodeBeforeValueIsEarlierThanThreadCreationDate = 50085
  1643. ErrCodeCommunityServerChannelsMustBeTextChannels = 50086
  1644. ErrCodeThisServerIsNotAvailableInYourLocation = 50095
  1645. ErrCodeThisServerNeedsMonetizationEnabledInOrderToPerformThisAction = 50097
  1646. ErrCodeThisServerNeedsMoreBoostsToPerformThisAction = 50101
  1647. ErrCodeTheRequestBodyContainsInvalidJSON = 50109
  1648. ErrCodeNoUsersWithDiscordTagExist = 80004
  1649. ErrCodeReactionBlocked = 90001
  1650. ErrCodeAPIResourceIsCurrentlyOverloaded = 130000
  1651. ErrCodeTheStageIsAlreadyOpen = 150006
  1652. ErrCodeCannotReplyWithoutPermissionToReadMessageHistory = 160002
  1653. ErrCodeThreadAlreadyCreatedForThisMessage = 160004
  1654. ErrCodeThreadIsLocked = 160005
  1655. ErrCodeMaximumNumberOfActiveThreadsReached = 160006
  1656. ErrCodeMaximumNumberOfActiveAnnouncementThreadsReached = 160007
  1657. ErrCodeInvalidJSONForUploadedLottieFile = 170001
  1658. ErrCodeUploadedLottiesCannotContainRasterizedImages = 170002
  1659. ErrCodeStickerMaximumFramerateExceeded = 170003
  1660. ErrCodeStickerFrameCountExceedsMaximumOfOneThousandFrames = 170004
  1661. ErrCodeLottieAnimationMaximumDimensionsExceeded = 170005
  1662. ErrCodeStickerFrameRateOutOfRange = 170006
  1663. ErrCodeStickerAnimationDurationExceedsMaximumOfFiveSeconds = 170007
  1664. ErrCodeCannotUpdateAFinishedEvent = 180000
  1665. ErrCodeFailedToCreateStageNeededForStageEvent = 180002
  1666. )
  1667. // Intent is the type of a Gateway Intent
  1668. // https://discord.com/developers/docs/topics/gateway#gateway-intents
  1669. type Intent int
  1670. // Constants for the different bit offsets of intents
  1671. const (
  1672. IntentGuilds Intent = 1 << 0
  1673. IntentGuildMembers Intent = 1 << 1
  1674. IntentGuildBans Intent = 1 << 2
  1675. IntentGuildEmojis Intent = 1 << 3
  1676. IntentGuildIntegrations Intent = 1 << 4
  1677. IntentGuildWebhooks Intent = 1 << 5
  1678. IntentGuildInvites Intent = 1 << 6
  1679. IntentGuildVoiceStates Intent = 1 << 7
  1680. IntentGuildPresences Intent = 1 << 8
  1681. IntentGuildMessages Intent = 1 << 9
  1682. IntentGuildMessageReactions Intent = 1 << 10
  1683. IntentGuildMessageTyping Intent = 1 << 11
  1684. IntentDirectMessages Intent = 1 << 12
  1685. IntentDirectMessageReactions Intent = 1 << 13
  1686. IntentDirectMessageTyping Intent = 1 << 14
  1687. IntentMessageContent Intent = 1 << 15
  1688. IntentGuildScheduledEvents Intent = 1 << 16
  1689. // TODO: remove when compatibility is not needed
  1690. IntentsGuilds Intent = 1 << 0
  1691. IntentsGuildMembers Intent = 1 << 1
  1692. IntentsGuildBans Intent = 1 << 2
  1693. IntentsGuildEmojis Intent = 1 << 3
  1694. IntentsGuildIntegrations Intent = 1 << 4
  1695. IntentsGuildWebhooks Intent = 1 << 5
  1696. IntentsGuildInvites Intent = 1 << 6
  1697. IntentsGuildVoiceStates Intent = 1 << 7
  1698. IntentsGuildPresences Intent = 1 << 8
  1699. IntentsGuildMessages Intent = 1 << 9
  1700. IntentsGuildMessageReactions Intent = 1 << 10
  1701. IntentsGuildMessageTyping Intent = 1 << 11
  1702. IntentsDirectMessages Intent = 1 << 12
  1703. IntentsDirectMessageReactions Intent = 1 << 13
  1704. IntentsDirectMessageTyping Intent = 1 << 14
  1705. IntentsMessageContent Intent = 1 << 15
  1706. IntentsGuildScheduledEvents Intent = 1 << 16
  1707. IntentsAllWithoutPrivileged = IntentGuilds |
  1708. IntentGuildBans |
  1709. IntentGuildEmojis |
  1710. IntentGuildIntegrations |
  1711. IntentGuildWebhooks |
  1712. IntentGuildInvites |
  1713. IntentGuildVoiceStates |
  1714. IntentGuildMessages |
  1715. IntentGuildMessageReactions |
  1716. IntentGuildMessageTyping |
  1717. IntentDirectMessages |
  1718. IntentDirectMessageReactions |
  1719. IntentDirectMessageTyping |
  1720. IntentGuildScheduledEvents
  1721. IntentsAll = IntentsAllWithoutPrivileged |
  1722. IntentGuildMembers |
  1723. IntentGuildPresences |
  1724. IntentMessageContent
  1725. IntentsNone Intent = 0
  1726. )
  1727. // MakeIntent used to help convert a gateway intent value for use in the Identify structure;
  1728. // this was useful to help support the use of a pointer type when intents were optional.
  1729. // This is now a no-op, and is not necessary to use.
  1730. func MakeIntent(intents Intent) Intent {
  1731. return intents
  1732. }