seyfert 1.5.0 → 2.1.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.
- package/LICENSE +21 -190
- package/README.md +18 -10
- package/lib/api/Router.js +2 -2
- package/lib/api/Routes/applications.d.ts +23 -1
- package/lib/api/Routes/channels.d.ts +1 -1
- package/lib/api/Routes/gateway.d.ts +1 -1
- package/lib/api/Routes/guilds.d.ts +5 -2
- package/lib/api/Routes/interactions.d.ts +8 -2
- package/lib/api/Routes/invites.d.ts +1 -1
- package/lib/api/Routes/skus.d.ts +11 -0
- package/lib/api/Routes/skus.js +2 -0
- package/lib/api/Routes/stage-instances.d.ts +1 -1
- package/lib/api/Routes/stickers.d.ts +2 -2
- package/lib/api/Routes/users.d.ts +1 -1
- package/lib/api/Routes/voice.d.ts +1 -1
- package/lib/api/Routes/webhooks.d.ts +2 -2
- package/lib/api/api.d.ts +3 -3
- package/lib/api/api.js +15 -25
- package/lib/api/bucket.d.ts +0 -1
- package/lib/api/shared.d.ts +1 -2
- package/lib/api/utils/constants.d.ts +2 -5
- package/lib/api/utils/constants.js +3 -7
- package/lib/api/utils/utils.d.ts +1 -2
- package/lib/api/utils/utils.js +2 -3
- package/lib/builders/ActionRow.d.ts +1 -1
- package/lib/builders/ActionRow.js +3 -3
- package/lib/builders/Attachment.d.ts +3 -4
- package/lib/builders/Attachment.js +24 -25
- package/lib/builders/Base.d.ts +2 -2
- package/lib/builders/Base.js +1 -1
- package/lib/builders/Button.d.ts +7 -7
- package/lib/builders/Button.js +11 -9
- package/lib/builders/Embed.d.ts +1 -1
- package/lib/builders/Modal.d.ts +1 -1
- package/lib/builders/Modal.js +2 -2
- package/lib/builders/Poll.d.ts +2 -2
- package/lib/builders/Poll.js +5 -6
- package/lib/builders/SelectMenu.d.ts +1 -1
- package/lib/builders/SelectMenu.js +17 -18
- package/lib/builders/index.d.ts +1 -1
- package/lib/builders/index.js +10 -11
- package/lib/cache/adapters/default.d.ts +16 -9
- package/lib/cache/adapters/default.js +42 -31
- package/lib/cache/adapters/index.d.ts +0 -1
- package/lib/cache/adapters/index.js +0 -1
- package/lib/cache/adapters/limited.d.ts +17 -12
- package/lib/cache/adapters/limited.js +80 -36
- package/lib/cache/adapters/types.d.ts +6 -7
- package/lib/cache/adapters/workeradapter.d.ts +6 -6
- package/lib/cache/adapters/workeradapter.js +13 -0
- package/lib/cache/index.d.ts +20 -8
- package/lib/cache/index.js +328 -22
- package/lib/cache/resources/bans.d.ts +9 -6
- package/lib/cache/resources/bans.js +13 -4
- package/lib/cache/resources/channels.d.ts +6 -4
- package/lib/cache/resources/channels.js +13 -7
- package/lib/cache/resources/default/base.d.ts +7 -7
- package/lib/cache/resources/default/base.js +2 -2
- package/lib/cache/resources/default/guild-based.d.ts +6 -6
- package/lib/cache/resources/default/guild-based.js +6 -6
- package/lib/cache/resources/default/guild-related.d.ts +7 -7
- package/lib/cache/resources/default/guild-related.js +10 -8
- package/lib/cache/resources/emojis.d.ts +15 -6
- package/lib/cache/resources/emojis.js +13 -4
- package/lib/cache/resources/guilds.d.ts +9 -6
- package/lib/cache/resources/guilds.js +27 -6
- package/lib/cache/resources/members.d.ts +9 -6
- package/lib/cache/resources/members.js +22 -6
- package/lib/cache/resources/messages.d.ts +11 -7
- package/lib/cache/resources/messages.js +19 -7
- package/lib/cache/resources/overwrites.d.ts +11 -2
- package/lib/cache/resources/overwrites.js +9 -0
- package/lib/cache/resources/presence.d.ts +3 -2
- package/lib/cache/resources/roles.d.ts +9 -6
- package/lib/cache/resources/roles.js +13 -4
- package/lib/cache/resources/stage-instances.d.ts +2 -2
- package/lib/cache/resources/stickers.d.ts +9 -6
- package/lib/cache/resources/stickers.js +13 -4
- package/lib/cache/resources/threads.d.ts +9 -6
- package/lib/cache/resources/threads.js +13 -4
- package/lib/cache/resources/users.d.ts +9 -6
- package/lib/cache/resources/users.js +13 -4
- package/lib/cache/resources/voice-states.d.ts +11 -8
- package/lib/cache/resources/voice-states.js +15 -4
- package/lib/client/base.d.ts +29 -21
- package/lib/client/base.js +64 -57
- package/lib/client/client.d.ts +11 -16
- package/lib/client/client.js +51 -37
- package/lib/client/collectors.d.ts +10 -10
- package/lib/client/collectors.js +26 -1
- package/lib/client/httpclient.d.ts +8 -13
- package/lib/client/httpclient.js +27 -218
- package/lib/client/index.d.ts +1 -0
- package/lib/client/index.js +1 -0
- package/lib/client/transformers.d.ts +68 -0
- package/lib/client/transformers.js +99 -0
- package/lib/client/types.d.ts +5 -0
- package/lib/client/types.js +2 -0
- package/lib/client/workerclient.d.ts +16 -15
- package/lib/client/workerclient.js +130 -72
- package/lib/commands/applications/chat.d.ts +35 -34
- package/lib/commands/applications/chat.js +5 -9
- package/lib/commands/applications/chatcontext.d.ts +17 -17
- package/lib/commands/applications/chatcontext.js +5 -5
- package/lib/commands/applications/entryPoint.d.ts +46 -0
- package/lib/commands/applications/entryPoint.js +56 -0
- package/lib/commands/applications/entrycontext.d.ts +40 -0
- package/lib/commands/applications/entrycontext.js +85 -0
- package/lib/commands/applications/menu.d.ts +2 -3
- package/lib/commands/applications/menu.js +2 -5
- package/lib/commands/applications/menucontext.d.ts +14 -13
- package/lib/commands/applications/menucontext.js +9 -9
- package/lib/commands/applications/options.d.ts +4 -3
- package/lib/commands/applications/options.js +20 -21
- package/lib/commands/applications/shared.d.ts +3 -1
- package/lib/commands/decorators.d.ts +47 -35
- package/lib/commands/decorators.js +20 -18
- package/lib/commands/handle.d.ts +65 -0
- package/lib/commands/handle.js +727 -0
- package/lib/commands/handler.d.ts +29 -18
- package/lib/commands/handler.js +295 -164
- package/lib/commands/index.d.ts +2 -0
- package/lib/commands/index.js +2 -0
- package/lib/commands/optionresolver.d.ts +13 -13
- package/lib/commands/optionresolver.js +24 -29
- package/lib/common/bot/watcher.d.ts +4 -33
- package/lib/common/bot/watcher.js +0 -109
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.js +1 -0
- package/lib/common/it/colors.js +48 -49
- package/lib/common/it/formatter.d.ts +32 -0
- package/lib/common/it/formatter.js +42 -0
- package/lib/common/it/logger.d.ts +0 -1
- package/lib/common/it/logger.js +3 -3
- package/lib/common/it/utils.d.ts +24 -4
- package/lib/common/it/utils.js +88 -17
- package/lib/common/shorters/application.d.ts +56 -0
- package/lib/common/shorters/application.js +81 -0
- package/lib/common/shorters/bans.d.ts +4 -5
- package/lib/common/shorters/bans.js +3 -3
- package/lib/common/shorters/channels.d.ts +7 -6
- package/lib/common/shorters/channels.js +19 -15
- package/lib/common/shorters/emojis.d.ts +5 -6
- package/lib/common/shorters/emojis.js +5 -5
- package/lib/common/shorters/guilds.d.ts +18 -16
- package/lib/common/shorters/guilds.js +31 -26
- package/lib/common/shorters/interaction.d.ts +7 -7
- package/lib/common/shorters/interaction.js +3 -2
- package/lib/common/shorters/members.d.ts +29 -12
- package/lib/common/shorters/members.js +55 -16
- package/lib/common/shorters/messages.d.ts +7 -8
- package/lib/common/shorters/messages.js +8 -7
- package/lib/common/shorters/reactions.d.ts +3 -3
- package/lib/common/shorters/reactions.js +11 -11
- package/lib/common/shorters/roles.d.ts +9 -7
- package/lib/common/shorters/roles.js +26 -7
- package/lib/common/shorters/templates.d.ts +7 -8
- package/lib/common/shorters/templates.js +7 -7
- package/lib/common/shorters/threads.d.ts +6 -7
- package/lib/common/shorters/threads.js +6 -9
- package/lib/common/shorters/users.d.ts +4 -4
- package/lib/common/shorters/users.js +8 -4
- package/lib/common/shorters/webhook.d.ts +10 -10
- package/lib/common/shorters/webhook.js +10 -9
- package/lib/common/types/resolvables.d.ts +2 -2
- package/lib/common/types/util.d.ts +4 -2
- package/lib/common/types/write.d.ts +3 -3
- package/lib/components/ActionRow.d.ts +1 -1
- package/lib/components/BaseComponent.d.ts +1 -1
- package/lib/components/BaseComponent.js +1 -1
- package/lib/components/BaseSelectMenuComponent.d.ts +1 -1
- package/lib/components/ButtonComponent.d.ts +17 -7
- package/lib/components/ButtonComponent.js +19 -2
- package/lib/components/ChannelSelectMenuComponent.d.ts +3 -3
- package/lib/components/MentionableSelectMenuComponent.d.ts +2 -2
- package/lib/components/RoleSelectMenuComponent.d.ts +2 -2
- package/lib/components/StringSelectMenuComponent.d.ts +2 -2
- package/lib/components/TextInputComponent.d.ts +2 -2
- package/lib/components/UserSelectMenuComponent.d.ts +2 -2
- package/lib/components/componentcommand.js +2 -2
- package/lib/components/componentcontext.d.ts +10 -9
- package/lib/components/componentcontext.js +8 -8
- package/lib/components/handler.d.ts +15 -14
- package/lib/components/handler.js +89 -93
- package/lib/components/index.d.ts +3 -3
- package/lib/components/index.js +12 -10
- package/lib/components/modalcontext.d.ts +12 -11
- package/lib/components/modalcontext.js +2 -2
- package/lib/deps/mixer.d.ts +8 -0
- package/lib/deps/mixer.js +71 -0
- package/lib/events/handler.d.ts +35 -13
- package/lib/events/handler.js +57 -24
- package/lib/events/hooks/application_command.d.ts +2 -2
- package/lib/events/hooks/auto_moderation.d.ts +6 -7
- package/lib/events/hooks/auto_moderation.js +4 -4
- package/lib/events/hooks/channel.d.ts +2 -2
- package/lib/events/hooks/channel.js +4 -7
- package/lib/events/hooks/custom.d.ts +4 -3
- package/lib/events/hooks/custom.js +5 -1
- package/lib/events/hooks/dispatch.d.ts +3 -4
- package/lib/events/hooks/dispatch.js +2 -2
- package/lib/events/hooks/entitlement.d.ts +5 -37
- package/lib/events/hooks/entitlement.js +7 -7
- package/lib/events/hooks/guild.d.ts +125 -125
- package/lib/events/hooks/guild.js +13 -15
- package/lib/events/hooks/integration.d.ts +27 -28
- package/lib/events/hooks/integration.js +3 -3
- package/lib/events/hooks/interactions.d.ts +2 -2
- package/lib/events/hooks/invite.d.ts +18 -17
- package/lib/events/hooks/message.d.ts +69 -54
- package/lib/events/hooks/message.js +4 -8
- package/lib/events/hooks/presence.d.ts +17 -16
- package/lib/events/hooks/stage.d.ts +4 -4
- package/lib/events/hooks/subscriptions.d.ts +35 -0
- package/lib/events/hooks/subscriptions.js +16 -0
- package/lib/events/hooks/thread.d.ts +132 -63
- package/lib/events/hooks/thread.js +4 -4
- package/lib/events/hooks/typing.d.ts +28 -6
- package/lib/events/hooks/typing.js +2 -2
- package/lib/events/hooks/user.d.ts +3 -3
- package/lib/events/hooks/user.js +2 -2
- package/lib/events/hooks/voice.d.ts +28 -3
- package/lib/events/hooks/voice.js +8 -4
- package/lib/events/hooks/webhook.d.ts +1 -1
- package/lib/index.d.ts +5 -14
- package/lib/index.js +7 -12
- package/lib/langs/handler.d.ts +14 -10
- package/lib/langs/handler.js +40 -9
- package/lib/structures/AutoModerationRule.d.ts +4 -4
- package/lib/structures/AutoModerationRule.js +1 -2
- package/lib/structures/ClientUser.d.ts +1 -1
- package/lib/structures/Entitlement.d.ts +10 -0
- package/lib/structures/Entitlement.js +16 -0
- package/lib/structures/Guild.d.ts +33 -34
- package/lib/structures/Guild.js +5 -2
- package/lib/structures/GuildBan.d.ts +6 -6
- package/lib/structures/GuildBan.js +2 -1
- package/lib/structures/GuildEmoji.d.ts +4 -4
- package/lib/structures/GuildEmoji.js +3 -2
- package/lib/structures/GuildMember.d.ts +20 -17
- package/lib/structures/GuildMember.js +18 -8
- package/lib/structures/GuildPreview.d.ts +1 -1
- package/lib/structures/GuildRole.d.ts +5 -3
- package/lib/structures/GuildRole.js +8 -1
- package/lib/structures/GuildTemplate.d.ts +2 -2
- package/lib/structures/GuildTemplate.js +1 -1
- package/lib/structures/Interaction.d.ts +76 -39
- package/lib/structures/Interaction.js +179 -94
- package/lib/structures/Message.d.ts +29 -33
- package/lib/structures/Message.js +8 -12
- package/lib/structures/Poll.d.ts +4 -3
- package/lib/structures/Poll.js +6 -2
- package/lib/structures/Sticker.d.ts +7 -7
- package/lib/structures/Sticker.js +7 -7
- package/lib/structures/User.d.ts +5 -4
- package/lib/structures/User.js +2 -1
- package/lib/structures/VoiceState.d.ts +15 -11
- package/lib/structures/VoiceState.js +35 -17
- package/lib/structures/Webhook.d.ts +6 -7
- package/lib/structures/Webhook.js +6 -7
- package/lib/structures/channels.d.ts +11 -10
- package/lib/structures/channels.js +70 -65
- package/lib/structures/extra/BaseGuild.d.ts +12 -2
- package/lib/structures/extra/BaseGuild.js +30 -3
- package/lib/structures/extra/BitField.d.ts +1 -1
- package/lib/structures/extra/BitField.js +3 -2
- package/lib/structures/extra/DiscordBase.js +2 -2
- package/lib/structures/extra/Permissions.d.ts +3 -1
- package/lib/structures/extra/Permissions.js +8 -3
- package/lib/types/gateway.d.ts +1554 -0
- package/lib/types/gateway.js +4 -0
- package/lib/types/index.d.ts +9 -1
- package/lib/types/index.js +28 -1
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/attachment.d.ts +5 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/attachment.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/base.d.ts +22 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/base.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/boolean.d.ts +4 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/boolean.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/channel.d.ts +7 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/channel.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/integer.d.ts +17 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/integer.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/mentionable.d.ts +5 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/mentionable.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/number.d.ts +17 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/number.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/role.d.ts +5 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/role.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/shared.d.ts +25 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/shared.js +20 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/string.d.ts +17 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/string.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/subcommand.d.ts +11 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/subcommand.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/subcommandGroup.d.ts +11 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/subcommandGroup.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/user.d.ts +5 -0
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/user.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/chatInput.d.ts +65 -0
- package/lib/types/payloads/_interactions/_applicationCommands/chatInput.js +29 -0
- package/lib/types/payloads/_interactions/_applicationCommands/contextMenu.d.ts +65 -0
- package/lib/types/payloads/_interactions/_applicationCommands/contextMenu.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/internals.d.ts +8 -0
- package/lib/types/payloads/_interactions/_applicationCommands/internals.js +2 -0
- package/lib/types/payloads/_interactions/_applicationCommands/permissions.d.ts +54 -0
- package/lib/types/payloads/_interactions/_applicationCommands/permissions.js +20 -0
- package/lib/types/payloads/_interactions/applicationCommands.d.ts +188 -0
- package/lib/types/payloads/_interactions/applicationCommands.js +88 -0
- package/lib/types/payloads/_interactions/autocomplete.d.ts +10 -0
- package/lib/types/payloads/_interactions/autocomplete.js +2 -0
- package/lib/types/payloads/_interactions/base.d.ts +197 -0
- package/lib/types/payloads/_interactions/base.js +2 -0
- package/lib/types/payloads/_interactions/messageComponents.d.ts +41 -0
- package/lib/types/payloads/_interactions/messageComponents.js +2 -0
- package/lib/types/payloads/_interactions/modalSubmit.d.ts +35 -0
- package/lib/types/payloads/_interactions/modalSubmit.js +2 -0
- package/lib/types/payloads/_interactions/ping.d.ts +3 -0
- package/lib/types/payloads/_interactions/ping.js +2 -0
- package/lib/types/payloads/_interactions/responses.d.ts +184 -0
- package/lib/types/payloads/_interactions/responses.js +58 -0
- package/lib/types/payloads/application.d.ts +292 -0
- package/lib/types/payloads/application.js +117 -0
- package/lib/types/payloads/auditLog.d.ts +644 -0
- package/lib/types/payloads/auditLog.js +80 -0
- package/lib/types/payloads/autoModeration.d.ts +219 -0
- package/lib/types/payloads/autoModeration.js +87 -0
- package/lib/types/payloads/channel.d.ts +1748 -0
- package/lib/types/payloads/channel.js +376 -0
- package/lib/types/payloads/emoji.d.ts +48 -0
- package/lib/types/payloads/emoji.js +5 -0
- package/lib/types/payloads/gateway.d.ts +373 -0
- package/lib/types/payloads/gateway.js +82 -0
- package/lib/types/payloads/guild.d.ts +1060 -0
- package/lib/types/payloads/guild.js +324 -0
- package/lib/types/payloads/guildScheduledEvent.d.ts +138 -0
- package/lib/types/payloads/guildScheduledEvent.js +32 -0
- package/lib/types/payloads/index.d.ts +64 -0
- package/lib/types/payloads/index.js +37 -0
- package/lib/types/payloads/interactions.d.ts +24 -0
- package/lib/types/payloads/interactions.js +23 -0
- package/lib/types/payloads/invite.d.ts +121 -0
- package/lib/types/payloads/invite.js +23 -0
- package/lib/types/payloads/monetization.d.ts +178 -0
- package/lib/types/payloads/monetization.js +88 -0
- package/lib/types/payloads/oauth2.d.ts +131 -0
- package/lib/types/payloads/oauth2.js +135 -0
- package/lib/types/payloads/permissions.d.ts +97 -0
- package/lib/types/payloads/permissions.js +16 -0
- package/lib/types/payloads/poll.d.ts +104 -0
- package/lib/types/payloads/poll.js +16 -0
- package/lib/types/payloads/stageInstance.d.ts +77 -0
- package/lib/types/payloads/stageInstance.js +19 -0
- package/lib/types/payloads/sticker.d.ts +123 -0
- package/lib/types/payloads/sticker.js +30 -0
- package/lib/types/payloads/teams.d.ts +78 -0
- package/lib/types/payloads/teams.js +23 -0
- package/lib/types/payloads/template.d.ts +62 -0
- package/lib/types/payloads/template.js +5 -0
- package/lib/types/payloads/user.d.ts +337 -0
- package/lib/types/payloads/user.js +167 -0
- package/lib/types/payloads/voice.d.ts +89 -0
- package/lib/types/payloads/voice.js +5 -0
- package/lib/types/payloads/webhook.d.ts +76 -0
- package/lib/types/payloads/webhook.js +21 -0
- package/lib/types/rest/application.d.ts +57 -0
- package/lib/types/rest/application.js +2 -0
- package/lib/types/rest/auditLog.d.ts +30 -0
- package/lib/types/rest/auditLog.js +2 -0
- package/lib/types/rest/autoModeration.d.ts +66 -0
- package/lib/types/rest/autoModeration.js +2 -0
- package/lib/types/rest/channel.d.ts +699 -0
- package/lib/types/rest/channel.js +11 -0
- package/lib/types/rest/emoji.d.ts +54 -0
- package/lib/types/rest/emoji.js +2 -0
- package/lib/types/rest/gateway.d.ts +9 -0
- package/lib/types/rest/gateway.js +2 -0
- package/lib/types/rest/guild.d.ts +865 -0
- package/lib/types/rest/guild.js +2 -0
- package/lib/types/rest/guildScheduledEvent.d.ts +126 -0
- package/lib/types/rest/guildScheduledEvent.js +2 -0
- package/lib/types/rest/index.d.ts +296 -0
- package/lib/types/rest/index.js +292 -0
- package/lib/types/rest/interactions.d.ts +216 -0
- package/lib/types/rest/interactions.js +2 -0
- package/lib/types/rest/invite.d.ts +24 -0
- package/lib/types/rest/invite.js +2 -0
- package/lib/types/rest/monetization.d.ts +103 -0
- package/lib/types/rest/monetization.js +11 -0
- package/lib/types/rest/oauth2.d.ts +172 -0
- package/lib/types/rest/oauth2.js +2 -0
- package/lib/types/rest/poll.d.ts +44 -0
- package/lib/types/rest/poll.js +2 -0
- package/lib/types/rest/stageInstance.d.ts +58 -0
- package/lib/types/rest/stageInstance.js +2 -0
- package/lib/types/rest/sticker.d.ts +77 -0
- package/lib/types/rest/sticker.js +2 -0
- package/lib/types/rest/template.d.ts +62 -0
- package/lib/types/rest/template.js +2 -0
- package/lib/types/rest/user.d.ts +120 -0
- package/lib/types/rest/user.js +2 -0
- package/lib/types/rest/voice.d.ts +17 -0
- package/lib/types/rest/voice.js +2 -0
- package/lib/types/rest/webhook.d.ts +250 -0
- package/lib/types/rest/webhook.js +2 -0
- package/lib/types/utils/index.d.ts +808 -0
- package/lib/types/utils/index.js +810 -0
- package/lib/websocket/SharedTypes.d.ts +12 -5
- package/lib/websocket/SharedTypes.js +1 -1
- package/lib/websocket/constants/index.d.ts +3 -3
- package/lib/websocket/constants/index.js +11 -1
- package/lib/websocket/discord/basesocket.d.ts +7 -7
- package/lib/websocket/discord/basesocket.js +34 -22
- package/lib/websocket/discord/events/memberUpdate.d.ts +1 -6
- package/lib/websocket/discord/events/memberUpdate.js +2 -1
- package/lib/websocket/discord/events/presenceUpdate.d.ts +5 -18
- package/lib/websocket/discord/events/presenceUpdate.js +5 -6
- package/lib/websocket/discord/shard.d.ts +9 -8
- package/lib/websocket/discord/shard.js +83 -57
- package/lib/websocket/discord/sharder.d.ts +6 -5
- package/lib/websocket/discord/sharder.js +70 -11
- package/lib/websocket/discord/shared.d.ts +34 -6
- package/lib/websocket/discord/socket/custom.d.ts +52 -0
- package/lib/websocket/discord/socket/custom.js +300 -0
- package/lib/websocket/discord/worker.d.ts +6 -10
- package/lib/websocket/discord/workermanager.d.ts +10 -16
- package/lib/websocket/discord/workermanager.js +63 -50
- package/lib/websocket/structures/index.d.ts +0 -1
- package/lib/websocket/structures/index.js +1 -1
- package/lib/websocket/structures/timeout.d.ts +0 -1
- package/package.json +70 -74
- package/lib/cache/adapters/redis.d.ts +0 -37
- package/lib/cache/adapters/redis.js +0 -218
- package/lib/client/oninteractioncreate.d.ts +0 -4
- package/lib/client/oninteractioncreate.js +0 -198
- package/lib/client/onmessagecreate.d.ts +0 -13
- package/lib/client/onmessagecreate.js +0 -410
- package/lib/structures/extra/functions.d.ts +0 -12
- package/lib/structures/extra/functions.js +0 -70
|
@@ -1,31 +1,42 @@
|
|
|
1
|
-
import { type APIApplicationCommandOption } from '
|
|
2
|
-
import type { Logger } from '../common';
|
|
1
|
+
import { type APIApplicationCommandOption, type LocalizationMap } from '../types';
|
|
2
|
+
import type { Logger, MakeRequired, NulleableCoalising, OmitInsert } from '../common';
|
|
3
3
|
import { BaseHandler } from '../common';
|
|
4
|
-
import { Command, SubCommand } from './applications/chat';
|
|
4
|
+
import { Command, type CommandOption, SubCommand } from './applications/chat';
|
|
5
5
|
import { ContextMenuCommand } from './applications/menu';
|
|
6
6
|
import type { UsingClient } from './applications/shared';
|
|
7
|
+
import type { EntryPointCommand } from '.';
|
|
7
8
|
export declare class CommandHandler extends BaseHandler {
|
|
8
9
|
protected logger: Logger;
|
|
9
10
|
protected client: UsingClient;
|
|
10
11
|
values: (Command | ContextMenuCommand)[];
|
|
12
|
+
entryPoint: EntryPointCommand | null;
|
|
11
13
|
protected filter: (path: string) => boolean;
|
|
12
14
|
constructor(logger: Logger, client: UsingClient);
|
|
13
15
|
reload(resolve: string | Command): Promise<void>;
|
|
14
16
|
reloadAll(stopIfFail?: boolean): Promise<void>;
|
|
17
|
+
protected shouldUploadLocales(locales?: LocalizationMap | null, cachedLocales?: LocalizationMap | null): boolean;
|
|
15
18
|
protected shouldUploadOption(option: APIApplicationCommandOption, cached: APIApplicationCommandOption): boolean | undefined;
|
|
16
|
-
shouldUpload(file: string): Promise<boolean>;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
shouldUpload(file: string, guildId?: string): Promise<boolean>;
|
|
20
|
+
set(commands: SeteableCommand[]): void;
|
|
21
|
+
load(commandsDir: string, client: UsingClient): Promise<(Command | ContextMenuCommand)[]>;
|
|
22
|
+
parseLocales(command: InstanceType<HandleableCommand>): Command | ContextMenuCommand | EntryPointCommand | SubCommand;
|
|
23
|
+
parseGlobalLocales(command: InstanceType<HandleableCommand>): void;
|
|
24
|
+
parseCommandOptionLocales(option: MakeRequired<CommandOption, 'locales'>): void;
|
|
25
|
+
parseCommandLocales(command: Command): void;
|
|
26
|
+
parseContextMenuLocales(command: ContextMenuCommand): ContextMenuCommand;
|
|
27
|
+
parseSubCommandLocales(command: SubCommand): SubCommand;
|
|
28
|
+
stablishContextCommandDefaults(commandInstance: InstanceType<HandleableCommand>): ContextMenuCommand | false;
|
|
29
|
+
stablishCommandDefaults(commandInstance: InstanceType<HandleableCommand>): OmitInsert<Command, 'options', {
|
|
30
|
+
options: NonNullable<Command['options']>;
|
|
31
|
+
}> | false;
|
|
32
|
+
stablishSubCommandDefaults(commandInstance: Command, option: SubCommand): SubCommand;
|
|
33
|
+
onFile(file: FileLoaded): HandleableCommand[] | undefined;
|
|
34
|
+
onCommand(file: HandleableCommand): InstanceType<HandleableCommand> | false;
|
|
35
|
+
onSubCommand(file: HandleableSubCommand): SubCommand | false;
|
|
31
36
|
}
|
|
37
|
+
export type FileLoaded<T = null> = {
|
|
38
|
+
default?: NulleableCoalising<T, HandleableCommand>;
|
|
39
|
+
} & Record<string, NulleableCoalising<T, HandleableCommand>>;
|
|
40
|
+
export type HandleableCommand = new () => Command | SubCommand | ContextMenuCommand | EntryPointCommand;
|
|
41
|
+
export type SeteableCommand = new () => Extract<InstanceType<HandleableCommand>, SubCommand>;
|
|
42
|
+
export type HandleableSubCommand = new () => SubCommand;
|
package/lib/commands/handler.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommandHandler = void 0;
|
|
4
|
-
const
|
|
4
|
+
const types_1 = require("../types");
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
6
|
const common_1 = require("../common");
|
|
7
7
|
const chat_1 = require("./applications/chat");
|
|
@@ -11,6 +11,7 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
11
11
|
logger;
|
|
12
12
|
client;
|
|
13
13
|
values = [];
|
|
14
|
+
entryPoint = null;
|
|
14
15
|
filter = (path) => path.endsWith('.js') || (!path.endsWith('.d.ts') && path.endsWith('.ts'));
|
|
15
16
|
constructor(logger, client) {
|
|
16
17
|
super(logger);
|
|
@@ -18,6 +19,9 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
18
19
|
this.client = client;
|
|
19
20
|
}
|
|
20
21
|
async reload(resolve) {
|
|
22
|
+
if ((0, common_1.isCloudfareWorker)()) {
|
|
23
|
+
throw new Error('Reload in cloudfare worker is not supported');
|
|
24
|
+
}
|
|
21
25
|
if (typeof resolve === 'string') {
|
|
22
26
|
return this.values.find(x => x.name === resolve)?.reload();
|
|
23
27
|
}
|
|
@@ -35,6 +39,28 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
35
39
|
}
|
|
36
40
|
}
|
|
37
41
|
}
|
|
42
|
+
shouldUploadLocales(locales, cachedLocales) {
|
|
43
|
+
if (!(locales || cachedLocales))
|
|
44
|
+
return false;
|
|
45
|
+
if (!locales && cachedLocales)
|
|
46
|
+
return true;
|
|
47
|
+
if (locales && !cachedLocales)
|
|
48
|
+
return true;
|
|
49
|
+
if (locales && cachedLocales) {
|
|
50
|
+
const localesEntries = Object.entries(locales);
|
|
51
|
+
const cachedLocalesEntries = Object.entries(cachedLocales);
|
|
52
|
+
if (localesEntries.length !== cachedLocalesEntries.length)
|
|
53
|
+
return true;
|
|
54
|
+
for (const [key, value] of localesEntries) {
|
|
55
|
+
const cached = cachedLocalesEntries.find(x => x[0] === key);
|
|
56
|
+
if (!cached)
|
|
57
|
+
return true;
|
|
58
|
+
if (value !== cached[1])
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
38
64
|
shouldUploadOption(option, cached) {
|
|
39
65
|
if (option.description !== cached.description)
|
|
40
66
|
return true;
|
|
@@ -45,11 +71,15 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
45
71
|
if (option.name !== cached.name)
|
|
46
72
|
return true;
|
|
47
73
|
//TODO: locales
|
|
74
|
+
if (this.shouldUploadLocales(option.name_localizations, cached.name_localizations))
|
|
75
|
+
return true;
|
|
76
|
+
if (this.shouldUploadLocales(option.description_localizations, cached.description_localizations))
|
|
77
|
+
return true;
|
|
48
78
|
switch (option.type) {
|
|
49
|
-
case
|
|
79
|
+
case types_1.ApplicationCommandOptionType.String:
|
|
50
80
|
return (option.min_length !== cached.min_length ||
|
|
51
81
|
option.max_length !== cached.max_length);
|
|
52
|
-
case
|
|
82
|
+
case types_1.ApplicationCommandOptionType.Channel:
|
|
53
83
|
{
|
|
54
84
|
if (option.channel_types?.length !== cached.channel_types?.length)
|
|
55
85
|
return true;
|
|
@@ -60,8 +90,8 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
60
90
|
}
|
|
61
91
|
}
|
|
62
92
|
return;
|
|
63
|
-
case
|
|
64
|
-
case
|
|
93
|
+
case types_1.ApplicationCommandOptionType.Subcommand:
|
|
94
|
+
case types_1.ApplicationCommandOptionType.SubcommandGroup:
|
|
65
95
|
if (option.options?.length !==
|
|
66
96
|
cached.options?.length) {
|
|
67
97
|
return true;
|
|
@@ -76,28 +106,37 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
76
106
|
return true;
|
|
77
107
|
}
|
|
78
108
|
break;
|
|
79
|
-
case
|
|
80
|
-
case
|
|
109
|
+
case types_1.ApplicationCommandOptionType.Integer:
|
|
110
|
+
case types_1.ApplicationCommandOptionType.Number:
|
|
81
111
|
return (option.min_value !== cached.min_value ||
|
|
82
112
|
option.max_value !== cached.max_value);
|
|
83
|
-
case
|
|
84
|
-
case
|
|
85
|
-
case
|
|
86
|
-
case
|
|
87
|
-
case
|
|
113
|
+
case types_1.ApplicationCommandOptionType.Attachment:
|
|
114
|
+
case types_1.ApplicationCommandOptionType.Boolean:
|
|
115
|
+
case types_1.ApplicationCommandOptionType.Mentionable:
|
|
116
|
+
case types_1.ApplicationCommandOptionType.Role:
|
|
117
|
+
case types_1.ApplicationCommandOptionType.User:
|
|
88
118
|
break;
|
|
89
119
|
}
|
|
90
120
|
return false;
|
|
91
121
|
}
|
|
92
|
-
async shouldUpload(file) {
|
|
122
|
+
async shouldUpload(file, guildId) {
|
|
123
|
+
const values = this.values.filter(x => {
|
|
124
|
+
if (!guildId)
|
|
125
|
+
return !x.guildId;
|
|
126
|
+
return x.guildId?.includes(guildId);
|
|
127
|
+
});
|
|
93
128
|
if (!(await node_fs_1.promises.access(file).then(() => true, () => false))) {
|
|
94
|
-
await node_fs_1.promises.writeFile(file, JSON.stringify(
|
|
129
|
+
await node_fs_1.promises.writeFile(file, JSON.stringify(values.map(x => x.toJSON())));
|
|
95
130
|
return true;
|
|
96
131
|
}
|
|
97
|
-
const cachedCommands = JSON.parse((await node_fs_1.promises.readFile(file)).toString())
|
|
98
|
-
|
|
132
|
+
const cachedCommands = JSON.parse((await node_fs_1.promises.readFile(file)).toString()).filter(x => {
|
|
133
|
+
if (!guildId)
|
|
134
|
+
return !x.guild_id;
|
|
135
|
+
return x.guild_id?.includes(guildId);
|
|
136
|
+
});
|
|
137
|
+
if (cachedCommands.length !== values.length)
|
|
99
138
|
return true;
|
|
100
|
-
for (const command of
|
|
139
|
+
for (const command of values.map(x => x.toJSON())) {
|
|
101
140
|
const cached = cachedCommands.find(x => {
|
|
102
141
|
if (x.name !== command.name)
|
|
103
142
|
return false;
|
|
@@ -121,7 +160,10 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
121
160
|
return true;
|
|
122
161
|
if (!!cached.integration_types !== !!command.integration_types)
|
|
123
162
|
return true;
|
|
124
|
-
|
|
163
|
+
if (this.shouldUploadLocales(command.name_localizations, cached.name_localizations))
|
|
164
|
+
return true;
|
|
165
|
+
if (this.shouldUploadLocales(command.description_localizations, cached.description_localizations))
|
|
166
|
+
return true;
|
|
125
167
|
if ('contexts' in command && 'contexts' in cached) {
|
|
126
168
|
if (command.contexts.length !== cached.contexts.length)
|
|
127
169
|
return true;
|
|
@@ -152,125 +194,140 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
152
194
|
}
|
|
153
195
|
return false;
|
|
154
196
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return { name: i.name, file: x, path: i.__filePath ?? '*' };
|
|
159
|
-
}) ??
|
|
160
|
-
(await this.loadFilesK(await this.getFiles(commandsDir))).filter(x => x.file);
|
|
161
|
-
this.values = [];
|
|
162
|
-
for (const command of result) {
|
|
197
|
+
set(commands) {
|
|
198
|
+
this.values ??= [];
|
|
199
|
+
for (const command of commands) {
|
|
163
200
|
let commandInstance;
|
|
164
201
|
try {
|
|
165
|
-
commandInstance = this.onCommand(command
|
|
202
|
+
commandInstance = this.onCommand(command);
|
|
166
203
|
if (!commandInstance)
|
|
167
204
|
continue;
|
|
168
205
|
}
|
|
169
206
|
catch (e) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
.split(process.cwd())
|
|
173
|
-
.slice(1)
|
|
174
|
-
.join(process.cwd())} doesn't export the class by \`export default <Command>\``);
|
|
175
|
-
}
|
|
176
|
-
else
|
|
177
|
-
this.logger.warn(e, command);
|
|
207
|
+
this.logger.warn(`${command.name} ins't a resolvable command`);
|
|
208
|
+
this.logger.error(e);
|
|
178
209
|
continue;
|
|
179
210
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
211
|
+
commandInstance.props = this.client.options.commands?.defaults?.props ?? {};
|
|
212
|
+
const isCommand = this.stablishCommandDefaults(commandInstance);
|
|
213
|
+
if (isCommand) {
|
|
214
|
+
for (const option of commandInstance.options ?? []) {
|
|
215
|
+
if (option instanceof chat_1.SubCommand)
|
|
216
|
+
this.stablishSubCommandDefaults(commandInstance, option);
|
|
217
|
+
}
|
|
186
218
|
}
|
|
187
|
-
|
|
219
|
+
else
|
|
220
|
+
this.stablishContextCommandDefaults(commandInstance);
|
|
221
|
+
this.parseLocales(commandInstance);
|
|
222
|
+
this.values.push(commandInstance);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
async load(commandsDir, client) {
|
|
226
|
+
const result = await this.loadFilesK(await this.getFiles(commandsDir));
|
|
227
|
+
this.values = [];
|
|
228
|
+
for (const { commands, file } of result.map(x => ({ commands: this.onFile(x.file), file: x }))) {
|
|
229
|
+
if (!commands)
|
|
188
230
|
continue;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
commandInstance.onOptionsError ??= client.options.commands?.defaults?.onOptionsError;
|
|
195
|
-
commandInstance.onPermissionsFail ??= client.options.commands?.defaults?.onPermissionsFail;
|
|
196
|
-
commandInstance.onRunError ??= client.options.commands?.defaults?.onRunError;
|
|
197
|
-
commandInstance.__filePath = command.path;
|
|
198
|
-
commandInstance.options ??= [];
|
|
199
|
-
commandInstance.props ??= client.options.commands?.defaults?.props ?? {};
|
|
200
|
-
if (commandInstance.__autoload) {
|
|
201
|
-
//@AutoLoad
|
|
202
|
-
const options = await this.getFiles((0, node_path_1.dirname)(command.path));
|
|
203
|
-
for (const option of options) {
|
|
204
|
-
if (command.name === (0, node_path_1.basename)(option)) {
|
|
231
|
+
for (const command of commands) {
|
|
232
|
+
let commandInstance;
|
|
233
|
+
try {
|
|
234
|
+
commandInstance = this.onCommand(command);
|
|
235
|
+
if (!commandInstance)
|
|
205
236
|
continue;
|
|
237
|
+
}
|
|
238
|
+
catch (e) {
|
|
239
|
+
if (e instanceof Error && e.message.includes('is not a constructor')) {
|
|
240
|
+
this.logger.warn(`${file.path
|
|
241
|
+
.split(process.cwd())
|
|
242
|
+
.slice(1)
|
|
243
|
+
.join(process.cwd())} doesn't export the class by \`export default <Command>\``);
|
|
206
244
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
245
|
+
else
|
|
246
|
+
this.logger.warn(e, command);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (commandInstance instanceof chat_1.SubCommand)
|
|
250
|
+
continue;
|
|
251
|
+
commandInstance.__filePath = file.path;
|
|
252
|
+
commandInstance.props ??= client.options.commands?.defaults?.props ?? {};
|
|
253
|
+
const isAvailableCommand = this.stablishCommandDefaults(commandInstance);
|
|
254
|
+
if (isAvailableCommand) {
|
|
255
|
+
commandInstance = isAvailableCommand;
|
|
256
|
+
if (commandInstance.__autoload) {
|
|
257
|
+
//@AutoLoad
|
|
258
|
+
const options = await this.getFiles((0, node_path_1.dirname)(file.path));
|
|
259
|
+
for (const option of options) {
|
|
260
|
+
if (file.name === (0, node_path_1.basename)(option)) {
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
try {
|
|
264
|
+
const fileSubCommands = this.onFile(result.find(x => x.path === option).file);
|
|
265
|
+
if (!fileSubCommands) {
|
|
266
|
+
this.logger.warn(`SubCommand returned (${fileSubCommands}) ignoring.`);
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
for (const fileSubCommand of fileSubCommands) {
|
|
270
|
+
const subCommand = this.onSubCommand(fileSubCommand);
|
|
271
|
+
if (subCommand && subCommand instanceof chat_1.SubCommand) {
|
|
272
|
+
subCommand.__filePath = option;
|
|
273
|
+
commandInstance.options.push(subCommand);
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
this.logger.warn(subCommand ? 'SubCommand expected' : 'Invalid SubCommand', subCommand);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
//pass
|
|
282
|
+
}
|
|
212
283
|
}
|
|
213
284
|
}
|
|
214
|
-
|
|
215
|
-
|
|
285
|
+
for (const option of commandInstance.options ?? []) {
|
|
286
|
+
if (option instanceof chat_1.SubCommand)
|
|
287
|
+
this.stablishSubCommandDefaults(commandInstance, option);
|
|
216
288
|
}
|
|
217
289
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (
|
|
221
|
-
|
|
222
|
-
option.onMiddlewaresError =
|
|
223
|
-
option.onMiddlewaresError?.bind(option) ??
|
|
224
|
-
commandInstance.onMiddlewaresError?.bind(commandInstance) ??
|
|
225
|
-
this.client.options.commands?.defaults?.onMiddlewaresError;
|
|
226
|
-
option.onRunError =
|
|
227
|
-
option.onRunError?.bind(option) ??
|
|
228
|
-
commandInstance.onRunError?.bind(commandInstance) ??
|
|
229
|
-
this.client.options.commands?.defaults?.onRunError;
|
|
230
|
-
option.onOptionsError =
|
|
231
|
-
option.onOptionsError?.bind(option) ??
|
|
232
|
-
commandInstance.onOptionsError?.bind(commandInstance) ??
|
|
233
|
-
this.client.options.commands?.defaults?.onOptionsError;
|
|
234
|
-
option.onInternalError =
|
|
235
|
-
option.onInternalError?.bind(option) ??
|
|
236
|
-
commandInstance.onInternalError?.bind(commandInstance) ??
|
|
237
|
-
this.client.options.commands?.defaults?.onInternalError;
|
|
238
|
-
option.onAfterRun =
|
|
239
|
-
option.onAfterRun?.bind(option) ??
|
|
240
|
-
commandInstance.onAfterRun?.bind(commandInstance) ??
|
|
241
|
-
this.client.options.commands?.defaults?.onAfterRun;
|
|
242
|
-
option.onBotPermissionsFail =
|
|
243
|
-
option.onBotPermissionsFail?.bind(option) ??
|
|
244
|
-
commandInstance.onBotPermissionsFail?.bind(commandInstance) ??
|
|
245
|
-
this.client.options.commands?.defaults?.onBotPermissionsFail;
|
|
246
|
-
option.onPermissionsFail =
|
|
247
|
-
option.onPermissionsFail?.bind(option) ??
|
|
248
|
-
commandInstance.onPermissionsFail?.bind(commandInstance) ??
|
|
249
|
-
this.client.options.commands?.defaults?.onPermissionsFail;
|
|
250
|
-
option.botPermissions ??= commandInstance.botPermissions;
|
|
251
|
-
option.defaultMemberPermissions ??= commandInstance.defaultMemberPermissions;
|
|
252
|
-
option.contexts ??= commandInstance.contexts;
|
|
253
|
-
option.integrationTypes ??= commandInstance.integrationTypes;
|
|
254
|
-
option.props ??= commandInstance.props;
|
|
290
|
+
this.stablishContextCommandDefaults(commandInstance);
|
|
291
|
+
this.parseLocales(commandInstance);
|
|
292
|
+
if ('handler' in commandInstance && commandInstance.handler) {
|
|
293
|
+
this.entryPoint = commandInstance;
|
|
255
294
|
}
|
|
295
|
+
else
|
|
296
|
+
this.values.push(commandInstance);
|
|
256
297
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
298
|
+
}
|
|
299
|
+
return this.values;
|
|
300
|
+
}
|
|
301
|
+
parseLocales(command) {
|
|
302
|
+
this.parseGlobalLocales(command);
|
|
303
|
+
if (command instanceof menu_1.ContextMenuCommand) {
|
|
304
|
+
this.parseContextMenuLocales(command);
|
|
305
|
+
return command;
|
|
306
|
+
}
|
|
307
|
+
if (command instanceof chat_1.Command && command.__tGroups) {
|
|
308
|
+
this.parseCommandLocales(command);
|
|
309
|
+
for (const option of command.options ?? []) {
|
|
310
|
+
if (option instanceof chat_1.SubCommand) {
|
|
311
|
+
this.parseSubCommandLocales(option);
|
|
312
|
+
continue;
|
|
262
313
|
}
|
|
314
|
+
// @ts-expect-error
|
|
315
|
+
if (option.locales)
|
|
316
|
+
this.parseCommandOptionLocales(option);
|
|
263
317
|
}
|
|
264
318
|
}
|
|
265
|
-
|
|
319
|
+
if (command instanceof chat_1.SubCommand) {
|
|
320
|
+
this.parseSubCommandLocales(command);
|
|
321
|
+
}
|
|
322
|
+
return command;
|
|
266
323
|
}
|
|
267
|
-
|
|
324
|
+
parseGlobalLocales(command) {
|
|
268
325
|
if (command.__t) {
|
|
269
326
|
command.name_localizations = {};
|
|
270
327
|
command.description_localizations = {};
|
|
271
328
|
for (const locale of Object.keys(this.client.langs.values)) {
|
|
272
329
|
const locales = this.client.langs.aliases.find(x => x[0] === locale)?.[1] ?? [];
|
|
273
|
-
if (Object.values(
|
|
330
|
+
if (Object.values(types_1.Locale).includes(locale))
|
|
274
331
|
locales.push(locale);
|
|
275
332
|
if (command.__t.name) {
|
|
276
333
|
for (const i of locales) {
|
|
@@ -288,72 +345,146 @@ class CommandHandler extends common_1.BaseHandler {
|
|
|
288
345
|
}
|
|
289
346
|
}
|
|
290
347
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
const valueName = this.client.langs.getKey(locale, options.locales.name);
|
|
305
|
-
if (valueName)
|
|
306
|
-
options.name_localizations[i] = valueName;
|
|
307
|
-
}
|
|
348
|
+
}
|
|
349
|
+
parseCommandOptionLocales(option) {
|
|
350
|
+
option.name_localizations = {};
|
|
351
|
+
option.description_localizations = {};
|
|
352
|
+
for (const locale of Object.keys(this.client.langs.values)) {
|
|
353
|
+
const locales = this.client.langs.aliases.find(x => x[0] === locale)?.[1] ?? [];
|
|
354
|
+
if (Object.values(types_1.Locale).includes(locale))
|
|
355
|
+
locales.push(locale);
|
|
356
|
+
if (option.locales.name) {
|
|
357
|
+
for (const i of locales) {
|
|
358
|
+
const valueName = this.client.langs.getKey(locale, option.locales.name);
|
|
359
|
+
if (valueName)
|
|
360
|
+
option.name_localizations[i] = valueName;
|
|
308
361
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
362
|
+
}
|
|
363
|
+
if (option.locales.description) {
|
|
364
|
+
for (const i of locales) {
|
|
365
|
+
const valueKey = this.client.langs.getKey(locale, option.locales.description);
|
|
366
|
+
if (valueKey)
|
|
367
|
+
option.description_localizations[i] = valueKey;
|
|
315
368
|
}
|
|
316
369
|
}
|
|
317
370
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
371
|
+
}
|
|
372
|
+
parseCommandLocales(command) {
|
|
373
|
+
command.groups = {};
|
|
374
|
+
for (const locale of Object.keys(this.client.langs.values)) {
|
|
375
|
+
const locales = this.client.langs.aliases.find(x => x[0] === locale)?.[1] ?? [];
|
|
376
|
+
if (Object.values(types_1.Locale).includes(locale))
|
|
377
|
+
locales.push(locale);
|
|
378
|
+
for (const group in command.__tGroups) {
|
|
379
|
+
command.groups[group] ??= {
|
|
380
|
+
defaultDescription: command.__tGroups[group].defaultDescription,
|
|
381
|
+
description: [],
|
|
382
|
+
name: [],
|
|
383
|
+
};
|
|
384
|
+
if (command.__tGroups[group].name) {
|
|
385
|
+
for (const i of locales) {
|
|
386
|
+
const valueName = this.client.langs.getKey(locale, command.__tGroups[group].name);
|
|
387
|
+
if (valueName) {
|
|
388
|
+
command.groups[group].name.push([i, valueName]);
|
|
336
389
|
}
|
|
337
390
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
391
|
+
}
|
|
392
|
+
if (command.__tGroups[group].description) {
|
|
393
|
+
for (const i of locales) {
|
|
394
|
+
const valueKey = this.client.langs.getKey(locale, command.__tGroups[group].description);
|
|
395
|
+
if (valueKey) {
|
|
396
|
+
command.groups[group].description.push([i, valueKey]);
|
|
344
397
|
}
|
|
345
398
|
}
|
|
346
399
|
}
|
|
347
400
|
}
|
|
348
401
|
}
|
|
349
402
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
403
|
+
parseContextMenuLocales(command) {
|
|
404
|
+
return command;
|
|
405
|
+
}
|
|
406
|
+
parseSubCommandLocales(command) {
|
|
407
|
+
for (const i of command.options ?? []) {
|
|
408
|
+
// @ts-expect-error
|
|
409
|
+
if (i.locales)
|
|
410
|
+
this.parseCommandOptionLocales(i);
|
|
411
|
+
}
|
|
412
|
+
return command;
|
|
413
|
+
}
|
|
414
|
+
stablishContextCommandDefaults(commandInstance) {
|
|
415
|
+
if (!(commandInstance instanceof menu_1.ContextMenuCommand))
|
|
416
|
+
return false;
|
|
417
|
+
commandInstance.onAfterRun ??= this.client.options.commands?.defaults?.onAfterRun;
|
|
418
|
+
//@ts-expect-error magic.
|
|
419
|
+
commandInstance.onBotPermissionsFail ??= this.client.options.commands?.defaults?.onBotPermissionsFail;
|
|
420
|
+
//@ts-expect-error magic.
|
|
421
|
+
commandInstance.onInternalError ??= this.client.options.commands?.defaults?.onInternalError;
|
|
422
|
+
//@ts-expect-error magic.
|
|
423
|
+
commandInstance.onMiddlewaresError ??= this.client.options.commands?.defaults?.onMiddlewaresError;
|
|
424
|
+
//@ts-expect-error magic.
|
|
425
|
+
commandInstance.onPermissionsFail ??= this.client.options.commands?.defaults?.onPermissionsFail;
|
|
426
|
+
//@ts-expect-error magic.
|
|
427
|
+
commandInstance.onRunError ??= this.client.options.commands?.defaults?.onRunError;
|
|
428
|
+
return commandInstance;
|
|
429
|
+
}
|
|
430
|
+
stablishCommandDefaults(commandInstance) {
|
|
431
|
+
if (!(commandInstance instanceof chat_1.Command))
|
|
432
|
+
return false;
|
|
433
|
+
commandInstance.onAfterRun ??= this.client.options.commands?.defaults?.onAfterRun;
|
|
434
|
+
commandInstance.onBotPermissionsFail ??= this.client.options.commands?.defaults?.onBotPermissionsFail;
|
|
435
|
+
commandInstance.onInternalError ??= this.client.options.commands?.defaults?.onInternalError;
|
|
436
|
+
commandInstance.onMiddlewaresError ??= this.client.options.commands?.defaults?.onMiddlewaresError;
|
|
437
|
+
commandInstance.onOptionsError ??= this.client.options.commands?.defaults?.onOptionsError;
|
|
438
|
+
commandInstance.onPermissionsFail ??= this.client.options.commands?.defaults?.onPermissionsFail;
|
|
439
|
+
commandInstance.onRunError ??= this.client.options.commands?.defaults?.onRunError;
|
|
440
|
+
commandInstance.options ??= [];
|
|
441
|
+
return commandInstance;
|
|
442
|
+
}
|
|
443
|
+
stablishSubCommandDefaults(commandInstance, option) {
|
|
444
|
+
option.middlewares = (commandInstance.middlewares ?? []).concat(option.middlewares ?? []);
|
|
445
|
+
option.onMiddlewaresError =
|
|
446
|
+
option.onMiddlewaresError?.bind(option) ??
|
|
447
|
+
commandInstance.onMiddlewaresError?.bind(commandInstance) ??
|
|
448
|
+
this.client.options.commands?.defaults?.onMiddlewaresError;
|
|
449
|
+
option.onRunError =
|
|
450
|
+
option.onRunError?.bind(option) ??
|
|
451
|
+
commandInstance.onRunError?.bind(commandInstance) ??
|
|
452
|
+
this.client.options.commands?.defaults?.onRunError;
|
|
453
|
+
option.onOptionsError =
|
|
454
|
+
option.onOptionsError?.bind(option) ??
|
|
455
|
+
commandInstance.onOptionsError?.bind(commandInstance) ??
|
|
456
|
+
this.client.options.commands?.defaults?.onOptionsError;
|
|
457
|
+
option.onInternalError =
|
|
458
|
+
option.onInternalError?.bind(option) ??
|
|
459
|
+
commandInstance.onInternalError?.bind(commandInstance) ??
|
|
460
|
+
this.client.options.commands?.defaults?.onInternalError;
|
|
461
|
+
option.onAfterRun =
|
|
462
|
+
option.onAfterRun?.bind(option) ??
|
|
463
|
+
commandInstance.onAfterRun?.bind(commandInstance) ??
|
|
464
|
+
this.client.options.commands?.defaults?.onAfterRun;
|
|
465
|
+
option.onBotPermissionsFail =
|
|
466
|
+
option.onBotPermissionsFail?.bind(option) ??
|
|
467
|
+
commandInstance.onBotPermissionsFail?.bind(commandInstance) ??
|
|
468
|
+
this.client.options.commands?.defaults?.onBotPermissionsFail;
|
|
469
|
+
option.onPermissionsFail =
|
|
470
|
+
option.onPermissionsFail?.bind(option) ??
|
|
471
|
+
commandInstance.onPermissionsFail?.bind(commandInstance) ??
|
|
472
|
+
this.client.options.commands?.defaults?.onPermissionsFail;
|
|
473
|
+
option.botPermissions ??= commandInstance.botPermissions;
|
|
474
|
+
option.defaultMemberPermissions ??= commandInstance.defaultMemberPermissions;
|
|
475
|
+
option.contexts ??= commandInstance.contexts;
|
|
476
|
+
option.integrationTypes ??= commandInstance.integrationTypes;
|
|
477
|
+
option.props ??= commandInstance.props;
|
|
478
|
+
return option;
|
|
479
|
+
}
|
|
480
|
+
onFile(file) {
|
|
481
|
+
return file.default ? [file.default] : undefined;
|
|
482
|
+
}
|
|
483
|
+
onCommand(file) {
|
|
484
|
+
return new file();
|
|
485
|
+
}
|
|
486
|
+
onSubCommand(file) {
|
|
487
|
+
return new file();
|
|
355
488
|
}
|
|
356
|
-
onCommand = (file) => new file();
|
|
357
|
-
onSubCommand = (file) => new file();
|
|
358
489
|
}
|
|
359
490
|
exports.CommandHandler = CommandHandler;
|
package/lib/commands/index.d.ts
CHANGED
|
@@ -4,5 +4,7 @@ export * from './applications/chatcontext';
|
|
|
4
4
|
export * from './applications/menu';
|
|
5
5
|
export * from './applications/menucontext';
|
|
6
6
|
export * from './applications/options';
|
|
7
|
+
export * from './applications/entryPoint';
|
|
8
|
+
export * from './applications/entrycontext';
|
|
7
9
|
export * from './decorators';
|
|
8
10
|
export * from './optionresolver';
|