seyfert 0.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 +190 -0
- package/README.md +57 -0
- package/lib/api/CDN.d.ts +220 -0
- package/lib/api/CDN.js +236 -0
- package/lib/api/REST.d.ts +127 -0
- package/lib/api/REST.js +424 -0
- package/lib/api/Router.d.ts +17 -0
- package/lib/api/Router.js +63 -0
- package/lib/api/Routes/applications.d.ts +46 -0
- package/lib/api/Routes/applications.js +2 -0
- package/lib/api/Routes/cdn.d.ts +66 -0
- package/lib/api/Routes/cdn.js +2 -0
- package/lib/api/Routes/channels.d.ts +109 -0
- package/lib/api/Routes/channels.js +2 -0
- package/lib/api/Routes/gateway.d.ts +11 -0
- package/lib/api/Routes/gateway.js +2 -0
- package/lib/api/Routes/guilds.d.ts +171 -0
- package/lib/api/Routes/guilds.js +2 -0
- package/lib/api/Routes/index.d.ts +13 -0
- package/lib/api/Routes/index.js +17 -0
- package/lib/api/Routes/interactions.d.ts +14 -0
- package/lib/api/Routes/interactions.js +2 -0
- package/lib/api/Routes/invites.d.ts +9 -0
- package/lib/api/Routes/invites.js +2 -0
- package/lib/api/Routes/stage-instances.d.ts +13 -0
- package/lib/api/Routes/stage-instances.js +2 -0
- package/lib/api/Routes/stickers.d.ts +11 -0
- package/lib/api/Routes/stickers.js +2 -0
- package/lib/api/Routes/users.d.ts +35 -0
- package/lib/api/Routes/users.js +2 -0
- package/lib/api/Routes/voice.d.ts +10 -0
- package/lib/api/Routes/voice.js +2 -0
- package/lib/api/Routes/webhooks.d.ts +29 -0
- package/lib/api/Routes/webhooks.js +2 -0
- package/lib/api/errors/DiscordAPIError.d.ts +51 -0
- package/lib/api/errors/DiscordAPIError.js +81 -0
- package/lib/api/errors/HTTPError.d.ts +20 -0
- package/lib/api/errors/HTTPError.js +28 -0
- package/lib/api/errors/RateLimitError.d.ts +19 -0
- package/lib/api/errors/RateLimitError.js +37 -0
- package/lib/api/handlers/BurstHandler.d.ts +51 -0
- package/lib/api/handlers/BurstHandler.js +124 -0
- package/lib/api/handlers/SequentialHandler.d.ts +81 -0
- package/lib/api/handlers/SequentialHandler.js +365 -0
- package/lib/api/handlers/Shared.d.ts +14 -0
- package/lib/api/handlers/Shared.js +125 -0
- package/lib/api/index.d.ts +5 -0
- package/lib/api/index.js +21 -0
- package/lib/api/interfaces/Handler.d.ts +21 -0
- package/lib/api/interfaces/Handler.js +2 -0
- package/lib/api/shared.d.ts +7 -0
- package/lib/api/shared.js +27 -0
- package/lib/api/utils/constants.d.ts +39 -0
- package/lib/api/utils/constants.js +50 -0
- package/lib/api/utils/types.d.ts +335 -0
- package/lib/api/utils/types.js +14 -0
- package/lib/api/utils/utils.d.ts +52 -0
- package/lib/api/utils/utils.js +159 -0
- package/lib/builders/ActionRow.d.ts +40 -0
- package/lib/builders/ActionRow.js +58 -0
- package/lib/builders/Attachment.d.ts +106 -0
- package/lib/builders/Attachment.js +196 -0
- package/lib/builders/Base.d.ts +10 -0
- package/lib/builders/Base.js +13 -0
- package/lib/builders/Button.d.ts +59 -0
- package/lib/builders/Button.js +94 -0
- package/lib/builders/MessageEmbed.d.ts +116 -0
- package/lib/builders/MessageEmbed.js +159 -0
- package/lib/builders/Modal.d.ts +111 -0
- package/lib/builders/Modal.js +162 -0
- package/lib/builders/SelectMenu.d.ts +201 -0
- package/lib/builders/SelectMenu.js +293 -0
- package/lib/builders/index.d.ts +12 -0
- package/lib/builders/index.js +54 -0
- package/lib/builders/types.d.ts +21 -0
- package/lib/builders/types.js +2 -0
- package/lib/cache/adapters/default.d.ts +24 -0
- package/lib/cache/adapters/default.js +118 -0
- package/lib/cache/adapters/index.d.ts +4 -0
- package/lib/cache/adapters/index.js +20 -0
- package/lib/cache/adapters/redis.d.ts +35 -0
- package/lib/cache/adapters/redis.js +180 -0
- package/lib/cache/adapters/types.d.ts +25 -0
- package/lib/cache/adapters/types.js +2 -0
- package/lib/cache/adapters/workeradapter.d.ts +24 -0
- package/lib/cache/adapters/workeradapter.js +76 -0
- package/lib/cache/index.d.ts +97 -0
- package/lib/cache/index.js +394 -0
- package/lib/cache/resources/channels.d.ts +7 -0
- package/lib/cache/resources/channels.js +20 -0
- package/lib/cache/resources/default/base.d.ts +25 -0
- package/lib/cache/resources/default/base.js +75 -0
- package/lib/cache/resources/default/guild-based.d.ts +33 -0
- package/lib/cache/resources/default/guild-based.js +91 -0
- package/lib/cache/resources/default/guild-related.d.ts +32 -0
- package/lib/cache/resources/default/guild-related.js +102 -0
- package/lib/cache/resources/emojis.d.ts +7 -0
- package/lib/cache/resources/emojis.js +17 -0
- package/lib/cache/resources/guilds.d.ts +10 -0
- package/lib/cache/resources/guilds.js +117 -0
- package/lib/cache/resources/members.d.ts +10 -0
- package/lib/cache/resources/members.js +41 -0
- package/lib/cache/resources/presence.d.ts +9 -0
- package/lib/cache/resources/presence.js +14 -0
- package/lib/cache/resources/roles.d.ts +7 -0
- package/lib/cache/resources/roles.js +17 -0
- package/lib/cache/resources/stage-instances.d.ts +5 -0
- package/lib/cache/resources/stage-instances.js +8 -0
- package/lib/cache/resources/stickers.d.ts +7 -0
- package/lib/cache/resources/stickers.js +17 -0
- package/lib/cache/resources/threads.d.ts +7 -0
- package/lib/cache/resources/threads.js +17 -0
- package/lib/cache/resources/users.d.ts +7 -0
- package/lib/cache/resources/users.js +17 -0
- package/lib/cache/resources/voice-states.d.ts +9 -0
- package/lib/cache/resources/voice-states.js +13 -0
- package/lib/client/base.d.ts +244 -0
- package/lib/client/base.js +178 -0
- package/lib/client/client.d.ts +32 -0
- package/lib/client/client.js +156 -0
- package/lib/client/httpclient.d.ts +21 -0
- package/lib/client/httpclient.js +143 -0
- package/lib/client/index.d.ts +4 -0
- package/lib/client/index.js +19 -0
- package/lib/client/oninteraction.d.ts +4 -0
- package/lib/client/oninteraction.js +180 -0
- package/lib/client/workerclient.d.ts +28 -0
- package/lib/client/workerclient.js +213 -0
- package/lib/collection.d.ts +233 -0
- package/lib/collection.js +371 -0
- package/lib/commands/applications/chat.d.ts +139 -0
- package/lib/commands/applications/chat.js +173 -0
- package/lib/commands/applications/chatcontext.d.ts +28 -0
- package/lib/commands/applications/chatcontext.js +53 -0
- package/lib/commands/applications/menu.d.ts +39 -0
- package/lib/commands/applications/menu.js +87 -0
- package/lib/commands/applications/menucontext.d.ts +25 -0
- package/lib/commands/applications/menucontext.js +64 -0
- package/lib/commands/applications/options.d.ts +67 -0
- package/lib/commands/applications/options.js +44 -0
- package/lib/commands/applications/shared.d.ts +35 -0
- package/lib/commands/applications/shared.js +2 -0
- package/lib/commands/decorators.d.ts +107 -0
- package/lib/commands/decorators.js +85 -0
- package/lib/commands/handler.d.ts +15 -0
- package/lib/commands/handler.js +140 -0
- package/lib/commands/index.d.ts +8 -0
- package/lib/commands/index.js +24 -0
- package/lib/commands/optionresolver.d.ts +49 -0
- package/lib/commands/optionresolver.js +146 -0
- package/lib/common/bot/watcher.d.ts +53 -0
- package/lib/common/bot/watcher.js +104 -0
- package/lib/common/index.d.ts +13 -0
- package/lib/common/index.js +30 -0
- package/lib/common/it/colors.d.ts +274 -0
- package/lib/common/it/colors.js +453 -0
- package/lib/common/it/constants.d.ts +36 -0
- package/lib/common/it/constants.js +40 -0
- package/lib/common/it/logger.d.ts +114 -0
- package/lib/common/it/logger.js +189 -0
- package/lib/common/it/utils.d.ts +107 -0
- package/lib/common/it/utils.js +275 -0
- package/lib/common/shorters/base.d.ts +5 -0
- package/lib/common/shorters/base.js +10 -0
- package/lib/common/shorters/channels.d.ts +90 -0
- package/lib/common/shorters/channels.js +95 -0
- package/lib/common/shorters/guilds.d.ts +389 -0
- package/lib/common/shorters/guilds.js +350 -0
- package/lib/common/shorters/members.d.ts +115 -0
- package/lib/common/shorters/members.js +179 -0
- package/lib/common/shorters/messages.d.ts +27 -0
- package/lib/common/shorters/messages.js +117 -0
- package/lib/common/shorters/roles.d.ts +12 -0
- package/lib/common/shorters/roles.js +51 -0
- package/lib/common/shorters/templates.d.ts +12 -0
- package/lib/common/shorters/templates.js +29 -0
- package/lib/common/shorters/users.d.ts +11 -0
- package/lib/common/shorters/users.js +42 -0
- package/lib/common/shorters/webhook.d.ts +33 -0
- package/lib/common/shorters/webhook.js +69 -0
- package/lib/common/types/options.d.ts +10 -0
- package/lib/common/types/options.js +2 -0
- package/lib/common/types/resolvables.d.ts +10 -0
- package/lib/common/types/resolvables.js +2 -0
- package/lib/common/types/util.d.ts +90 -0
- package/lib/common/types/util.js +2 -0
- package/lib/common/types/write.d.ts +21 -0
- package/lib/common/types/write.js +2 -0
- package/lib/components/ActionRow.d.ts +10 -0
- package/lib/components/ActionRow.js +13 -0
- package/lib/components/ButtonComponent.d.ts +19 -0
- package/lib/components/ButtonComponent.js +34 -0
- package/lib/components/ChannelSelectMenuComponent.d.ts +6 -0
- package/lib/components/ChannelSelectMenuComponent.js +12 -0
- package/lib/components/MentionableSelectMenuComponent.d.ts +4 -0
- package/lib/components/MentionableSelectMenuComponent.js +7 -0
- package/lib/components/RoleSelectMenuComponent.d.ts +4 -0
- package/lib/components/RoleSelectMenuComponent.js +7 -0
- package/lib/components/StringSelectMenuComponent.d.ts +6 -0
- package/lib/components/StringSelectMenuComponent.js +12 -0
- package/lib/components/TextInputComponent.d.ts +7 -0
- package/lib/components/TextInputComponent.js +14 -0
- package/lib/components/UserSelectMenuComponent.d.ts +4 -0
- package/lib/components/UserSelectMenuComponent.js +7 -0
- package/lib/components/command.d.ts +23 -0
- package/lib/components/command.js +15 -0
- package/lib/components/handler.d.ts +48 -0
- package/lib/components/handler.js +231 -0
- package/lib/components/index.d.ts +20 -0
- package/lib/components/index.js +55 -0
- package/lib/components/listener.d.ts +11 -0
- package/lib/components/listener.js +18 -0
- package/lib/events/event.d.ts +23 -0
- package/lib/events/event.js +2 -0
- package/lib/events/handler.d.ts +19 -0
- package/lib/events/handler.js +112 -0
- package/lib/events/hooks/application_command.d.ts +12 -0
- package/lib/events/hooks/application_command.js +8 -0
- package/lib/events/hooks/auto_moderation.d.ts +22 -0
- package/lib/events/hooks/auto_moderation.js +21 -0
- package/lib/events/hooks/channel.d.ts +11 -0
- package/lib/events/hooks/channel.js +24 -0
- package/lib/events/hooks/custom.d.ts +4 -0
- package/lib/events/hooks/custom.js +11 -0
- package/lib/events/hooks/dispatch.d.ts +5 -0
- package/lib/events/hooks/dispatch.js +12 -0
- package/lib/events/hooks/entitlement.d.ts +35 -0
- package/lib/events/hooks/entitlement.js +16 -0
- package/lib/events/hooks/guild.d.ts +228 -0
- package/lib/events/hooks/guild.js +101 -0
- package/lib/events/hooks/index.d.ts +23 -0
- package/lib/events/hooks/index.js +34 -0
- package/lib/events/hooks/integration.d.ts +94 -0
- package/lib/events/hooks/integration.js +27 -0
- package/lib/events/hooks/interactions.d.ts +4 -0
- package/lib/events/hooks/interactions.js +8 -0
- package/lib/events/hooks/invite.d.ts +21 -0
- package/lib/events/hooks/invite.js +12 -0
- package/lib/events/hooks/message.d.ts +69 -0
- package/lib/events/hooks/message.js +37 -0
- package/lib/events/hooks/presence.d.ts +27 -0
- package/lib/events/hooks/presence.js +8 -0
- package/lib/events/hooks/stage.d.ts +29 -0
- package/lib/events/hooks/stage.js +16 -0
- package/lib/events/hooks/thread.d.ts +198 -0
- package/lib/events/hooks/thread.js +29 -0
- package/lib/events/hooks/typing.d.ts +16 -0
- package/lib/events/hooks/typing.js +14 -0
- package/lib/events/hooks/user.d.ts +4 -0
- package/lib/events/hooks/user.js +8 -0
- package/lib/events/hooks/voice.d.ts +37 -0
- package/lib/events/hooks/voice.js +18 -0
- package/lib/events/hooks/webhook.d.ts +6 -0
- package/lib/events/hooks/webhook.js +8 -0
- package/lib/events/index.d.ts +2 -0
- package/lib/events/index.js +18 -0
- package/lib/index.d.ts +79 -0
- package/lib/index.js +104 -0
- package/lib/langs/handler.d.ts +11 -0
- package/lib/langs/handler.js +34 -0
- package/lib/langs/index.d.ts +2 -0
- package/lib/langs/index.js +18 -0
- package/lib/langs/router.d.ts +18 -0
- package/lib/langs/router.js +42 -0
- package/lib/structures/AnonymousGuild.d.ts +7 -0
- package/lib/structures/AnonymousGuild.js +11 -0
- package/lib/structures/AutoModerationRule.d.ts +22 -0
- package/lib/structures/AutoModerationRule.js +34 -0
- package/lib/structures/ClientUser.d.ts +25 -0
- package/lib/structures/ClientUser.js +52 -0
- package/lib/structures/Guild.d.ts +86 -0
- package/lib/structures/Guild.js +66 -0
- package/lib/structures/GuildEmoji.d.ts +29 -0
- package/lib/structures/GuildEmoji.js +47 -0
- package/lib/structures/GuildMember.d.ts +92 -0
- package/lib/structures/GuildMember.js +137 -0
- package/lib/structures/GuildPreview.d.ts +10 -0
- package/lib/structures/GuildPreview.js +14 -0
- package/lib/structures/GuildRole.d.ts +21 -0
- package/lib/structures/GuildRole.js +32 -0
- package/lib/structures/GuildTemplate.d.ts +23 -0
- package/lib/structures/GuildTemplate.js +36 -0
- package/lib/structures/Interaction.d.ts +152 -0
- package/lib/structures/Interaction.js +409 -0
- package/lib/structures/Message.d.ts +53 -0
- package/lib/structures/Message.js +123 -0
- package/lib/structures/Sticker.d.ts +27 -0
- package/lib/structures/Sticker.js +44 -0
- package/lib/structures/User.d.ts +20 -0
- package/lib/structures/User.js +37 -0
- package/lib/structures/Webhook.d.ts +42 -0
- package/lib/structures/Webhook.js +63 -0
- package/lib/structures/channels.d.ts +232 -0
- package/lib/structures/channels.js +366 -0
- package/lib/structures/extra/Base.d.ts +7 -0
- package/lib/structures/extra/Base.js +39 -0
- package/lib/structures/extra/BaseComponent.d.ts +9 -0
- package/lib/structures/extra/BaseComponent.js +12 -0
- package/lib/structures/extra/BaseGuild.d.ts +40 -0
- package/lib/structures/extra/BaseGuild.js +71 -0
- package/lib/structures/extra/BaseSelectMenuComponent.d.ts +9 -0
- package/lib/structures/extra/BaseSelectMenuComponent.js +13 -0
- package/lib/structures/extra/BitField.d.ts +14 -0
- package/lib/structures/extra/BitField.js +56 -0
- package/lib/structures/extra/DiscordBase.d.ts +18 -0
- package/lib/structures/extra/DiscordBase.js +28 -0
- package/lib/structures/extra/Permissions.d.ts +54 -0
- package/lib/structures/extra/Permissions.js +9 -0
- package/lib/structures/extra/functions.d.ts +11 -0
- package/lib/structures/extra/functions.js +69 -0
- package/lib/structures/index.d.ts +15 -0
- package/lib/structures/index.js +31 -0
- package/lib/websocket/SharedTypes.d.ts +128 -0
- package/lib/websocket/SharedTypes.js +2 -0
- package/lib/websocket/constants/index.d.ts +26 -0
- package/lib/websocket/constants/index.js +31 -0
- package/lib/websocket/discord/basesocket.d.ts +12 -0
- package/lib/websocket/discord/basesocket.js +37 -0
- package/lib/websocket/discord/events/memberUpdate.d.ts +16 -0
- package/lib/websocket/discord/events/memberUpdate.js +47 -0
- package/lib/websocket/discord/events/presenceUpdate.d.ts +24 -0
- package/lib/websocket/discord/events/presenceUpdate.js +46 -0
- package/lib/websocket/discord/handlemessage.d.ts +0 -0
- package/lib/websocket/discord/handlemessage.js +1 -0
- package/lib/websocket/discord/index.d.ts +4 -0
- package/lib/websocket/discord/index.js +20 -0
- package/lib/websocket/discord/memberUpdate.d.ts +16 -0
- package/lib/websocket/discord/memberUpdate.js +47 -0
- package/lib/websocket/discord/shard.d.ts +46 -0
- package/lib/websocket/discord/shard.js +278 -0
- package/lib/websocket/discord/sharder.d.ts +25 -0
- package/lib/websocket/discord/sharder.js +153 -0
- package/lib/websocket/discord/shared.d.ts +99 -0
- package/lib/websocket/discord/shared.js +8 -0
- package/lib/websocket/discord/worker.d.ts +43 -0
- package/lib/websocket/discord/worker.js +2 -0
- package/lib/websocket/discord/workermanager.d.ts +69 -0
- package/lib/websocket/discord/workermanager.js +273 -0
- package/lib/websocket/index.d.ts +3 -0
- package/lib/websocket/index.js +19 -0
- package/lib/websocket/structures/index.d.ts +117 -0
- package/lib/websocket/structures/index.js +261 -0
- package/lib/websocket/structures/timeout.d.ts +20 -0
- package/lib/websocket/structures/timeout.js +75 -0
- package/package.json +70 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MentionableSelectMenuComponent = void 0;
|
|
4
|
+
const BaseSelectMenuComponent_1 = require("../structures/extra/BaseSelectMenuComponent");
|
|
5
|
+
class MentionableSelectMenuComponent extends BaseSelectMenuComponent_1.BaseSelectMenuComponent {
|
|
6
|
+
}
|
|
7
|
+
exports.MentionableSelectMenuComponent = MentionableSelectMenuComponent;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RoleSelectMenuComponent = void 0;
|
|
4
|
+
const BaseSelectMenuComponent_1 = require("../structures/extra/BaseSelectMenuComponent");
|
|
5
|
+
class RoleSelectMenuComponent extends BaseSelectMenuComponent_1.BaseSelectMenuComponent {
|
|
6
|
+
}
|
|
7
|
+
exports.RoleSelectMenuComponent = RoleSelectMenuComponent;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { APISelectMenuOption, APIStringSelectComponent, ComponentType } from '../common';
|
|
2
|
+
import { BaseSelectMenuComponent } from '../structures/extra/BaseSelectMenuComponent';
|
|
3
|
+
export declare class StringSelectMenuComponent extends BaseSelectMenuComponent<ComponentType.StringSelect> {
|
|
4
|
+
constructor(data: APIStringSelectComponent);
|
|
5
|
+
options: APISelectMenuOption[];
|
|
6
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StringSelectMenuComponent = void 0;
|
|
4
|
+
const BaseSelectMenuComponent_1 = require("../structures/extra/BaseSelectMenuComponent");
|
|
5
|
+
class StringSelectMenuComponent extends BaseSelectMenuComponent_1.BaseSelectMenuComponent {
|
|
6
|
+
constructor(data) {
|
|
7
|
+
super(data);
|
|
8
|
+
this.options = data.options;
|
|
9
|
+
}
|
|
10
|
+
options;
|
|
11
|
+
}
|
|
12
|
+
exports.StringSelectMenuComponent = StringSelectMenuComponent;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { APIModalComponent, APITextInputComponent, ComponentType } from '../common';
|
|
2
|
+
import { BaseComponent } from '../structures/extra/BaseComponent';
|
|
3
|
+
export declare class TextInputComponent extends BaseComponent<ComponentType.TextInput> {
|
|
4
|
+
constructor(data: APITextInputComponent);
|
|
5
|
+
customId: string;
|
|
6
|
+
value: string | APIModalComponent;
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TextInputComponent = void 0;
|
|
4
|
+
const BaseComponent_1 = require("../structures/extra/BaseComponent");
|
|
5
|
+
class TextInputComponent extends BaseComponent_1.BaseComponent {
|
|
6
|
+
constructor(data) {
|
|
7
|
+
super(data);
|
|
8
|
+
this.customId = data.custom_id;
|
|
9
|
+
this.value = data.value;
|
|
10
|
+
}
|
|
11
|
+
customId;
|
|
12
|
+
value;
|
|
13
|
+
}
|
|
14
|
+
exports.TextInputComponent = TextInputComponent;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserSelectMenuComponent = void 0;
|
|
4
|
+
const BaseSelectMenuComponent_1 = require("../structures/extra/BaseSelectMenuComponent");
|
|
5
|
+
class UserSelectMenuComponent extends BaseSelectMenuComponent_1.BaseSelectMenuComponent {
|
|
6
|
+
}
|
|
7
|
+
exports.UserSelectMenuComponent = UserSelectMenuComponent;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ComponentType } from 'discord-api-types/v10';
|
|
2
|
+
import type { ComponentInteraction, ModalSubmitInteraction, StringSelectMenuInteraction } from '../structures';
|
|
3
|
+
export declare const InteractionCommandType: {
|
|
4
|
+
readonly COMPONENT: 0;
|
|
5
|
+
readonly MODAL: 1;
|
|
6
|
+
};
|
|
7
|
+
export interface ComponentCommand {
|
|
8
|
+
__filePath?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare abstract class ComponentCommand {
|
|
11
|
+
type: 0;
|
|
12
|
+
abstract componentType: ComponentType;
|
|
13
|
+
abstract filter(interaction: ComponentInteraction | StringSelectMenuInteraction): Promise<boolean> | boolean;
|
|
14
|
+
abstract run(interaction: ComponentInteraction | StringSelectMenuInteraction): any;
|
|
15
|
+
}
|
|
16
|
+
export interface ModalCommand {
|
|
17
|
+
__filePath?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare abstract class ModalCommand {
|
|
20
|
+
type: 1;
|
|
21
|
+
abstract filter(interaction: ModalSubmitInteraction): Promise<boolean> | boolean;
|
|
22
|
+
abstract run(interaction: ModalSubmitInteraction): any;
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModalCommand = exports.ComponentCommand = exports.InteractionCommandType = void 0;
|
|
4
|
+
exports.InteractionCommandType = {
|
|
5
|
+
COMPONENT: 0,
|
|
6
|
+
MODAL: 1,
|
|
7
|
+
};
|
|
8
|
+
class ComponentCommand {
|
|
9
|
+
type = exports.InteractionCommandType.COMPONENT;
|
|
10
|
+
}
|
|
11
|
+
exports.ComponentCommand = ComponentCommand;
|
|
12
|
+
class ModalCommand {
|
|
13
|
+
type = exports.InteractionCommandType.MODAL;
|
|
14
|
+
}
|
|
15
|
+
exports.ModalCommand = ModalCommand;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { type BuilderComponents } from '../builders';
|
|
3
|
+
import type { ComponentCallback, ModalSubmitCallback } from '../builders/types';
|
|
4
|
+
import type { BaseClient } from '../client/base';
|
|
5
|
+
import { LimitedCollection } from '../collection';
|
|
6
|
+
import { BaseHandler, type OnFailCallback, type APIMessage, type APIModalInteractionResponseCallbackData, type Logger } from '../common';
|
|
7
|
+
import type { InteractionMessageUpdateBodyRequest, MessageCreateBodyRequest, MessageUpdateBodyRequest, ModalCreateBodyRequest, ResolverProps } from '../common/types/write';
|
|
8
|
+
import type { ComponentInteraction, ModalSubmitInteraction, ReplyInteractionBody } from '../structures';
|
|
9
|
+
import { ComponentCommand, ModalCommand } from './command';
|
|
10
|
+
import { ComponentsListener } from './listener';
|
|
11
|
+
type COMPONENTS = {
|
|
12
|
+
buttons: Partial<Record<string, {
|
|
13
|
+
callback: ComponentCallback;
|
|
14
|
+
}>>;
|
|
15
|
+
listener: ComponentsListener<BuilderComponents>;
|
|
16
|
+
messageId?: string;
|
|
17
|
+
idle?: NodeJS.Timeout;
|
|
18
|
+
timeout?: NodeJS.Timeout;
|
|
19
|
+
};
|
|
20
|
+
export declare class ComponentHandler extends BaseHandler {
|
|
21
|
+
protected client: BaseClient;
|
|
22
|
+
protected onFail?: OnFailCallback;
|
|
23
|
+
readonly values: Map<string, COMPONENTS>;
|
|
24
|
+
readonly modals: LimitedCollection<string, ModalSubmitCallback>;
|
|
25
|
+
readonly commands: (ComponentCommand | ModalCommand)[];
|
|
26
|
+
protected filter: (path: string) => boolean;
|
|
27
|
+
constructor(logger: Logger, client: BaseClient);
|
|
28
|
+
set OnFail(cb: OnFailCallback);
|
|
29
|
+
hasComponent(id: string, customId: string): boolean;
|
|
30
|
+
onComponent(id: string, interaction: ComponentInteraction): Promise<void>;
|
|
31
|
+
resetTimeouts(id: string): void;
|
|
32
|
+
hasModal(interaction: ModalSubmitInteraction): boolean;
|
|
33
|
+
onModalSubmit(interaction: ModalSubmitInteraction): any;
|
|
34
|
+
__setComponents(id: string, record: NonNullable<ResolverProps['components']>): void;
|
|
35
|
+
protected __setModal(id: string, record: APIModalInteractionResponseCallbackData | ModalCreateBodyRequest): void;
|
|
36
|
+
deleteValue(id: string, reason?: string): void;
|
|
37
|
+
onRequestInteraction(interactionId: string, interaction: ReplyInteractionBody): void;
|
|
38
|
+
onMessageDelete(id: string): void;
|
|
39
|
+
onRequestMessage(body: MessageCreateBodyRequest, message: APIMessage): void;
|
|
40
|
+
onRequestInteractionUpdate(body: InteractionMessageUpdateBodyRequest, message: APIMessage): void;
|
|
41
|
+
onRequestUpdateMessage(body: MessageUpdateBodyRequest, message: APIMessage): void;
|
|
42
|
+
load(componentsDir: string): Promise<void>;
|
|
43
|
+
reload(path: string): Promise<any>;
|
|
44
|
+
reloadAll(): Promise<void>;
|
|
45
|
+
executeComponent(interaction: ComponentInteraction): Promise<void>;
|
|
46
|
+
executeModal(interaction: ModalSubmitInteraction): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComponentHandler = void 0;
|
|
4
|
+
const builders_1 = require("../builders");
|
|
5
|
+
const collection_1 = require("../collection");
|
|
6
|
+
const common_1 = require("../common");
|
|
7
|
+
const command_1 = require("./command");
|
|
8
|
+
const listener_1 = require("./listener");
|
|
9
|
+
class ComponentHandler extends common_1.BaseHandler {
|
|
10
|
+
client;
|
|
11
|
+
onFail;
|
|
12
|
+
values = new Map();
|
|
13
|
+
// 10 minutes timeout, because discord dont send an event when the user cancel the modal
|
|
14
|
+
modals = new collection_1.LimitedCollection({ expire: 60e3 * 10 });
|
|
15
|
+
commands = [];
|
|
16
|
+
filter = (path) => path.endsWith('.js') || path.endsWith('.ts');
|
|
17
|
+
constructor(logger, client) {
|
|
18
|
+
super(logger);
|
|
19
|
+
this.client = client;
|
|
20
|
+
}
|
|
21
|
+
set OnFail(cb) {
|
|
22
|
+
this.onFail = cb;
|
|
23
|
+
}
|
|
24
|
+
hasComponent(id, customId) {
|
|
25
|
+
return !!this.values.get(id)?.buttons?.[customId];
|
|
26
|
+
}
|
|
27
|
+
async onComponent(id, interaction) {
|
|
28
|
+
const row = this.values.get(id);
|
|
29
|
+
const component = row?.buttons?.[interaction.customId];
|
|
30
|
+
if (!component)
|
|
31
|
+
return;
|
|
32
|
+
if (row.listener.options?.filter) {
|
|
33
|
+
if (!(await row.listener.options.filter(interaction)))
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
row.idle?.refresh();
|
|
37
|
+
await component.callback(interaction, reason => {
|
|
38
|
+
row.listener.options?.onStop?.(reason ?? 'stop');
|
|
39
|
+
this.deleteValue(id);
|
|
40
|
+
}, () => {
|
|
41
|
+
this.resetTimeouts(id);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
resetTimeouts(id) {
|
|
45
|
+
const listener = this.values.get(id);
|
|
46
|
+
if (listener) {
|
|
47
|
+
listener.timeout?.refresh();
|
|
48
|
+
listener.idle?.refresh();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
hasModal(interaction) {
|
|
52
|
+
return this.modals.has(interaction.user.id);
|
|
53
|
+
}
|
|
54
|
+
onModalSubmit(interaction) {
|
|
55
|
+
setImmediate(() => this.modals.delete(interaction.user.id));
|
|
56
|
+
return this.modals.get(interaction.user.id)?.(interaction);
|
|
57
|
+
}
|
|
58
|
+
__setComponents(id, record) {
|
|
59
|
+
this.deleteValue(id);
|
|
60
|
+
if (!(record instanceof listener_1.ComponentsListener))
|
|
61
|
+
return;
|
|
62
|
+
const components = {
|
|
63
|
+
buttons: {},
|
|
64
|
+
listener: record,
|
|
65
|
+
};
|
|
66
|
+
if ((record.options.idle ?? -1) > 0) {
|
|
67
|
+
components.idle = setTimeout(() => {
|
|
68
|
+
clearTimeout(components.timeout);
|
|
69
|
+
clearTimeout(components.idle);
|
|
70
|
+
record.options?.onStop?.('idle', () => {
|
|
71
|
+
this.__setComponents(id, record);
|
|
72
|
+
});
|
|
73
|
+
this.values.delete(id);
|
|
74
|
+
}, record.options.idle);
|
|
75
|
+
}
|
|
76
|
+
if ((record.options.timeout ?? -1) > 0) {
|
|
77
|
+
components.timeout = setTimeout(() => {
|
|
78
|
+
clearTimeout(components.timeout);
|
|
79
|
+
clearTimeout(components.idle);
|
|
80
|
+
record.options?.onStop?.('timeout', () => {
|
|
81
|
+
this.__setComponents(id, record);
|
|
82
|
+
});
|
|
83
|
+
this.values.delete(id);
|
|
84
|
+
}, record.options.timeout);
|
|
85
|
+
}
|
|
86
|
+
for (const actionRow of record.components) {
|
|
87
|
+
for (const child of actionRow.components) {
|
|
88
|
+
if ((child instanceof builders_1.SelectMenu || child instanceof builders_1.Button) && 'custom_id' in child.data) {
|
|
89
|
+
components.buttons[child.data.custom_id] = {
|
|
90
|
+
callback: child.__exec,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (Object.entries(components.buttons).length) {
|
|
96
|
+
this.values.set(id, components);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
__setModal(id, record) {
|
|
100
|
+
if ('__exec' in record) {
|
|
101
|
+
this.modals.set(id, record.__exec);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
deleteValue(id, reason) {
|
|
105
|
+
const component = this.values.get(id);
|
|
106
|
+
if (component) {
|
|
107
|
+
if (reason !== undefined)
|
|
108
|
+
component.listener.options.onStop?.(reason);
|
|
109
|
+
clearTimeout(component.timeout);
|
|
110
|
+
clearTimeout(component.idle);
|
|
111
|
+
this.values.delete(id);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
onRequestInteraction(interactionId, interaction) {
|
|
115
|
+
// @ts-expect-error dapi
|
|
116
|
+
if (!interaction.data) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
switch (interaction.type) {
|
|
120
|
+
case common_1.InteractionResponseType.ChannelMessageWithSource:
|
|
121
|
+
case common_1.InteractionResponseType.UpdateMessage:
|
|
122
|
+
if (!interaction.data.components)
|
|
123
|
+
return;
|
|
124
|
+
this.__setComponents(interactionId, interaction.data.components);
|
|
125
|
+
break;
|
|
126
|
+
case common_1.InteractionResponseType.Modal:
|
|
127
|
+
if (!(interaction.data instanceof builders_1.Modal))
|
|
128
|
+
return;
|
|
129
|
+
this.__setModal(interactionId, interaction.data);
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
onMessageDelete(id) {
|
|
134
|
+
this.deleteValue(id, 'messageDelete');
|
|
135
|
+
}
|
|
136
|
+
onRequestMessage(body, message) {
|
|
137
|
+
if (!body.components) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
this.__setComponents(message.id, body.components);
|
|
141
|
+
}
|
|
142
|
+
onRequestInteractionUpdate(body, message) {
|
|
143
|
+
if (!body.components) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
this.__setComponents(message.interaction.id, body.components);
|
|
147
|
+
}
|
|
148
|
+
onRequestUpdateMessage(body, message) {
|
|
149
|
+
if (!body.components)
|
|
150
|
+
return;
|
|
151
|
+
this.__setComponents(message.id, body.components);
|
|
152
|
+
}
|
|
153
|
+
async load(componentsDir) {
|
|
154
|
+
const paths = await this.loadFilesK(await this.getFiles(componentsDir));
|
|
155
|
+
for (let i = 0; i < paths.length; i++) {
|
|
156
|
+
let component;
|
|
157
|
+
try {
|
|
158
|
+
component = new paths[i].file();
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
if (e instanceof Error && e.message === 'paths[i].file is not a constructor') {
|
|
162
|
+
this.logger.warn(`${paths[i].path
|
|
163
|
+
.split(process.cwd())
|
|
164
|
+
.slice(1)
|
|
165
|
+
.join(process.cwd())} doesn't export the class by \`export default <ComponentCommand>\``);
|
|
166
|
+
}
|
|
167
|
+
else
|
|
168
|
+
this.logger.warn(e, paths[i]);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (!(component instanceof command_1.ModalCommand) && !(component instanceof command_1.ComponentCommand))
|
|
172
|
+
continue;
|
|
173
|
+
component.__filePath = paths[i].path;
|
|
174
|
+
this.commands.push(component);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
async reload(path) {
|
|
178
|
+
const component = this.client.components.commands.find(x => x.__filePath?.endsWith(`${path}.js`) ||
|
|
179
|
+
x.__filePath?.endsWith(`${path}.ts`) ||
|
|
180
|
+
x.__filePath?.endsWith(path) ||
|
|
181
|
+
x.__filePath === path);
|
|
182
|
+
if (!component || !component.__filePath)
|
|
183
|
+
return null;
|
|
184
|
+
delete require.cache[component.__filePath];
|
|
185
|
+
const index = this.client.components.commands.findIndex(x => x.__filePath === component.__filePath);
|
|
186
|
+
if (index === -1)
|
|
187
|
+
return null;
|
|
188
|
+
this.client.components.commands.splice(index, 1);
|
|
189
|
+
const imported = await (0, common_1.magicImport)(component.__filePath).then(x => x.default ?? x);
|
|
190
|
+
const command = new imported();
|
|
191
|
+
command.__filePath = component.__filePath;
|
|
192
|
+
this.client.components.commands.push(command);
|
|
193
|
+
return imported;
|
|
194
|
+
}
|
|
195
|
+
async reloadAll() {
|
|
196
|
+
for (const i of this.client.components.commands) {
|
|
197
|
+
if (!i.__filePath)
|
|
198
|
+
return this.logger.warn('Unknown command dont have __filePath property', i);
|
|
199
|
+
await this.reload(i.__filePath);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
async executeComponent(interaction) {
|
|
203
|
+
for (const i of this.commands) {
|
|
204
|
+
try {
|
|
205
|
+
if (i.type === command_1.InteractionCommandType.COMPONENT &&
|
|
206
|
+
i.componentType === interaction.componentType &&
|
|
207
|
+
(await i.filter(interaction))) {
|
|
208
|
+
await i.run(interaction);
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
catch (e) {
|
|
213
|
+
await this.onFail?.(e);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
async executeModal(interaction) {
|
|
218
|
+
for (const i of this.commands) {
|
|
219
|
+
try {
|
|
220
|
+
if (i.type === command_1.InteractionCommandType.MODAL && (await i.filter(interaction))) {
|
|
221
|
+
await i.run(interaction);
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch (e) {
|
|
226
|
+
await this.onFail?.(e);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
exports.ComponentHandler = ComponentHandler;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { APIMessageActionRowComponent } from '../common';
|
|
2
|
+
import { BaseComponent } from '../structures/extra/BaseComponent';
|
|
3
|
+
import { ButtonComponent, LinkButtonComponent } from './ButtonComponent';
|
|
4
|
+
import { ChannelSelectMenuComponent } from './ChannelSelectMenuComponent';
|
|
5
|
+
import { MentionableSelectMenuComponent } from './MentionableSelectMenuComponent';
|
|
6
|
+
import { RoleSelectMenuComponent } from './RoleSelectMenuComponent';
|
|
7
|
+
import { StringSelectMenuComponent } from './StringSelectMenuComponent';
|
|
8
|
+
import type { TextInputComponent } from './TextInputComponent';
|
|
9
|
+
import { UserSelectMenuComponent } from './UserSelectMenuComponent';
|
|
10
|
+
export type MessageComponents = ButtonComponent | LinkButtonComponent | RoleSelectMenuComponent | UserSelectMenuComponent | StringSelectMenuComponent | ChannelSelectMenuComponent | MentionableSelectMenuComponent | TextInputComponent;
|
|
11
|
+
export type ActionRowMessageComponents = Exclude<MessageComponents, TextInputComponent>;
|
|
12
|
+
export * from './command';
|
|
13
|
+
export * from './listener';
|
|
14
|
+
/**
|
|
15
|
+
* Return a new component instance based on the component type.
|
|
16
|
+
*
|
|
17
|
+
* @param component The component to create.
|
|
18
|
+
* @returns The component instance.
|
|
19
|
+
*/
|
|
20
|
+
export declare function componentFactory(component: APIMessageActionRowComponent): ActionRowMessageComponents | BaseComponent<ActionRowMessageComponents['type']>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.componentFactory = void 0;
|
|
18
|
+
const common_1 = require("../common");
|
|
19
|
+
const BaseComponent_1 = require("../structures/extra/BaseComponent");
|
|
20
|
+
const ButtonComponent_1 = require("./ButtonComponent");
|
|
21
|
+
const ChannelSelectMenuComponent_1 = require("./ChannelSelectMenuComponent");
|
|
22
|
+
const MentionableSelectMenuComponent_1 = require("./MentionableSelectMenuComponent");
|
|
23
|
+
const RoleSelectMenuComponent_1 = require("./RoleSelectMenuComponent");
|
|
24
|
+
const StringSelectMenuComponent_1 = require("./StringSelectMenuComponent");
|
|
25
|
+
const UserSelectMenuComponent_1 = require("./UserSelectMenuComponent");
|
|
26
|
+
__exportStar(require("./command"), exports);
|
|
27
|
+
__exportStar(require("./listener"), exports);
|
|
28
|
+
/**
|
|
29
|
+
* Return a new component instance based on the component type.
|
|
30
|
+
*
|
|
31
|
+
* @param component The component to create.
|
|
32
|
+
* @returns The component instance.
|
|
33
|
+
*/
|
|
34
|
+
function componentFactory(component) {
|
|
35
|
+
switch (component.type) {
|
|
36
|
+
case common_1.ComponentType.Button:
|
|
37
|
+
if (component.style === common_1.ButtonStyle.Link) {
|
|
38
|
+
return new ButtonComponent_1.LinkButtonComponent(component);
|
|
39
|
+
}
|
|
40
|
+
return new ButtonComponent_1.ButtonComponent(component);
|
|
41
|
+
case common_1.ComponentType.ChannelSelect:
|
|
42
|
+
return new ChannelSelectMenuComponent_1.ChannelSelectMenuComponent(component);
|
|
43
|
+
case common_1.ComponentType.RoleSelect:
|
|
44
|
+
return new RoleSelectMenuComponent_1.RoleSelectMenuComponent(component);
|
|
45
|
+
case common_1.ComponentType.StringSelect:
|
|
46
|
+
return new StringSelectMenuComponent_1.StringSelectMenuComponent(component);
|
|
47
|
+
case common_1.ComponentType.UserSelect:
|
|
48
|
+
return new UserSelectMenuComponent_1.UserSelectMenuComponent(component);
|
|
49
|
+
case common_1.ComponentType.MentionableSelect:
|
|
50
|
+
return new MentionableSelectMenuComponent_1.MentionableSelectMenuComponent(component);
|
|
51
|
+
default:
|
|
52
|
+
return new BaseComponent_1.BaseComponent(component);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.componentFactory = componentFactory;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { ActionRow, BuilderComponents, ListenerOptions } from '../builders';
|
|
3
|
+
import { type RestOrArray } from '../common';
|
|
4
|
+
export declare class ComponentsListener<T extends BuilderComponents> {
|
|
5
|
+
readonly options: ListenerOptions;
|
|
6
|
+
components: ActionRow<T>[];
|
|
7
|
+
idle?: NodeJS.Timeout;
|
|
8
|
+
timeout?: NodeJS.Timeout;
|
|
9
|
+
constructor(options: ListenerOptions);
|
|
10
|
+
addRows(...row: RestOrArray<ActionRow<T>>): this;
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComponentsListener = void 0;
|
|
4
|
+
const common_1 = require("../common");
|
|
5
|
+
class ComponentsListener {
|
|
6
|
+
options;
|
|
7
|
+
components = [];
|
|
8
|
+
idle;
|
|
9
|
+
timeout;
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.options = options;
|
|
12
|
+
}
|
|
13
|
+
addRows(...row) {
|
|
14
|
+
this.components = this.components.concat((0, common_1.fastFlat)(row));
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.ComponentsListener = ComponentsListener;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { UsingClient } from '../commands';
|
|
2
|
+
import type { ClientEvents } from './hooks';
|
|
3
|
+
export interface DeclareEventsOptions {
|
|
4
|
+
name: `${keyof ClientEvents}`;
|
|
5
|
+
once?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type ClientNameEvents = Extract<keyof ClientEvents, string>;
|
|
8
|
+
export interface ClientDataEvent {
|
|
9
|
+
name: ClientNameEvents;
|
|
10
|
+
once: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type Handler = {
|
|
13
|
+
[K in keyof ClientEvents]: (...data: [Awaited<ClientEvents[K]>, UsingClient, number]) => unknown;
|
|
14
|
+
};
|
|
15
|
+
export type EventContext<T extends {
|
|
16
|
+
data: {
|
|
17
|
+
name: ClientNameEvents;
|
|
18
|
+
};
|
|
19
|
+
}> = Parameters<Handler[T['data']['name']]>;
|
|
20
|
+
export interface ClientEvent {
|
|
21
|
+
data: ClientDataEvent;
|
|
22
|
+
run(...args: EventContext<any>): any;
|
|
23
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Client, WorkerClient } from '../client';
|
|
2
|
+
import { BaseHandler, type OnFailCallback, type GatewayDispatchPayload, type MakeRequired, type SnakeCase } from '../common';
|
|
3
|
+
import type { ClientEvents } from '../events/hooks';
|
|
4
|
+
import type { ClientEvent, ClientNameEvents } from './event';
|
|
5
|
+
type EventValue = MakeRequired<ClientEvent, '__filePath'> & {
|
|
6
|
+
fired?: boolean;
|
|
7
|
+
};
|
|
8
|
+
type GatewayEvents = Uppercase<SnakeCase<keyof ClientEvents>>;
|
|
9
|
+
export declare class EventHandler extends BaseHandler {
|
|
10
|
+
protected onFail?: OnFailCallback;
|
|
11
|
+
protected filter: (path: string) => boolean;
|
|
12
|
+
values: Partial<Record<GatewayEvents, EventValue>>;
|
|
13
|
+
set OnFail(cb: OnFailCallback);
|
|
14
|
+
load(eventsDir: string): Promise<void>;
|
|
15
|
+
execute(name: GatewayEvents, ...args: [GatewayDispatchPayload, Client<true> | WorkerClient<true>, number]): Promise<void>;
|
|
16
|
+
reload(name: ClientNameEvents): Promise<any>;
|
|
17
|
+
reloadAll(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|