structs.go 72 KB

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