structs.go 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  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. "net/http"
  13. "sync"
  14. "time"
  15. "github.com/gorilla/websocket"
  16. )
  17. // A Session represents a connection to the Discord API.
  18. type Session struct {
  19. sync.RWMutex
  20. // General configurable settings.
  21. // Authentication token for this session
  22. Token string
  23. MFA bool
  24. // Debug for printing JSON request/responses
  25. Debug bool // Deprecated, will be removed.
  26. LogLevel int
  27. // Should the session reconnect the websocket on errors.
  28. ShouldReconnectOnError bool
  29. // Should the session request compressed websocket data.
  30. Compress bool
  31. // Sharding
  32. ShardID int
  33. ShardCount int
  34. // Should state tracking be enabled.
  35. // State tracking is the best way for getting the the users
  36. // active guilds and the members of the guilds.
  37. StateEnabled bool
  38. // Whether or not to call event handlers synchronously.
  39. // e.g false = launch event handlers in their own goroutines.
  40. SyncEvents bool
  41. // Exposed but should not be modified by User.
  42. // Whether the Data Websocket is ready
  43. DataReady bool // NOTE: Maye be deprecated soon
  44. // Max number of REST API retries
  45. MaxRestRetries int
  46. // Status stores the currect status of the websocket connection
  47. // this is being tested, may stay, may go away.
  48. status int32
  49. // Whether the Voice Websocket is ready
  50. VoiceReady bool // NOTE: Deprecated.
  51. // Whether the UDP Connection is ready
  52. UDPReady bool // NOTE: Deprecated
  53. // Stores a mapping of guild id's to VoiceConnections
  54. VoiceConnections map[string]*VoiceConnection
  55. // Managed state object, updated internally with events when
  56. // StateEnabled is true.
  57. State *State
  58. // The http client used for REST requests
  59. Client *http.Client
  60. // Stores the last HeartbeatAck that was recieved (in UTC)
  61. LastHeartbeatAck time.Time
  62. // used to deal with rate limits
  63. Ratelimiter *RateLimiter
  64. // Event handlers
  65. handlersMu sync.RWMutex
  66. handlers map[string][]*eventHandlerInstance
  67. onceHandlers map[string][]*eventHandlerInstance
  68. // The websocket connection.
  69. wsConn *websocket.Conn
  70. // When nil, the session is not listening.
  71. listening chan interface{}
  72. // sequence tracks the current gateway api websocket sequence number
  73. sequence *int64
  74. // stores sessions current Discord Gateway
  75. gateway string
  76. // stores session ID of current Gateway connection
  77. sessionID string
  78. // used to make sure gateway websocket writes do not happen concurrently
  79. wsMutex sync.Mutex
  80. }
  81. // A VoiceRegion stores data for a specific voice region server.
  82. type VoiceRegion struct {
  83. ID string `json:"id"`
  84. Name string `json:"name"`
  85. Hostname string `json:"sample_hostname"`
  86. Port int `json:"sample_port"`
  87. }
  88. // A VoiceICE stores data for voice ICE servers.
  89. type VoiceICE struct {
  90. TTL string `json:"ttl"`
  91. Servers []*ICEServer `json:"servers"`
  92. }
  93. // A ICEServer stores data for a specific voice ICE server.
  94. type ICEServer struct {
  95. URL string `json:"url"`
  96. Username string `json:"username"`
  97. Credential string `json:"credential"`
  98. }
  99. // A Invite stores all data related to a specific Discord Guild or Channel invite.
  100. type Invite struct {
  101. Guild *Guild `json:"guild"`
  102. Channel *Channel `json:"channel"`
  103. Inviter *User `json:"inviter"`
  104. Code string `json:"code"`
  105. CreatedAt Timestamp `json:"created_at"`
  106. MaxAge int `json:"max_age"`
  107. Uses int `json:"uses"`
  108. MaxUses int `json:"max_uses"`
  109. Revoked bool `json:"revoked"`
  110. Temporary bool `json:"temporary"`
  111. Unique bool `json:"unique"`
  112. }
  113. // ChannelType is the type of a Channel
  114. type ChannelType int
  115. // Block contains known ChannelType values
  116. const (
  117. ChannelTypeGuildText ChannelType = iota
  118. ChannelTypeDM
  119. ChannelTypeGuildVoice
  120. ChannelTypeGroupDM
  121. ChannelTypeGuildCategory
  122. )
  123. // A Channel holds all data related to an individual Discord channel.
  124. type Channel struct {
  125. ID string `json:"id"`
  126. GuildID string `json:"guild_id"`
  127. Name string `json:"name"`
  128. Topic string `json:"topic"`
  129. Type ChannelType `json:"type"`
  130. LastMessageID string `json:"last_message_id"`
  131. NSFW bool `json:"nsfw"`
  132. Position int `json:"position"`
  133. Bitrate int `json:"bitrate"`
  134. Recipients []*User `json:"recipients"`
  135. Messages []*Message `json:"-"`
  136. PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites"`
  137. ParentID string `json:"parent_id"`
  138. }
  139. // A ChannelEdit holds Channel Feild data for a channel edit.
  140. type ChannelEdit struct {
  141. Name string `json:"name,omitempty"`
  142. Topic string `json:"topic,omitempty"`
  143. NSFW bool `json:"nsfw,omitempty"`
  144. Position int `json:"position"`
  145. Bitrate int `json:"bitrate,omitempty"`
  146. UserLimit int `json:"user_limit,omitempty"`
  147. PermissionOverwrites []*PermissionOverwrite `json:"permission_overwrites,omitempty"`
  148. ParentID string `json:"parent_id,omitempty"`
  149. }
  150. // A PermissionOverwrite holds permission overwrite data for a Channel
  151. type PermissionOverwrite struct {
  152. ID string `json:"id"`
  153. Type string `json:"type"`
  154. Deny int `json:"deny"`
  155. Allow int `json:"allow"`
  156. }
  157. // Emoji struct holds data related to Emoji's
  158. type Emoji struct {
  159. ID string `json:"id"`
  160. Name string `json:"name"`
  161. Roles []string `json:"roles"`
  162. Managed bool `json:"managed"`
  163. RequireColons bool `json:"require_colons"`
  164. Animated bool `json:"animated"`
  165. }
  166. // APIName returns an correctly formatted API name for use in the MessageReactions endpoints.
  167. func (e *Emoji) APIName() string {
  168. if e.ID != "" && e.Name != "" {
  169. return e.Name + ":" + e.ID
  170. }
  171. if e.Name != "" {
  172. return e.Name
  173. }
  174. return e.ID
  175. }
  176. // VerificationLevel type definition
  177. type VerificationLevel int
  178. // Constants for VerificationLevel levels from 0 to 3 inclusive
  179. const (
  180. VerificationLevelNone VerificationLevel = iota
  181. VerificationLevelLow
  182. VerificationLevelMedium
  183. VerificationLevelHigh
  184. )
  185. // A Guild holds all data related to a specific Discord Guild. Guilds are also
  186. // sometimes referred to as Servers in the Discord client.
  187. type Guild struct {
  188. ID string `json:"id"`
  189. Name string `json:"name"`
  190. Icon string `json:"icon"`
  191. Region string `json:"region"`
  192. AfkChannelID string `json:"afk_channel_id"`
  193. EmbedChannelID string `json:"embed_channel_id"`
  194. OwnerID string `json:"owner_id"`
  195. JoinedAt Timestamp `json:"joined_at"`
  196. Splash string `json:"splash"`
  197. AfkTimeout int `json:"afk_timeout"`
  198. MemberCount int `json:"member_count"`
  199. VerificationLevel VerificationLevel `json:"verification_level"`
  200. EmbedEnabled bool `json:"embed_enabled"`
  201. Large bool `json:"large"` // ??
  202. DefaultMessageNotifications int `json:"default_message_notifications"`
  203. Roles []*Role `json:"roles"`
  204. Emojis []*Emoji `json:"emojis"`
  205. Members []*Member `json:"members"`
  206. Presences []*Presence `json:"presences"`
  207. Channels []*Channel `json:"channels"`
  208. VoiceStates []*VoiceState `json:"voice_states"`
  209. Unavailable bool `json:"unavailable"`
  210. }
  211. // A UserGuild holds a brief version of a Guild
  212. type UserGuild struct {
  213. ID string `json:"id"`
  214. Name string `json:"name"`
  215. Icon string `json:"icon"`
  216. Owner bool `json:"owner"`
  217. Permissions int `json:"permissions"`
  218. }
  219. // A GuildParams stores all the data needed to update discord guild settings
  220. type GuildParams struct {
  221. Name string `json:"name,omitempty"`
  222. Region string `json:"region,omitempty"`
  223. VerificationLevel *VerificationLevel `json:"verification_level,omitempty"`
  224. DefaultMessageNotifications int `json:"default_message_notifications,omitempty"` // TODO: Separate type?
  225. AfkChannelID string `json:"afk_channel_id,omitempty"`
  226. AfkTimeout int `json:"afk_timeout,omitempty"`
  227. Icon string `json:"icon,omitempty"`
  228. OwnerID string `json:"owner_id,omitempty"`
  229. Splash string `json:"splash,omitempty"`
  230. }
  231. // A Role stores information about Discord guild member roles.
  232. type Role struct {
  233. ID string `json:"id"`
  234. Name string `json:"name"`
  235. Managed bool `json:"managed"`
  236. Mentionable bool `json:"mentionable"`
  237. Hoist bool `json:"hoist"`
  238. Color int `json:"color"`
  239. Position int `json:"position"`
  240. Permissions int `json:"permissions"`
  241. }
  242. // Roles are a collection of Role
  243. type Roles []*Role
  244. func (r Roles) Len() int {
  245. return len(r)
  246. }
  247. func (r Roles) Less(i, j int) bool {
  248. return r[i].Position > r[j].Position
  249. }
  250. func (r Roles) Swap(i, j int) {
  251. r[i], r[j] = r[j], r[i]
  252. }
  253. // A VoiceState stores the voice states of Guilds
  254. type VoiceState struct {
  255. UserID string `json:"user_id"`
  256. SessionID string `json:"session_id"`
  257. ChannelID string `json:"channel_id"`
  258. GuildID string `json:"guild_id"`
  259. Suppress bool `json:"suppress"`
  260. SelfMute bool `json:"self_mute"`
  261. SelfDeaf bool `json:"self_deaf"`
  262. Mute bool `json:"mute"`
  263. Deaf bool `json:"deaf"`
  264. }
  265. // A Presence stores the online, offline, or idle and game status of Guild members.
  266. type Presence struct {
  267. User *User `json:"user"`
  268. Status Status `json:"status"`
  269. Game *Game `json:"game"`
  270. Nick string `json:"nick"`
  271. Roles []string `json:"roles"`
  272. Since *int `json:"since"`
  273. }
  274. // GameType is the type of "game" (see GameType* consts) in the Game struct
  275. type GameType int
  276. // Valid GameType values
  277. const (
  278. GameTypeGame GameType = iota
  279. GameTypeStreaming
  280. )
  281. // A Game struct holds the name of the "playing .." game for a user
  282. type Game struct {
  283. Name string `json:"name"`
  284. Type GameType `json:"type"`
  285. URL string `json:"url,omitempty"`
  286. Details string `json:"details,omitempty"`
  287. State string `json:"state,omitempty"`
  288. TimeStamps TimeStamps `json:"timestamps,omitempty"`
  289. Assets Assets `json:"assets,omitempty"`
  290. ApplicationID string `json:"application_id,omitempty"`
  291. Instance int8 `json:"instance,omitempty"`
  292. // TODO: Party and Secrets (unknown structure)
  293. }
  294. // A TimeStamps struct contains start and end times used in the rich presence "playing .." Game
  295. type TimeStamps struct {
  296. EndTimestamp int64 `json:"end,omitempty"`
  297. StartTimestamp int64 `json:"start,omitempty"`
  298. }
  299. // UnmarshalJSON unmarshals JSON into TimeStamps struct
  300. func (t *TimeStamps) UnmarshalJSON(b []byte) error {
  301. temp := struct {
  302. End float64 `json:"end,omitempty"`
  303. Start float64 `json:"start,omitempty"`
  304. }{}
  305. err := json.Unmarshal(b, &temp)
  306. if err != nil {
  307. return err
  308. }
  309. t.EndTimestamp = int64(temp.End)
  310. t.StartTimestamp = int64(temp.Start)
  311. return nil
  312. }
  313. // An Assets struct contains assets and labels used in the rich presence "playing .." Game
  314. type Assets struct {
  315. LargeImageID string `json:"large_image,omitempty"`
  316. SmallImageID string `json:"small_image,omitempty"`
  317. LargeText string `json:"large_text,omitempty"`
  318. SmallText string `json:"small_text,omitempty"`
  319. }
  320. // A Member stores user information for Guild members.
  321. type Member struct {
  322. GuildID string `json:"guild_id"`
  323. JoinedAt string `json:"joined_at"`
  324. Nick string `json:"nick"`
  325. Deaf bool `json:"deaf"`
  326. Mute bool `json:"mute"`
  327. User *User `json:"user"`
  328. Roles []string `json:"roles"`
  329. }
  330. // A Settings stores data for a specific users Discord client settings.
  331. type Settings struct {
  332. RenderEmbeds bool `json:"render_embeds"`
  333. InlineEmbedMedia bool `json:"inline_embed_media"`
  334. InlineAttachmentMedia bool `json:"inline_attachment_media"`
  335. EnableTtsCommand bool `json:"enable_tts_command"`
  336. MessageDisplayCompact bool `json:"message_display_compact"`
  337. ShowCurrentGame bool `json:"show_current_game"`
  338. ConvertEmoticons bool `json:"convert_emoticons"`
  339. Locale string `json:"locale"`
  340. Theme string `json:"theme"`
  341. GuildPositions []string `json:"guild_positions"`
  342. RestrictedGuilds []string `json:"restricted_guilds"`
  343. FriendSourceFlags *FriendSourceFlags `json:"friend_source_flags"`
  344. Status Status `json:"status"`
  345. DetectPlatformAccounts bool `json:"detect_platform_accounts"`
  346. DeveloperMode bool `json:"developer_mode"`
  347. }
  348. // Status type definition
  349. type Status string
  350. // Constants for Status with the different current available status
  351. const (
  352. StatusOnline Status = "online"
  353. StatusIdle Status = "idle"
  354. StatusDoNotDisturb Status = "dnd"
  355. StatusInvisible Status = "invisible"
  356. StatusOffline Status = "offline"
  357. )
  358. // FriendSourceFlags stores ... TODO :)
  359. type FriendSourceFlags struct {
  360. All bool `json:"all"`
  361. MutualGuilds bool `json:"mutual_guilds"`
  362. MutualFriends bool `json:"mutual_friends"`
  363. }
  364. // A Relationship between the logged in user and Relationship.User
  365. type Relationship struct {
  366. User *User `json:"user"`
  367. Type int `json:"type"` // 1 = friend, 2 = blocked, 3 = incoming friend req, 4 = sent friend req
  368. ID string `json:"id"`
  369. }
  370. // A TooManyRequests struct holds information received from Discord
  371. // when receiving a HTTP 429 response.
  372. type TooManyRequests struct {
  373. Bucket string `json:"bucket"`
  374. Message string `json:"message"`
  375. RetryAfter time.Duration `json:"retry_after"`
  376. }
  377. // A ReadState stores data on the read state of channels.
  378. type ReadState struct {
  379. MentionCount int `json:"mention_count"`
  380. LastMessageID string `json:"last_message_id"`
  381. ID string `json:"id"`
  382. }
  383. // An Ack is used to ack messages
  384. type Ack struct {
  385. Token string `json:"token"`
  386. }
  387. // A GuildRole stores data for guild roles.
  388. type GuildRole struct {
  389. Role *Role `json:"role"`
  390. GuildID string `json:"guild_id"`
  391. }
  392. // A GuildBan stores data for a guild ban.
  393. type GuildBan struct {
  394. Reason string `json:"reason"`
  395. User *User `json:"user"`
  396. }
  397. // A GuildIntegration stores data for a guild integration.
  398. type GuildIntegration struct {
  399. ID string `json:"id"`
  400. Name string `json:"name"`
  401. Type string `json:"type"`
  402. Enabled bool `json:"enabled"`
  403. Syncing bool `json:"syncing"`
  404. RoleID string `json:"role_id"`
  405. ExpireBehavior int `json:"expire_behavior"`
  406. ExpireGracePeriod int `json:"expire_grace_period"`
  407. User *User `json:"user"`
  408. Account *GuildIntegrationAccount `json:"account"`
  409. SyncedAt int `json:"synced_at"`
  410. }
  411. // A GuildIntegrationAccount stores data for a guild integration account.
  412. type GuildIntegrationAccount struct {
  413. ID string `json:"id"`
  414. Name string `json:"name"`
  415. }
  416. // A GuildEmbed stores data for a guild embed.
  417. type GuildEmbed struct {
  418. Enabled bool `json:"enabled"`
  419. ChannelID string `json:"channel_id"`
  420. }
  421. // A GuildAuditLog stores data for a guild audit log.
  422. type GuildAuditLog struct {
  423. Webhooks []struct {
  424. ChannelID string `json:"channel_id"`
  425. GuildID string `json:"guild_id"`
  426. ID string `json:"id"`
  427. Avatar string `json:"avatar"`
  428. Name string `json:"name"`
  429. } `json:"webhooks,omitempty"`
  430. Users []struct {
  431. Username string `json:"username"`
  432. Discriminator string `json:"discriminator"`
  433. Bot bool `json:"bot"`
  434. ID string `json:"id"`
  435. Avatar string `json:"avatar"`
  436. } `json:"users,omitempty"`
  437. AuditLogEntries []struct {
  438. TargetID string `json:"target_id"`
  439. Changes []struct {
  440. NewValue interface{} `json:"new_value"`
  441. OldValue interface{} `json:"old_value"`
  442. Key string `json:"key"`
  443. } `json:"changes,omitempty"`
  444. UserID string `json:"user_id"`
  445. ID string `json:"id"`
  446. ActionType int `json:"action_type"`
  447. Options struct {
  448. DeleteMembersDay string `json:"delete_member_days"`
  449. MembersRemoved string `json:"members_removed"`
  450. ChannelID string `json:"channel_id"`
  451. Count string `json:"count"`
  452. ID string `json:"id"`
  453. Type string `json:"type"`
  454. RoleName string `json:"role_name"`
  455. } `json:"options,omitempty"`
  456. Reason string `json:"reason"`
  457. } `json:"audit_log_entries"`
  458. }
  459. // Block contains Discord Audit Log Action Types
  460. const (
  461. AuditLogActionGuildUpdate = 1
  462. AuditLogActionChannelCreate = 10
  463. AuditLogActionChannelUpdate = 11
  464. AuditLogActionChannelDelete = 12
  465. AuditLogActionChannelOverwriteCreate = 13
  466. AuditLogActionChannelOverwriteUpdate = 14
  467. AuditLogActionChannelOverwriteDelete = 15
  468. AuditLogActionMemberKick = 20
  469. AuditLogActionMemberPrune = 21
  470. AuditLogActionMemberBanAdd = 22
  471. AuditLogActionMemberBanRemove = 23
  472. AuditLogActionMemberUpdate = 24
  473. AuditLogActionMemberRoleUpdate = 25
  474. AuditLogActionRoleCreate = 30
  475. AuditLogActionRoleUpdate = 31
  476. AuditLogActionRoleDelete = 32
  477. AuditLogActionInviteCreate = 40
  478. AuditLogActionInviteUpdate = 41
  479. AuditLogActionInviteDelete = 42
  480. AuditLogActionWebhookCreate = 50
  481. AuditLogActionWebhookUpdate = 51
  482. AuditLogActionWebhookDelete = 52
  483. AuditLogActionEmojiCreate = 60
  484. AuditLogActionEmojiUpdate = 61
  485. AuditLogActionEmojiDelete = 62
  486. AuditLogActionMessageDelete = 72
  487. )
  488. // A UserGuildSettingsChannelOverride stores data for a channel override for a users guild settings.
  489. type UserGuildSettingsChannelOverride struct {
  490. Muted bool `json:"muted"`
  491. MessageNotifications int `json:"message_notifications"`
  492. ChannelID string `json:"channel_id"`
  493. }
  494. // A UserGuildSettings stores data for a users guild settings.
  495. type UserGuildSettings struct {
  496. SupressEveryone bool `json:"suppress_everyone"`
  497. Muted bool `json:"muted"`
  498. MobilePush bool `json:"mobile_push"`
  499. MessageNotifications int `json:"message_notifications"`
  500. GuildID string `json:"guild_id"`
  501. ChannelOverrides []*UserGuildSettingsChannelOverride `json:"channel_overrides"`
  502. }
  503. // A UserGuildSettingsEdit stores data for editing UserGuildSettings
  504. type UserGuildSettingsEdit struct {
  505. SupressEveryone bool `json:"suppress_everyone"`
  506. Muted bool `json:"muted"`
  507. MobilePush bool `json:"mobile_push"`
  508. MessageNotifications int `json:"message_notifications"`
  509. ChannelOverrides map[string]*UserGuildSettingsChannelOverride `json:"channel_overrides"`
  510. }
  511. // An APIErrorMessage is an api error message returned from discord
  512. type APIErrorMessage struct {
  513. Code int `json:"code"`
  514. Message string `json:"message"`
  515. }
  516. // Webhook stores the data for a webhook.
  517. type Webhook struct {
  518. ID string `json:"id"`
  519. GuildID string `json:"guild_id"`
  520. ChannelID string `json:"channel_id"`
  521. User *User `json:"user"`
  522. Name string `json:"name"`
  523. Avatar string `json:"avatar"`
  524. Token string `json:"token"`
  525. }
  526. // WebhookParams is a struct for webhook params, used in the WebhookExecute command.
  527. type WebhookParams struct {
  528. Content string `json:"content,omitempty"`
  529. Username string `json:"username,omitempty"`
  530. AvatarURL string `json:"avatar_url,omitempty"`
  531. TTS bool `json:"tts,omitempty"`
  532. File string `json:"file,omitempty"`
  533. Embeds []*MessageEmbed `json:"embeds,omitempty"`
  534. }
  535. // MessageReaction stores the data for a message reaction.
  536. type MessageReaction struct {
  537. UserID string `json:"user_id"`
  538. MessageID string `json:"message_id"`
  539. Emoji Emoji `json:"emoji"`
  540. ChannelID string `json:"channel_id"`
  541. }
  542. // GatewayBotResponse stores the data for the gateway/bot response
  543. type GatewayBotResponse struct {
  544. URL string `json:"url"`
  545. Shards int `json:"shards"`
  546. }
  547. // Constants for the different bit offsets of text channel permissions
  548. const (
  549. PermissionReadMessages = 1 << (iota + 10)
  550. PermissionSendMessages
  551. PermissionSendTTSMessages
  552. PermissionManageMessages
  553. PermissionEmbedLinks
  554. PermissionAttachFiles
  555. PermissionReadMessageHistory
  556. PermissionMentionEveryone
  557. PermissionUseExternalEmojis
  558. )
  559. // Constants for the different bit offsets of voice permissions
  560. const (
  561. PermissionVoiceConnect = 1 << (iota + 20)
  562. PermissionVoiceSpeak
  563. PermissionVoiceMuteMembers
  564. PermissionVoiceDeafenMembers
  565. PermissionVoiceMoveMembers
  566. PermissionVoiceUseVAD
  567. )
  568. // Constants for general management.
  569. const (
  570. PermissionChangeNickname = 1 << (iota + 26)
  571. PermissionManageNicknames
  572. PermissionManageRoles
  573. PermissionManageWebhooks
  574. PermissionManageEmojis
  575. )
  576. // Constants for the different bit offsets of general permissions
  577. const (
  578. PermissionCreateInstantInvite = 1 << iota
  579. PermissionKickMembers
  580. PermissionBanMembers
  581. PermissionAdministrator
  582. PermissionManageChannels
  583. PermissionManageServer
  584. PermissionAddReactions
  585. PermissionViewAuditLogs
  586. PermissionAllText = PermissionReadMessages |
  587. PermissionSendMessages |
  588. PermissionSendTTSMessages |
  589. PermissionManageMessages |
  590. PermissionEmbedLinks |
  591. PermissionAttachFiles |
  592. PermissionReadMessageHistory |
  593. PermissionMentionEveryone
  594. PermissionAllVoice = PermissionVoiceConnect |
  595. PermissionVoiceSpeak |
  596. PermissionVoiceMuteMembers |
  597. PermissionVoiceDeafenMembers |
  598. PermissionVoiceMoveMembers |
  599. PermissionVoiceUseVAD
  600. PermissionAllChannel = PermissionAllText |
  601. PermissionAllVoice |
  602. PermissionCreateInstantInvite |
  603. PermissionManageRoles |
  604. PermissionManageChannels |
  605. PermissionAddReactions |
  606. PermissionViewAuditLogs
  607. PermissionAll = PermissionAllChannel |
  608. PermissionKickMembers |
  609. PermissionBanMembers |
  610. PermissionManageServer |
  611. PermissionAdministrator
  612. )
  613. // Block contains Discord JSON Error Response codes
  614. const (
  615. ErrCodeUnknownAccount = 10001
  616. ErrCodeUnknownApplication = 10002
  617. ErrCodeUnknownChannel = 10003
  618. ErrCodeUnknownGuild = 10004
  619. ErrCodeUnknownIntegration = 10005
  620. ErrCodeUnknownInvite = 10006
  621. ErrCodeUnknownMember = 10007
  622. ErrCodeUnknownMessage = 10008
  623. ErrCodeUnknownOverwrite = 10009
  624. ErrCodeUnknownProvider = 10010
  625. ErrCodeUnknownRole = 10011
  626. ErrCodeUnknownToken = 10012
  627. ErrCodeUnknownUser = 10013
  628. ErrCodeUnknownEmoji = 10014
  629. ErrCodeBotsCannotUseEndpoint = 20001
  630. ErrCodeOnlyBotsCanUseEndpoint = 20002
  631. ErrCodeMaximumGuildsReached = 30001
  632. ErrCodeMaximumFriendsReached = 30002
  633. ErrCodeMaximumPinsReached = 30003
  634. ErrCodeMaximumGuildRolesReached = 30005
  635. ErrCodeTooManyReactions = 30010
  636. ErrCodeUnauthorized = 40001
  637. ErrCodeMissingAccess = 50001
  638. ErrCodeInvalidAccountType = 50002
  639. ErrCodeCannotExecuteActionOnDMChannel = 50003
  640. ErrCodeEmbedCisabled = 50004
  641. ErrCodeCannotEditFromAnotherUser = 50005
  642. ErrCodeCannotSendEmptyMessage = 50006
  643. ErrCodeCannotSendMessagesToThisUser = 50007
  644. ErrCodeCannotSendMessagesInVoiceChannel = 50008
  645. ErrCodeChannelVerificationLevelTooHigh = 50009
  646. ErrCodeOAuth2ApplicationDoesNotHaveBot = 50010
  647. ErrCodeOAuth2ApplicationLimitReached = 50011
  648. ErrCodeInvalidOAuthState = 50012
  649. ErrCodeMissingPermissions = 50013
  650. ErrCodeInvalidAuthenticationToken = 50014
  651. ErrCodeNoteTooLong = 50015
  652. ErrCodeTooFewOrTooManyMessagesToDelete = 50016
  653. ErrCodeCanOnlyPinMessageToOriginatingChannel = 50019
  654. ErrCodeCannotExecuteActionOnSystemMessage = 50021
  655. ErrCodeMessageProvidedTooOldForBulkDelete = 50034
  656. ErrCodeInvalidFormBody = 50035
  657. ErrCodeInviteAcceptedToGuildApplicationsBotNotIn = 50036
  658. ErrCodeReactionBlocked = 90001
  659. )