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
@@ -0,0 +1,600 @@
1
+ import type {
2
+ JSONActionRow,
3
+ JSONApplicationCommand,
4
+ JSONAttachment,
5
+ JSONChannel,
6
+ JSONEmbed,
7
+ JSONEmoji,
8
+ JSONRole,
9
+ JSONUser,
10
+ PresenceUpdateEventFields,
11
+ RawActionRow,
12
+ RawApplicationCommand,
13
+ RawAttachment,
14
+ RawChannel,
15
+ RawEmbed,
16
+ RawEmoji,
17
+ RawPresenceUpdateEventFields,
18
+ RawRole,
19
+ RawUser,
20
+ } from "../types";
21
+ import { ComponentTypes } from "../constants";
22
+ import { User } from "../structures";
23
+ import type { Client } from "../Client";
24
+
25
+ export class Util {
26
+ applicationCommandToRaw(
27
+ command: Partial<JSONApplicationCommand>
28
+ ): Partial<RawApplicationCommand> {
29
+ return {
30
+ id: command.id,
31
+ type: command.type,
32
+ application_id: command.applicationId,
33
+ guild_id: command.guildId,
34
+ name: command.name,
35
+ name_localizations: command.nameLocalizations,
36
+ description: command.description,
37
+ description_localizations: command.descriptionLocalizations,
38
+ options: command.options?.map((option) => ({
39
+ type: option.type,
40
+ name: option.name,
41
+ name_localizations: option.nameLocalizations,
42
+ description: option.description,
43
+ description_localizations: option.descriptionLocalizations,
44
+ required: option.required,
45
+ choices: option.choices?.map((choice) => ({
46
+ name: choice.name,
47
+ name_localizations: choice.nameLocalizations,
48
+ value: choice.value,
49
+ })),
50
+ options: option.options?.map((o) => ({
51
+ type: o.type,
52
+ name: o.name,
53
+ name_localizations: o.nameLocalizations,
54
+ description: o.description,
55
+ description_localizations: o.descriptionLocalizations,
56
+ required: o.required,
57
+ choices: o.choices?.map((choice) => ({
58
+ name: choice.name,
59
+ name_localizations: choice.nameLocalizations,
60
+ value: choice.value,
61
+ })),
62
+ channel_types: o.channelTypes,
63
+ min_value: o.minValue,
64
+ max_value: o.maxValue,
65
+ min_length: o.minLength,
66
+ max_length: o.maxLength,
67
+ autocomplete: o.autocomplete,
68
+ })),
69
+ channel_types: option.channelTypes,
70
+ min_value: option.minValue,
71
+ max_value: option.maxValue,
72
+ min_length: option.minLength,
73
+ max_length: option.maxLength,
74
+ autocomplete: option.autocomplete,
75
+ })),
76
+ default_member_permissions: command.defaultMemberPermissions,
77
+ dm_permission: command.dmPermission,
78
+ default_permission: command.defaultPermission,
79
+ nsfw: command.nsfw,
80
+ version: command.version,
81
+ };
82
+ }
83
+
84
+ attachmentToJSON(attachment: RawAttachment): JSONAttachment {
85
+ return {
86
+ id: attachment.id,
87
+ filename: attachment.filename,
88
+ description: attachment.description,
89
+ contentType: attachment.content_type,
90
+ size: attachment.size,
91
+ url: attachment.url,
92
+ proxyURL: attachment.proxy_url,
93
+ height: attachment.height,
94
+ width: attachment.width,
95
+ ephemeral: attachment.ephemeral,
96
+ durationSecs: attachment.duration_secs,
97
+ waveform: attachment.waveform,
98
+ flags: attachment.flags,
99
+ };
100
+ }
101
+
102
+ channelToRaw(channel: JSONChannel): RawChannel {
103
+ return {
104
+ id: channel.id,
105
+ type: channel.type,
106
+ guild_id: channel.guildId,
107
+ position: channel.position,
108
+ permission_overwrites: channel.permissionOverwrites?.map((overwrite) => ({
109
+ id: overwrite.id,
110
+ type: overwrite.type,
111
+ allow: overwrite.allow,
112
+ deny: overwrite.deny,
113
+ })),
114
+ name: channel.name,
115
+ topic: channel.topic,
116
+ nsfw: channel.nsfw,
117
+ last_message_id: channel.lastMessageId,
118
+ bitrate: channel.bitrate,
119
+ user_limit: channel.userLimit,
120
+ rate_limit_per_user: channel.rateLimitPerUser,
121
+ recipients: channel.recipients?.map((recipient) =>
122
+ this.userToRaw(recipient)
123
+ ),
124
+ icon: channel.icon,
125
+ owner_id: channel.ownerId,
126
+ application_id: channel.applicationId,
127
+ managed: channel.managed,
128
+ parent_id: channel.parentId,
129
+ last_pin_timestamp: channel.lastPinTimestamp,
130
+ rtc_region: channel.rtcRegion,
131
+ video_quality_mode: channel.videoQualityMode,
132
+ message_count: channel.messageCount,
133
+ member_count: channel.memberCount,
134
+ thread_metadata:
135
+ channel.threadMetadata !== undefined
136
+ ? {
137
+ archived: channel.threadMetadata?.archived,
138
+ auto_archive_duration:
139
+ channel.threadMetadata?.autoArchiveDuration,
140
+ archive_timestamp: channel.threadMetadata?.archiveTimestamp,
141
+ locked: channel.threadMetadata?.locked,
142
+ invitable: channel.threadMetadata?.invitable,
143
+ create_timestamp: channel.threadMetadata?.createTimestamp,
144
+ }
145
+ : undefined,
146
+ member:
147
+ channel.member !== undefined
148
+ ? {
149
+ id: channel.member.id,
150
+ user_id: channel.member.userId,
151
+ join_timestamp: channel.member.joinTimestamp,
152
+ flags: channel.member.flags,
153
+ member:
154
+ channel.member.member !== undefined
155
+ ? {
156
+ user:
157
+ channel.member.member.user !== undefined
158
+ ? this.userToRaw(channel.member.member.user)
159
+ : undefined,
160
+ nick: channel.member.member.nick,
161
+ avatar: channel.member.member.avatar,
162
+ roles: channel.member.member.roles,
163
+ joined_at: channel.member.member.joinedAt,
164
+ premium_since: channel.member.member.premiumSince,
165
+ deaf: channel.member.member.deaf,
166
+ mute: channel.member.member.mute,
167
+ flags: channel.member.member.flags,
168
+ pending: channel.member.member.pending,
169
+ permissions: channel.member.member.permissions,
170
+ communication_disabled_until:
171
+ channel.member.member.communicationDisabledUntil,
172
+ }
173
+ : undefined,
174
+ }
175
+ : undefined,
176
+ default_auto_archive_duration: channel.defaultAutoArchiveDuration,
177
+ permissions: channel.permissions,
178
+ flags: channel.flags,
179
+ total_message_sent: channel.totalMessageSent,
180
+ available_tags: channel.availableTags?.map((availableTag) => ({
181
+ id: availableTag.id,
182
+ name: availableTag.name,
183
+ moderated: availableTag.moderated,
184
+ emoji_id: availableTag.emojiId,
185
+ emoji_name: availableTag.emojiName,
186
+ })),
187
+ applied_tags: channel.appliedTags,
188
+ default_reaction_emoji:
189
+ channel.defaultReactionEmoji !== undefined
190
+ ? channel.defaultReactionEmoji !== null
191
+ ? {
192
+ emoji_id: channel.defaultReactionEmoji.emojiId,
193
+ emoji_name: channel.defaultReactionEmoji.emojiName,
194
+ }
195
+ : null
196
+ : undefined,
197
+ default_thread_rate_limit_per_user: channel.defaultThreadRateLimitPerUser,
198
+ default_sort_order: channel.defaultSortOrder,
199
+ default_forum_layout: channel.defaultForumLayout,
200
+ };
201
+ }
202
+
203
+ embedsToJSON(embeds: Array<RawEmbed>): Array<JSONEmbed> {
204
+ return embeds.map((embed) => ({
205
+ title: embed.title,
206
+ type: embed.type,
207
+ description: embed.description,
208
+ url: embed.url,
209
+ timestamp: embed.timestamp,
210
+ color: embed.color,
211
+ footer:
212
+ embed.footer !== undefined
213
+ ? {
214
+ text: embed.footer.text,
215
+ iconURL: embed.footer.icon_url,
216
+ proxyIconURL: embed.footer.proxy_icon_url,
217
+ }
218
+ : undefined,
219
+ image:
220
+ embed.image !== undefined
221
+ ? {
222
+ url: embed.image.url,
223
+ proxyURL: embed.image.proxy_url,
224
+ height: embed.image.height,
225
+ width: embed.image.width,
226
+ }
227
+ : undefined,
228
+ thumbnail:
229
+ embed.thumbnail !== undefined
230
+ ? {
231
+ url: embed.thumbnail.url,
232
+ proxyURL: embed.thumbnail.proxy_url,
233
+ height: embed.thumbnail.height,
234
+ width: embed.thumbnail.width,
235
+ }
236
+ : undefined,
237
+ video: {
238
+ url: embed.video?.url,
239
+ proxyURL: embed.video?.proxy_url,
240
+ height: embed.video?.height,
241
+ width: embed.video?.width,
242
+ },
243
+ provider: {
244
+ name: embed.provider?.name,
245
+ url: embed.provider?.url,
246
+ },
247
+ author:
248
+ embed.author !== undefined
249
+ ? {
250
+ name: embed.author.name,
251
+ url: embed.author.url,
252
+ iconURL: embed.author.icon_url,
253
+ proxyIconURL: embed.author.proxy_icon_url,
254
+ }
255
+ : undefined,
256
+ fields: embed.fields?.map((field) => ({
257
+ name: field.name,
258
+ value: field.value,
259
+ inline: field.inline,
260
+ })),
261
+ }));
262
+ }
263
+
264
+ embedsToRaw(embeds: Array<JSONEmbed>): Array<RawEmbed> {
265
+ return embeds.map((embed) => ({
266
+ title: embed.title,
267
+ type: embed.type,
268
+ description: embed.description,
269
+ url: embed.url,
270
+ timestamp: embed.timestamp,
271
+ color: embed.color,
272
+ footer:
273
+ embed.footer !== undefined
274
+ ? {
275
+ text: embed.footer.text,
276
+ icon_url: embed.footer.iconURL,
277
+ proxy_icon_url: embed.footer.proxyIconURL,
278
+ }
279
+ : undefined,
280
+ image:
281
+ embed.image !== undefined
282
+ ? {
283
+ url: embed.image.url,
284
+ proxy_url: embed.image.proxyURL,
285
+ height: embed.image.height,
286
+ width: embed.image.width,
287
+ }
288
+ : undefined,
289
+ thumbnail:
290
+ embed.thumbnail !== undefined
291
+ ? {
292
+ url: embed.thumbnail.url,
293
+ proxy_url: embed.thumbnail.proxyURL,
294
+ height: embed.thumbnail.height,
295
+ width: embed.thumbnail.width,
296
+ }
297
+ : undefined,
298
+ video: {
299
+ url: embed.video?.url,
300
+ proxy_url: embed.video?.proxyURL,
301
+ height: embed.video?.height,
302
+ width: embed.video?.width,
303
+ },
304
+ provider: {
305
+ name: embed.provider?.name,
306
+ url: embed.provider?.url,
307
+ },
308
+ author:
309
+ embed.author !== undefined
310
+ ? {
311
+ name: embed.author.name,
312
+ url: embed.author.url,
313
+ icon_url: embed.author.iconURL,
314
+ proxy_icon_url: embed.author.proxyIconURL,
315
+ }
316
+ : undefined,
317
+ fields: embed.fields?.map((field) => ({
318
+ name: field.name,
319
+ value: field.value,
320
+ inline: field.inline,
321
+ })),
322
+ }));
323
+ }
324
+
325
+ emojiToRaw(emoji: JSONEmoji): RawEmoji {
326
+ return {
327
+ id: emoji.id,
328
+ name: emoji.name,
329
+ roles: emoji.roles,
330
+ user: emoji.user !== undefined ? this.userToRaw(emoji.user) : undefined,
331
+ require_colons: emoji.requireColons,
332
+ managed: emoji.managed,
333
+ animated: emoji.animated,
334
+ available: emoji.available,
335
+ };
336
+ }
337
+
338
+ messageComponentsToJSON(
339
+ components: Array<RawActionRow>
340
+ ): Array<JSONActionRow> {
341
+ return components.map((component) => ({
342
+ type: component.type,
343
+ components: component.components.map((c) => {
344
+ switch (c.type) {
345
+ case ComponentTypes.Button: {
346
+ return {
347
+ type: c.type,
348
+ style: c.style,
349
+ label: c.label,
350
+ emoji:
351
+ c.emoji !== undefined
352
+ ? {
353
+ name: c.emoji.name,
354
+ id: c.emoji.id,
355
+ animated: c.emoji.animated,
356
+ }
357
+ : undefined,
358
+ customId: c.custom_id,
359
+ url: c.url,
360
+ disabled: c.disabled,
361
+ };
362
+ }
363
+ case ComponentTypes.TextInput: {
364
+ return {
365
+ type: c.type,
366
+ customId: c.custom_id,
367
+ style: c.style,
368
+ label: c.label,
369
+ minLength: c.min_length,
370
+ maxLength: c.max_length,
371
+ required: c.required,
372
+ value: c.value,
373
+ placeholder: c.placeholder,
374
+ };
375
+ }
376
+ case ComponentTypes.ChannelSelect: {
377
+ return {
378
+ type: c.type,
379
+ customId: c.custom_id,
380
+ channelTypes: c.channel_types,
381
+ placeholder: c.placeholder,
382
+ defaultValues: c.default_values,
383
+ minValues: c.min_values,
384
+ maxValues: c.max_values,
385
+ disabled: c.disabled,
386
+ };
387
+ }
388
+ case ComponentTypes.StringSelect: {
389
+ return {
390
+ type: c.type,
391
+ customId: c.custom_id,
392
+ placeholder: c.placeholder,
393
+ options: c.options?.map((option) => ({
394
+ label: option.label,
395
+ value: option.value,
396
+ description: option.description,
397
+ emoji:
398
+ option.emoji !== undefined
399
+ ? {
400
+ name: option.emoji.name,
401
+ id: option.emoji.id,
402
+ animated: option.emoji.animated,
403
+ }
404
+ : undefined,
405
+ default: option.default,
406
+ })),
407
+ minValues: c.min_values,
408
+ maxValues: c.max_values,
409
+ disabled: c.disabled,
410
+ };
411
+ }
412
+ case ComponentTypes.MentionableSelect:
413
+ case ComponentTypes.RoleSelect:
414
+ case ComponentTypes.UserSelect: {
415
+ return {
416
+ type: c.type,
417
+ customId: c.custom_id,
418
+ placeholder: c.placeholder,
419
+ defaultValues: c.default_values,
420
+ minValues: c.min_values,
421
+ maxValues: c.max_values,
422
+ disabled: c.disabled,
423
+ };
424
+ }
425
+ }
426
+ }),
427
+ }));
428
+ }
429
+
430
+ messageComponentsToRaw(
431
+ components: Array<JSONActionRow>
432
+ ): Array<RawActionRow> {
433
+ return components.map((component) => ({
434
+ type: component.type,
435
+ components: component.components.map((c) => {
436
+ switch (c.type) {
437
+ case ComponentTypes.Button: {
438
+ return {
439
+ type: c.type,
440
+ style: c.style,
441
+ label: c.label,
442
+ emoji:
443
+ c.emoji !== undefined
444
+ ? {
445
+ name: c.emoji.name,
446
+ id: c.emoji.id,
447
+ animated: c.emoji.animated,
448
+ }
449
+ : undefined,
450
+ custom_id: c.customId,
451
+ url: c.url,
452
+ disabled: c.disabled,
453
+ };
454
+ }
455
+ case ComponentTypes.TextInput: {
456
+ return {
457
+ type: c.type,
458
+ custom_id: c.customId,
459
+ style: c.style,
460
+ label: c.label,
461
+ min_length: c.minLength,
462
+ max_length: c.maxLength,
463
+ required: c.required,
464
+ value: c.value,
465
+ placeholder: c.placeholder,
466
+ };
467
+ }
468
+ case ComponentTypes.ChannelSelect: {
469
+ return {
470
+ type: c.type,
471
+ custom_id: c.customId,
472
+ channel_types: c.channelTypes,
473
+ placeholder: c.placeholder,
474
+ default_values: c.defaultValues,
475
+ min_values: c.minValues,
476
+ max_values: c.maxValues,
477
+ disabled: c.disabled,
478
+ };
479
+ }
480
+ case ComponentTypes.StringSelect: {
481
+ return {
482
+ type: c.type,
483
+ custom_id: c.customId,
484
+ placeholder: c.placeholder,
485
+ options: c.options?.map((option) => ({
486
+ label: option.label,
487
+ value: option.value,
488
+ description: option.description,
489
+ emoji:
490
+ option.emoji !== undefined
491
+ ? {
492
+ name: option.emoji.name,
493
+ id: option.emoji.id,
494
+ animated: option.emoji.animated,
495
+ }
496
+ : undefined,
497
+ default: option.default,
498
+ })),
499
+ min_values: c.minValues,
500
+ max_values: c.maxValues,
501
+ disabled: c.disabled,
502
+ };
503
+ }
504
+ case ComponentTypes.MentionableSelect:
505
+ case ComponentTypes.RoleSelect:
506
+ case ComponentTypes.UserSelect: {
507
+ return {
508
+ type: c.type,
509
+ custom_id: c.customId,
510
+ placeholder: c.placeholder,
511
+ default_values: c.defaultValues,
512
+ min_values: c.minValues,
513
+ max_values: c.maxValues,
514
+ disabled: c.disabled,
515
+ };
516
+ }
517
+ }
518
+ }),
519
+ }));
520
+ }
521
+
522
+ presenceToREST(
523
+ presence: RawPresenceUpdateEventFields,
524
+ client: Client
525
+ ): PresenceUpdateEventFields {
526
+ return {
527
+ user: new User(presence.user, client),
528
+ guildId: presence.guild_id,
529
+ status: presence.status,
530
+ activities: presence.activities.map((activity) => ({
531
+ name: activity.name,
532
+ type: activity.type,
533
+ url: activity.url,
534
+ createdAt: activity.created_at,
535
+ timestamps: activity.timestamps,
536
+ applicationId: activity.application_id,
537
+ details: activity.details,
538
+ state: activity.state,
539
+ party: activity.party,
540
+ assets: {
541
+ largeImage: activity.assets?.large_image,
542
+ largeText: activity.assets?.large_text,
543
+ smallImage: activity.assets?.small_image,
544
+ smallText: activity.assets?.small_text,
545
+ },
546
+ secrets: activity.secrets,
547
+ instance: activity.instance,
548
+ flags: activity.flags,
549
+ buttons: activity.buttons,
550
+ })),
551
+ clientStatus: presence.client_status,
552
+ };
553
+ }
554
+
555
+ roleToRaw(role: JSONRole | Partial<JSONRole>): RawRole | Partial<RawRole> {
556
+ return {
557
+ id: role.id,
558
+ name: role.name,
559
+ color: role.color,
560
+ hoist: role.hoist,
561
+ icon: role.icon,
562
+ unicode_emoji: role.unicodeEmoji,
563
+ position: role.position,
564
+ permissions: role.permissions,
565
+ managed: role.managed,
566
+ mentionable: role.mentionable,
567
+ tags: {
568
+ bot_id: role.tags?.botId,
569
+ integration_id: role.tags?.integrationId,
570
+ premium_subscriber: role.tags?.premiumSubscriber,
571
+ subscription_listing_id: role.tags?.subscriptionListingId,
572
+ available_for_purchase: role.tags?.availableForPurchase,
573
+ guild_connections: role.tags?.guildConnections,
574
+ },
575
+ flags: role.flags,
576
+ };
577
+ }
578
+
579
+ userToRaw(user: JSONUser): RawUser {
580
+ return {
581
+ id: user.id,
582
+ username: user.username,
583
+ discriminator: user.discriminator,
584
+ global_name: user.globalName,
585
+ avatar: user.avatar,
586
+ bot: user.bot,
587
+ system: user.system,
588
+ mfa_enabled: user.mfaEnabled,
589
+ banner: user.banner,
590
+ accent_color: user.accentColor,
591
+ locale: user.locale,
592
+ verified: user.verified,
593
+ email: user.email,
594
+ flags: user.flags,
595
+ premium_type: user.premiumType,
596
+ public_flags: user.publicFlags,
597
+ avatar_decoration: user.avatarDecoration,
598
+ };
599
+ }
600
+ }
@@ -0,0 +1,23 @@
1
+ export class RESTError extends Error {
2
+ override name: string = "RESTError";
3
+
4
+ constructor(message: string) {
5
+ super(message);
6
+ }
7
+ }
8
+
9
+ export class HTTPError extends Error {
10
+ override name: string = "HTTPError";
11
+
12
+ constructor(message: string) {
13
+ super(message);
14
+ }
15
+ }
16
+
17
+ export class GatewayError extends Error {
18
+ override name: string = "GatewayError";
19
+
20
+ constructor(message: string) {
21
+ super(message);
22
+ }
23
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./errors";
2
+ export * from "./Util";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "disgroove",
3
- "version": "1.3.1",
3
+ "version": "1.3.3-dev.1",
4
4
  "description": "A module to interact with the Discord API",
5
5
  "main": "./dist/lib/index.js",
6
6
  "types": "./dist/lib/index.d.ts",