@buape/carbon 0.8.0 → 0.10.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/dist/package.json +7 -7
- package/dist/src/abstracts/AnySelectMenu.d.ts +2 -1
- package/dist/src/abstracts/AnySelectMenu.d.ts.map +1 -1
- package/dist/src/abstracts/AnySelectMenu.js +6 -0
- package/dist/src/abstracts/AnySelectMenu.js.map +1 -1
- package/dist/src/abstracts/AnySelectMenuInteraction.d.ts +0 -1
- package/dist/src/abstracts/AnySelectMenuInteraction.d.ts.map +1 -1
- package/dist/src/abstracts/AnySelectMenuInteraction.js +0 -2
- package/dist/src/abstracts/AnySelectMenuInteraction.js.map +1 -1
- package/dist/src/abstracts/BaseChannel.d.ts +10 -1
- package/dist/src/abstracts/BaseChannel.d.ts.map +1 -1
- package/dist/src/abstracts/BaseChannel.js +13 -0
- package/dist/src/abstracts/BaseChannel.js.map +1 -1
- package/dist/src/abstracts/BaseCommand.d.ts +18 -8
- package/dist/src/abstracts/BaseCommand.d.ts.map +1 -1
- package/dist/src/abstracts/BaseCommand.js +24 -7
- package/dist/src/abstracts/BaseCommand.js.map +1 -1
- package/dist/src/abstracts/BaseComponentInteraction.d.ts +0 -1
- package/dist/src/abstracts/BaseComponentInteraction.d.ts.map +1 -1
- package/dist/src/abstracts/BaseComponentInteraction.js +3 -3
- package/dist/src/abstracts/BaseComponentInteraction.js.map +1 -1
- package/dist/src/abstracts/BaseGuildChannel.d.ts +3 -2
- package/dist/src/abstracts/BaseGuildChannel.d.ts.map +1 -1
- package/dist/src/abstracts/BaseGuildChannel.js +5 -3
- package/dist/src/abstracts/BaseGuildChannel.js.map +1 -1
- package/dist/src/abstracts/BaseGuildTextChannel.d.ts +1 -1
- package/dist/src/abstracts/BaseGuildTextChannel.d.ts.map +1 -1
- package/dist/src/abstracts/BaseInteraction.d.ts +45 -2
- package/dist/src/abstracts/BaseInteraction.d.ts.map +1 -1
- package/dist/src/abstracts/BaseInteraction.js +99 -14
- package/dist/src/abstracts/BaseInteraction.js.map +1 -1
- package/dist/src/abstracts/BaseMessageInteractiveComponent.d.ts +18 -12
- package/dist/src/abstracts/BaseMessageInteractiveComponent.d.ts.map +1 -1
- package/dist/src/abstracts/BaseMessageInteractiveComponent.js +18 -18
- package/dist/src/abstracts/BaseMessageInteractiveComponent.js.map +1 -1
- package/dist/src/abstracts/BaseModalComponent.d.ts +16 -10
- package/dist/src/abstracts/BaseModalComponent.d.ts.map +1 -1
- package/dist/src/abstracts/BaseModalComponent.js +25 -17
- package/dist/src/abstracts/BaseModalComponent.js.map +1 -1
- package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts +11 -4
- package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts.map +1 -1
- package/dist/src/abstracts/GuildThreadOnlyChannel.js +14 -1
- package/dist/src/abstracts/GuildThreadOnlyChannel.js.map +1 -1
- package/dist/src/abstracts/Plugin.d.ts +1 -1
- package/dist/src/abstracts/Plugin.d.ts.map +1 -1
- package/dist/src/classes/Client.d.ts +32 -8
- package/dist/src/classes/Client.d.ts.map +1 -1
- package/dist/src/classes/Client.js +76 -17
- package/dist/src/classes/Client.js.map +1 -1
- package/dist/src/classes/ClientWithCaching.d.ts +51 -0
- package/dist/src/classes/ClientWithCaching.d.ts.map +1 -0
- package/dist/src/classes/ClientWithCaching.js +108 -0
- package/dist/src/classes/ClientWithCaching.js.map +1 -0
- package/dist/src/classes/Command.d.ts +10 -2
- package/dist/src/classes/Command.d.ts.map +1 -1
- package/dist/src/classes/Command.js +12 -1
- package/dist/src/classes/Command.js.map +1 -1
- package/dist/src/classes/Listener.d.ts +20 -0
- package/dist/src/classes/Listener.d.ts.map +1 -1
- package/dist/src/classes/Listener.js +116 -14
- package/dist/src/classes/Listener.js.map +1 -1
- package/dist/src/classes/Modal.d.ts +19 -2
- package/dist/src/classes/Modal.d.ts.map +1 -1
- package/dist/src/classes/Modal.js +14 -0
- package/dist/src/classes/Modal.js.map +1 -1
- package/dist/src/classes/RequestClient.d.ts +7 -5
- package/dist/src/classes/RequestClient.d.ts.map +1 -1
- package/dist/src/classes/RequestClient.js +28 -16
- package/dist/src/classes/RequestClient.js.map +1 -1
- package/dist/src/classes/components/Button.d.ts +3 -1
- package/dist/src/classes/components/Button.d.ts.map +1 -1
- package/dist/src/classes/components/Button.js +10 -1
- package/dist/src/classes/components/Button.js.map +1 -1
- package/dist/src/classes/components/ChannelSelectMenu.d.ts +2 -1
- package/dist/src/classes/components/ChannelSelectMenu.d.ts.map +1 -1
- package/dist/src/classes/components/ChannelSelectMenu.js +6 -0
- package/dist/src/classes/components/ChannelSelectMenu.js.map +1 -1
- package/dist/src/classes/components/Container.d.ts +0 -3
- package/dist/src/classes/components/Container.d.ts.map +1 -1
- package/dist/src/classes/components/Container.js +0 -3
- package/dist/src/classes/components/Container.js.map +1 -1
- package/dist/src/classes/components/MentionableSelectMenu.d.ts +2 -1
- package/dist/src/classes/components/MentionableSelectMenu.d.ts.map +1 -1
- package/dist/src/classes/components/MentionableSelectMenu.js +6 -0
- package/dist/src/classes/components/MentionableSelectMenu.js.map +1 -1
- package/dist/src/classes/components/RoleSelectMenu.d.ts +2 -1
- package/dist/src/classes/components/RoleSelectMenu.d.ts.map +1 -1
- package/dist/src/classes/components/RoleSelectMenu.js +6 -0
- package/dist/src/classes/components/RoleSelectMenu.js.map +1 -1
- package/dist/src/classes/components/StringSelectMenu.d.ts +2 -1
- package/dist/src/classes/components/StringSelectMenu.d.ts.map +1 -1
- package/dist/src/classes/components/StringSelectMenu.js +6 -0
- package/dist/src/classes/components/StringSelectMenu.js.map +1 -1
- package/dist/src/classes/components/UserSelectMenu.d.ts +2 -1
- package/dist/src/classes/components/UserSelectMenu.d.ts.map +1 -1
- package/dist/src/classes/components/UserSelectMenu.js +6 -0
- package/dist/src/classes/components/UserSelectMenu.js.map +1 -1
- package/dist/src/functions/enforceChoicesLimit.d.ts +3 -0
- package/dist/src/functions/enforceChoicesLimit.d.ts.map +1 -0
- package/dist/src/functions/enforceChoicesLimit.js +17 -0
- package/dist/src/functions/enforceChoicesLimit.js.map +1 -0
- package/dist/src/functions/errorsMapper.d.ts.map +1 -1
- package/dist/src/functions/errorsMapper.js +13 -1
- package/dist/src/functions/errorsMapper.js.map +1 -1
- package/dist/src/index.d.ts +8 -54
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +9 -5
- package/dist/src/index.js.map +1 -1
- package/dist/src/internals/AutocompleteInteraction.d.ts +9 -3
- package/dist/src/internals/AutocompleteInteraction.d.ts.map +1 -1
- package/dist/src/internals/AutocompleteInteraction.js +13 -3
- package/dist/src/internals/AutocompleteInteraction.js.map +1 -1
- package/dist/src/internals/ButtonInteraction.d.ts +0 -1
- package/dist/src/internals/ButtonInteraction.d.ts.map +1 -1
- package/dist/src/internals/ButtonInteraction.js +0 -2
- package/dist/src/internals/ButtonInteraction.js.map +1 -1
- package/dist/src/internals/Cache.d.ts +76 -0
- package/dist/src/internals/Cache.d.ts.map +1 -0
- package/dist/src/internals/Cache.js +122 -0
- package/dist/src/internals/Cache.js.map +1 -0
- package/dist/src/internals/CommandHandler.d.ts +2 -1
- package/dist/src/internals/CommandHandler.d.ts.map +1 -1
- package/dist/src/internals/CommandHandler.js +44 -13
- package/dist/src/internals/CommandHandler.js.map +1 -1
- package/dist/src/internals/CommandInteraction.d.ts +7 -1
- package/dist/src/internals/CommandInteraction.d.ts.map +1 -1
- package/dist/src/internals/CommandInteraction.js +10 -4
- package/dist/src/internals/CommandInteraction.js.map +1 -1
- package/dist/src/internals/ComponentHandler.d.ts +5 -2
- package/dist/src/internals/ComponentHandler.d.ts.map +1 -1
- package/dist/src/internals/ComponentHandler.js +34 -10
- package/dist/src/internals/ComponentHandler.js.map +1 -1
- package/dist/src/internals/ModalHandler.d.ts +1 -1
- package/dist/src/internals/ModalHandler.d.ts.map +1 -1
- package/dist/src/internals/ModalHandler.js +6 -2
- package/dist/src/internals/ModalHandler.js.map +1 -1
- package/dist/src/internals/ModalInteraction.js +1 -1
- package/dist/src/internals/ModalInteraction.js.map +1 -1
- package/dist/src/internals/OptionsHandler.d.ts +13 -3
- package/dist/src/internals/OptionsHandler.d.ts.map +1 -1
- package/dist/src/internals/OptionsHandler.js +51 -1
- package/dist/src/internals/OptionsHandler.js.map +1 -1
- package/dist/src/permissions.d.ts +54 -0
- package/dist/src/permissions.d.ts.map +1 -0
- package/dist/src/permissions.js +4 -0
- package/dist/src/permissions.js.map +1 -0
- package/dist/src/plugins/command-data/CommandDataPlugin.d.ts +16 -0
- package/dist/src/plugins/command-data/CommandDataPlugin.d.ts.map +1 -0
- package/dist/src/plugins/command-data/CommandDataPlugin.js +46 -0
- package/dist/src/plugins/command-data/CommandDataPlugin.js.map +1 -0
- package/dist/src/plugins/command-data/index.d.ts +2 -0
- package/dist/src/plugins/command-data/index.d.ts.map +1 -0
- package/dist/src/plugins/command-data/index.js +2 -0
- package/dist/src/plugins/command-data/index.js.map +1 -0
- package/dist/src/plugins/gateway/GatewayPlugin.d.ts +47 -3
- package/dist/src/plugins/gateway/GatewayPlugin.d.ts.map +1 -1
- package/dist/src/plugins/gateway/GatewayPlugin.js +169 -22
- package/dist/src/plugins/gateway/GatewayPlugin.js.map +1 -1
- package/dist/src/plugins/gateway/types.d.ts +58 -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/utils/monitor.d.ts +2 -0
- package/dist/src/plugins/gateway/utils/monitor.d.ts.map +1 -1
- package/dist/src/plugins/gateway/utils/monitor.js +10 -1
- package/dist/src/plugins/gateway/utils/monitor.js.map +1 -1
- package/dist/src/plugins/gateway/utils/payload.d.ts +8 -5
- package/dist/src/plugins/gateway/utils/payload.d.ts.map +1 -1
- package/dist/src/plugins/gateway/utils/payload.js +20 -1
- package/dist/src/plugins/gateway/utils/payload.js.map +1 -1
- package/dist/src/plugins/gateway/utils/rateLimit.d.ts +41 -0
- package/dist/src/plugins/gateway/utils/rateLimit.d.ts.map +1 -0
- package/dist/src/plugins/gateway/utils/rateLimit.js +61 -0
- package/dist/src/plugins/gateway/utils/rateLimit.js.map +1 -0
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.d.ts +1 -1
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.d.ts.map +1 -1
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.js +2 -2
- package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.js.map +1 -1
- package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.d.ts +10 -0
- package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.d.ts.map +1 -0
- package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.js +11 -0
- package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.js.map +1 -0
- package/dist/src/plugins/gateway-forwarder/index.d.ts +1 -0
- package/dist/src/plugins/gateway-forwarder/index.d.ts.map +1 -1
- package/dist/src/plugins/gateway-forwarder/index.js +1 -0
- package/dist/src/plugins/gateway-forwarder/index.js.map +1 -1
- package/dist/src/plugins/paginator/GoToPageModal.d.ts +24 -0
- package/dist/src/plugins/paginator/GoToPageModal.d.ts.map +1 -0
- package/dist/src/plugins/paginator/GoToPageModal.js +50 -0
- package/dist/src/plugins/paginator/GoToPageModal.js.map +1 -0
- package/dist/src/plugins/paginator/Paginator.d.ts +53 -0
- package/dist/src/plugins/paginator/Paginator.d.ts.map +1 -0
- package/dist/src/plugins/paginator/Paginator.js +183 -0
- package/dist/src/plugins/paginator/Paginator.js.map +1 -0
- package/dist/src/plugins/paginator/index.d.ts +9 -0
- package/dist/src/plugins/paginator/index.d.ts.map +1 -0
- package/dist/src/plugins/paginator/index.js +9 -0
- package/dist/src/plugins/paginator/index.js.map +1 -0
- package/dist/src/plugins/sharding/ShardingPlugin.d.ts +3 -1
- package/dist/src/plugins/sharding/ShardingPlugin.d.ts.map +1 -1
- package/dist/src/plugins/sharding/ShardingPlugin.js +11 -2
- package/dist/src/plugins/sharding/ShardingPlugin.js.map +1 -1
- package/dist/src/structures/DmChannel.d.ts +3 -3
- package/dist/src/structures/DmChannel.d.ts.map +1 -1
- package/dist/src/structures/DmChannel.js +5 -3
- package/dist/src/structures/DmChannel.js.map +1 -1
- package/dist/src/structures/GroupDmChannel.d.ts +1 -1
- package/dist/src/structures/GroupDmChannel.d.ts.map +1 -1
- package/dist/src/structures/Guild.d.ts +184 -5
- package/dist/src/structures/Guild.d.ts.map +1 -1
- package/dist/src/structures/Guild.js +406 -12
- package/dist/src/structures/Guild.js.map +1 -1
- package/dist/src/structures/GuildCategoryChannel.d.ts +1 -1
- package/dist/src/structures/GuildCategoryChannel.d.ts.map +1 -1
- package/dist/src/structures/GuildForumChannel.d.ts +1 -1
- package/dist/src/structures/GuildForumChannel.d.ts.map +1 -1
- package/dist/src/structures/GuildMember.d.ts +15 -12
- package/dist/src/structures/GuildMember.d.ts.map +1 -1
- package/dist/src/structures/GuildMember.js +78 -19
- package/dist/src/structures/GuildMember.js.map +1 -1
- package/dist/src/structures/GuildStageOrVoiceChannel.d.ts +1 -1
- package/dist/src/structures/GuildStageOrVoiceChannel.d.ts.map +1 -1
- package/dist/src/structures/GuildTextChannel.d.ts +1 -1
- package/dist/src/structures/GuildTextChannel.d.ts.map +1 -1
- package/dist/src/structures/GuildThreadChannel.d.ts +1 -1
- package/dist/src/structures/GuildThreadChannel.d.ts.map +1 -1
- package/dist/src/structures/Message.d.ts +29 -10
- package/dist/src/structures/Message.d.ts.map +1 -1
- package/dist/src/structures/Message.js +82 -18
- package/dist/src/structures/Message.js.map +1 -1
- package/dist/src/structures/Poll.d.ts +25 -0
- package/dist/src/structures/Poll.d.ts.map +1 -0
- package/dist/src/structures/Poll.js +45 -0
- package/dist/src/structures/Poll.js.map +1 -0
- package/dist/src/structures/Role.d.ts +29 -12
- package/dist/src/structures/Role.d.ts.map +1 -1
- package/dist/src/structures/Role.js +48 -21
- package/dist/src/structures/Role.js.map +1 -1
- package/dist/src/structures/ThreadMember.d.ts +36 -0
- package/dist/src/structures/ThreadMember.d.ts.map +1 -0
- package/dist/src/structures/ThreadMember.js +72 -0
- package/dist/src/structures/ThreadMember.js.map +1 -0
- package/dist/src/structures/User.d.ts +7 -2
- package/dist/src/structures/User.d.ts.map +1 -1
- package/dist/src/structures/User.js +8 -1
- package/dist/src/structures/User.js.map +1 -1
- package/dist/src/structures/Webhook.d.ts +135 -0
- package/dist/src/structures/Webhook.d.ts.map +1 -0
- package/dist/src/structures/Webhook.js +239 -0
- package/dist/src/structures/Webhook.js.map +1 -0
- package/dist/src/types/index.d.ts +73 -8
- 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 +71 -44
- package/dist/src/types/listeners.d.ts.map +1 -1
- package/dist/src/types/listeners.js.map +1 -1
- package/dist/src/utils/customIdParser.d.ts +3 -0
- package/dist/src/utils/customIdParser.d.ts.map +1 -0
- package/dist/src/utils/customIdParser.js +17 -0
- package/dist/src/utils/customIdParser.js.map +1 -0
- package/dist/src/utils/index.d.ts +4 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +4 -0
- package/dist/src/utils/index.js.map +1 -0
- package/dist/src/utils/payload.d.ts +4 -0
- package/dist/src/utils/payload.d.ts.map +1 -0
- package/dist/src/utils/payload.js +45 -0
- package/dist/src/utils/payload.js.map +1 -0
- package/dist/src/utils/verification.d.ts +4 -0
- package/dist/src/utils/verification.d.ts.map +1 -0
- package/dist/src/utils/verification.js +52 -0
- package/dist/src/utils/verification.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/dist/src/utils.d.ts +0 -9
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/utils.js +0 -93
- package/dist/src/utils.js.map +0 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface RateLimitConfig {
|
|
2
|
+
/** Maximum number of events allowed in the time window */
|
|
3
|
+
maxEvents: number;
|
|
4
|
+
/** Time window in milliseconds */
|
|
5
|
+
windowMs: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class GatewayRateLimit {
|
|
8
|
+
private events;
|
|
9
|
+
private readonly config;
|
|
10
|
+
constructor(config?: RateLimitConfig);
|
|
11
|
+
/**
|
|
12
|
+
* Check if sending an event would exceed the rate limit
|
|
13
|
+
* @returns true if the event can be sent, false if rate limited
|
|
14
|
+
*/
|
|
15
|
+
canSend(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Record that an event was sent
|
|
18
|
+
*/
|
|
19
|
+
recordEvent(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Get the current number of events in the time window
|
|
22
|
+
*/
|
|
23
|
+
getCurrentEventCount(): number;
|
|
24
|
+
/**
|
|
25
|
+
* Get remaining events before hitting rate limit
|
|
26
|
+
*/
|
|
27
|
+
getRemainingEvents(): number;
|
|
28
|
+
/**
|
|
29
|
+
* Get time until rate limit resets (in milliseconds)
|
|
30
|
+
*/
|
|
31
|
+
getResetTime(): number;
|
|
32
|
+
/**
|
|
33
|
+
* Remove events outside the current time window
|
|
34
|
+
*/
|
|
35
|
+
private cleanupOldEvents;
|
|
36
|
+
/**
|
|
37
|
+
* Reset the rate limiter
|
|
38
|
+
*/
|
|
39
|
+
reset(): void;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=rateLimit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rateLimit.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/gateway/utils/rateLimit.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC/B,0DAA0D;IAC1D,SAAS,EAAE,MAAM,CAAA;IACjB,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAA;CAChB;AAED,qBAAa,gBAAgB;IAC5B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;gBAE5B,MAAM,GAAE,eAAqD;IAIzE;;;OAGG;IACI,OAAO,IAAI,OAAO;IAKzB;;OAEG;IACI,WAAW,IAAI,IAAI;IAI1B;;OAEG;IACI,oBAAoB,IAAI,MAAM;IAKrC;;OAEG;IACI,kBAAkB,IAAI,MAAM;IAInC;;OAEG;IACI,YAAY,IAAI,MAAM;IAS7B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAMxB;;OAEG;IACI,KAAK,IAAI,IAAI;CAGpB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export class GatewayRateLimit {
|
|
2
|
+
events = [];
|
|
3
|
+
config;
|
|
4
|
+
constructor(config = { maxEvents: 120, windowMs: 60000 }) {
|
|
5
|
+
this.config = config;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Check if sending an event would exceed the rate limit
|
|
9
|
+
* @returns true if the event can be sent, false if rate limited
|
|
10
|
+
*/
|
|
11
|
+
canSend() {
|
|
12
|
+
this.cleanupOldEvents();
|
|
13
|
+
return this.events.length < this.config.maxEvents;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Record that an event was sent
|
|
17
|
+
*/
|
|
18
|
+
recordEvent() {
|
|
19
|
+
this.events.push(Date.now());
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the current number of events in the time window
|
|
23
|
+
*/
|
|
24
|
+
getCurrentEventCount() {
|
|
25
|
+
this.cleanupOldEvents();
|
|
26
|
+
return this.events.length;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get remaining events before hitting rate limit
|
|
30
|
+
*/
|
|
31
|
+
getRemainingEvents() {
|
|
32
|
+
return Math.max(0, this.config.maxEvents - this.getCurrentEventCount());
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get time until rate limit resets (in milliseconds)
|
|
36
|
+
*/
|
|
37
|
+
getResetTime() {
|
|
38
|
+
this.cleanupOldEvents();
|
|
39
|
+
if (this.events.length === 0)
|
|
40
|
+
return 0;
|
|
41
|
+
const oldestEvent = this.events[0];
|
|
42
|
+
if (!oldestEvent)
|
|
43
|
+
return 0;
|
|
44
|
+
return Math.max(0, this.config.windowMs - (Date.now() - oldestEvent));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Remove events outside the current time window
|
|
48
|
+
*/
|
|
49
|
+
cleanupOldEvents() {
|
|
50
|
+
const now = Date.now();
|
|
51
|
+
const cutoff = now - this.config.windowMs;
|
|
52
|
+
this.events = this.events.filter((timestamp) => timestamp > cutoff);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Reset the rate limiter
|
|
56
|
+
*/
|
|
57
|
+
reset() {
|
|
58
|
+
this.events = [];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=rateLimit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rateLimit.js","sourceRoot":"","sources":["../../../../../src/plugins/gateway/utils/rateLimit.ts"],"names":[],"mappings":"AAOA,MAAM,OAAO,gBAAgB;IACpB,MAAM,GAAa,EAAE,CAAA;IACZ,MAAM,CAAiB;IAExC,YAAY,SAA0B,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE;QACxE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACrB,CAAC;IAED;;;OAGG;IACI,OAAO;QACb,IAAI,CAAC,gBAAgB,EAAE,CAAA;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAA;IAClD,CAAC;IAED;;OAEG;IACI,WAAW;QACjB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;IAC7B,CAAC;IAED;;OAEG;IACI,oBAAoB;QAC1B,IAAI,CAAC,gBAAgB,EAAE,CAAA;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAA;IAC1B,CAAC;IAED;;OAEG;IACI,kBAAkB;QACxB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAA;IACxE,CAAC;IAED;;OAEG;IACI,YAAY;QAClB,IAAI,CAAC,gBAAgB,EAAE,CAAA;QACvB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,CAAC,CAAA;QAEtC,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QAClC,IAAI,CAAC,WAAW;YAAE,OAAO,CAAC,CAAA;QAC1B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC,CAAC,CAAA;IACtE,CAAC;IAED;;OAEG;IACK,gBAAgB;QACvB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACtB,MAAM,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAA;QACzC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,GAAG,MAAM,CAAC,CAAA;IACpE,CAAC;IAED;;OAEG;IACI,KAAK;QACX,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;IACjB,CAAC;CACD"}
|
|
@@ -17,7 +17,7 @@ export interface GatewayForwarderPluginOptions extends GatewayPluginOptions {
|
|
|
17
17
|
privateKey: string;
|
|
18
18
|
}
|
|
19
19
|
export declare class GatewayForwarderPlugin extends GatewayPlugin {
|
|
20
|
-
readonly id
|
|
20
|
+
readonly id: "gateway";
|
|
21
21
|
protected config: GatewayForwarderPluginOptions;
|
|
22
22
|
private privateKey;
|
|
23
23
|
constructor(options: GatewayForwarderPluginOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GatewayForwarderPlugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/gateway-forwarder/GatewayForwarderPlugin.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,KAAK,EAAkB,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE/E,MAAM,WAAW,6BAA8B,SAAQ,oBAAoB;IAC1E;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;;;;;;OAOG;IACH,UAAU,EAAE,MAAM,CAAA;CAClB;AAED,qBAAa,sBAAuB,SAAQ,aAAa;IACxD,
|
|
1
|
+
{"version":3,"file":"GatewayForwarderPlugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/gateway-forwarder/GatewayForwarderPlugin.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,KAAK,EAAkB,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE/E,MAAM,WAAW,6BAA8B,SAAQ,oBAAoB;IAC1E;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;;;;;;OAOG;IACH,UAAU,EAAE,MAAM,CAAA;CAClB;AAED,qBAAa,sBAAuB,SAAQ,aAAa;IACxD,SAAkB,EAAE,EAA0B,SAAS,CAAA;IAEvD,SAAS,CAAC,MAAM,EAAE,6BAA6B,CAAA;IAC/C,OAAO,CAAC,UAAU,CAAqC;gBAE3C,OAAO,EAAE,6BAA6B;cAoB/B,cAAc,IAAI,IAAI;CAuDzC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createPrivateKey, sign } from "node:crypto";
|
|
2
2
|
import { ApplicationWebhookType } from "discord-api-types/v10";
|
|
3
|
-
import { concatUint8Arrays, valueToUint8Array } from "../../utils.js";
|
|
3
|
+
import { concatUint8Arrays, valueToUint8Array } from "../../utils/index.js";
|
|
4
4
|
import { GatewayPlugin } from "../gateway/GatewayPlugin.js";
|
|
5
5
|
export class GatewayForwarderPlugin extends GatewayPlugin {
|
|
6
6
|
id = "gateway-forwarder";
|
|
@@ -32,7 +32,7 @@ export class GatewayForwarderPlugin extends GatewayPlugin {
|
|
|
32
32
|
try {
|
|
33
33
|
const payload = JSON.parse(data.toString());
|
|
34
34
|
if (payload.t && payload.d) {
|
|
35
|
-
if (
|
|
35
|
+
if (this.config.eventFilter &&
|
|
36
36
|
!this.config.eventFilter(payload.t))
|
|
37
37
|
return;
|
|
38
38
|
// In the below code, the events are not truly webhook events,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GatewayForwarderPlugin.js","sourceRoot":"","sources":["../../../../src/plugins/gateway-forwarder/GatewayForwarderPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAEN,sBAAsB,EACtB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"GatewayForwarderPlugin.js","sourceRoot":"","sources":["../../../../src/plugins/gateway-forwarder/GatewayForwarderPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAEN,sBAAsB,EACtB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAoB3D,MAAM,OAAO,sBAAuB,SAAQ,aAAa;IACtC,EAAE,GAAG,mBAAgC,CAAA;IAE7C,MAAM,CAA+B;IACvC,UAAU,CAAqC;IAEvD,YAAY,OAAsC;QACjD,IAAI,CAAC,OAAO,CAAC,UAAU,EA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/ShardingPlugin.js";
|
|
2
|
+
import type { GatewayForwarderPluginOptions } from "./GatewayForwarderPlugin.js";
|
|
3
|
+
import { GatewayForwarderPlugin } from "./GatewayForwarderPlugin.js";
|
|
4
|
+
export type ShardedGatewayForwarderPluginOptions = GatewayForwarderPluginOptions & ShardingPluginOptions;
|
|
5
|
+
export declare class ShardedGatewayForwarderPlugin extends ShardingPlugin {
|
|
6
|
+
readonly id: "sharding";
|
|
7
|
+
constructor(options: ShardedGatewayForwarderPluginOptions);
|
|
8
|
+
customGatewayPlugin: typeof GatewayForwarderPlugin;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=ShardedGatewayForwarderPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShardedGatewayForwarderPlugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EACd,KAAK,qBAAqB,EAC1B,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAA;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAEpE,MAAM,MAAM,oCAAoC,GAC/C,6BAA6B,GAAG,qBAAqB,CAAA;AAEtD,qBAAa,6BAA8B,SAAQ,cAAc;IAChE,SAAkB,EAAE,EAAkC,UAAU,CAAA;gBAEpD,OAAO,EAAE,oCAAoC;IAIzD,mBAAmB,gCAAyB;CAC5C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ShardingPlugin } from "../sharding/ShardingPlugin.js";
|
|
2
|
+
import { GatewayForwarderPlugin } from "./GatewayForwarderPlugin.js";
|
|
3
|
+
export class ShardedGatewayForwarderPlugin extends ShardingPlugin {
|
|
4
|
+
id = "sharded-gateway-forwarder";
|
|
5
|
+
// biome-ignore lint/complexity/noUselessConstructor:
|
|
6
|
+
constructor(options) {
|
|
7
|
+
super(options);
|
|
8
|
+
}
|
|
9
|
+
customGatewayPlugin = GatewayForwarderPlugin;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ShardedGatewayForwarderPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShardedGatewayForwarderPlugin.js","sourceRoot":"","sources":["../../../../src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,cAAc,EAEd,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAKpE,MAAM,OAAO,6BAA8B,SAAQ,cAAc;IAC9C,EAAE,GAAG,2BAAyC,CAAA;IAChE,qDAAqD;IACrD,YAAY,OAA6C;QACxD,KAAK,CAAC,OAAO,CAAC,CAAA;IACf,CAAC;IAED,mBAAmB,GAAG,sBAAsB,CAAA;CAC5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/gateway-forwarder/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA;AAC3C,cAAc,qBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/gateway-forwarder/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA;AAC3C,cAAc,oCAAoC,CAAA;AAClD,cAAc,qBAAqB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/gateway-forwarder/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA;AAC3C,cAAc,qBAAqB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/gateway-forwarder/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA;AAC3C,cAAc,oCAAoC,CAAA;AAClD,cAAc,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { TextInputStyle } from "discord-api-types/v10";
|
|
2
|
+
import { Modal } from "../../classes/Modal.js";
|
|
3
|
+
import { Row } from "../../classes/components/Row.js";
|
|
4
|
+
import { TextInput } from "../../classes/components/TextInput.js";
|
|
5
|
+
import type { ModalInteraction } from "../../internals/ModalInteraction.js";
|
|
6
|
+
import type { ComponentData } from "../../types/index.js";
|
|
7
|
+
export declare class GoToPageModal extends Modal {
|
|
8
|
+
title: string;
|
|
9
|
+
customId: string;
|
|
10
|
+
components: Row<PageNumberInput>[];
|
|
11
|
+
constructor(paginatorId: string, maxPages: number);
|
|
12
|
+
run(interaction: ModalInteraction, data: ComponentData): Promise<void | import("../../index.js").Message<false>>;
|
|
13
|
+
}
|
|
14
|
+
declare class PageNumberInput extends TextInput {
|
|
15
|
+
label: string;
|
|
16
|
+
customId: string;
|
|
17
|
+
style: TextInputStyle;
|
|
18
|
+
placeholder: string;
|
|
19
|
+
minLength: number;
|
|
20
|
+
maxLength: number;
|
|
21
|
+
required: boolean;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=GoToPageModal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoToPageModal.d.ts","sourceRoot":"","sources":["../../../../src/plugins/paginator/GoToPageModal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAA;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAA;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEzD,qBAAa,aAAc,SAAQ,KAAK;IACvC,KAAK,SAAe;IACpB,QAAQ,EAAE,MAAM,CAAA;IAEhB,UAAU,yBAAqC;gBAEnC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAK3C,GAAG,CAAC,WAAW,EAAE,gBAAgB,EAAE,IAAI,EAAE,aAAa;CAiC5D;AAED,cAAM,eAAgB,SAAQ,SAAS;IACtC,KAAK,SAAgB;IACrB,QAAQ,SAAS;IACjB,KAAK,iBAAuB;IAC5B,WAAW,SAAyB;IACpC,SAAS,SAAI;IACb,SAAS,SAAK;IACd,QAAQ,UAAO;CACf"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { MessageFlags, TextInputStyle } from "discord-api-types/v10";
|
|
2
|
+
import { Modal } from "../../classes/Modal.js";
|
|
3
|
+
import { Row } from "../../classes/components/Row.js";
|
|
4
|
+
import { TextInput } from "../../classes/components/TextInput.js";
|
|
5
|
+
export class GoToPageModal extends Modal {
|
|
6
|
+
title = "Go to Page";
|
|
7
|
+
customId;
|
|
8
|
+
components = [new Row([new PageNumberInput()])];
|
|
9
|
+
constructor(paginatorId, maxPages) {
|
|
10
|
+
super();
|
|
11
|
+
this.customId = `paginator-goto:id=${paginatorId};max=${maxPages}`;
|
|
12
|
+
}
|
|
13
|
+
async run(interaction, data) {
|
|
14
|
+
const pageInput = interaction.fields.getText("page", true);
|
|
15
|
+
const pageNumber = Number.parseInt(pageInput);
|
|
16
|
+
const paginatorId = data.id;
|
|
17
|
+
const maxPages = data.max;
|
|
18
|
+
// Validate page number
|
|
19
|
+
if (Number.isNaN(pageNumber) || pageNumber < 1 || pageNumber > maxPages) {
|
|
20
|
+
return interaction.reply({
|
|
21
|
+
content: `Please enter a valid page number between 1 and ${maxPages}.`,
|
|
22
|
+
flags: MessageFlags.Ephemeral
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
// Find the paginator and navigate to the page
|
|
26
|
+
const paginator = interaction.client.paginators.find((p) => p.id === paginatorId);
|
|
27
|
+
if (!paginator) {
|
|
28
|
+
return interaction.reply({
|
|
29
|
+
content: "Paginator not found in memory.",
|
|
30
|
+
flags: MessageFlags.Ephemeral
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
// Check if user is authorized to use this paginator
|
|
34
|
+
if (paginator.userId && paginator.userId !== interaction.user?.id) {
|
|
35
|
+
return interaction.acknowledge();
|
|
36
|
+
}
|
|
37
|
+
// Convert to 0-based index and navigate
|
|
38
|
+
await paginator.goToPageFromModal(pageNumber - 1, interaction);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
class PageNumberInput extends TextInput {
|
|
42
|
+
label = "Page Number";
|
|
43
|
+
customId = "page";
|
|
44
|
+
style = TextInputStyle.Short;
|
|
45
|
+
placeholder = "Enter page number...";
|
|
46
|
+
minLength = 1;
|
|
47
|
+
maxLength = 10;
|
|
48
|
+
required = true;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=GoToPageModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoToPageModal.js","sourceRoot":"","sources":["../../../../src/plugins/paginator/GoToPageModal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAA;AAIjE,MAAM,OAAO,aAAc,SAAQ,KAAK;IACvC,KAAK,GAAG,YAAY,CAAA;IACpB,QAAQ,CAAQ;IAEhB,UAAU,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,eAAe,EAAE,CAAC,CAAC,CAAC,CAAA;IAE/C,YAAY,WAAmB,EAAE,QAAgB;QAChD,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,QAAQ,GAAG,qBAAqB,WAAW,Q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,eAAgB,SAAQ,SAAS;IACtC,KAAK,GAAG,aAAa,CAAA;IACrB,QAAQ,GAAG,MAAM,CAAA;IACjB,KAAK,GAAG,cAAc,CAAC,KAAK,CAAA;IAC5B,WAAW,GAAG,sBAAsB,CAAA;IACpC,SAAS,GAAG,CAAC,CAAA;IACb,SAAS,GAAG,EAAE,CAAA;IACd,QAAQ,GAAG,IAAI,CAAA;CACf"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Client } from "../../classes/Client.js";
|
|
2
|
+
import type { ButtonInteraction } from "../../internals/ButtonInteraction.js";
|
|
3
|
+
import type { CommandInteraction } from "../../internals/CommandInteraction.js";
|
|
4
|
+
import type { ModalInteraction } from "../../internals/ModalInteraction.js";
|
|
5
|
+
import type { MessagePayloadObject } from "../../types/index.js";
|
|
6
|
+
export declare class Paginator {
|
|
7
|
+
readonly pages: MessagePayloadObject[];
|
|
8
|
+
readonly id: string;
|
|
9
|
+
protected currentPage: number;
|
|
10
|
+
private timeout;
|
|
11
|
+
private readonly timeoutDuration;
|
|
12
|
+
/**
|
|
13
|
+
* The user ID who is allowed to interact with the paginator
|
|
14
|
+
*/
|
|
15
|
+
readonly userId?: string;
|
|
16
|
+
constructor(
|
|
17
|
+
/**
|
|
18
|
+
* The pages to display in the paginator, with no limit on the amount of pages
|
|
19
|
+
*/
|
|
20
|
+
pages: typeof this.pages, {
|
|
21
|
+
/**
|
|
22
|
+
* The client to use for the paginator
|
|
23
|
+
*/
|
|
24
|
+
client,
|
|
25
|
+
/**
|
|
26
|
+
* How long in milliseconds the paginator will wait before disabling the buttons
|
|
27
|
+
* @default 300000 (5 minutes)
|
|
28
|
+
*/
|
|
29
|
+
timeoutDuration,
|
|
30
|
+
/**
|
|
31
|
+
* The user ID who is allowed to interact with the paginator
|
|
32
|
+
*/
|
|
33
|
+
userId }: {
|
|
34
|
+
client: Client;
|
|
35
|
+
timeoutDuration?: number;
|
|
36
|
+
userId?: string;
|
|
37
|
+
});
|
|
38
|
+
private startTimeout;
|
|
39
|
+
private disableButtons;
|
|
40
|
+
destroy(): void;
|
|
41
|
+
private getCurrentPage;
|
|
42
|
+
goToPage(pageIndex: number, interaction: ButtonInteraction): Promise<import("../../index.js").Message<false> | undefined>;
|
|
43
|
+
goToPageFromModal(pageIndex: number, interaction: ModalInteraction): Promise<import("../../index.js").Message<false> | undefined>;
|
|
44
|
+
private createNavigationButtons;
|
|
45
|
+
private getCurrentPageWithButtons;
|
|
46
|
+
getInitialPage(): MessagePayloadObject;
|
|
47
|
+
/**
|
|
48
|
+
* Sends the paginator message using the provided interaction
|
|
49
|
+
* @param interaction The interaction to use for sending the message
|
|
50
|
+
*/
|
|
51
|
+
send(interaction: CommandInteraction): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=Paginator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Paginator.d.ts","sourceRoot":"","sources":["../../../../src/plugins/paginator/Paginator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAGrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAA;AAC3E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAIhE,qBAAa,SAAS;IACrB,QAAQ,CAAC,KAAK,EAAE,oBAAoB,EAAE,CAAA;IACtC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,WAAW,SAAI;IACzB,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAQ;IAExC;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;;IAGvB;;OAEG;IACH,KAAK,EAAE,OAAO,IAAI,CAAC,KAAK,EACxB;IACC;;OAEG;IACH,MAAM;IACN;;;OAGG;IACH,eAAwB;IACxB;;OAEG;IACH,MAAM,EACN,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IAejE,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,cAAc;IAef,OAAO;IAOd,OAAO,CAAC,cAAc;IAMT,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,iBAAiB;IAW1D,iBAAiB,CAC7B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,gBAAgB;IAa9B,OAAO,CAAC,uBAAuB;IAyB/B,OAAO,CAAC,yBAAyB;IAQ1B,cAAc,IAAI,oBAAoB;IAI7C;;;OAGG;IACU,IAAI,CAAC,WAAW,EAAE,kBAAkB;CAGjD"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { ButtonStyle, MessageFlags } from "discord-api-types/v10";
|
|
2
|
+
import { Button } from "../../classes/components/Button.js";
|
|
3
|
+
import { Row } from "../../classes/components/Row.js";
|
|
4
|
+
import { GoToPageModal } from "./GoToPageModal.js";
|
|
5
|
+
export class Paginator {
|
|
6
|
+
pages;
|
|
7
|
+
id;
|
|
8
|
+
currentPage = 0;
|
|
9
|
+
timeout = null;
|
|
10
|
+
timeoutDuration;
|
|
11
|
+
/**
|
|
12
|
+
* The user ID who is allowed to interact with the paginator
|
|
13
|
+
*/
|
|
14
|
+
userId;
|
|
15
|
+
constructor(
|
|
16
|
+
/**
|
|
17
|
+
* The pages to display in the paginator, with no limit on the amount of pages
|
|
18
|
+
*/
|
|
19
|
+
pages, {
|
|
20
|
+
/**
|
|
21
|
+
* The client to use for the paginator
|
|
22
|
+
*/
|
|
23
|
+
client,
|
|
24
|
+
/**
|
|
25
|
+
* How long in milliseconds the paginator will wait before disabling the buttons
|
|
26
|
+
* @default 300000 (5 minutes)
|
|
27
|
+
*/
|
|
28
|
+
timeoutDuration = 300000,
|
|
29
|
+
/**
|
|
30
|
+
* The user ID who is allowed to interact with the paginator
|
|
31
|
+
*/
|
|
32
|
+
userId }) {
|
|
33
|
+
if (pages.length === 0) {
|
|
34
|
+
throw new Error("Paginator must have at least one page");
|
|
35
|
+
}
|
|
36
|
+
this.pages = pages;
|
|
37
|
+
this.timeoutDuration = timeoutDuration;
|
|
38
|
+
this.userId = userId;
|
|
39
|
+
const timestamp = Date.now().toString(36);
|
|
40
|
+
const random = Math.random().toString(36).slice(2, 5);
|
|
41
|
+
this.id = `${timestamp}-${random}`;
|
|
42
|
+
client.paginators.push(this);
|
|
43
|
+
this.startTimeout();
|
|
44
|
+
}
|
|
45
|
+
startTimeout() {
|
|
46
|
+
if (this.timeout) {
|
|
47
|
+
clearTimeout(this.timeout);
|
|
48
|
+
}
|
|
49
|
+
this.timeout = setTimeout(() => {
|
|
50
|
+
this.disableButtons();
|
|
51
|
+
}, this.timeoutDuration);
|
|
52
|
+
}
|
|
53
|
+
disableButtons() {
|
|
54
|
+
const page = this.getCurrentPage();
|
|
55
|
+
if (!page.components)
|
|
56
|
+
return;
|
|
57
|
+
const row = this.createNavigationButtons();
|
|
58
|
+
for (const component of row.components) {
|
|
59
|
+
if ("disabled" in component) {
|
|
60
|
+
component.disabled = true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const otherComponents = page.components.slice(0, -1);
|
|
64
|
+
page.components = [...otherComponents, row];
|
|
65
|
+
}
|
|
66
|
+
destroy() {
|
|
67
|
+
if (this.timeout) {
|
|
68
|
+
clearTimeout(this.timeout);
|
|
69
|
+
this.timeout = null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
getCurrentPage() {
|
|
73
|
+
const page = this.pages[this.currentPage];
|
|
74
|
+
if (!page)
|
|
75
|
+
throw new Error("Invalid page index");
|
|
76
|
+
return page;
|
|
77
|
+
}
|
|
78
|
+
async goToPage(pageIndex, interaction) {
|
|
79
|
+
if (pageIndex < 0 || pageIndex >= this.pages.length) {
|
|
80
|
+
return interaction.reply({
|
|
81
|
+
content: "Invalid page number"
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
this.currentPage = pageIndex;
|
|
85
|
+
this.startTimeout();
|
|
86
|
+
await interaction.update(this.getCurrentPageWithButtons());
|
|
87
|
+
}
|
|
88
|
+
async goToPageFromModal(pageIndex, interaction) {
|
|
89
|
+
if (pageIndex < 0 || pageIndex >= this.pages.length) {
|
|
90
|
+
return interaction.reply({
|
|
91
|
+
content: "Invalid page number",
|
|
92
|
+
flags: MessageFlags.Ephemeral
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
this.currentPage = pageIndex;
|
|
96
|
+
this.startTimeout();
|
|
97
|
+
await interaction.update(this.getCurrentPageWithButtons());
|
|
98
|
+
}
|
|
99
|
+
createNavigationButtons(disabled = false) {
|
|
100
|
+
const backButton = new DirectionButton({
|
|
101
|
+
paginatorId: this.id,
|
|
102
|
+
goToPage: this.currentPage - 1,
|
|
103
|
+
disabled: disabled || this.currentPage === 0,
|
|
104
|
+
label: "Back"
|
|
105
|
+
});
|
|
106
|
+
const pageNumber = new PageNumberButton(this.id, this.currentPage, this.pages.length, disabled);
|
|
107
|
+
const nextButton = new DirectionButton({
|
|
108
|
+
paginatorId: this.id,
|
|
109
|
+
goToPage: this.currentPage + 1,
|
|
110
|
+
disabled: disabled || this.currentPage === this.pages.length - 1,
|
|
111
|
+
label: "Next"
|
|
112
|
+
});
|
|
113
|
+
return new Row([backButton, pageNumber, nextButton]);
|
|
114
|
+
}
|
|
115
|
+
getCurrentPageWithButtons() {
|
|
116
|
+
const page = this.getCurrentPage();
|
|
117
|
+
return {
|
|
118
|
+
...page,
|
|
119
|
+
components: [...(page.components || []), this.createNavigationButtons()]
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
getInitialPage() {
|
|
123
|
+
return this.getCurrentPageWithButtons();
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Sends the paginator message using the provided interaction
|
|
127
|
+
* @param interaction The interaction to use for sending the message
|
|
128
|
+
*/
|
|
129
|
+
async send(interaction) {
|
|
130
|
+
await interaction.reply(this.getInitialPage());
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
class DirectionButton extends Button {
|
|
134
|
+
label;
|
|
135
|
+
customId;
|
|
136
|
+
style = ButtonStyle.Secondary;
|
|
137
|
+
disabled = false;
|
|
138
|
+
constructor({ paginatorId, goToPage, disabled, label }) {
|
|
139
|
+
super();
|
|
140
|
+
this.customId = `paginator:paginatorId=${paginatorId};goToPage=${goToPage}`;
|
|
141
|
+
this.label = label;
|
|
142
|
+
this.disabled = disabled;
|
|
143
|
+
}
|
|
144
|
+
async run(interaction, data) {
|
|
145
|
+
const paginatorId = data.paginatorId;
|
|
146
|
+
const goToPage = Number.parseInt(`${data.goToPage}`);
|
|
147
|
+
const paginator = interaction.client.paginators.find((p) => p.id === paginatorId);
|
|
148
|
+
if (!paginator)
|
|
149
|
+
return interaction.reply({
|
|
150
|
+
content: `Paginator ${paginatorId} not found in memory`
|
|
151
|
+
});
|
|
152
|
+
if (paginator.userId && paginator.userId !== interaction.user?.id)
|
|
153
|
+
return interaction.acknowledge();
|
|
154
|
+
await paginator.goToPage(goToPage, interaction);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
class PageNumberButton extends Button {
|
|
158
|
+
label;
|
|
159
|
+
customId;
|
|
160
|
+
style = ButtonStyle.Secondary;
|
|
161
|
+
disabled;
|
|
162
|
+
constructor(paginatorId, currentPage, totalPages, disabled) {
|
|
163
|
+
super();
|
|
164
|
+
this.label = `${currentPage + 1} / ${totalPages}`;
|
|
165
|
+
this.customId = `paginator-page:id=${paginatorId};max=${totalPages}`;
|
|
166
|
+
this.disabled = disabled || totalPages <= 1;
|
|
167
|
+
}
|
|
168
|
+
async run(interaction, data) {
|
|
169
|
+
const paginatorId = data.id;
|
|
170
|
+
const maxPages = data.max;
|
|
171
|
+
const paginator = interaction.client.paginators.find((p) => p.id === paginatorId);
|
|
172
|
+
if (!paginator)
|
|
173
|
+
return interaction.reply({
|
|
174
|
+
content: "Paginator not found in memory",
|
|
175
|
+
flags: MessageFlags.Ephemeral
|
|
176
|
+
});
|
|
177
|
+
if (paginator.userId && paginator.userId !== interaction.user?.id)
|
|
178
|
+
return interaction.acknowledge();
|
|
179
|
+
const modal = new GoToPageModal(paginatorId, maxPages);
|
|
180
|
+
await interaction.showModal(modal);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=Paginator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Paginator.js","sourceRoot":"","sources":["../../../../src/plugins/paginator/Paginator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEjE,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAA;AAC3D,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAA;AAMrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,MAAM,OAAO,SAAS;IACZ,KAAK,CAAwB;IAC7B,EAAE,CAAQ;IACT,WAAW,GAAG,CAAC,CAAA;IACjB,OAAO,GAA0B,IAAI,CAAA;IAC5B,eAAe,CAAQ;IAExC;;OAEG;IACM,MAAM,CAAS;IAExB;IACC;;OAEG;IACH,KAAwB,EACxB;IACC;;OAEG;IACH,MAAM;IACN;;;OAGG;IACH,eAAe,GAAG,MAAM;IACxB;;OAEG;IACH,MAAM,EACyD;QAEhE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAA;QACzD,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;QACtC,IA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AE,CAAA;QACP,IAAI,CAAC,KAAK,GAAG,GAAG,WAAW,GAAG,CAAC,MAAM,UAAU,EAAE,CAAA;QACjD,IAAI,CAAC,QAAQ,GAAG,qBAAqB,WAAW,QAAQ,UAAU,EAAE,CAAA;QACpE,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,UAAU,IAAI,CAAC,CAAA;IAC5C,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,WAA8B,EAAE,IAAmB;QAC5D,MAAM,WAAW,GAAG,IAAI,CAAC,EAAY,CAAA;QACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAa,CAAA;QACnC,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CACnD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,WAAW,CAC3B,CAAA;QACD,IAAI,CAAC,SAAS;YACb,OAAO,WAAW,CAAC,KAAK,CAAC;gBACxB,OAAO,EAAE,+BAA+B;gBACxC,KAAK,EAAE,YAAY,CAAC,SAAS;aAC7B,CAAC,CAAA;QACH,IAAI,SAAS,CAAC,MAAM,IAAI,SAAS,CAAC,MAAM,KAAK,WAAW,CAAC,IAAI,EAAE,EAAE;YAChE,OAAO,WAAW,CAAC,WAAW,EAAE,CAAA;QAEjC,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAA;QACtD,MAAM,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IACnC,CAAC;CACD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare module "../../classes/Client.js" {
|
|
2
|
+
interface Client {
|
|
3
|
+
paginators: Paginator[];
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
import { GoToPageModal } from "./GoToPageModal.js";
|
|
7
|
+
import { Paginator } from "./Paginator.js";
|
|
8
|
+
export { Paginator, GoToPageModal };
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/paginator/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,yBAAyB,CAAC;IACxC,UAAU,MAAM;QACf,UAAU,EAAE,SAAS,EAAE,CAAA;KACvB;CACD;AAGD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAO1C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Client } from "../../classes/Client.js";
|
|
2
|
+
import { GoToPageModal } from "./GoToPageModal.js";
|
|
3
|
+
import { Paginator } from "./Paginator.js";
|
|
4
|
+
Object.assign(Client.prototype, {
|
|
5
|
+
Paginator,
|
|
6
|
+
paginators: []
|
|
7
|
+
});
|
|
8
|
+
export { Paginator, GoToPageModal };
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/paginator/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE;IAC/B,SAAS;IACT,UAAU,EAAE,EAAiB;CAC7B,CAAC,CAAA;AAEF,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -26,7 +26,9 @@ export declare class ShardingPlugin extends Plugin {
|
|
|
26
26
|
protected spawnQueue: number[];
|
|
27
27
|
protected spawning: boolean;
|
|
28
28
|
protected gatewayInfo?: APIGatewayBotInfo;
|
|
29
|
+
customGatewayPlugin: typeof GatewayPlugin;
|
|
29
30
|
constructor(options: ShardingPluginOptions);
|
|
31
|
+
get ping(): Record<number, number | null>;
|
|
30
32
|
registerClient(client: Client): Promise<void>;
|
|
31
33
|
protected processSpawnQueue(): Promise<void>;
|
|
32
34
|
disconnect(): void;
|
|
@@ -37,6 +39,6 @@ export declare class ShardingPlugin extends Plugin {
|
|
|
37
39
|
/**
|
|
38
40
|
* Discord's sharding formula
|
|
39
41
|
*/
|
|
40
|
-
|
|
42
|
+
calculateShardId(guildId: string, totalShards: number): number;
|
|
41
43
|
}
|
|
42
44
|
//# sourceMappingURL=ShardingPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShardingPlugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/sharding/ShardingPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAE/D,MAAM,WAAW,qBAChB,SAAQ,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC;IAC3C;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,qBAAa,cAAe,SAAQ,MAAM;IACzC,QAAQ,CAAC,EAAE,cAAa;IACxB,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAY;IACvD,QAAQ,CAAC,MAAM,EAAE,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