seyfert 4.5.0 → 5.0.0

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 (230) hide show
  1. package/lib/api/Routes/cdn.d.ts +2 -2
  2. package/lib/api/Routes/guilds.d.ts +2 -2
  3. package/lib/api/Routes/invites.d.ts +2 -2
  4. package/lib/api/api.d.ts +20 -8
  5. package/lib/api/api.js +198 -44
  6. package/lib/api/shared.d.ts +30 -1
  7. package/lib/api/utils/constants.d.ts +1 -1
  8. package/lib/api/utils/constants.js +1 -1
  9. package/lib/api/utils/utils.d.ts +2 -1
  10. package/lib/api/utils/utils.js +1 -1
  11. package/lib/builders/Attachment.d.ts +1 -1
  12. package/lib/builders/Attachment.js +30 -8
  13. package/lib/builders/MediaGallery.d.ts +2 -2
  14. package/lib/builders/MediaGallery.js +10 -0
  15. package/lib/builders/Modal.d.ts +18 -8
  16. package/lib/builders/Modal.js +36 -7
  17. package/lib/builders/Poll.js +18 -0
  18. package/lib/builders/RadioGroup.d.ts +4 -3
  19. package/lib/builders/RadioGroup.js +24 -3
  20. package/lib/builders/SelectMenu.d.ts +8 -6
  21. package/lib/builders/SelectMenu.js +24 -3
  22. package/lib/builders/types.d.ts +3 -2
  23. package/lib/cache/adapters/default.d.ts +1 -1
  24. package/lib/cache/adapters/default.js +23 -26
  25. package/lib/cache/adapters/limited.d.ts +1 -0
  26. package/lib/cache/adapters/limited.js +47 -33
  27. package/lib/cache/index.d.ts +19 -25
  28. package/lib/cache/index.js +58 -6
  29. package/lib/cache/resources/bans.d.ts +1 -1
  30. package/lib/cache/resources/bans.js +4 -4
  31. package/lib/cache/resources/channels.d.ts +1 -1
  32. package/lib/cache/resources/channels.js +4 -4
  33. package/lib/cache/resources/default/base.d.ts +1 -1
  34. package/lib/cache/resources/default/base.js +8 -8
  35. package/lib/cache/resources/default/guild-based.d.ts +5 -5
  36. package/lib/cache/resources/default/guild-based.js +29 -16
  37. package/lib/cache/resources/default/guild-related.d.ts +5 -5
  38. package/lib/cache/resources/default/guild-related.js +14 -14
  39. package/lib/cache/resources/emojis.d.ts +1 -1
  40. package/lib/cache/resources/emojis.js +4 -4
  41. package/lib/cache/resources/guilds.js +28 -15
  42. package/lib/cache/resources/members.d.ts +1 -1
  43. package/lib/cache/resources/members.js +6 -6
  44. package/lib/cache/resources/messages.d.ts +7 -2
  45. package/lib/cache/resources/messages.js +43 -20
  46. package/lib/cache/resources/overwrites.d.ts +1 -1
  47. package/lib/cache/resources/overwrites.js +5 -8
  48. package/lib/cache/resources/roles.d.ts +1 -1
  49. package/lib/cache/resources/roles.js +4 -4
  50. package/lib/cache/resources/stickers.d.ts +1 -1
  51. package/lib/cache/resources/stickers.js +4 -4
  52. package/lib/cache/resources/users.js +4 -4
  53. package/lib/cache/resources/voice-states.d.ts +1 -1
  54. package/lib/cache/resources/voice-states.js +4 -4
  55. package/lib/client/base.d.ts +83 -24
  56. package/lib/client/base.js +594 -39
  57. package/lib/client/client.d.ts +28 -3
  58. package/lib/client/client.js +33 -9
  59. package/lib/client/collectors.d.ts +9 -8
  60. package/lib/client/collectors.js +19 -52
  61. package/lib/client/httpclient.d.ts +3 -0
  62. package/lib/client/index.d.ts +3 -1
  63. package/lib/client/index.js +4 -0
  64. package/lib/client/intents.d.ts +3 -0
  65. package/lib/client/intents.js +9 -0
  66. package/lib/client/plugins/api.d.ts +4 -0
  67. package/lib/client/plugins/api.js +550 -0
  68. package/lib/client/plugins/errors.d.ts +25 -0
  69. package/lib/client/plugins/errors.js +79 -0
  70. package/lib/client/plugins/order.d.ts +10 -0
  71. package/lib/client/plugins/order.js +32 -0
  72. package/lib/client/plugins/registry.d.ts +273 -0
  73. package/lib/client/plugins/registry.js +868 -0
  74. package/lib/client/plugins/shared.d.ts +23 -0
  75. package/lib/client/plugins/shared.js +193 -0
  76. package/lib/client/plugins/types.d.ts +398 -0
  77. package/lib/client/plugins/types.js +8 -0
  78. package/lib/client/plugins.d.ts +78 -0
  79. package/lib/client/plugins.js +558 -0
  80. package/lib/client/transformers.d.ts +33 -33
  81. package/lib/client/workerclient.d.ts +10 -1
  82. package/lib/client/workerclient.js +27 -17
  83. package/lib/collection.d.ts +10 -8
  84. package/lib/collection.js +19 -25
  85. package/lib/commands/applications/chat.d.ts +20 -18
  86. package/lib/commands/applications/chat.js +39 -14
  87. package/lib/commands/applications/chatcontext.d.ts +23 -15
  88. package/lib/commands/applications/chatcontext.js +23 -2
  89. package/lib/commands/applications/entryPoint.d.ts +4 -3
  90. package/lib/commands/applications/entryPoint.js +1 -1
  91. package/lib/commands/applications/entrycontext.d.ts +7 -9
  92. package/lib/commands/applications/entrycontext.js +3 -1
  93. package/lib/commands/applications/menu.d.ts +4 -3
  94. package/lib/commands/applications/menucontext.d.ts +7 -9
  95. package/lib/commands/applications/menucontext.js +3 -1
  96. package/lib/commands/applications/options.d.ts +23 -23
  97. package/lib/commands/applications/shared.d.ts +39 -17
  98. package/lib/commands/decorators.d.ts +50 -38
  99. package/lib/commands/decorators.js +15 -5
  100. package/lib/commands/handle.d.ts +19 -8
  101. package/lib/commands/handle.js +224 -143
  102. package/lib/commands/handler.d.ts +21 -8
  103. package/lib/commands/handler.js +157 -69
  104. package/lib/commands/index.d.ts +1 -0
  105. package/lib/commands/optionresolver.d.ts +2 -2
  106. package/lib/common/it/colors.js +12 -2
  107. package/lib/common/it/error.d.ts +9 -0
  108. package/lib/common/it/error.js +8 -0
  109. package/lib/common/it/fake-promise.d.ts +4 -0
  110. package/lib/common/it/fake-promise.js +10 -0
  111. package/lib/common/it/formatter.d.ts +14 -11
  112. package/lib/common/it/formatter.js +4 -3
  113. package/lib/common/it/logger.d.ts +7 -1
  114. package/lib/common/it/logger.js +24 -6
  115. package/lib/common/it/utils.d.ts +6 -8
  116. package/lib/common/it/utils.js +44 -42
  117. package/lib/common/shorters/application.d.ts +3 -3
  118. package/lib/common/shorters/application.js +3 -2
  119. package/lib/common/shorters/bans.d.ts +8 -4
  120. package/lib/common/shorters/bans.js +13 -5
  121. package/lib/common/shorters/channels.d.ts +4 -4
  122. package/lib/common/shorters/channels.js +4 -4
  123. package/lib/common/shorters/emojis.js +1 -0
  124. package/lib/common/shorters/guilds.d.ts +8 -8
  125. package/lib/common/shorters/guilds.js +14 -31
  126. package/lib/common/shorters/interaction.d.ts +1 -1
  127. package/lib/common/shorters/invites.d.ts +201 -201
  128. package/lib/common/shorters/members.d.ts +7 -7
  129. package/lib/common/shorters/members.js +13 -14
  130. package/lib/common/shorters/messages.d.ts +2 -2
  131. package/lib/common/shorters/soundboard.d.ts +5 -5
  132. package/lib/common/shorters/users.d.ts +1 -1
  133. package/lib/common/shorters/webhook.d.ts +3 -2
  134. package/lib/common/shorters/webhook.js +0 -7
  135. package/lib/common/types/options.d.ts +4 -0
  136. package/lib/common/types/util.d.ts +8 -0
  137. package/lib/common/types/write.d.ts +2 -1
  138. package/lib/components/BaseSelectMenuComponent.d.ts +1 -1
  139. package/lib/components/BaseSelectMenuComponent.js +1 -1
  140. package/lib/components/ButtonComponent.d.ts +3 -3
  141. package/lib/components/ChannelSelectMenuComponent.d.ts +2 -2
  142. package/lib/components/File.d.ts +1 -1
  143. package/lib/components/MediaGallery.d.ts +1 -1
  144. package/lib/components/MentionableSelectMenuComponent.d.ts +1 -1
  145. package/lib/components/RoleSelectMenuComponent.d.ts +1 -1
  146. package/lib/components/Separator.d.ts +1 -1
  147. package/lib/components/StringSelectMenuComponent.d.ts +1 -1
  148. package/lib/components/TextInputComponent.d.ts +1 -1
  149. package/lib/components/Thumbnail.d.ts +1 -1
  150. package/lib/components/UserSelectMenuComponent.d.ts +1 -1
  151. package/lib/components/componentcommand.d.ts +8 -7
  152. package/lib/components/componentcontext.d.ts +24 -36
  153. package/lib/components/componentcontext.js +7 -17
  154. package/lib/components/handler.d.ts +17 -7
  155. package/lib/components/handler.js +108 -49
  156. package/lib/components/index.d.ts +1 -0
  157. package/lib/components/index.js +1 -0
  158. package/lib/components/interactioncontext.d.ts +45 -0
  159. package/lib/components/interactioncontext.js +93 -0
  160. package/lib/components/modalcommand.d.ts +5 -4
  161. package/lib/components/modalcontext.d.ts +39 -20
  162. package/lib/components/modalcontext.js +59 -6
  163. package/lib/events/event.d.ts +9 -3
  164. package/lib/events/handler.d.ts +51 -6
  165. package/lib/events/handler.js +165 -36
  166. package/lib/events/hooks/application_command.d.ts +1 -1
  167. package/lib/events/hooks/auto_moderation.d.ts +2 -2
  168. package/lib/events/hooks/guild.d.ts +150 -150
  169. package/lib/events/hooks/interactions.d.ts +1 -1
  170. package/lib/events/hooks/invite.d.ts +20 -20
  171. package/lib/events/hooks/message.d.ts +27 -27
  172. package/lib/events/hooks/presence.d.ts +11 -11
  173. package/lib/events/hooks/soundboard.d.ts +6 -6
  174. package/lib/events/hooks/stage.d.ts +2 -2
  175. package/lib/events/hooks/subscriptions.d.ts +3 -3
  176. package/lib/events/hooks/thread.d.ts +30 -30
  177. package/lib/events/hooks/voice.d.ts +3 -4
  178. package/lib/events/hooks/voice.js +2 -1
  179. package/lib/events/utils.d.ts +4 -0
  180. package/lib/events/utils.js +59 -0
  181. package/lib/index.d.ts +9 -4
  182. package/lib/index.js +13 -8
  183. package/lib/langs/handler.d.ts +14 -11
  184. package/lib/langs/handler.js +46 -9
  185. package/lib/langs/router.d.ts +10 -3
  186. package/lib/structures/Application.d.ts +1 -1
  187. package/lib/structures/Emoji.d.ts +3 -3
  188. package/lib/structures/Emoji.js +2 -2
  189. package/lib/structures/Guild.d.ts +154 -154
  190. package/lib/structures/GuildBan.d.ts +4 -4
  191. package/lib/structures/GuildBan.js +3 -3
  192. package/lib/structures/GuildMember.d.ts +7 -7
  193. package/lib/structures/GuildMember.js +28 -7
  194. package/lib/structures/GuildRole.d.ts +1 -1
  195. package/lib/structures/GuildRole.js +2 -2
  196. package/lib/structures/Interaction.d.ts +11 -9
  197. package/lib/structures/Interaction.js +33 -12
  198. package/lib/structures/Message.d.ts +21 -14
  199. package/lib/structures/Message.js +29 -14
  200. package/lib/structures/User.d.ts +1 -1
  201. package/lib/structures/VoiceState.d.ts +4 -0
  202. package/lib/structures/VoiceState.js +13 -1
  203. package/lib/structures/Webhook.d.ts +9 -1
  204. package/lib/structures/Webhook.js +4 -1
  205. package/lib/structures/channels.d.ts +148 -134
  206. package/lib/structures/channels.js +27 -26
  207. package/lib/structures/extra/BitField.d.ts +4 -4
  208. package/lib/structures/extra/BitField.js +20 -4
  209. package/lib/structures/extra/DiscordBase.js +1 -1
  210. package/lib/structures/extra/Permissions.d.ts +2 -4
  211. package/lib/structures/extra/Permissions.js +1 -17
  212. package/lib/types/payloads/_interactions/responses.d.ts +2 -2
  213. package/lib/types/payloads/components.d.ts +4 -4
  214. package/lib/websocket/SharedTypes.d.ts +4 -4
  215. package/lib/websocket/constants/index.d.ts +1 -1
  216. package/lib/websocket/constants/index.js +3 -2
  217. package/lib/websocket/discord/events/memberUpdate.js +2 -2
  218. package/lib/websocket/discord/heartbeater.d.ts +1 -0
  219. package/lib/websocket/discord/heartbeater.js +7 -0
  220. package/lib/websocket/discord/shard.d.ts +2 -2
  221. package/lib/websocket/discord/shard.js +15 -13
  222. package/lib/websocket/discord/sharder.d.ts +8 -7
  223. package/lib/websocket/discord/sharder.js +25 -5
  224. package/lib/websocket/discord/shared.d.ts +19 -6
  225. package/lib/websocket/discord/socket/custom.js +5 -0
  226. package/lib/websocket/discord/worker.d.ts +1 -0
  227. package/lib/websocket/discord/worker.js +2 -0
  228. package/lib/websocket/discord/workermanager.d.ts +25 -11
  229. package/lib/websocket/discord/workermanager.js +41 -10
  230. package/package.json +12 -16
@@ -38,39 +38,39 @@ export type WebhookStructure = InferCustomStructure<Webhook, 'Webhook'>;
38
38
  export type OptionResolverStructure = InferCustomStructure<OptionResolver, 'OptionResolver'>;
39
39
  export type EntitlementStructure = InferCustomStructure<Entitlement, 'Entitlement'>;
40
40
  export declare const Transformers: {
41
- Application(client: import("../commands").UsingClient, data: import("../types").APIApplication): ApplicationStructure;
42
- ApplicationEmoji(client: import("../commands").UsingClient, data: import("../types").APIApplicationEmoji): ApplicationEmojiStructure;
43
- AnonymousGuild(client: import("../commands").UsingClient, data: import("../types").APIPartialGuild): AnonymousGuildStructure;
44
- AutoModerationRule(client: import("../commands").UsingClient, data: import("../types").APIAutoModerationRule): AutoModerationRuleStructure;
45
- BaseChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): BaseChannelStructure;
46
- BaseGuildChannel(client: import("../commands").UsingClient, data: import("../types").APIGuildChannel<ChannelType>): BaseGuildChannelStructure;
47
- TextGuildChannel(client: import("../commands").UsingClient, data: import("../types").APIGuildChannel<ChannelType>): TextGuildChannelStructure;
48
- DMChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): DMChannelStructure;
49
- VoiceChannel(client: import("../commands").UsingClient, data: import("../types").APIGuildChannel<ChannelType>): VoiceChannelStructure;
50
- StageChannel(client: import("../commands").UsingClient, data: import("../types").APIGuildChannel<ChannelType>): StageChannelStructure;
51
- MediaChannel(client: import("../commands").UsingClient, data: import("../types").APIGuildChannel<ChannelType>): MediaChannelStructure;
52
- ForumChannel(client: import("../commands").UsingClient, data: import("../types").APIGuildChannel<ChannelType>): ForumChannelStructure;
53
- ThreadChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): ThreadChannelStructure;
41
+ Application(client: import("..").UsingClient, data: import("..").APIApplication): ApplicationStructure;
42
+ ApplicationEmoji(client: import("..").UsingClient, data: import("..").APIApplicationEmoji): ApplicationEmojiStructure;
43
+ AnonymousGuild(client: import("..").UsingClient, data: import("..").APIPartialGuild): AnonymousGuildStructure;
44
+ AutoModerationRule(client: import("..").UsingClient, data: import("..").APIAutoModerationRule): AutoModerationRuleStructure;
45
+ BaseChannel(client: import("..").UsingClient, data: import("..").APIChannelBase<ChannelType>): BaseChannelStructure;
46
+ BaseGuildChannel(client: import("..").UsingClient, data: import("..").APIGuildChannel<ChannelType>): BaseGuildChannelStructure;
47
+ TextGuildChannel(client: import("..").UsingClient, data: import("..").APIGuildChannel<ChannelType>): TextGuildChannelStructure;
48
+ DMChannel(client: import("..").UsingClient, data: import("..").APIChannelBase<ChannelType>): DMChannelStructure;
49
+ VoiceChannel(client: import("..").UsingClient, data: import("..").APIGuildChannel<ChannelType>): VoiceChannelStructure;
50
+ StageChannel(client: import("..").UsingClient, data: import("..").APIGuildChannel<ChannelType>): StageChannelStructure;
51
+ MediaChannel(client: import("..").UsingClient, data: import("..").APIGuildChannel<ChannelType>): MediaChannelStructure;
52
+ ForumChannel(client: import("..").UsingClient, data: import("..").APIGuildChannel<ChannelType>): ForumChannelStructure;
53
+ ThreadChannel(client: import("..").UsingClient, data: import("..").APIChannelBase<ChannelType>): ThreadChannelStructure;
54
54
  CategoryChannel(...args: ConstructorParameters<typeof CategoryChannel>): CategoryChannelStructure;
55
- NewsChannel(client: import("../commands").UsingClient, data: import("../types").APIGuildChannel<ChannelType>): NewsChannelStructure;
56
- DirectoryChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): DirectoryChannelStructure;
57
- ClientUser(client: import("../commands").UsingClient, data: import("../types").APIUser, application: Pick<import("../types").APIApplication, "id" | "flags">): ClientUserStructure;
58
- Guild<State extends StructStates = "api">(client: import("../commands").UsingClient, data: import("../types").APIGuild | import("../types").GatewayGuildCreateDispatchData): GuildStructure<State>;
59
- GuildBan(client: import("../commands").UsingClient, data: import("../types").APIBan | import("../types").ActuallyBan, guildId: string): GuildBanStructure;
60
- Emoji(client: import("../commands").UsingClient, data: import("../types").APIEmoji): EmojiStructure;
61
- GuildEmoji(client: import("../commands").UsingClient, data: import("../types").APIEmoji, guildId: string): GuildEmojiStructure;
62
- GuildMember(client: import("../commands").UsingClient, data: import("../structures").GuildMemberData, user: import("../types").APIUser, guildId: string): GuildMemberStructure;
63
- InteractionGuildMember(client: import("../commands").UsingClient, data: import("../types").APIInteractionDataResolvedGuildMember, user: import("../types").APIUser, guildId: string): InteractionGuildMemberStructure;
64
- GuildRole(client: import("../commands").UsingClient, data: import("../types").APIRole, guildId: string): GuildRoleStructure;
65
- GuildTemplate(client: import("../commands").UsingClient, data: import("../types").APITemplate): GuildTemplateStructure;
66
- Message(client: import("../commands").UsingClient, data: import("../structures").MessageData): MessageStructure;
67
- WebhookMessage(client: import("../commands").UsingClient, data: import("../structures").MessageData, webhookId: string, webhookToken: string): WebhookMessageStructure;
68
- Poll(client: import("../commands").UsingClient, data: import("../types").APIPoll, channelId: string, messageId: string): PollStructure;
69
- Sticker(client: import("../commands").UsingClient, data: import("../types").APISticker): StickerStructure;
70
- User(client: import("../commands").UsingClient, data: import("../types").APIUser): UserStructure;
71
- VoiceState(client: import("../commands").UsingClient, data: import("../types").APIVoiceState): VoiceStateStructure;
72
- Webhook(client: import("../commands").UsingClient, data: import("../types").APIWebhook): WebhookStructure;
73
- OptionResolver(client: import("../commands").UsingClient, options: import("../types").APIApplicationCommandInteractionDataOption[], parent?: import("../commands").Command | undefined, guildId?: string | undefined, resolved?: import("../commands").ContextOptionsResolved | undefined): OptionResolverStructure;
74
- Entitlement(client: import("../commands").UsingClient, data: import("../types").APIEntitlement): EntitlementStructure;
55
+ NewsChannel(client: import("..").UsingClient, data: import("..").APIGuildChannel<ChannelType>): NewsChannelStructure;
56
+ DirectoryChannel(client: import("..").UsingClient, data: import("..").APIChannelBase<ChannelType>): DirectoryChannelStructure;
57
+ ClientUser(client: import("..").UsingClient, data: import("..").APIUser, application: Pick<import("..").APIApplication, "id" | "flags">): ClientUserStructure;
58
+ Guild<State extends StructStates = "api">(client: import("..").UsingClient, data: import("..").APIGuild | import("..").GatewayGuildCreateDispatchData): GuildStructure<State>;
59
+ GuildBan(client: import("..").UsingClient, data: import("..").APIBan | import("..").ActuallyBan, guildId: string): GuildBanStructure;
60
+ Emoji(client: import("..").UsingClient, data: import("..").APIEmoji): EmojiStructure;
61
+ GuildEmoji(client: import("..").UsingClient, data: import("..").APIEmoji, guildId: string): GuildEmojiStructure;
62
+ GuildMember(client: import("..").UsingClient, data: import("..").GuildMemberData, user: import("..").APIUser, guildId: string): GuildMemberStructure;
63
+ InteractionGuildMember(client: import("..").UsingClient, data: import("..").APIInteractionDataResolvedGuildMember, user: import("..").APIUser, guildId: string): InteractionGuildMemberStructure;
64
+ GuildRole(client: import("..").UsingClient, data: import("..").APIRole, guildId: string): GuildRoleStructure;
65
+ GuildTemplate(client: import("..").UsingClient, data: import("..").APITemplate): GuildTemplateStructure;
66
+ Message(client: import("..").UsingClient, data: import("..").MessageData): MessageStructure;
67
+ WebhookMessage(client: import("..").UsingClient, data: import("..").MessageData, webhookId: string, webhookToken: string): WebhookMessageStructure;
68
+ Poll(client: import("..").UsingClient, data: import("..").APIPoll, channelId: string, messageId: string): PollStructure;
69
+ Sticker(client: import("..").UsingClient, data: import("..").APISticker): StickerStructure;
70
+ User(client: import("..").UsingClient, data: import("..").APIUser): UserStructure;
71
+ VoiceState(client: import("..").UsingClient, data: import("..").APIVoiceState): VoiceStateStructure;
72
+ Webhook(client: import("..").UsingClient, data: import("..").APIWebhook): WebhookStructure;
73
+ OptionResolver(client: import("..").UsingClient, options: import("..").APIApplicationCommandInteractionDataOption[], parent?: import("..").Command | undefined, guildId?: string | undefined, resolved?: import("..").ContextOptionsResolved | undefined): OptionResolverStructure;
74
+ Entitlement(client: import("..").UsingClient, data: import("..").APIEntitlement): EntitlementStructure;
75
75
  };
76
76
  export type InferCustomStructure<T, N extends string> = CustomStructures extends Record<N, infer P> ? P : T;
@@ -12,6 +12,7 @@ import type { BaseClientOptions, ServicesOptions, StartOptions } from './base';
12
12
  import { BaseClient } from './base';
13
13
  import type { Client, ClientOptions } from './client';
14
14
  import { Collectors } from './collectors';
15
+ import { type RegisteredPluginExtension } from './plugins';
15
16
  import { type ClientUserStructure } from './transformers';
16
17
  export declare class WorkerClient<Ready extends boolean = boolean> extends BaseClient {
17
18
  memberUpdateHandler: MemberUpdateHandler;
@@ -47,13 +48,21 @@ export declare class WorkerClient<Ready extends boolean = boolean> extends BaseC
47
48
  tellWorkers<R, V extends Record<string, unknown>>(func: (_: this, vars: V) => R, vars: V): Promise<Awaited<R>[]>;
48
49
  createShard(id: number, data: Pick<ManagerSpawnShards, 'info' | 'compress' | 'properties'>): Shard;
49
50
  resumeShard(shardId: number, shardData: MakeRequired<ShardData>): Promise<unknown>;
50
- protected onPacket(packet: GatewayDispatchPayload, shardId: number): Promise<void>;
51
+ protected onPacket(packet: GatewayDispatchPayload, shardId: number): Promise<GatewayDispatchPayload | null>;
52
+ }
53
+ export interface WorkerClient<Ready extends boolean = boolean> extends RegisteredPluginExtension {
51
54
  }
52
55
  export declare function generateShardInfo(shard: Shard): WorkerShardInfo;
53
56
  export interface WorkerClientOptions extends BaseClientOptions {
54
57
  commands?: NonNullable<Client['options']>['commands'];
55
58
  handlePayload?: ShardManagerOptions['handlePayload'];
59
+ /**
60
+ * @deprecated Use shard disconnect events instead. Injected ShardManager callbacks can double-fire.
61
+ */
56
62
  onShardDisconnect?: ShardManagerOptions['onShardDisconnect'];
63
+ /**
64
+ * @deprecated Use shard reconnect events instead. Injected ShardManager callbacks can double-fire.
65
+ */
57
66
  onShardReconnect?: ShardManagerOptions['onShardReconnect'];
58
67
  gateway?: ClientOptions['gateway'];
59
68
  postMessage?: (body: unknown) => Awaitable<unknown>;
@@ -13,6 +13,7 @@ const memberUpdate_1 = require("../websocket/discord/events/memberUpdate");
13
13
  const presenceUpdate_1 = require("../websocket/discord/events/presenceUpdate");
14
14
  const base_1 = require("./base");
15
15
  const collectors_1 = require("./collectors");
16
+ const plugins_1 = require("./plugins");
16
17
  const transformers_1 = require("./transformers");
17
18
  let workerData;
18
19
  let manager;
@@ -62,6 +63,8 @@ class WorkerClient extends base_1.BaseClient {
62
63
  return workerData.workerId;
63
64
  }
64
65
  get latency() {
66
+ if (this.shards.size <= 0)
67
+ return 0;
65
68
  let acc = 0;
66
69
  this.shards.forEach(s => (acc += s.latency));
67
70
  return acc / this.shards.size;
@@ -99,9 +102,7 @@ class WorkerClient extends base_1.BaseClient {
99
102
  }
100
103
  if (workerData.mode !== 'custom')
101
104
  (manager ?? process).on('message', (data) => this.handleManagerMessages(data));
102
- this.logger = new __1.Logger({
103
- name: `[Worker #${workerData.workerId}]`,
104
- });
105
+ this.configureLogger({ name: `[Worker #${workerData.workerId}]` }, this.options.logger);
105
106
  if (workerData.debug) {
106
107
  this.debugger = new __1.Logger({
107
108
  name: `[Worker #${workerData.workerId}]`,
@@ -117,21 +118,24 @@ class WorkerClient extends base_1.BaseClient {
117
118
  }),
118
119
  });
119
120
  }
120
- this.cache.intents = workerData.intents;
121
+ this.resolvePluginGatewayIntents(workerData.intents);
121
122
  this.rest.workerData = workerData;
123
+ await super.start(options);
124
+ workerData.intents = this.resolvePluginGatewayIntents(workerData.intents);
122
125
  this.postMessage({
123
126
  type: workerData.resharding ? 'WORKER_START_RESHARDING' : 'WORKER_START',
124
127
  workerId: workerData.workerId,
125
128
  });
126
- await super.start(options);
127
129
  await this.loadEvents(options.eventsDir);
128
130
  }
129
131
  async loadEvents(dir) {
130
132
  dir ??= await this.getRC().then(x => x.locations.events);
133
+ await (0, plugins_1.runPluginHooks)(this, 'events:beforeLoad', this, dir);
131
134
  if (dir) {
132
135
  await this.events.load(dir);
133
136
  this.logger.info('EventHandler loaded');
134
137
  }
138
+ await (0, plugins_1.runPluginHooks)(this, 'events:afterLoad', this, dir);
135
139
  }
136
140
  postMessage(body) {
137
141
  if (manager)
@@ -158,12 +162,13 @@ class WorkerClient extends base_1.BaseClient {
158
162
  {
159
163
  const shard = this.shards.get(data.shardId);
160
164
  if (!shard) {
161
- this.logger.fatal('Worker trying send payload by non-existent shard');
165
+ this.logger.fatal(`Worker trying to send payload by non-existent shard (#${data.shardId})`);
162
166
  return;
163
167
  }
164
- await shard.send(true, {
165
- ...data,
166
- });
168
+ const { nonce: _nonce, shardId: _shardId, type: _type, ...payload } = data;
169
+ const pluginPayload = await (0, plugins_1.applyPluginGatewaySendPayloadWrappers)(this, data.shardId, payload);
170
+ if (pluginPayload !== null)
171
+ await shard.send(true, pluginPayload);
167
172
  this.postMessage({
168
173
  type: 'RESULT_PAYLOAD',
169
174
  nonce: data.nonce,
@@ -175,7 +180,7 @@ class WorkerClient extends base_1.BaseClient {
175
180
  {
176
181
  const shard = this.resharding.get(data.shardId);
177
182
  if (!shard) {
178
- this.logger.fatal('Worker trying reshard non-existent shard');
183
+ this.logger.fatal(`Worker trying to reshard non-existent shard (#${data.shardId})`);
179
184
  return;
180
185
  }
181
186
  shard.options.presence = data.presence;
@@ -186,7 +191,7 @@ class WorkerClient extends base_1.BaseClient {
186
191
  {
187
192
  const shard = this.shards.get(data.shardId);
188
193
  if (!shard) {
189
- this.logger.fatal('Worker trying connect non-existent shard');
194
+ this.logger.fatal(`Worker trying to connect non-existent shard (#${data.shardId})`);
190
195
  return;
191
196
  }
192
197
  shard.options.presence = data.presence;
@@ -257,7 +262,7 @@ class WorkerClient extends base_1.BaseClient {
257
262
  {
258
263
  const shard = this.shards.get(data.shardId);
259
264
  if (!shard) {
260
- this.logger.fatal('Worker trying get non-existent shard');
265
+ this.logger.fatal(`Worker trying to get non-existent shard (#${data.shardId})`);
261
266
  return;
262
267
  }
263
268
  this.postMessage({
@@ -415,13 +420,13 @@ class WorkerClient extends base_1.BaseClient {
415
420
  },
416
421
  async handlePayload(shardId, payload) {
417
422
  await handlePayload?.(shardId, payload);
418
- await onPacket(payload, shardId);
419
- if (self.options.sendPayloadToParent)
423
+ const pluginPacket = await onPacket(payload, shardId);
424
+ if (self.options.sendPayloadToParent && pluginPacket !== null)
420
425
  self.postMessage({
421
426
  workerId: workerData.workerId,
422
427
  shardId,
423
428
  type: 'RECEIVE_PAYLOAD',
424
- payload,
429
+ payload: pluginPacket,
425
430
  });
426
431
  },
427
432
  });
@@ -448,6 +453,10 @@ class WorkerClient extends base_1.BaseClient {
448
453
  });
449
454
  }
450
455
  async onPacket(packet, shardId) {
456
+ const pluginPacket = await (0, plugins_1.applyPluginGatewayDispatchInterceptors)(this, shardId, packet);
457
+ if (pluginPacket === null)
458
+ return null;
459
+ packet = pluginPacket;
451
460
  Promise.allSettled([
452
461
  this.events.runEvent('RAW', this, packet, shardId, false),
453
462
  this.collectors.run('RAW', packet, this),
@@ -456,7 +465,7 @@ class WorkerClient extends base_1.BaseClient {
456
465
  case 'GUILD_MEMBER_UPDATE':
457
466
  {
458
467
  if (!this.memberUpdateHandler.check(packet.d)) {
459
- return;
468
+ return packet;
460
469
  }
461
470
  await this.events.execute(packet, this, shardId);
462
471
  }
@@ -464,7 +473,7 @@ class WorkerClient extends base_1.BaseClient {
464
473
  case 'PRESENCE_UPDATE':
465
474
  {
466
475
  if (!this.presenceUpdateHandler.check(packet.d)) {
467
- return;
476
+ return packet;
468
477
  }
469
478
  await this.events.execute(packet, this, shardId);
470
479
  }
@@ -517,6 +526,7 @@ class WorkerClient extends base_1.BaseClient {
517
526
  break;
518
527
  }
519
528
  }
529
+ return packet;
520
530
  }
521
531
  }
522
532
  exports.WorkerClient = WorkerClient;
@@ -46,7 +46,10 @@ export declare class Collection<K, V> extends Map<K, V> {
46
46
  * const filteredArray = collection.filter((value, key) => key % 2 === 0);
47
47
  * console.log(filteredArray); // Output: ['two']
48
48
  */
49
+ filter<S extends V>(fn: (value: V, key: K, collection: this) => value is S): S[];
49
50
  filter(fn: (value: V, key: K, collection: this) => boolean): V[];
51
+ filterCollection<S extends V>(fn: (value: V, key: K, collection: this) => value is S): Collection<K, S>;
52
+ filterCollection(fn: (value: V, key: K, collection: this) => boolean): Collection<K, V>;
50
53
  /**
51
54
  * Apply a function against an accumulator and each element in the collection (from left to right) to reduce it to a single value.
52
55
  * @param fn The function to execute on each element in the collection.
@@ -99,6 +102,7 @@ export declare class Collection<K, V> extends Map<K, V> {
99
102
  * const firstEvenValue = collection.find(value => value % 2 === 0);
100
103
  * console.log(firstEvenValue); // Output: 2
101
104
  */
105
+ find<S extends V>(fn: (value: V, key: K, collection: this) => value is S): S | undefined;
102
106
  find(fn: (value: V, key: K, collection: this) => boolean): V | undefined;
103
107
  /**
104
108
  * Returns the first key in the collection that satisfies the provided testing function.
@@ -114,7 +118,7 @@ export declare class Collection<K, V> extends Map<K, V> {
114
118
  */
115
119
  findKey(fn: (value: V, key: K, collection: this) => boolean): K | undefined;
116
120
  }
117
- type LimitedCollectionData<V> = {
121
+ export type LimitedCollectionData<V> = {
118
122
  expire: number;
119
123
  expireOn: number;
120
124
  value: V;
@@ -242,13 +246,11 @@ export declare class LimitedCollection<K, V> {
242
246
  private stopTimeout;
243
247
  private startTimeout;
244
248
  keys(): MapIterator<K>;
245
- values(): Generator<{
246
- value: V;
247
- expire: number;
248
- expireOn: number;
249
- }, void, unknown>;
250
- entries(): Generator<[K, LimitedCollectionData<V>], void, unknown>;
249
+ values(): IterableIterator<V>;
250
+ rawValues(): IterableIterator<LimitedCollectionData<V>>;
251
+ entries(): IterableIterator<[K, V]>;
252
+ rawEntries(): IterableIterator<[K, LimitedCollectionData<V>]>;
253
+ [Symbol.iterator](): IterableIterator<[K, V]>;
251
254
  clear(): void;
252
255
  private clearExpired;
253
256
  }
254
- export {};
package/lib/collection.js CHANGED
@@ -50,19 +50,6 @@ class Collection extends Map {
50
50
  }
51
51
  return result;
52
52
  }
53
- /**
54
- * Creates a new array with all elements that pass the test implemented by the provided function.
55
- * @param fn The function to test each element of the collection.
56
- * @param thisArg The value to use as `this` when executing the filter function.
57
- * @returns A new array with the elements that pass the test.
58
- * @example
59
- * const collection = new Collection<number, string>();
60
- * collection.set(1, 'one');
61
- * collection.set(2, 'two');
62
- * collection.set(3, 'three');
63
- * const filteredArray = collection.filter((value, key) => key % 2 === 0);
64
- * console.log(filteredArray); // Output: ['two']
65
- */
66
53
  filter(fn) {
67
54
  const result = [];
68
55
  for (const [key, value] of this.entries()) {
@@ -71,6 +58,14 @@ class Collection extends Map {
71
58
  }
72
59
  return result;
73
60
  }
61
+ filterCollection(fn) {
62
+ const result = new Collection();
63
+ for (const [key, value] of this.entries()) {
64
+ if (fn(value, key, this))
65
+ result.set(key, value);
66
+ }
67
+ return result;
68
+ }
74
69
  /**
75
70
  * Apply a function against an accumulator and each element in the collection (from left to right) to reduce it to a single value.
76
71
  * @param fn The function to execute on each element in the collection.
@@ -141,18 +136,6 @@ class Collection extends Map {
141
136
  }
142
137
  return false;
143
138
  }
144
- /**
145
- * Returns the value of the first element in the collection that satisfies the provided testing function.
146
- * @param fn The function to test each element of the collection.
147
- * @returns The value of the first element that passes the test. `undefined` if no element passes the test.
148
- * @example
149
- * const collection = new Collection<number, number>();
150
- * collection.set(1, 1);
151
- * collection.set(2, 2);
152
- * collection.set(3, 3);
153
- * const firstEvenValue = collection.find(value => value % 2 === 0);
154
- * console.log(firstEvenValue); // Output: 2
155
- */
156
139
  find(fn) {
157
140
  for (const [key, value] of this.entries()) {
158
141
  if (fn(value, key, this)) {
@@ -210,6 +193,8 @@ class LimitedCollection {
210
193
  _closerDirty = true;
211
194
  constructor(options = {}) {
212
195
  this.options = (0, common_1.MergeOptions)(LimitedCollection.default, options);
196
+ if (Number.isNaN(this.options.limit))
197
+ throw new TypeError('LimitedCollection limit cannot be NaN');
213
198
  }
214
199
  /**
215
200
  * Adds an element to the limited collection.
@@ -435,6 +420,9 @@ class LimitedCollection {
435
420
  return this.data.keys();
436
421
  }
437
422
  values() {
423
+ return this.data.values();
424
+ }
425
+ rawValues() {
438
426
  return (function* (self) {
439
427
  for (const key of self.data.keys()) {
440
428
  yield self.raw(key);
@@ -442,12 +430,18 @@ class LimitedCollection {
442
430
  })(this);
443
431
  }
444
432
  entries() {
433
+ return this.data.entries();
434
+ }
435
+ rawEntries() {
445
436
  return (function* (self) {
446
437
  for (const key of self.data.keys()) {
447
438
  yield [key, self.raw(key)];
448
439
  }
449
440
  })(this);
450
441
  }
442
+ [Symbol.iterator]() {
443
+ return this.entries();
444
+ }
451
445
  clear() {
452
446
  this.data.clear();
453
447
  this.expirations.clear();
@@ -1,27 +1,28 @@
1
1
  import type { PermissionStrings, SeyfertBaseChoiceableOption, SeyfertBasicOption, SeyfertChoice } from '../..';
2
2
  import type { Attachment } from '../../builders';
3
+ import type { PluginMiddlewareDenialMetadata } from '../../client/plugins/types';
3
4
  import type { GuildMemberStructure, GuildRoleStructure, InteractionGuildMemberStructure, UserStructure } from '../../client/transformers';
4
5
  import type { AllChannels, AutocompleteInteraction } from '../../structures';
5
6
  import { type APIApplicationCommandBasicOption, type APIApplicationCommandOption, ApplicationCommandOptionType, ApplicationCommandType, type ApplicationIntegrationType, type InteractionContextType, type LocaleString } from '../../types';
6
- import type { Groups, RegisteredMiddlewares } from '../decorators';
7
+ import type { Groups, ResolvedRegisteredMiddlewares } from '../decorators';
7
8
  import type { CommandOptionWithType } from '../handle';
8
9
  import type { CommandContext } from './chatcontext';
9
10
  import type { ExtraProps, IgnoreCommand, OnOptionsReturnObject, SeyfertChannelMap, UsingClient } from './shared';
10
11
  export interface ReturnOptionsTypes {
11
- 1: never;
12
- 2: never;
13
- 3: string;
14
- 4: number;
15
- 5: boolean;
16
- 6: InteractionGuildMemberStructure | UserStructure;
17
- 7: AllChannels;
18
- 8: GuildRoleStructure;
19
- 9: GuildRoleStructure | InteractionGuildMemberStructure | GuildMemberStructure | UserStructure;
20
- 10: number;
21
- 11: Attachment;
12
+ [ApplicationCommandOptionType.Subcommand]: never;
13
+ [ApplicationCommandOptionType.SubcommandGroup]: never;
14
+ [ApplicationCommandOptionType.String]: string;
15
+ [ApplicationCommandOptionType.Integer]: number;
16
+ [ApplicationCommandOptionType.Boolean]: boolean;
17
+ [ApplicationCommandOptionType.User]: InteractionGuildMemberStructure | UserStructure;
18
+ [ApplicationCommandOptionType.Channel]: AllChannels;
19
+ [ApplicationCommandOptionType.Role]: GuildRoleStructure;
20
+ [ApplicationCommandOptionType.Mentionable]: GuildRoleStructure | InteractionGuildMemberStructure | GuildMemberStructure | UserStructure;
21
+ [ApplicationCommandOptionType.Number]: number;
22
+ [ApplicationCommandOptionType.Attachment]: Attachment;
22
23
  }
23
- export type AutocompleteCallback = (interaction: AutocompleteInteraction) => any;
24
- export type OnAutocompleteErrorCallback = (interaction: AutocompleteInteraction, error: unknown) => any;
24
+ export type AutocompleteCallback<ValueType extends string | number = string | number> = (interaction: AutocompleteInteraction<boolean, ValueType>) => any;
25
+ export type OnAutocompleteErrorCallback<ValueType extends string | number = string | number> = (interaction: AutocompleteInteraction<boolean, ValueType>, error: unknown) => any;
25
26
  export type CommandBaseOption = SeyfertBaseChoiceableOption<ApplicationCommandOptionType> | SeyfertBasicOption<ApplicationCommandOptionType>;
26
27
  export type CommandBaseAutocompleteOption = (SeyfertBasicOption<ApplicationCommandOptionType> | SeyfertBaseChoiceableOption<ApplicationCommandOptionType>) & {
27
28
  autocomplete: AutocompleteCallback;
@@ -44,9 +45,9 @@ type ContextOptionsAuxInternal<T extends CommandBaseOption & {
44
45
  type: ApplicationCommandOptionType;
45
46
  }> = T['value'] extends (...args: any) => any ? Parameters<Parameters<T['value']>[1]>[0] : NonNullable<T['value']> extends (...args: any) => any ? Parameters<Parameters<NonNullable<T['value']>>[1]>[0] extends never ? T extends {
46
47
  channel_types?: infer C;
47
- } ? C extends any[] ? C[number] extends keyof SeyfertChannelMap ? SeyfertChannelMap[C[number]] : never : never : T extends {
48
+ } ? C extends readonly any[] ? C[number] extends keyof SeyfertChannelMap ? SeyfertChannelMap[C[number]] : never : never : T extends {
48
49
  choices?: infer C;
49
- } ? C extends SeyfertChoice<string | number>[] ? C[number]['value'] : never : never : Parameters<Parameters<NonNullable<T['value']>>[1]>[0] : ReturnOptionsTypes[T['type']];
50
+ } ? C extends readonly SeyfertChoice<string | number>[] ? C[number]['value'] : never : never : Parameters<Parameters<NonNullable<T['value']>>[1]>[0] : ReturnOptionsTypes[T['type']];
50
51
  type ContextOptionsAux<T extends OptionsRecord> = {
51
52
  [K in Exclude<keyof T, KeysWithoutRequired<T>>]: ContextOptionsAuxInternal<T[K]>;
52
53
  } & {
@@ -54,7 +55,7 @@ type ContextOptionsAux<T extends OptionsRecord> = {
54
55
  };
55
56
  export type ContextOptions<T extends OptionsRecord> = ContextOptionsAux<T>;
56
57
  export declare class BaseCommand {
57
- middlewares: (keyof RegisteredMiddlewares)[];
58
+ middlewares: readonly (keyof ResolvedRegisteredMiddlewares)[];
58
59
  __filePath?: string;
59
60
  __t?: {
60
61
  name: string | undefined;
@@ -76,6 +77,7 @@ export declare class BaseCommand {
76
77
  ignore?: IgnoreCommand;
77
78
  aliases?: string[];
78
79
  props: ExtraProps;
80
+ private static __getMiddlewareOwnerName;
79
81
  toJSON(): {
80
82
  name: BaseCommand["name"];
81
83
  type: BaseCommand["type"];
@@ -95,7 +97,7 @@ export declare class BaseCommand {
95
97
  onAfterRun?(context: CommandContext, error: unknown | undefined): any;
96
98
  onRunError?(context: CommandContext, error: unknown): any;
97
99
  onOptionsError?(context: CommandContext, metadata: OnOptionsReturnObject): any;
98
- onMiddlewaresError?(context: CommandContext, error: string): any;
100
+ onMiddlewaresError?(context: CommandContext, error: string, metadata: PluginMiddlewareDenialMetadata): any;
99
101
  onBotPermissionsFail?(context: CommandContext, permissions: PermissionStrings): any;
100
102
  onPermissionsFail?(context: CommandContext, permissions: PermissionStrings): any;
101
103
  onInternalError?(client: UsingClient, command: Command | SubCommand, error?: unknown): any;
@@ -79,39 +79,56 @@ class BaseCommand {
79
79
  if (!middlewares.length) {
80
80
  return Promise.resolve({});
81
81
  }
82
+ const missingMiddlewares = middlewares.filter(middleware => !context.client.middlewares?.[middleware]);
83
+ if (missingMiddlewares.length) {
84
+ const owner = BaseCommand.__getMiddlewareOwnerName(context);
85
+ const message = `${owner} has ${global ? 'global ' : ''}middleware${missingMiddlewares.length === 1 ? '' : 's'} ${missingMiddlewares
86
+ .map(middleware => `"${String(middleware)}"`)
87
+ .join(', ')} assigned, but ${missingMiddlewares.length === 1 ? 'it is' : 'they are'} not registered.`;
88
+ context.client.logger.warn(message);
89
+ }
90
+ const activeMiddlewares = middlewares.filter(middleware => context.client.middlewares?.[middleware]);
91
+ if (!activeMiddlewares.length)
92
+ return Promise.resolve({});
82
93
  let index = 0;
83
94
  return new Promise((res, rej) => {
84
95
  let running = true;
85
- const pass = () => {
86
- if (!running) {
87
- return;
88
- }
89
- running = false;
90
- return res({ pass: true });
91
- };
92
96
  function next(...args) {
93
97
  if (!running) {
94
98
  return;
95
99
  }
96
100
  if (args.length) {
97
- context[global ? 'globalMetadata' : 'metadata'][middlewares[index]] = args[0];
101
+ context[global ? 'globalMetadata' : 'metadata'][activeMiddlewares[index]] = args[0];
98
102
  }
99
- if (++index >= middlewares.length) {
103
+ if (++index >= activeMiddlewares.length) {
100
104
  running = false;
101
105
  return res({});
102
106
  }
103
- void invoke(middlewares[index]);
107
+ void invoke(activeMiddlewares[index]);
104
108
  }
105
- const stop = err => {
109
+ const deny = (err, middleware) => {
106
110
  if (!running) {
107
111
  return;
108
112
  }
109
113
  running = false;
110
- return res({ error: err });
114
+ return res({
115
+ error: err,
116
+ metadata: { middleware: String(middleware), scope: global ? 'global' : 'command' },
117
+ });
118
+ };
119
+ const stop = err => {
120
+ if (err == null) {
121
+ if (!running) {
122
+ return;
123
+ }
124
+ running = false;
125
+ return res({ pass: true });
126
+ }
127
+ return deny(err, activeMiddlewares[index]);
111
128
  };
112
129
  async function invoke(middleware) {
113
130
  try {
114
- await context.client.middlewares[middleware]({ context, next, stop, pass });
131
+ await context.client.middlewares[middleware]({ context, next, stop });
115
132
  }
116
133
  catch (err) {
117
134
  if (!running) {
@@ -121,9 +138,17 @@ class BaseCommand {
121
138
  rej(err);
122
139
  }
123
140
  }
124
- void invoke(middlewares[0]);
141
+ void invoke(activeMiddlewares[0]);
125
142
  });
126
143
  }
144
+ static __getMiddlewareOwnerName(context) {
145
+ const command = context.command;
146
+ if (command?.name)
147
+ return `Command "${command.name}"`;
148
+ if (typeof command?.customId === 'string')
149
+ return `Component "${command.customId}"`;
150
+ return 'Command';
151
+ }
127
152
  /** @internal */
128
153
  __runMiddlewares(context) {
129
154
  return BaseCommand.__runMiddlewares(context, this.middlewares, false);