@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,503 +0,0 @@
1
- import { EventEmitter } from 'events';
2
- import { Client } from '@erinjs/core';
3
- import { VoiceChannel } from '@erinjs/core';
4
- import { Events } from '@erinjs/core';
5
- import { GatewayOpcodes, Routes } from '@erinjs/types';
6
- import { thumbnail } from './streamPreviewPlaceholder.js';
7
- import {
8
- GatewayVoiceServerUpdateDispatchData,
9
- GatewayVoiceStateUpdateDispatchData,
10
- } from '@erinjs/types';
11
- import { VoiceConnection } from './VoiceConnection.js';
12
- import { LiveKitRtcConnection, type LiveKitReceiveSubscription } from './LiveKitRtcConnection.js';
13
- import { isLiveKitEndpoint } from './livekit.js';
14
- import { Collection } from '@erinjs/collection';
15
-
16
- /** Maps guild_id -> user_id -> channel_id (null if not in voice). */
17
- export type VoiceStateMap = Map<string, Map<string, string | null>>;
18
-
19
- /**
20
- * Options for creating a VoiceManager.
21
- *
22
- * @property shardId - Gateway shard ID to use for voice connections (default 0).
23
- * Use when the client runs multiple shards and you need to target a specific one.
24
- */
25
- export interface VoiceManagerOptions {
26
- /** Gateway shard ID to use for voice (default 0). */
27
- shardId?: number;
28
- }
29
-
30
- /** Manages voice connections. Use `getVoiceManager(client)` to obtain an instance. */
31
- export class VoiceManager extends EventEmitter {
32
- readonly client: Client;
33
- /** channel_id -> connection (Fluxer multi-channel: allows multiple connections per guild) */
34
- private readonly connections = new Collection<string, VoiceConnection | LiveKitRtcConnection>();
35
- /** channel_id -> connection_id (from VoiceServerUpdate; required for voice state updates) */
36
- private readonly connectionIds = new Map<string, string>();
37
- /** guild_id -> user_id -> channel_id */
38
- readonly voiceStates: VoiceStateMap = new Map();
39
- /** channel_id -> pending join */
40
- private readonly pending = new Map<
41
- string,
42
- {
43
- channel: VoiceChannel;
44
- resolve: (c: VoiceConnection | LiveKitRtcConnection) => void;
45
- reject: (e: Error) => void;
46
- server?: GatewayVoiceServerUpdateDispatchData;
47
- state?: GatewayVoiceStateUpdateDispatchData;
48
- }
49
- >();
50
- private readonly shardId: number;
51
-
52
- constructor(client: Client, options: VoiceManagerOptions = {}) {
53
- super();
54
- this.client = client;
55
- this.shardId = options.shardId ?? 0;
56
- this.client.on(Events.VoiceStateUpdate, (data: GatewayVoiceStateUpdateDispatchData) =>
57
- this.handleVoiceStateUpdate(data),
58
- );
59
- this.client.on(Events.VoiceServerUpdate, (data: GatewayVoiceServerUpdateDispatchData) =>
60
- this.handleVoiceServerUpdate(data),
61
- );
62
- this.client.on(
63
- Events.VoiceStatesSync,
64
- (data: {
65
- guildId: string;
66
- voiceStates: Array<{ user_id: string; channel_id: string | null }>;
67
- }) => this.handleVoiceStatesSync(data),
68
- );
69
- }
70
-
71
- private handleVoiceStatesSync(data: {
72
- guildId: string;
73
- voiceStates: Array<{ user_id: string; channel_id: string | null }>;
74
- }): void {
75
- let guildMap = this.voiceStates.get(data.guildId);
76
- if (!guildMap) {
77
- guildMap = new Map();
78
- this.voiceStates.set(data.guildId, guildMap);
79
- }
80
- for (const vs of data.voiceStates) {
81
- guildMap.set(vs.user_id, vs.channel_id);
82
- }
83
- }
84
-
85
- /**
86
- * Get the voice channel ID the user is currently in, or null if not in voice.
87
- * @param guildId - Guild ID to look up
88
- * @param userId - User ID to look up
89
- */
90
- getVoiceChannelId(guildId: string, userId: string): string | null {
91
- const guildMap = this.voiceStates.get(guildId);
92
- if (!guildMap) return null;
93
- return guildMap.get(userId) ?? null;
94
- }
95
-
96
- /**
97
- * List participant user IDs currently in a specific voice channel.
98
- */
99
- listParticipantsInChannel(guildId: string, channelId: string): string[] {
100
- const guildMap = this.voiceStates.get(guildId);
101
- if (!guildMap) return [];
102
- const participants: string[] = [];
103
- for (const [userId, voiceChannelId] of guildMap.entries()) {
104
- if (voiceChannelId === channelId) participants.push(userId);
105
- }
106
- return participants;
107
- }
108
-
109
- /**
110
- * Subscribe to inbound audio for all known participants currently in a voice channel.
111
- * Only supported for LiveKit connections.
112
- */
113
- subscribeChannelParticipants(
114
- channelId: string,
115
- opts?: { autoResubscribe?: boolean },
116
- ): LiveKitReceiveSubscription[] {
117
- const conn = this.connections.get(channelId);
118
- if (!(conn instanceof LiveKitRtcConnection)) return [];
119
- const guildId = conn.channel.guildId;
120
- const participants = this.listParticipantsInChannel(guildId, channelId).filter(
121
- (participantId) => participantId !== this.client.user?.id,
122
- );
123
- return participants.map((participantId) => conn.subscribeParticipantAudio(participantId, opts));
124
- }
125
-
126
- private handleVoiceStateUpdate(data: GatewayVoiceStateUpdateDispatchData): void {
127
- const guildId = data.guild_id ?? '';
128
- if (!guildId) return;
129
- this.client.emit?.(
130
- 'debug',
131
- `[VoiceManager] VoiceStateUpdate guild=${guildId} user=${data.user_id} channel=${data.channel_id ?? 'null'} (bot=${this.client.user?.id})`,
132
- );
133
- let guildMap = this.voiceStates.get(guildId);
134
- if (!guildMap) {
135
- guildMap = new Map();
136
- this.voiceStates.set(guildId, guildMap);
137
- }
138
- guildMap.set(data.user_id, data.channel_id);
139
-
140
- const channelKey = data.channel_id ?? guildId;
141
- const pendingByChannel = this.pending.get(channelKey);
142
- const pendingByGuild = this.pending.get(guildId);
143
- const pending = pendingByChannel ?? pendingByGuild;
144
- const isBot = String(data.user_id) === String(this.client.user?.id);
145
- if (isBot && data.connection_id) {
146
- this.storeConnectionId(channelKey, data.connection_id);
147
- }
148
- if (pending && isBot) {
149
- this.client.emit?.(
150
- 'debug',
151
- `[VoiceManager] VoiceStateUpdate for bot - completing pending channel ${channelKey}`,
152
- );
153
- pending.state = data;
154
- this.tryCompletePending(pendingByChannel ? channelKey : guildId, pending);
155
- }
156
- }
157
-
158
- private handleVoiceServerUpdate(data: GatewayVoiceServerUpdateDispatchData): void {
159
- const guildId = data.guild_id;
160
-
161
- let pending = this.pending.get(guildId);
162
- if (!pending) {
163
- for (const [, p] of this.pending) {
164
- if (p.channel?.guildId === guildId) {
165
- pending = p;
166
- break;
167
- }
168
- }
169
- }
170
- if (pending) {
171
- const channelKey = pending.channel?.id ?? guildId;
172
- const hasToken = !!(data.token && data.token.length > 0);
173
- this.client.emit?.(
174
- 'debug',
175
- `[VoiceManager] VoiceServerUpdate guild=${guildId} channel=${channelKey} endpoint=${data.endpoint ?? 'null'} token=${hasToken ? 'yes' : 'NO'}`,
176
- );
177
- pending.server = data;
178
- this.tryCompletePending(channelKey, pending);
179
- return;
180
- }
181
-
182
- const userId = this.client.user?.id;
183
- if (!userId) {
184
- this.client.emit?.(
185
- 'debug',
186
- '[VoiceManager] Client user not available. Ensure the client is logged in.',
187
- );
188
- return;
189
- }
190
-
191
- let conn: VoiceConnection | LiveKitRtcConnection | undefined;
192
- for (const [, c] of this.connections) {
193
- if (c?.channel?.guildId === guildId) {
194
- conn = c;
195
- break;
196
- }
197
- }
198
- if (!conn) return;
199
-
200
- if (!data.endpoint || !data.token) {
201
- this.client.emit?.(
202
- 'debug',
203
- `[VoiceManager] Voice server endpoint null for guild ${guildId}; disconnecting`,
204
- );
205
- conn.destroy();
206
- this.connections.delete(conn.channel.id);
207
- return;
208
- }
209
-
210
- if (!isLiveKitEndpoint(data.endpoint, data.token)) return;
211
-
212
- if (conn instanceof LiveKitRtcConnection && conn.isSameServer(data.endpoint, data.token)) {
213
- return;
214
- }
215
-
216
- const channel = conn.channel;
217
- this.client.emit?.(
218
- 'debug',
219
- `[VoiceManager] Voice server migration for guild ${guildId} channel ${channel.id}; reconnecting`,
220
- );
221
- conn.destroy();
222
- this.connections.delete(channel.id);
223
- this.connectionIds.delete(channel.id);
224
- this.storeConnectionId(channel.id, data.connection_id);
225
-
226
- const ConnClass = LiveKitRtcConnection;
227
- const newConn = new ConnClass(this.client, channel, userId);
228
- this.registerConnection(channel.id, newConn);
229
-
230
- const state: GatewayVoiceStateUpdateDispatchData = {
231
- guild_id: guildId,
232
- channel_id: channel.id,
233
- user_id: userId,
234
- session_id: '',
235
- };
236
-
237
- newConn.connect(data, state).catch((e) => {
238
- this.connections.delete(channel.id);
239
- newConn.emit('error', e instanceof Error ? e : new Error(String(e)));
240
- });
241
- }
242
-
243
- private storeConnectionId(channelId: string, connectionId: string | null | undefined): void {
244
- const id = connectionId != null ? String(connectionId) : null;
245
- if (id) this.connectionIds.set(channelId, id);
246
- else this.connectionIds.delete(channelId);
247
- }
248
-
249
- private registerConnection(
250
- channelId: string,
251
- conn: VoiceConnection | LiveKitRtcConnection,
252
- ): void {
253
- const cid = conn.channel?.id ?? channelId;
254
- this.connections.set(cid, conn);
255
- conn.once('disconnect', () => {
256
- this.connections.delete(cid);
257
- this.connectionIds.delete(cid);
258
- });
259
- conn.on('requestVoiceStateSync', (p: { self_stream?: boolean; self_video?: boolean }) => {
260
- this.updateVoiceState(cid, p);
261
- if (p.self_stream) {
262
- this.uploadStreamPreview(cid, conn).catch((e) =>
263
- this.client.emit?.('debug', `[VoiceManager] Stream preview upload failed: ${String(e)}`),
264
- );
265
- }
266
- });
267
- }
268
-
269
- /** Upload a placeholder stream preview so the preview URL returns 200 instead of 404. */
270
- private async uploadStreamPreview(
271
- channelId: string,
272
- conn: VoiceConnection | LiveKitRtcConnection,
273
- ): Promise<void> {
274
- const cid = conn.channel?.id ?? channelId;
275
- const connectionId = this.connectionIds.get(cid);
276
- if (!connectionId) return;
277
-
278
- const streamKey = `${conn.channel.guildId}:${conn.channel.id}:${connectionId}`;
279
- const route = Routes.streamPreview(streamKey);
280
- const body = { channel_id: conn.channel.id, thumbnail, content_type: 'image/png' };
281
-
282
- await this.client.rest.post(route, { body, auth: true });
283
- this.client.emit?.('debug', `[VoiceManager] Uploaded stream preview for ${streamKey}`);
284
- }
285
-
286
- private tryCompletePending(
287
- channelId: string,
288
- pending: {
289
- channel: VoiceChannel;
290
- resolve: (c: VoiceConnection | LiveKitRtcConnection) => void;
291
- reject: (e: Error) => void;
292
- server?: GatewayVoiceServerUpdateDispatchData;
293
- state?: GatewayVoiceStateUpdateDispatchData;
294
- },
295
- ): void {
296
- if (!pending?.server) return;
297
-
298
- const useLiveKit = isLiveKitEndpoint(pending.server.endpoint, pending.server.token);
299
- const hasState = !!pending.state;
300
-
301
- if (!useLiveKit && !hasState) return;
302
- if (useLiveKit && !hasState) {
303
- this.client.emit?.(
304
- 'debug',
305
- `[VoiceManager] Proceeding with VoiceServerUpdate only (LiveKit does not require VoiceStateUpdate)`,
306
- );
307
- }
308
-
309
- const userId = this.client.user?.id;
310
- if (!userId) {
311
- this.client.emit?.(
312
- 'debug',
313
- '[VoiceManager] Client user not available. Ensure the client is logged in.',
314
- );
315
- return;
316
- }
317
-
318
- const guildId = pending.channel?.guildId ?? '';
319
- const state: GatewayVoiceStateUpdateDispatchData = pending.state ?? {
320
- guild_id: guildId,
321
- channel_id: pending.channel.id,
322
- user_id: userId,
323
- session_id: '',
324
- };
325
-
326
- this.storeConnectionId(
327
- channelId,
328
- pending.server.connection_id ?? (state as { connection_id?: string }).connection_id,
329
- );
330
- this.pending.delete(channelId);
331
- const ConnClass = useLiveKit ? LiveKitRtcConnection : VoiceConnection;
332
- const conn = new ConnClass(this.client, pending.channel, userId);
333
- this.registerConnection(channelId, conn);
334
- conn.connect(pending.server, state).then(
335
- () => pending.resolve(conn),
336
- (e) => pending.reject(e),
337
- );
338
- }
339
-
340
- /**
341
- * Join a voice channel. Resolves when the connection is ready.
342
- * Supports multiple connections per guild (Fluxer multi-channel).
343
- * @param channel - The voice channel to join
344
- * @returns The voice connection (LiveKitRtcConnection when Fluxer uses LiveKit)
345
- */
346
- async join(channel: VoiceChannel): Promise<VoiceConnection | LiveKitRtcConnection> {
347
- const channelId = channel.id;
348
- const existing = this.connections.get(channelId);
349
- if (existing) {
350
- const isReusable = existing instanceof LiveKitRtcConnection ? existing.isConnected() : true;
351
- if (isReusable) return existing;
352
- existing.destroy();
353
- this.connections.delete(channelId);
354
- }
355
- return new Promise((resolve, reject) => {
356
- this.client.emit?.(
357
- 'debug',
358
- `[VoiceManager] Requesting voice join guild=${channel.guildId} channel=${channelId}`,
359
- );
360
- const timeout = setTimeout(() => {
361
- if (this.pending.has(channelId)) {
362
- this.pending.delete(channelId);
363
- reject(
364
- new Error(
365
- 'Voice connection timeout. Ensure the server has voice enabled and the bot has Connect permissions. ' +
366
- 'The gateway must send VoiceServerUpdate and VoiceStateUpdate in response.',
367
- ),
368
- );
369
- }
370
- }, 20_000);
371
- this.pending.set(channelId, {
372
- channel,
373
- resolve: (c) => {
374
- clearTimeout(timeout);
375
- resolve(c);
376
- },
377
- reject: (e) => {
378
- clearTimeout(timeout);
379
- reject(e);
380
- },
381
- });
382
- this.client.sendToGateway(this.shardId, {
383
- op: GatewayOpcodes.VoiceStateUpdate,
384
- d: {
385
- guild_id: channel.guildId,
386
- channel_id: channel.id,
387
- self_mute: false,
388
- self_deaf: false,
389
- },
390
- });
391
- });
392
- }
393
-
394
- /**
395
- * Leave all voice channels in a guild.
396
- * With multi-channel support, disconnects from every channel in the guild.
397
- * @param guildId - Guild ID to leave
398
- */
399
- leave(guildId: string): void {
400
- const toLeave: { channelId: string; conn: VoiceConnection | LiveKitRtcConnection }[] = [];
401
- for (const [cid, c] of this.connections) {
402
- if (c?.channel?.guildId === guildId) toLeave.push({ channelId: cid, conn: c });
403
- }
404
- for (const { channelId, conn } of toLeave) {
405
- conn.destroy();
406
- this.connections.delete(channelId);
407
- this.connectionIds.delete(channelId);
408
- }
409
- if (toLeave.length > 0) {
410
- this.client.sendToGateway(this.shardId, {
411
- op: GatewayOpcodes.VoiceStateUpdate,
412
- d: {
413
- guild_id: guildId,
414
- channel_id: null,
415
- self_mute: false,
416
- self_deaf: false,
417
- },
418
- });
419
- }
420
- }
421
-
422
- /**
423
- * Leave a specific voice channel by channel ID.
424
- * @param channelId - Channel ID to leave
425
- */
426
- leaveChannel(channelId: string): void {
427
- const conn = this.connections.get(channelId);
428
- if (conn) {
429
- const guildId = conn.channel?.guildId;
430
- conn.destroy();
431
- this.connections.delete(channelId);
432
- this.connectionIds.delete(channelId);
433
- if (guildId) {
434
- this.client.sendToGateway(this.shardId, {
435
- op: GatewayOpcodes.VoiceStateUpdate,
436
- d: {
437
- guild_id: guildId,
438
- channel_id: null,
439
- self_mute: false,
440
- self_deaf: false,
441
- },
442
- });
443
- }
444
- }
445
- }
446
-
447
- /**
448
- * Get the active voice connection for a channel or guild.
449
- * @param channelOrGuildId - Channel ID (primary) or guild ID (returns first connection in that guild)
450
- */
451
- getConnection(channelOrGuildId: string): VoiceConnection | LiveKitRtcConnection | undefined {
452
- const byChannel = this.connections.get(channelOrGuildId);
453
- if (byChannel) return byChannel;
454
- for (const [, c] of this.connections) {
455
- if (c?.channel?.guildId === channelOrGuildId) return c;
456
- }
457
- return undefined;
458
- }
459
-
460
- /**
461
- * Update voice state (e.g. self_stream, self_video) while in a channel.
462
- * Sends a VoiceStateUpdate to the gateway so the server and clients see the change.
463
- * Requires connection_id (from VoiceServerUpdate); without it, the gateway would treat
464
- * the update as a new join and trigger a new VoiceServerUpdate, causing connection loops.
465
- * @param channelId - Channel ID (connection key)
466
- * @param partial - Partial voice state to update (self_stream, self_video, self_mute, self_deaf)
467
- */
468
- updateVoiceState(
469
- channelId: string,
470
- partial: {
471
- self_stream?: boolean;
472
- self_video?: boolean;
473
- self_mute?: boolean;
474
- self_deaf?: boolean;
475
- },
476
- ): void {
477
- const conn = this.connections.get(channelId);
478
- if (!conn) return;
479
-
480
- const connectionId = this.connectionIds.get(channelId);
481
- const guildId = conn.channel?.guildId;
482
- if (!connectionId) {
483
- this.client.emit?.(
484
- 'debug',
485
- `[VoiceManager] Skipping voice state sync: no connection_id for channel ${channelId}`,
486
- );
487
- return;
488
- }
489
-
490
- this.client.sendToGateway(this.shardId, {
491
- op: GatewayOpcodes.VoiceStateUpdate,
492
- d: {
493
- guild_id: guildId ?? '',
494
- channel_id: conn.channel.id,
495
- connection_id: connectionId,
496
- self_mute: partial.self_mute ?? false,
497
- self_deaf: partial.self_deaf ?? false,
498
- self_video: partial.self_video ?? false,
499
- self_stream: partial.self_stream ?? false,
500
- },
501
- });
502
- }
503
- }
@@ -1,38 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { VoiceManager, VoiceConnection, LiveKitRtcConnection, getVoiceManager } from './index.js';
3
-
4
- describe('@erinjs/voice exports', () => {
5
- it('exports VoiceManager class', () => {
6
- expect(VoiceManager).toBeDefined();
7
- expect(typeof VoiceManager).toBe('function');
8
- });
9
-
10
- it('exports VoiceConnection class', () => {
11
- expect(VoiceConnection).toBeDefined();
12
- expect(typeof VoiceConnection).toBe('function');
13
- });
14
-
15
- it('exports LiveKitRtcConnection class', () => {
16
- expect(LiveKitRtcConnection).toBeDefined();
17
- expect(typeof LiveKitRtcConnection).toBe('function');
18
- });
19
-
20
- it('exports getVoiceManager function', () => {
21
- expect(getVoiceManager).toBeDefined();
22
- expect(typeof getVoiceManager).toBe('function');
23
- });
24
-
25
- it('getVoiceManager returns VoiceManager for mock client', () => {
26
- const mockClient = { on: () => {} };
27
- const manager = getVoiceManager(mockClient);
28
- expect(manager).toBeInstanceOf(VoiceManager);
29
- expect(typeof manager.join).toBe('function');
30
- });
31
-
32
- it('getVoiceManager returns same instance for same client', () => {
33
- const mockClient = { on: () => {} };
34
- const m1 = getVoiceManager(mockClient);
35
- const m2 = getVoiceManager(mockClient);
36
- expect(m1).toBe(m2);
37
- });
38
- });
@@ -1,51 +0,0 @@
1
- export { VoiceManager, type VoiceManagerOptions, type VoiceStateMap } from './VoiceManager.js';
2
- export { VoiceConnection, type VoiceConnectionEvents } from './VoiceConnection.js';
3
- export {
4
- LiveKitRtcConnection,
5
- type LiveKitRtcConnectionEvents,
6
- type LiveKitAudioFrame,
7
- type LiveKitReceiveSubscription,
8
- type VideoPlayOptions,
9
- } from './LiveKitRtcConnection.js';
10
- import { Client } from '@erinjs/core';
11
- import { VoiceChannel } from '@erinjs/core';
12
- import { VoiceManager } from './VoiceManager.js';
13
- import { VoiceConnection } from './VoiceConnection';
14
- import { LiveKitRtcConnection } from './LiveKitRtcConnection';
15
-
16
- /** Union of connection types (Discord-style or LiveKit). */
17
- export type VoiceConnectionLike = VoiceConnection | LiveKitRtcConnection;
18
-
19
- /**
20
- * Create a voice manager and join a voice channel in one call.
21
- *
22
- * @param client - The Fluxer client instance
23
- * @param channel - The voice channel to join
24
- * @param options - Optional options; `shardId` for the gateway shard to use (default 0)
25
- * @returns The voice connection (LiveKitRtcConnection when using LiveKit)
26
- */
27
- export async function joinVoiceChannel(
28
- client: Client,
29
- channel: VoiceChannel,
30
- options?: { shardId?: number },
31
- ): Promise<VoiceConnectionLike> {
32
- const manager = getVoiceManager(client, options);
33
- return manager.join(channel);
34
- }
35
-
36
- const voiceManagers = new WeakMap<Client, VoiceManager>();
37
-
38
- /**
39
- * Get or create the VoiceManager for this client.
40
- *
41
- * @param client - The Fluxer client instance
42
- * @param options - Optional options; `shardId` for the gateway shard to use (default 0)
43
- */
44
- export function getVoiceManager(client: Client, options?: { shardId?: number }): VoiceManager {
45
- let manager = voiceManagers.get(client);
46
- if (!manager) {
47
- manager = new VoiceManager(client, options);
48
- voiceManagers.set(client, manager);
49
- }
50
- return manager;
51
- }
@@ -1,48 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { isLiveKitEndpoint, buildLiveKitUrlForRtcSdk } from './livekit.js';
3
-
4
- describe('isLiveKitEndpoint', () => {
5
- it('returns false for null, undefined, empty', () => {
6
- expect(isLiveKitEndpoint(null)).toBe(false);
7
- expect(isLiveKitEndpoint(undefined)).toBe(false);
8
- expect(isLiveKitEndpoint('')).toBe(false);
9
- });
10
-
11
- it('returns true when access_token in URL', () => {
12
- expect(isLiveKitEndpoint('https://ferret.fluxer.media?access_token=abc')).toBe(true);
13
- });
14
-
15
- it('returns true when /rtc and query params', () => {
16
- expect(isLiveKitEndpoint('wss://host/rtc?token=xyz')).toBe(true);
17
- });
18
-
19
- it('returns true when token provided and endpoint has no query', () => {
20
- expect(isLiveKitEndpoint('ferret.iad.fluxer.media', 'token123')).toBe(true);
21
- });
22
-
23
- it('returns false for plain host without token', () => {
24
- expect(isLiveKitEndpoint('ferret.iad.fluxer.media')).toBe(false);
25
- });
26
- });
27
-
28
- describe('buildLiveKitUrlForRtcSdk', () => {
29
- it('strips scheme and path, keeps host', () => {
30
- const url = buildLiveKitUrlForRtcSdk('wss://ferret.fluxer.media/rtc');
31
- expect(url).toMatch(/wss:\/\/ferret\.fluxer\.media/);
32
- });
33
-
34
- it('uses wss when endpoint has wss', () => {
35
- const url = buildLiveKitUrlForRtcSdk('wss://host.com');
36
- expect(url).toBe('wss://host.com');
37
- });
38
-
39
- it('uses ws when endpoint has ws', () => {
40
- const url = buildLiveKitUrlForRtcSdk('ws://host.com');
41
- expect(url).toBe('ws://host.com');
42
- });
43
-
44
- it('defaults to wss for host without scheme', () => {
45
- const url = buildLiveKitUrlForRtcSdk('host.example.com');
46
- expect(url).toContain('wss://');
47
- });
48
- });
@@ -1,33 +0,0 @@
1
- /**
2
- * Helpers for LiveKit voice endpoints (e.g. Fluxer with access_token in URL).
3
- */
4
-
5
- /**
6
- * True when we should use LiveKit: full URL with access_token, or host + token (Fluxer sends host only to bots).
7
- */
8
- export function isLiveKitEndpoint(
9
- endpoint: string | null | undefined,
10
- token?: string | null,
11
- ): boolean {
12
- if (!endpoint || typeof endpoint !== 'string') return false;
13
- const s = endpoint.trim();
14
- if (s.includes('access_token=') || (s.includes('/rtc') && s.includes('?'))) return true;
15
- // Gateway may send only host (e.g. ferret.iad.fluxer.media) + token
16
- if (token && !s.includes('?')) return true;
17
- return false;
18
- }
19
-
20
- /**
21
- * Build base WebSocket URL for @livekit/rtc-node SDK. The SDK adds /rtc internally.
22
- * Use this for room.connect(url, token) - pass token separately.
23
- * Removes trailing slashes and /rtc path to avoid 404 (SDK adds /rtc itself).
24
- */
25
- export function buildLiveKitUrlForRtcSdk(endpoint: string): string {
26
- const base =
27
- endpoint
28
- .replace(/^(wss|ws|https?):\/\//i, '')
29
- .replace(/^\/+/, '')
30
- .split('/')[0] ?? endpoint;
31
- const scheme = /^wss?:\/\//i.test(endpoint) ? (endpoint.startsWith('wss') ? 'wss' : 'ws') : 'wss';
32
- return `${scheme}://${base.replace(/\/+$/, '')}`;
33
- }