Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.85 KB | None | 0 0
  1. const Endpoints = {
  2. User: userID => {
  3. if (userID.id) userID = userID.id;
  4. const base = `/users/${userID}`;
  5. return {
  6. toString: () => base,
  7. channels: `${base}/channels`,
  8. profile: `${base}/profile`,
  9. relationships: `${base}/relationships`,
  10. settings: `${base}/settings`,
  11. Relationship: uID => `${base}/relationships/${uID}`,
  12. Guild: guildID => ({
  13. toString: () => `${base}/guilds/${guildID}`,
  14. settings: `${base}/guilds/${guildID}/settings`,
  15. }),
  16. Note: id => `${base}/notes/${id}`,
  17. Mentions: (limit, roles, everyone, guildID) =>
  18. `${base}/mentions?limit=${limit}&roles=${roles}&everyone=${everyone}${guildID ? `&guild_id=${guildID}` : ''}`,
  19. Avatar: (root, hash) => {
  20. if (userID === '1') return hash;
  21. return Endpoints.CDN(root).Avatar(userID, hash);
  22. },
  23. };
  24. },
  25. guilds: '/guilds',
  26. Guild: guildID => {
  27. if (guildID.id) guildID = guildID.id;
  28. const base = `/guilds/${guildID}`;
  29. return {
  30. toString: () => base,
  31. prune: `${base}/prune`,
  32. embed: `${base}/embed`,
  33. bans: `${base}/bans`,
  34. integrations: `${base}/integrations`,
  35. members: `${base}/members`,
  36. channels: `${base}/channels`,
  37. invites: `${base}/invites`,
  38. roles: `${base}/roles`,
  39. emojis: `${base}/emojis`,
  40. search: `${base}/messages/search`,
  41. voiceRegions: `${base}/regions`,
  42. webhooks: `${base}/webhooks`,
  43. ack: `${base}/ack`,
  44. settings: `${base}/settings`,
  45. auditLogs: `${base}/audit-logs`,
  46. Emoji: emojiID => `${base}/emojis/${emojiID}`,
  47. Icon: (root, hash) => Endpoints.CDN(root).Icon(guildID, hash),
  48. Splash: (root, hash) => Endpoints.CDN(root).Splash(guildID, hash),
  49. Role: roleID => `${base}/roles/${roleID}`,
  50. Member: memberID => {
  51. if (memberID.id) memberID = memberID.id;
  52. const mbase = `${base}/members/${memberID}`;
  53. return {
  54. toString: () => mbase,
  55. Role: roleID => `${mbase}/roles/${roleID}`,
  56. nickname: `${base}/members/@me/nick`,
  57. };
  58. },
  59. };
  60. },
  61. channels: '/channels',
  62. Channel: channelID => {
  63. if (channelID.id) channelID = channelID.id;
  64. const base = `/channels/${channelID}`;
  65. return {
  66. toString: () => base,
  67. messages: {
  68. toString: () => `${base}/messages`,
  69. bulkDelete: `${base}/messages/bulk-delete`,
  70. },
  71. invites: `${base}/invites`,
  72. typing: `${base}/typing`,
  73. permissions: `${base}/permissions`,
  74. webhooks: `${base}/webhooks`,
  75. search: `${base}/messages/search`,
  76. pins: `${base}/pins`,
  77. Icon: (root, hash) => Endpoints.CDN(root).GDMIcon(channelID, hash),
  78. Pin: messageID => `${base}/pins/${messageID}`,
  79. Recipient: recipientID => `${base}/recipients/${recipientID}`,
  80. Message: messageID => {
  81. if (messageID.id) messageID = messageID.id;
  82. const mbase = `${base}/messages/${messageID}`;
  83. return {
  84. toString: () => mbase,
  85. reactions: `${mbase}/reactions`,
  86. ack: `${mbase}/ack`,
  87. Reaction: emoji => {
  88. const rbase = `${mbase}/reactions/${emoji}`;
  89. return {
  90. toString: () => rbase,
  91. User: userID => `${rbase}/${userID}`,
  92. };
  93. },
  94. };
  95. },
  96. };
  97. },
  98. Message: (m, c) => Endpoints.Channel(c).Message(m),
  99. Member: (m, g) => Endpoints.Guild(g).Member(m),
  100. CDN(root) {
  101. return {
  102. Emoji: (emojiID, format = 'png') => `${root}/emojis/${emojiID}.${format}`,
  103. Asset: name => `${root}/assets/${name}`,
  104. Avatar: (userID, hash) => `${root}/avatars/${userID}/${hash}.${hash.startsWith('a_') ? 'gif' : 'png?size=2048'}`,
  105. Icon: (guildID, hash) => `${root}/icons/${guildID}/${hash}.jpg`,
  106. AppIcon: (clientID, hash) => `${root}/app-icons/${clientID}/${hash}.png`,
  107. AppAsset: (clientID, hash) => `${root}/app-assets/${clientID}/${hash}.png`,
  108. GDMIcon: (channelID, hash) => `${root}/channel-icons/${channelID}/${hash}.jpg?size=2048`,
  109. Splash: (guildID, hash) => `${root}/splashes/${guildID}/${hash}.jpg`,
  110. };
  111. },
  112. OAUTH2: {
  113. Application: appID => {
  114. const base = `/oauth2/applications/${appID}`;
  115. return {
  116. toString: () => base,
  117. resetSecret: `${base}/reset`,
  118. resetToken: `${base}/bot/reset`,
  119. };
  120. },
  121. App: appID => `/oauth2/authorize?client_id=${appID}`,
  122. },
  123. login: '/auth/login',
  124. logout: '/auth/logout',
  125. voiceRegions: '/voice/regions',
  126. gateway: {
  127. toString: () => '/gateway',
  128. bot: '/gateway/bot',
  129. },
  130. Invite: (inviteID, withCounts = true) => `/invite/${inviteID}?with_counts=${withCounts}`,
  131. inviteLink: id => `https://discord.gg/${id}`,
  132. Webhook: (webhookID, token) => `/webhooks/${webhookID}${token ? `/${token}` : ''}`,
  133. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement