@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,508 +0,0 @@
1
- import { Client } from '../client/Client.js';
2
- import { MessageManager } from '../client/MessageManager.js';
3
- import { MessageCollector } from '../util/MessageCollector.js';
4
- import { MessageCollectorOptions } from '../util/MessageCollector.js';
5
- import { Base } from './Base.js';
6
- import { buildSendBody, resolveMessageFiles } from '../util/messageUtils.js';
7
- import { MessageSendOptions } from '../util/messageUtils.js';
8
- import {
9
- APIChannel,
10
- APIChannelPartial,
11
- APIChannelOverwrite,
12
- APIUser,
13
- APIMessage,
14
- APIWebhook,
15
- APIInvite,
16
- } from '@erinjs/types';
17
- import { ChannelType, Routes } from '@erinjs/types';
18
- import { PermissionFlags } from '@erinjs/util';
19
- import { emitDeprecationWarning } from '@erinjs/util';
20
- import { User } from './User.js';
21
- import { Webhook } from './Webhook.js';
22
- import { Message } from './Message';
23
- import { Invite } from './Invite';
24
-
25
- /** Base class for all channel types. */
26
- export abstract class Channel extends Base {
27
- /** Whether this channel has a send method (TextChannel, DMChannel). */
28
- isTextBased(): this is TextChannel | DMChannel {
29
- return 'send' in this;
30
- }
31
-
32
- /** Whether this channel is a DM or Group DM. */
33
- isDM(): this is DMChannel {
34
- return this.type === ChannelType.DM || this.type === ChannelType.GroupDM;
35
- }
36
-
37
- /** Whether this channel is voice-based (VoiceChannel). */
38
- isVoice(): this is VoiceChannel {
39
- return 'bitrate' in this;
40
- }
41
-
42
- isLink(): this is LinkChannel {
43
- return 'url' in this;
44
- }
45
-
46
- /** Create a DM channel from API data (type DM or GroupDM). */
47
- static createDM(client: Client, data: APIChannelPartial): DMChannel {
48
- return new DMChannel(client, data);
49
- }
50
- readonly client: Client;
51
- readonly id: string;
52
- type: ChannelType;
53
- /** Channel name. Guild channels and Group DMs have names; 1:1 DMs are typically null. */
54
- name: string | null;
55
- /** Channel icon hash (Group DMs). Null if none. */
56
- icon: string | null;
57
- /** ISO timestamp when the last message was pinned. Null if never pinned. */
58
- lastPinTimestamp: string | null;
59
-
60
- /** @param data - API channel from GET /channels/{id} or GET /guilds/{id}/channels */
61
- constructor(client: Client, data: APIChannelPartial) {
62
- super();
63
- this.client = client;
64
- this.id = data.id;
65
- this.type = data.type;
66
- this.name = data.name ?? null;
67
- this.icon = data.icon ?? null;
68
- this.lastPinTimestamp = (data as APIChannel).last_pin_timestamp ?? null;
69
- }
70
-
71
- /**
72
- * Create the appropriate channel subclass from API data.
73
- * @param client - The client instance
74
- * @param data - Channel data from the API
75
- */
76
- static from(
77
- client: Client,
78
- data: APIChannel | APIChannelPartial,
79
- ): GuildChannel | TextChannel | null {
80
- const type = data.type ?? 0;
81
- if (type === ChannelType.GuildText) return new TextChannel(client, data as APIChannel);
82
- if (type === ChannelType.GuildCategory) return new CategoryChannel(client, data as APIChannel);
83
- if (type === ChannelType.GuildVoice) return new VoiceChannel(client, data as APIChannel);
84
- if (type === ChannelType.GuildLink || type === ChannelType.GuildLinkExtended)
85
- return new LinkChannel(client, data as APIChannel);
86
- return new GuildChannel(client, data as APIChannel);
87
- }
88
-
89
- /**
90
- * Create a channel from API data, including DM and GroupDM.
91
- * Used by ChannelManager.fetch() for GET /channels/{id}.
92
- */
93
- static fromOrCreate(
94
- client: Client,
95
- data: APIChannel | APIChannelPartial,
96
- ): TextChannel | DMChannel | GuildChannel | null {
97
- const type = data.type ?? 0;
98
- if (type === ChannelType.DM || type === ChannelType.GroupDM)
99
- return Channel.createDM(client, data);
100
- return Channel.from(client, data);
101
- }
102
-
103
- /**
104
- * Bulk delete messages. Requires Manage Messages permission.
105
- * @param messageIds - Array of message IDs to delete (2–100)
106
- */
107
- async bulkDeleteMessages(messageIds: string[]): Promise<void> {
108
- await this.client.rest.post(Routes.channelBulkDelete(this.id), {
109
- body: { message_ids: messageIds },
110
- auth: true,
111
- });
112
- }
113
-
114
- /**
115
- * Send a typing indicator to the channel. Lasts ~10 seconds.
116
- */
117
- async sendTyping(): Promise<void> {
118
- await this.client.rest.post(Routes.channelTyping(this.id), { auth: true });
119
- }
120
-
121
- /**
122
- * Whether the bot can send messages in this channel.
123
- * For DMs: always true (when the channel exists).
124
- * For guild channels: checks ViewChannel and SendMessages permissions via guild.members.me.
125
- */
126
- canSendMessage(): boolean {
127
- if (this.isDM()) return true;
128
- return false;
129
- }
130
- }
131
-
132
- export class GuildChannel extends Channel {
133
- readonly guildId: string;
134
- name: string | null;
135
- position?: number;
136
- parentId: string | null;
137
- /** Permission overwrites for roles and members. */
138
- permissionOverwrites: APIChannelOverwrite[];
139
-
140
- constructor(client: Client, data: APIChannel) {
141
- super(client, data);
142
- this.guildId = data.guild_id ?? '';
143
- this.name = data.name ?? null;
144
- this.position = data.position;
145
- this.parentId = data.parent_id ?? null;
146
- this.permissionOverwrites = data.permission_overwrites ?? [];
147
- }
148
-
149
- /**
150
- * Create a webhook in this channel.
151
- * @param options - Webhook name and optional avatar URL
152
- * @returns The webhook with token (required for send()). Requires Manage Webhooks permission.
153
- */
154
- async createWebhook(options: { name: string; avatar?: string | null }): Promise<Webhook> {
155
- const data = await this.client.rest.post(Routes.channelWebhooks(this.id), {
156
- body: options,
157
- auth: true,
158
- });
159
- return new Webhook(this.client, data as APIWebhook);
160
- }
161
-
162
- /**
163
- * Fetch all webhooks in this channel.
164
- * @returns Webhooks (includes token when listing from channel; can send via send())
165
- */
166
- async fetchWebhooks(): Promise<Webhook[]> {
167
- const data = await this.client.rest.get(Routes.channelWebhooks(this.id));
168
- const list = Array.isArray(data) ? data : Object.values(data ?? {});
169
- return list.map((w) => new Webhook(this.client, w));
170
- }
171
-
172
- /**
173
- * Create an invite for this channel.
174
- * @param options - max_uses (0–100), max_age (0–604800 seconds), unique, temporary
175
- * Requires Create Instant Invite permission.
176
- */
177
- async createInvite(options?: {
178
- max_uses?: number;
179
- max_age?: number;
180
- unique?: boolean;
181
- temporary?: boolean;
182
- }): Promise<Invite> {
183
- const body: Record<string, unknown> = {};
184
- if (options?.max_uses != null) body.max_uses = options.max_uses;
185
- if (options?.max_age != null) body.max_age = options.max_age;
186
- if (options?.unique != null) body.unique = options.unique;
187
- if (options?.temporary != null) body.temporary = options.temporary;
188
- const data = await this.client.rest.post(Routes.channelInvites(this.id), {
189
- body: Object.keys(body).length ? body : undefined,
190
- auth: true,
191
- });
192
- return new Invite(this.client, data as APIInvite);
193
- }
194
-
195
- /**
196
- * Fetch invites for this channel.
197
- * Requires Manage Channel permission.
198
- */
199
- async fetchInvites(): Promise<Invite[]> {
200
- const data = await this.client.rest.get(Routes.channelInvites(this.id));
201
- const list = Array.isArray(data) ? data : Object.values(data ?? {});
202
- return list.map((i) => new Invite(this.client, i as APIInvite));
203
- }
204
-
205
- /**
206
- * Set or update a permission overwrite. PUT /channels/{id}/permissions/{overwriteId}.
207
- * @param overwriteId - Role or member ID
208
- * @param options - type (0=role, 1=member), allow, deny (permission bitfields)
209
- */
210
- async editPermission(
211
- overwriteId: string,
212
- options: { type: 0 | 1; allow?: string; deny?: string },
213
- ): Promise<void> {
214
- await this.client.rest.put(Routes.channelPermission(this.id, overwriteId), {
215
- body: options,
216
- auth: true,
217
- });
218
- const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
219
- const entry = {
220
- id: overwriteId,
221
- type: options.type,
222
- allow: options.allow ?? '0',
223
- deny: options.deny ?? '0',
224
- };
225
- if (idx >= 0) this.permissionOverwrites[idx] = entry;
226
- else this.permissionOverwrites.push(entry);
227
- }
228
-
229
- /**
230
- * Whether the bot can send messages in this channel.
231
- * Checks ViewChannel and SendMessages via guild.members.me permissions.
232
- * Returns false if guild or bot member not cached.
233
- */
234
- override canSendMessage(): boolean {
235
- const guild = this.client.guilds.get(this.guildId);
236
- if (!guild) return false;
237
- const me = guild.members.me;
238
- if (!me) return false;
239
- const perms = me.permissionsIn(this);
240
- return perms.has(PermissionFlags.ViewChannel) && perms.has(PermissionFlags.SendMessages);
241
- }
242
-
243
- /**
244
- * Send a message to this guild channel.
245
- * Works for text and announcement channels. Voice/category/link channels will fail at the API.
246
- */
247
- async send(options: MessageSendOptions): Promise<Message> {
248
- const opts = typeof options === 'string' ? { content: options } : options;
249
- const body = buildSendBody(options);
250
- const files = opts.files?.length ? await resolveMessageFiles(opts.files) : undefined;
251
- const postOptions = files?.length ? { body, files } : { body };
252
- const data = await this.client.rest.post(Routes.channelMessages(this.id), postOptions);
253
- this.client._addMessageToCache(this.id, data as APIMessage);
254
- return new Message(this.client, data as APIMessage);
255
- }
256
-
257
- /**
258
- * Remove a permission overwrite. DELETE /channels/{id}/permissions/{overwriteId}.
259
- */
260
- async deletePermission(overwriteId: string): Promise<void> {
261
- await this.client.rest.delete(Routes.channelPermission(this.id, overwriteId), { auth: true });
262
- const idx = this.permissionOverwrites.findIndex((o) => o.id === overwriteId);
263
- if (idx >= 0) this.permissionOverwrites.splice(idx, 1);
264
- }
265
-
266
- /**
267
- * Edit this channel. PATCH /channels/{id}.
268
- * Requires Manage Channel permission.
269
- */
270
- async edit(options: {
271
- name?: string | null;
272
- topic?: string | null;
273
- parent_id?: string | null;
274
- bitrate?: number | null;
275
- user_limit?: number | null;
276
- nsfw?: boolean;
277
- rate_limit_per_user?: number;
278
- rtc_region?: string | null;
279
- permission_overwrites?: Array<{ id: string; type: number; allow?: string; deny?: string }>;
280
- }): Promise<this> {
281
- const data = await this.client.rest.patch<APIChannel>(Routes.channel(this.id), {
282
- body: options,
283
- auth: true,
284
- });
285
- this.name = data.name ?? this.name;
286
- this.parentId = data.parent_id ?? this.parentId;
287
- this.permissionOverwrites = data.permission_overwrites ?? this.permissionOverwrites;
288
- const self = this as Record<string, unknown>;
289
- if ('topic' in self && 'topic' in data) self.topic = data.topic ?? null;
290
- if ('nsfw' in self && 'nsfw' in data) self.nsfw = data.nsfw ?? false;
291
- if ('rate_limit_per_user' in data) self.rateLimitPerUser = data.rate_limit_per_user ?? 0;
292
- if ('bitrate' in self && 'bitrate' in data) self.bitrate = data.bitrate ?? null;
293
- if ('user_limit' in data) self.userLimit = data.user_limit ?? null;
294
- if ('rtc_region' in data) self.rtcRegion = data.rtc_region ?? null;
295
- return this;
296
- }
297
-
298
- /**
299
- * Delete this channel. Requires Manage Channel permission.
300
- * @param options - silent: if true, does not send a system message (default false)
301
- */
302
- async delete(options?: { silent?: boolean }): Promise<void> {
303
- const url = Routes.channel(this.id) + (options?.silent ? '?silent=true' : '');
304
- await this.client.rest.delete(url, { auth: true });
305
- this.client.channels.delete(this.id);
306
- const guild = this.client.guilds.get(this.guildId);
307
- if (guild) guild.channels.delete(this.id);
308
- }
309
- }
310
-
311
- export class TextChannel extends GuildChannel {
312
- topic?: string | null;
313
- nsfw?: boolean;
314
- rateLimitPerUser?: number;
315
- lastMessageId?: string | null;
316
-
317
- constructor(client: Client, data: APIChannel) {
318
- super(client, data);
319
- this.topic = data.topic ?? null;
320
- this.nsfw = data.nsfw ?? false;
321
- this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
322
- this.lastMessageId = data.last_message_id ?? null;
323
- }
324
-
325
- /**
326
- * Send a message to this channel.
327
- * @param options - Text content or object with content, embeds, and/or files
328
- */
329
- async send(options: MessageSendOptions): Promise<Message> {
330
- const opts = typeof options === 'string' ? { content: options } : options;
331
- const body = buildSendBody(options);
332
- const files = opts.files?.length ? await resolveMessageFiles(opts.files) : undefined;
333
- const postOptions = files?.length ? { body, files } : { body };
334
- const data = await this.client.rest.post(Routes.channelMessages(this.id), postOptions);
335
- this.client._addMessageToCache(this.id, data as APIMessage);
336
- return new Message(this.client, data as APIMessage);
337
- }
338
-
339
- /** Message manager for this channel. Use channel.messages.fetch(messageId). */
340
- get messages(): MessageManager {
341
- return new MessageManager(this.client, this.id);
342
- }
343
-
344
- /**
345
- * Create a message collector for this channel.
346
- * Collects messages matching the filter until time expires or max is reached.
347
- * @param options - Filter, time (ms), and max count
348
- * @example
349
- * const collector = channel.createMessageCollector({ filter: m => m.author.id === userId, time: 10000 });
350
- * collector.on('collect', m => console.log(m.content));
351
- * collector.on('end', (collected, reason) => { ... });
352
- */
353
- createMessageCollector(options?: MessageCollectorOptions): MessageCollector {
354
- return new MessageCollector(this.client, this.id, options);
355
- }
356
-
357
- /**
358
- * Fetch pinned messages in this channel.
359
- * @returns Pinned messages
360
- */
361
- async fetchPinnedMessages(): Promise<Message[]> {
362
- type PinnedItem = APIMessage | { message?: APIMessage };
363
- const data = (await this.client.rest.get(Routes.channelPins(this.id))) as
364
- | { items?: PinnedItem[] }
365
- | APIMessage[];
366
- const list: PinnedItem[] = Array.isArray(data) ? data : (data?.items ?? []);
367
- return list.map((item) => {
368
- const msg = typeof item === 'object' && item && 'message' in item ? item.message : item;
369
- return new Message(this.client, msg as APIMessage);
370
- });
371
- }
372
-
373
- /**
374
- * Fetch a message by ID from this channel.
375
- * @param messageId - Snowflake of the message
376
- * @returns The message, or null if not found
377
- * @deprecated Use channel.messages.fetch(messageId) instead.
378
- */
379
- async fetchMessage(messageId: string): Promise<Message> {
380
- emitDeprecationWarning(
381
- 'Channel.fetchMessage()',
382
- 'Use channel.messages.fetch(messageId) instead.',
383
- );
384
- return this.client.channels.fetchMessage(this.id, messageId);
385
- }
386
- }
387
-
388
- export class CategoryChannel extends GuildChannel {}
389
- export class VoiceChannel extends GuildChannel {
390
- bitrate?: number | null;
391
- userLimit?: number | null;
392
- rtcRegion?: string | null;
393
-
394
- constructor(client: Client, data: APIChannel) {
395
- super(client, data);
396
- this.bitrate = data.bitrate ?? null;
397
- this.userLimit = data.user_limit ?? null;
398
- this.rtcRegion = data.rtc_region ?? null;
399
- }
400
- }
401
-
402
- export class LinkChannel extends GuildChannel {
403
- url: string | null;
404
- constructor(client: Client, data: APIChannel) {
405
- super(client, data);
406
- this.url = data.url ?? null;
407
- }
408
- }
409
-
410
- /** DM channel (direct message between bot and a user). */
411
- export class DMChannel extends Channel {
412
- lastMessageId?: string | null;
413
- /** Group DM creator ID. Null for 1:1 DMs. */
414
- ownerId: string | null;
415
- /** Group DM recipients as User objects. Empty for 1:1 DMs. */
416
- recipients: User[];
417
- /** Group DM member display names (userId -> nickname). */
418
- nicks: Record<string, string>;
419
-
420
- constructor(client: Client, data: APIChannelPartial & Partial<APIChannel>) {
421
- super(client, data);
422
- this.lastMessageId = (data as APIChannel).last_message_id ?? null;
423
- this.ownerId = (data as APIChannel).owner_id ?? null;
424
- this.recipients = ((data as APIChannel).recipients ?? []).map((u: APIUser) =>
425
- client.getOrCreateUser(u),
426
- );
427
- this.nicks = (data as APIChannel).nicks ?? {};
428
- }
429
-
430
- /**
431
- * Send a message to this DM channel.
432
- * @param options - Text content or object with content, embeds, and/or files
433
- */
434
- async send(options: MessageSendOptions): Promise<Message> {
435
- const opts = typeof options === 'string' ? { content: options } : options;
436
- const body = buildSendBody(options);
437
- const files = opts.files?.length ? await resolveMessageFiles(opts.files) : undefined;
438
- const postOptions = files?.length ? { body, files } : { body };
439
- const data = await this.client.rest.post(Routes.channelMessages(this.id), postOptions);
440
- this.client._addMessageToCache(this.id, data as APIMessage);
441
- return new Message(this.client, data as APIMessage);
442
- }
443
-
444
- /** Message manager for this channel. Use channel.messages.fetch(messageId). */
445
- get messages(): MessageManager {
446
- return new MessageManager(this.client, this.id);
447
- }
448
-
449
- /**
450
- * Create a message collector for this DM channel.
451
- * @param options - Filter, time (ms), and max count
452
- */
453
- createMessageCollector(options?: MessageCollectorOptions): MessageCollector {
454
- return new MessageCollector(this.client, this.id, options);
455
- }
456
-
457
- /**
458
- * Fetch pinned messages in this DM channel.
459
- * @returns Pinned messages
460
- */
461
- async fetchPinnedMessages(): Promise<Message[]> {
462
- type PinnedItem = APIMessage | { message?: APIMessage };
463
- const data = (await this.client.rest.get(Routes.channelPins(this.id))) as
464
- | { items?: PinnedItem[] }
465
- | APIMessage[];
466
- const list: PinnedItem[] = Array.isArray(data) ? data : (data?.items ?? []);
467
- return list.map((item) => {
468
- const msg = typeof item === 'object' && item && 'message' in item ? item.message : item;
469
- return new Message(this.client, msg as APIMessage);
470
- });
471
- }
472
-
473
- /**
474
- * Fetch a message by ID from this DM channel.
475
- * @param messageId - Snowflake of the message
476
- * @returns The message, or null if not found
477
- * @deprecated Use channel.messages.fetch(messageId) instead.
478
- */
479
- async fetchMessage(messageId: string): Promise<Message> {
480
- emitDeprecationWarning(
481
- 'Channel.fetchMessage()',
482
- 'Use channel.messages.fetch(messageId) instead.',
483
- );
484
- return this.client.channels.fetchMessage(this.id, messageId);
485
- }
486
-
487
- /**
488
- * Add a recipient to this Group DM. Requires Group DM (type GroupDM).
489
- * PUT /channels/{id}/recipients/{userId}.
490
- */
491
- async addRecipient(userId: string): Promise<void> {
492
- await this.client.rest.put(Routes.channelRecipient(this.id, userId), { auth: true });
493
- const user = this.client.users.get(userId) ?? (await this.client.users.fetch(userId));
494
- if (user) this.recipients.push(user);
495
- }
496
-
497
- /**
498
- * Remove a recipient from this Group DM. Requires Group DM (type GroupDM).
499
- * DELETE /channels/{id}/recipients/{userId}.
500
- * @param options - silent: if true, does not send a system message (default false)
501
- */
502
- async removeRecipient(userId: string, options?: { silent?: boolean }): Promise<void> {
503
- const url = Routes.channelRecipient(this.id, userId) + (options?.silent ? '?silent=true' : '');
504
- await this.client.rest.delete(url, { auth: true });
505
- const idx = this.recipients.findIndex((u) => u.id === userId);
506
- if (idx >= 0) this.recipients.splice(idx, 1);
507
- }
508
- }
@@ -1,189 +0,0 @@
1
- import { describe, it, expect, vi } from 'vitest';
2
- import { Guild, Client } from '../';
3
- import { Routes } from '@erinjs/types';
4
-
5
- function createMockClient() {
6
- return {} as Client;
7
- }
8
-
9
- function createRestBackedGuild(restGetResponse: unknown) {
10
- const get = vi.fn().mockResolvedValue(restGetResponse);
11
- const client = {
12
- rest: { get },
13
- getOrCreateUser: (data: { id: string; username?: string; discriminator?: string }) => ({
14
- id: data.id,
15
- username: data.username ?? 'user',
16
- discriminator: data.discriminator ?? '0',
17
- }),
18
- guilds: new Map(),
19
- channels: new Map(),
20
- } as unknown as Client;
21
-
22
- const guild = new Guild(client, {
23
- id: 'guild1',
24
- name: 'Test Guild',
25
- icon: null,
26
- banner: null,
27
- splash: null,
28
- owner_id: 'owner1',
29
- features: [],
30
- afk_timeout: 0,
31
- nsfw_level: 0,
32
- verification_level: 0,
33
- mfa_level: 0,
34
- explicit_content_filter: 0,
35
- default_message_notifications: 0,
36
- });
37
-
38
- return { guild, get };
39
- }
40
-
41
- function createGuild(
42
- overrides: {
43
- id?: string;
44
- icon?: string | null;
45
- banner?: string | null;
46
- splash?: string | null;
47
- } = {},
48
- ) {
49
- return new Guild(createMockClient(), {
50
- id: overrides.id ?? 'guild1',
51
- name: 'Test Guild',
52
- icon: overrides.icon ?? null,
53
- banner: overrides.banner ?? null,
54
- splash: overrides.splash ?? null,
55
- owner_id: 'owner1',
56
- features: [],
57
- afk_timeout: 0,
58
- nsfw_level: 0,
59
- verification_level: 0,
60
- mfa_level: 0,
61
- explicit_content_filter: 0,
62
- default_message_notifications: 0,
63
- });
64
- }
65
-
66
- describe('Guild', () => {
67
- describe('iconURL()', () => {
68
- it('returns null when icon is null', () => {
69
- const guild = createGuild({ icon: null });
70
- expect(guild.iconURL()).toBeNull();
71
- });
72
-
73
- it('builds icon URL when icon is set', () => {
74
- const guild = createGuild({ icon: 'iconhash123' });
75
- const url = guild.iconURL();
76
- expect(url).toContain('fluxerusercontent.com/icons/guild1/iconhash123.png');
77
- });
78
-
79
- it('appends size when provided', () => {
80
- const guild = createGuild({ icon: 'hash' });
81
- const url = guild.iconURL({ size: 512 });
82
- expect(url).toContain('?size=512');
83
- });
84
- });
85
-
86
- describe('bannerURL()', () => {
87
- it('returns null when banner is null', () => {
88
- const guild = createGuild({ banner: null });
89
- expect(guild.bannerURL()).toBeNull();
90
- });
91
-
92
- it('builds banner URL when banner is set', () => {
93
- const guild = createGuild({ banner: 'bannerhash' });
94
- const url = guild.bannerURL();
95
- expect(url).toContain('fluxerusercontent.com/banners/guild1/bannerhash.png');
96
- });
97
- });
98
-
99
- describe('splashURL()', () => {
100
- it('returns null when splash is null', () => {
101
- const guild = createGuild({ splash: null });
102
- expect(guild.splashURL()).toBeNull();
103
- });
104
-
105
- it('builds splash URL when splash is set', () => {
106
- const guild = createGuild({ splash: 'splashhash' });
107
- const url = guild.splashURL();
108
- expect(url).toContain('fluxerusercontent.com/splashes/guild1/splashhash.png');
109
- });
110
- });
111
-
112
- describe('constructor', () => {
113
- it('parses guild id and name', () => {
114
- const guild = createGuild({ id: 'custom123' });
115
- expect(guild.id).toBe('custom123');
116
- expect(guild.name).toBe('Test Guild');
117
- });
118
- });
119
-
120
- describe('invite helper methods', () => {
121
- it('fetchInvites() fetches and maps guild invites', async () => {
122
- const { guild, get } = createRestBackedGuild([
123
- {
124
- code: 'abc123',
125
- type: 0,
126
- guild: { id: 'guild1', name: 'Test Guild' },
127
- channel: { id: 'channel1', type: 0, name: 'general' },
128
- },
129
- ]);
130
-
131
- const invites = await guild.fetchInvites();
132
-
133
- expect(get).toHaveBeenCalledWith(Routes.guildInvites('guild1'));
134
- expect(invites).toHaveLength(1);
135
- expect(invites[0]?.code).toBe('abc123');
136
- });
137
-
138
- it('fetchInvite() supports code-or-url helper flow', async () => {
139
- const { guild, get } = createRestBackedGuild({
140
- code: 'xyz789',
141
- type: 0,
142
- guild: { id: 'guild1', name: 'Test Guild' },
143
- channel: { id: 'channel1', type: 0, name: 'general' },
144
- });
145
-
146
- const invite = await guild.fetchInvite('https://fluxer.gg/xyz789');
147
-
148
- expect(get).toHaveBeenCalledWith(Routes.invite('xyz789'));
149
- expect(invite.code).toBe('xyz789');
150
- });
151
- });
152
-
153
- describe('guild sticker helper methods', () => {
154
- it('fetchStickers() fetches and caches guild stickers', async () => {
155
- const { guild, get } = createRestBackedGuild([
156
- {
157
- id: 'sticker1',
158
- name: 'sample_sticker_a',
159
- description: 'Sample sticker A',
160
- tags: ['sample', 'a'],
161
- animated: false,
162
- },
163
- ]);
164
-
165
- const stickers = await guild.fetchStickers();
166
-
167
- expect(get).toHaveBeenCalledWith(Routes.guildStickers('guild1'));
168
- expect(stickers).toHaveLength(1);
169
- expect(stickers[0]?.id).toBe('sticker1');
170
- expect(guild.stickers.get('sticker1')?.name).toBe('sample_sticker_a');
171
- });
172
-
173
- it('fetchSticker() fetches and caches a single guild sticker', async () => {
174
- const { guild, get } = createRestBackedGuild({
175
- id: 'sticker42',
176
- name: 'sample_sticker_b',
177
- description: 'Sample sticker B',
178
- tags: ['sample', 'b'],
179
- animated: false,
180
- });
181
-
182
- const sticker = await guild.fetchSticker('sticker42');
183
-
184
- expect(get).toHaveBeenCalledWith(Routes.guildSticker('guild1', 'sticker42'));
185
- expect(sticker.id).toBe('sticker42');
186
- expect(guild.stickers.get('sticker42')?.name).toBe('sample_sticker_b');
187
- });
188
- });
189
- });