structs.go 83 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040
  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. Intents Intent `json:"intents"`
  1426. }
  1427. // IdentifyProperties contains the "properties" portion of an Identify packet
  1428. // https://discord.com/developers/docs/topics/gateway#identify-identify-connection-properties
  1429. type IdentifyProperties struct {
  1430. OS string `json:"$os"`
  1431. Browser string `json:"$browser"`
  1432. Device string `json:"$device"`
  1433. Referer string `json:"$referer"`
  1434. ReferringDomain string `json:"$referring_domain"`
  1435. }
  1436. // Constants for the different bit offsets of text channel permissions
  1437. const (
  1438. // Deprecated: PermissionReadMessages has been replaced with PermissionViewChannel for text and voice channels
  1439. PermissionReadMessages = 0x0000000000000400
  1440. PermissionSendMessages = 0x0000000000000800
  1441. PermissionSendTTSMessages = 0x0000000000001000
  1442. PermissionManageMessages = 0x0000000000002000
  1443. PermissionEmbedLinks = 0x0000000000004000
  1444. PermissionAttachFiles = 0x0000000000008000
  1445. PermissionReadMessageHistory = 0x0000000000010000
  1446. PermissionMentionEveryone = 0x0000000000020000
  1447. PermissionUseExternalEmojis = 0x0000000000040000
  1448. PermissionUseSlashCommands = 0x0000000080000000
  1449. PermissionManageThreads = 0x0000000400000000
  1450. PermissionCreatePublicThreads = 0x0000000800000000
  1451. PermissionCreatePrivateThreads = 0x0000001000000000
  1452. PermissionUseExternalStickers = 0x0000002000000000
  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. PermissionUseActivities = 0x0000008000000000
  1467. )
  1468. // Constants for general management.
  1469. const (
  1470. PermissionChangeNickname = 0x0000000004000000
  1471. PermissionManageNicknames = 0x0000000008000000
  1472. PermissionManageRoles = 0x0000000010000000
  1473. PermissionManageWebhooks = 0x0000000020000000
  1474. PermissionManageEmojis = 0x0000000040000000
  1475. PermissionManageEvents = 0x0000000200000000
  1476. )
  1477. // Constants for the different bit offsets of general permissions
  1478. const (
  1479. PermissionCreateInstantInvite = 0x0000000000000001
  1480. PermissionKickMembers = 0x0000000000000002
  1481. PermissionBanMembers = 0x0000000000000004
  1482. PermissionAdministrator = 0x0000000000000008
  1483. PermissionManageChannels = 0x0000000000000010
  1484. PermissionManageServer = 0x0000000000000020
  1485. PermissionAddReactions = 0x0000000000000040
  1486. PermissionViewAuditLogs = 0x0000000000000080
  1487. PermissionViewChannel = 0x0000000000000400
  1488. PermissionViewGuildInsights = 0x0000000000080000
  1489. PermissionModerateMembers = 0x0000010000000000
  1490. PermissionAllText = PermissionViewChannel |
  1491. PermissionSendMessages |
  1492. PermissionSendTTSMessages |
  1493. PermissionManageMessages |
  1494. PermissionEmbedLinks |
  1495. PermissionAttachFiles |
  1496. PermissionReadMessageHistory |
  1497. PermissionMentionEveryone
  1498. PermissionAllVoice = PermissionViewChannel |
  1499. PermissionVoiceConnect |
  1500. PermissionVoiceSpeak |
  1501. PermissionVoiceMuteMembers |
  1502. PermissionVoiceDeafenMembers |
  1503. PermissionVoiceMoveMembers |
  1504. PermissionVoiceUseVAD |
  1505. PermissionVoicePrioritySpeaker
  1506. PermissionAllChannel = PermissionAllText |
  1507. PermissionAllVoice |
  1508. PermissionCreateInstantInvite |
  1509. PermissionManageRoles |
  1510. PermissionManageChannels |
  1511. PermissionAddReactions |
  1512. PermissionViewAuditLogs
  1513. PermissionAll = PermissionAllChannel |
  1514. PermissionKickMembers |
  1515. PermissionBanMembers |
  1516. PermissionManageServer |
  1517. PermissionAdministrator |
  1518. PermissionManageWebhooks |
  1519. PermissionManageEmojis
  1520. )
  1521. // Block contains Discord JSON Error Response codes
  1522. const (
  1523. ErrCodeGeneralError = 0
  1524. ErrCodeUnknownAccount = 10001
  1525. ErrCodeUnknownApplication = 10002
  1526. ErrCodeUnknownChannel = 10003
  1527. ErrCodeUnknownGuild = 10004
  1528. ErrCodeUnknownIntegration = 10005
  1529. ErrCodeUnknownInvite = 10006
  1530. ErrCodeUnknownMember = 10007
  1531. ErrCodeUnknownMessage = 10008
  1532. ErrCodeUnknownOverwrite = 10009
  1533. ErrCodeUnknownProvider = 10010
  1534. ErrCodeUnknownRole = 10011
  1535. ErrCodeUnknownToken = 10012
  1536. ErrCodeUnknownUser = 10013
  1537. ErrCodeUnknownEmoji = 10014
  1538. ErrCodeUnknownWebhook = 10015
  1539. ErrCodeUnknownWebhookService = 10016
  1540. ErrCodeUnknownSession = 10020
  1541. ErrCodeUnknownBan = 10026
  1542. ErrCodeUnknownSKU = 10027
  1543. ErrCodeUnknownStoreListing = 10028
  1544. ErrCodeUnknownEntitlement = 10029
  1545. ErrCodeUnknownBuild = 10030
  1546. ErrCodeUnknownLobby = 10031
  1547. ErrCodeUnknownBranch = 10032
  1548. ErrCodeUnknownStoreDirectoryLayout = 10033
  1549. ErrCodeUnknownRedistributable = 10036
  1550. ErrCodeUnknownGiftCode = 10038
  1551. ErrCodeUnknownStream = 10049
  1552. ErrCodeUnknownPremiumServerSubscribeCooldown = 10050
  1553. ErrCodeUnknownGuildTemplate = 10057
  1554. ErrCodeUnknownDiscoveryCategory = 10059
  1555. ErrCodeUnknownSticker = 10060
  1556. ErrCodeUnknownInteraction = 10062
  1557. ErrCodeUnknownApplicationCommand = 10063
  1558. ErrCodeUnknownApplicationCommandPermissions = 10066
  1559. ErrCodeUnknownStageInstance = 10067
  1560. ErrCodeUnknownGuildMemberVerificationForm = 10068
  1561. ErrCodeUnknownGuildWelcomeScreen = 10069
  1562. ErrCodeUnknownGuildScheduledEvent = 10070
  1563. ErrCodeUnknownGuildScheduledEventUser = 10071
  1564. ErrCodeBotsCannotUseEndpoint = 20001
  1565. ErrCodeOnlyBotsCanUseEndpoint = 20002
  1566. ErrCodeExplicitContentCannotBeSentToTheDesiredRecipients = 20009
  1567. ErrCodeYouAreNotAuthorizedToPerformThisActionOnThisApplication = 20012
  1568. ErrCodeThisActionCannotBePerformedDueToSlowmodeRateLimit = 20016
  1569. ErrCodeOnlyTheOwnerOfThisAccountCanPerformThisAction = 20018
  1570. ErrCodeMessageCannotBeEditedDueToAnnouncementRateLimits = 20022
  1571. ErrCodeChannelHasHitWriteRateLimit = 20028
  1572. ErrCodeTheWriteActionYouArePerformingOnTheServerHasHitTheWriteRateLimit = 20029
  1573. ErrCodeStageTopicContainsNotAllowedWordsForPublicStages = 20031
  1574. ErrCodeGuildPremiumSubscriptionLevelTooLow = 20035
  1575. ErrCodeMaximumGuildsReached = 30001
  1576. ErrCodeMaximumPinsReached = 30003
  1577. ErrCodeMaximumNumberOfRecipientsReached = 30004
  1578. ErrCodeMaximumGuildRolesReached = 30005
  1579. ErrCodeMaximumNumberOfWebhooksReached = 30007
  1580. ErrCodeMaximumNumberOfEmojisReached = 30008
  1581. ErrCodeTooManyReactions = 30010
  1582. ErrCodeMaximumNumberOfGuildChannelsReached = 30013
  1583. ErrCodeMaximumNumberOfAttachmentsInAMessageReached = 30015
  1584. ErrCodeMaximumNumberOfInvitesReached = 30016
  1585. ErrCodeMaximumNumberOfAnimatedEmojisReached = 30018
  1586. ErrCodeMaximumNumberOfServerMembersReached = 30019
  1587. ErrCodeMaximumNumberOfGuildDiscoverySubcategoriesReached = 30030
  1588. ErrCodeGuildAlreadyHasATemplate = 30031
  1589. ErrCodeMaximumNumberOfThreadParticipantsReached = 30033
  1590. ErrCodeMaximumNumberOfBansForNonGuildMembersHaveBeenExceeded = 30035
  1591. ErrCodeMaximumNumberOfBansFetchesHasBeenReached = 30037
  1592. ErrCodeMaximumNumberOfUncompletedGuildScheduledEventsReached = 30038
  1593. ErrCodeMaximumNumberOfStickersReached = 30039
  1594. ErrCodeMaximumNumberOfPruneRequestsHasBeenReached = 30040
  1595. ErrCodeMaximumNumberOfGuildWidgetSettingsUpdatesHasBeenReached = 30042
  1596. ErrCodeMaximumNumberOfEditsToMessagesOlderThanOneHourReached = 30046
  1597. ErrCodeUnauthorized = 40001
  1598. ErrCodeActionRequiredVerifiedAccount = 40002
  1599. ErrCodeOpeningDirectMessagesTooFast = 40003
  1600. ErrCodeSendMessagesHasBeenTemporarilyDisabled = 40004
  1601. ErrCodeRequestEntityTooLarge = 40005
  1602. ErrCodeFeatureTemporarilyDisabledServerSide = 40006
  1603. ErrCodeUserIsBannedFromThisGuild = 40007
  1604. ErrCodeTargetIsNotConnectedToVoice = 40032
  1605. ErrCodeMessageAlreadyCrossposted = 40033
  1606. ErrCodeAnApplicationWithThatNameAlreadyExists = 40041
  1607. ErrCodeInteractionHasAlreadyBeenAcknowledged = 40060
  1608. ErrCodeMissingAccess = 50001
  1609. ErrCodeInvalidAccountType = 50002
  1610. ErrCodeCannotExecuteActionOnDMChannel = 50003
  1611. ErrCodeEmbedDisabled = 50004
  1612. ErrCodeGuildWidgetDisabled = 50004
  1613. ErrCodeCannotEditFromAnotherUser = 50005
  1614. ErrCodeCannotSendEmptyMessage = 50006
  1615. ErrCodeCannotSendMessagesToThisUser = 50007
  1616. ErrCodeCannotSendMessagesInVoiceChannel = 50008
  1617. ErrCodeChannelVerificationLevelTooHigh = 50009
  1618. ErrCodeOAuth2ApplicationDoesNotHaveBot = 50010
  1619. ErrCodeOAuth2ApplicationLimitReached = 50011
  1620. ErrCodeInvalidOAuthState = 50012
  1621. ErrCodeMissingPermissions = 50013
  1622. ErrCodeInvalidAuthenticationToken = 50014
  1623. ErrCodeTooFewOrTooManyMessagesToDelete = 50016
  1624. ErrCodeCanOnlyPinMessageToOriginatingChannel = 50019
  1625. ErrCodeInviteCodeWasEitherInvalidOrTaken = 50020
  1626. ErrCodeCannotExecuteActionOnSystemMessage = 50021
  1627. ErrCodeCannotExecuteActionOnThisChannelType = 50024
  1628. ErrCodeInvalidOAuth2AccessTokenProvided = 50025
  1629. ErrCodeMissingRequiredOAuth2Scope = 50026
  1630. ErrCodeInvalidWebhookTokenProvided = 50027
  1631. ErrCodeInvalidRole = 50028
  1632. ErrCodeInvalidRecipients = 50033
  1633. ErrCodeMessageProvidedTooOldForBulkDelete = 50034
  1634. ErrCodeInvalidFormBody = 50035
  1635. ErrCodeInviteAcceptedToGuildApplicationsBotNotIn = 50036
  1636. ErrCodeInvalidAPIVersionProvided = 50041
  1637. ErrCodeFileUploadedExceedsTheMaximumSize = 50045
  1638. ErrCodeInvalidFileUploaded = 50046
  1639. ErrCodeInvalidGuild = 50055
  1640. ErrCodeInvalidMessageType = 50068
  1641. ErrCodeCannotDeleteAChannelRequiredForCommunityGuilds = 50074
  1642. ErrCodeInvalidStickerSent = 50081
  1643. ErrCodePerformedOperationOnArchivedThread = 50083
  1644. ErrCodeBeforeValueIsEarlierThanThreadCreationDate = 50085
  1645. ErrCodeCommunityServerChannelsMustBeTextChannels = 50086
  1646. ErrCodeThisServerIsNotAvailableInYourLocation = 50095
  1647. ErrCodeThisServerNeedsMonetizationEnabledInOrderToPerformThisAction = 50097
  1648. ErrCodeThisServerNeedsMoreBoostsToPerformThisAction = 50101
  1649. ErrCodeTheRequestBodyContainsInvalidJSON = 50109
  1650. ErrCodeNoUsersWithDiscordTagExist = 80004
  1651. ErrCodeReactionBlocked = 90001
  1652. ErrCodeAPIResourceIsCurrentlyOverloaded = 130000
  1653. ErrCodeTheStageIsAlreadyOpen = 150006
  1654. ErrCodeCannotReplyWithoutPermissionToReadMessageHistory = 160002
  1655. ErrCodeThreadAlreadyCreatedForThisMessage = 160004
  1656. ErrCodeThreadIsLocked = 160005
  1657. ErrCodeMaximumNumberOfActiveThreadsReached = 160006
  1658. ErrCodeMaximumNumberOfActiveAnnouncementThreadsReached = 160007
  1659. ErrCodeInvalidJSONForUploadedLottieFile = 170001
  1660. ErrCodeUploadedLottiesCannotContainRasterizedImages = 170002
  1661. ErrCodeStickerMaximumFramerateExceeded = 170003
  1662. ErrCodeStickerFrameCountExceedsMaximumOfOneThousandFrames = 170004
  1663. ErrCodeLottieAnimationMaximumDimensionsExceeded = 170005
  1664. ErrCodeStickerFrameRateOutOfRange = 170006
  1665. ErrCodeStickerAnimationDurationExceedsMaximumOfFiveSeconds = 170007
  1666. ErrCodeCannotUpdateAFinishedEvent = 180000
  1667. ErrCodeFailedToCreateStageNeededForStageEvent = 180002
  1668. )
  1669. // Intent is the type of a Gateway Intent
  1670. // https://discord.com/developers/docs/topics/gateway#gateway-intents
  1671. type Intent int
  1672. // Constants for the different bit offsets of intents
  1673. const (
  1674. IntentGuilds Intent = 1 << 0
  1675. IntentGuildMembers Intent = 1 << 1
  1676. IntentGuildBans Intent = 1 << 2
  1677. IntentGuildEmojis Intent = 1 << 3
  1678. IntentGuildIntegrations Intent = 1 << 4
  1679. IntentGuildWebhooks Intent = 1 << 5
  1680. IntentGuildInvites Intent = 1 << 6
  1681. IntentGuildVoiceStates Intent = 1 << 7
  1682. IntentGuildPresences Intent = 1 << 8
  1683. IntentGuildMessages Intent = 1 << 9
  1684. IntentGuildMessageReactions Intent = 1 << 10
  1685. IntentGuildMessageTyping Intent = 1 << 11
  1686. IntentDirectMessages Intent = 1 << 12
  1687. IntentDirectMessageReactions Intent = 1 << 13
  1688. IntentDirectMessageTyping Intent = 1 << 14
  1689. IntentMessageContent Intent = 1 << 15
  1690. IntentGuildScheduledEvents Intent = 1 << 16
  1691. // TODO: remove when compatibility is not needed
  1692. IntentsGuilds Intent = 1 << 0
  1693. IntentsGuildMembers Intent = 1 << 1
  1694. IntentsGuildBans Intent = 1 << 2
  1695. IntentsGuildEmojis Intent = 1 << 3
  1696. IntentsGuildIntegrations Intent = 1 << 4
  1697. IntentsGuildWebhooks Intent = 1 << 5
  1698. IntentsGuildInvites Intent = 1 << 6
  1699. IntentsGuildVoiceStates Intent = 1 << 7
  1700. IntentsGuildPresences Intent = 1 << 8
  1701. IntentsGuildMessages Intent = 1 << 9
  1702. IntentsGuildMessageReactions Intent = 1 << 10
  1703. IntentsGuildMessageTyping Intent = 1 << 11
  1704. IntentsDirectMessages Intent = 1 << 12
  1705. IntentsDirectMessageReactions Intent = 1 << 13
  1706. IntentsDirectMessageTyping Intent = 1 << 14
  1707. IntentsMessageContent Intent = 1 << 15
  1708. IntentsGuildScheduledEvents Intent = 1 << 16
  1709. IntentsAllWithoutPrivileged = IntentGuilds |
  1710. IntentGuildBans |
  1711. IntentGuildEmojis |
  1712. IntentGuildIntegrations |
  1713. IntentGuildWebhooks |
  1714. IntentGuildInvites |
  1715. IntentGuildVoiceStates |
  1716. IntentGuildMessages |
  1717. IntentGuildMessageReactions |
  1718. IntentGuildMessageTyping |
  1719. IntentDirectMessages |
  1720. IntentDirectMessageReactions |
  1721. IntentDirectMessageTyping |
  1722. IntentGuildScheduledEvents
  1723. IntentsAll = IntentsAllWithoutPrivileged |
  1724. IntentGuildMembers |
  1725. IntentGuildPresences |
  1726. IntentMessageContent
  1727. IntentsNone Intent = 0
  1728. )
  1729. // MakeIntent used to help convert a gateway intent value for use in the Identify structure;
  1730. // this was useful to help support the use of a pointer type when intents were optional.
  1731. // This is now a no-op, and is not necessary to use.
  1732. func MakeIntent(intents Intent) Intent {
  1733. return intents
  1734. }