@buape/carbon 0.13.0 → 0.15.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 +1 -1
- package/dist/package.json +12 -8
- package/dist/src/abstracts/BaseCommand.d.ts +19 -3
- package/dist/src/abstracts/BaseCommand.d.ts.map +1 -1
- package/dist/src/abstracts/BaseCommand.js +55 -3
- package/dist/src/abstracts/BaseCommand.js.map +1 -1
- package/dist/src/abstracts/BaseComponent.d.ts +2 -2
- package/dist/src/abstracts/BaseComponent.d.ts.map +1 -1
- package/dist/src/abstracts/BaseInteraction.d.ts +52 -0
- package/dist/src/abstracts/BaseInteraction.d.ts.map +1 -1
- package/dist/src/abstracts/BaseInteraction.js +43 -5
- package/dist/src/abstracts/BaseInteraction.js.map +1 -1
- package/dist/src/abstracts/BaseListener.d.ts +7 -4
- package/dist/src/abstracts/BaseListener.d.ts.map +1 -1
- package/dist/src/abstracts/BaseListener.js.map +1 -1
- package/dist/src/abstracts/BaseModalComponent.d.ts +3 -10
- package/dist/src/abstracts/BaseModalComponent.d.ts.map +1 -1
- package/dist/src/abstracts/BaseModalComponent.js.map +1 -1
- package/dist/src/abstracts/Plugin.d.ts +6 -0
- package/dist/src/abstracts/Plugin.d.ts.map +1 -1
- package/dist/src/abstracts/Plugin.js.map +1 -1
- package/dist/src/adapters/bun/index.d.ts +2 -2
- package/dist/src/adapters/bun/index.d.ts.map +1 -1
- package/dist/src/adapters/bun/index.js +6 -0
- package/dist/src/adapters/bun/index.js.map +1 -1
- package/dist/src/adapters/fetch/index.d.ts.map +1 -1
- package/dist/src/adapters/fetch/index.js +6 -0
- package/dist/src/adapters/fetch/index.js.map +1 -1
- package/dist/src/classes/Client.d.ts +111 -9
- package/dist/src/classes/Client.d.ts.map +1 -1
- package/dist/src/classes/Client.js +237 -23
- package/dist/src/classes/Client.js.map +1 -1
- package/dist/src/classes/EntryPointCommand.d.ts +11 -0
- package/dist/src/classes/EntryPointCommand.d.ts.map +1 -0
- package/dist/src/classes/EntryPointCommand.js +13 -0
- package/dist/src/classes/EntryPointCommand.js.map +1 -0
- package/dist/src/classes/Listener.d.ts +85 -83
- package/dist/src/classes/Listener.d.ts.map +1 -1
- package/dist/src/classes/Listener.js +14 -0
- package/dist/src/classes/Listener.js.map +1 -1
- package/dist/src/classes/Modal.d.ts +2 -3
- package/dist/src/classes/Modal.d.ts.map +1 -1
- package/dist/src/classes/Modal.js.map +1 -1
- package/dist/src/classes/RequestClient.d.ts +99 -8
- package/dist/src/classes/RequestClient.d.ts.map +1 -1
- package/dist/src/classes/RequestClient.js +406 -137
- package/dist/src/classes/RequestClient.js.map +1 -1
- package/dist/src/classes/components/Checkbox.d.ts +12 -0
- package/dist/src/classes/components/Checkbox.d.ts.map +1 -0
- package/dist/src/classes/components/Checkbox.js +20 -0
- package/dist/src/classes/components/Checkbox.js.map +1 -0
- package/dist/src/classes/components/CheckboxGroup.d.ts +24 -0
- package/dist/src/classes/components/CheckboxGroup.d.ts.map +1 -0
- package/dist/src/classes/components/CheckboxGroup.js +37 -0
- package/dist/src/classes/components/CheckboxGroup.js.map +1 -0
- package/dist/src/classes/components/Container.d.ts +6 -2
- package/dist/src/classes/components/Container.d.ts.map +1 -1
- package/dist/src/classes/components/Container.js +11 -0
- package/dist/src/classes/components/Container.js.map +1 -1
- package/dist/src/classes/components/File.d.ts +2 -2
- package/dist/src/classes/components/File.d.ts.map +1 -1
- package/dist/src/classes/components/File.js +4 -1
- package/dist/src/classes/components/File.js.map +1 -1
- package/dist/src/classes/components/FileUpload.d.ts +3 -2
- package/dist/src/classes/components/FileUpload.d.ts.map +1 -1
- package/dist/src/classes/components/FileUpload.js +2 -2
- package/dist/src/classes/components/FileUpload.js.map +1 -1
- package/dist/src/classes/components/Label.d.ts +9 -5
- package/dist/src/classes/components/Label.d.ts.map +1 -1
- package/dist/src/classes/components/Label.js +1 -2
- package/dist/src/classes/components/Label.js.map +1 -1
- package/dist/src/classes/components/MediaGallery.d.ts +8 -13
- package/dist/src/classes/components/MediaGallery.d.ts.map +1 -1
- package/dist/src/classes/components/MediaGallery.js +5 -0
- package/dist/src/classes/components/MediaGallery.js.map +1 -1
- package/dist/src/classes/components/RadioGroup.d.ts +24 -0
- package/dist/src/classes/components/RadioGroup.d.ts.map +1 -0
- package/dist/src/classes/components/RadioGroup.js +33 -0
- package/dist/src/classes/components/RadioGroup.js.map +1 -0
- package/dist/src/classes/components/Row.d.ts.map +1 -1
- package/dist/src/classes/components/Row.js +2 -3
- package/dist/src/classes/components/Row.js.map +1 -1
- package/dist/src/classes/components/Section.d.ts +4 -3
- package/dist/src/classes/components/Section.d.ts.map +1 -1
- package/dist/src/classes/components/Section.js +22 -0
- package/dist/src/classes/components/Section.js.map +1 -1
- package/dist/src/classes/components/TextDisplay.d.ts +2 -2
- package/dist/src/classes/components/TextDisplay.d.ts.map +1 -1
- package/dist/src/classes/components/TextDisplay.js +3 -0
- package/dist/src/classes/components/TextDisplay.js.map +1 -1
- package/dist/src/classes/components/Thumbnail.d.ts +3 -2
- package/dist/src/classes/components/Thumbnail.d.ts.map +1 -1
- package/dist/src/classes/components/Thumbnail.js +11 -0
- package/dist/src/classes/components/Thumbnail.js.map +1 -1
- package/dist/src/errors/RatelimitError.d.ts +4 -1
- package/dist/src/errors/RatelimitError.d.ts.map +1 -1
- package/dist/src/errors/RatelimitError.js +7 -1
- package/dist/src/errors/RatelimitError.js.map +1 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/internals/AutocompleteInteraction.d.ts +1 -1
- package/dist/src/internals/AutocompleteInteraction.d.ts.map +1 -1
- package/dist/src/internals/BoundedExecutor.d.ts +12 -0
- package/dist/src/internals/BoundedExecutor.d.ts.map +1 -0
- package/dist/src/internals/BoundedExecutor.js +60 -0
- package/dist/src/internals/BoundedExecutor.js.map +1 -0
- package/dist/src/internals/CommandHandler.d.ts.map +1 -1
- package/dist/src/internals/CommandHandler.js +53 -6
- package/dist/src/internals/CommandHandler.js.map +1 -1
- package/dist/src/internals/CommandInteraction.d.ts +4 -0
- package/dist/src/internals/CommandInteraction.d.ts.map +1 -1
- package/dist/src/internals/CommandInteraction.js +30 -0
- package/dist/src/internals/CommandInteraction.js.map +1 -1
- package/dist/src/internals/ComponentHandler.d.ts +5 -10
- package/dist/src/internals/ComponentHandler.d.ts.map +1 -1
- package/dist/src/internals/ComponentHandler.js +53 -38
- package/dist/src/internals/ComponentHandler.js.map +1 -1
- package/dist/src/internals/EmojiHandler.d.ts.map +1 -1
- package/dist/src/internals/EmojiHandler.js +0 -1
- package/dist/src/internals/EmojiHandler.js.map +1 -1
- package/dist/src/internals/EventHandler.d.ts +28 -2
- package/dist/src/internals/EventHandler.d.ts.map +1 -1
- package/dist/src/internals/EventHandler.js +14 -11
- package/dist/src/internals/EventHandler.js.map +1 -1
- package/dist/src/internals/EventQueue.d.ts +90 -0
- package/dist/src/internals/EventQueue.d.ts.map +1 -0
- package/dist/src/internals/EventQueue.js +363 -0
- package/dist/src/internals/EventQueue.js.map +1 -0
- package/dist/src/internals/FieldsHandler.d.ts.map +1 -1
- package/dist/src/internals/FieldsHandler.js +10 -1
- package/dist/src/internals/FieldsHandler.js.map +1 -1
- package/dist/src/internals/OptionsHandler.d.ts +9 -1
- package/dist/src/internals/OptionsHandler.d.ts.map +1 -1
- package/dist/src/internals/OptionsHandler.js +20 -1
- package/dist/src/internals/OptionsHandler.js.map +1 -1
- package/dist/src/internals/RequestBody.d.ts +6 -0
- package/dist/src/internals/RequestBody.d.ts.map +1 -0
- package/dist/src/internals/RequestBody.js +74 -0
- package/dist/src/internals/RequestBody.js.map +1 -0
- package/dist/src/internals/RequestScheduler.d.ts +131 -0
- package/dist/src/internals/RequestScheduler.d.ts.map +1 -0
- package/dist/src/internals/RequestScheduler.js +245 -0
- package/dist/src/internals/RequestScheduler.js.map +1 -0
- package/dist/src/internals/TemporaryListenerManager.d.ts +20 -0
- package/dist/src/internals/TemporaryListenerManager.d.ts.map +1 -0
- package/dist/src/internals/TemporaryListenerManager.js +59 -0
- package/dist/src/internals/TemporaryListenerManager.js.map +1 -0
- package/dist/src/permissions.d.ts +1 -0
- package/dist/src/permissions.d.ts.map +1 -1
- package/dist/src/plugins/client-manager/ClientManager.d.ts +30 -2
- package/dist/src/plugins/client-manager/ClientManager.d.ts.map +1 -1
- package/dist/src/plugins/client-manager/ClientManager.js +93 -16
- package/dist/src/plugins/client-manager/ClientManager.js.map +1 -1
- package/dist/src/plugins/cloudflare-gateway/CloudflareGatewayDurableObject.d.ts +43 -0
- package/dist/src/plugins/cloudflare-gateway/CloudflareGatewayDurableObject.d.ts.map +1 -0
- package/dist/src/plugins/cloudflare-gateway/CloudflareGatewayDurableObject.js +210 -0
- package/dist/src/plugins/cloudflare-gateway/CloudflareGatewayDurableObject.js.map +1 -0
- package/dist/src/plugins/cloudflare-gateway/CloudflareGatewayPlugin.d.ts +16 -0
- package/dist/src/plugins/cloudflare-gateway/CloudflareGatewayPlugin.d.ts.map +1 -0
- package/dist/src/plugins/cloudflare-gateway/CloudflareGatewayPlugin.js +129 -0
- package/dist/src/plugins/cloudflare-gateway/CloudflareGatewayPlugin.js.map +1 -0
- package/dist/src/plugins/cloudflare-gateway/index.d.ts +4 -0
- package/dist/src/plugins/cloudflare-gateway/index.d.ts.map +1 -0
- package/dist/src/plugins/cloudflare-gateway/index.js +4 -0
- package/dist/src/plugins/cloudflare-gateway/index.js.map +1 -0
- package/dist/src/plugins/cloudflare-gateway/types.d.ts +63 -0
- package/dist/src/plugins/cloudflare-gateway/types.d.ts.map +1 -0
- package/dist/src/plugins/cloudflare-gateway/types.js +2 -0
- package/dist/src/plugins/cloudflare-gateway/types.js.map +1 -0
- package/dist/src/plugins/gateway/BabyCache.d.ts +13 -4
- package/dist/src/plugins/gateway/BabyCache.d.ts.map +1 -1
- package/dist/src/plugins/gateway/BabyCache.js +47 -0
- package/dist/src/plugins/gateway/BabyCache.js.map +1 -1
- package/dist/src/plugins/gateway/GatewayPlugin.d.ts +111 -19
- package/dist/src/plugins/gateway/GatewayPlugin.d.ts.map +1 -1
- package/dist/src/plugins/gateway/GatewayPlugin.js +605 -234
- package/dist/src/plugins/gateway/GatewayPlugin.js.map +1 -1
- package/dist/src/plugins/gateway/types.d.ts +33 -1
- package/dist/src/plugins/gateway/types.d.ts.map +1 -1
- package/dist/src/plugins/gateway/types.js +21 -0
- package/dist/src/plugins/gateway/types.js.map +1 -1
- package/dist/src/plugins/gateway/utils/heartbeat.d.ts +1 -0
- package/dist/src/plugins/gateway/utils/heartbeat.d.ts.map +1 -1
- package/dist/src/plugins/gateway/utils/heartbeat.js +23 -12
- package/dist/src/plugins/gateway/utils/heartbeat.js.map +1 -1
- package/dist/src/plugins/gateway/utils/payload.d.ts.map +1 -1
- package/dist/src/plugins/gateway/utils/payload.js +0 -4
- package/dist/src/plugins/gateway/utils/payload.js.map +1 -1
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.d.ts +56 -3
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.d.ts.map +1 -1
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.js +224 -17
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.js.map +1 -1
- package/dist/src/plugins/paginator/index.d.ts +1 -1
- package/dist/src/plugins/paginator/index.d.ts.map +1 -1
- package/dist/src/plugins/paginator/index.js +1 -1
- package/dist/src/plugins/paginator/index.js.map +1 -1
- package/dist/src/plugins/voice/GuildDeleteListener.d.ts +7 -0
- package/dist/src/plugins/voice/GuildDeleteListener.d.ts.map +1 -0
- package/dist/src/plugins/voice/GuildDeleteListener.js +11 -0
- package/dist/src/plugins/voice/GuildDeleteListener.js.map +1 -0
- package/dist/src/plugins/voice/VoicePlugin.d.ts +15 -0
- package/dist/src/plugins/voice/VoicePlugin.d.ts.map +1 -0
- package/dist/src/plugins/voice/VoicePlugin.js +58 -0
- package/dist/src/plugins/voice/VoicePlugin.js.map +1 -0
- package/dist/src/plugins/voice/VoiceServerUpdateListener.d.ts +10 -0
- package/dist/src/plugins/voice/VoiceServerUpdateListener.d.ts.map +1 -0
- package/dist/src/plugins/voice/VoiceServerUpdateListener.js +16 -0
- package/dist/src/plugins/voice/VoiceServerUpdateListener.js.map +1 -0
- package/dist/src/plugins/voice/VoiceStateUpdateListener.d.ts +10 -0
- package/dist/src/plugins/voice/VoiceStateUpdateListener.d.ts.map +1 -0
- package/dist/src/plugins/voice/VoiceStateUpdateListener.js +21 -0
- package/dist/src/plugins/voice/VoiceStateUpdateListener.js.map +1 -0
- package/dist/src/plugins/voice/index.d.ts +2 -0
- package/dist/src/plugins/voice/index.d.ts.map +1 -0
- package/dist/src/plugins/voice/index.js +2 -0
- package/dist/src/plugins/voice/index.js.map +1 -0
- package/dist/src/structures/DmChannel.d.ts +4 -0
- package/dist/src/structures/DmChannel.d.ts.map +1 -1
- package/dist/src/structures/DmChannel.js +6 -0
- package/dist/src/structures/DmChannel.js.map +1 -1
- package/dist/src/structures/GroupDmChannel.d.ts +4 -0
- package/dist/src/structures/GroupDmChannel.d.ts.map +1 -1
- package/dist/src/structures/GroupDmChannel.js +6 -0
- package/dist/src/structures/GroupDmChannel.js.map +1 -1
- package/dist/src/structures/Guild.js +1 -1
- package/dist/src/structures/Guild.js.map +1 -1
- package/dist/src/structures/GuildMember.d.ts +10 -5
- package/dist/src/structures/GuildMember.d.ts.map +1 -1
- package/dist/src/structures/GuildMember.js.map +1 -1
- package/dist/src/structures/Poll.d.ts +1 -1
- package/dist/src/structures/Poll.d.ts.map +1 -1
- package/dist/src/structures/User.d.ts +1 -1
- package/dist/src/structures/User.d.ts.map +1 -1
- package/dist/src/structures/User.js +3 -3
- package/dist/src/structures/User.js.map +1 -1
- package/dist/src/structures/Webhook.d.ts +4 -2
- package/dist/src/structures/Webhook.d.ts.map +1 -1
- package/dist/src/structures/Webhook.js +42 -29
- package/dist/src/structures/Webhook.js.map +1 -1
- package/dist/src/types/commandMiddleware.d.ts +64 -0
- package/dist/src/types/commandMiddleware.d.ts.map +1 -0
- package/dist/src/types/commandMiddleware.js +2 -0
- package/dist/src/types/commandMiddleware.js.map +1 -0
- package/dist/src/types/index.d.ts +58 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js +1 -0
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/listeners.d.ts +15 -4
- package/dist/src/types/listeners.d.ts.map +1 -1
- package/dist/src/types/listeners.js.map +1 -1
- package/dist/src/utils/LRUCache.d.ts +46 -0
- package/dist/src/utils/LRUCache.d.ts.map +1 -0
- package/dist/src/utils/LRUCache.js +78 -0
- package/dist/src/utils/LRUCache.js.map +1 -0
- package/dist/src/utils/customIdParser.d.ts.map +1 -1
- package/dist/src/utils/customIdParser.js +6 -2
- package/dist/src/utils/customIdParser.js.map +1 -1
- package/dist/src/utils/payload.d.ts.map +1 -1
- package/dist/src/utils/payload.js +18 -1
- package/dist/src/utils/payload.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -8
- package/dist/src/classes/ApplicationManager.d.ts +0 -88
- package/dist/src/classes/ApplicationManager.d.ts.map +0 -1
- package/dist/src/classes/ApplicationManager.js +0 -179
- package/dist/src/classes/ApplicationManager.js.map +0 -1
- package/dist/src/classes/ClientWithCaching.d.ts +0 -51
- package/dist/src/classes/ClientWithCaching.d.ts.map +0 -1
- package/dist/src/classes/ClientWithCaching.js +0 -108
- package/dist/src/classes/ClientWithCaching.js.map +0 -1
- package/dist/src/classes/components/ModalChannelSelectMenu.d.ts +0 -62
- package/dist/src/classes/components/ModalChannelSelectMenu.d.ts.map +0 -1
- package/dist/src/classes/components/ModalChannelSelectMenu.js +0 -73
- package/dist/src/classes/components/ModalChannelSelectMenu.js.map +0 -1
- package/dist/src/classes/components/ModalMentionableSelectMenu.d.ts +0 -58
- package/dist/src/classes/components/ModalMentionableSelectMenu.d.ts.map +0 -1
- package/dist/src/classes/components/ModalMentionableSelectMenu.js +0 -68
- package/dist/src/classes/components/ModalMentionableSelectMenu.js.map +0 -1
- package/dist/src/classes/components/ModalRoleSelectMenu.d.ts +0 -58
- package/dist/src/classes/components/ModalRoleSelectMenu.d.ts.map +0 -1
- package/dist/src/classes/components/ModalRoleSelectMenu.js +0 -68
- package/dist/src/classes/components/ModalRoleSelectMenu.js.map +0 -1
- package/dist/src/classes/components/ModalStringSelectMenu.d.ts +0 -58
- package/dist/src/classes/components/ModalStringSelectMenu.d.ts.map +0 -1
- package/dist/src/classes/components/ModalStringSelectMenu.js +0 -64
- package/dist/src/classes/components/ModalStringSelectMenu.js.map +0 -1
- package/dist/src/classes/components/ModalUserSelectMenu.d.ts +0 -58
- package/dist/src/classes/components/ModalUserSelectMenu.d.ts.map +0 -1
- package/dist/src/classes/components/ModalUserSelectMenu.js +0 -68
- package/dist/src/classes/components/ModalUserSelectMenu.js.map +0 -1
- package/dist/src/internals/Cache.d.ts +0 -76
- package/dist/src/internals/Cache.d.ts.map +0 -1
- package/dist/src/internals/Cache.js +0 -122
- package/dist/src/internals/Cache.js.map +0 -1
- package/dist/src/plugins/multi-app/ApplicationManager.d.ts +0 -120
- package/dist/src/plugins/multi-app/ApplicationManager.d.ts.map +0 -1
- package/dist/src/plugins/multi-app/ApplicationManager.js +0 -207
- package/dist/src/plugins/multi-app/ApplicationManager.js.map +0 -1
- package/dist/src/plugins/multi-app/index.d.ts +0 -2
- package/dist/src/plugins/multi-app/index.d.ts.map +0 -1
- package/dist/src/plugins/multi-app/index.js +0 -2
- package/dist/src/plugins/multi-app/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buape/carbon",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/src/index.js",
|
|
6
|
-
"repository":
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/buape/carbon"
|
|
9
|
+
},
|
|
7
10
|
"exports": {
|
|
8
11
|
".": {
|
|
9
12
|
"types": "./dist/src/index.d.ts",
|
|
@@ -20,15 +23,16 @@
|
|
|
20
23
|
},
|
|
21
24
|
"license": "MIT",
|
|
22
25
|
"dependencies": {
|
|
23
|
-
"@types/node": "^
|
|
24
|
-
"discord-api-types": "0.38.
|
|
26
|
+
"@types/node": "^25.6.0",
|
|
27
|
+
"discord-api-types": "0.38.45"
|
|
25
28
|
},
|
|
26
29
|
"optionalDependencies": {
|
|
27
|
-
"@cloudflare/workers-types": "4.
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
+
"@cloudflare/workers-types": "4.20260405.1",
|
|
31
|
+
"@discordjs/voice": "0.19.2",
|
|
32
|
+
"@hono/node-server": "1.19.13",
|
|
33
|
+
"@types/bun": "1.3.11",
|
|
30
34
|
"@types/ws": "8.18.1",
|
|
31
|
-
"ws": "8.
|
|
35
|
+
"ws": "8.20.0"
|
|
32
36
|
},
|
|
33
37
|
"files": [
|
|
34
38
|
"dist",
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import type { Context, Route } from "../abstracts/Plugin.js";
|
|
2
|
-
import { Client, type ClientOptions } from "./Client.js";
|
|
3
|
-
/**
|
|
4
|
-
* Credentials for a single application in the ApplicationManager
|
|
5
|
-
*/
|
|
6
|
-
export interface ApplicationCredentials {
|
|
7
|
-
/**
|
|
8
|
-
* The client ID of the application - must be a valid Discord snowflake
|
|
9
|
-
*/
|
|
10
|
-
clientId: string;
|
|
11
|
-
/**
|
|
12
|
-
* The public key of the app, used for interaction verification
|
|
13
|
-
* Can be a single key or an array of keys
|
|
14
|
-
*/
|
|
15
|
-
publicKey: string | string[];
|
|
16
|
-
/**
|
|
17
|
-
* The token of the bot
|
|
18
|
-
*/
|
|
19
|
-
token: string;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Options for the ApplicationManager
|
|
23
|
-
*/
|
|
24
|
-
export interface ApplicationManagerOptions {
|
|
25
|
-
/**
|
|
26
|
-
* Shared options that apply to all applications
|
|
27
|
-
*/
|
|
28
|
-
sharedOptions: Omit<ClientOptions, "clientId" | "publicKey" | "token">;
|
|
29
|
-
/**
|
|
30
|
-
* Array of application credentials
|
|
31
|
-
*/
|
|
32
|
-
applications: ApplicationCredentials[];
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Manages multiple Discord applications, routing requests to the appropriate client
|
|
36
|
-
* based on the client ID in the URL path (/:clientId/*)
|
|
37
|
-
*/
|
|
38
|
-
export declare class ApplicationManager {
|
|
39
|
-
/**
|
|
40
|
-
* Map of client IDs to their respective Client instances
|
|
41
|
-
*/
|
|
42
|
-
private clients;
|
|
43
|
-
/**
|
|
44
|
-
* The routes that the application manager will handle
|
|
45
|
-
*/
|
|
46
|
-
routes: Route[];
|
|
47
|
-
/**
|
|
48
|
-
* The shared deploy secret used for all applications
|
|
49
|
-
*/
|
|
50
|
-
private deploySecret?;
|
|
51
|
-
/**
|
|
52
|
-
* Creates a new ApplicationManager
|
|
53
|
-
* @param options Configuration options including shared settings and per-app credentials
|
|
54
|
-
*/
|
|
55
|
-
constructor(options: ApplicationManagerOptions);
|
|
56
|
-
/**
|
|
57
|
-
* Set up the routing for the application manager
|
|
58
|
-
*/
|
|
59
|
-
private setupRoutes;
|
|
60
|
-
/**
|
|
61
|
-
* Deploy all applications
|
|
62
|
-
*/
|
|
63
|
-
private handleGlobalDeploy;
|
|
64
|
-
/**
|
|
65
|
-
* Handle a request and route it to the appropriate client
|
|
66
|
-
* @param req The incoming request
|
|
67
|
-
* @param ctx Optional context (for Cloudflare Workers, etc.)
|
|
68
|
-
*/
|
|
69
|
-
handleRequest(req: Request, ctx?: Context): Promise<Response>;
|
|
70
|
-
/**
|
|
71
|
-
* Internal handler for the catch-all proxy route
|
|
72
|
-
*/
|
|
73
|
-
private handleProxyRequest;
|
|
74
|
-
/**
|
|
75
|
-
* Get a client by its client ID
|
|
76
|
-
* @param clientId The client ID to look up
|
|
77
|
-
*/
|
|
78
|
-
getClient(clientId: string): Client | undefined;
|
|
79
|
-
/**
|
|
80
|
-
* Get all clients
|
|
81
|
-
*/
|
|
82
|
-
getAllClients(): Client[];
|
|
83
|
-
/**
|
|
84
|
-
* Get all client IDs
|
|
85
|
-
*/
|
|
86
|
-
getClientIds(): string[];
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=ApplicationManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationManager.d.ts","sourceRoot":"","sources":["../../../src/classes/ApplicationManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAExD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;;OAGG;IACH,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IAC5B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACzC;;OAEG;IACH,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC,CAAA;IACtE;;OAEG;IACH,YAAY,EAAE,sBAAsB,EAAE,CAAA;CACtC;AAUD;;;GAGG;AACH,qBAAa,kBAAkB;IAC9B;;OAEG;IACH,OAAO,CAAC,OAAO,CAAiC;IAEhD;;OAEG;IACH,MAAM,EAAE,KAAK,EAAE,CAAK;IAEpB;;OAEG;IACH,OAAO,CAAC,YAAY,CAAC,CAAQ;IAE7B;;;OAGG;gBACS,OAAO,EAAE,yBAAyB;IAqC9C;;OAEG;IACH,OAAO,CAAC,WAAW;IAyBnB;;OAEG;YACW,kBAAkB;IA2BhC;;;;OAIG;IACG,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IA2DnE;;OAEG;YACW,kBAAkB;IAOhC;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI/C;;OAEG;IACH,aAAa,IAAI,MAAM,EAAE;IAIzB;;OAEG;IACH,YAAY,IAAI,MAAM,EAAE;CAGxB"}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import { Client } from "./Client.js";
|
|
2
|
-
/**
|
|
3
|
-
* Validates if a string is a valid Discord snowflake
|
|
4
|
-
*/
|
|
5
|
-
function isValidSnowflake(id) {
|
|
6
|
-
// Discord snowflakes are 17-19 digit numbers
|
|
7
|
-
return /^\d{17,19}$/.test(id);
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Manages multiple Discord applications, routing requests to the appropriate client
|
|
11
|
-
* based on the client ID in the URL path (/:clientId/*)
|
|
12
|
-
*/
|
|
13
|
-
export class ApplicationManager {
|
|
14
|
-
/**
|
|
15
|
-
* Map of client IDs to their respective Client instances
|
|
16
|
-
*/
|
|
17
|
-
clients = new Map();
|
|
18
|
-
/**
|
|
19
|
-
* The routes that the application manager will handle
|
|
20
|
-
*/
|
|
21
|
-
routes = [];
|
|
22
|
-
/**
|
|
23
|
-
* The shared deploy secret used for all applications
|
|
24
|
-
*/
|
|
25
|
-
deploySecret;
|
|
26
|
-
/**
|
|
27
|
-
* Creates a new ApplicationManager
|
|
28
|
-
* @param options Configuration options including shared settings and per-app credentials
|
|
29
|
-
*/
|
|
30
|
-
constructor(options) {
|
|
31
|
-
if (options.applications.length === 0) {
|
|
32
|
-
throw new Error("At least one application must be provided");
|
|
33
|
-
}
|
|
34
|
-
this.deploySecret = options.sharedOptions.deploySecret;
|
|
35
|
-
// Create a Client instance for each application
|
|
36
|
-
for (const app of options.applications) {
|
|
37
|
-
// Validate client ID is a valid snowflake
|
|
38
|
-
if (!isValidSnowflake(app.clientId)) {
|
|
39
|
-
throw new Error(`Invalid client ID: ${app.clientId}. Client ID must be a valid Discord snowflake (17-19 digits).`);
|
|
40
|
-
}
|
|
41
|
-
if (this.clients.has(app.clientId)) {
|
|
42
|
-
throw new Error(`Duplicate client ID: ${app.clientId}. Each application must have a unique client ID.`);
|
|
43
|
-
}
|
|
44
|
-
// Merge shared options with per-app credentials
|
|
45
|
-
const clientOptions = {
|
|
46
|
-
...options.sharedOptions,
|
|
47
|
-
clientId: app.clientId,
|
|
48
|
-
publicKey: app.publicKey,
|
|
49
|
-
token: app.token
|
|
50
|
-
};
|
|
51
|
-
const client = new Client(clientOptions, {}, []);
|
|
52
|
-
this.clients.set(app.clientId, client);
|
|
53
|
-
}
|
|
54
|
-
this.setupRoutes();
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Set up the routing for the application manager
|
|
58
|
-
*/
|
|
59
|
-
setupRoutes() {
|
|
60
|
-
// Global deploy route that deploys all applications
|
|
61
|
-
this.routes.push({
|
|
62
|
-
method: "GET",
|
|
63
|
-
path: "/deploy",
|
|
64
|
-
handler: this.handleGlobalDeploy.bind(this),
|
|
65
|
-
protected: true,
|
|
66
|
-
disabled: !this.deploySecret
|
|
67
|
-
});
|
|
68
|
-
// Catch-all route for /:clientId/*
|
|
69
|
-
// This will be handled by the adapter's router
|
|
70
|
-
this.routes.push({
|
|
71
|
-
method: "POST",
|
|
72
|
-
path: "/:clientId/*",
|
|
73
|
-
handler: this.handleProxyRequest.bind(this)
|
|
74
|
-
});
|
|
75
|
-
this.routes.push({
|
|
76
|
-
method: "GET",
|
|
77
|
-
path: "/:clientId/*",
|
|
78
|
-
handler: this.handleProxyRequest.bind(this)
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Deploy all applications
|
|
83
|
-
*/
|
|
84
|
-
async handleGlobalDeploy(req) {
|
|
85
|
-
// Verify deploy secret if provided
|
|
86
|
-
if (this.deploySecret) {
|
|
87
|
-
const url = new URL(req.url);
|
|
88
|
-
const secret = url.searchParams.get("secret");
|
|
89
|
-
if (secret !== this.deploySecret) {
|
|
90
|
-
return new Response("Unauthorized", { status: 401 });
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const results = [];
|
|
94
|
-
for (const [clientId, client] of this.clients) {
|
|
95
|
-
try {
|
|
96
|
-
await client.handleDeployRequest();
|
|
97
|
-
results.push({ clientId, status: "success" });
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
results.push({
|
|
101
|
-
clientId,
|
|
102
|
-
status: `error: ${error instanceof Error ? error.message : String(error)}`
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return Response.json(results, { status: 200 });
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Handle a request and route it to the appropriate client
|
|
110
|
-
* @param req The incoming request
|
|
111
|
-
* @param ctx Optional context (for Cloudflare Workers, etc.)
|
|
112
|
-
*/
|
|
113
|
-
async handleRequest(req, ctx) {
|
|
114
|
-
const url = new URL(req.url);
|
|
115
|
-
// Handle global deploy route
|
|
116
|
-
if (url.pathname === "/deploy" && req.method === "GET") {
|
|
117
|
-
return this.handleGlobalDeploy(req);
|
|
118
|
-
}
|
|
119
|
-
// Extract client ID from path: /:clientId/*
|
|
120
|
-
const pathParts = url.pathname.split("/").filter(Boolean);
|
|
121
|
-
if (pathParts.length < 2) {
|
|
122
|
-
return new Response("Bad Request: Invalid path format", { status: 400 });
|
|
123
|
-
}
|
|
124
|
-
const clientId = pathParts[0];
|
|
125
|
-
if (!clientId) {
|
|
126
|
-
return new Response("Bad Request: Missing client ID", { status: 400 });
|
|
127
|
-
}
|
|
128
|
-
const client = this.clients.get(clientId);
|
|
129
|
-
if (!client) {
|
|
130
|
-
return new Response(`Not Found: No application with client ID ${clientId}`, {
|
|
131
|
-
status: 404
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
// Reconstruct the path without the client ID prefix
|
|
135
|
-
const remainingPath = `/${pathParts.slice(1).join("/")}`;
|
|
136
|
-
// Find the matching route in the client
|
|
137
|
-
const route = client.routes.find((r) => r.path === remainingPath && r.method === req.method && !r.disabled);
|
|
138
|
-
if (!route) {
|
|
139
|
-
return new Response(`Not Found: No route ${req.method} ${remainingPath}`, {
|
|
140
|
-
status: 404
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
// If the route is protected, verify the secret
|
|
144
|
-
if (route.protected) {
|
|
145
|
-
const secret = url.searchParams.get("secret");
|
|
146
|
-
if (secret !== client.options.deploySecret) {
|
|
147
|
-
return new Response("Unauthorized", { status: 401 });
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
// Call the route handler
|
|
151
|
-
return route.handler(req, ctx);
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Internal handler for the catch-all proxy route
|
|
155
|
-
*/
|
|
156
|
-
async handleProxyRequest(req, ctx) {
|
|
157
|
-
return this.handleRequest(req, ctx);
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Get a client by its client ID
|
|
161
|
-
* @param clientId The client ID to look up
|
|
162
|
-
*/
|
|
163
|
-
getClient(clientId) {
|
|
164
|
-
return this.clients.get(clientId);
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Get all clients
|
|
168
|
-
*/
|
|
169
|
-
getAllClients() {
|
|
170
|
-
return Array.from(this.clients.values());
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Get all client IDs
|
|
174
|
-
*/
|
|
175
|
-
getClientIds() {
|
|
176
|
-
return Array.from(this.clients.keys());
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
//# sourceMappingURL=ApplicationManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationManager.js","sourceRoot":"","sources":["../../../src/classes/ApplicationManager.ts"],"names":[],"mappings":"AAC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EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;YACrD,CAAC;QACF,CAAC;QAED,yBAAyB;QACzB,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IAC/B,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,kBAAkB,CAC/B,GAAY,EACZ,GAAa;QAEb,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACpC,CAAC;IAED;;;OAGG;IACH,SAAS,CAAC,QAAgB;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAClC,CAAC;IAED;;OAEG;IACH,aAAa;QACZ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IACzC,CAAC;IAED;;OAEG;IACH,YAAY;QACX,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;IACvC,CAAC;CACD"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { BaseCommand } from "../abstracts/BaseCommand.js";
|
|
2
|
-
import type { BaseListener } from "../abstracts/BaseListener.js";
|
|
3
|
-
import type { BaseMessageInteractiveComponent } from "../abstracts/BaseMessageInteractiveComponent.js";
|
|
4
|
-
import type { Plugin } from "../abstracts/Plugin.js";
|
|
5
|
-
import { Cache, type CacheOptions, type CacheTypes } from "../internals/Cache.js";
|
|
6
|
-
import { Client, type ClientOptions } from "./Client.js";
|
|
7
|
-
export type ClientWithCachingOptions = ClientOptions & ({
|
|
8
|
-
/**
|
|
9
|
-
* Options for the cache
|
|
10
|
-
*/
|
|
11
|
-
caching?: Partial<CacheOptions>;
|
|
12
|
-
} | {
|
|
13
|
-
/**
|
|
14
|
-
* A custom cache instance to use
|
|
15
|
-
*/
|
|
16
|
-
customCache: Cache<keyof CacheTypes, CacheTypes[keyof CacheTypes]>;
|
|
17
|
-
});
|
|
18
|
-
/**
|
|
19
|
-
* A variant of the Client that has caching built in
|
|
20
|
-
*/
|
|
21
|
-
export declare class ClientWithCaching extends Client {
|
|
22
|
-
cache: Cache<string, unknown>;
|
|
23
|
-
constructor(options: ClientWithCachingOptions, handlers: {
|
|
24
|
-
commands?: BaseCommand[];
|
|
25
|
-
listeners?: BaseListener[];
|
|
26
|
-
components?: BaseMessageInteractiveComponent[];
|
|
27
|
-
}, plugins?: Plugin[]);
|
|
28
|
-
isCaching(): this is ClientWithCaching;
|
|
29
|
-
static createCompositeKey(parts: (string | number)[]): string;
|
|
30
|
-
fetchUser(id: string, bypassCache?: boolean): ReturnType<typeof Client.prototype.fetchUser>;
|
|
31
|
-
fetchGuild(id: string, bypassCache?: boolean): ReturnType<typeof Client.prototype.fetchGuild>;
|
|
32
|
-
fetchChannel(id: string, bypassCache?: boolean): ReturnType<typeof Client.prototype.fetchChannel>;
|
|
33
|
-
fetchRole(guildId: string, id: string, bypassCache?: boolean): ReturnType<typeof Client.prototype.fetchRole>;
|
|
34
|
-
fetchMember(guildId: string, id: string, bypassCache?: boolean): ReturnType<typeof Client.prototype.fetchMember>;
|
|
35
|
-
fetchMessage(channelId: string, messageId: string, bypassCache?: boolean): ReturnType<typeof Client.prototype.fetchMessage>;
|
|
36
|
-
/**
|
|
37
|
-
* Purge the cache with optional filters
|
|
38
|
-
* @param options Options for purging the cache
|
|
39
|
-
*/
|
|
40
|
-
purgeCache(_options?: {
|
|
41
|
-
type?: keyof CacheTypes;
|
|
42
|
-
before?: number;
|
|
43
|
-
after?: number;
|
|
44
|
-
}): void;
|
|
45
|
-
/**
|
|
46
|
-
* Clear the entire cache or a specific type
|
|
47
|
-
* @param type Optional type to clear
|
|
48
|
-
*/
|
|
49
|
-
clearCache(_type?: keyof CacheTypes): void;
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=ClientWithCaching.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file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AAM,CAAC,SAAS,CAAC,SAAS,CAAC;IAajC,UAAU,CACxB,EAAE,EAAE,MAAM,EACV,WAAW,UAAQ,GACjB,UAAU,CAAC,OAAO,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC;IAalC,YAAY,CAC1B,EAAE,EAAE,MAAM,EACV,WAAW,UAAQ,GACjB,UAAU,CAAC,OAAO,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC;IAapC,SAAS,CACvB,OAAO,EAAE,MAAM,EACf,EAAE,EAAE,MAAM,EACV,WAAW,UAAQ,GACjB,UAAU,CAAC,OAAO,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC;IAajC,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,EAAE,EAAE,MAAM,EACV,WAAW,UAAQ,GACjB,UAAU,CAAC,OAAO,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC;IAanC,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,WAAW,UAAQ,GACjB,UAAU,CAAC,OAAO,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC;IAiBnD;;;OAGG;IACH,UAAU,CACT,QAAQ,GAAE;QACT,IAAI,CAAC,EAAE,MAAM,UAAU,CAAA;QACvB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,KAAK,CAAC,EAAE,MAAM,CAAA;KACT;IAMP;;;OAGG;IACH,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,UAAU;CAInC"}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { Cache } from "../internals/Cache.js";
|
|
2
|
-
import { Client } from "./Client.js";
|
|
3
|
-
/**
|
|
4
|
-
* A variant of the Client that has caching built in
|
|
5
|
-
*/
|
|
6
|
-
export class ClientWithCaching extends Client {
|
|
7
|
-
cache;
|
|
8
|
-
constructor(options, handlers, plugins = []) {
|
|
9
|
-
super(options, handlers, plugins);
|
|
10
|
-
this.cache =
|
|
11
|
-
"customCache" in options
|
|
12
|
-
? options.customCache
|
|
13
|
-
: new Cache(options.caching);
|
|
14
|
-
}
|
|
15
|
-
isCaching() {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
static createCompositeKey(parts) {
|
|
19
|
-
return parts.join(":");
|
|
20
|
-
}
|
|
21
|
-
async fetchUser(id, bypassCache = false) {
|
|
22
|
-
const key = `user:${id}`;
|
|
23
|
-
if (!bypassCache) {
|
|
24
|
-
const user = this.cache.get(key);
|
|
25
|
-
if (user)
|
|
26
|
-
return user;
|
|
27
|
-
}
|
|
28
|
-
const user = await super.fetchUser(id);
|
|
29
|
-
this.cache.set(key, user);
|
|
30
|
-
return user;
|
|
31
|
-
}
|
|
32
|
-
async fetchGuild(id, bypassCache = false) {
|
|
33
|
-
const key = `guild:${id}`;
|
|
34
|
-
if (!bypassCache) {
|
|
35
|
-
const guild = this.cache.get(key);
|
|
36
|
-
if (guild)
|
|
37
|
-
return guild;
|
|
38
|
-
}
|
|
39
|
-
const guild = await super.fetchGuild(id);
|
|
40
|
-
this.cache.set(key, guild);
|
|
41
|
-
return guild;
|
|
42
|
-
}
|
|
43
|
-
async fetchChannel(id, bypassCache = false) {
|
|
44
|
-
const key = `channel:${id}`;
|
|
45
|
-
if (!bypassCache) {
|
|
46
|
-
const channel = this.cache.get(key);
|
|
47
|
-
if (channel)
|
|
48
|
-
return channel;
|
|
49
|
-
}
|
|
50
|
-
const channel = await super.fetchChannel(id);
|
|
51
|
-
this.cache.set(key, channel);
|
|
52
|
-
return channel;
|
|
53
|
-
}
|
|
54
|
-
async fetchRole(guildId, id, bypassCache = false) {
|
|
55
|
-
const key = ClientWithCaching.createCompositeKey(["role", guildId, id]);
|
|
56
|
-
if (!bypassCache) {
|
|
57
|
-
const role = this.cache.get(key);
|
|
58
|
-
if (role)
|
|
59
|
-
return role;
|
|
60
|
-
}
|
|
61
|
-
const role = await super.fetchRole(guildId, id);
|
|
62
|
-
this.cache.set(key, role);
|
|
63
|
-
return role;
|
|
64
|
-
}
|
|
65
|
-
async fetchMember(guildId, id, bypassCache = false) {
|
|
66
|
-
const key = ClientWithCaching.createCompositeKey(["member", guildId, id]);
|
|
67
|
-
if (!bypassCache) {
|
|
68
|
-
const member = this.cache.get(key);
|
|
69
|
-
if (member)
|
|
70
|
-
return member;
|
|
71
|
-
}
|
|
72
|
-
const member = await super.fetchMember(guildId, id);
|
|
73
|
-
this.cache.set(key, member);
|
|
74
|
-
return member;
|
|
75
|
-
}
|
|
76
|
-
async fetchMessage(channelId, messageId, bypassCache = false) {
|
|
77
|
-
const key = ClientWithCaching.createCompositeKey([
|
|
78
|
-
"message",
|
|
79
|
-
channelId,
|
|
80
|
-
messageId
|
|
81
|
-
]);
|
|
82
|
-
if (!bypassCache) {
|
|
83
|
-
const message = this.cache.get(key);
|
|
84
|
-
if (message)
|
|
85
|
-
return message;
|
|
86
|
-
}
|
|
87
|
-
const message = await super.fetchMessage(channelId, messageId);
|
|
88
|
-
this.cache.set(key, message);
|
|
89
|
-
return message;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Purge the cache with optional filters
|
|
93
|
-
* @param options Options for purging the cache
|
|
94
|
-
*/
|
|
95
|
-
purgeCache(_options = {}) {
|
|
96
|
-
// TODO: Implement purgeCache on Cache class
|
|
97
|
-
// this.cache.purgeCache(options)
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Clear the entire cache or a specific type
|
|
101
|
-
* @param type Optional type to clear
|
|
102
|
-
*/
|
|
103
|
-
clearCache(_type) {
|
|
104
|
-
// TODO: Implement clearCache on Cache class
|
|
105
|
-
// this.cache.clearCache(type)
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
//# sourceMappingURL=ClientWithCaching.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ClientWithCaching.js","sourceRoot":"","sources":["../../../src/classes/ClientWithCaching.ts"],"names":[],"mappings":"AAIA,OAAO,EACN,KAAK,EAGL,MAAM,uBAAuB,CAAA;AAC9B,O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QAC5C,8BAA8B;IAC/B,CAAC;CACD"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { type APIChannelSelectComponent, ComponentType } from "discord-api-types/v10";
|
|
2
|
-
import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
|
|
3
|
-
import type { ChannelSelectMenuInteraction } from "../../internals/ChannelSelectMenuInteraction.js";
|
|
4
|
-
import type { ComponentParserResult } from "../../types/index.js";
|
|
5
|
-
import type { ComponentData } from "../../types/index.js";
|
|
6
|
-
export declare abstract class ModalChannelSelectMenu extends BaseModalComponent {
|
|
7
|
-
readonly type: ComponentType.ChannelSelect;
|
|
8
|
-
readonly isV2 = false;
|
|
9
|
-
/**
|
|
10
|
-
* The custom ID of the component.
|
|
11
|
-
* If you want to provide a custom ID with additional data, you should either follow the default parser's format or implement your own custom parser.
|
|
12
|
-
*
|
|
13
|
-
* @see {@link customIdParser}
|
|
14
|
-
*/
|
|
15
|
-
abstract customId: string;
|
|
16
|
-
/**
|
|
17
|
-
* This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
|
|
18
|
-
* By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
|
|
19
|
-
* It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
|
|
20
|
-
*
|
|
21
|
-
* You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
|
|
22
|
-
* - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
|
|
23
|
-
* - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
|
|
24
|
-
*
|
|
25
|
-
* @param id - The custom ID of the component as received from an interaction event
|
|
26
|
-
* @returns The base key and the data object
|
|
27
|
-
*/
|
|
28
|
-
customIdParser: (id: string) => ComponentParserResult;
|
|
29
|
-
/**
|
|
30
|
-
* The minimum number of values that must be selected
|
|
31
|
-
*/
|
|
32
|
-
minValues?: number;
|
|
33
|
-
/**
|
|
34
|
-
* The maximum number of values that can be selected
|
|
35
|
-
*/
|
|
36
|
-
maxValues?: number;
|
|
37
|
-
/**
|
|
38
|
-
* Whether this component is required (defaults to true in modals)
|
|
39
|
-
*/
|
|
40
|
-
required?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* The placeholder text for the select menu
|
|
43
|
-
*/
|
|
44
|
-
placeholder?: string;
|
|
45
|
-
/**
|
|
46
|
-
* The types of channels to include in the select menu
|
|
47
|
-
*/
|
|
48
|
-
channelTypes?: APIChannelSelectComponent["channel_types"];
|
|
49
|
-
/**
|
|
50
|
-
* Default values for the select menu
|
|
51
|
-
*/
|
|
52
|
-
defaultValues?: APIChannelSelectComponent["default_values"];
|
|
53
|
-
abstract run(interaction: ChannelSelectMenuInteraction, data: ComponentData): unknown | Promise<unknown>;
|
|
54
|
-
serialize: () => APIChannelSelectComponent;
|
|
55
|
-
/**
|
|
56
|
-
* The disabled field is not allowed on modal select components
|
|
57
|
-
* @throws Error when trying to set disabled to true
|
|
58
|
-
*/
|
|
59
|
-
set disabled(value: boolean | undefined);
|
|
60
|
-
get disabled(): boolean | undefined;
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=ModalChannelSelectMenu.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModalChannelSelectMenu.d.ts","sourceRoot":"","sources":["../../../../src/classes/components/ModalChannelSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,yBAAyB,EAC9B,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAA;AACnG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAGzD,8BAAsB,sBAAuB,SAAQ,kBAAkB;IACtE,QAAQ,CAAC,IAAI,8BAAuC;IACpD,QAAQ,CAAC,IAAI,SAAQ;IAErB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB;;;;;;;;;;;OAWG;IACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,qBAAqB,CAAgB;IAErE;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,YAAY,CAAC,EAAE,yBAAyB,CAAC,eAAe,CAAC,CAAA;IAEzD;;OAEG;IACH,aAAa,CAAC,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAA;IAE3D,QAAQ,CAAC,GAAG,CACX,WAAW,EAAE,4BAA4B,EACzC,IAAI,EAAE,aAAa,GACjB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAE7B,SAAS,QAAO,yBAAyB,CAiBxC;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAMtC;IAED,IAAI,QAAQ,IAAI,OAAO,GAAG,SAAS,CAElC;CACD"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { ComponentType } from "discord-api-types/v10";
|
|
2
|
-
import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
|
|
3
|
-
import { parseCustomId } from "../../utils/customIdParser.js";
|
|
4
|
-
export class ModalChannelSelectMenu extends BaseModalComponent {
|
|
5
|
-
type = ComponentType.ChannelSelect;
|
|
6
|
-
isV2 = false;
|
|
7
|
-
/**
|
|
8
|
-
* This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
|
|
9
|
-
* By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
|
|
10
|
-
* It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
|
|
11
|
-
*
|
|
12
|
-
* You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
|
|
13
|
-
* - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
|
|
14
|
-
* - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
|
|
15
|
-
*
|
|
16
|
-
* @param id - The custom ID of the component as received from an interaction event
|
|
17
|
-
* @returns The base key and the data object
|
|
18
|
-
*/
|
|
19
|
-
customIdParser = parseCustomId;
|
|
20
|
-
/**
|
|
21
|
-
* The minimum number of values that must be selected
|
|
22
|
-
*/
|
|
23
|
-
minValues;
|
|
24
|
-
/**
|
|
25
|
-
* The maximum number of values that can be selected
|
|
26
|
-
*/
|
|
27
|
-
maxValues;
|
|
28
|
-
/**
|
|
29
|
-
* Whether this component is required (defaults to true in modals)
|
|
30
|
-
*/
|
|
31
|
-
required;
|
|
32
|
-
/**
|
|
33
|
-
* The placeholder text for the select menu
|
|
34
|
-
*/
|
|
35
|
-
placeholder;
|
|
36
|
-
/**
|
|
37
|
-
* The types of channels to include in the select menu
|
|
38
|
-
*/
|
|
39
|
-
channelTypes;
|
|
40
|
-
/**
|
|
41
|
-
* Default values for the select menu
|
|
42
|
-
*/
|
|
43
|
-
defaultValues;
|
|
44
|
-
serialize = () => {
|
|
45
|
-
const data = {
|
|
46
|
-
type: this.type,
|
|
47
|
-
custom_id: this.customId,
|
|
48
|
-
placeholder: this.placeholder,
|
|
49
|
-
min_values: this.minValues,
|
|
50
|
-
max_values: this.maxValues,
|
|
51
|
-
channel_types: this.channelTypes,
|
|
52
|
-
default_values: this.defaultValues
|
|
53
|
-
};
|
|
54
|
-
// In modals, required defaults to true
|
|
55
|
-
if (this.required !== undefined) {
|
|
56
|
-
data.required = this.required;
|
|
57
|
-
}
|
|
58
|
-
return data;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* The disabled field is not allowed on modal select components
|
|
62
|
-
* @throws Error when trying to set disabled to true
|
|
63
|
-
*/
|
|
64
|
-
set disabled(value) {
|
|
65
|
-
if (value === true) {
|
|
66
|
-
throw new Error("The 'disabled' field is not allowed on modal select components");
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
get disabled() {
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=ModalChannelSelectMenu.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModalChannelSelectMenu.js","sourceRoot":"","sources":["../../../../src/classes/components/ModalChannelSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAI1E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAE7D,MAAM,OAAgB,sBAAuB,SAAQ,kBAAkB;IAC7D,IAAI,GAAG,aAAa,CAAC,aAAsB,CAAA;IAC3C,IAAI,GAAG,KAAK,CAAA;IAUrB;;;;;;;;;;;OAWG;IACH,cAAc,GAA0C,aAAa,CAAA;IAErE;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,QAAQ,CAAU;IAElB;;OAEG;IACH,WAAW,CAAS;IAEpB;;OAEG;IACH,YAAY,CAA6C;IAEzD;;OAEG;IACH,aAAa,CAA8C;IAO3D,SAAS,GAAG,GAA8B,EAAE;QAC3C,MAAM,IAAI,GAA8B;YACvC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B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