@seedcord/gateway 0.3.1 → 0.4.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/index.d.mts +246 -48
- package/dist/index.mjs +230 -104
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { WinstonConsoleSink, WinstonFileSink } from "@seedcord/logger/node";
|
|
3
|
+
import { AnyCustomId, AutocompletableNames, AutocompleteRouteBrand, CacheFor, ChoiceValueOf, ComponentDefsBrand, ComponentKindBrand, ContextMenuKindBrand, ContextMenuLeaves, ContextMenuNamesBrand, EntryFor, FocusedField, GateFitsWith, HasComponentDefs, Initializeable, MatchArms, MenuCacheFor, NamesFor, PageCursor, SingleParams, SlashOptions as SlashOptions$1, SlashRouteBrand } from "@seedcord/core/internal";
|
|
4
|
+
import { ArraySourceBase, AutocompleteOptions, BaseHandler as BaseHandler$1, BaseReplySender, Bus, CoreBase, CursorSourceBase, DispatchContext, Gate, GateContextBase, GateNoticeOptions, GuildPermissionsContext, ModalLike, Notice, PageSourceBase, PaginatorBase, PaginatorConfig, PermissionNoticeOverrides, PermissionScope, RepliableHandler as RepliableHandler$1, RequiredOf, ResolvedEmoji, SelectMenuKind, SlashRegistry, Subscriber as Subscriber$1, SubscriptionKey, WebhookLog as WebhookLog$1 } from "@seedcord/core";
|
|
4
5
|
import { Logger } from "@seedcord/logger";
|
|
5
|
-
import { APIInteractionGuildMember, APIModalInteractionResponseCallbackData, AnySelectMenuInteraction, ApplicationCommandOptionChoiceData, ApplicationCommandType, ApplicationEmoji, AutocompleteInteraction, BaseMessageOptions, BooleanCache, ButtonInteraction, ButtonStyle, CacheType, CacheTypeReducer, ChannelSelectMenuInteraction, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, CommandInteractionOption, ContextMenuCommandInteraction, Events, Guild, GuildEmoji, GuildMember, Interaction, MentionableSelectMenuInteraction, Message, MessageContextMenuCommandInteraction, ModalSubmitInteraction, Role, RoleSelectMenuInteraction, StringSelectMenuInteraction, TextChannel, User, UserContextMenuCommandInteraction, UserSelectMenuInteraction } from "discord.js";
|
|
6
|
+
import { APIInteractionGuildMember, APIModalInteractionResponseCallbackData, AnySelectMenuInteraction, ApplicationCommandOptionChoiceData, ApplicationCommandType, ApplicationEmoji, AutocompleteInteraction, BaseMessageOptions, BooleanCache, ButtonInteraction, ButtonStyle, CacheType, CacheTypeReducer, ChannelSelectMenuInteraction, ChatInputCommandInteraction, Client, ClientEvents, ClientOptions, CommandInteractionOption, ContextMenuCommandInteraction, Events, Guild, GuildEmoji, GuildMember, Interaction, MentionableSelectMenuInteraction, Message, MessageContextMenuCommandInteraction, ModalSubmitFields, ModalSubmitInteraction, Role, RoleSelectMenuInteraction, StringSelectMenuInteraction, TextChannel, User, UserContextMenuCommandInteraction, UserSelectMenuInteraction } from "discord.js";
|
|
6
7
|
import { Plugin as Plugin$1, PluginLifecycleSpec, PluginOptions, PluginOptions as PluginOptions$1 } from "@seedcord/core/plugin";
|
|
7
|
-
import { CoordinatedShutdown, CoordinatedStartup, Pluggable } from "@seedcord/core/node
|
|
8
|
-
import {
|
|
8
|
+
import { CoordinatedShutdown, CoordinatedStartup, Pluggable } from "@seedcord/core/node";
|
|
9
|
+
import { CommandRegistry } from "@seedcord/core/node/internal";
|
|
10
|
+
import { HostAugmentTarget, HostVersion, SeedcordBrand, SeedcordInstance } from "@seedcord/types/internal";
|
|
9
11
|
import { BotConfig, Config, DeferOpts, EmojiMap, EventFrequency, HealthCheckOption, HmrAware, HmrUpdateEvent, IRateLimiter, ReplyResponse, SendOpts, TypedOmit } from "@seedcord/types";
|
|
10
12
|
import { REST } from "@discordjs/rest";
|
|
11
13
|
export * from "@seedcord/errors";
|
|
@@ -22,8 +24,8 @@ declare module '@seedcord/core/internal' {
|
|
|
22
24
|
unhandledEventError: {
|
|
23
25
|
error: Error;
|
|
24
26
|
};
|
|
25
|
-
/** Triggered
|
|
26
|
-
|
|
27
|
+
/** Triggered before an event's handlers run. An event that no handler registered never triggers it. */
|
|
28
|
+
eventDispatching: { [Name in keyof ClientEvents]: {
|
|
27
29
|
name: Name;
|
|
28
30
|
args: ClientEvents[Name];
|
|
29
31
|
}; }[keyof ClientEvents];
|
|
@@ -76,38 +78,140 @@ interface GatewayConfig extends Config {
|
|
|
76
78
|
healthCheck?: HealthCheckOption;
|
|
77
79
|
}
|
|
78
80
|
//#endregion
|
|
81
|
+
//#region src/bot/controllers/EventDispatcher.d.ts
|
|
82
|
+
/**
|
|
83
|
+
* Interactions route through InteractionDispatcher.
|
|
84
|
+
*
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
declare class EventDispatcher implements Initializeable, HmrAware {
|
|
88
|
+
protected core: Core;
|
|
89
|
+
private readonly logger;
|
|
90
|
+
private isInitialized;
|
|
91
|
+
private readonly eventMap;
|
|
92
|
+
private readonly middlewares;
|
|
93
|
+
private readonly executedOnceHandlers;
|
|
94
|
+
private readonly attachedEvents;
|
|
95
|
+
private readonly inFlight;
|
|
96
|
+
private draining;
|
|
97
|
+
private loading;
|
|
98
|
+
private readonly loadedHandlers;
|
|
99
|
+
private readonly loadedMiddlewares;
|
|
100
|
+
private readonly hmrHandler?;
|
|
101
|
+
constructor(core: Core);
|
|
102
|
+
private getArtifacts;
|
|
103
|
+
init(): Promise<void>;
|
|
104
|
+
private reportLoad;
|
|
105
|
+
private loadHandlers;
|
|
106
|
+
private loadMiddlewares;
|
|
107
|
+
/** @internal */
|
|
108
|
+
onHmr(event: HmrUpdateEvent): Promise<void>;
|
|
109
|
+
private unregisterHandler;
|
|
110
|
+
private unregisterMiddleware;
|
|
111
|
+
private registerMiddleware;
|
|
112
|
+
private runMiddlewares;
|
|
113
|
+
private isEventHandlerClass;
|
|
114
|
+
private isMiddlewareClass;
|
|
115
|
+
private registerHandler;
|
|
116
|
+
private attachToClient;
|
|
117
|
+
private attachListener;
|
|
118
|
+
stopAccepting(): void;
|
|
119
|
+
drain(timeoutMs: number): Promise<void>;
|
|
120
|
+
private processEvent;
|
|
121
|
+
private processHandler;
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/bot/controllers/InteractionDispatcher.d.ts
|
|
125
|
+
declare class InteractionDispatcher implements Initializeable, HmrAware {
|
|
126
|
+
protected core: Core;
|
|
127
|
+
private readonly logger;
|
|
128
|
+
private isInitialized;
|
|
129
|
+
private readonly slashMap;
|
|
130
|
+
private readonly buttonMap;
|
|
131
|
+
private readonly modalMap;
|
|
132
|
+
private readonly stringSelectMap;
|
|
133
|
+
private readonly userSelectMap;
|
|
134
|
+
private readonly roleSelectMap;
|
|
135
|
+
private readonly channelSelectMap;
|
|
136
|
+
private readonly mentionableSelectMap;
|
|
137
|
+
private readonly messageContextMenuMap;
|
|
138
|
+
private readonly userContextMenuMap;
|
|
139
|
+
private readonly autocompleteMap;
|
|
140
|
+
private readonly handlerFiles;
|
|
141
|
+
private readonly keysToIgnore;
|
|
142
|
+
private readonly middlewares;
|
|
143
|
+
private readonly inFlight;
|
|
144
|
+
private draining;
|
|
145
|
+
private loading;
|
|
146
|
+
private readonly loadedHandlers;
|
|
147
|
+
private readonly loadedMiddlewares;
|
|
148
|
+
private readonly hmrHandler?;
|
|
149
|
+
private readonly routeTypes;
|
|
150
|
+
constructor(core: Core);
|
|
151
|
+
warnUnhandledRoutes(commandLeaves: Iterable<string>): void;
|
|
152
|
+
warnUnhandledContextMenuRoutes(leaves: ContextMenuLeaves): void;
|
|
153
|
+
private getArtifacts;
|
|
154
|
+
init(): Promise<void>;
|
|
155
|
+
private reportLoad;
|
|
156
|
+
private loadHandlers;
|
|
157
|
+
private loadMiddlewares;
|
|
158
|
+
private registerMiddleware;
|
|
159
|
+
private isHandlerClass;
|
|
160
|
+
private isMiddlewareClass;
|
|
161
|
+
private registerHandler;
|
|
162
|
+
onHmr(event: HmrUpdateEvent): Promise<void>;
|
|
163
|
+
private unregisterHandler;
|
|
164
|
+
private unregisterMiddleware;
|
|
165
|
+
private attachToClient;
|
|
166
|
+
stopAccepting(): void;
|
|
167
|
+
drain(timeoutMs: number): Promise<void>;
|
|
168
|
+
private handleCustomIdInteraction;
|
|
169
|
+
private processInteraction;
|
|
170
|
+
private answer;
|
|
171
|
+
private buildHandler;
|
|
172
|
+
private runMiddlewares;
|
|
173
|
+
private gateRefusal;
|
|
174
|
+
private handleInteraction;
|
|
175
|
+
private handleSlashCommand;
|
|
176
|
+
private handleButton;
|
|
177
|
+
private handleModal;
|
|
178
|
+
private handleStringSelectMenu;
|
|
179
|
+
private handleUserSelectMenu;
|
|
180
|
+
private handleRoleSelectMenu;
|
|
181
|
+
private handleChannelSelectMenu;
|
|
182
|
+
private handleMentionableSelectMenu;
|
|
183
|
+
private handleMessageContextMenu;
|
|
184
|
+
private handleUserContextMenu;
|
|
185
|
+
private handleAutocomplete;
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
79
188
|
//#region src/bot/Bot.d.ts
|
|
80
189
|
declare const loggerSlot: unique symbol;
|
|
190
|
+
declare const initSlot: unique symbol;
|
|
191
|
+
declare const controllersSlot: unique symbol;
|
|
192
|
+
interface Controllers {
|
|
193
|
+
readonly interactions?: InteractionDispatcher | undefined;
|
|
194
|
+
readonly events?: EventDispatcher | undefined;
|
|
195
|
+
readonly commandRegistry?: CommandRegistry | undefined;
|
|
196
|
+
}
|
|
81
197
|
/**
|
|
82
198
|
* The Discord client and its controllers. Access it through `core.bot`.
|
|
83
199
|
*/
|
|
84
|
-
declare class Bot implements
|
|
200
|
+
declare class Bot implements HmrAware {
|
|
201
|
+
#private;
|
|
85
202
|
readonly botToken: string;
|
|
86
|
-
private readonly logger;
|
|
87
203
|
/** @internal */
|
|
88
204
|
readonly [loggerSlot]: Logger;
|
|
89
|
-
private isInitialized;
|
|
90
|
-
private readonly intents;
|
|
91
|
-
private readonly _client;
|
|
92
|
-
private readonly interactions?;
|
|
93
|
-
private readonly events?;
|
|
94
|
-
private readonly emojiInjector;
|
|
95
|
-
private readonly commandRegistry?;
|
|
96
205
|
/** @internal */
|
|
97
206
|
onHmr(event: HmrUpdateEvent): Promise<void>;
|
|
98
207
|
/** @internal */
|
|
99
208
|
constructor(core: Core);
|
|
100
209
|
/** @internal */
|
|
101
|
-
get
|
|
102
|
-
private registerShutdownTasks;
|
|
103
|
-
private stopAccepting;
|
|
104
|
-
private drain;
|
|
210
|
+
get [controllersSlot](): Controllers;
|
|
105
211
|
/** @internal */
|
|
106
|
-
|
|
212
|
+
get applicationId(): string;
|
|
107
213
|
/** @internal */
|
|
108
|
-
|
|
109
|
-
private login;
|
|
110
|
-
private logout;
|
|
214
|
+
[initSlot](): Promise<void>;
|
|
111
215
|
get client(): Client;
|
|
112
216
|
}
|
|
113
217
|
//#endregion
|
|
@@ -740,9 +844,15 @@ declare abstract class SlashHandler<Route extends keyof SlashRegistry, Cache ext
|
|
|
740
844
|
/** @internal */
|
|
741
845
|
readonly [SlashRouteBrand]?: Route;
|
|
742
846
|
/**
|
|
743
|
-
* The typed options for this command's route.
|
|
744
|
-
*
|
|
745
|
-
*
|
|
847
|
+
* The typed options for this command's route. Only the getters for kinds this command declares appear.
|
|
848
|
+
* Each getter's name argument is restricted to that command's options of its kind.
|
|
849
|
+
*
|
|
850
|
+
* - A required option drops the null.
|
|
851
|
+
* - Choices narrow to their literal union.
|
|
852
|
+
* - A channel option declared with `addChannelTypes` narrows to those types.
|
|
853
|
+
*
|
|
854
|
+
* Use `this.event.options` directly for anything outside this view, such as `getSubcommand()`.
|
|
855
|
+
* However, for the common case, the methods in this would suffice.
|
|
746
856
|
*/
|
|
747
857
|
protected get options(): SlashOptions<Route, Cache>;
|
|
748
858
|
/**
|
|
@@ -762,8 +872,8 @@ declare abstract class SlashHandler<Route extends keyof SlashRegistry, Cache ext
|
|
|
762
872
|
* class ModHandler extends SlashHandler<'ban' | 'kick'> {
|
|
763
873
|
* async execute() {
|
|
764
874
|
* await this.match({
|
|
765
|
-
* ban: (options) => this.event.guild?.members.ban(options.getUser('target'
|
|
766
|
-
* kick: (options) => this.event.guild?.members.kick(options.getUser('member'
|
|
875
|
+
* ban: (options) => this.event.guild?.members.ban(options.getUser('target').id),
|
|
876
|
+
* kick: (options) => this.event.guild?.members.kick(options.getUser('member').id)
|
|
767
877
|
* });
|
|
768
878
|
* }
|
|
769
879
|
* }
|
|
@@ -773,6 +883,8 @@ declare abstract class SlashHandler<Route extends keyof SlashRegistry, Cache ext
|
|
|
773
883
|
}
|
|
774
884
|
//#endregion
|
|
775
885
|
//#region src/handlers/interaction/ContextMenuHandler.d.ts
|
|
886
|
+
type UserMenuArms<Names extends NamesFor<ApplicationCommandType.User>, Ret> = { [Name in Names]: (target: User, member: CacheTypeReducer<MenuCacheFor<ApplicationCommandType.User, Name>, GuildMember, APIInteractionGuildMember> | null) => Promisable<Ret>; };
|
|
887
|
+
type MessageMenuArms<Names extends NamesFor<ApplicationCommandType.Message>, Ret> = { [Name in Names]: (target: Message<BooleanCache<MenuCacheFor<ApplicationCommandType.Message, Name>>>) => Promisable<Ret>; };
|
|
776
888
|
/**
|
|
777
889
|
* Base class for a user context-menu command handler (right-click a user).
|
|
778
890
|
*
|
|
@@ -800,6 +912,34 @@ declare abstract class UserContextMenuHandler<Names extends NamesFor<Application
|
|
|
800
912
|
protected get target(): User;
|
|
801
913
|
/** The right-clicked user's guild member, null outside a guild. */
|
|
802
914
|
protected get targetMember(): CacheTypeReducer<Cache, GuildMember, APIInteractionGuildMember> | null;
|
|
915
|
+
/** Which of the registered commands fired. */
|
|
916
|
+
protected get commandName(): Names;
|
|
917
|
+
/**
|
|
918
|
+
* Run the arm for whichever command fired. Use this only when the handler is registered for several
|
|
919
|
+
* names.
|
|
920
|
+
*
|
|
921
|
+
* Provide one arm per registered name, keyed by the name Discord shows in the right-click menu. Each
|
|
922
|
+
* arm receives the clicked user and that user's guild member, both narrowed to the cache state of that
|
|
923
|
+
* one command. The arms must cover every name in the generic. A missing name or an unknown key is a
|
|
924
|
+
* compile error.
|
|
925
|
+
*
|
|
926
|
+
* @param arms - One handler per registered command name.
|
|
927
|
+
* @returns The result of the arm that ran.
|
|
928
|
+
*
|
|
929
|
+
* @example
|
|
930
|
+
* ```ts
|
|
931
|
+
* \@UserContextMenuRoute('View Profile', 'Warn')
|
|
932
|
+
* class Moderation extends UserContextMenuHandler<'View Profile' | 'Warn'> {
|
|
933
|
+
* async execute() {
|
|
934
|
+
* await this.match({
|
|
935
|
+
* 'View Profile': (user) => this.reply(`Profile for ${user.tag}.`),
|
|
936
|
+
* Warn: (user, member) => this.reply(`Warned ${member?.displayName ?? user.tag}.`)
|
|
937
|
+
* });
|
|
938
|
+
* }
|
|
939
|
+
* }
|
|
940
|
+
* ```
|
|
941
|
+
*/
|
|
942
|
+
protected match<Ret>(arms: UserMenuArms<Names, Ret>): Promise<Ret>;
|
|
803
943
|
}
|
|
804
944
|
/**
|
|
805
945
|
* Base class for a message context-menu command handler (right-click a message).
|
|
@@ -826,6 +966,33 @@ declare abstract class MessageContextMenuHandler<Names extends NamesFor<Applicat
|
|
|
826
966
|
/** @internal */
|
|
827
967
|
readonly [ContextMenuNamesBrand]?: Names;
|
|
828
968
|
protected get target(): Message<BooleanCache<Cache>>;
|
|
969
|
+
/** Which of the registered commands fired. */
|
|
970
|
+
protected get commandName(): Names;
|
|
971
|
+
/**
|
|
972
|
+
* Run the arm for whichever command fired. Use this only when the handler is registered for several
|
|
973
|
+
* names.
|
|
974
|
+
*
|
|
975
|
+
* Provide one arm per registered name, keyed by the name Discord shows in the right-click menu. Each
|
|
976
|
+
* arm receives the clicked message, narrowed to the cache state of that one command. The arms must
|
|
977
|
+
* cover every name in the generic. A missing name or an unknown key is a compile error.
|
|
978
|
+
*
|
|
979
|
+
* @param arms - One handler per registered command name.
|
|
980
|
+
* @returns The result of the arm that ran.
|
|
981
|
+
*
|
|
982
|
+
* @example
|
|
983
|
+
* ```ts
|
|
984
|
+
* \@MessageContextMenuRoute('Report Message', 'Pin Message')
|
|
985
|
+
* class MessageTools extends MessageContextMenuHandler<'Report Message' | 'Pin Message'> {
|
|
986
|
+
* async execute() {
|
|
987
|
+
* await this.match({
|
|
988
|
+
* 'Report Message': (message) => this.report(message),
|
|
989
|
+
* 'Pin Message': (message) => message.pin()
|
|
990
|
+
* });
|
|
991
|
+
* }
|
|
992
|
+
* }
|
|
993
|
+
* ```
|
|
994
|
+
*/
|
|
995
|
+
protected match<Ret>(arms: MessageMenuArms<Names, Ret>): Promise<Ret>;
|
|
829
996
|
}
|
|
830
997
|
//#endregion
|
|
831
998
|
//#region src/handlers/interaction/AutocompleteHandler.d.ts
|
|
@@ -992,8 +1159,8 @@ declare abstract class ButtonHandler<Defs extends readonly AnyCustomId[], Cache
|
|
|
992
1159
|
*
|
|
993
1160
|
* Register the customId definitions this handler decodes with `@ModalRoute`, list the same ones in the
|
|
994
1161
|
* generic, then read `this.params` for a single route or `this.match` for several. Read the submitted
|
|
995
|
-
* inputs from `this.
|
|
996
|
-
*
|
|
1162
|
+
* inputs from `this.fields`. Reply through the handler members. `showModal` fails compilation on this kind,
|
|
1163
|
+
* because Discord forbids opening a modal in response to a modal.
|
|
997
1164
|
*
|
|
998
1165
|
* @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof ConfigId]`.
|
|
999
1166
|
* @typeParam Cache - The interaction cache state, `'cached'` by default.
|
|
@@ -1004,7 +1171,7 @@ declare abstract class ButtonHandler<Defs extends readonly AnyCustomId[], Cache
|
|
|
1004
1171
|
* class ConfigModal extends ModalHandler<[typeof ConfigId]> {
|
|
1005
1172
|
* async execute() {
|
|
1006
1173
|
* const { guildId } = this.params;
|
|
1007
|
-
* const name = this.
|
|
1174
|
+
* const name = this.fields.getTextInputValue('name');
|
|
1008
1175
|
* await this.reply(`saved ${name} for ${guildId}`);
|
|
1009
1176
|
* }
|
|
1010
1177
|
* }
|
|
@@ -1013,6 +1180,8 @@ declare abstract class ButtonHandler<Defs extends readonly AnyCustomId[], Cache
|
|
|
1013
1180
|
declare abstract class ModalHandler<Defs extends readonly AnyCustomId[], Cache extends CacheType = 'cached'> extends ComponentHandler<ModalSubmitInteraction<Cache>, Defs> {
|
|
1014
1181
|
/** @internal */
|
|
1015
1182
|
readonly [ComponentKindBrand]?: 'modal';
|
|
1183
|
+
/** The fields this modal submitted, read by custom id. */
|
|
1184
|
+
protected get fields(): ModalSubmitFields<Cache>;
|
|
1016
1185
|
/** Rewrite the message this modal was opened from. Throws when a command opened the modal. */
|
|
1017
1186
|
protected update(response: GatewayReplyResponse | string): Promise<SentMessage>;
|
|
1018
1187
|
/** Acknowledge the submit without changing the source message. Throws when a command opened the modal. */
|
|
@@ -1021,14 +1190,18 @@ declare abstract class ModalHandler<Defs extends readonly AnyCustomId[], Cache e
|
|
|
1021
1190
|
}
|
|
1022
1191
|
//#endregion
|
|
1023
1192
|
//#region src/handlers/interaction/components/SelectMenuHandler.d.ts
|
|
1193
|
+
type SelectKey = 'values' | 'users' | 'members' | 'roles' | 'channels';
|
|
1194
|
+
type EventMember<Kind extends SelectMenuKind, Cache extends CacheType, Key extends SelectKey> = Key extends keyof SelectMenuInteractionFor<Kind, Cache> ? SelectMenuInteractionFor<Kind, Cache>[Key] : never;
|
|
1024
1195
|
type SelectMenuInteractionFor<SelectMenu extends SelectMenuKind, Cache extends CacheType = CacheType> = SelectMenu extends SelectMenuKind.String ? StringSelectMenuInteraction<Cache> : SelectMenu extends SelectMenuKind.User ? UserSelectMenuInteraction<Cache> : SelectMenu extends SelectMenuKind.Role ? RoleSelectMenuInteraction<Cache> : SelectMenu extends SelectMenuKind.Channel ? ChannelSelectMenuInteraction<Cache> : SelectMenu extends SelectMenuKind.Mentionable ? MentionableSelectMenuInteraction<Cache> : never;
|
|
1025
1196
|
/**
|
|
1026
1197
|
* Base class for a select menu handler.
|
|
1027
1198
|
*
|
|
1028
|
-
* Pass the select kind first and the customId definitions second, the same order as `@SelectMenuRoute
|
|
1029
|
-
*
|
|
1030
|
-
*
|
|
1031
|
-
*
|
|
1199
|
+
* Pass the select kind first and the customId definitions second, the same order as `@SelectMenuRoute`.
|
|
1200
|
+
* Read the picked ids from `this.values`. The kind decides which of `this.users`, `this.members`,
|
|
1201
|
+
* `this.roles`, and `this.channels` this handler carries. The rest are `never`.
|
|
1202
|
+
*
|
|
1203
|
+
* Read `this.params` for a single route or `this.match` for several. Reply through the handler members, or
|
|
1204
|
+
* rewrite the source message with `this.update`.
|
|
1032
1205
|
*
|
|
1033
1206
|
* @typeParam Kind - The select kind from {@link SelectMenuKind}, e.g. `SelectMenuKind.User`.
|
|
1034
1207
|
* @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof AssignId]`.
|
|
@@ -1040,7 +1213,7 @@ type SelectMenuInteractionFor<SelectMenu extends SelectMenuKind, Cache extends C
|
|
|
1040
1213
|
* class AssignSelect extends SelectMenuHandler<SelectMenuKind.User, [typeof AssignId]> {
|
|
1041
1214
|
* async execute() {
|
|
1042
1215
|
* const { roleId } = this.params;
|
|
1043
|
-
* await this.reply(`assigning ${this.
|
|
1216
|
+
* await this.reply(`assigning ${this.users.size} member(s) to <@&${roleId}>`);
|
|
1044
1217
|
* }
|
|
1045
1218
|
* }
|
|
1046
1219
|
* ```
|
|
@@ -1048,6 +1221,17 @@ type SelectMenuInteractionFor<SelectMenu extends SelectMenuKind, Cache extends C
|
|
|
1048
1221
|
declare abstract class SelectMenuHandler<Kind extends SelectMenuKind, Defs extends readonly AnyCustomId[], Cache extends CacheType = 'cached'> extends ComponentHandler<SelectMenuInteractionFor<Kind, Cache>, Defs> {
|
|
1049
1222
|
/** @internal */
|
|
1050
1223
|
readonly [ComponentKindBrand]?: Kind;
|
|
1224
|
+
private eventMember;
|
|
1225
|
+
/** The ids this select picked. */
|
|
1226
|
+
protected get values(): string[];
|
|
1227
|
+
/** The users this select picked. */
|
|
1228
|
+
protected get users(): EventMember<Kind, Cache, 'users'>;
|
|
1229
|
+
/** The guild members behind the picked users. Discord resolves these only inside a guild. */
|
|
1230
|
+
protected get members(): EventMember<Kind, Cache, 'members'>;
|
|
1231
|
+
/** The roles this select picked. */
|
|
1232
|
+
protected get roles(): EventMember<Kind, Cache, 'roles'>;
|
|
1233
|
+
/** The channels this select picked. */
|
|
1234
|
+
protected get channels(): EventMember<Kind, Cache, 'channels'>;
|
|
1051
1235
|
}
|
|
1052
1236
|
//#endregion
|
|
1053
1237
|
//#region src/bot/decorators/Middlewares.d.ts
|
|
@@ -1345,7 +1529,7 @@ interface DefaultConfirmOptions extends ConfirmOptions {
|
|
|
1345
1529
|
* \@SlashRoute('ban')
|
|
1346
1530
|
* class BanHandler extends SlashHandler<'ban'> {
|
|
1347
1531
|
* async execute() {
|
|
1348
|
-
* const target = this.options.getUser('target'
|
|
1532
|
+
* const target = this.options.getUser('target');
|
|
1349
1533
|
* if (!(await getConfirmation(this, `Ban ${target.tag}? This cannot be undone.`))) return;
|
|
1350
1534
|
* await this.event.guild?.members.ban(target.id);
|
|
1351
1535
|
* }
|
|
@@ -1396,7 +1580,7 @@ declare function getConfirmation(handler: RepliableHandler<NonModalInteraction>,
|
|
|
1396
1580
|
* }
|
|
1397
1581
|
* }
|
|
1398
1582
|
*
|
|
1399
|
-
* const target = this.options.getUser('target'
|
|
1583
|
+
* const target = this.options.getUser('target');
|
|
1400
1584
|
* const confirmed = await getConfirmation(
|
|
1401
1585
|
* this,
|
|
1402
1586
|
* (ids) => ({ components: [new BanPrompt(`Ban ${target.tag}?`).component, new ConfirmRow(ids).component] }),
|
|
@@ -1453,15 +1637,29 @@ declare class Paginator<Item, const Prefix extends string> extends PaginatorBase
|
|
|
1453
1637
|
readonly Handler: PaginatorHandlerCtor<Prefix>;
|
|
1454
1638
|
constructor(config: PaginatorConfig<Item, Prefix, PageContext>);
|
|
1455
1639
|
/**
|
|
1456
|
-
* Render page
|
|
1457
|
-
*
|
|
1640
|
+
* Render a page as a {@link ReplyResponse} without sending anything.
|
|
1641
|
+
*
|
|
1642
|
+
* @param handler - The handler rendering the page, normally `this`.
|
|
1643
|
+
* @param n - The zero-based page.
|
|
1644
|
+
*/
|
|
1645
|
+
page(handler: RepliableHandler<Repliables>, n: number): Promise<ReplyResponse>;
|
|
1646
|
+
/**
|
|
1647
|
+
* Send a page through the handler's sender. The sender picks reply, edit, or followUp from its ack state.
|
|
1458
1648
|
*
|
|
1459
1649
|
* @param handler - The handler starting the paginator, normally `this`.
|
|
1650
|
+
* @param n - The zero-based page to open on.
|
|
1460
1651
|
*/
|
|
1461
|
-
start(handler: RepliableHandler<Repliables
|
|
1652
|
+
start(handler: RepliableHandler<Repliables>, n?: number): Promise<SentMessage>;
|
|
1462
1653
|
}
|
|
1463
1654
|
//#endregion
|
|
1464
1655
|
//#region src/pagination/sources.d.ts
|
|
1656
|
+
/**
|
|
1657
|
+
* The one method a paginator calls on a source, once per click. Implement it for a source neither shipped
|
|
1658
|
+
* one covers.
|
|
1659
|
+
*
|
|
1660
|
+
* @typeParam Item - The item type the source pages over.
|
|
1661
|
+
*/
|
|
1662
|
+
type PageSource<Item> = PageSourceBase<Item, PageContext>;
|
|
1465
1663
|
/**
|
|
1466
1664
|
* A source for a bounded list you can load whole. It loads the full list on every click, then slices the
|
|
1467
1665
|
* page, so the real total is known (a real last button, "Page X of Y"). Cache inside your loader if the
|
|
@@ -1469,7 +1667,7 @@ declare class Paginator<Item, const Prefix extends string> extends PaginatorBase
|
|
|
1469
1667
|
*
|
|
1470
1668
|
* @typeParam Item - The item type, inferred from the loader's return.
|
|
1471
1669
|
*/
|
|
1472
|
-
declare class ArraySource<Item> extends
|
|
1670
|
+
declare class ArraySource<Item> extends ArraySourceBase<Item, PageContext> {}
|
|
1473
1671
|
/**
|
|
1474
1672
|
* A source for a large or unknown-length set you fetch one page at a time (SQL LIMIT/OFFSET, a paged API).
|
|
1475
1673
|
* The fetcher receives the page index and the page size and reports whether a next page exists. A cursor
|
|
@@ -1478,7 +1676,7 @@ declare class ArraySource<Item> extends ArraySource$1<Item, PageContext> {}
|
|
|
1478
1676
|
*
|
|
1479
1677
|
* @typeParam Item - The item type, inferred from the fetcher's slice.
|
|
1480
1678
|
*/
|
|
1481
|
-
declare class CursorSource<Item> extends
|
|
1679
|
+
declare class CursorSource<Item> extends CursorSourceBase<Item, PageContext> {}
|
|
1482
1680
|
//#endregion
|
|
1483
1681
|
//#region src/subscribers/index.d.ts
|
|
1484
1682
|
/**
|
|
@@ -1527,9 +1725,9 @@ declare class Seedcord extends Pluggable<'gateway', 'server'> implements Core, S
|
|
|
1527
1725
|
/** @internal */
|
|
1528
1726
|
readonly [SeedcordBrand] = true;
|
|
1529
1727
|
/** @internal */
|
|
1530
|
-
readonly
|
|
1728
|
+
readonly [HostAugmentTarget] = "@seedcord/gateway";
|
|
1531
1729
|
/** @internal */
|
|
1532
|
-
readonly
|
|
1730
|
+
readonly [HostVersion]: string;
|
|
1533
1731
|
private readonly healthCheck?;
|
|
1534
1732
|
private readonly hmrManager;
|
|
1535
1733
|
/** @see {@link Bus} */
|
|
@@ -1550,7 +1748,7 @@ declare class Seedcord extends Pluggable<'gateway', 'server'> implements Core, S
|
|
|
1550
1748
|
constructor(config: GatewayConfig);
|
|
1551
1749
|
/** The bot's discord username, populated after login. */
|
|
1552
1750
|
get username(): string | undefined;
|
|
1553
|
-
protected static reset():
|
|
1751
|
+
protected static reset(host?: object): boolean;
|
|
1554
1752
|
private registerStartupTasks;
|
|
1555
1753
|
/**
|
|
1556
1754
|
* Starts the bot and runs all initialization tasks
|
|
@@ -1565,5 +1763,5 @@ declare class Seedcord extends Pluggable<'gateway', 'server'> implements Core, S
|
|
|
1565
1763
|
/** Package version */
|
|
1566
1764
|
declare const version: string;
|
|
1567
1765
|
//#endregion
|
|
1568
|
-
export { ArraySource, AssignRoleNoticeOverrides, AutocompleteHandler, BaseHandler, ButtonHandler, type CheckPermissionOptions, ComponentHandler, type ConfirmOptions, type Core, CursorSource, type DefaultConfirmOptions, Emojis, type EventGateContext, EventHandler, EventMiddleware, type EventSpec, type EventsConfig, type GateContext, Gated, type GatewayBotConfig, type GatewayConfig, GatewayEmoji, type GatewayFile, type GatewayPluginOptions, type GatewayReplyResponse, HasPermsToAssignOptions, IgnoreBots, type InjectedEmojiMap, type InteractionGateContext, InteractionHandler, InteractionMiddleware, MessageContextMenuHandler, Middleware, type MiddlewareOptions, MiddlewareType, ModalHandler, Nsfw, type PageContext, Paginator, Plugin, type PluginLifecycleSpec, type PluginOptions, RegisterEvent, type RegisterEventOptions, RepliableHandler, type Repliables, Seedcord, SelectMenuHandler, SlashHandler, type SlashOptions, Subscriber, UserContextMenuHandler, type ValidEventTypes, type ValidInteractionTypes, type ValidNonInteractionKeys, WebhookLog, checkBotPermissions, checkPermissions, getConfirmation, hasPermsToAssign, version };
|
|
1766
|
+
export { ArraySource, AssignRoleNoticeOverrides, AutocompleteHandler, BaseHandler, ButtonHandler, type CheckPermissionOptions, ComponentHandler, type ConfirmOptions, type Core, CursorSource, type DefaultConfirmOptions, Emojis, type EventGateContext, EventHandler, EventMiddleware, type EventSpec, type EventsConfig, type GateContext, Gated, type GatewayBotConfig, type GatewayConfig, GatewayEmoji, type GatewayFile, type GatewayPluginOptions, type GatewayReplyResponse, HasPermsToAssignOptions, IgnoreBots, type InjectedEmojiMap, type InteractionGateContext, InteractionHandler, InteractionMiddleware, MessageContextMenuHandler, Middleware, type MiddlewareOptions, MiddlewareType, ModalHandler, Nsfw, type PageContext, type PageSource, Paginator, Plugin, type PluginLifecycleSpec, type PluginOptions, RegisterEvent, type RegisterEventOptions, RepliableHandler, type Repliables, ReplySender, Seedcord, SelectMenuHandler, type SentMessage, SlashHandler, type SlashOptions, Subscriber, UserContextMenuHandler, type ValidEventTypes, type ValidInteractionTypes, type ValidNonInteractionKeys, WebhookLog, WinstonConsoleSink, WinstonFileSink, checkBotPermissions, checkPermissions, getConfirmation, hasPermsToAssign, version };
|
|
1569
1767
|
//# sourceMappingURL=index.d.mts.map
|