endpoints.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. EndpointUserGuilds = func(uID string) string { return EndpointUsers + uID + "/guilds" }
  47. EndpointUserGuild = func(uID, gID string) string { return EndpointUsers + uID + "/guilds/" + gID }
  48. EndpointUserChannels = func(uID string) string { return EndpointUsers + uID + "/channels" }
  49. EndpointUserConnections = func(uID string) string { return EndpointUsers + uID + "/connections" }
  50. EndpointGuild = func(gID string) string { return EndpointGuilds + gID }
  51. EndpointGuildThreads = func(gID string) string { return EndpointGuild(gID) + "/threads" }
  52. EndpointGuildActiveThreads = func(gID string) string { return EndpointGuildThreads(gID) + "/active" }
  53. EndpointGuildPreview = func(gID string) string { return EndpointGuilds + gID + "/preview" }
  54. EndpointGuildChannels = func(gID string) string { return EndpointGuilds + gID + "/channels" }
  55. EndpointGuildMembers = func(gID string) string { return EndpointGuilds + gID + "/members" }
  56. EndpointGuildMember = func(gID, uID string) string { return EndpointGuilds + gID + "/members/" + uID }
  57. EndpointGuildMemberRole = func(gID, uID, rID string) string { return EndpointGuilds + gID + "/members/" + uID + "/roles/" + rID }
  58. EndpointGuildBans = func(gID string) string { return EndpointGuilds + gID + "/bans" }
  59. EndpointGuildBan = func(gID, uID string) string { return EndpointGuilds + gID + "/bans/" + uID }
  60. EndpointGuildIntegrations = func(gID string) string { return EndpointGuilds + gID + "/integrations" }
  61. EndpointGuildIntegration = func(gID, iID string) string { return EndpointGuilds + gID + "/integrations/" + iID }
  62. EndpointGuildRoles = func(gID string) string { return EndpointGuilds + gID + "/roles" }
  63. EndpointGuildRole = func(gID, rID string) string { return EndpointGuilds + gID + "/roles/" + rID }
  64. EndpointGuildInvites = func(gID string) string { return EndpointGuilds + gID + "/invites" }
  65. EndpointGuildWidget = func(gID string) string { return EndpointGuilds + gID + "/widget" }
  66. EndpointGuildEmbed = EndpointGuildWidget
  67. EndpointGuildPrune = func(gID string) string { return EndpointGuilds + gID + "/prune" }
  68. EndpointGuildIcon = func(gID, hash string) string { return EndpointCDNIcons + gID + "/" + hash + ".png" }
  69. EndpointGuildIconAnimated = func(gID, hash string) string { return EndpointCDNIcons + gID + "/" + hash + ".gif" }
  70. EndpointGuildSplash = func(gID, hash string) string { return EndpointCDNSplashes + gID + "/" + hash + ".png" }
  71. EndpointGuildWebhooks = func(gID string) string { return EndpointGuilds + gID + "/webhooks" }
  72. EndpointGuildAuditLogs = func(gID string) string { return EndpointGuilds + gID + "/audit-logs" }
  73. EndpointGuildEmojis = func(gID string) string { return EndpointGuilds + gID + "/emojis" }
  74. EndpointGuildEmoji = func(gID, eID string) string { return EndpointGuilds + gID + "/emojis/" + eID }
  75. EndpointGuildBanner = func(gID, hash string) string { return EndpointCDNBanners + gID + "/" + hash + ".png" }
  76. EndpointGuildStickers = func(gID string) string { return EndpointGuilds + gID + "/stickers" }
  77. EndpointGuildSticker = func(gID, sID string) string { return EndpointGuilds + gID + "/stickers/" + sID }
  78. EndpointGuildScheduledEvents = func(gID string) string { return EndpointGuilds + gID + "/scheduled-events" }
  79. EndpointGuildScheduledEvent = func(gID, eID string) string { return EndpointGuilds + gID + "/scheduled-events/" + eID }
  80. EndpointGuildScheduledEventUsers = func(gID, eID string) string { return EndpointGuildScheduledEvent(gID, eID) + "/users" }
  81. EndpointGuildTemplate = func(tID string) string { return EndpointGuilds + "/templates/" + tID }
  82. EndpointGuildTemplates = func(gID string) string { return EndpointGuilds + gID + "/templates" }
  83. EndpointGuildTemplateSync = func(gID, tID string) string { return EndpointGuilds + gID + "/templates/" + tID }
  84. EndpointGuildMemberAvatar = func(gId, uID, aID string) string {
  85. return EndpointCDNGuilds + gId + "/users/" + uID + "/avatars/" + aID + ".png"
  86. }
  87. EndpointGuildMemberAvatarAnimated = func(gId, uID, aID string) string {
  88. return EndpointCDNGuilds + gId + "/users/" + uID + "/avatars/" + aID + ".gif"
  89. }
  90. EndpointChannel = func(cID string) string { return EndpointChannels + cID }
  91. EndpointChannelThreads = func(cID string) string { return EndpointChannel(cID) + "/threads" }
  92. EndpointChannelActiveThreads = func(cID string) string { return EndpointChannelThreads(cID) + "/active" }
  93. EndpointChannelPublicArchivedThreads = func(cID string) string { return EndpointChannelThreads(cID) + "/archived/public" }
  94. EndpointChannelPrivateArchivedThreads = func(cID string) string { return EndpointChannelThreads(cID) + "/archived/private" }
  95. EndpointChannelJoinedPrivateArchivedThreads = func(cID string) string { return EndpointChannel(cID) + "/users/@me/threads/archived/private" }
  96. EndpointChannelPermissions = func(cID string) string { return EndpointChannels + cID + "/permissions" }
  97. EndpointChannelPermission = func(cID, tID string) string { return EndpointChannels + cID + "/permissions/" + tID }
  98. EndpointChannelInvites = func(cID string) string { return EndpointChannels + cID + "/invites" }
  99. EndpointChannelTyping = func(cID string) string { return EndpointChannels + cID + "/typing" }
  100. EndpointChannelMessages = func(cID string) string { return EndpointChannels + cID + "/messages" }
  101. EndpointChannelMessage = func(cID, mID string) string { return EndpointChannels + cID + "/messages/" + mID }
  102. EndpointChannelMessageThread = func(cID, mID string) string { return EndpointChannelMessage(cID, mID) + "/threads" }
  103. EndpointChannelMessagesBulkDelete = func(cID string) string { return EndpointChannel(cID) + "/messages/bulk-delete" }
  104. EndpointChannelMessagesPins = func(cID string) string { return EndpointChannel(cID) + "/pins" }
  105. EndpointChannelMessagePin = func(cID, mID string) string { return EndpointChannel(cID) + "/pins/" + mID }
  106. EndpointChannelMessageCrosspost = func(cID, mID string) string { return EndpointChannel(cID) + "/messages/" + mID + "/crosspost" }
  107. EndpointChannelFollow = func(cID string) string { return EndpointChannel(cID) + "/followers" }
  108. EndpointThreadMembers = func(tID string) string { return EndpointChannel(tID) + "/thread-members" }
  109. EndpointThreadMember = func(tID, mID string) string { return EndpointThreadMembers(tID) + "/" + mID }
  110. EndpointGroupIcon = func(cID, hash string) string { return EndpointCDNChannelIcons + cID + "/" + hash + ".png" }
  111. EndpointSticker = func(sID string) string { return EndpointStickers + sID }
  112. EndpointNitroStickersPacks = EndpointAPI + "/sticker-packs"
  113. EndpointChannelWebhooks = func(cID string) string { return EndpointChannel(cID) + "/webhooks" }
  114. EndpointWebhook = func(wID string) string { return EndpointWebhooks + wID }
  115. EndpointWebhookToken = func(wID, token string) string { return EndpointWebhooks + wID + "/" + token }
  116. EndpointWebhookMessage = func(wID, token, messageID string) string {
  117. return EndpointWebhookToken(wID, token) + "/messages/" + messageID
  118. }
  119. EndpointMessageReactionsAll = func(cID, mID string) string {
  120. return EndpointChannelMessage(cID, mID) + "/reactions"
  121. }
  122. EndpointMessageReactions = func(cID, mID, eID string) string {
  123. return EndpointChannelMessage(cID, mID) + "/reactions/" + eID
  124. }
  125. EndpointMessageReaction = func(cID, mID, eID, uID string) string {
  126. return EndpointMessageReactions(cID, mID, eID) + "/" + uID
  127. }
  128. EndpointApplicationGlobalCommands = func(aID string) string {
  129. return EndpointApplication(aID) + "/commands"
  130. }
  131. EndpointApplicationGlobalCommand = func(aID, cID string) string {
  132. return EndpointApplicationGlobalCommands(aID) + "/" + cID
  133. }
  134. EndpointApplicationGuildCommands = func(aID, gID string) string {
  135. return EndpointApplication(aID) + "/guilds/" + gID + "/commands"
  136. }
  137. EndpointApplicationGuildCommand = func(aID, gID, cID string) string {
  138. return EndpointApplicationGuildCommands(aID, gID) + "/" + cID
  139. }
  140. EndpointApplicationCommandPermissions = func(aID, gID, cID string) string {
  141. return EndpointApplicationGuildCommand(aID, gID, cID) + "/permissions"
  142. }
  143. EndpointApplicationCommandsGuildPermissions = func(aID, gID string) string {
  144. return EndpointApplicationGuildCommands(aID, gID) + "/permissions"
  145. }
  146. EndpointInteraction = func(aID, iToken string) string {
  147. return EndpointAPI + "interactions/" + aID + "/" + iToken
  148. }
  149. EndpointInteractionResponse = func(iID, iToken string) string {
  150. return EndpointInteraction(iID, iToken) + "/callback"
  151. }
  152. EndpointInteractionResponseActions = func(aID, iToken string) string {
  153. return EndpointWebhookMessage(aID, iToken, "@original")
  154. }
  155. EndpointFollowupMessage = func(aID, iToken string) string {
  156. return EndpointWebhookToken(aID, iToken)
  157. }
  158. EndpointFollowupMessageActions = func(aID, iToken, mID string) string {
  159. return EndpointWebhookMessage(aID, iToken, mID)
  160. }
  161. EndpointGuildCreate = EndpointAPI + "guilds"
  162. EndpointInvite = func(iID string) string { return EndpointAPI + "invites/" + iID }
  163. EndpointEmoji = func(eID string) string { return EndpointCDN + "emojis/" + eID + ".png" }
  164. EndpointEmojiAnimated = func(eID string) string { return EndpointCDN + "emojis/" + eID + ".gif" }
  165. EndpointApplications = EndpointAPI + "applications"
  166. EndpointApplication = func(aID string) string { return EndpointApplications + "/" + aID }
  167. EndpointOAuth2 = EndpointAPI + "oauth2/"
  168. EndpointOAuth2Applications = EndpointOAuth2 + "applications"
  169. EndpointOAuth2Application = func(aID string) string { return EndpointOAuth2Applications + "/" + aID }
  170. EndpointOAuth2ApplicationsBot = func(aID string) string { return EndpointOAuth2Applications + "/" + aID + "/bot" }
  171. EndpointOAuth2ApplicationAssets = func(aID string) string { return EndpointOAuth2Applications + "/" + aID + "/assets" }
  172. // TODO: Deprecated, remove in the next release
  173. EndpointOauth2 = EndpointOAuth2
  174. EndpointOauth2Applications = EndpointOAuth2Applications
  175. EndpointOauth2Application = EndpointOAuth2Application
  176. EndpointOauth2ApplicationsBot = EndpointOAuth2ApplicationsBot
  177. EndpointOauth2ApplicationAssets = EndpointOAuth2ApplicationAssets
  178. )