@erinjs/core 1.0.0 → 1.2.4

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 (394) hide show
  1. package/{core/LICENSE → LICENSE} +203 -203
  2. package/README.md +46 -0
  3. package/dist/index.d.mts +2084 -0
  4. package/dist/index.d.ts +2084 -0
  5. package/dist/index.js +3867 -0
  6. package/dist/index.mjs +3809 -0
  7. package/package.json +50 -15
  8. package/core/.changeset/README.md +0 -8
  9. package/core/.changeset/community-bootstrap-release.md +0 -17
  10. package/core/.changeset/config.json +0 -11
  11. package/core/.changeset/no-changelog.js +0 -16
  12. package/core/.changeset/pre.json +0 -17
  13. package/core/.editorconfig +0 -13
  14. package/core/.gitattributes +0 -2
  15. package/core/.github/CODE_OF_CONDUCT.md +0 -23
  16. package/core/.github/FUNDING.yml +0 -7
  17. package/core/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
  18. package/core/.github/ISSUE_TEMPLATE/feature_request.md +0 -23
  19. package/core/.github/PULL_REQUEST_TEMPLATE.md +0 -16
  20. package/core/.github/dependabot.yml +0 -16
  21. package/core/.github/workflows/autoapp.yml +0 -16
  22. package/core/.github/workflows/ci.yml +0 -187
  23. package/core/.github/workflows/codeql.yml +0 -30
  24. package/core/.github/workflows/deploy-docs.yml +0 -54
  25. package/core/.github/workflows/publish.yml +0 -43
  26. package/core/.lintstagedrc.json +0 -4
  27. package/core/.nvmrc +0 -1
  28. package/core/.prettierignore +0 -8
  29. package/core/.prettierrc +0 -11
  30. package/core/CONTRIBUTING.md +0 -70
  31. package/core/README.md +0 -61
  32. package/core/SECURITY.md +0 -21
  33. package/core/apps/docs/index.html +0 -28
  34. package/core/apps/docs/middleware.ts +0 -21
  35. package/core/apps/docs/package.json +0 -33
  36. package/core/apps/docs/public/@flux.png +0 -0
  37. package/core/apps/docs/public/docs/latest/guides.json +0 -1420
  38. package/core/apps/docs/public/docs/latest/main.json +0 -14981
  39. package/core/apps/docs/public/docs/latest/rag-index.json +0 -1
  40. package/core/apps/docs/public/docs/v1.0.5/guides.json +0 -226
  41. package/core/apps/docs/public/docs/v1.0.5/main.json +0 -7920
  42. package/core/apps/docs/public/docs/v1.0.6/guides.json +0 -226
  43. package/core/apps/docs/public/docs/v1.0.6/main.json +0 -7920
  44. package/core/apps/docs/public/docs/v1.0.7/guides.json +0 -259
  45. package/core/apps/docs/public/docs/v1.0.7/main.json +0 -8652
  46. package/core/apps/docs/public/docs/v1.0.8/guides.json +0 -313
  47. package/core/apps/docs/public/docs/v1.0.8/main.json +0 -9618
  48. package/core/apps/docs/public/docs/v1.0.9/guides.json +0 -319
  49. package/core/apps/docs/public/docs/v1.0.9/main.json +0 -10694
  50. package/core/apps/docs/public/docs/v1.1.0/guides.json +0 -589
  51. package/core/apps/docs/public/docs/v1.1.0/main.json +0 -12576
  52. package/core/apps/docs/public/docs/v1.1.2/guides.json +0 -650
  53. package/core/apps/docs/public/docs/v1.1.2/main.json +0 -13239
  54. package/core/apps/docs/public/docs/v1.1.3/guides.json +0 -650
  55. package/core/apps/docs/public/docs/v1.1.3/main.json +0 -13239
  56. package/core/apps/docs/public/docs/v1.1.4/guides.json +0 -708
  57. package/core/apps/docs/public/docs/v1.1.4/main.json +0 -13231
  58. package/core/apps/docs/public/docs/v1.1.5/guides.json +0 -1035
  59. package/core/apps/docs/public/docs/v1.1.5/main.json +0 -13838
  60. package/core/apps/docs/public/docs/v1.1.6/guides.json +0 -1041
  61. package/core/apps/docs/public/docs/v1.1.6/main.json +0 -14313
  62. package/core/apps/docs/public/docs/v1.1.8/guides.json +0 -1047
  63. package/core/apps/docs/public/docs/v1.1.8/main.json +0 -14421
  64. package/core/apps/docs/public/docs/v1.1.9/guides.json +0 -1047
  65. package/core/apps/docs/public/docs/v1.1.9/main.json +0 -14421
  66. package/core/apps/docs/public/docs/v1.2.0/guides.json +0 -1212
  67. package/core/apps/docs/public/docs/v1.2.0/main.json +0 -14663
  68. package/core/apps/docs/public/docs/v1.2.1/guides.json +0 -1293
  69. package/core/apps/docs/public/docs/v1.2.1/main.json +0 -14828
  70. package/core/apps/docs/public/docs/v1.2.2/guides.json +0 -1293
  71. package/core/apps/docs/public/docs/v1.2.2/main.json +0 -15025
  72. package/core/apps/docs/public/docs/v1.2.3/guides.json +0 -1420
  73. package/core/apps/docs/public/docs/v1.2.3/main.json +0 -14954
  74. package/core/apps/docs/public/docs/v1.2.4/guides.json +0 -1420
  75. package/core/apps/docs/public/docs/v1.2.4/main.json +0 -14981
  76. package/core/apps/docs/public/docs/versions.json +0 -24
  77. package/core/apps/docs/public/flux.png +0 -0
  78. package/core/apps/docs/public/locales/en.json +0 -50
  79. package/core/apps/docs/public/locales/guides-en.json +0 -512
  80. package/core/apps/docs/public/robots.txt +0 -4
  81. package/core/apps/docs/public/sitemap.xml +0 -33
  82. package/core/apps/docs/src/App.vue +0 -538
  83. package/core/apps/docs/src/components/ApiCategorySection.vue +0 -42
  84. package/core/apps/docs/src/components/ApiDiscordCompat.vue +0 -65
  85. package/core/apps/docs/src/components/ApiEndpointCard.vue +0 -313
  86. package/core/apps/docs/src/components/ApiSchemaBlock.vue +0 -131
  87. package/core/apps/docs/src/components/CodeBlock.vue +0 -177
  88. package/core/apps/docs/src/components/CommunityCallout.vue +0 -90
  89. package/core/apps/docs/src/components/ConstructorSection.vue +0 -82
  90. package/core/apps/docs/src/components/DocDescription.vue +0 -40
  91. package/core/apps/docs/src/components/FluxerLogo.vue +0 -3
  92. package/core/apps/docs/src/components/Footer.vue +0 -106
  93. package/core/apps/docs/src/components/GuideCodeBlock.vue +0 -102
  94. package/core/apps/docs/src/components/GuideDiscordCompat.vue +0 -77
  95. package/core/apps/docs/src/components/GuideDiscordCompatCallout.vue +0 -83
  96. package/core/apps/docs/src/components/GuideTable.vue +0 -77
  97. package/core/apps/docs/src/components/GuideTip.vue +0 -38
  98. package/core/apps/docs/src/components/MethodsSection.vue +0 -195
  99. package/core/apps/docs/src/components/ParamsTable.vue +0 -70
  100. package/core/apps/docs/src/components/PropertiesSection.vue +0 -143
  101. package/core/apps/docs/src/components/SearchBar.vue +0 -76
  102. package/core/apps/docs/src/components/SearchModal.vue +0 -361
  103. package/core/apps/docs/src/components/SidebarNav.vue +0 -225
  104. package/core/apps/docs/src/components/SponsorBanner.vue +0 -153
  105. package/core/apps/docs/src/components/TypeSignature.vue +0 -187
  106. package/core/apps/docs/src/components/VersionPicker.vue +0 -191
  107. package/core/apps/docs/src/composables/useSearchIndex.ts +0 -144
  108. package/core/apps/docs/src/composables/useVersionedPath.ts +0 -20
  109. package/core/apps/docs/src/data/apiEndpoints.ts +0 -1073
  110. package/core/apps/docs/src/data/changelog.ts +0 -717
  111. package/core/apps/docs/src/data/guides.ts +0 -2362
  112. package/core/apps/docs/src/env.d.ts +0 -7
  113. package/core/apps/docs/src/locales/guides-en.json +0 -512
  114. package/core/apps/docs/src/main.ts +0 -27
  115. package/core/apps/docs/src/pages/ApiReferenceLayout.vue +0 -175
  116. package/core/apps/docs/src/pages/ApiReferencePage.vue +0 -128
  117. package/core/apps/docs/src/pages/Changelog.vue +0 -288
  118. package/core/apps/docs/src/pages/ClassPage.vue +0 -319
  119. package/core/apps/docs/src/pages/ClassesList.vue +0 -100
  120. package/core/apps/docs/src/pages/DocsLayout.vue +0 -127
  121. package/core/apps/docs/src/pages/GuidePage.vue +0 -279
  122. package/core/apps/docs/src/pages/GuidesIndex.vue +0 -166
  123. package/core/apps/docs/src/pages/GuidesLayout.vue +0 -245
  124. package/core/apps/docs/src/pages/Home.vue +0 -125
  125. package/core/apps/docs/src/pages/NotFound.vue +0 -57
  126. package/core/apps/docs/src/pages/TypedefPage.vue +0 -230
  127. package/core/apps/docs/src/pages/TypedefsList.vue +0 -168
  128. package/core/apps/docs/src/pages/VersionLayout.vue +0 -15
  129. package/core/apps/docs/src/router.ts +0 -73
  130. package/core/apps/docs/src/stores/docs.ts +0 -54
  131. package/core/apps/docs/src/stores/guides.ts +0 -53
  132. package/core/apps/docs/src/stores/version.ts +0 -67
  133. package/core/apps/docs/src/styles/main.css +0 -278
  134. package/core/apps/docs/src/styles/prism.css +0 -95
  135. package/core/apps/docs/src/types/doc-schema.ts +0 -112
  136. package/core/apps/docs/tsconfig.json +0 -17
  137. package/core/apps/docs/tsconfig.node.json +0 -10
  138. package/core/apps/docs/vite.config.d.ts +0 -2
  139. package/core/apps/docs/vite.config.js +0 -26
  140. package/core/apps/docs/vite.config.ts +0 -28
  141. package/core/apps/docs-vitepress/.vitepress/config.ts +0 -141
  142. package/core/apps/docs-vitepress/api-data/latest/main.json +0 -15035
  143. package/core/apps/docs-vitepress/api-data/v1.2.4/main.json +0 -15035
  144. package/core/apps/docs-vitepress/api-data/versions.json +0 -6
  145. package/core/apps/docs-vitepress/index.md +0 -15
  146. package/core/apps/docs-vitepress/package-lock.json +0 -2924
  147. package/core/apps/docs-vitepress/package.json +0 -20
  148. package/core/apps/docs-vitepress/public/CNAME +0 -1
  149. package/core/apps/docs-vitepress/scripts/generate-api.ts +0 -243
  150. package/core/apps/docs-vitepress/scripts/migrate-guides.ts +0 -129
  151. package/core/apps/docs-vitepress/tsconfig.json +0 -11
  152. package/core/apps/docs-vitepress/v/latest/guides/attachments-by-url.md +0 -57
  153. package/core/apps/docs-vitepress/v/latest/guides/attachments.md +0 -62
  154. package/core/apps/docs-vitepress/v/latest/guides/basic-bot.md +0 -49
  155. package/core/apps/docs-vitepress/v/latest/guides/channels.md +0 -180
  156. package/core/apps/docs-vitepress/v/latest/guides/deprecated-apis.md +0 -58
  157. package/core/apps/docs-vitepress/v/latest/guides/discord-js-compatibility.md +0 -42
  158. package/core/apps/docs-vitepress/v/latest/guides/editing-embeds.md +0 -65
  159. package/core/apps/docs-vitepress/v/latest/guides/embed-media.md +0 -87
  160. package/core/apps/docs-vitepress/v/latest/guides/embeds.md +0 -166
  161. package/core/apps/docs-vitepress/v/latest/guides/emojis.md +0 -77
  162. package/core/apps/docs-vitepress/v/latest/guides/events.md +0 -202
  163. package/core/apps/docs-vitepress/v/latest/guides/gifs.md +0 -47
  164. package/core/apps/docs-vitepress/v/latest/guides/installation.md +0 -10
  165. package/core/apps/docs-vitepress/v/latest/guides/moderation.md +0 -89
  166. package/core/apps/docs-vitepress/v/latest/guides/permissions.md +0 -130
  167. package/core/apps/docs-vitepress/v/latest/guides/prefix-commands.md +0 -41
  168. package/core/apps/docs-vitepress/v/latest/guides/profile-urls.md +0 -58
  169. package/core/apps/docs-vitepress/v/latest/guides/reactions.md +0 -69
  170. package/core/apps/docs-vitepress/v/latest/guides/roles.md +0 -130
  171. package/core/apps/docs-vitepress/v/latest/guides/sending-without-reply.md +0 -172
  172. package/core/apps/docs-vitepress/v/latest/guides/voice.md +0 -109
  173. package/core/apps/docs-vitepress/v/latest/guides/wait-for-guilds.md +0 -37
  174. package/core/apps/docs-vitepress/v/latest/guides/webhook-attachments-embeds.md +0 -73
  175. package/core/apps/docs-vitepress/v/latest/guides/webhooks.md +0 -131
  176. package/core/eslint.config.js +0 -80
  177. package/core/examples/.env.example +0 -22
  178. package/core/examples/README.md +0 -68
  179. package/core/examples/first-steps-bot.js +0 -118
  180. package/core/examples/minimal-bot.js +0 -17
  181. package/core/examples/moderation-bot.js +0 -209
  182. package/core/examples/package.json +0 -14
  183. package/core/examples/ping-bot.js +0 -1146
  184. package/core/examples/reaction-bot.js +0 -70
  185. package/core/examples/reaction-roles-bot.js +0 -140
  186. package/core/examples/webhook-bot.js +0 -239
  187. package/core/flux.png +0 -0
  188. package/core/package.json +0 -78
  189. package/core/packages/builders/package.json +0 -51
  190. package/core/packages/builders/src/index.ts +0 -13
  191. package/core/packages/builders/src/messages/AttachmentBuilder.test.ts +0 -79
  192. package/core/packages/builders/src/messages/AttachmentBuilder.ts +0 -69
  193. package/core/packages/builders/src/messages/EmbedBuilder.test.ts +0 -266
  194. package/core/packages/builders/src/messages/EmbedBuilder.ts +0 -239
  195. package/core/packages/builders/src/messages/MessagePayload.test.ts +0 -118
  196. package/core/packages/builders/src/messages/MessagePayload.ts +0 -122
  197. package/core/packages/builders/tsconfig.json +0 -9
  198. package/core/packages/builders/tsup.config.ts +0 -9
  199. package/core/packages/builders/vitest.config.ts +0 -9
  200. package/core/packages/collection/package.json +0 -47
  201. package/core/packages/collection/src/Collection.test.ts +0 -232
  202. package/core/packages/collection/src/Collection.ts +0 -196
  203. package/core/packages/collection/src/index.ts +0 -1
  204. package/core/packages/collection/tsconfig.json +0 -9
  205. package/core/packages/collection/tsup.config.ts +0 -9
  206. package/core/packages/collection/vitest.config.ts +0 -9
  207. package/core/packages/docgen/package.json +0 -26
  208. package/core/packages/docgen/src/extract.ts +0 -262
  209. package/core/packages/docgen/src/formatType.ts +0 -24
  210. package/core/packages/docgen/src/index.ts +0 -103
  211. package/core/packages/docgen/src/schema.ts +0 -100
  212. package/core/packages/docgen/src/visitor.ts +0 -147
  213. package/core/packages/docgen/tsconfig.json +0 -9
  214. package/core/packages/docgen/tsup.config.ts +0 -9
  215. package/core/packages/fluxer-core/README.md +0 -26
  216. package/core/packages/fluxer-core/package.json +0 -60
  217. package/core/packages/fluxer-core/src/client/ChannelManager.ts +0 -143
  218. package/core/packages/fluxer-core/src/client/Client.gateway.test.ts +0 -84
  219. package/core/packages/fluxer-core/src/client/Client.resolveEmoji.test.ts +0 -45
  220. package/core/packages/fluxer-core/src/client/Client.ts +0 -558
  221. package/core/packages/fluxer-core/src/client/ClientUser.ts +0 -40
  222. package/core/packages/fluxer-core/src/client/EventHandlerRegistry.ts +0 -469
  223. package/core/packages/fluxer-core/src/client/GuildManager.ts +0 -79
  224. package/core/packages/fluxer-core/src/client/GuildMemberManager.ts +0 -91
  225. package/core/packages/fluxer-core/src/client/MessageManager.ts +0 -58
  226. package/core/packages/fluxer-core/src/client/UsersManager.ts +0 -122
  227. package/core/packages/fluxer-core/src/errors/ErrorCodes.test.ts +0 -19
  228. package/core/packages/fluxer-core/src/errors/ErrorCodes.ts +0 -12
  229. package/core/packages/fluxer-core/src/errors/FluxerError.test.ts +0 -32
  230. package/core/packages/fluxer-core/src/errors/FluxerError.ts +0 -15
  231. package/core/packages/fluxer-core/src/index.ts +0 -85
  232. package/core/packages/fluxer-core/src/structures/Base.ts +0 -7
  233. package/core/packages/fluxer-core/src/structures/Channel.ts +0 -508
  234. package/core/packages/fluxer-core/src/structures/Guild.test.ts +0 -189
  235. package/core/packages/fluxer-core/src/structures/Guild.ts +0 -734
  236. package/core/packages/fluxer-core/src/structures/GuildBan.ts +0 -35
  237. package/core/packages/fluxer-core/src/structures/GuildEmoji.ts +0 -57
  238. package/core/packages/fluxer-core/src/structures/GuildMember.test.ts +0 -203
  239. package/core/packages/fluxer-core/src/structures/GuildMember.ts +0 -213
  240. package/core/packages/fluxer-core/src/structures/GuildMemberRoleManager.ts +0 -121
  241. package/core/packages/fluxer-core/src/structures/GuildSticker.ts +0 -56
  242. package/core/packages/fluxer-core/src/structures/Invite.test.ts +0 -103
  243. package/core/packages/fluxer-core/src/structures/Invite.ts +0 -121
  244. package/core/packages/fluxer-core/src/structures/Message.test.ts +0 -109
  245. package/core/packages/fluxer-core/src/structures/Message.ts +0 -397
  246. package/core/packages/fluxer-core/src/structures/MessageReaction.ts +0 -72
  247. package/core/packages/fluxer-core/src/structures/PartialMessage.ts +0 -12
  248. package/core/packages/fluxer-core/src/structures/Role.test.ts +0 -77
  249. package/core/packages/fluxer-core/src/structures/Role.ts +0 -112
  250. package/core/packages/fluxer-core/src/structures/User.test.ts +0 -110
  251. package/core/packages/fluxer-core/src/structures/User.ts +0 -109
  252. package/core/packages/fluxer-core/src/structures/Webhook.test.ts +0 -109
  253. package/core/packages/fluxer-core/src/structures/Webhook.ts +0 -258
  254. package/core/packages/fluxer-core/src/util/Constants.test.ts +0 -16
  255. package/core/packages/fluxer-core/src/util/Constants.ts +0 -7
  256. package/core/packages/fluxer-core/src/util/Events.ts +0 -46
  257. package/core/packages/fluxer-core/src/util/MessageCollector.ts +0 -87
  258. package/core/packages/fluxer-core/src/util/Options.ts +0 -33
  259. package/core/packages/fluxer-core/src/util/ReactionCollector.ts +0 -116
  260. package/core/packages/fluxer-core/src/util/cdn.test.ts +0 -108
  261. package/core/packages/fluxer-core/src/util/cdn.ts +0 -130
  262. package/core/packages/fluxer-core/src/util/guildUtils.ts +0 -33
  263. package/core/packages/fluxer-core/src/util/messageUtils.test.ts +0 -74
  264. package/core/packages/fluxer-core/src/util/messageUtils.ts +0 -119
  265. package/core/packages/fluxer-core/src/util/permissions.test.ts +0 -95
  266. package/core/packages/fluxer-core/src/util/permissions.ts +0 -43
  267. package/core/packages/fluxer-core/tsconfig.json +0 -9
  268. package/core/packages/fluxer-core/tsup.config.ts +0 -9
  269. package/core/packages/fluxer-core/vitest.config.ts +0 -9
  270. package/core/packages/rest/package.json +0 -52
  271. package/core/packages/rest/src/REST.test.ts +0 -64
  272. package/core/packages/rest/src/REST.ts +0 -90
  273. package/core/packages/rest/src/RateLimitManager.test.ts +0 -71
  274. package/core/packages/rest/src/RateLimitManager.ts +0 -60
  275. package/core/packages/rest/src/RequestManager.test.ts +0 -87
  276. package/core/packages/rest/src/RequestManager.ts +0 -172
  277. package/core/packages/rest/src/errors/FluxerAPIError.test.ts +0 -57
  278. package/core/packages/rest/src/errors/FluxerAPIError.ts +0 -21
  279. package/core/packages/rest/src/errors/HTTPError.test.ts +0 -55
  280. package/core/packages/rest/src/errors/HTTPError.ts +0 -25
  281. package/core/packages/rest/src/errors/RateLimitError.test.ts +0 -41
  282. package/core/packages/rest/src/errors/RateLimitError.ts +0 -15
  283. package/core/packages/rest/src/errors/index.ts +0 -3
  284. package/core/packages/rest/src/index.ts +0 -6
  285. package/core/packages/rest/src/utils/constants.test.ts +0 -31
  286. package/core/packages/rest/src/utils/constants.ts +0 -5
  287. package/core/packages/rest/src/utils/files.test.ts +0 -37
  288. package/core/packages/rest/src/utils/files.ts +0 -75
  289. package/core/packages/rest/tsconfig.json +0 -9
  290. package/core/packages/rest/tsup.config.ts +0 -9
  291. package/core/packages/rest/vitest.config.ts +0 -9
  292. package/core/packages/types/package.json +0 -46
  293. package/core/packages/types/src/api/ban.ts +0 -8
  294. package/core/packages/types/src/api/channel.ts +0 -65
  295. package/core/packages/types/src/api/embed.ts +0 -82
  296. package/core/packages/types/src/api/emoji.ts +0 -12
  297. package/core/packages/types/src/api/errors.ts +0 -68
  298. package/core/packages/types/src/api/gateway.ts +0 -14
  299. package/core/packages/types/src/api/guild.ts +0 -123
  300. package/core/packages/types/src/api/index.ts +0 -15
  301. package/core/packages/types/src/api/instance.ts +0 -32
  302. package/core/packages/types/src/api/interaction.ts +0 -26
  303. package/core/packages/types/src/api/invite.ts +0 -28
  304. package/core/packages/types/src/api/message.ts +0 -140
  305. package/core/packages/types/src/api/role.ts +0 -41
  306. package/core/packages/types/src/api/sticker.ts +0 -14
  307. package/core/packages/types/src/api/user.ts +0 -79
  308. package/core/packages/types/src/api/webhook.ts +0 -41
  309. package/core/packages/types/src/common/index.ts +0 -1
  310. package/core/packages/types/src/common/snowflake.test.ts +0 -9
  311. package/core/packages/types/src/common/snowflake.ts +0 -8
  312. package/core/packages/types/src/gateway/events.ts +0 -189
  313. package/core/packages/types/src/gateway/index.ts +0 -3
  314. package/core/packages/types/src/gateway/opcodes.ts +0 -17
  315. package/core/packages/types/src/gateway/payloads.ts +0 -481
  316. package/core/packages/types/src/index.ts +0 -4
  317. package/core/packages/types/src/rest/index.ts +0 -1
  318. package/core/packages/types/src/rest/routes.test.ts +0 -169
  319. package/core/packages/types/src/rest/routes.ts +0 -109
  320. package/core/packages/types/tsconfig.json +0 -9
  321. package/core/packages/types/tsup.config.ts +0 -9
  322. package/core/packages/types/vitest.config.ts +0 -9
  323. package/core/packages/util/package.json +0 -51
  324. package/core/packages/util/src/BitField.test.ts +0 -96
  325. package/core/packages/util/src/BitField.ts +0 -105
  326. package/core/packages/util/src/MessageFlagsBitField.test.ts +0 -42
  327. package/core/packages/util/src/MessageFlagsBitField.ts +0 -20
  328. package/core/packages/util/src/PermissionsBitField.test.ts +0 -79
  329. package/core/packages/util/src/PermissionsBitField.ts +0 -97
  330. package/core/packages/util/src/SnowflakeUtil.test.ts +0 -69
  331. package/core/packages/util/src/SnowflakeUtil.ts +0 -65
  332. package/core/packages/util/src/UserFlagsBitField.test.ts +0 -39
  333. package/core/packages/util/src/UserFlagsBitField.ts +0 -48
  334. package/core/packages/util/src/deprecation.test.ts +0 -44
  335. package/core/packages/util/src/deprecation.ts +0 -28
  336. package/core/packages/util/src/emojiShortcodes.generated.ts +0 -5
  337. package/core/packages/util/src/emojiShortcodes.test.ts +0 -41
  338. package/core/packages/util/src/emojiShortcodes.ts +0 -22
  339. package/core/packages/util/src/formatters.test.ts +0 -65
  340. package/core/packages/util/src/formatters.ts +0 -35
  341. package/core/packages/util/src/index.ts +0 -34
  342. package/core/packages/util/src/resolvers.test.ts +0 -198
  343. package/core/packages/util/src/resolvers.ts +0 -127
  344. package/core/packages/util/src/tenorUtils.test.ts +0 -75
  345. package/core/packages/util/src/tenorUtils.ts +0 -86
  346. package/core/packages/util/tsconfig.json +0 -9
  347. package/core/packages/util/tsup.config.ts +0 -9
  348. package/core/packages/util/vitest.config.ts +0 -9
  349. package/core/packages/voice/README.md +0 -42
  350. package/core/packages/voice/package.json +0 -67
  351. package/core/packages/voice/src/LiveKitRtcConnection.receive.test.ts +0 -24
  352. package/core/packages/voice/src/LiveKitRtcConnection.ts +0 -1767
  353. package/core/packages/voice/src/VoiceConnection.ts +0 -413
  354. package/core/packages/voice/src/VoiceManager.receive.test.ts +0 -61
  355. package/core/packages/voice/src/VoiceManager.test.ts +0 -44
  356. package/core/packages/voice/src/VoiceManager.ts +0 -503
  357. package/core/packages/voice/src/exports.test.ts +0 -38
  358. package/core/packages/voice/src/index.ts +0 -51
  359. package/core/packages/voice/src/livekit.test.ts +0 -48
  360. package/core/packages/voice/src/livekit.ts +0 -33
  361. package/core/packages/voice/src/mp4box.d.ts +0 -32
  362. package/core/packages/voice/src/opusUtils.test.ts +0 -29
  363. package/core/packages/voice/src/opusUtils.ts +0 -86
  364. package/core/packages/voice/src/streamPreviewPlaceholder.test.ts +0 -16
  365. package/core/packages/voice/src/streamPreviewPlaceholder.ts +0 -8
  366. package/core/packages/voice/src/ws.d.ts +0 -1
  367. package/core/packages/voice/tsconfig.json +0 -5
  368. package/core/packages/voice/tsup.config.ts +0 -10
  369. package/core/packages/voice/vitest.config.ts +0 -9
  370. package/core/packages/ws/package.json +0 -52
  371. package/core/packages/ws/src/WebSocketManager.ts +0 -130
  372. package/core/packages/ws/src/WebSocketShard.ts +0 -296
  373. package/core/packages/ws/src/index.ts +0 -12
  374. package/core/packages/ws/src/utils/constants.test.ts +0 -46
  375. package/core/packages/ws/src/utils/constants.ts +0 -22
  376. package/core/packages/ws/src/utils/getWebSocket.ts +0 -55
  377. package/core/packages/ws/src/ws.d.ts +0 -10
  378. package/core/packages/ws/tsconfig.json +0 -9
  379. package/core/packages/ws/tsup.config.ts +0 -9
  380. package/core/pnpm-lock.yaml +0 -7033
  381. package/core/pnpm-workspace.yaml +0 -4
  382. package/core/scripts/generate-ai-rag.ts +0 -240
  383. package/core/scripts/generate-docs.ts +0 -143
  384. package/core/scripts/generate-emoji-shortcodes.ts +0 -58
  385. package/core/scripts/generate-types.ts +0 -6
  386. package/core/scripts/publish-ordered.js +0 -63
  387. package/core/scripts/test-cjs-require.mjs +0 -43
  388. package/core/scripts/test-esm-imports.mjs +0 -42
  389. package/core/scripts/test-package-exports.mjs +0 -98
  390. package/core/scripts/test-smoke.mjs +0 -103
  391. package/core/tsconfig.json +0 -18
  392. package/core/turbo.json +0 -30
  393. package/core/vitest.config.ts +0 -17
  394. package/core/wrangler.jsonc +0 -9
@@ -1,69 +0,0 @@
1
- /**
2
- * Builder for message attachment metadata (filename, description, spoiler).
3
- * Actual file data is passed separately when sending (e.g. FormData).
4
- */
5
- export interface AttachmentPayloadOptions {
6
- name: string;
7
- description?: string;
8
- spoiler?: boolean;
9
- }
10
-
11
- /** API format for an attachment in a message payload. */
12
- export interface APIAttachmentPayload {
13
- id: number;
14
- filename: string;
15
- description?: string | null;
16
- }
17
-
18
- /** Builder for attachment metadata (filename, description, spoiler). Actual file data is passed separately when sending. */
19
- export class AttachmentBuilder {
20
- public readonly id: number;
21
- public filename: string;
22
- public description?: string | null;
23
- public spoiler: boolean;
24
-
25
- /** @param id - Index of the attachment (0-based). Must match the FormData part order. */
26
- constructor(id: number, filename: string, options?: Partial<AttachmentPayloadOptions>) {
27
- if (!filename?.trim()) {
28
- throw new Error('Filename is required');
29
- }
30
- this.id = id;
31
- this.filename = options?.spoiler ? `SPOILER_${filename}` : filename;
32
- this.description = options?.description ?? undefined;
33
- this.spoiler = options?.spoiler ?? false;
34
- }
35
-
36
- /** Set the displayed filename. */
37
- setName(name: string): this {
38
- if (!name?.trim()) {
39
- throw new Error('Filename is required');
40
- }
41
- this.filename = this.spoiler ? `SPOILER_${name}` : name;
42
- return this;
43
- }
44
-
45
- /** Set the attachment description (alt text). */
46
- setDescription(description: string | null): this {
47
- this.description = description ?? undefined;
48
- return this;
49
- }
50
-
51
- /** Mark the attachment as a spoiler (blurred until clicked). */
52
- setSpoiler(spoiler = true): this {
53
- this.spoiler = spoiler;
54
- if (spoiler && !this.filename.startsWith('SPOILER_'))
55
- this.filename = `SPOILER_${this.filename}`;
56
- else if (!spoiler && this.filename.startsWith('SPOILER_'))
57
- this.filename = this.filename.slice(8);
58
- return this;
59
- }
60
-
61
- /** Convert to API format for MessagePayload. */
62
- toJSON(): APIAttachmentPayload {
63
- return {
64
- id: this.id,
65
- filename: this.filename,
66
- description: this.description ?? undefined,
67
- };
68
- }
69
- }
@@ -1,266 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { EmbedBuilder } from './EmbedBuilder.js';
3
-
4
- describe('EmbedBuilder', () => {
5
- describe('setVideo', () => {
6
- it('sets video URL in toJSON output (type stays rich)', () => {
7
- const url = 'https://example.com/video.mp4';
8
- const embed = new EmbedBuilder().setTitle('Video embed').setVideo(url);
9
- const json = embed.toJSON();
10
-
11
- expect(json.video).toEqual({ url });
12
- expect(json.type).toBe('rich');
13
- });
14
-
15
- it('clears video when passed null', () => {
16
- const embed = new EmbedBuilder().setVideo('https://example.com/video.mp4').setVideo(null);
17
- const json = embed.toJSON();
18
-
19
- expect(json.video).toBeUndefined();
20
- });
21
-
22
- it('accepts full EmbedMediaOptions with duration, width, height', () => {
23
- const options = {
24
- url: 'https://example.com/video.mp4',
25
- duration: 120,
26
- width: 1920,
27
- height: 1080,
28
- };
29
- const embed = new EmbedBuilder().setTitle('Video').setVideo(options);
30
- const json = embed.toJSON();
31
-
32
- expect(json.video).toEqual({
33
- url: options.url,
34
- duration: 120,
35
- width: 1920,
36
- height: 1080,
37
- });
38
- expect(json.type).toBe('rich');
39
- });
40
- });
41
-
42
- describe('setAudio', () => {
43
- it('sets audio URL in toJSON output', () => {
44
- const url = 'https://example.com/audio.mp3';
45
- const embed = new EmbedBuilder().setTitle('Audio embed').setAudio(url);
46
- const json = embed.toJSON();
47
-
48
- expect(json.audio).toEqual({ url });
49
- expect(json.type).toBe('rich');
50
- });
51
-
52
- it('clears audio when passed null', () => {
53
- const embed = new EmbedBuilder().setAudio('https://example.com/audio.mp3').setAudio(null);
54
- const json = embed.toJSON();
55
-
56
- expect(json.audio).toBeUndefined();
57
- });
58
-
59
- it('accepts full EmbedMediaOptions with duration', () => {
60
- const options = {
61
- url: 'https://example.com/podcast.mp3',
62
- duration: 3600,
63
- content_type: 'audio/mpeg',
64
- };
65
- const embed = new EmbedBuilder().setTitle('Podcast').setAudio(options);
66
- const json = embed.toJSON();
67
-
68
- expect(json.audio).toEqual({
69
- url: options.url,
70
- duration: 3600,
71
- content_type: 'audio/mpeg',
72
- });
73
- });
74
- });
75
-
76
- describe('setImage and setThumbnail', () => {
77
- it('accept string URL (backward compatibility)', () => {
78
- const embed = new EmbedBuilder()
79
- .setImage('https://example.com/img.png')
80
- .setThumbnail('https://example.com/thumb.png');
81
- const json = embed.toJSON();
82
-
83
- expect(json.image).toEqual({ url: 'https://example.com/img.png' });
84
- expect(json.thumbnail).toEqual({ url: 'https://example.com/thumb.png' });
85
- });
86
-
87
- it('accept full EmbedMediaOptions with width and height', () => {
88
- const embed = new EmbedBuilder()
89
- .setImage({
90
- url: 'https://example.com/img.png',
91
- width: 800,
92
- height: 600,
93
- })
94
- .setThumbnail({
95
- url: 'https://example.com/thumb.png',
96
- width: 128,
97
- height: 128,
98
- });
99
- const json = embed.toJSON();
100
-
101
- expect(json.image).toEqual({
102
- url: 'https://example.com/img.png',
103
- width: 800,
104
- height: 600,
105
- });
106
- expect(json.thumbnail).toEqual({
107
- url: 'https://example.com/thumb.png',
108
- width: 128,
109
- height: 128,
110
- });
111
- });
112
- });
113
-
114
- describe('validation', () => {
115
- it('setTitle throws for over 256 chars', () => {
116
- const embed = new EmbedBuilder();
117
- expect(() => embed.setTitle('x'.repeat(257))).toThrow(RangeError);
118
- });
119
-
120
- it('setDescription throws for over 4096 chars', () => {
121
- const embed = new EmbedBuilder();
122
- expect(() => embed.setDescription('x'.repeat(4097))).toThrow(RangeError);
123
- });
124
-
125
- it('setURL throws for invalid URL', () => {
126
- const embed = new EmbedBuilder();
127
- expect(() => embed.setURL('not-a-valid-url')).toThrow('Invalid embed URL');
128
- });
129
-
130
- it('setImage throws for invalid media URL', () => {
131
- const embed = new EmbedBuilder();
132
- expect(() => embed.setImage({ url: 'invalid', width: 100 })).toThrow(
133
- 'Invalid embed media URL',
134
- );
135
- });
136
-
137
- it('toJSON throws when total length exceeds 6000', () => {
138
- const embed = new EmbedBuilder()
139
- .setTitle('x'.repeat(256))
140
- .setDescription('y'.repeat(2000))
141
- .addFields(
142
- { name: 'n'.repeat(256), value: 'v'.repeat(600) },
143
- { name: 'n'.repeat(256), value: 'v'.repeat(600) },
144
- { name: 'n'.repeat(256), value: 'v'.repeat(600) },
145
- { name: 'n'.repeat(256), value: 'v'.repeat(600) },
146
- { name: 'n'.repeat(256), value: 'v'.repeat(500) },
147
- );
148
- expect(() => embed.toJSON()).toThrow(RangeError);
149
- });
150
- });
151
-
152
- describe('setAuthor and setFooter', () => {
153
- it('setAuthor with name, url, iconURL', () => {
154
- const embed = new EmbedBuilder().setAuthor({
155
- name: 'Author',
156
- url: 'https://example.com',
157
- iconURL: 'https://example.com/icon.png',
158
- });
159
- const json = embed.toJSON();
160
- expect(json.author).toEqual({
161
- name: 'Author',
162
- url: 'https://example.com',
163
- icon_url: 'https://example.com/icon.png',
164
- });
165
- });
166
-
167
- it('setFooter with text and iconURL', () => {
168
- const embed = new EmbedBuilder().setFooter({
169
- text: 'Footer text',
170
- iconURL: 'https://example.com/footer.png',
171
- });
172
- const json = embed.toJSON();
173
- expect(json.footer).toEqual({
174
- text: 'Footer text',
175
- icon_url: 'https://example.com/footer.png',
176
- });
177
- });
178
-
179
- it('setAuthor null clears author', () => {
180
- const embed = new EmbedBuilder().setAuthor({ name: 'A' }).setAuthor(null);
181
- expect(embed.toJSON().author).toBeUndefined();
182
- });
183
- });
184
-
185
- describe('setColor and setTimestamp', () => {
186
- it('setColor accepts number, hex, RGB array', () => {
187
- const embed = new EmbedBuilder().setColor(0xff0000);
188
- expect(embed.toJSON().color).toBe(0xff0000);
189
- embed.setColor('#00ff00');
190
- expect(embed.toJSON().color).toBe(0x00ff00);
191
- embed.setColor([0, 0, 255]);
192
- expect(embed.toJSON().color).toBe(0x0000ff);
193
- });
194
-
195
- it('setColor null clears', () => {
196
- const embed = new EmbedBuilder().setColor(0xff0000).setColor(null);
197
- expect(embed.toJSON().color).toBeUndefined();
198
- });
199
-
200
- it('setTimestamp accepts Date and number', () => {
201
- const d = new Date('2021-01-01T00:00:00Z');
202
- const embed = new EmbedBuilder().setTitle('T').setTimestamp(d);
203
- expect(embed.toJSON().timestamp).toBe('2021-01-01T00:00:00.000Z');
204
- embed.setTimestamp(1609459200000);
205
- expect(embed.toJSON().timestamp).toBe('2021-01-01T00:00:00.000Z');
206
- });
207
- });
208
-
209
- describe('addFields and spliceFields', () => {
210
- it('addFields adds multiple', () => {
211
- const embed = new EmbedBuilder()
212
- .setTitle('T')
213
- .addFields({ name: 'A', value: '1' }, { name: 'B', value: '2', inline: true });
214
- const json = embed.toJSON();
215
- expect(json.fields).toHaveLength(2);
216
- expect(json.fields![0]).toEqual({ name: 'A', value: '1', inline: undefined });
217
- expect(json.fields![1]).toEqual({ name: 'B', value: '2', inline: true });
218
- });
219
-
220
- it('spliceFields replaces at index', () => {
221
- const embed = new EmbedBuilder()
222
- .setTitle('T')
223
- .addFields({ name: 'A', value: '1' }, { name: 'B', value: '2' })
224
- .spliceFields(1, 1, { name: 'X', value: 'replacement' });
225
- const json = embed.toJSON();
226
- expect(json.fields).toHaveLength(2);
227
- expect(json.fields![1].name).toBe('X');
228
- });
229
- });
230
-
231
- describe('EmbedBuilder.from', () => {
232
- it('restores video from existing embed (type always rich)', () => {
233
- const source = {
234
- video: { url: 'https://media.tenor.com/videos/xyz.mp4' },
235
- };
236
- const rebuilt = EmbedBuilder.from(source);
237
- const json = rebuilt.toJSON();
238
-
239
- expect(json.video).toEqual(source.video);
240
- expect(json.type).toBe('rich');
241
- });
242
-
243
- it('preserves video and audio with full metadata', () => {
244
- const source = {
245
- video: {
246
- url: 'https://example.com/video.mp4',
247
- duration: 90,
248
- width: 1280,
249
- height: 720,
250
- flags: 0,
251
- },
252
- audio: {
253
- url: 'https://example.com/audio.mp3',
254
- duration: 180,
255
- content_type: 'audio/mpeg',
256
- flags: 0,
257
- },
258
- };
259
- const rebuilt = EmbedBuilder.from(source);
260
- const json = rebuilt.toJSON();
261
-
262
- expect(json.video).toEqual(source.video);
263
- expect(json.audio).toEqual(source.audio);
264
- });
265
- });
266
- });
@@ -1,239 +0,0 @@
1
- import { APIEmbed, APIEmbedAuthor, APIEmbedFooter, APIEmbedMedia } from '@erinjs/types';
2
- import { resolveColor } from '@erinjs/util';
3
-
4
- /** Options for embed media (image, thumbnail, video, audio). */
5
- export interface EmbedMediaOptions {
6
- url: string;
7
- content_type?: string | null;
8
- width?: number | null;
9
- height?: number | null;
10
- description?: string | null;
11
- placeholder?: string | null;
12
- duration?: number | null;
13
- flags?: number | null;
14
- }
15
-
16
- const EMBED_MAX = {
17
- title: 256,
18
- description: 4096,
19
- fields: 25,
20
- fieldName: 256,
21
- fieldValue: 1024,
22
- footerText: 2048,
23
- authorName: 256,
24
- total: 6000,
25
- };
26
-
27
- function toEmbedMedia(input: string | EmbedMediaOptions): APIEmbedMedia {
28
- if (typeof input === 'string') {
29
- return { url: input };
30
- }
31
- if (!URL.canParse(input.url)) {
32
- throw new Error('Invalid embed media URL');
33
- }
34
- const media: APIEmbedMedia = { url: input.url };
35
- if (input.content_type != null) media.content_type = input.content_type;
36
- if (input.width != null) media.width = input.width;
37
- if (input.height != null) media.height = input.height;
38
- if (input.description != null) media.description = input.description;
39
- if (input.placeholder != null) media.placeholder = input.placeholder;
40
- if (input.duration != null) media.duration = input.duration;
41
- if (input.flags != null) media.flags = input.flags;
42
- return media;
43
- }
44
-
45
- /** Author field for an embed. */
46
- export interface EmbedAuthorOptions {
47
- name: string;
48
- iconURL?: string;
49
- url?: string;
50
- }
51
-
52
- /** Footer field for an embed. */
53
- export interface EmbedFooterOptions {
54
- text: string;
55
- iconURL?: string;
56
- }
57
-
58
- /** A single embed field (name, value, optional inline). */
59
- export interface EmbedFieldData {
60
- name: string;
61
- value: string;
62
- inline?: boolean;
63
- }
64
-
65
- /**
66
- * Builder for creating rich embeds. Use `toJSON()` when passing to `reply`, `send`, or `edit`.
67
- * Embeds must have at least one of: title, description, fields, or image/thumbnail.
68
- * A description-only embed (no title) is valid.
69
- */
70
- export class EmbedBuilder {
71
- public readonly data: Partial<APIEmbed> = {};
72
-
73
- /** Set the embed title. Max 256 characters. */
74
- setTitle(title: string | null): this {
75
- if (title !== null && title.length > EMBED_MAX.title)
76
- throw new RangeError(`Title must be ≤${EMBED_MAX.title} characters`);
77
- this.data.title = title ?? undefined;
78
- return this;
79
- }
80
-
81
- /** Set the embed description. Max 4096 characters. */
82
- setDescription(description: string | null): this {
83
- if (description !== null && description.length > EMBED_MAX.description)
84
- throw new RangeError(`Description must be ≤${EMBED_MAX.description} characters`);
85
- this.data.description = description ?? undefined;
86
- return this;
87
- }
88
-
89
- /** Set the embed URL (title becomes a link). */
90
- setURL(url: string | null): this {
91
- if (url != null && url !== '' && !URL.canParse(url)) {
92
- throw new Error('Invalid embed URL');
93
- }
94
- this.data.url = url ?? undefined;
95
- return this;
96
- }
97
-
98
- /** Set the embed color. Number (hex), hex string, or `[r,g,b]` array. */
99
- setColor(color: number | string | [number, number, number] | null): this {
100
- if (color === null) {
101
- this.data.color = undefined;
102
- return this;
103
- }
104
- this.data.color = typeof color === 'number' ? color : resolveColor(color);
105
- return this;
106
- }
107
-
108
- /** Set the embed timestamp. Omit for current time. */
109
- setTimestamp(timestamp?: Date | number | null): this {
110
- if (timestamp === undefined || timestamp === null) {
111
- this.data.timestamp = undefined;
112
- return this;
113
- }
114
- const date = timestamp instanceof Date ? timestamp : new Date(timestamp);
115
- this.data.timestamp = date.toISOString();
116
- return this;
117
- }
118
-
119
- /** Set the embed author (name, optional icon URL and link). */
120
- setAuthor(options: EmbedAuthorOptions | null): this {
121
- if (!options) {
122
- this.data.author = undefined;
123
- return this;
124
- }
125
- const name = options.name.slice(0, EMBED_MAX.authorName);
126
- const author: APIEmbedAuthor = { name };
127
- if (options.url) author.url = options.url;
128
- if (options.iconURL) author.icon_url = options.iconURL;
129
- this.data.author = author;
130
- return this;
131
- }
132
-
133
- /** Set the embed footer (text, optional icon URL). */
134
- setFooter(options: EmbedFooterOptions | null): this {
135
- if (!options) {
136
- this.data.footer = undefined;
137
- return this;
138
- }
139
- const text = options.text.slice(0, EMBED_MAX.footerText);
140
- const footer: APIEmbedFooter = { text };
141
- if (options.iconURL) footer.icon_url = options.iconURL;
142
- this.data.footer = footer;
143
- return this;
144
- }
145
-
146
- /** Set the embed image (URL string or full media options). */
147
- setImage(input: string | EmbedMediaOptions | null): this {
148
- this.data.image = input ? toEmbedMedia(input) : undefined;
149
- return this;
150
- }
151
-
152
- /** Set the embed thumbnail (URL string or full media options). */
153
- setThumbnail(input: string | EmbedMediaOptions | null): this {
154
- this.data.thumbnail = input ? toEmbedMedia(input) : undefined;
155
- return this;
156
- }
157
-
158
- /**
159
- * Set the embed video. Supported by Fluxer.
160
- * Embed stays type 'rich'; this adds the .video field.
161
- * Include a title (e.g. setTitle) when using video.
162
- *
163
- * @param input - Video URL, full media options (e.g. duration for progress bars), or null to clear
164
- */
165
- setVideo(input: string | EmbedMediaOptions | null): this {
166
- this.data.video = input ? toEmbedMedia(input) : undefined;
167
- return this;
168
- }
169
-
170
- /**
171
- * Set the embed audio. Supported by Fluxer.
172
- *
173
- * @param input - Audio URL, full media options, or null to clear
174
- */
175
- setAudio(input: string | EmbedMediaOptions | null): this {
176
- this.data.audio = input ? toEmbedMedia(input) : undefined;
177
- return this;
178
- }
179
-
180
- /** Add one or more fields. Max 25 fields. */
181
- addFields(...fields: EmbedFieldData[]): this {
182
- const current = (this.data.fields ?? []).slice();
183
- for (const f of fields) {
184
- if (current.length >= EMBED_MAX.fields) break;
185
- current.push({
186
- name: f.name.slice(0, EMBED_MAX.fieldName),
187
- value: f.value.slice(0, EMBED_MAX.fieldValue),
188
- inline: f.inline,
189
- });
190
- }
191
- this.data.fields = current.length ? current : undefined;
192
- return this;
193
- }
194
-
195
- spliceFields(index: number, deleteCount: number, ...fields: EmbedFieldData[]): this {
196
- const current = (this.data.fields ?? []).slice();
197
- const toAdd = fields.map((f) => ({
198
- name: f.name.slice(0, EMBED_MAX.fieldName),
199
- value: f.value.slice(0, EMBED_MAX.fieldValue),
200
- inline: f.inline,
201
- }));
202
- current.splice(index, deleteCount, ...toAdd);
203
- this.data.fields = current.length ? current : undefined;
204
- return this;
205
- }
206
-
207
- /** Convert to API embed format for `reply`, `send`, or `edit`. */
208
- toJSON(): APIEmbed {
209
- const totalLength = [
210
- this.data.title,
211
- this.data.description,
212
- ...(this.data.fields ?? []).flatMap((f) => [f.name, f.value]),
213
- this.data.footer?.text,
214
- ]
215
- .filter(Boolean)
216
- .join('').length;
217
- if (totalLength > EMBED_MAX.total)
218
- throw new RangeError(`Embed total length must be ≤${EMBED_MAX.total}`);
219
- return { ...this.data, type: 'rich' } as APIEmbed;
220
- }
221
-
222
- /** Create an EmbedBuilder from an existing API embed. */
223
- static from(data: APIEmbed): EmbedBuilder {
224
- const b = new EmbedBuilder();
225
- b.data.title = data.title ?? undefined;
226
- b.data.description = data.description ?? undefined;
227
- b.data.url = data.url ?? undefined;
228
- b.data.color = data.color ?? undefined;
229
- b.data.timestamp = data.timestamp ?? undefined;
230
- b.data.author = data.author ?? undefined;
231
- b.data.footer = data.footer ?? undefined;
232
- b.data.image = data.image ?? undefined;
233
- b.data.thumbnail = data.thumbnail ?? undefined;
234
- b.data.video = data.video ?? undefined;
235
- b.data.audio = data.audio ?? undefined;
236
- b.data.fields = data.fields ?? undefined;
237
- return b;
238
- }
239
- }
@@ -1,118 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { MessagePayload } from './MessagePayload.js';
3
- import { EmbedBuilder } from './EmbedBuilder.js';
4
- import { AttachmentBuilder } from './AttachmentBuilder.js';
5
-
6
- describe('MessagePayload', () => {
7
- it('creates empty payload', () => {
8
- const p = new MessagePayload();
9
- expect(p.toJSON()).toEqual({});
10
- });
11
-
12
- it('setContent sets and clears', () => {
13
- const p = new MessagePayload();
14
- p.setContent('hello');
15
- expect(p.data.content).toBe('hello');
16
- p.setContent(null);
17
- expect(p.data.content).toBeUndefined();
18
- });
19
-
20
- it('setContent throws for over 2000 chars', () => {
21
- const p = new MessagePayload();
22
- expect(() => p.setContent('x'.repeat(2001))).toThrow(RangeError);
23
- });
24
-
25
- it('setContent accepts exactly 2000 chars', () => {
26
- const p = new MessagePayload();
27
- p.setContent('x'.repeat(2000));
28
- expect(p.data.content).toHaveLength(2000);
29
- });
30
-
31
- it('setEmbeds accepts EmbedBuilder and raw APIEmbed', () => {
32
- const embed = new EmbedBuilder().setTitle('T').setDescription('D');
33
- const p = new MessagePayload().setEmbeds([embed]);
34
- expect(p.data.embeds).toHaveLength(1);
35
- expect(p.data.embeds![0]).toEqual(embed.toJSON());
36
- });
37
-
38
- it('setEmbeds throws for more than 10', () => {
39
- const p = new MessagePayload();
40
- const embeds = Array.from({ length: 11 }, () =>
41
- new EmbedBuilder().setTitle('x').setDescription('y'),
42
- );
43
- expect(() => p.setEmbeds(embeds)).toThrow(RangeError);
44
- });
45
-
46
- it('addEmbed adds one at a time', () => {
47
- const p = new MessagePayload();
48
- p.addEmbed(new EmbedBuilder().setTitle('1').setDescription('a'));
49
- p.addEmbed(new EmbedBuilder().setTitle('2').setDescription('b'));
50
- expect(p.data.embeds).toHaveLength(2);
51
- expect(p.data.embeds![0].title).toBe('1');
52
- expect(p.data.embeds![1].title).toBe('2');
53
- });
54
-
55
- it('setAttachments accepts AttachmentBuilder', () => {
56
- const att = new AttachmentBuilder(0, 'file.png');
57
- const p = new MessagePayload().setAttachments([att]);
58
- expect(p.data.attachments).toEqual([{ id: 0, filename: 'file.png', description: undefined }]);
59
- });
60
-
61
- it('setAttachments accepts plain objects', () => {
62
- const p = new MessagePayload().setAttachments([
63
- { id: 0, filename: 'a.txt', description: 'desc' },
64
- ]);
65
- expect(p.data.attachments).toEqual([{ id: 0, filename: 'a.txt', description: 'desc' }]);
66
- });
67
-
68
- it('setReply sets message_reference', () => {
69
- const p = new MessagePayload().setReply({
70
- channel_id: 'c1',
71
- message_id: 'm1',
72
- guild_id: 'g1',
73
- });
74
- expect(p.data.message_reference).toEqual({
75
- channel_id: 'c1',
76
- message_id: 'm1',
77
- guild_id: 'g1',
78
- });
79
- });
80
-
81
- it('setReply omits guild_id when null', () => {
82
- const p = new MessagePayload().setReply({
83
- channel_id: 'c1',
84
- message_id: 'm1',
85
- guild_id: null,
86
- });
87
- expect(p.data.message_reference?.guild_id).toBeUndefined();
88
- });
89
-
90
- it('setTTS and setFlags', () => {
91
- const p = new MessagePayload().setTTS(true).setFlags(64);
92
- expect(p.data.tts).toBe(true);
93
- expect(p.data.flags).toBe(64);
94
- });
95
-
96
- describe('MessagePayload.create', () => {
97
- it('creates from string', () => {
98
- const p = MessagePayload.create('Hi');
99
- expect(p.data.content).toBe('Hi');
100
- });
101
-
102
- it('creates from options object', () => {
103
- const p = MessagePayload.create({
104
- content: 'Test',
105
- embeds: [new EmbedBuilder().setTitle('E').setDescription('D')],
106
- tts: true,
107
- });
108
- expect(p.data.content).toBe('Test');
109
- expect(p.data.embeds).toHaveLength(1);
110
- expect(p.data.tts).toBe(true);
111
- });
112
-
113
- it('creates empty when no args', () => {
114
- const p = MessagePayload.create();
115
- expect(p.toJSON()).toEqual({});
116
- });
117
- });
118
- });