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