endpoints.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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 variables for all known Discord end points. All functions
  7. // throughout the Discordgo package use these variables for all connections
  8. // to Discord. These are all exported and you may modify them if needed.
  9. package discordgo
  10. import "strconv"
  11. // APIVersion is the Discord API version used for the REST and Websocket API.
  12. var APIVersion = "9"
  13. // Known Discord API Endpoints.
  14. var (
  15. EndpointStatus = "https://status.discord.com/api/v2/"
  16. EndpointSm = EndpointStatus + "scheduled-maintenances/"
  17. EndpointSmActive = EndpointSm + "active.json"
  18. EndpointSmUpcoming = EndpointSm + "upcoming.json"
  19. EndpointDiscord = "https://discord.com/"
  20. EndpointAPI = EndpointDiscord + "api/v" + APIVersion + "/"
  21. EndpointGuilds = EndpointAPI + "guilds/"
  22. EndpointChannels = EndpointAPI + "channels/"
  23. EndpointUsers = EndpointAPI + "users/"
  24. EndpointGateway = EndpointAPI + "gateway"
  25. EndpointGatewayBot = EndpointGateway + "/bot"
  26. EndpointWebhooks = EndpointAPI + "webhooks/"
  27. EndpointStickers = EndpointAPI + "stickers/"
  28. EndpointCDN = "https://cdn.discordapp.com/"
  29. EndpointCDNAttachments = EndpointCDN + "attachments/"
  30. EndpointCDNAvatars = EndpointCDN + "avatars/"
  31. EndpointCDNIcons = EndpointCDN + "icons/"
  32. EndpointCDNSplashes = EndpointCDN + "splashes/"
  33. EndpointCDNChannelIcons = EndpointCDN + "channel-icons/"
  34. EndpointCDNBanners = EndpointCDN + "banners/"
  35. EndpointCDNGuilds = EndpointCDN + "guilds/"
  36. EndpointVoice = EndpointAPI + "/voice/"
  37. EndpointVoiceRegions = EndpointVoice + "regions"
  38. // TODO: EndpointUserGuildMember
  39. EndpointUser = func(uID string) string { return EndpointUsers + uID }
  40. EndpointUserAvatar = func(uID, aID string) string { return EndpointCDNAvatars + uID + "/" + aID + ".png" }
  41. EndpointUserAvatarAnimated = func(uID, aID string) string { return EndpointCDNAvatars + uID + "/" + aID + ".gif" }
  42. EndpointDefaultUserAvatar = func(uDiscriminator string) string {
  43. uDiscriminatorInt, _ := strconv.Atoi(uDiscriminator)
  44. return EndpointCDN + "embed/avatars/" + strconv.Itoa(uDiscriminatorInt%5) + ".png"
  45. }
  46. EndpointUserBanner = func(uID, cID string) string {
  47. return EndpointCDNBanners + uID + "/" + cID + ".png"
  48. }
  49. EndpointUserBannerAnimated = func(uID, cID string) string {
  50. return EndpointCDNBanners + uID + "/" + cID + ".gif"
  51. }
  52. EndpointUserGuilds = func(uID string) string { return EndpointUsers + uID + "/guilds" }
  53. EndpointUserGuild = func(uID, gID string) string { return EndpointUsers + uID + "/guilds/" + gID }
  54. EndpointUserChannels = func(uID string) string { return EndpointUsers + uID + "/channels" }
  55. EndpointUserConnections = func(uID string) string { return EndpointUsers + uID + "/connections" }
  56. EndpointGuild = func(gID string) string { return EndpointGuilds + gID }
  57. EndpointGuildThreads = func(gID string) string { return EndpointGuild(gID) + "/threads" }
  58. EndpointGuildActiveThreads = func(gID string) string { return EndpointGuildThreads(gID) + "/active" }
  59. EndpointGuildPreview = func(gID string) string { return EndpointGuilds + gID + "/preview" }
  60. EndpointGuildChannels = func(gID string) string { return EndpointGuilds + gID + "/channels" }
  61. EndpointGuildMembers = func(gID string) string { return EndpointGuilds + gID + "/members" }
  62. EndpointGuildMember = func(gID, uID string) string { return EndpointGuilds + gID + "/members/" + uID }
  63. EndpointGuildMemberRole = func(gID, uID, rID string) string { return EndpointGuilds + gID + "/members/" + uID + "/roles/" + rID }
  64. EndpointGuildBans = func(gID string) string { return EndpointGuilds + gID + "/bans" }
  65. EndpointGuildBan = func(gID, uID string) string { return EndpointGuilds + gID + "/bans/" + uID }
  66. EndpointGuildIntegrations = func(gID string) string { return EndpointGuilds + gID + "/integrations" }
  67. EndpointGuildIntegration = func(gID, iID string) string { return EndpointGuilds + gID + "/integrations/" + iID }
  68. EndpointGuildRoles = func(gID string) string { return EndpointGuilds + gID + "/roles" }
  69. EndpointGuildRole = func(gID, rID string) string { return EndpointGuilds + gID + "/roles/" + rID }
  70. EndpointGuildInvites = func(gID string) string { return EndpointGuilds + gID + "/invites" }
  71. EndpointGuildWidget = func(gID string) string { return EndpointGuilds + gID + "/widget" }
  72. EndpointGuildEmbed = EndpointGuildWidget
  73. EndpointGuildPrune = func(gID string) string { return EndpointGuilds + gID + "/prune" }
  74. EndpointGuildIcon = func(gID, hash string) string { return EndpointCDNIcons + gID + "/" + hash + ".png" }
  75. EndpointGuildIconAnimated = func(gID, hash string) string { return EndpointCDNIcons + gID + "/" + hash + ".gif" }
  76. EndpointGuildSplash = func(gID, hash string) string { return EndpointCDNSplashes + gID + "/" + hash + ".png" }
  77. EndpointGuildWebhooks = func(gID string) string { return EndpointGuilds + gID + "/webhooks" }
  78. EndpointGuildAuditLogs = func(gID string) string { return EndpointGuilds + gID + "/audit-logs" }
  79. EndpointGuildEmojis = func(gID string) string { return EndpointGuilds + gID + "/emojis" }
  80. EndpointGuildEmoji = func(gID, eID string) string { return EndpointGuilds + gID + "/emojis/" + eID }
  81. EndpointGuildBanner = func(gID, hash string) string { return EndpointCDNBanners + gID + "/" + hash + ".png" }
  82. EndpointGuildStickers = func(gID string) string { return EndpointGuilds + gID + "/stickers" }
  83. EndpointGuildSticker = func(gID, sID string) string { return EndpointGuilds + gID + "/stickers/" + sID }
  84. EndpointGuildScheduledEvents = func(gID string) string { return EndpointGuilds + gID + "/scheduled-events" }
  85. EndpointGuildScheduledEvent = func(gID, eID string) string { return EndpointGuilds + gID + "/scheduled-events/" + eID }
  86. EndpointGuildScheduledEventUsers = func(gID, eID string) string { return EndpointGuildScheduledEvent(gID, eID) + "/users" }
  87. EndpointGuildTemplate = func(tID string) string { return EndpointGuilds + "/templates/" + tID }
  88. EndpointGuildTemplates = func(gID string) string { return EndpointGuilds + gID + "/templates" }
  89. EndpointGuildTemplateSync = func(gID, tID string) string { return EndpointGuilds + gID + "/templates/" + tID }
  90. EndpointGuildMemberAvatar = func(gId, uID, aID string) string {
  91. return EndpointCDNGuilds + gId + "/users/" + uID + "/avatars/" + aID + ".png"
  92. }
  93. EndpointGuildMemberAvatarAnimated = func(gId, uID, aID string) string {
  94. return EndpointCDNGuilds + gId + "/users/" + uID + "/avatars/" + aID + ".gif"
  95. }
  96. EndpointChannel = func(cID string) string { return EndpointChannels + cID }
  97. EndpointChannelThreads = func(cID string) string { return EndpointChannel(cID) + "/threads" }
  98. EndpointChannelActiveThreads = func(cID string) string { return EndpointChannelThreads(cID) + "/active" }
  99. EndpointChannelPublicArchivedThreads = func(cID string) string { return EndpointChannelThreads(cID) + "/archived/public" }
  100. EndpointChannelPrivateArchivedThreads = func(cID string) string { return EndpointChannelThreads(cID) + "/archived/private" }
  101. EndpointChannelJoinedPrivateArchivedThreads = func(cID string) string { return EndpointChannel(cID) + "/users/@me/threads/archived/private" }
  102. EndpointChannelPermissions = func(cID string) string { return EndpointChannels + cID + "/permissions" }
  103. EndpointChannelPermission = func(cID, tID string) string { return EndpointChannels + cID + "/permissions/" + tID }
  104. EndpointChannelInvites = func(cID string) string { return EndpointChannels + cID + "/invites" }
  105. EndpointChannelTyping = func(cID string) string { return EndpointChannels + cID + "/typing" }
  106. EndpointChannelMessages = func(cID string) string { return EndpointChannels + cID + "/messages" }
  107. EndpointChannelMessage = func(cID, mID string) string { return EndpointChannels + cID + "/messages/" + mID }
  108. EndpointChannelMessageThread = func(cID, mID string) string { return EndpointChannelMessage(cID, mID) + "/threads" }
  109. EndpointChannelMessagesBulkDelete = func(cID string) string { return EndpointChannel(cID) + "/messages/bulk-delete" }
  110. EndpointChannelMessagesPins = func(cID string) string { return EndpointChannel(cID) + "/pins" }
  111. EndpointChannelMessagePin = func(cID, mID string) string { return EndpointChannel(cID) + "/pins/" + mID }
  112. EndpointChannelMessageCrosspost = func(cID, mID string) string { return EndpointChannel(cID) + "/messages/" + mID + "/crosspost" }
  113. EndpointChannelFollow = func(cID string) string { return EndpointChannel(cID) + "/followers" }
  114. EndpointThreadMembers = func(tID string) string { return EndpointChannel(tID) + "/thread-members" }
  115. EndpointThreadMember = func(tID, mID string) string { return EndpointThreadMembers(tID) + "/" + mID }
  116. EndpointGroupIcon = func(cID, hash string) string { return EndpointCDNChannelIcons + cID + "/" + hash + ".png" }
  117. EndpointSticker = func(sID string) string { return EndpointStickers + sID }
  118. EndpointNitroStickersPacks = EndpointAPI + "/sticker-packs"
  119. EndpointChannelWebhooks = func(cID string) string { return EndpointChannel(cID) + "/webhooks" }
  120. EndpointWebhook = func(wID string) string { return EndpointWebhooks + wID }
  121. EndpointWebhookToken = func(wID, token string) string { return EndpointWebhooks + wID + "/" + token }
  122. EndpointWebhookMessage = func(wID, token, messageID string) string {
  123. return EndpointWebhookToken(wID, token) + "/messages/" + messageID
  124. }
  125. EndpointMessageReactionsAll = func(cID, mID string) string {
  126. return EndpointChannelMessage(cID, mID) + "/reactions"
  127. }
  128. EndpointMessageReactions = func(cID, mID, eID string) string {
  129. return EndpointChannelMessage(cID, mID) + "/reactions/" + eID
  130. }
  131. EndpointMessageReaction = func(cID, mID, eID, uID string) string {
  132. return EndpointMessageReactions(cID, mID, eID) + "/" + uID
  133. }
  134. EndpointApplicationGlobalCommands = func(aID string) string {
  135. return EndpointApplication(aID) + "/commands"
  136. }
  137. EndpointApplicationGlobalCommand = func(aID, cID string) string {
  138. return EndpointApplicationGlobalCommands(aID) + "/" + cID
  139. }
  140. EndpointApplicationGuildCommands = func(aID, gID string) string {
  141. return EndpointApplication(aID) + "/guilds/" + gID + "/commands"
  142. }
  143. EndpointApplicationGuildCommand = func(aID, gID, cID string) string {
  144. return EndpointApplicationGuildCommands(aID, gID) + "/" + cID
  145. }
  146. EndpointApplicationCommandPermissions = func(aID, gID, cID string) string {
  147. return EndpointApplicationGuildCommand(aID, gID, cID) + "/permissions"
  148. }
  149. EndpointApplicationCommandsGuildPermissions = func(aID, gID string) string {
  150. return EndpointApplicationGuildCommands(aID, gID) + "/permissions"
  151. }
  152. EndpointInteraction = func(aID, iToken string) string {
  153. return EndpointAPI + "interactions/" + aID + "/" + iToken
  154. }
  155. EndpointInteractionResponse = func(iID, iToken string) string {
  156. return EndpointInteraction(iID, iToken) + "/callback"
  157. }
  158. EndpointInteractionResponseActions = func(aID, iToken string) string {
  159. return EndpointWebhookMessage(aID, iToken, "@original")
  160. }
  161. EndpointFollowupMessage = func(aID, iToken string) string {
  162. return EndpointWebhookToken(aID, iToken)
  163. }
  164. EndpointFollowupMessageActions = func(aID, iToken, mID string) string {
  165. return EndpointWebhookMessage(aID, iToken, mID)
  166. }
  167. EndpointGuildCreate = EndpointAPI + "guilds"
  168. EndpointInvite = func(iID string) string { return EndpointAPI + "invites/" + iID }
  169. EndpointEmoji = func(eID string) string { return EndpointCDN + "emojis/" + eID + ".png" }
  170. EndpointEmojiAnimated = func(eID string) string { return EndpointCDN + "emojis/" + eID + ".gif" }
  171. EndpointApplications = EndpointAPI + "applications"
  172. EndpointApplication = func(aID string) string { return EndpointApplications + "/" + aID }
  173. EndpointOAuth2 = EndpointAPI + "oauth2/"
  174. EndpointOAuth2Applications = EndpointOAuth2 + "applications"
  175. EndpointOAuth2Application = func(aID string) string { return EndpointOAuth2Applications + "/" + aID }
  176. EndpointOAuth2ApplicationsBot = func(aID string) string { return EndpointOAuth2Applications + "/" + aID + "/bot" }
  177. EndpointOAuth2ApplicationAssets = func(aID string) string { return EndpointOAuth2Applications + "/" + aID + "/assets" }
  178. // TODO: Deprecated, remove in the next release
  179. EndpointOauth2 = EndpointOAuth2
  180. EndpointOauth2Applications = EndpointOAuth2Applications
  181. EndpointOauth2Application = EndpointOAuth2Application
  182. EndpointOauth2ApplicationsBot = EndpointOAuth2ApplicationsBot
  183. EndpointOauth2ApplicationAssets = EndpointOAuth2ApplicationAssets
  184. )