@buape/carbon 0.11.0 → 0.13.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/README.md +1 -1
- package/dist/package.json +3 -3
- package/dist/src/abstracts/AnySelectMenu.d.ts +7 -0
- package/dist/src/abstracts/AnySelectMenu.d.ts.map +1 -1
- package/dist/src/abstracts/AnySelectMenu.js +8 -0
- package/dist/src/abstracts/AnySelectMenu.js.map +1 -1
- package/dist/src/abstracts/BaseGuildChannel.d.ts +1 -2
- package/dist/src/abstracts/BaseGuildChannel.d.ts.map +1 -1
- package/dist/src/abstracts/BaseGuildChannel.js.map +1 -1
- package/dist/src/abstracts/BaseInteraction.d.ts.map +1 -1
- package/dist/src/abstracts/BaseInteraction.js +1 -1
- package/dist/src/abstracts/BaseInteraction.js.map +1 -1
- package/dist/src/abstracts/BaseListener.d.ts +3 -3
- 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 +10 -2
- package/dist/src/abstracts/BaseModalComponent.d.ts.map +1 -1
- package/dist/src/abstracts/BaseModalComponent.js +1 -1
- package/dist/src/abstracts/BaseModalComponent.js.map +1 -1
- package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts +1 -2
- package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts.map +1 -1
- package/dist/src/abstracts/GuildThreadOnlyChannel.js.map +1 -1
- package/dist/src/adapters/bun/index.d.ts +4 -3
- package/dist/src/adapters/bun/index.d.ts.map +1 -1
- package/dist/src/adapters/bun/index.js +2 -2
- package/dist/src/adapters/bun/index.js.map +1 -1
- package/dist/src/adapters/fetch/index.d.ts +4 -3
- package/dist/src/adapters/fetch/index.d.ts.map +1 -1
- package/dist/src/adapters/fetch/index.js +7 -2
- package/dist/src/adapters/fetch/index.js.map +1 -1
- package/dist/src/adapters/node/index.d.ts +4 -3
- package/dist/src/adapters/node/index.d.ts.map +1 -1
- package/dist/src/adapters/node/index.js +2 -2
- package/dist/src/adapters/node/index.js.map +1 -1
- package/dist/src/classes/ApplicationManager.d.ts +88 -0
- package/dist/src/classes/ApplicationManager.d.ts.map +1 -0
- package/dist/src/classes/ApplicationManager.js +179 -0
- package/dist/src/classes/ApplicationManager.js.map +1 -0
- package/dist/src/classes/Client.d.ts +14 -0
- package/dist/src/classes/Client.d.ts.map +1 -1
- package/dist/src/classes/Client.js +20 -4
- package/dist/src/classes/Client.js.map +1 -1
- package/dist/src/classes/CommandWithSubcommandGroups.d.ts.map +1 -1
- package/dist/src/classes/CommandWithSubcommandGroups.js +4 -8
- package/dist/src/classes/CommandWithSubcommandGroups.js.map +1 -1
- package/dist/src/classes/CommandWithSubcommands.d.ts.map +1 -1
- package/dist/src/classes/CommandWithSubcommands.js +2 -4
- package/dist/src/classes/CommandWithSubcommands.js.map +1 -1
- package/dist/src/classes/Listener.d.ts +13 -0
- package/dist/src/classes/Listener.d.ts.map +1 -1
- package/dist/src/classes/Listener.js +27 -6
- package/dist/src/classes/Listener.js.map +1 -1
- package/dist/src/classes/Modal.d.ts +2 -1
- 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.map +1 -1
- package/dist/src/classes/RequestClient.js +5 -3
- package/dist/src/classes/RequestClient.js.map +1 -1
- package/dist/src/classes/components/Button.d.ts.map +1 -1
- package/dist/src/classes/components/Button.js.map +1 -1
- package/dist/src/classes/components/FileUpload.d.ts +22 -0
- package/dist/src/classes/components/FileUpload.d.ts.map +1 -0
- package/dist/src/classes/components/FileUpload.js +36 -0
- package/dist/src/classes/components/FileUpload.js.map +1 -0
- package/dist/src/classes/components/Label.d.ts +4 -4
- package/dist/src/classes/components/Label.d.ts.map +1 -1
- package/dist/src/classes/components/Label.js +7 -3
- package/dist/src/classes/components/Label.js.map +1 -1
- package/dist/src/classes/components/ModalChannelSelectMenu.d.ts +62 -0
- package/dist/src/classes/components/ModalChannelSelectMenu.d.ts.map +1 -0
- package/dist/src/classes/components/ModalChannelSelectMenu.js +73 -0
- package/dist/src/classes/components/ModalChannelSelectMenu.js.map +1 -0
- package/dist/src/classes/components/ModalMentionableSelectMenu.d.ts +58 -0
- package/dist/src/classes/components/ModalMentionableSelectMenu.d.ts.map +1 -0
- package/dist/src/classes/components/ModalMentionableSelectMenu.js +68 -0
- package/dist/src/classes/components/ModalMentionableSelectMenu.js.map +1 -0
- package/dist/src/classes/components/ModalRoleSelectMenu.d.ts +58 -0
- package/dist/src/classes/components/ModalRoleSelectMenu.d.ts.map +1 -0
- package/dist/src/classes/components/ModalRoleSelectMenu.js +68 -0
- package/dist/src/classes/components/ModalRoleSelectMenu.js.map +1 -0
- package/dist/src/classes/components/ModalStringSelectMenu.d.ts +56 -8
- package/dist/src/classes/components/ModalStringSelectMenu.d.ts.map +1 -1
- package/dist/src/classes/components/ModalStringSelectMenu.js +59 -10
- package/dist/src/classes/components/ModalStringSelectMenu.js.map +1 -1
- package/dist/src/classes/components/ModalUserSelectMenu.d.ts +58 -0
- package/dist/src/classes/components/ModalUserSelectMenu.d.ts.map +1 -0
- package/dist/src/classes/components/ModalUserSelectMenu.js +68 -0
- package/dist/src/classes/components/ModalUserSelectMenu.js.map +1 -0
- package/dist/src/classes/components/TextInput.d.ts +0 -1
- package/dist/src/classes/components/TextInput.d.ts.map +1 -1
- package/dist/src/classes/components/TextInput.js +0 -1
- package/dist/src/classes/components/TextInput.js.map +1 -1
- package/dist/src/errors/DiscordError.d.ts.map +1 -1
- package/dist/src/errors/DiscordError.js.map +1 -1
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/internals/CommandInteraction.d.ts.map +1 -1
- package/dist/src/internals/CommandInteraction.js +2 -1
- package/dist/src/internals/CommandInteraction.js.map +1 -1
- package/dist/src/internals/ComponentHandler.d.ts.map +1 -1
- package/dist/src/internals/ComponentHandler.js +7 -3
- package/dist/src/internals/ComponentHandler.js.map +1 -1
- package/dist/src/internals/EmojiHandler.d.ts +19 -0
- package/dist/src/internals/EmojiHandler.d.ts.map +1 -0
- package/dist/src/internals/EmojiHandler.js +35 -0
- package/dist/src/internals/EmojiHandler.js.map +1 -0
- package/dist/src/internals/EventHandler.d.ts +2 -2
- package/dist/src/internals/EventHandler.d.ts.map +1 -1
- package/dist/src/internals/EventHandler.js +3 -1
- package/dist/src/internals/EventHandler.js.map +1 -1
- package/dist/src/internals/FieldsHandler.d.ts +49 -16
- package/dist/src/internals/FieldsHandler.d.ts.map +1 -1
- package/dist/src/internals/FieldsHandler.js +110 -26
- package/dist/src/internals/FieldsHandler.js.map +1 -1
- package/dist/src/internals/ModalHandler.d.ts.map +1 -1
- package/dist/src/internals/ModalHandler.js +7 -1
- package/dist/src/internals/ModalHandler.js.map +1 -1
- package/dist/src/internals/OptionsHandler.d.ts +20 -12
- package/dist/src/internals/OptionsHandler.d.ts.map +1 -1
- package/dist/src/internals/OptionsHandler.js +48 -15
- package/dist/src/internals/OptionsHandler.js.map +1 -1
- package/dist/src/plugins/client-manager/ClientManager.d.ts +151 -0
- package/dist/src/plugins/client-manager/ClientManager.d.ts.map +1 -0
- package/dist/src/plugins/client-manager/ClientManager.js +246 -0
- package/dist/src/plugins/client-manager/ClientManager.js.map +1 -0
- package/dist/src/plugins/client-manager/index.d.ts +2 -0
- package/dist/src/plugins/client-manager/index.d.ts.map +1 -0
- package/dist/src/plugins/client-manager/index.js +2 -0
- package/dist/src/plugins/client-manager/index.js.map +1 -0
- package/dist/src/plugins/command-data/CommandDataPlugin.d.ts.map +1 -1
- package/dist/src/plugins/command-data/CommandDataPlugin.js +3 -6
- package/dist/src/plugins/command-data/CommandDataPlugin.js.map +1 -1
- package/dist/src/plugins/gateway/BabyCache.d.ts +7 -0
- package/dist/src/plugins/gateway/BabyCache.d.ts.map +1 -0
- package/dist/src/plugins/gateway/BabyCache.js +6 -0
- package/dist/src/plugins/gateway/BabyCache.js.map +1 -0
- package/dist/src/plugins/gateway/GatewayPlugin.d.ts +4 -2
- package/dist/src/plugins/gateway/GatewayPlugin.d.ts.map +1 -1
- package/dist/src/plugins/gateway/GatewayPlugin.js +68 -22
- package/dist/src/plugins/gateway/GatewayPlugin.js.map +1 -1
- package/dist/src/plugins/gateway/InteractionEventListener.d.ts +8 -0
- package/dist/src/plugins/gateway/InteractionEventListener.d.ts.map +1 -0
- package/dist/src/plugins/gateway/InteractionEventListener.js +9 -0
- package/dist/src/plugins/gateway/InteractionEventListener.js.map +1 -0
- package/dist/src/plugins/gateway/index.d.ts +1 -0
- package/dist/src/plugins/gateway/index.d.ts.map +1 -1
- package/dist/src/plugins/gateway/index.js +1 -0
- package/dist/src/plugins/gateway/index.js.map +1 -1
- package/dist/src/plugins/gateway/types.d.ts +5 -0
- package/dist/src/plugins/gateway/types.d.ts.map +1 -1
- package/dist/src/plugins/gateway/types.js.map +1 -1
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.d.ts +5 -1
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.d.ts.map +1 -1
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.js +7 -5
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.js.map +1 -1
- package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.d.ts +0 -1
- package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.d.ts.map +1 -1
- package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.js +0 -4
- package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.js.map +1 -1
- package/dist/src/plugins/gateway-forwarder/index.d.ts +1 -1
- package/dist/src/plugins/gateway-forwarder/index.d.ts.map +1 -1
- package/dist/src/plugins/gateway-forwarder/index.js +1 -1
- package/dist/src/plugins/gateway-forwarder/index.js.map +1 -1
- package/dist/src/plugins/multi-app/ApplicationManager.d.ts +120 -0
- package/dist/src/plugins/multi-app/ApplicationManager.d.ts.map +1 -0
- package/dist/src/plugins/multi-app/ApplicationManager.js +207 -0
- package/dist/src/plugins/multi-app/ApplicationManager.js.map +1 -0
- package/dist/src/plugins/multi-app/index.d.ts +2 -0
- package/dist/src/plugins/multi-app/index.d.ts.map +1 -0
- package/dist/src/plugins/multi-app/index.js +2 -0
- package/dist/src/plugins/multi-app/index.js.map +1 -0
- package/dist/src/plugins/paginator/GoToPageModal.d.ts +1 -1
- package/dist/src/plugins/paginator/GoToPageModal.d.ts.map +1 -1
- package/dist/src/plugins/paginator/GoToPageModal.js +2 -2
- package/dist/src/plugins/paginator/GoToPageModal.js.map +1 -1
- package/dist/src/plugins/paginator/Paginator.d.ts.map +1 -1
- package/dist/src/plugins/paginator/Paginator.js +1 -1
- package/dist/src/plugins/paginator/Paginator.js.map +1 -1
- package/dist/src/plugins/paginator/index.d.ts +2 -0
- package/dist/src/plugins/paginator/index.d.ts.map +1 -1
- package/dist/src/plugins/paginator/index.js +2 -0
- package/dist/src/plugins/paginator/index.js.map +1 -1
- package/dist/src/plugins/sharding/index.d.ts +1 -1
- package/dist/src/plugins/sharding/index.js +1 -1
- package/dist/src/structures/DmChannel.d.ts.map +1 -1
- package/dist/src/structures/DmChannel.js.map +1 -1
- package/dist/src/structures/Emoji.d.ts +75 -0
- package/dist/src/structures/Emoji.d.ts.map +1 -0
- package/dist/src/structures/Emoji.js +156 -0
- package/dist/src/structures/Emoji.js.map +1 -0
- package/dist/src/structures/GroupDmChannel.d.ts +8 -1
- package/dist/src/structures/GroupDmChannel.d.ts.map +1 -1
- package/dist/src/structures/GroupDmChannel.js +13 -4
- package/dist/src/structures/GroupDmChannel.js.map +1 -1
- package/dist/src/structures/Guild.d.ts +83 -6
- package/dist/src/structures/Guild.d.ts.map +1 -1
- package/dist/src/structures/Guild.js +177 -22
- package/dist/src/structures/Guild.js.map +1 -1
- package/dist/src/structures/GuildMember.d.ts +23 -1
- package/dist/src/structures/GuildMember.d.ts.map +1 -1
- package/dist/src/structures/GuildMember.js +38 -9
- package/dist/src/structures/GuildMember.js.map +1 -1
- package/dist/src/structures/GuildScheduledEvent.d.ts +121 -0
- package/dist/src/structures/GuildScheduledEvent.d.ts.map +1 -0
- package/dist/src/structures/GuildScheduledEvent.js +228 -0
- package/dist/src/structures/GuildScheduledEvent.js.map +1 -0
- package/dist/src/structures/GuildThreadChannel.d.ts +1 -1
- package/dist/src/structures/GuildThreadChannel.d.ts.map +1 -1
- package/dist/src/structures/Role.d.ts +33 -12
- package/dist/src/structures/Role.d.ts.map +1 -1
- package/dist/src/structures/Role.js +58 -24
- package/dist/src/structures/Role.js.map +1 -1
- package/dist/src/structures/ThreadMember.d.ts.map +1 -1
- package/dist/src/structures/ThreadMember.js +0 -1
- package/dist/src/structures/ThreadMember.js.map +1 -1
- package/dist/src/structures/User.d.ts +16 -4
- package/dist/src/structures/User.d.ts.map +1 -1
- package/dist/src/structures/User.js +25 -9
- package/dist/src/structures/User.js.map +1 -1
- package/dist/src/structures/Webhook.d.ts +40 -19
- package/dist/src/structures/Webhook.d.ts.map +1 -1
- package/dist/src/structures/Webhook.js +70 -30
- package/dist/src/structures/Webhook.js.map +1 -1
- package/dist/src/types/index.d.ts +5 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/listeners.d.ts +12 -7
- package/dist/src/types/listeners.d.ts.map +1 -1
- package/dist/src/types/listeners.js +3 -1
- package/dist/src/types/listeners.js.map +1 -1
- package/dist/src/utils/cdn.d.ts +31 -0
- package/dist/src/utils/cdn.d.ts.map +1 -0
- package/dist/src/utils/cdn.js +18 -0
- package/dist/src/utils/cdn.js.map +1 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +1 -0
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/utils/payload.d.ts.map +1 -1
- package/dist/src/utils/payload.js +20 -5
- package/dist/src/utils/payload.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { Routes } from "discord-api-types/v10";
|
|
2
|
+
import { Client } from "../../classes/Client.js";
|
|
3
|
+
/**
|
|
4
|
+
* Manages multiple Discord applications, routing requests to the appropriate client
|
|
5
|
+
* based on the client ID in the URL path (/:clientId/*)
|
|
6
|
+
*
|
|
7
|
+
* To use with a database, extend this class and override:
|
|
8
|
+
* - getClient(clientId) - Return the client for a specific ID (or create it)
|
|
9
|
+
* - getAllClients() - Return all available clients
|
|
10
|
+
* - getClientIds() - Return all available client IDs
|
|
11
|
+
*
|
|
12
|
+
* Then call setupClient(credentials) to create clients on-demand.
|
|
13
|
+
*/
|
|
14
|
+
export class ClientManager {
|
|
15
|
+
/**
|
|
16
|
+
* The routes that the application manager will handle
|
|
17
|
+
*/
|
|
18
|
+
routes = [];
|
|
19
|
+
/**
|
|
20
|
+
* The shared deploy secret used for all applications
|
|
21
|
+
*/
|
|
22
|
+
deploySecret;
|
|
23
|
+
/**
|
|
24
|
+
* The base URL of the applications to mount the proxy at
|
|
25
|
+
*/
|
|
26
|
+
baseUrl;
|
|
27
|
+
/**
|
|
28
|
+
* Shared options that apply to all applications
|
|
29
|
+
* Protected to allow subclasses to use it when creating clients
|
|
30
|
+
*/
|
|
31
|
+
sharedOptions;
|
|
32
|
+
clients = new Map();
|
|
33
|
+
staticApplications;
|
|
34
|
+
initialHandlers;
|
|
35
|
+
initialPlugins;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new ClientManager
|
|
38
|
+
* @param options Configuration options including shared settings and per-app credentials
|
|
39
|
+
*/
|
|
40
|
+
constructor(options, handlers, plugins) {
|
|
41
|
+
this.sharedOptions = options.sharedOptions;
|
|
42
|
+
this.deploySecret = options.deploySecret;
|
|
43
|
+
this.baseUrl = options.baseUrl;
|
|
44
|
+
this.staticApplications = options.applications ?? [];
|
|
45
|
+
this.initialHandlers = handlers;
|
|
46
|
+
this.initialPlugins = plugins;
|
|
47
|
+
this.setupRoutes();
|
|
48
|
+
this.getApplications().then(async (applications) => {
|
|
49
|
+
applications.map(async (application) => {
|
|
50
|
+
this.setupClient({
|
|
51
|
+
clientId: application.clientId,
|
|
52
|
+
publicKey: application.publicKey,
|
|
53
|
+
token: application.token
|
|
54
|
+
}, options.initialSetupOptions);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Setup a client from credentials.
|
|
60
|
+
*
|
|
61
|
+
* @param credentials The application credentials
|
|
62
|
+
* @param options The setup options for the client
|
|
63
|
+
* @returns A configured Client instance
|
|
64
|
+
*/
|
|
65
|
+
async setupClient(credentials, options = {
|
|
66
|
+
recreate: false,
|
|
67
|
+
setInteractionsUrlOnDevPortal: false,
|
|
68
|
+
setEventsUrlOnDevPortal: false
|
|
69
|
+
}) {
|
|
70
|
+
const existing = this.getClient(credentials.clientId);
|
|
71
|
+
if (existing && !options.recreate) {
|
|
72
|
+
throw new Error(`Client ${credentials.clientId} already exists. If you want to recreate it, pass true to the recreate parameter.`);
|
|
73
|
+
}
|
|
74
|
+
if (existing && options.recreate) {
|
|
75
|
+
this.clients.delete(credentials.clientId);
|
|
76
|
+
}
|
|
77
|
+
if (!this.isValidClientId(credentials.clientId)) {
|
|
78
|
+
throw new Error(`Invalid client ID: ${credentials.clientId}. Client ID must be a valid Discord snowflake (17-19 digits).`);
|
|
79
|
+
}
|
|
80
|
+
const clientOptions = {
|
|
81
|
+
...this.sharedOptions,
|
|
82
|
+
baseUrl: `${this.baseUrl}/${credentials.clientId}`,
|
|
83
|
+
deploySecret: this.deploySecret,
|
|
84
|
+
clientId: credentials.clientId,
|
|
85
|
+
publicKey: credentials.publicKey,
|
|
86
|
+
token: credentials.token
|
|
87
|
+
};
|
|
88
|
+
const client = new Client(clientOptions, this.initialHandlers, this.initialPlugins);
|
|
89
|
+
this.clients.set(credentials.clientId, client);
|
|
90
|
+
if (options.setInteractionsUrlOnDevPortal ||
|
|
91
|
+
options.setEventsUrlOnDevPortal) {
|
|
92
|
+
await client.rest.patch(Routes.currentApplication(), {
|
|
93
|
+
body: {
|
|
94
|
+
interactions_endpoint_url: options.setInteractionsUrlOnDevPortal
|
|
95
|
+
? `${this.baseUrl}/${credentials.clientId}/interactions`
|
|
96
|
+
: undefined,
|
|
97
|
+
event_webhooks_url: options.setEventsUrlOnDevPortal
|
|
98
|
+
? `${this.baseUrl}/${credentials.clientId}/events`
|
|
99
|
+
: undefined
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return client;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Set up the routing for the application manager
|
|
107
|
+
*/
|
|
108
|
+
setupRoutes() {
|
|
109
|
+
this.routes.push({
|
|
110
|
+
method: "GET",
|
|
111
|
+
path: "/deploy",
|
|
112
|
+
handler: this.handleGlobalDeploy.bind(this),
|
|
113
|
+
protected: true,
|
|
114
|
+
disabled: !this.deploySecret
|
|
115
|
+
});
|
|
116
|
+
this.routes.push({
|
|
117
|
+
method: "POST",
|
|
118
|
+
path: "/:clientId/*",
|
|
119
|
+
handler: this.handleProxyRequest.bind(this)
|
|
120
|
+
});
|
|
121
|
+
this.routes.push({
|
|
122
|
+
method: "GET",
|
|
123
|
+
path: "/:clientId/*",
|
|
124
|
+
handler: this.handleProxyRequest.bind(this)
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Deploy all applications
|
|
129
|
+
*/
|
|
130
|
+
async handleGlobalDeploy(req) {
|
|
131
|
+
if (this.deploySecret) {
|
|
132
|
+
const url = new URL(req.url);
|
|
133
|
+
const secret = url.searchParams.get("secret");
|
|
134
|
+
if (secret !== this.deploySecret) {
|
|
135
|
+
return new Response("Unauthorized", { status: 401 });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const results = [];
|
|
139
|
+
const clientIds = this.getClientIds();
|
|
140
|
+
for (const clientId of clientIds) {
|
|
141
|
+
const client = this.getClient(clientId);
|
|
142
|
+
if (!client)
|
|
143
|
+
continue;
|
|
144
|
+
try {
|
|
145
|
+
await client.handleDeployRequest();
|
|
146
|
+
results.push({ clientId, status: "success" });
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
results.push({
|
|
150
|
+
clientId,
|
|
151
|
+
status: `error: ${error instanceof Error ? error.message : String(error)}`
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return Response.json(results, { status: 200 });
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Handle a request and route it to the appropriate client
|
|
159
|
+
* @param req The incoming request
|
|
160
|
+
* @param ctx Optional context (for Cloudflare Workers, etc.)
|
|
161
|
+
*/
|
|
162
|
+
async handleRequest(req, ctx) {
|
|
163
|
+
const url = new URL(req.url);
|
|
164
|
+
const baseUrl = new URL(this.baseUrl);
|
|
165
|
+
const basePathname = baseUrl.pathname.replace(/\/$/, "");
|
|
166
|
+
const reqPathname = url.pathname.replace(/\/$/, "");
|
|
167
|
+
if (!reqPathname.startsWith(basePathname)) {
|
|
168
|
+
return new Response("Not Found: Invalid base URL", { status: 404 });
|
|
169
|
+
}
|
|
170
|
+
const truePathname = reqPathname.slice(basePathname.length);
|
|
171
|
+
if (truePathname === "/deploy" && req.method === "GET") {
|
|
172
|
+
return this.handleGlobalDeploy(req);
|
|
173
|
+
}
|
|
174
|
+
const pathParts = truePathname.split("/").filter(Boolean);
|
|
175
|
+
if (pathParts.length < 2) {
|
|
176
|
+
return new Response("Bad Request: Invalid path format", { status: 400 });
|
|
177
|
+
}
|
|
178
|
+
const clientId = pathParts[0];
|
|
179
|
+
if (!clientId) {
|
|
180
|
+
return new Response("Bad Request: Missing client ID", { status: 400 });
|
|
181
|
+
}
|
|
182
|
+
const client = this.getClient(clientId);
|
|
183
|
+
if (!client) {
|
|
184
|
+
return new Response(`Not Found: No application with client ID ${clientId}`, {
|
|
185
|
+
status: 404
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
const remainingPath = `/${pathParts.slice(1).join("/")}`;
|
|
189
|
+
const route = client.routes.find((r) => r.path === remainingPath && r.method === req.method && !r.disabled);
|
|
190
|
+
if (!route) {
|
|
191
|
+
return new Response(`Not Found: No route ${req.method} ${remainingPath}`, {
|
|
192
|
+
status: 404
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
if (route.protected) {
|
|
196
|
+
const secret = url.searchParams.get("secret");
|
|
197
|
+
if (secret !== client.options.deploySecret) {
|
|
198
|
+
return new Response("Unauthorized", { status: 401 });
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return route.handler(req, ctx);
|
|
202
|
+
}
|
|
203
|
+
async handleProxyRequest(req, ctx) {
|
|
204
|
+
return this.handleRequest(req, ctx);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Get a client by its client ID
|
|
208
|
+
* @param clientId The client ID to look up
|
|
209
|
+
*/
|
|
210
|
+
getClient(clientId) {
|
|
211
|
+
return this.clients.get(clientId);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Get all clients that the manager is managing
|
|
215
|
+
*/
|
|
216
|
+
getClients() {
|
|
217
|
+
return Array.from(this.clients.values());
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Get all client IDs that the manager is managing
|
|
221
|
+
*/
|
|
222
|
+
getClientIds() {
|
|
223
|
+
return Array.from(this.clients.keys());
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Get all applications
|
|
227
|
+
* You can override this in an extended class to return dynamic applications
|
|
228
|
+
*/
|
|
229
|
+
async getApplications() {
|
|
230
|
+
return this.staticApplications;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Get an application by its client ID
|
|
234
|
+
* You can override this in an extended class to return dynamic applications
|
|
235
|
+
*/
|
|
236
|
+
async getApplication(clientId) {
|
|
237
|
+
return this.staticApplications.find((app) => app.clientId === clientId);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Validate if a string is a valid Discord snowflake
|
|
241
|
+
*/
|
|
242
|
+
isValidClientId(id) {
|
|
243
|
+
return /^\d{17,19}$/.test(id);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=ClientManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientManager.js","sourceRoot":"","sources":["../../../../src/plugins/client-manager/ClientManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAE9C,OAAO,EAAE,MAAM,EAAsB,MAAM,yBAAyB,CAAA;AAmEpE;;;;;;;;;;GAUG;AACH,MAAM,OAAO,aAAa;IACzB;;OAEG;IACH,MAAM,GAAY,EAAE,CAAA;IAEpB;;OAEG;IACO,YAAY,CAAS;IAE/B;;OAEG;IACO,OAAO,CAAQ;IAEzB;;;OAGG;IACO,aAAa,CAGtB;IAES,OAAO,GAAwB,IAAI,GAAG,EAAE,CAAA;IACxC,kBAAkB,CAA0B;IAC5C,eAAe,CAAyC;IACxD,cAAc,CAAyC;IAEjE;;;OAGG;IACH,YACC,OAA6B,EAC7B,QAAiD,EACjD,OAAgD;QAEhD,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAA;QAC1C,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAA;QACxC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,YAAY,IAAI,EAAE,CAAA;QACpD,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAA;QAC/B,IAAI,CAAC,cAAc,GAAG,OAAO,CAAA;QAE7B,IAAI,CAAC,WAAW,EAAE,CAAA;QAElB,IAAI,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,Y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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,UAAU;QACT,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;IAED;;;OAGG;IACH,KAAK,CAAC,eAAe;QACpB,OAAO,IAAI,CAAC,kBAAkB,CAAA;IAC/B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,cAAc,CACnB,QAAgB;QAEhB,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAA;IACxE,CAAC;IAED;;OAEG;IACO,eAAe,CAAC,EAAU;QACnC,OAAO,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC9B,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/client-manager/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/client-manager/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandDataPlugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/command-data/CommandDataPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAErD;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,MAAM;IAC5C,QAAQ,CAAC,EAAE,kBAAiB;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IAER,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAIpC,cAAc,CAAC,MAAM,EAAE,MAAM;IAepC,OAAO,CAAC,kBAAkB,CAAuC;IACpD,4BAA4B;
|
|
1
|
+
{"version":3,"file":"CommandDataPlugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/command-data/CommandDataPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAErD;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,MAAM;IAC5C,QAAQ,CAAC,EAAE,kBAAiB;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IAER,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAIpC,cAAc,CAAC,MAAM,EAAE,MAAM;IAepC,OAAO,CAAC,kBAAkB,CAAuC;IACpD,4BAA4B;IAW5B,wBAAwB;CAQrC"}
|
|
@@ -26,13 +26,10 @@ export class CommandDataPlugin extends Plugin {
|
|
|
26
26
|
if (!this.client)
|
|
27
27
|
return new Response("Client not registered", { status: 500 });
|
|
28
28
|
if (this.discordCommandData)
|
|
29
|
-
return
|
|
30
|
-
status: 200,
|
|
31
|
-
headers: { "Content-Type": "application/json" }
|
|
32
|
-
});
|
|
29
|
+
return Response.json(this.discordCommandData);
|
|
33
30
|
const commands = (await this.client.rest.get(Routes.applicationCommands(this.client.options.clientId)));
|
|
34
31
|
this.discordCommandData = commands;
|
|
35
|
-
return
|
|
32
|
+
return Response.json(commands);
|
|
36
33
|
}
|
|
37
34
|
async handleCommandDataRequest() {
|
|
38
35
|
if (!this.client)
|
|
@@ -40,7 +37,7 @@ export class CommandDataPlugin extends Plugin {
|
|
|
40
37
|
const commands = this.client?.commands
|
|
41
38
|
.filter((c) => c.name !== "*")
|
|
42
39
|
.map((c) => c.serialize());
|
|
43
|
-
return
|
|
40
|
+
return Response.json(commands);
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
43
|
//# sourceMappingURL=CommandDataPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandDataPlugin.js","sourceRoot":"","sources":["../../../../src/plugins/command-data/CommandDataPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAGlD;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,MAAM;IACnC,EAAE,GAAG,cAAc,CAAA;IAC5B,MAAM,CAAS;IAER,cAAc,CAAC,MAAc;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACrB,CAAC;IAEM,cAAc,CAAC,MAAc;QACnC,MAAM,CAAC,MAAM,CAAC,IAAI,CACjB;YACC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC;SACjD,EACD;YACC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,gBAAgB;YACtB,OAAO,EAAE,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC;SACrD,CACD,CAAA;IACF,CAAC;IAEO,kBAAkB,GAAmC,IAAI,CAAA;IAC1D,KAAK,CAAC,4BAA4B;QACxC,IAAI,CAAC,IAAI,CAAC,MAAM;YACf,OAAO,IAAI,QAAQ,CAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;QAC9D,IAAI,IAAI,CAAC,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G,QAAQ,CAAA;QAClC,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC/B,CAAC;IAEM,KAAK,CAAC,wBAAwB;QACpC,IAAI,CAAC,IAAI,CAAC,MAAM;YACf,OAAO,IAAI,QAAQ,CAAC,uBAAuB,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;QAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,EAAE,QAAQ;aACpC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC;aAC7B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAA;QAC3B,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC/B,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BabyCache.d.ts","sourceRoot":"","sources":["../../../../src/plugins/gateway/BabyCache.ts"],"names":[],"mappings":"AAGA,qBAAa,SAAS;IACrB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAY;CAC9E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BabyCache.js","sourceRoot":"","sources":["../../../../src/plugins/gateway/BabyCache.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,oEAAoE;AAEpE,MAAM,OAAO,SAAS;IACrB,UAAU,GAA2D,IAAI,GAAG,EAAE,CAAA;CAC9E"}
|
|
@@ -2,13 +2,14 @@ import { EventEmitter } from "node:events";
|
|
|
2
2
|
import WebSocket from "ws";
|
|
3
3
|
import { Plugin } from "../../abstracts/Plugin.js";
|
|
4
4
|
import type { Client } from "../../classes/Client.js";
|
|
5
|
+
import { BabyCache } from "./BabyCache.js";
|
|
5
6
|
import { type APIGatewayBotInfo, type GatewayPayload, type GatewayPluginOptions, type GatewayState, type RequestGuildMembersData, type UpdatePresenceData, type UpdateVoiceStateData } from "./types.js";
|
|
6
7
|
import { ConnectionMonitor } from "./utils/monitor.js";
|
|
7
8
|
import { GatewayRateLimit } from "./utils/rateLimit.js";
|
|
8
9
|
export declare class GatewayPlugin extends Plugin {
|
|
9
10
|
readonly id = "gateway";
|
|
10
11
|
protected client?: Client;
|
|
11
|
-
|
|
12
|
+
readonly options: GatewayPluginOptions;
|
|
12
13
|
protected state: GatewayState;
|
|
13
14
|
protected ws: WebSocket | null;
|
|
14
15
|
protected monitor: ConnectionMonitor;
|
|
@@ -23,6 +24,7 @@ export declare class GatewayPlugin extends Plugin {
|
|
|
23
24
|
protected gatewayInfo?: APIGatewayBotInfo;
|
|
24
25
|
isConnected: boolean;
|
|
25
26
|
protected pings: number[];
|
|
27
|
+
protected babyCache: BabyCache;
|
|
26
28
|
constructor(options: GatewayPluginOptions, gatewayInfo?: APIGatewayBotInfo);
|
|
27
29
|
get ping(): number | null;
|
|
28
30
|
registerClient(client: Client): Promise<void>;
|
|
@@ -66,7 +68,7 @@ export declare class GatewayPlugin extends Plugin {
|
|
|
66
68
|
currentEventCount: number;
|
|
67
69
|
};
|
|
68
70
|
/**
|
|
69
|
-
* Get information about
|
|
71
|
+
* Get information about optionsured intents
|
|
70
72
|
*/
|
|
71
73
|
getIntentsInfo(): {
|
|
72
74
|
intents: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GatewayPlugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/gateway/GatewayPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,SAAS,MAAM,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"GatewayPlugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/gateway/GatewayPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAA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 import { EventEmitter } from "node:events";
|
|
|
2
2
|
import WebSocket from "ws";
|
|
3
3
|
import { Plugin } from "../../abstracts/Plugin.js";
|
|
4
4
|
import { ListenerEvent } from "../../types/index.js";
|
|
5
|
+
import { BabyCache } from "./BabyCache.js";
|
|
6
|
+
import { InteractionEventListener } from "./InteractionEventListener.js";
|
|
5
7
|
import { GatewayCloseCodes, GatewayIntents, GatewayOpcodes } from "./types.js";
|
|
6
8
|
import { startHeartbeat, stopHeartbeat } from "./utils/heartbeat.js";
|
|
7
9
|
import { ConnectionMonitor } from "./utils/monitor.js";
|
|
@@ -10,7 +12,7 @@ import { GatewayRateLimit } from "./utils/rateLimit.js";
|
|
|
10
12
|
export class GatewayPlugin extends Plugin {
|
|
11
13
|
id = "gateway";
|
|
12
14
|
client;
|
|
13
|
-
|
|
15
|
+
options;
|
|
14
16
|
state;
|
|
15
17
|
ws = null;
|
|
16
18
|
monitor;
|
|
@@ -25,9 +27,10 @@ export class GatewayPlugin extends Plugin {
|
|
|
25
27
|
gatewayInfo;
|
|
26
28
|
isConnected = false;
|
|
27
29
|
pings = [];
|
|
30
|
+
babyCache;
|
|
28
31
|
constructor(options, gatewayInfo) {
|
|
29
32
|
super();
|
|
30
|
-
this.
|
|
33
|
+
this.options = {
|
|
31
34
|
reconnect: {
|
|
32
35
|
maxAttempts: 5,
|
|
33
36
|
baseDelay: 1000,
|
|
@@ -44,6 +47,7 @@ export class GatewayPlugin extends Plugin {
|
|
|
44
47
|
this.rateLimit = new GatewayRateLimit();
|
|
45
48
|
this.emitter = new EventEmitter();
|
|
46
49
|
this.gatewayInfo = gatewayInfo;
|
|
50
|
+
this.babyCache = new BabyCache();
|
|
47
51
|
this.monitor.on("metrics", (metrics) => this.emitter.emit("metrics", metrics));
|
|
48
52
|
this.monitor.on("warning", (warning) => this.emitter.emit("warning", warning));
|
|
49
53
|
}
|
|
@@ -68,9 +72,12 @@ export class GatewayPlugin extends Plugin {
|
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
74
|
// Set shard information on the client
|
|
71
|
-
if (this.
|
|
72
|
-
client.shardId = this.
|
|
73
|
-
client.totalShards = this.
|
|
75
|
+
if (this.options.shard) {
|
|
76
|
+
client.shardId = this.options.shard[0];
|
|
77
|
+
client.totalShards = this.options.shard[1];
|
|
78
|
+
}
|
|
79
|
+
if (this.options.autoInteractions) {
|
|
80
|
+
this.client?.listeners.push(new InteractionEventListener());
|
|
74
81
|
}
|
|
75
82
|
this.connect();
|
|
76
83
|
}
|
|
@@ -79,7 +86,7 @@ export class GatewayPlugin extends Plugin {
|
|
|
79
86
|
const url = resume && this.state.resumeGatewayUrl
|
|
80
87
|
? this.state.resumeGatewayUrl
|
|
81
88
|
: (this.gatewayInfo?.url ??
|
|
82
|
-
this.
|
|
89
|
+
this.options.url ??
|
|
83
90
|
"wss://gateway.discord.gg/?v=10&encoding=json");
|
|
84
91
|
this.ws = this.createWebSocket(url);
|
|
85
92
|
this.setupWebSocket();
|
|
@@ -159,7 +166,7 @@ export class GatewayPlugin extends Plugin {
|
|
|
159
166
|
const t1 = payload1.t;
|
|
160
167
|
try {
|
|
161
168
|
if (!Object.values(ListenerEvent).includes(t1)) {
|
|
162
|
-
|
|
169
|
+
break;
|
|
163
170
|
}
|
|
164
171
|
if (t1 === "READY") {
|
|
165
172
|
const readyData = d;
|
|
@@ -167,8 +174,47 @@ export class GatewayPlugin extends Plugin {
|
|
|
167
174
|
this.state.resumeGatewayUrl = readyData.resume_gateway_url;
|
|
168
175
|
}
|
|
169
176
|
if (t && this.client) {
|
|
170
|
-
if (!this.
|
|
171
|
-
|
|
177
|
+
if (!this.options.eventFilter || this.options.eventFilter?.(t1)) {
|
|
178
|
+
if (t1 === "READY") {
|
|
179
|
+
const readyData = d;
|
|
180
|
+
readyData.guilds.forEach((guild) => {
|
|
181
|
+
this.babyCache.guildCache.set(guild.id, {
|
|
182
|
+
available: false,
|
|
183
|
+
lastEvent: Date.now()
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
if (t1 === "GUILD_CREATE") {
|
|
188
|
+
const guildCreateData = d;
|
|
189
|
+
const existingGuild = this.babyCache.guildCache.get(guildCreateData.id);
|
|
190
|
+
if (existingGuild && !existingGuild.available) {
|
|
191
|
+
this.babyCache.guildCache.set(guildCreateData.id, {
|
|
192
|
+
available: true,
|
|
193
|
+
lastEvent: Date.now()
|
|
194
|
+
});
|
|
195
|
+
this.client.eventHandler.handleEvent({
|
|
196
|
+
...guildCreateData,
|
|
197
|
+
clientId: this.client.options.clientId
|
|
198
|
+
}, "GUILD_AVAILABLE");
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (t1 === "GUILD_DELETE") {
|
|
203
|
+
const guildDeleteData = d;
|
|
204
|
+
const existingGuild = this.babyCache.guildCache.get(guildDeleteData.id);
|
|
205
|
+
if (existingGuild?.available && guildDeleteData.unavailable) {
|
|
206
|
+
this.babyCache.guildCache.set(guildDeleteData.id, {
|
|
207
|
+
available: false,
|
|
208
|
+
lastEvent: Date.now()
|
|
209
|
+
});
|
|
210
|
+
this.client.eventHandler.handleEvent({
|
|
211
|
+
...guildDeleteData,
|
|
212
|
+
clientId: this.client.options.clientId
|
|
213
|
+
}, "GUILD_UNAVAILABLE");
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
this.client.eventHandler.handleEvent({ ...payload1.d, clientId: this.client.options.clientId }, t1);
|
|
172
218
|
}
|
|
173
219
|
}
|
|
174
220
|
}
|
|
@@ -220,7 +266,7 @@ export class GatewayPlugin extends Plugin {
|
|
|
220
266
|
});
|
|
221
267
|
}
|
|
222
268
|
handleReconnectionAttempt(options) {
|
|
223
|
-
const { maxAttempts = 5, baseDelay = 1000, maxDelay = 30000 } = this.
|
|
269
|
+
const { maxAttempts = 5, baseDelay = 1000, maxDelay = 30000 } = this.options.reconnect ?? {};
|
|
224
270
|
this.disconnect();
|
|
225
271
|
if (this.reconnectAttempts >= maxAttempts) {
|
|
226
272
|
this.emitter.emit("error", new Error(`Max reconnect attempts (${maxAttempts}) reached${options.code ? ` after code ${options.code}` : ""}`));
|
|
@@ -306,13 +352,13 @@ export class GatewayPlugin extends Plugin {
|
|
|
306
352
|
return;
|
|
307
353
|
const payload = createIdentifyPayload({
|
|
308
354
|
token: this.client.options.token,
|
|
309
|
-
intents: this.
|
|
355
|
+
intents: this.options.intents,
|
|
310
356
|
properties: {
|
|
311
357
|
os: process.platform,
|
|
312
358
|
browser: "@buape/carbon - https://carbon.buape.com",
|
|
313
359
|
device: "@buape/carbon - https://carbon.buape.com"
|
|
314
360
|
},
|
|
315
|
-
...(this.
|
|
361
|
+
...(this.options.shard ? { shard: this.options.shard } : {})
|
|
316
362
|
});
|
|
317
363
|
this.send(payload, true);
|
|
318
364
|
}
|
|
@@ -346,12 +392,12 @@ export class GatewayPlugin extends Plugin {
|
|
|
346
392
|
if (!this.isConnected) {
|
|
347
393
|
throw new Error("Gateway is not connected");
|
|
348
394
|
}
|
|
349
|
-
const hasGuildMembersIntent = (this.
|
|
395
|
+
const hasGuildMembersIntent = (this.options.intents & GatewayIntents.GuildMembers) !== 0;
|
|
350
396
|
if (!hasGuildMembersIntent) {
|
|
351
397
|
throw new Error("GUILD_MEMBERS intent is required for requestGuildMembers operation");
|
|
352
398
|
}
|
|
353
399
|
if (data.presences) {
|
|
354
|
-
const hasPresencesIntent = (this.
|
|
400
|
+
const hasPresencesIntent = (this.options.intents & GatewayIntents.GuildPresences) !== 0;
|
|
355
401
|
if (!hasPresencesIntent) {
|
|
356
402
|
throw new Error("GUILD_PRESENCES intent is required when requesting presences");
|
|
357
403
|
}
|
|
@@ -373,16 +419,16 @@ export class GatewayPlugin extends Plugin {
|
|
|
373
419
|
};
|
|
374
420
|
}
|
|
375
421
|
/**
|
|
376
|
-
* Get information about
|
|
422
|
+
* Get information about optionsured intents
|
|
377
423
|
*/
|
|
378
424
|
getIntentsInfo() {
|
|
379
425
|
return {
|
|
380
|
-
intents: this.
|
|
381
|
-
hasGuilds: (this.
|
|
382
|
-
hasGuildMembers: (this.
|
|
383
|
-
hasGuildPresences: (this.
|
|
384
|
-
hasGuildMessages: (this.
|
|
385
|
-
hasMessageContent: (this.
|
|
426
|
+
intents: this.options.intents,
|
|
427
|
+
hasGuilds: (this.options.intents & GatewayIntents.Guilds) !== 0,
|
|
428
|
+
hasGuildMembers: (this.options.intents & GatewayIntents.GuildMembers) !== 0,
|
|
429
|
+
hasGuildPresences: (this.options.intents & GatewayIntents.GuildPresences) !== 0,
|
|
430
|
+
hasGuildMessages: (this.options.intents & GatewayIntents.GuildMessages) !== 0,
|
|
431
|
+
hasMessageContent: (this.options.intents & GatewayIntents.MessageContent) !== 0
|
|
386
432
|
};
|
|
387
433
|
}
|
|
388
434
|
/**
|
|
@@ -390,7 +436,7 @@ export class GatewayPlugin extends Plugin {
|
|
|
390
436
|
* @param intent The intent to check
|
|
391
437
|
*/
|
|
392
438
|
hasIntent(intent) {
|
|
393
|
-
return (this.
|
|
439
|
+
return (this.options.intents & intent) !== 0;
|
|
394
440
|
}
|
|
395
441
|
}
|
|
396
442
|
//# sourceMappingURL=GatewayPlugin.js.map
|