disgroove 1.3.1 → 1.3.3-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/README.md +1 -1
  2. package/dist/lib/Client.d.ts +234 -0
  3. package/dist/lib/Client.js +256 -0
  4. package/dist/lib/Client.js.map +1 -0
  5. package/dist/lib/constants.d.ts +1084 -0
  6. package/dist/lib/constants.js +1163 -0
  7. package/dist/lib/constants.js.map +1 -0
  8. package/dist/lib/gateway/Shard.d.ts +25 -0
  9. package/dist/lib/gateway/Shard.js +522 -0
  10. package/dist/lib/gateway/Shard.js.map +1 -0
  11. package/dist/lib/gateway/ShardsManager.d.ts +5 -0
  12. package/dist/lib/gateway/ShardsManager.js +13 -0
  13. package/dist/lib/gateway/ShardsManager.js.map +1 -0
  14. package/dist/lib/gateway/index.d.ts +2 -0
  15. package/dist/lib/gateway/index.js +19 -0
  16. package/dist/lib/gateway/index.js.map +1 -0
  17. package/dist/lib/index.d.ts +7 -0
  18. package/dist/lib/index.js +24 -0
  19. package/dist/lib/index.js.map +1 -0
  20. package/dist/lib/rest/CDN.d.ts +21 -0
  21. package/dist/lib/rest/CDN.js +46 -0
  22. package/dist/lib/rest/CDN.js.map +1 -0
  23. package/dist/lib/rest/Endpoints.d.ts +94 -0
  24. package/dist/lib/rest/Endpoints.js +211 -0
  25. package/dist/lib/rest/Endpoints.js.map +1 -0
  26. package/dist/lib/rest/REST.d.ts +22 -0
  27. package/dist/lib/rest/REST.js +35 -0
  28. package/dist/lib/rest/REST.js.map +1 -0
  29. package/dist/lib/rest/RequestsManager.d.ts +17 -0
  30. package/dist/lib/rest/RequestsManager.js +124 -0
  31. package/dist/lib/rest/RequestsManager.js.map +1 -0
  32. package/dist/lib/rest/index.d.ts +4 -0
  33. package/dist/lib/rest/index.js +34 -0
  34. package/dist/lib/rest/index.js.map +1 -0
  35. package/dist/lib/structures/Application.d.ts +174 -0
  36. package/dist/lib/structures/Application.js +328 -0
  37. package/dist/lib/structures/Application.js.map +1 -0
  38. package/dist/lib/structures/ApplicationCommand.d.ts +45 -0
  39. package/dist/lib/structures/ApplicationCommand.js +127 -0
  40. package/dist/lib/structures/ApplicationCommand.js.map +1 -0
  41. package/dist/lib/structures/AuditLog.d.ts +20 -0
  42. package/dist/lib/structures/AuditLog.js +76 -0
  43. package/dist/lib/structures/AuditLog.js.map +1 -0
  44. package/dist/lib/structures/AutoModerationRule.d.ts +34 -0
  45. package/dist/lib/structures/AutoModerationRule.js +96 -0
  46. package/dist/lib/structures/AutoModerationRule.js.map +1 -0
  47. package/dist/lib/structures/Base.d.ts +17 -0
  48. package/dist/lib/structures/Base.js +31 -0
  49. package/dist/lib/structures/Base.js.map +1 -0
  50. package/dist/lib/structures/Channel.d.ts +253 -0
  51. package/dist/lib/structures/Channel.js +591 -0
  52. package/dist/lib/structures/Channel.js.map +1 -0
  53. package/dist/lib/structures/ClientApplication.d.ts +150 -0
  54. package/dist/lib/structures/ClientApplication.js +241 -0
  55. package/dist/lib/structures/ClientApplication.js.map +1 -0
  56. package/dist/lib/structures/Emoji.d.ts +28 -0
  57. package/dist/lib/structures/Emoji.js +79 -0
  58. package/dist/lib/structures/Emoji.js.map +1 -0
  59. package/dist/lib/structures/Entitlement.d.ts +24 -0
  60. package/dist/lib/structures/Entitlement.js +68 -0
  61. package/dist/lib/structures/Entitlement.js.map +1 -0
  62. package/dist/lib/structures/Guild.d.ts +462 -0
  63. package/dist/lib/structures/Guild.js +1095 -0
  64. package/dist/lib/structures/Guild.js.map +1 -0
  65. package/dist/lib/structures/GuildMember.d.ts +50 -0
  66. package/dist/lib/structures/GuildMember.js +149 -0
  67. package/dist/lib/structures/GuildMember.js.map +1 -0
  68. package/dist/lib/structures/GuildScheduledEvent.d.ts +49 -0
  69. package/dist/lib/structures/GuildScheduledEvent.js +118 -0
  70. package/dist/lib/structures/GuildScheduledEvent.js.map +1 -0
  71. package/dist/lib/structures/GuildTemplate.d.ts +32 -0
  72. package/dist/lib/structures/GuildTemplate.js +76 -0
  73. package/dist/lib/structures/GuildTemplate.js.map +1 -0
  74. package/dist/lib/structures/Integration.d.ts +30 -0
  75. package/dist/lib/structures/Integration.js +102 -0
  76. package/dist/lib/structures/Integration.js.map +1 -0
  77. package/dist/lib/structures/Interaction.d.ts +76 -0
  78. package/dist/lib/structures/Interaction.js +345 -0
  79. package/dist/lib/structures/Interaction.js.map +1 -0
  80. package/dist/lib/structures/Invite.d.ts +28 -0
  81. package/dist/lib/structures/Invite.js +86 -0
  82. package/dist/lib/structures/Invite.js.map +1 -0
  83. package/dist/lib/structures/Message.d.ts +84 -0
  84. package/dist/lib/structures/Message.js +300 -0
  85. package/dist/lib/structures/Message.js.map +1 -0
  86. package/dist/lib/structures/Role.d.ts +37 -0
  87. package/dist/lib/structures/Role.js +90 -0
  88. package/dist/lib/structures/Role.js.map +1 -0
  89. package/dist/lib/structures/SKU.d.ts +23 -0
  90. package/dist/lib/structures/SKU.js +63 -0
  91. package/dist/lib/structures/SKU.js.map +1 -0
  92. package/dist/lib/structures/StageInstance.d.ts +24 -0
  93. package/dist/lib/structures/StageInstance.js +57 -0
  94. package/dist/lib/structures/StageInstance.js.map +1 -0
  95. package/dist/lib/structures/Sticker.d.ts +31 -0
  96. package/dist/lib/structures/Sticker.js +86 -0
  97. package/dist/lib/structures/Sticker.js.map +1 -0
  98. package/dist/lib/structures/Team.d.ts +14 -0
  99. package/dist/lib/structures/Team.js +39 -0
  100. package/dist/lib/structures/Team.js.map +1 -0
  101. package/dist/lib/structures/TestEntitlement.d.ts +23 -0
  102. package/dist/lib/structures/TestEntitlement.js +61 -0
  103. package/dist/lib/structures/TestEntitlement.js.map +1 -0
  104. package/dist/lib/structures/UnavailableGuild.d.ts +11 -0
  105. package/dist/lib/structures/UnavailableGuild.js +25 -0
  106. package/dist/lib/structures/UnavailableGuild.js.map +1 -0
  107. package/dist/lib/structures/User.d.ts +63 -0
  108. package/dist/lib/structures/User.js +177 -0
  109. package/dist/lib/structures/User.js.map +1 -0
  110. package/dist/lib/structures/VoiceState.d.ts +26 -0
  111. package/dist/lib/structures/VoiceState.js +70 -0
  112. package/dist/lib/structures/VoiceState.js.map +1 -0
  113. package/dist/lib/structures/Webhook.d.ts +84 -0
  114. package/dist/lib/structures/Webhook.js +239 -0
  115. package/dist/lib/structures/Webhook.js.map +1 -0
  116. package/dist/lib/structures/index.d.ts +27 -0
  117. package/dist/lib/structures/index.js +44 -0
  118. package/dist/lib/structures/index.js.map +1 -0
  119. package/dist/lib/types/application-command.d.ts +102 -0
  120. package/dist/lib/types/application-command.js +3 -0
  121. package/dist/lib/types/application-command.js.map +1 -0
  122. package/dist/lib/types/application-role-connection-metadata.d.ts +18 -0
  123. package/dist/lib/types/application-role-connection-metadata.js +3 -0
  124. package/dist/lib/types/application-role-connection-metadata.js.map +1 -0
  125. package/dist/lib/types/application.d.ts +66 -0
  126. package/dist/lib/types/application.js +3 -0
  127. package/dist/lib/types/application.js.map +1 -0
  128. package/dist/lib/types/audit-log.d.ts +82 -0
  129. package/dist/lib/types/audit-log.js +3 -0
  130. package/dist/lib/types/audit-log.js.map +1 -0
  131. package/dist/lib/types/auto-moderation.d.ts +65 -0
  132. package/dist/lib/types/auto-moderation.js +3 -0
  133. package/dist/lib/types/auto-moderation.js.map +1 -0
  134. package/dist/lib/types/channel.d.ts +456 -0
  135. package/dist/lib/types/channel.js +3 -0
  136. package/dist/lib/types/channel.js.map +1 -0
  137. package/dist/lib/types/emoji.d.ts +22 -0
  138. package/dist/lib/types/emoji.js +3 -0
  139. package/dist/lib/types/emoji.js.map +1 -0
  140. package/dist/lib/types/entitlements.d.ts +32 -0
  141. package/dist/lib/types/entitlements.js +3 -0
  142. package/dist/lib/types/entitlements.js.map +1 -0
  143. package/dist/lib/types/gateway-events.d.ts +805 -0
  144. package/dist/lib/types/gateway-events.js +3 -0
  145. package/dist/lib/types/gateway-events.js.map +1 -0
  146. package/dist/lib/types/guild-scheduled-event.d.ts +57 -0
  147. package/dist/lib/types/guild-scheduled-event.js +3 -0
  148. package/dist/lib/types/guild-scheduled-event.js.map +1 -0
  149. package/dist/lib/types/guild-template.d.ts +28 -0
  150. package/dist/lib/types/guild-template.js +3 -0
  151. package/dist/lib/types/guild-template.js.map +1 -0
  152. package/dist/lib/types/guild.d.ts +333 -0
  153. package/dist/lib/types/guild.js +3 -0
  154. package/dist/lib/types/guild.js.map +1 -0
  155. package/dist/lib/types/index.d.ts +23 -0
  156. package/dist/lib/types/index.js +40 -0
  157. package/dist/lib/types/index.js.map +1 -0
  158. package/dist/lib/types/interaction.d.ts +170 -0
  159. package/dist/lib/types/interaction.js +3 -0
  160. package/dist/lib/types/interaction.js.map +1 -0
  161. package/dist/lib/types/invite.d.ts +59 -0
  162. package/dist/lib/types/invite.js +3 -0
  163. package/dist/lib/types/invite.js.map +1 -0
  164. package/dist/lib/types/message-components.d.ts +100 -0
  165. package/dist/lib/types/message-components.js +3 -0
  166. package/dist/lib/types/message-components.js.map +1 -0
  167. package/dist/lib/types/role.d.ts +47 -0
  168. package/dist/lib/types/role.js +3 -0
  169. package/dist/lib/types/role.js.map +1 -0
  170. package/dist/lib/types/sku.d.ts +30 -0
  171. package/dist/lib/types/sku.js +3 -0
  172. package/dist/lib/types/sku.js.map +1 -0
  173. package/dist/lib/types/stage-instance.d.ts +20 -0
  174. package/dist/lib/types/stage-instance.js +3 -0
  175. package/dist/lib/types/stage-instance.js.map +1 -0
  176. package/dist/lib/types/sticker.d.ts +61 -0
  177. package/dist/lib/types/sticker.js +3 -0
  178. package/dist/lib/types/sticker.js.map +1 -0
  179. package/dist/lib/types/team.d.ts +30 -0
  180. package/dist/lib/types/team.js +3 -0
  181. package/dist/lib/types/team.js.map +1 -0
  182. package/dist/lib/types/user.d.ts +77 -0
  183. package/dist/lib/types/user.js +3 -0
  184. package/dist/lib/types/user.js.map +1 -0
  185. package/dist/lib/types/voice.d.ts +47 -0
  186. package/dist/lib/types/voice.js +3 -0
  187. package/dist/lib/types/voice.js.map +1 -0
  188. package/dist/lib/types/webhook.d.ts +31 -0
  189. package/dist/lib/types/webhook.js +3 -0
  190. package/dist/lib/types/webhook.js.map +1 -0
  191. package/dist/lib/utils/Util.d.ts +15 -0
  192. package/dist/lib/utils/Util.js +543 -0
  193. package/dist/lib/utils/Util.js.map +1 -0
  194. package/dist/lib/utils/errors.d.ts +12 -0
  195. package/dist/lib/utils/errors.js +25 -0
  196. package/dist/lib/utils/errors.js.map +1 -0
  197. package/dist/lib/utils/index.d.ts +2 -0
  198. package/dist/lib/utils/index.js +19 -0
  199. package/dist/lib/utils/index.js.map +1 -0
  200. package/dist/package.json +1 -1
  201. package/lib/Client.ts +616 -0
  202. package/lib/constants.ts +1173 -0
  203. package/lib/gateway/Shard.ts +704 -0
  204. package/lib/gateway/ShardsManager.ts +11 -0
  205. package/lib/gateway/index.ts +2 -0
  206. package/lib/index.ts +7 -0
  207. package/lib/rest/CDN.ts +56 -0
  208. package/lib/rest/Endpoints.ts +241 -0
  209. package/lib/rest/REST.ts +45 -0
  210. package/lib/rest/RequestsManager.ts +134 -0
  211. package/lib/rest/index.ts +4 -0
  212. package/lib/structures/Application.ts +599 -0
  213. package/lib/structures/ApplicationCommand.ts +187 -0
  214. package/lib/structures/AuditLog.ts +112 -0
  215. package/lib/structures/AutoModerationRule.ts +127 -0
  216. package/lib/structures/Base.ts +39 -0
  217. package/lib/structures/Channel.ts +921 -0
  218. package/lib/structures/ClientApplication.ts +515 -0
  219. package/lib/structures/Emoji.ts +95 -0
  220. package/lib/structures/Entitlement.ts +65 -0
  221. package/lib/structures/Guild.ts +1842 -0
  222. package/lib/structures/GuildMember.ts +193 -0
  223. package/lib/structures/GuildScheduledEvent.ts +164 -0
  224. package/lib/structures/GuildTemplate.ts +103 -0
  225. package/lib/structures/Integration.ts +136 -0
  226. package/lib/structures/Interaction.ts +506 -0
  227. package/lib/structures/Invite.ts +108 -0
  228. package/lib/structures/Message.ts +421 -0
  229. package/lib/structures/Role.ts +116 -0
  230. package/lib/structures/SKU.ts +63 -0
  231. package/lib/structures/StageInstance.ts +74 -0
  232. package/lib/structures/Sticker.ts +100 -0
  233. package/lib/structures/Team.ts +41 -0
  234. package/lib/structures/TestEntitlement.ts +78 -0
  235. package/lib/structures/UnavailableGuild.ts +27 -0
  236. package/lib/structures/User.ts +233 -0
  237. package/lib/structures/VoiceState.ts +72 -0
  238. package/lib/structures/Webhook.ts +341 -0
  239. package/lib/structures/index.ts +27 -0
  240. package/lib/types/application-command.ts +118 -0
  241. package/lib/types/application-role-connection-metadata.ts +23 -0
  242. package/lib/types/application.ts +77 -0
  243. package/lib/types/audit-log.ts +105 -0
  244. package/lib/types/auto-moderation.ts +78 -0
  245. package/lib/types/channel.ts +534 -0
  246. package/lib/types/emoji.ts +24 -0
  247. package/lib/types/entitlements.ts +34 -0
  248. package/lib/types/gateway-events.ts +970 -0
  249. package/lib/types/guild-scheduled-event.ts +67 -0
  250. package/lib/types/guild-template.ts +30 -0
  251. package/lib/types/guild.ts +388 -0
  252. package/lib/types/index.ts +23 -0
  253. package/lib/types/interaction.ts +224 -0
  254. package/lib/types/invite.ts +78 -0
  255. package/lib/types/message-components.ts +127 -0
  256. package/lib/types/role.ts +51 -0
  257. package/lib/types/sku.ts +32 -0
  258. package/lib/types/stage-instance.ts +22 -0
  259. package/lib/types/sticker.ts +67 -0
  260. package/lib/types/team.ts +34 -0
  261. package/lib/types/user.ts +93 -0
  262. package/lib/types/voice.ts +51 -0
  263. package/lib/types/webhook.ts +40 -0
  264. package/lib/utils/Util.ts +600 -0
  265. package/lib/utils/errors.ts +23 -0
  266. package/lib/utils/index.ts +2 -0
  267. package/package.json +1 -1
package/lib/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from "./gateway";
2
+ export * from "./rest";
3
+ export * from "./structures";
4
+ export * from "./types";
5
+ export * from "./utils";
6
+ export * from "./Client";
7
+ export * from "./constants";
@@ -0,0 +1,56 @@
1
+ export const achievementIcon = (
2
+ applicationId: string,
3
+ achievementId: string,
4
+ iconHash: string
5
+ ) =>
6
+ `app-assets/${applicationId}/achievements/${achievementId}/icons/${iconHash}.png` as const;
7
+ export const applicationAsset = (applicationId: string, assetId: string) =>
8
+ `app-assets/${applicationId}/${assetId}.png` as const;
9
+ export const applicationCover = (applicationId: string, coverImage: string) =>
10
+ `app-icons/${applicationId}/${coverImage}.png` as const;
11
+ export const applicationIcon = (applicationId: string, icon: string) =>
12
+ `app-icons/${applicationId}/${icon}.png` as const;
13
+ export const customEmoji = (emojiId: string) =>
14
+ `emojis/${emojiId}.png` as const;
15
+ export const defaultUserAvatar = (index: string) =>
16
+ `embed/avatars/${index}.png` as const;
17
+ export const guildBanner = (guildId: string, banner: string) =>
18
+ `banners/${guildId}/${banner}.png` as const;
19
+ export const guildDiscoverySplash = (guildId: string, splash: string) =>
20
+ `discovery-splashes/${guildId}/${splash}.png` as const;
21
+ export const guildIcon = (guildId: string, icon: string) =>
22
+ `icons/${guildId}/${icon}.png` as const;
23
+ export const guildMemberAvatar = (
24
+ guildId: string,
25
+ userId: string,
26
+ avatar: string
27
+ ) => `guilds/${guildId}/users/${userId}/avatars/${avatar}.png` as const;
28
+ export const guildMemberBanner = (
29
+ guildId: string,
30
+ userId: string,
31
+ banner: string
32
+ ) => `guilds/${guildId}/users/${userId}/banners/${banner}.png` as const;
33
+ export const guildScheduledEventCover = (
34
+ scheduledEventId: string,
35
+ coverImage: string
36
+ ) => `guild-events/${scheduledEventId}/${coverImage}.png` as const;
37
+ export const guildSplash = (guildId: string, splash: string) =>
38
+ `splashes/${guildId}/${splash}.png` as const;
39
+ export const roleIcon = (roleId: string, icon: string) =>
40
+ `role-icons/${roleId}/${icon}.png` as const;
41
+ export const stickerPackBanner = (assetId: string) =>
42
+ `app-assets/710982414301790216/store/${assetId}.png` as const;
43
+ export const sticker = (stickerId: string) =>
44
+ `stickers/${stickerId}.png` as const;
45
+ export const storePageAsset = (applicationId: string, assetId: string) =>
46
+ `app-assets/${applicationId}/store/${assetId}` as const;
47
+ export const teamIcon = (teamId: string, icon: string) =>
48
+ `team-icons/${teamId}/${icon}.png` as const;
49
+ export const userAvatar = (userId: string, avatar: string) =>
50
+ `avatars/${userId}/${avatar}.png` as const;
51
+ export const userAvatarDecoration = (
52
+ userId: string,
53
+ avatarDecoration: string
54
+ ) => `avatar-decorations/${userId}/${avatarDecoration}.png` as const;
55
+ export const userBanner = (userId: string, banner: string) =>
56
+ `banners/${userId}/${banner}.png` as const;
@@ -0,0 +1,241 @@
1
+ // Guilds
2
+ export const guild = (guildId: string) => `guilds/${guildId}` as const;
3
+ export const guilds = () => "guilds" as const;
4
+ export const guildActiveThreads = (guildId: string) =>
5
+ `guilds/${guildId}/threads/active` as const;
6
+ export const guildAuditLog = (guildId: string) =>
7
+ `guilds/${guildId}/audit-logs` as const;
8
+ export const guildAutoModerationRule = (guildId: string, ruleId: string) =>
9
+ `guilds/${guildId}/auto-moderation/rules/${ruleId}` as const;
10
+ export const guildAutoModerationRules = (guildId: string) =>
11
+ `guilds/${guildId}/auto-moderation/rules` as const;
12
+ export const guildBan = (guildId: string, userId: string) =>
13
+ `guilds/${guildId}/bans/${userId}` as const;
14
+ export const guildBans = (guildId: string) => `guilds/${guildId}/bans` as const;
15
+ export const guildChannels = (guildId: string) =>
16
+ `guilds/${guildId}/channels` as const;
17
+ export const guildCurrentMemberNickname = (guildId: string) =>
18
+ `guilds/${guildId}/members/@me/nick` as const;
19
+ export const guildEmoji = (guildId: string, emojiId: string) =>
20
+ `guilds/${guildId}/emojis/${emojiId}` as const;
21
+ export const guildEmojis = (guildId: string) =>
22
+ `guilds/${guildId}/emojis` as const;
23
+ export const guildIntegration = (guildId: string, integrationId: string) =>
24
+ `guilds/${guildId}/integrations/${integrationId}` as const;
25
+ export const guildIntegrations = (guildId: string) =>
26
+ `guilds/${guildId}/integrations` as const;
27
+ export const guildInvites = (guildId: string) =>
28
+ `guilds/${guildId}/invites` as const;
29
+ export const guildMFA = (guildId: string) => `guilds/${guildId}/mfa` as const;
30
+ export const guildMember = (guildId: string, userId: string | "@me" = "@me") =>
31
+ `guilds/${guildId}/members/${userId}` as const;
32
+ export const guildMemberRole = (
33
+ guildId: string,
34
+ memberId: string,
35
+ roleId: string
36
+ ) => `guilds/${guildId}/members/${memberId}/roles/${roleId}` as const;
37
+ export const guildMembers = (guildId: string) =>
38
+ `guilds/${guildId}/members` as const;
39
+ export const guildMembersSearch = (guildId: string) =>
40
+ `guilds/${guildId}/members/search` as const;
41
+ export const guildMemberVerification = (guildId: string) =>
42
+ `guilds/${guildId}/member-verification` as const;
43
+ export const guildOnboarding = (guildId: string) =>
44
+ `guilds/${guildId}/onboarding` as const;
45
+ export const guildPreview = (guildId: string) =>
46
+ `guilds/${guildId}/preview` as const;
47
+ export const guildPrune = (guildId: string) =>
48
+ `guilds/${guildId}/prune` as const;
49
+ export const guildRole = (guildId: string, roleId: string) =>
50
+ `guilds/${guildId}/roles/${roleId}` as const;
51
+ export const guildRoles = (guildId: string) =>
52
+ `guilds/${guildId}/roles` as const;
53
+ export const guildScheduledEvent = (
54
+ guildId: string,
55
+ guildScheduledEventId: string
56
+ ) => `guilds/${guildId}/scheduled-events/${guildScheduledEventId}` as const;
57
+ export const guildScheduledEvents = (guildId: string) =>
58
+ `guilds/${guildId}/scheduled-events` as const;
59
+ export const guildScheduledEventUsers = (
60
+ guildId: string,
61
+ guildScheduledEventId: string
62
+ ) =>
63
+ `guilds/${guildId}/scheduled-events/${guildScheduledEventId}/users` as const;
64
+ export const guildSticker = (guildId: string, stickerId: string) =>
65
+ `guilds/${guildId}/stickers/${stickerId}` as const;
66
+ export const guildStickers = (guildId: string) =>
67
+ `guilds/${guildId}/stickers` as const;
68
+ export const guildTemplate = (guildId: string, code: string) =>
69
+ `guilds/${guildId}/templates/${code}` as const;
70
+ export const guildTemplates = (guildId: string) =>
71
+ `guilds/${guildId}/templates` as const;
72
+ export const guildVanityURL = (guildId: string) =>
73
+ `guilds/${guildId}/vanity-url` as const;
74
+ export const guildVoiceRegions = (guildId: string) =>
75
+ `guilds/${guildId}/regions` as const;
76
+ export const guildVoiceState = (
77
+ guildId: string,
78
+ userId: string | "@me" = "@me"
79
+ ) => `guilds/${guildId}/voice-states/${userId}` as const;
80
+ export const guildWebhooks = (guildId: string) =>
81
+ `guilds/${guildId}/webhooks` as const;
82
+ export const guildWelcomeScreen = (guildId: string) =>
83
+ `guilds/${guildId}/welcome-screen` as const;
84
+ export const guildWidgetImage = (guildId: string) =>
85
+ `guilds/${guildId}/widget.png` as const;
86
+
87
+ export const guildWidgetJSON = (guildId: string) =>
88
+ `guilds/${guildId}/widget.json` as const;
89
+ export const guildWidgetSettings = (guildId: string) =>
90
+ `guilds/${guildId}/widget` as const;
91
+ export const template = (code: string) => `guilds/templates/${code}` as const;
92
+
93
+ // Channels
94
+ export const channel = (channelId: string) => `channels/${channelId}` as const;
95
+ export const channelBulkDelete = (channelId: string) =>
96
+ `channels/${channelId}/messages/bulk-delete` as const;
97
+ export const channelFollowers = (channelId: string) =>
98
+ `channels/${channelId}/followers` as const;
99
+ export const channelInvites = (channelId: string) =>
100
+ `channels/${channelId}/invites` as const;
101
+ export const channelMessage = (channelId: string, messageId: string) =>
102
+ `channels/${channelId}/messages/${messageId}` as const;
103
+ export const channelMessageAllReactions = (
104
+ channelId: string,
105
+ messageId: string,
106
+ emoji?: string
107
+ ) =>
108
+ emoji
109
+ ? (`channels/${channelId}/messages/${messageId}/reactions/${emoji}` as const)
110
+ : (`channels/${channelId}/messages/${messageId}/reactions` as const);
111
+ export const channelMessageCrosspost = (channelId: string, messageId: string) =>
112
+ `channels/${channelId}/messages/${messageId}/crosspost` as const;
113
+ export const channelMessageReaction = (
114
+ channelId: string,
115
+ messageId: string,
116
+ emoji: string,
117
+ userId: string | "@me" = "@me"
118
+ ) =>
119
+ `channels/${channelId}/messages/${messageId}/reactions/${emoji}/${userId}` as const;
120
+ export const channelMessages = (channelId: string) =>
121
+ `channels/${channelId}/messages` as const;
122
+ export const channelPermission = (channelId: string, overwriteId: string) =>
123
+ `channels/${channelId}/permissions/${overwriteId}` as const;
124
+ export const channelPin = (channelId: string, messageId: string) =>
125
+ `channels/${channelId}/pins/${messageId}` as const;
126
+ export const channelPins = (channelId: string) =>
127
+ `channels/${channelId}/pins` as const;
128
+ export const channelRecipient = (channelId: string, userId: string) =>
129
+ `channels/${channelId}/recipients/${userId}` as const;
130
+ export const channelThreads = (
131
+ channelId: string,
132
+ archivedStatus: "public" | "private",
133
+ joined: boolean
134
+ ) =>
135
+ joined
136
+ ? (`channels/${channelId}/users/@me/threads/archived/${archivedStatus}` as const)
137
+ : (`channels/${channelId}/threads/archived/${archivedStatus}` as const);
138
+ export const channelTyping = (channelId: string) =>
139
+ `channels/${channelId}/typing` as const;
140
+ export const channelWebhooks = (channelId: string) =>
141
+ `channels/${channelId}/webhooks` as const;
142
+ export const threads = (channelId: string, messageId?: string) =>
143
+ messageId
144
+ ? (`channels/${channelId}/messages/${messageId}/threads` as const)
145
+ : (`channels/${channelId}/threads` as const);
146
+ export const threadMembers = (threadId: string, userId?: string | "@me") =>
147
+ userId
148
+ ? (`channels/${threadId}/thread-members` as const)
149
+ : (`channels/${threadId}/thread-members/${userId}` as const);
150
+
151
+ // Users
152
+ export const user = (userId: string | "@me" = "@me") =>
153
+ `users/${userId}` as const;
154
+ export const userApplicationRoleConnection = (applicationId: string) =>
155
+ `users/@me/applications/${applicationId}/role-connection` as const;
156
+ export const userChannels = () => "users/@me/channels" as const;
157
+ export const userConnections = () => "users/@me/connections" as const;
158
+ export const userGuild = (guildId: string) =>
159
+ `users/@me/guilds/${guildId}` as const;
160
+ export const userGuilds = () => "users/@me/guilds" as const;
161
+
162
+ // Applications
163
+
164
+ export const applicationCommand = (applicationId: string, commandId: string) =>
165
+ `applications/${applicationId}/commands/${commandId}` as const;
166
+ export const applicationCommands = (applicationId: string) =>
167
+ `applications/${applicationId}/commands` as const;
168
+ export const applicationCommandPermissions = (
169
+ applicationId: string,
170
+ guildId: string,
171
+ commandId: string
172
+ ) =>
173
+ `applications/${applicationId}/guilds/${guildId}/commands/${commandId}/permissions` as const;
174
+ export const applicationCurrentUser = () => "applications/@me" as const;
175
+ export const applicationEntitlement = (
176
+ applicationId: string,
177
+ entitlementId: string
178
+ ) => `applications/${applicationId}/entitlements/${entitlementId}` as const;
179
+ export const applicationEntitlements = (applicationId: string) =>
180
+ `applications/${applicationId}/entitlements` as const;
181
+ export const applicationGuildCommand = (
182
+ applicationId: string,
183
+ guildId: string,
184
+ commandId: string
185
+ ) =>
186
+ `applications/${applicationId}/guilds/${guildId}/commands/${commandId}` as const;
187
+ export const applicationGuildCommands = (
188
+ applicationId: string,
189
+ guildId: string
190
+ ) => `applications/${applicationId}/guilds/${guildId}/commands` as const;
191
+ export const applicationRoleConnectionMetadata = (applicationId: string) =>
192
+ `applications/${applicationId}/role-connections/metadata` as const;
193
+ export const applicationSKUs = (applicationId: string) =>
194
+ `applications/${applicationId}/skus` as const;
195
+ export const guildApplicationCommandsPermissions = (
196
+ applicationId: string,
197
+ guildId: string
198
+ ) =>
199
+ `applications/${applicationId}/guilds/${guildId}/commands/permissions` as const;
200
+
201
+ // Webhooks
202
+ export const webhook = (webhookId: string, webhookToken?: string) =>
203
+ webhookToken
204
+ ? (`webhooks/${webhookId}/${webhookToken}` as const)
205
+ : (`webhooks/${webhookId}` as const);
206
+ export const webhookMessage = (
207
+ webhookId: string,
208
+ webhookToken: string,
209
+ messageId: string | "@original" = "@original"
210
+ ) => `webhooks/${webhookId}/${webhookToken}/messages/${messageId}` as const;
211
+ export const webhookPlatform = (
212
+ webhookId: string,
213
+ webhookToken: string,
214
+ platform: "github" | "slack"
215
+ ) => `webhooks/${webhookId}/${webhookToken}/${platform}` as const;
216
+
217
+ // Gateway
218
+ export const gateway = () => "gateway" as const;
219
+ export const gatewayBot = () => "gateway/bot" as const;
220
+
221
+ // OAuth2
222
+ export const oauth2Authorization = () => "oauth2/authorize" as const;
223
+
224
+ export const oauth2CurrentApplication = () =>
225
+ `oauth2/applications/@me` as const;
226
+ export const oauth2CurrentAuthorization = () => "oauth2/@me" as const;
227
+ export const oauth2TokenExchange = () => "oauth2/token" as const;
228
+ export const oauth2TokenRevocation = () => "oauth2/token/revoke" as const;
229
+
230
+ // Misc
231
+ export const interactionCallback = (
232
+ interactionId: string,
233
+ interactionToken: string
234
+ ) => `interactions/${interactionId}/${interactionToken}/callback` as const;
235
+ export const invite = (code: string) => `invites/${code}` as const;
236
+ export const stageInstance = (channelId: string) =>
237
+ `stage-instances/${channelId}` as const;
238
+ export const stageInstances = () => "stage-instances" as const;
239
+ export const sticker = (stickerId: string) => `stickers/${stickerId}` as const;
240
+ export const stickerPacks = () => "sticker-packs" as const;
241
+ export const voiceRegions = () => "voice/regions" as const;
@@ -0,0 +1,45 @@
1
+ import { RequestData, RequestsManager } from ".";
2
+
3
+ export interface File {
4
+ contents: Buffer;
5
+ name: string;
6
+ }
7
+
8
+ export enum RESTMethods {
9
+ Get = "GET",
10
+ Post = "POST",
11
+ Delete = "DELETE",
12
+ Patch = "PATCH",
13
+ Put = "PUT",
14
+ }
15
+
16
+ export class REST {
17
+ manager: RequestsManager;
18
+
19
+ constructor(token: string, auth: "Bot" | "Bearer") {
20
+ this.manager = new RequestsManager(token, auth);
21
+ }
22
+
23
+ get<T>(
24
+ endpoint: string,
25
+ data?: Pick<RequestData, "query" | "authorization">
26
+ ): Promise<T> {
27
+ return this.manager.request<T>(RESTMethods.Get, endpoint, data);
28
+ }
29
+
30
+ post<T>(endpoint: string, data?: RequestData): Promise<T> {
31
+ return this.manager.request<T>(RESTMethods.Post, endpoint, data);
32
+ }
33
+
34
+ delete<T>(endpoint: string, data?: RequestData): Promise<T> {
35
+ return this.manager.request<T>(RESTMethods.Delete, endpoint, data);
36
+ }
37
+
38
+ patch<T>(endpoint: string, data?: RequestData): Promise<T> {
39
+ return this.manager.request<T>(RESTMethods.Patch, endpoint, data);
40
+ }
41
+
42
+ put<T>(endpoint: string, data?: RequestData): Promise<T> {
43
+ return this.manager.request<T>(RESTMethods.Put, endpoint, data);
44
+ }
45
+ }
@@ -0,0 +1,134 @@
1
+ import { File, RESTMethods } from ".";
2
+ import { fetch, FormData, File as UndiciFile } from "undici";
3
+ import { HTTPResponseCodes } from "../constants";
4
+ import { HTTPError, RESTError } from "../utils";
5
+ import * as pkg from "../../package.json";
6
+
7
+ export interface RequestData {
8
+ json?: unknown;
9
+ form?: FormData;
10
+ files?: Array<File> | null;
11
+ reason?: string;
12
+ query?: Partial<Record<string, string | number | boolean | Array<string>>>;
13
+ authorization?: boolean;
14
+ }
15
+
16
+ export class RequestsManager {
17
+ token: string;
18
+ auth: "Bot" | "Bearer";
19
+ globalBlock: boolean = false;
20
+
21
+ constructor(token: string, auth: "Bot" | "Bearer") {
22
+ this.token = token;
23
+ this.auth = auth;
24
+ }
25
+
26
+ request<T = unknown>(
27
+ method: RESTMethods,
28
+ endpoint: string,
29
+ data?: RequestData
30
+ ): Promise<T> {
31
+ return new Promise<T>(async (resolve, reject) => {
32
+ if (this.globalBlock && !endpoint.startsWith("interactions")) return;
33
+
34
+ let url: URL = new URL(`https://discord.com/api/v10/${endpoint}`);
35
+
36
+ if (data?.query)
37
+ for (const [key, value] of Object.entries(data.query))
38
+ if (value !== undefined) url.searchParams.set(key, String(value));
39
+
40
+ let headers: Record<string, string> = {
41
+ "User-Agent": `DiscordBot (https://github.com/XenKys/disgroove, ${pkg.version})`,
42
+ Authorization: `${this.auth} ${this.token}`,
43
+ };
44
+ let body: string | FormData | undefined;
45
+
46
+ if (data?.authorization === false) delete headers["Authorization"];
47
+
48
+ if (method !== RESTMethods.Get) {
49
+ if (data?.form || (data?.files && data?.files?.length !== 0)) {
50
+ const formData = data.form ?? new FormData();
51
+
52
+ if (data?.files && data?.files?.length !== 0) {
53
+ for (let i = 0; i < data?.files.length; i++) {
54
+ const file = data?.files[i];
55
+
56
+ formData?.set(
57
+ `files[${i}]`,
58
+ new UndiciFile([file.contents], file.name)
59
+ );
60
+ }
61
+
62
+ if (data?.json)
63
+ formData?.set("payload_json", JSON.stringify(data?.json));
64
+ }
65
+
66
+ body = formData;
67
+ } else {
68
+ body = JSON.stringify(data?.json);
69
+
70
+ headers["Content-Type"] = "application/json";
71
+ }
72
+
73
+ if (data?.reason !== undefined)
74
+ headers["X-Audit-Log-Reason"] = data?.reason;
75
+ }
76
+
77
+ try {
78
+ const response = await fetch(url.href, {
79
+ method,
80
+ body,
81
+ headers,
82
+ });
83
+
84
+ if (response.headers.has("X-RateLimit-Global")) {
85
+ this.globalBlock = true;
86
+
87
+ setTimeout(() => {
88
+ this.globalBlock = false;
89
+ }, Number(response.headers.get("Retry-After")) * 1000);
90
+ }
91
+
92
+ if (response.status >= HTTPResponseCodes.NotModified) {
93
+ if (response.status === HTTPResponseCodes.TooManyRequests) {
94
+ setTimeout(
95
+ () =>
96
+ this.request<T>(method, endpoint, data)
97
+ .then(resolve)
98
+ .catch(reject),
99
+ Number(response.headers.get("Retry-After")) * 1000
100
+ );
101
+ } else if (response.status === HTTPResponseCodes.GatewayUnavailable) {
102
+ setTimeout(
103
+ () =>
104
+ this.request<T>(method, endpoint, data)
105
+ .then(resolve)
106
+ .catch(reject),
107
+ 5 * 1000
108
+ );
109
+ } else {
110
+ const responseJSON = await response.json();
111
+
112
+ reject(
113
+ responseJSON &&
114
+ typeof responseJSON === "object" &&
115
+ "code" in responseJSON &&
116
+ "message" in responseJSON &&
117
+ responseJSON.code !== 0
118
+ ? new RESTError(
119
+ `[${responseJSON.code}] ${responseJSON.message}`
120
+ )
121
+ : new HTTPError(`[${response.status}] ${response.statusText}`)
122
+ );
123
+ }
124
+ } else if (response.status === HTTPResponseCodes.NoContent) {
125
+ resolve(null as T);
126
+ } else {
127
+ resolve((await response.json()) as T);
128
+ }
129
+ } catch (err) {
130
+ reject(err);
131
+ }
132
+ });
133
+ }
134
+ }
@@ -0,0 +1,4 @@
1
+ export * as CDN from "./CDN";
2
+ export * as Endpoints from "./Endpoints";
3
+ export * from "./RequestsManager";
4
+ export * from "./REST";