@deffa5556/bail 1.0.6 → 1.0.7

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 (314) hide show
  1. package/cjs/WAProto/index.cjs +106053 -0
  2. package/cjs/deffa/config.cjs +14 -0
  3. package/cjs/deffa/plugins/ai/deepseekr1.cjs +35 -0
  4. package/cjs/deffa/plugins/ai/gita.cjs +26 -0
  5. package/cjs/deffa/plugins/ai/glm47flash.cjs +35 -0
  6. package/cjs/deffa/plugins/ai/gptoss120b.cjs +35 -0
  7. package/cjs/deffa/plugins/ai/qwq32b.cjs +35 -0
  8. package/cjs/deffa/plugins/berita/antara.cjs +25 -0
  9. package/cjs/deffa/plugins/berita/cnbcindonesia.cjs +25 -0
  10. package/cjs/deffa/plugins/berita/cnn.cjs +25 -0
  11. package/cjs/deffa/plugins/berita/kompas.cjs +25 -0
  12. package/cjs/deffa/plugins/berita/liputan6.cjs +25 -0
  13. package/cjs/deffa/plugins/berita/merdeka.cjs +25 -0
  14. package/cjs/deffa/plugins/berita/sindonews.cjs +25 -0
  15. package/cjs/deffa/plugins/berita/tribunnews.cjs +25 -0
  16. package/cjs/deffa/plugins/downloader/douyin.cjs +30 -0
  17. package/cjs/deffa/plugins/downloader/facebook.cjs +30 -0
  18. package/cjs/deffa/plugins/downloader/github.cjs +35 -0
  19. package/cjs/deffa/plugins/downloader/lahelu.cjs +30 -0
  20. package/cjs/deffa/plugins/downloader/snackvideo.cjs +30 -0
  21. package/cjs/deffa/plugins/downloader/soundcloud.cjs +30 -0
  22. package/cjs/deffa/plugins/downloader/tiktok.cjs +30 -0
  23. package/cjs/deffa/plugins/downloader/tiktokhd.cjs +30 -0
  24. package/cjs/deffa/plugins/downloader/twitter.cjs +30 -0
  25. package/cjs/deffa/plugins/downloader/ummy.cjs +36 -0
  26. package/cjs/deffa/plugins/index.cjs +213 -0
  27. package/cjs/deffa/plugins/info/bmkg.cjs +34 -0
  28. package/cjs/deffa/plugins/info/cuaca.cjs +31 -0
  29. package/cjs/deffa/plugins/info/jadwaltv.cjs +29 -0
  30. package/cjs/deffa/plugins/maker/brat.cjs +45 -0
  31. package/cjs/deffa/plugins/maker/bratvid.cjs +52 -0
  32. package/cjs/deffa/plugins/search/8font.cjs +28 -0
  33. package/cjs/deffa/plugins/search/applemusic.cjs +28 -0
  34. package/cjs/deffa/plugins/search/bimg.cjs +30 -0
  35. package/cjs/deffa/plugins/search/brave.cjs +34 -0
  36. package/cjs/deffa/plugins/search/duckduckgo.cjs +28 -0
  37. package/cjs/deffa/plugins/search/lahelu.cjs +28 -0
  38. package/cjs/deffa/plugins/search/mangatoon.cjs +28 -0
  39. package/cjs/deffa/plugins/search/mcpedl.cjs +28 -0
  40. package/cjs/deffa/plugins/search/myinstants.cjs +28 -0
  41. package/cjs/deffa/plugins/search/otakotaku.cjs +28 -0
  42. package/cjs/deffa/plugins/search/pinterest.cjs +30 -0
  43. package/cjs/deffa/plugins/search/resep.cjs +28 -0
  44. package/cjs/deffa/plugins/search/seegore.cjs +30 -0
  45. package/cjs/deffa/plugins/search/soundcloud.cjs +28 -0
  46. package/cjs/deffa/plugins/search/youtube.cjs +28 -0
  47. package/cjs/deffa/plugins/stalk/github.cjs +38 -0
  48. package/cjs/deffa/plugins/stalk/pinterest.cjs +37 -0
  49. package/cjs/deffa/plugins/stalk/threads.cjs +34 -0
  50. package/cjs/deffa/plugins/stalk/tiktok.cjs +37 -0
  51. package/cjs/deffa/plugins/stalk/twitter.cjs +37 -0
  52. package/cjs/deffa/plugins/stalk/youtube.cjs +37 -0
  53. package/cjs/lib/Defaults/index.cjs +158 -0
  54. package/cjs/lib/Discord/Client.cjs +263 -0
  55. package/cjs/lib/Discord/Constants.cjs +1842 -0
  56. package/cjs/lib/Discord/connect-dc.cjs +11 -0
  57. package/cjs/lib/Discord/esm-bridge.cjs +136 -0
  58. package/cjs/lib/Discord/gateway/Dispatcher.cjs +93 -0
  59. package/cjs/lib/Discord/gateway/Shard.cjs +695 -0
  60. package/cjs/lib/Discord/gateway/ShardManager.cjs +344 -0
  61. package/cjs/lib/Discord/gateway/compression/base.cjs +13 -0
  62. package/cjs/lib/Discord/gateway/compression/config.cjs +47 -0
  63. package/cjs/lib/Discord/gateway/compression/pako.cjs +44 -0
  64. package/cjs/lib/Discord/gateway/compression/zlib-native.cjs +47 -0
  65. package/cjs/lib/Discord/gateway/compression/zlib-sync.cjs +31 -0
  66. package/cjs/lib/Discord/gateway/compression/zstd-napi.cjs +80 -0
  67. package/cjs/lib/Discord/gateway/compression/zstd-native.cjs +46 -0
  68. package/cjs/lib/Discord/gateway/events.cjs +956 -0
  69. package/cjs/lib/Discord/index.cjs +238 -0
  70. package/cjs/lib/Discord/rest/Bucket.cjs +69 -0
  71. package/cjs/lib/Discord/rest/DiscordHTTPError.cjs +63 -0
  72. package/cjs/lib/Discord/rest/DiscordRESTError.cjs +84 -0
  73. package/cjs/lib/Discord/rest/OAuthHelper.cjs +226 -0
  74. package/cjs/lib/Discord/rest/RESTManager.cjs +116 -0
  75. package/cjs/lib/Discord/rest/RequestHandler.cjs +320 -0
  76. package/cjs/lib/Discord/rest/SequentialBucket.cjs +69 -0
  77. package/cjs/lib/Discord/routes/Applications.cjs +625 -0
  78. package/cjs/lib/Discord/routes/Channels.cjs +1199 -0
  79. package/cjs/lib/Discord/routes/Guilds.cjs +1792 -0
  80. package/cjs/lib/Discord/routes/Interactions.cjs +212 -0
  81. package/cjs/lib/Discord/routes/Lobbies.cjs +197 -0
  82. package/cjs/lib/Discord/routes/Miscellaneous.cjs +120 -0
  83. package/cjs/lib/Discord/routes/OAuth.cjs +350 -0
  84. package/cjs/lib/Discord/routes/Users.cjs +107 -0
  85. package/cjs/lib/Discord/routes/Webhooks.cjs +308 -0
  86. package/cjs/lib/Discord/structures/AnnouncementChannel.cjs +46 -0
  87. package/cjs/lib/Discord/structures/AnnouncementThreadChannel.cjs +28 -0
  88. package/cjs/lib/Discord/structures/Application.cjs +345 -0
  89. package/cjs/lib/Discord/structures/ApplicationCommand.cjs +109 -0
  90. package/cjs/lib/Discord/structures/Attachment.cjs +46 -0
  91. package/cjs/lib/Discord/structures/AuditLogEntry.cjs +41 -0
  92. package/cjs/lib/Discord/structures/AutoModerationRule.cjs +117 -0
  93. package/cjs/lib/Discord/structures/AutocompleteInteraction.cjs +90 -0
  94. package/cjs/lib/Discord/structures/Base.cjs +56 -0
  95. package/cjs/lib/Discord/structures/BaseEntitlement.cjs +40 -0
  96. package/cjs/lib/Discord/structures/CategoryChannel.cjs +102 -0
  97. package/cjs/lib/Discord/structures/Channel.cjs +89 -0
  98. package/cjs/lib/Discord/structures/ClientApplication.cjs +269 -0
  99. package/cjs/lib/Discord/structures/CommandInteraction.cjs +294 -0
  100. package/cjs/lib/Discord/structures/ComponentInteraction.cjs +306 -0
  101. package/cjs/lib/Discord/structures/Entitlement.cjs +24 -0
  102. package/cjs/lib/Discord/structures/ExtendedUser.cjs +48 -0
  103. package/cjs/lib/Discord/structures/ForumChannel.cjs +20 -0
  104. package/cjs/lib/Discord/structures/GroupChannel.cjs +160 -0
  105. package/cjs/lib/Discord/structures/Guild.cjs +1289 -0
  106. package/cjs/lib/Discord/structures/GuildChannel.cjs +82 -0
  107. package/cjs/lib/Discord/structures/GuildPreview.cjs +141 -0
  108. package/cjs/lib/Discord/structures/GuildScheduledEvent.cjs +166 -0
  109. package/cjs/lib/Discord/structures/GuildTemplate.cjs +96 -0
  110. package/cjs/lib/Discord/structures/Integration.cjs +123 -0
  111. package/cjs/lib/Discord/structures/Interaction.cjs +78 -0
  112. package/cjs/lib/Discord/structures/InteractionResolvedChannel.cjs +36 -0
  113. package/cjs/lib/Discord/structures/Invite.cjs +196 -0
  114. package/cjs/lib/Discord/structures/InviteGuild.cjs +117 -0
  115. package/cjs/lib/Discord/structures/InviteRole.cjs +88 -0
  116. package/cjs/lib/Discord/structures/Lobby.cjs +84 -0
  117. package/cjs/lib/Discord/structures/LobbyMember.cjs +30 -0
  118. package/cjs/lib/Discord/structures/MediaChannel.cjs +20 -0
  119. package/cjs/lib/Discord/structures/Member.cjs +300 -0
  120. package/cjs/lib/Discord/structures/Message.cjs +553 -0
  121. package/cjs/lib/Discord/structures/ModalSubmitInteraction.cjs +263 -0
  122. package/cjs/lib/Discord/structures/OAuthApplication.cjs +203 -0
  123. package/cjs/lib/Discord/structures/OAuthGuild.cjs +98 -0
  124. package/cjs/lib/Discord/structures/PartialApplication.cjs +97 -0
  125. package/cjs/lib/Discord/structures/Permission.cjs +61 -0
  126. package/cjs/lib/Discord/structures/PermissionOverwrite.cjs +46 -0
  127. package/cjs/lib/Discord/structures/PingInteraction.cjs +27 -0
  128. package/cjs/lib/Discord/structures/Poll.cjs +69 -0
  129. package/cjs/lib/Discord/structures/PrimaryGuild.cjs +93 -0
  130. package/cjs/lib/Discord/structures/PrivateChannel.cjs +131 -0
  131. package/cjs/lib/Discord/structures/PrivateThreadChannel.cjs +28 -0
  132. package/cjs/lib/Discord/structures/PublicThreadChannel.cjs +36 -0
  133. package/cjs/lib/Discord/structures/Role.cjs +126 -0
  134. package/cjs/lib/Discord/structures/SKU.cjs +58 -0
  135. package/cjs/lib/Discord/structures/Soundboard.cjs +58 -0
  136. package/cjs/lib/Discord/structures/StageChannel.cjs +45 -0
  137. package/cjs/lib/Discord/structures/StageInstance.cjs +80 -0
  138. package/cjs/lib/Discord/structures/Subscription.cjs +21 -0
  139. package/cjs/lib/Discord/structures/Team.cjs +70 -0
  140. package/cjs/lib/Discord/structures/TestEntitlement.cjs +22 -0
  141. package/cjs/lib/Discord/structures/TextChannel.cjs +48 -0
  142. package/cjs/lib/Discord/structures/TextableChannel.cjs +265 -0
  143. package/cjs/lib/Discord/structures/TextableVoiceChannel.cjs +70 -0
  144. package/cjs/lib/Discord/structures/ThreadChannel.cjs +276 -0
  145. package/cjs/lib/Discord/structures/ThreadOnlyChannel.cjs +205 -0
  146. package/cjs/lib/Discord/structures/ThreadableChannel.cjs +57 -0
  147. package/cjs/lib/Discord/structures/UnavailableGuild.cjs +21 -0
  148. package/cjs/lib/Discord/structures/User.cjs +223 -0
  149. package/cjs/lib/Discord/structures/VoiceChannel.cjs +34 -0
  150. package/cjs/lib/Discord/structures/VoiceState.cjs +113 -0
  151. package/cjs/lib/Discord/structures/Webhook.cjs +224 -0
  152. package/cjs/lib/Discord/util/Collection.cjs +77 -0
  153. package/cjs/lib/Discord/util/Errors.cjs +81 -0
  154. package/cjs/lib/Discord/util/QueryBuilder.cjs +20 -0
  155. package/cjs/lib/Discord/util/Routes.cjs +293 -0
  156. package/cjs/lib/Discord/util/SimpleCollection.cjs +78 -0
  157. package/cjs/lib/Discord/util/Time.cjs +92 -0
  158. package/cjs/lib/Discord/util/TypedCollection.cjs +78 -0
  159. package/cjs/lib/Discord/util/TypedEmitter.cjs +20 -0
  160. package/cjs/lib/Discord/util/Util.cjs +906 -0
  161. package/cjs/lib/Discord/util/interactions/InteractionOptionsWrapper.cjs +207 -0
  162. package/cjs/lib/Discord/util/interactions/MessageInteractionResponse.cjs +26 -0
  163. package/cjs/lib/Discord/util/interactions/ModalSubmitInteractionComponentsWrapper.cjs +98 -0
  164. package/cjs/lib/Discord/util/interactions/SelectMenuValuesWrapper.cjs +77 -0
  165. package/cjs/lib/Discord/util/interactions/shared.cjs +20 -0
  166. package/cjs/lib/Discord/util/warning.cjs +34 -0
  167. package/cjs/lib/Signal/Group/ciphertext-message.cjs +16 -0
  168. package/cjs/lib/Signal/Group/group-session-builder.cjs +67 -0
  169. package/cjs/lib/Signal/Group/group_cipher.cjs +86 -0
  170. package/cjs/lib/Signal/Group/index.cjs +58 -0
  171. package/cjs/lib/Signal/Group/keyhelper.cjs +56 -0
  172. package/cjs/lib/Signal/Group/sender-chain-key.cjs +30 -0
  173. package/cjs/lib/Signal/Group/sender-key-distribution-message.cjs +67 -0
  174. package/cjs/lib/Signal/Group/sender-key-message.cjs +70 -0
  175. package/cjs/lib/Signal/Group/sender-key-name.cjs +52 -0
  176. package/cjs/lib/Signal/Group/sender-key-record.cjs +45 -0
  177. package/cjs/lib/Signal/Group/sender-key-state.cjs +88 -0
  178. package/cjs/lib/Signal/Group/sender-message-key.cjs +30 -0
  179. package/cjs/lib/Signal/libsignal.cjs +467 -0
  180. package/cjs/lib/Signal/lid-mapping.cjs +281 -0
  181. package/cjs/lib/Socket/Client/index.cjs +19 -0
  182. package/cjs/lib/Socket/Client/types.cjs +15 -0
  183. package/cjs/lib/Socket/Client/websocket.cjs +61 -0
  184. package/cjs/lib/Socket/business.cjs +384 -0
  185. package/cjs/lib/Socket/chats.cjs +1221 -0
  186. package/cjs/lib/Socket/communities.cjs +440 -0
  187. package/cjs/lib/Socket/groups.cjs +353 -0
  188. package/cjs/lib/Socket/index.cjs +14 -0
  189. package/cjs/lib/Socket/messages-recv.cjs +1772 -0
  190. package/cjs/lib/Socket/messages-send.cjs +1376 -0
  191. package/cjs/lib/Socket/mex.cjs +46 -0
  192. package/cjs/lib/Socket/newsletter.cjs +230 -0
  193. package/cjs/lib/Socket/socket.cjs +976 -0
  194. package/cjs/lib/Store/index.cjs +20 -0
  195. package/cjs/lib/Store/make-in-memory-store.cjs +470 -0
  196. package/cjs/lib/Store/make-ordered-dictionary.cjs +82 -0
  197. package/cjs/lib/Store/object-repository.cjs +28 -0
  198. package/cjs/lib/Telegram/button.cjs +147 -0
  199. package/cjs/lib/Telegram/composer.cjs +582 -0
  200. package/cjs/lib/Telegram/context.cjs +853 -0
  201. package/cjs/lib/Telegram/core/helpers/args.cjs +57 -0
  202. package/cjs/lib/Telegram/core/helpers/check.cjs +55 -0
  203. package/cjs/lib/Telegram/core/helpers/compact.cjs +16 -0
  204. package/cjs/lib/Telegram/core/helpers/deunionize.cjs +12 -0
  205. package/cjs/lib/Telegram/core/helpers/formatting.cjs +91 -0
  206. package/cjs/lib/Telegram/core/helpers/util.cjs +50 -0
  207. package/cjs/lib/Telegram/core/network/client.cjs +338 -0
  208. package/cjs/lib/Telegram/core/network/error.cjs +21 -0
  209. package/cjs/lib/Telegram/core/network/multipart-stream.cjs +79 -0
  210. package/cjs/lib/Telegram/core/network/polling.cjs +87 -0
  211. package/cjs/lib/Telegram/core/network/webhook.cjs +54 -0
  212. package/cjs/lib/Telegram/core/types/typegram.cjs +31 -0
  213. package/cjs/lib/Telegram/deffa-telegraf.cjs +264 -0
  214. package/cjs/lib/Telegram/esm-bridge.cjs +20 -0
  215. package/cjs/lib/Telegram/filters.cjs +69 -0
  216. package/cjs/lib/Telegram/format.cjs +58 -0
  217. package/cjs/lib/Telegram/future.cjs +140 -0
  218. package/cjs/lib/Telegram/index.cjs +67 -0
  219. package/cjs/lib/Telegram/input.cjs +61 -0
  220. package/cjs/lib/Telegram/markup.cjs +129 -0
  221. package/cjs/lib/Telegram/middleware.cjs +2 -0
  222. package/cjs/lib/Telegram/reactions.cjs +84 -0
  223. package/cjs/lib/Telegram/router.cjs +46 -0
  224. package/cjs/lib/Telegram/scenes/base.cjs +39 -0
  225. package/cjs/lib/Telegram/scenes/context.cjs +104 -0
  226. package/cjs/lib/Telegram/scenes/index.cjs +21 -0
  227. package/cjs/lib/Telegram/scenes/stage.cjs +49 -0
  228. package/cjs/lib/Telegram/scenes/wizard/context.cjs +31 -0
  229. package/cjs/lib/Telegram/scenes/wizard/index.cjs +45 -0
  230. package/cjs/lib/Telegram/scenes.cjs +21 -0
  231. package/cjs/lib/Telegram/session.cjs +166 -0
  232. package/cjs/lib/Telegram/telegram-types.cjs +6 -0
  233. package/cjs/lib/Telegram/telegram.cjs +945 -0
  234. package/cjs/lib/Telegram/types.cjs +2 -0
  235. package/cjs/lib/Telegram/utils.cjs +5 -0
  236. package/cjs/lib/Types/Auth.cjs +3 -0
  237. package/cjs/lib/Types/Bussines.cjs +3 -0
  238. package/cjs/lib/Types/Call.cjs +3 -0
  239. package/cjs/lib/Types/Chat.cjs +11 -0
  240. package/cjs/lib/Types/Contact.cjs +3 -0
  241. package/cjs/lib/Types/Events.cjs +4 -0
  242. package/cjs/lib/Types/GroupMetadata.cjs +3 -0
  243. package/cjs/lib/Types/Label.cjs +26 -0
  244. package/cjs/lib/Types/LabelAssociation.cjs +8 -0
  245. package/cjs/lib/Types/Message.cjs +19 -0
  246. package/cjs/lib/Types/Mex.cjs +40 -0
  247. package/cjs/lib/Types/Product.cjs +3 -0
  248. package/cjs/lib/Types/RichType.cjs +24 -0
  249. package/cjs/lib/Types/Signal.cjs +4 -0
  250. package/cjs/lib/Types/Socket.cjs +4 -0
  251. package/cjs/lib/Types/State.cjs +54 -0
  252. package/cjs/lib/Types/USync.cjs +4 -0
  253. package/cjs/lib/Types/index.cjs +42 -0
  254. package/cjs/lib/Utils/auth-utils.cjs +312 -0
  255. package/cjs/lib/Utils/browser-utils.cjs +39 -0
  256. package/cjs/lib/Utils/business.cjs +241 -0
  257. package/cjs/lib/Utils/chat-utils.cjs +890 -0
  258. package/cjs/lib/Utils/companion-reg-client-utils.cjs +51 -0
  259. package/cjs/lib/Utils/crypto.cjs +170 -0
  260. package/cjs/lib/Utils/decode-wa-message.cjs +330 -0
  261. package/cjs/lib/Utils/event-buffer.cjs +629 -0
  262. package/cjs/lib/Utils/generics.cjs +427 -0
  263. package/cjs/lib/Utils/history.cjs +141 -0
  264. package/cjs/lib/Utils/identity-change-handler.cjs +56 -0
  265. package/cjs/lib/Utils/index.cjs +43 -0
  266. package/cjs/lib/Utils/link-preview.cjs +122 -0
  267. package/cjs/lib/Utils/logger.cjs +8 -0
  268. package/cjs/lib/Utils/lt-hash.cjs +11 -0
  269. package/cjs/lib/Utils/make-mutex.cjs +38 -0
  270. package/cjs/lib/Utils/message-retry-manager.cjs +267 -0
  271. package/cjs/lib/Utils/messages-media.cjs +906 -0
  272. package/cjs/lib/Utils/messages.cjs +1909 -0
  273. package/cjs/lib/Utils/noise-handler.cjs +205 -0
  274. package/cjs/lib/Utils/offline-node-processor.cjs +43 -0
  275. package/cjs/lib/Utils/pre-key-manager.cjs +113 -0
  276. package/cjs/lib/Utils/process-message.cjs +755 -0
  277. package/cjs/lib/Utils/reporting-utils.cjs +263 -0
  278. package/cjs/lib/Utils/rich-message-utils.cjs +434 -0
  279. package/cjs/lib/Utils/session-guard.cjs +163 -0
  280. package/cjs/lib/Utils/signal.cjs +214 -0
  281. package/cjs/lib/Utils/stanza-ack.cjs +41 -0
  282. package/cjs/lib/Utils/sync-action-utils.cjs +54 -0
  283. package/cjs/lib/Utils/tc-token-utils.cjs +174 -0
  284. package/cjs/lib/Utils/text-sticker.cjs +174 -0
  285. package/cjs/lib/Utils/use-multi-file-auth-state.cjs +125 -0
  286. package/cjs/lib/Utils/use-single-file-auth-state.cjs +113 -0
  287. package/cjs/lib/Utils/use-sqlite-auth-state.cjs +145 -0
  288. package/cjs/lib/Utils/validate-connection.cjs +210 -0
  289. package/cjs/lib/WABinary/constants.cjs +1470 -0
  290. package/cjs/lib/WABinary/decode.cjs +301 -0
  291. package/cjs/lib/WABinary/encode.cjs +257 -0
  292. package/cjs/lib/WABinary/generic-utils.cjs +240 -0
  293. package/cjs/lib/WABinary/index.cjs +22 -0
  294. package/cjs/lib/WABinary/jid-utils.cjs +114 -0
  295. package/cjs/lib/WABinary/types.cjs +37 -0
  296. package/cjs/lib/WAM/BinaryInfo.cjs +14 -0
  297. package/cjs/lib/WAM/constants.cjs +22856 -0
  298. package/cjs/lib/WAM/encode.cjs +154 -0
  299. package/cjs/lib/WAM/index.cjs +20 -0
  300. package/cjs/lib/WAUSync/Protocols/USyncContactProtocol.cjs +56 -0
  301. package/cjs/lib/WAUSync/Protocols/USyncDeviceProtocol.cjs +58 -0
  302. package/cjs/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.cjs +31 -0
  303. package/cjs/lib/WAUSync/Protocols/USyncStatusProtocol.cjs +42 -0
  304. package/cjs/lib/WAUSync/Protocols/USyncUsernameProtocol.cjs +29 -0
  305. package/cjs/lib/WAUSync/Protocols/UsyncBotProfileProtocol.cjs +55 -0
  306. package/cjs/lib/WAUSync/Protocols/UsyncLIDProtocol.cjs +33 -0
  307. package/cjs/lib/WAUSync/Protocols/index.cjs +22 -0
  308. package/cjs/lib/WAUSync/USyncQuery.cjs +102 -0
  309. package/cjs/lib/WAUSync/USyncUser.cjs +35 -0
  310. package/cjs/lib/WAUSync/index.cjs +20 -0
  311. package/cjs/lib/index.cjs +372 -0
  312. package/cjs/lib/plugins/loader.cjs +117 -0
  313. package/lib/Defaults/index.js +1 -1
  314. package/package.json +11 -6
@@ -0,0 +1,906 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ /** @module Util */
7
+ const Routes_1 = require("./Routes");
8
+ const Errors_1 = require("./Errors");
9
+ const Constants_1 = require("../Constants");
10
+ const Member_1 = __importDefault(require("../structures/Member"));
11
+ const Channel_1 = __importDefault(require("../structures/Channel"));
12
+ const Message_1 = __importDefault(require("../structures/Message"));
13
+ const Entitlement_1 = __importDefault(require("../structures/Entitlement"));
14
+ const TestEntitlement_1 = __importDefault(require("../structures/TestEntitlement"));
15
+ const node_util_1 = require("node:util");
16
+ /** A general set of utilities. These are intentionally poorly documented, as they serve almost no usefulness to outside developers. */
17
+ class Util {
18
+ constructor(client) {
19
+ this._client = client;
20
+ }
21
+ static rawEmbeds(embeds) {
22
+ const data = Util.prototype.embedsToParsed(Array.isArray(embeds) ? embeds : [embeds]);
23
+ return Array.isArray(embeds) ? data : data[0];
24
+ }
25
+ static rawMessageComponents(components) {
26
+ const data = Util.prototype.componentsToParsed(Array.isArray(components) ? components : [components]);
27
+ return Array.isArray(components) ? data : data[0];
28
+ }
29
+ static rawModalComponents(components) {
30
+ const data = Util.prototype.componentsToParsed(Array.isArray(components) ? components : [components]);
31
+ return Array.isArray(components) ? data : data[0];
32
+ }
33
+ /** @hidden intentionally not documented - this is an internal function */
34
+ _arrayToCSV(data, header) {
35
+ return Buffer.from([header, ...data].filter(Boolean).join("\n"), "utf8");
36
+ }
37
+ /** @hidden intentionally not documented - this is an internal function */
38
+ _arrayToCSVFile(data, name, header) {
39
+ return {
40
+ name: `${name}.csv`,
41
+ field: name,
42
+ contents: this._arrayToCSV(data, header)
43
+ };
44
+ }
45
+ /** @hidden intentionally not documented - this is an internal function */
46
+ _convertImage(image, name) {
47
+ try {
48
+ return this.convertImage(image);
49
+ }
50
+ catch (err) {
51
+ throw new TypeError(`Invalid ${name} provided. Ensure you are providing a valid, fully-qualified base64 url.`, { cause: err });
52
+ }
53
+ }
54
+ /** @hidden intended for internal use only */
55
+ _convertSound(sound, name) {
56
+ try {
57
+ return this.convertSound(sound);
58
+ }
59
+ catch (err) {
60
+ throw new TypeError(`Invalid ${name} provided. Ensure you are providing a valid, fully-qualified base64 url.`, { cause: err });
61
+ }
62
+ }
63
+ /** @internal */
64
+ _freeze(obj, detail) {
65
+ let message = "This is an error in the library and should be reported.";
66
+ if (detail) {
67
+ message += `Detail: ${detail}`;
68
+ }
69
+ if (typeof obj !== "object" || obj === null || node_util_1.types.isProxy(obj)) {
70
+ return obj;
71
+ }
72
+ return new Proxy(obj, {
73
+ set: (target, prop, value, receiver) => {
74
+ this._client.emit("error", new Errors_1.FrozenModificationError(message, prop));
75
+ return Reflect.set(target, prop, value, receiver);
76
+ }
77
+ });
78
+ }
79
+ /** @hidden intended for internal use only */
80
+ _getLimit(name, id) {
81
+ const opt = this._client.options.collectionLimits[name];
82
+ if (typeof opt === "number") {
83
+ return opt;
84
+ }
85
+ return (id === undefined ? undefined : opt[id]) ?? opt.default ?? Infinity;
86
+ }
87
+ /** @hidden intended for internal use only */
88
+ _isModuleInstalled(name) {
89
+ try {
90
+ // eslint-disable-next-line unicorn/prefer-module
91
+ require(name);
92
+ return true;
93
+ }
94
+ catch {
95
+ return false;
96
+ }
97
+ }
98
+ _setLimit(values, defaultValue = Infinity) {
99
+ if (values === undefined) {
100
+ return defaultValue;
101
+ }
102
+ if (typeof values === "object") {
103
+ return { default: defaultValue, ...values };
104
+ }
105
+ return values;
106
+ }
107
+ componentToParsed(component) {
108
+ switch (component.type) {
109
+ case Constants_1.ComponentTypes.ACTION_ROW: {
110
+ return {
111
+ components: component.components.map(c => this.componentToParsed(c)),
112
+ type: component.type
113
+ };
114
+ }
115
+ case Constants_1.ComponentTypes.BUTTON: {
116
+ if (component.style === Constants_1.ButtonStyles.LINK)
117
+ return component;
118
+ if (component.style === Constants_1.ButtonStyles.PREMIUM) {
119
+ return {
120
+ disabled: component.disabled,
121
+ skuID: component.sku_id,
122
+ style: component.style,
123
+ type: component.type
124
+ };
125
+ }
126
+ return {
127
+ customID: component.custom_id,
128
+ disabled: component.disabled,
129
+ emoji: component.emoji,
130
+ label: component.label,
131
+ style: component.style,
132
+ type: component.type
133
+ };
134
+ }
135
+ case Constants_1.ComponentTypes.TEXT_INPUT: {
136
+ return {
137
+ customID: component.custom_id,
138
+ label: component.label,
139
+ maxLength: component.max_length,
140
+ minLength: component.min_length,
141
+ placeholder: component.placeholder,
142
+ required: component.required,
143
+ style: component.style,
144
+ type: component.type,
145
+ value: component.value
146
+ };
147
+ }
148
+ case Constants_1.ComponentTypes.STRING_SELECT:
149
+ case Constants_1.ComponentTypes.USER_SELECT:
150
+ case Constants_1.ComponentTypes.ROLE_SELECT:
151
+ case Constants_1.ComponentTypes.MENTIONABLE_SELECT:
152
+ case Constants_1.ComponentTypes.CHANNEL_SELECT: {
153
+ const parsedComponent = {
154
+ customID: component.custom_id,
155
+ disabled: component.disabled,
156
+ maxValues: component.max_values,
157
+ minValues: component.min_values,
158
+ placeholder: component.placeholder,
159
+ type: component.type
160
+ };
161
+ if (component.type !== Constants_1.ComponentTypes.STRING_SELECT && component.default_values !== undefined) {
162
+ parsedComponent.defaultValues = component.default_values;
163
+ }
164
+ if (component.type === Constants_1.ComponentTypes.STRING_SELECT) {
165
+ return { ...parsedComponent, options: component.options };
166
+ }
167
+ else if (component.type === Constants_1.ComponentTypes.CHANNEL_SELECT) {
168
+ return { ...parsedComponent, channelTypes: component.channel_types };
169
+ }
170
+ else {
171
+ return parsedComponent;
172
+ }
173
+ }
174
+ case Constants_1.ComponentTypes.TEXT_DISPLAY: {
175
+ return component;
176
+ }
177
+ case Constants_1.ComponentTypes.THUMBNAIL: {
178
+ return {
179
+ description: component.description,
180
+ media: {
181
+ attachmentID: component.media.attachment_id,
182
+ contentType: component.media.content_type,
183
+ height: component.media.height,
184
+ proxyURL: component.media.proxy_url,
185
+ url: component.media.url,
186
+ width: component.media.width
187
+ },
188
+ spoiler: component.spoiler,
189
+ type: component.type
190
+ };
191
+ }
192
+ case Constants_1.ComponentTypes.MEDIA_GALLERY: {
193
+ return {
194
+ items: component.items.map(i => ({
195
+ description: i.description,
196
+ media: {
197
+ attachmentID: i.media.attachment_id,
198
+ contentType: i.media.content_type,
199
+ height: i.media.height,
200
+ proxyURL: i.media.proxy_url,
201
+ url: i.media.url,
202
+ width: i.media.width
203
+ },
204
+ spoiler: i.spoiler
205
+ })),
206
+ type: component.type
207
+ };
208
+ }
209
+ case Constants_1.ComponentTypes.FILE: {
210
+ return {
211
+ file: {
212
+ attachmentID: component.file.attachment_id,
213
+ contentType: component.file.content_type,
214
+ height: component.file.height,
215
+ proxyURL: component.file.proxy_url,
216
+ url: component.file.url,
217
+ width: component.file.width
218
+ },
219
+ spoiler: component.spoiler,
220
+ type: component.type
221
+ };
222
+ }
223
+ case Constants_1.ComponentTypes.SEPARATOR: {
224
+ return component;
225
+ }
226
+ case Constants_1.ComponentTypes.CONTAINER: {
227
+ return {
228
+ accentColor: component.accent_color,
229
+ components: component.components.map(c => this.componentToParsed(c)),
230
+ spoiler: component.spoiler,
231
+ type: component.type
232
+ };
233
+ }
234
+ case Constants_1.ComponentTypes.SECTION: {
235
+ return {
236
+ type: component.type,
237
+ accessory: component.accessory ? this.componentToParsed(component.accessory) : undefined,
238
+ components: component.components.map(c => this.componentToParsed(c))
239
+ };
240
+ }
241
+ case Constants_1.ComponentTypes.LABEL: {
242
+ return {
243
+ type: component.type,
244
+ label: component.label,
245
+ description: component.description,
246
+ component: this.componentToParsed(component.component)
247
+ };
248
+ }
249
+ case Constants_1.ComponentTypes.FILE_UPLOAD: {
250
+ return {
251
+ customID: component.custom_id,
252
+ maxValues: component.max_values,
253
+ minValues: component.min_values,
254
+ required: component.required,
255
+ type: component.type
256
+ };
257
+ }
258
+ case Constants_1.ComponentTypes.RADIO_GROUP: {
259
+ return {
260
+ customID: component.custom_id,
261
+ required: component.required,
262
+ options: component.options.map(o => ({
263
+ default: o.default,
264
+ description: o.description,
265
+ label: o.label,
266
+ value: o.value
267
+ })),
268
+ type: component.type
269
+ };
270
+ }
271
+ case Constants_1.ComponentTypes.CHECKBOX: {
272
+ return {
273
+ customID: component.custom_id,
274
+ default: component.default,
275
+ type: component.type
276
+ };
277
+ }
278
+ case Constants_1.ComponentTypes.CHECKBOX_GROUP: {
279
+ return {
280
+ customID: component.custom_id,
281
+ maxValues: component.max_values,
282
+ minValues: component.min_values,
283
+ options: component.options.map(o => ({
284
+ default: o.default,
285
+ description: o.description,
286
+ label: o.label,
287
+ value: o.value
288
+ })),
289
+ required: component.required,
290
+ type: component.type
291
+ };
292
+ }
293
+ default: {
294
+ return component;
295
+ }
296
+ }
297
+ }
298
+ componentToRaw(component) {
299
+ switch (component.type) {
300
+ case Constants_1.ComponentTypes.ACTION_ROW: {
301
+ return {
302
+ type: component.type,
303
+ components: component.components.map(c => this.componentToRaw(c))
304
+ };
305
+ }
306
+ case Constants_1.ComponentTypes.BUTTON: {
307
+ if (component.style === Constants_1.ButtonStyles.LINK)
308
+ return component;
309
+ if (component.style === Constants_1.ButtonStyles.PREMIUM) {
310
+ return {
311
+ disabled: component.disabled,
312
+ sku_id: component.skuID,
313
+ style: component.style,
314
+ type: component.type
315
+ };
316
+ }
317
+ return {
318
+ custom_id: component.customID,
319
+ disabled: component.disabled,
320
+ emoji: component.emoji,
321
+ label: component.label,
322
+ style: component.style,
323
+ type: component.type
324
+ };
325
+ }
326
+ case Constants_1.ComponentTypes.TEXT_INPUT: {
327
+ return {
328
+ custom_id: component.customID,
329
+ label: component.label,
330
+ max_length: component.maxLength,
331
+ min_length: component.minLength,
332
+ placeholder: component.placeholder,
333
+ required: component.required,
334
+ style: component.style,
335
+ type: component.type,
336
+ value: component.value
337
+ };
338
+ }
339
+ case Constants_1.ComponentTypes.STRING_SELECT:
340
+ case Constants_1.ComponentTypes.USER_SELECT:
341
+ case Constants_1.ComponentTypes.ROLE_SELECT:
342
+ case Constants_1.ComponentTypes.MENTIONABLE_SELECT:
343
+ case Constants_1.ComponentTypes.CHANNEL_SELECT: {
344
+ const rawComponent = {
345
+ custom_id: component.customID,
346
+ disabled: component.disabled,
347
+ max_values: component.maxValues,
348
+ min_values: component.minValues,
349
+ placeholder: component.placeholder,
350
+ required: component.required,
351
+ type: component.type
352
+ };
353
+ if (component.type !== Constants_1.ComponentTypes.STRING_SELECT && component.defaultValues !== undefined) {
354
+ rawComponent.default_values = component.defaultValues;
355
+ }
356
+ if (component.type === Constants_1.ComponentTypes.STRING_SELECT) {
357
+ return { ...rawComponent, options: component.options };
358
+ }
359
+ else if (component.type === Constants_1.ComponentTypes.CHANNEL_SELECT) {
360
+ return { ...rawComponent, channel_types: component.channelTypes };
361
+ }
362
+ else {
363
+ return rawComponent;
364
+ }
365
+ }
366
+ case Constants_1.ComponentTypes.TEXT_DISPLAY: {
367
+ return component;
368
+ }
369
+ case Constants_1.ComponentTypes.THUMBNAIL: {
370
+ return {
371
+ description: component.description,
372
+ media: {
373
+ attachment_id: component.media.attachmentID,
374
+ content_type: component.media.contentType,
375
+ height: component.media.height,
376
+ proxy_url: component.media.proxyURL,
377
+ url: component.media.url,
378
+ width: component.media.width
379
+ },
380
+ spoiler: component.spoiler,
381
+ type: component.type
382
+ };
383
+ }
384
+ case Constants_1.ComponentTypes.MEDIA_GALLERY: {
385
+ return {
386
+ items: component.items.map(i => ({
387
+ description: i.description,
388
+ media: {
389
+ attachment_id: i.media.attachmentID,
390
+ content_type: i.media.contentType,
391
+ height: i.media.height,
392
+ proxy_url: i.media.proxyURL,
393
+ url: i.media.url,
394
+ width: i.media.width
395
+ },
396
+ spoiler: i.spoiler
397
+ })),
398
+ type: component.type
399
+ };
400
+ }
401
+ case Constants_1.ComponentTypes.FILE: {
402
+ return {
403
+ file: {
404
+ attachment_id: component.file.attachmentID,
405
+ content_type: component.file.contentType,
406
+ height: component.file.height,
407
+ proxy_url: component.file.proxyURL,
408
+ url: component.file.url,
409
+ width: component.file.width
410
+ },
411
+ spoiler: component.spoiler,
412
+ type: component.type
413
+ };
414
+ }
415
+ case Constants_1.ComponentTypes.SEPARATOR: {
416
+ return component;
417
+ }
418
+ case Constants_1.ComponentTypes.CONTAINER: {
419
+ return {
420
+ accent_color: component.accentColor,
421
+ components: component.components.map(c => this.componentToRaw(c)),
422
+ spoiler: component.spoiler,
423
+ type: component.type
424
+ };
425
+ }
426
+ case Constants_1.ComponentTypes.SECTION: {
427
+ return {
428
+ type: component.type,
429
+ accessory: component.accessory ? this.componentToRaw(component.accessory) : undefined,
430
+ components: component.components.map(c => this.componentToRaw(c))
431
+ };
432
+ }
433
+ case Constants_1.ComponentTypes.LABEL: {
434
+ return {
435
+ type: component.type,
436
+ label: component.label,
437
+ description: component.description,
438
+ component: this.componentToRaw(component.component)
439
+ };
440
+ }
441
+ case Constants_1.ComponentTypes.FILE_UPLOAD:
442
+ return {
443
+ custom_id: component.customID,
444
+ max_values: component.maxValues,
445
+ min_values: component.minValues,
446
+ required: component.required,
447
+ type: component.type
448
+ };
449
+ case Constants_1.ComponentTypes.RADIO_GROUP: {
450
+ return {
451
+ custom_id: component.customID,
452
+ required: component.required,
453
+ options: component.options.map(o => ({
454
+ default: o.default,
455
+ description: o.description,
456
+ label: o.label,
457
+ value: o.value
458
+ })),
459
+ type: component.type
460
+ };
461
+ }
462
+ case Constants_1.ComponentTypes.CHECKBOX: {
463
+ return {
464
+ custom_id: component.customID,
465
+ default: component.default,
466
+ type: component.type
467
+ };
468
+ }
469
+ case Constants_1.ComponentTypes.CHECKBOX_GROUP: {
470
+ return {
471
+ custom_id: component.customID,
472
+ max_values: component.maxValues,
473
+ min_values: component.minValues,
474
+ options: component.options.map(o => ({
475
+ default: o.default,
476
+ description: o.description,
477
+ label: o.label,
478
+ value: o.value
479
+ })),
480
+ required: component.required,
481
+ type: component.type
482
+ };
483
+ }
484
+ default: {
485
+ return component;
486
+ }
487
+ }
488
+ }
489
+ componentsToParsed(components) {
490
+ return components.map(component => this.componentToParsed(component));
491
+ }
492
+ componentsToRaw(components) {
493
+ return components.map(component => this.componentToRaw(component));
494
+ }
495
+ convertApplicationEmoji(raw) {
496
+ return this.convertGuildEmoji(raw);
497
+ }
498
+ convertGuildEmoji(raw) {
499
+ return {
500
+ animated: raw.animated,
501
+ available: raw.available,
502
+ id: raw.id,
503
+ managed: raw.managed,
504
+ name: raw.name,
505
+ requireColons: raw.require_colons,
506
+ roles: raw.roles,
507
+ user: raw.user ? this._client.users.update(raw.user) : undefined
508
+ };
509
+ }
510
+ convertImage(img) {
511
+ if (Buffer.isBuffer(img)) {
512
+ const b64 = img.toString("base64");
513
+ let mime;
514
+ const magicMap = [
515
+ // 47 49 46 38
516
+ ["image/gif", /^47494638/],
517
+ // 89 50 4E 47
518
+ ["image/png", /^89504E47/],
519
+ // FF D8 FF
520
+ ["image/jpeg", /^FFD8FF/],
521
+ // 52 49 46 46 ?? ?? ?? ?? 57 45 42 50
522
+ ["image/webp", /^52494646\d{8}57454250/],
523
+ // 02 27 62 20 22 0 - lottie JSON (assuming all files will start with {"v":")
524
+ ["application/json", /^02276220220/]
525
+ ];
526
+ for (const format of magicMap) {
527
+ if (format[1].test(this.getMagic(img, 16))) {
528
+ mime = format[0];
529
+ break;
530
+ }
531
+ }
532
+ if (!mime) {
533
+ throw new TypeError(`Failed to determine image format. (magic: ${this.getMagic(img, 16)})`);
534
+ }
535
+ img = `data:${mime};base64,${b64}`;
536
+ }
537
+ return img;
538
+ }
539
+ convertSound(audio) {
540
+ if (Buffer.isBuffer(audio)) {
541
+ const b64 = audio.toString("base64");
542
+ let mime;
543
+ const magicMap = [
544
+ // 49 44 33
545
+ ["audio/mpeg", /^494433/],
546
+ // FF FB
547
+ ["audio/mpeg", /^FFFB/],
548
+ // 4F 67 67 53
549
+ ["audio/ogg", /^4F676753/]
550
+ ];
551
+ for (const format of magicMap) {
552
+ if (format[1].test(this.getMagic(audio, 16))) {
553
+ mime = format[0];
554
+ break;
555
+ }
556
+ }
557
+ if (!mime) {
558
+ throw new TypeError(`Failed to determine sound format. (magic: ${this.getMagic(audio, 16)})`);
559
+ }
560
+ audio = `data:${mime};base64,${b64}`;
561
+ }
562
+ return audio;
563
+ }
564
+ convertSticker(raw) {
565
+ return {
566
+ asset: raw.asset,
567
+ available: raw.available,
568
+ description: raw.description,
569
+ formatType: raw.format_type,
570
+ guildID: raw.guild_id,
571
+ id: raw.id,
572
+ name: raw.name,
573
+ packID: raw.pack_id,
574
+ sortValue: raw.sort_value,
575
+ tags: raw.tags,
576
+ type: raw.type,
577
+ user: raw.user ? this._client.users.update(raw.user) : undefined
578
+ };
579
+ }
580
+ async detectMissingPrivilegedIntents(intents) {
581
+ var _a;
582
+ const application = this._client["_application"] || await this._client.rest.applications.getClient();
583
+ intents ?? (intents = this._client.shards.options.intents);
584
+ (_a = this._client)["_application"] ?? (_a["_application"] = application);
585
+ const missing = [];
586
+ const check = (intent, allowed) => {
587
+ if ((intents & intent) === intent && !allowed.some(flag => (application.flags & flag) === flag)) {
588
+ missing.push(Constants_1.Intents[intent]);
589
+ }
590
+ };
591
+ for (const [intent, allowed] of Constants_1.PrivilegedIntentMapping) {
592
+ check(intent, allowed);
593
+ }
594
+ return missing;
595
+ }
596
+ embedsToParsed(embeds) {
597
+ return embeds.map(embed => ({
598
+ author: embed.author === undefined ? undefined : {
599
+ name: embed.author.name,
600
+ iconURL: embed.author.icon_url,
601
+ proxyIconURL: embed.author.proxy_icon_url
602
+ },
603
+ color: embed.color,
604
+ description: embed.description,
605
+ fields: embed.fields?.map(field => ({
606
+ inline: field.inline,
607
+ name: field.name,
608
+ value: field.value
609
+ })),
610
+ flags: embed.flags,
611
+ footer: embed.footer === undefined ? undefined : {
612
+ flags: embed.footer.flags,
613
+ iconURL: embed.footer.icon_url,
614
+ proxyIconURL: embed.footer.proxy_icon_url,
615
+ text: embed.footer.text
616
+ },
617
+ timestamp: embed.timestamp,
618
+ title: embed.title,
619
+ image: embed.image === undefined ? undefined : {
620
+ flags: embed.image.flags,
621
+ height: embed.image.height,
622
+ proxyURL: embed.image.proxy_url,
623
+ url: embed.image.url,
624
+ width: embed.image.width
625
+ },
626
+ provider: embed.provider === undefined ? undefined : {
627
+ name: embed.provider.name,
628
+ url: embed.provider.url
629
+ },
630
+ thumbnail: embed.thumbnail === undefined ? undefined : {
631
+ url: embed.thumbnail.url,
632
+ height: embed.thumbnail.height,
633
+ proxyURL: embed.thumbnail.proxy_url,
634
+ width: embed.thumbnail.width
635
+ },
636
+ url: embed.url,
637
+ type: embed.type,
638
+ video: embed.video === undefined ? undefined : {
639
+ height: embed.video.height,
640
+ proxyURL: embed.video.proxy_url,
641
+ url: embed.video.url,
642
+ width: embed.video.width
643
+ }
644
+ }));
645
+ }
646
+ embedsToRaw(embeds) {
647
+ return embeds.map(embed => ({
648
+ author: embed.author === undefined ? undefined : {
649
+ name: embed.author.name,
650
+ icon_url: embed.author.iconURL,
651
+ url: embed.author.url
652
+ },
653
+ color: embed.color,
654
+ description: embed.description,
655
+ fields: embed.fields?.map(field => ({
656
+ inline: field.inline,
657
+ name: field.name,
658
+ value: field.value
659
+ })),
660
+ footer: embed.footer === undefined ? undefined : {
661
+ text: embed.footer.text,
662
+ icon_url: embed.footer.iconURL
663
+ },
664
+ timestamp: embed.timestamp,
665
+ title: embed.title,
666
+ image: embed.image === undefined ? undefined : { url: embed.image.url },
667
+ thumbnail: embed.thumbnail === undefined ? undefined : { url: embed.thumbnail.url },
668
+ url: embed.url
669
+ }));
670
+ }
671
+ formatAllowedMentions(allowed) {
672
+ const result = { parse: [] };
673
+ if (!allowed) {
674
+ return this.formatAllowedMentions(this._client.options.allowedMentions);
675
+ }
676
+ if (allowed.everyone === true) {
677
+ result.parse.push("everyone");
678
+ }
679
+ if (allowed.roles === true) {
680
+ result.parse.push("roles");
681
+ }
682
+ else if (Array.isArray(allowed.roles)) {
683
+ result.roles = allowed.roles;
684
+ }
685
+ if (allowed.users === true) {
686
+ result.parse.push("users");
687
+ }
688
+ else if (Array.isArray(allowed.users)) {
689
+ result.users = allowed.users;
690
+ }
691
+ if (allowed.repliedUser === true) {
692
+ result.replied_user = true;
693
+ }
694
+ return result;
695
+ }
696
+ formatImage(url, format, size) {
697
+ if (!format || !Constants_1.ImageFormats.includes(format.toLowerCase())) {
698
+ format = url.includes("/a_") ? "gif" : this._client.options.defaultImageFormat;
699
+ }
700
+ if (!size || !Constants_1.MEDIA_PROXY_SIZES.includes(size)) {
701
+ size = this._client.options.defaultImageSize;
702
+ }
703
+ return `${Routes_1.CDN_URL}${url}.${format}?size=${size}`;
704
+ }
705
+ getMagic(file, len = 4) {
706
+ return [...new Uint8Array(file.subarray(0, len))].map(b => b.toString(16).padStart(2, "0")).join("").toUpperCase();
707
+ }
708
+ modalSubmitComponentToParsed(component) {
709
+ switch (component.type) {
710
+ case Constants_1.ComponentTypes.CHECKBOX:
711
+ case Constants_1.ComponentTypes.RADIO_GROUP:
712
+ case Constants_1.ComponentTypes.TEXT_INPUT: {
713
+ return {
714
+ customID: component.custom_id,
715
+ type: component.type,
716
+ value: component.value
717
+ };
718
+ }
719
+ case Constants_1.ComponentTypes.STRING_SELECT:
720
+ case Constants_1.ComponentTypes.USER_SELECT:
721
+ case Constants_1.ComponentTypes.ROLE_SELECT:
722
+ case Constants_1.ComponentTypes.MENTIONABLE_SELECT:
723
+ case Constants_1.ComponentTypes.CHANNEL_SELECT:
724
+ case Constants_1.ComponentTypes.CHECKBOX_GROUP:
725
+ case Constants_1.ComponentTypes.FILE_UPLOAD: {
726
+ return {
727
+ customID: component.custom_id,
728
+ type: component.type,
729
+ values: component.values
730
+ };
731
+ }
732
+ default: {
733
+ return component;
734
+ }
735
+ }
736
+ }
737
+ modalSubmitComponentsToParsed(components) {
738
+ return components.map(row => {
739
+ if (row.type === Constants_1.ComponentTypes.ACTION_ROW) {
740
+ return {
741
+ type: row.type,
742
+ components: row.components ? row.components.map(component => this.modalSubmitComponentToParsed(component)) : undefined
743
+ };
744
+ }
745
+ else {
746
+ return {
747
+ type: row.type,
748
+ component: row.component ? this.modalSubmitComponentToParsed(row.component) : undefined
749
+ };
750
+ }
751
+ });
752
+ }
753
+ optionToParsed(option) {
754
+ return {
755
+ autocomplete: option.autocomplete,
756
+ channelTypes: option.channel_types,
757
+ choices: option.choices,
758
+ description: option.description,
759
+ descriptionLocalizations: option.description_localizations,
760
+ descriptionLocalized: option.description_localized,
761
+ max_length: option.max_length,
762
+ max_value: option.max_value,
763
+ min_length: option.min_length,
764
+ min_value: option.min_value,
765
+ name: option.name,
766
+ nameLocalizations: option.name_localizations,
767
+ nameLocalized: option.name_localized,
768
+ options: option.options?.map(o => this.optionToParsed(o)),
769
+ required: option.required,
770
+ type: option.type
771
+ };
772
+ }
773
+ optionToRaw(option) {
774
+ const opt = option;
775
+ return {
776
+ autocomplete: opt.autocomplete,
777
+ channel_types: opt.channelTypes,
778
+ choices: opt.choices?.map(choice => ({
779
+ name: choice.name,
780
+ name_localizations: choice.nameLocalizations,
781
+ value: choice.value
782
+ })),
783
+ description: opt.description,
784
+ description_localizations: opt.descriptionLocalizations,
785
+ max_length: opt.maxLength,
786
+ max_value: opt.maxValue,
787
+ min_length: opt.minLength,
788
+ min_value: opt.minValue,
789
+ name: opt.name,
790
+ name_localizations: opt.nameLocalizations,
791
+ options: opt.options?.map(o => this.optionToRaw(o)),
792
+ required: opt.required,
793
+ type: opt.type
794
+ };
795
+ }
796
+ /** @internal */
797
+ replacePollAnswer(poll, answerID, count, users) {
798
+ let answerCount = poll.results.answerCounts.find(a => a.id === answerID);
799
+ if (!answerCount) {
800
+ answerCount = {
801
+ count,
802
+ id: answerID,
803
+ users: [],
804
+ meVoted: false
805
+ };
806
+ }
807
+ answerCount.count = count;
808
+ if (users) {
809
+ answerCount.users = users;
810
+ answerCount.meVoted = (this._client["_user"] && users.includes(this._client["_user"]?.id)) ?? false;
811
+ }
812
+ }
813
+ updateChannel(channelData) {
814
+ guild: if (channelData.guild_id) {
815
+ const guild = this._client.guilds.get(channelData.guild_id);
816
+ if (guild) {
817
+ if (Constants_1.ThreadChannelTypes.includes(channelData.type)) {
818
+ if (!channelData.parent_id) {
819
+ break guild;
820
+ }
821
+ return guild.threads.update(channelData);
822
+ }
823
+ else {
824
+ return guild.channels.update(channelData);
825
+ }
826
+ }
827
+ }
828
+ switch (channelData.type) {
829
+ case Constants_1.ChannelTypes.DM: return this._client.privateChannels.update(channelData);
830
+ case Constants_1.ChannelTypes.GROUP_DM: return this._client.groupChannels.update(channelData);
831
+ default: return Channel_1.default.from(channelData, this._client);
832
+ }
833
+ }
834
+ /** @internal */
835
+ updateEntitlement(data) {
836
+ if (this._client["_application"] === undefined) {
837
+ return "subscription_id" in data && data.subscription_id ?
838
+ new Entitlement_1.default(data, this._client) :
839
+ new TestEntitlement_1.default(data, this._client);
840
+ }
841
+ else {
842
+ return this._client.application.entitlements.update(data);
843
+ }
844
+ }
845
+ /** @internal */
846
+ updateMember(guildID, memberID, member) {
847
+ const guild = this._client.guilds.get(guildID);
848
+ if (guild && this._client["_user"] && this._client.user.id === memberID) {
849
+ if (guild["_clientMember"]) {
850
+ guild["_clientMember"]["update"](member);
851
+ }
852
+ else {
853
+ guild["_clientMember"] = guild.members.update({ ...member, id: memberID }, guildID);
854
+ }
855
+ return guild["_clientMember"];
856
+ }
857
+ return guild ? guild.members.update({ ...member, id: memberID }, guildID) : new Member_1.default({ ...member, id: memberID }, this._client, guildID);
858
+ }
859
+ /** @internal */
860
+ updateMessage(data) {
861
+ const channel = this._client.getChannel(data.channel_id);
862
+ if (channel && "messages" in channel) {
863
+ return channel.messages.update(data);
864
+ }
865
+ return new Message_1.default(data, this._client);
866
+ }
867
+ /** @internal */
868
+ updatePollAnswer(poll, answerID, count, user) {
869
+ let answerCount = poll.results.answerCounts.find(a => a.id === answerID);
870
+ if (!answerCount) {
871
+ if (count === -1) {
872
+ return;
873
+ }
874
+ answerCount = {
875
+ count,
876
+ id: answerID,
877
+ users: user ? [user] : [],
878
+ meVoted: user === this._client["_user"]?.id
879
+ };
880
+ poll.results.answerCounts.push(answerCount);
881
+ return;
882
+ }
883
+ answerCount.count += count;
884
+ if (user) {
885
+ if (count === 1 && !answerCount.users.includes(user)) {
886
+ answerCount.users.push(user);
887
+ answerCount.meVoted = user === this._client["_user"]?.id;
888
+ }
889
+ else if (count === -1 && answerCount.users.includes(user)) {
890
+ answerCount.users.splice(answerCount.users.indexOf(user), 1);
891
+ if (user === this._client["_user"]?.id) {
892
+ answerCount.meVoted = false;
893
+ }
894
+ }
895
+ }
896
+ }
897
+ /** @internal */
898
+ updateThread(threadData) {
899
+ const guild = this._client.guilds.get(threadData.guild_id);
900
+ if (guild) {
901
+ return guild.threads.update(threadData);
902
+ }
903
+ return Channel_1.default.from(threadData, this._client);
904
+ }
905
+ }
906
+ exports.default = Util;