@seedcord/http 0.10.2 → 0.11.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -9
- package/dist/index.d.mts +42 -57
- package/dist/index.mjs +144 -239
- package/dist/index.mjs.map +1 -1
- package/dist/shared-vsj1uwIH.d.mts +977 -0
- package/dist/{edge.index-DCP1BD6f.mjs → username-3UsqzTSd.mjs} +1634 -1519
- package/dist/username-3UsqzTSd.mjs.map +1 -0
- package/dist/workerd.index.d.mts +65 -0
- package/dist/workerd.index.mjs +177 -0
- package/dist/workerd.index.mjs.map +1 -0
- package/package.json +19 -27
- package/dist/Manifest-D5MEsTmH.d.mts +0 -485
- package/dist/edge.index-DCP1BD6f.mjs.map +0 -1
- package/dist/edge.index-DFszgCJp.d.mts +0 -502
- package/dist/edge.index.d.mts +0 -10
- package/dist/edge.index.mjs +0 -15
- package/dist/manifest.index.d.mts +0 -10
- package/dist/manifest.index.mjs +0 -26
- package/dist/manifest.index.mjs.map +0 -1
|
@@ -1,502 +0,0 @@
|
|
|
1
|
-
import { _ as Core, a as RoleMenuHandler, b as HttpServerConfig, c as UserMenuHandler, d as RepliableHandler$1, f as Repliables, g as AutocompleteHandler, h as SentMessage, i as MentionableMenuHandler, l as ComponentHandler, m as ReplySender, n as InteractionMiddleware, o as SelectMenuHandler, p as InteractionRef, r as ChannelMenuHandler, s as StringMenuHandler, t as Manifest, u as InteractionHandler, v as HttpConfig, y as HttpEdgeConfig } from "./Manifest-D5MEsTmH.mjs";
|
|
2
|
-
import "reflect-metadata";
|
|
3
|
-
import { ComponentKindBrand, ContextMenuKindBrand, ContextMenuNamesBrand, GateFitsWith, MiddlewareRegistry, NamesFor, PageCursor, SlashOptions, SlashRouteBrand } from "@seedcord/core/internal";
|
|
4
|
-
import { ArraySourceBase, CursorSourceBase, Gate, GateContextBase, GuildPermissionsContext, InteractionKind, PageSourceBase, PaginatorBase, PaginatorConfig, RequiredOf, ResolvedEmoji, SlashRegistry, Subscriber, SubscriptionKey, WebhookLog } from "@seedcord/core";
|
|
5
|
-
import { APIAttachment, APIChatInputApplicationCommandInteraction, APIInteraction, APIInteractionDataResolvedChannel, APIInteractionDataResolvedChannelBase, APIInteractionDataResolvedGuildMember, APIInteractionGuildMember, APIMessage, APIMessageApplicationCommandInteraction, APIMessageChannelSelectInteractionData, APIMessageComponentButtonInteraction, APIMessageComponentSelectMenuInteraction, APIMessageMentionableSelectInteractionData, APIMessageRoleSelectInteractionData, APIMessageStringSelectInteractionData, APIMessageUserSelectInteractionData, APIModalSubmission, APIModalSubmitInteraction, APIRole, APIThreadChannel, APIUser, APIUserApplicationCommandInteraction, ApplicationCommandType, ChannelType, ModalSubmitComponent, ThreadChannelType } from "discord-api-types/v10";
|
|
6
|
-
import { AnyCustomId } from "@seedcord/custom-id";
|
|
7
|
-
import { Collection } from "@discordjs/collection";
|
|
8
|
-
import { EmojiMap, ReplyResponse } from "@seedcord/types";
|
|
9
|
-
import { NonEmptyTuple, Promisable } from "type-fest";
|
|
10
|
-
//#region src/subscriptions.d.ts
|
|
11
|
-
declare module '@seedcord/core/internal' {
|
|
12
|
-
interface DefaultSubscriptions {
|
|
13
|
-
/** Triggered for every verified interaction, before routing. */
|
|
14
|
-
anyInteraction: {
|
|
15
|
-
interaction: APIInteraction;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region src/engine.d.ts
|
|
21
|
-
/** Structural match for the Workers `ExecutionContext`. Pass it from the edge entry so post-202 work runs under `waitUntil`. */
|
|
22
|
-
interface EngineContext {
|
|
23
|
-
waitUntil(promise: Promise<unknown>): void;
|
|
24
|
-
}
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region src/createSeedcord.d.ts
|
|
27
|
-
/**
|
|
28
|
-
* Builds the HTTP-interactions engine, a `(request, ctx?) => Promise<Response>` handler.
|
|
29
|
-
*
|
|
30
|
-
* The handler verifies the Ed25519 signature over the raw request bytes, rejects stale or replayed
|
|
31
|
-
* requests, answers a PING with an in-body PONG, and acks every other interaction with an empty 202.
|
|
32
|
-
* The engine dispatches a matched interaction through the manifest before the 202 goes out. Gates run
|
|
33
|
-
* first and the sender posts any refusal over the REST callback. `execute()` continues past the 202 under
|
|
34
|
-
* `ctx.waitUntil` when the caller passes one (the edge entry), and an engine-held in-flight set tracks
|
|
35
|
-
* it otherwise (node paths). It reads only the method, headers, and body. Mount it at any path.
|
|
36
|
-
*
|
|
37
|
-
* Reads `DISCORD_PUBLIC_KEY` and `DISCORD_BOT_TOKEN` from the environment through envapt and throws a
|
|
38
|
-
* `SeedcordError` when either is missing or malformed.
|
|
39
|
-
*
|
|
40
|
-
* Applies `config.logger`. An omitted `logger` resets the level and the sinks to their defaults, the
|
|
41
|
-
* way `installNodeDefaults` does on the node hosts.
|
|
42
|
-
*/
|
|
43
|
-
declare function createSeedcord(config: HttpConfig, manifest: Manifest): (request: Request, ctx?: EngineContext) => Promise<Response>;
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/inputs/SlashOptions.d.ts
|
|
46
|
-
type ResolvedChannelOf<Type extends ChannelType> = APIInteractionDataResolvedChannelBase<Type> & (Type extends ThreadChannelType ? Pick<APIThreadChannel, 'parent_id' | 'thread_metadata'> : unknown);
|
|
47
|
-
type AnyResolvedChannel = { [Type in ChannelType]: ResolvedChannelOf<Type>; }[ChannelType];
|
|
48
|
-
interface HttpLens {
|
|
49
|
-
user: APIUser;
|
|
50
|
-
member: APIInteractionDataResolvedGuildMember;
|
|
51
|
-
channel: AnyResolvedChannel;
|
|
52
|
-
role: APIRole;
|
|
53
|
-
mentionable: APIUser | APIInteractionDataResolvedGuildMember | APIRole;
|
|
54
|
-
attachment: APIAttachment;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* The typed view over a chat-input command's options for one route on the HTTP transport. Each getter
|
|
58
|
-
* restricts its `name` to that route's options of the matching kind, drops the null on required options,
|
|
59
|
-
* narrows `choices` to their literal union, and only appears when the route has an option of that kind.
|
|
60
|
-
* The rich kinds return `discord-api-types` payloads resolved from the interaction's `resolved` data.
|
|
61
|
-
*
|
|
62
|
-
* A channel option declared with `addChannelTypes` narrows `getChannel` to the matching resolved-channel
|
|
63
|
-
* subtype.
|
|
64
|
-
*
|
|
65
|
-
* @typeParam Route - A route key from the generated {@link SlashRegistry}.
|
|
66
|
-
*/
|
|
67
|
-
type SlashOptions$1<Route extends keyof SlashRegistry> = SlashOptions<Route, HttpLens>;
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/inputs/ModalFields.d.ts
|
|
70
|
-
type FieldKind = ModalSubmitComponent['type'];
|
|
71
|
-
/** The users, members, and roles a mentionable select picked. */
|
|
72
|
-
interface SelectedMentionables {
|
|
73
|
-
users: Collection<string, APIUser>;
|
|
74
|
-
members: Collection<string, APIInteractionDataResolvedGuildMember>;
|
|
75
|
-
roles: Collection<string, APIRole>;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* The fields a modal carries, read by custom id.
|
|
79
|
-
*
|
|
80
|
-
* Every getter throws when no field in the modal has that custom id. It also throws when the field holds a
|
|
81
|
-
* kind that getter does not read. The message names the getter that does.
|
|
82
|
-
*
|
|
83
|
-
* A select getter resolves the ids its field picked against the interaction's `resolved` data and returns a
|
|
84
|
-
* `Collection` keyed by id. A field that picked nothing returns null. Pass `required` to throw there instead.
|
|
85
|
-
*/
|
|
86
|
-
declare class ModalFields {
|
|
87
|
-
private readonly entries;
|
|
88
|
-
private readonly resolved;
|
|
89
|
-
constructor(data: APIModalSubmission);
|
|
90
|
-
private entry;
|
|
91
|
-
private field;
|
|
92
|
-
private selected;
|
|
93
|
-
/**
|
|
94
|
-
* Returns the field with this custom id, as Discord sent it. Use it for a component type the typed
|
|
95
|
-
* getters do not cover.
|
|
96
|
-
*
|
|
97
|
-
* Pass a component type to get that exact type back. It throws when the field holds a different one.
|
|
98
|
-
*/
|
|
99
|
-
getField<Kind extends FieldKind>(customId: string, kind: Kind): Extract<ModalSubmitComponent, {
|
|
100
|
-
type: Kind;
|
|
101
|
-
}>;
|
|
102
|
-
getField(customId: string): ModalSubmitComponent;
|
|
103
|
-
getTextInputValue(customId: string): string;
|
|
104
|
-
getStringSelectValues(customId: string): string[];
|
|
105
|
-
getSelectedUsers(customId: string, required: true): Collection<string, APIUser>;
|
|
106
|
-
getSelectedUsers(customId: string, required?: boolean): Collection<string, APIUser> | null;
|
|
107
|
-
/** The guild members behind the picked users. Discord resolves these only inside a guild. */
|
|
108
|
-
getSelectedMembers(customId: string): Collection<string, APIInteractionDataResolvedGuildMember> | null;
|
|
109
|
-
getSelectedRoles(customId: string, required: true): Collection<string, APIRole>;
|
|
110
|
-
getSelectedRoles(customId: string, required?: boolean): Collection<string, APIRole> | null;
|
|
111
|
-
/** Pass `channelTypes` to throw when a pick falls outside those types. */
|
|
112
|
-
getSelectedChannels(customId: string, required: true, channelTypes?: readonly ChannelType[]): Collection<string, APIInteractionDataResolvedChannel>;
|
|
113
|
-
getSelectedChannels(customId: string, required?: boolean, channelTypes?: readonly ChannelType[]): Collection<string, APIInteractionDataResolvedChannel> | null;
|
|
114
|
-
getSelectedMentionables(customId: string, required: true): SelectedMentionables;
|
|
115
|
-
getSelectedMentionables(customId: string, required?: boolean): SelectedMentionables | null;
|
|
116
|
-
getUploadedFiles(customId: string, required: true): Collection<string, APIAttachment>;
|
|
117
|
-
getUploadedFiles(customId: string, required?: boolean): Collection<string, APIAttachment> | null;
|
|
118
|
-
getRadioGroup(customId: string, required: true): string;
|
|
119
|
-
getRadioGroup(customId: string, required?: boolean): string | null;
|
|
120
|
-
getCheckboxGroup(customId: string): string[];
|
|
121
|
-
getCheckbox(customId: string): boolean;
|
|
122
|
-
}
|
|
123
|
-
//#endregion
|
|
124
|
-
//#region src/emojis/EmojiInjector.d.ts
|
|
125
|
-
/** The global {@link Emojis} accessor type. */
|
|
126
|
-
type InjectedEmojiMap = { [K in keyof EmojiMap]: ResolvedEmoji; };
|
|
127
|
-
/**
|
|
128
|
-
* The bot's resolved emojis, keyed by {@link EmojiMap}. Filled by {@link EmojiInjector} during startup.
|
|
129
|
-
* Throws if you read a key the injector did not fill.
|
|
130
|
-
*/
|
|
131
|
-
declare const Emojis: InjectedEmojiMap;
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/handlers/interaction/SlashHandler.d.ts
|
|
134
|
-
type SlashMatchArms<Route extends keyof SlashRegistry, Ret> = { [Key in Route]: (options: SlashOptions$1<Key>) => Promisable<Ret>; };
|
|
135
|
-
/**
|
|
136
|
-
* Base class for a chat-input (slash) command handler on the HTTP transport.
|
|
137
|
-
*
|
|
138
|
-
* Pass the route from the generated registry as the generic, then read `this.options` for a single
|
|
139
|
-
* command or `this.match` for several. Command authoring stays plain discord.js, `seedcord codegen`
|
|
140
|
-
* reads its `toJSON()` to type these options.
|
|
141
|
-
*
|
|
142
|
-
* @typeParam Route - One or more route keys from {@link SlashRegistry}, e.g. `'ban'` or `'ban' | 'kick'`.
|
|
143
|
-
*/
|
|
144
|
-
declare abstract class SlashHandler<Route extends keyof SlashRegistry> extends InteractionHandler<APIChatInputApplicationCommandInteraction> {
|
|
145
|
-
/** @internal */
|
|
146
|
-
readonly [SlashRouteBrand]?: Route;
|
|
147
|
-
private resolver?;
|
|
148
|
-
/**
|
|
149
|
-
* The typed options for this command's route. Only the getters for kinds this command declares appear.
|
|
150
|
-
* Each getter's name argument is restricted to that command's options of its kind.
|
|
151
|
-
*
|
|
152
|
-
* - A required option drops the null.
|
|
153
|
-
*
|
|
154
|
-
* - Choices narrow to their literal union.
|
|
155
|
-
*
|
|
156
|
-
* - A channel option declared with `addChannelTypes` narrows to those types.
|
|
157
|
-
*
|
|
158
|
-
* Rich kinds resolve from the interaction's `resolved` data.
|
|
159
|
-
*/
|
|
160
|
-
protected get options(): SlashOptions$1<Route>;
|
|
161
|
-
/**
|
|
162
|
-
* Run the arm for whichever command fired. Use this only when the handler is registered for several
|
|
163
|
-
* routes.
|
|
164
|
-
*
|
|
165
|
-
* Provide one arm per registered route, keyed by its route string, and each arm receives that route's
|
|
166
|
-
* own narrowed options. The arms must cover every route in the generic, a missing route or an unknown
|
|
167
|
-
* key is a compile error.
|
|
168
|
-
*
|
|
169
|
-
* @param arms - One handler per registered route, keyed by route string.
|
|
170
|
-
* @returns The result of the arm that ran.
|
|
171
|
-
*/
|
|
172
|
-
protected match<Ret>(arms: SlashMatchArms<Route, Ret>): Promise<Ret>;
|
|
173
|
-
}
|
|
174
|
-
//#endregion
|
|
175
|
-
//#region src/handlers/interaction/ContextMenuHandler.d.ts
|
|
176
|
-
type UserMenuArms<Names extends NamesFor<ApplicationCommandType.User>, Ret> = Record<Names, (target: APIUser, member: APIInteractionDataResolvedGuildMember | null) => Promisable<Ret>>;
|
|
177
|
-
type MessageMenuArms<Names extends NamesFor<ApplicationCommandType.Message>, Ret> = Record<Names, (target: APIMessage) => Promisable<Ret>>;
|
|
178
|
-
/**
|
|
179
|
-
* Base class for a user context-menu command handler on the HTTP transport (right-click a user).
|
|
180
|
-
*
|
|
181
|
-
* Pass the command name(s) as the generic, the same as `@UserContextMenuRoute`. Read the right-clicked user
|
|
182
|
-
* from `this.target` and that same user's guild member from `this.targetMember`.
|
|
183
|
-
*
|
|
184
|
-
* @typeParam Names - One or more command names from the generated user registry.
|
|
185
|
-
*/
|
|
186
|
-
declare abstract class UserContextMenuHandler<Names extends NamesFor<ApplicationCommandType.User>> extends InteractionHandler<APIUserApplicationCommandInteraction> {
|
|
187
|
-
/** @internal */
|
|
188
|
-
readonly [ContextMenuKindBrand]?: ApplicationCommandType.User;
|
|
189
|
-
/** @internal */
|
|
190
|
-
readonly [ContextMenuNamesBrand]?: Names;
|
|
191
|
-
protected get target(): APIUser;
|
|
192
|
-
/** The right-clicked user's guild member, null outside a guild. */
|
|
193
|
-
protected get targetMember(): APIInteractionDataResolvedGuildMember | null;
|
|
194
|
-
/** Which of the registered commands fired. */
|
|
195
|
-
protected get commandName(): Names;
|
|
196
|
-
/**
|
|
197
|
-
* Run the arm for whichever command fired. Use this only when the handler is registered for several
|
|
198
|
-
* names.
|
|
199
|
-
*
|
|
200
|
-
* Provide one arm per registered name, keyed by the name Discord shows in the right-click menu. Each
|
|
201
|
-
* arm receives the clicked user and that user's guild member. The arms must cover every name in the
|
|
202
|
-
* generic. A missing name or an unknown key is a compile error.
|
|
203
|
-
*
|
|
204
|
-
* @param arms - One handler per registered command name.
|
|
205
|
-
* @returns The result of the arm that ran.
|
|
206
|
-
*
|
|
207
|
-
* @example
|
|
208
|
-
* ```ts
|
|
209
|
-
* \@UserContextMenuRoute('View Profile', 'Warn')
|
|
210
|
-
* class Moderation extends UserContextMenuHandler<'View Profile' | 'Warn'> {
|
|
211
|
-
* async execute() {
|
|
212
|
-
* await this.match({
|
|
213
|
-
* 'View Profile': (user) => this.reply(`Profile for ${user.username}.`),
|
|
214
|
-
* Warn: (user, member) => this.reply(`Warned ${member?.nick ?? user.username}.`)
|
|
215
|
-
* });
|
|
216
|
-
* }
|
|
217
|
-
* }
|
|
218
|
-
* ```
|
|
219
|
-
*/
|
|
220
|
-
protected match<Ret>(arms: UserMenuArms<Names, Ret>): Promise<Ret>;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Base class for a message context-menu command handler on the HTTP transport (right-click a message).
|
|
224
|
-
*
|
|
225
|
-
* Pass the command name(s) as the generic, the same as `@MessageContextMenuRoute`. Read the right-clicked
|
|
226
|
-
* message from `this.target`.
|
|
227
|
-
*
|
|
228
|
-
* @typeParam Names - One or more command names from the generated message registry.
|
|
229
|
-
*/
|
|
230
|
-
declare abstract class MessageContextMenuHandler<Names extends NamesFor<ApplicationCommandType.Message>> extends InteractionHandler<APIMessageApplicationCommandInteraction> {
|
|
231
|
-
/** @internal */
|
|
232
|
-
readonly [ContextMenuKindBrand]?: ApplicationCommandType.Message;
|
|
233
|
-
/** @internal */
|
|
234
|
-
readonly [ContextMenuNamesBrand]?: Names;
|
|
235
|
-
protected get target(): APIMessage;
|
|
236
|
-
/** Which of the registered commands fired. */
|
|
237
|
-
protected get commandName(): Names;
|
|
238
|
-
/**
|
|
239
|
-
* Run the arm for whichever command fired. Use this only when the handler is registered for several
|
|
240
|
-
* names.
|
|
241
|
-
*
|
|
242
|
-
* Provide one arm per registered name, keyed by the name Discord shows in the right-click menu. Each
|
|
243
|
-
* arm receives the clicked message. The arms must cover every name in the generic. A missing name or
|
|
244
|
-
* an unknown key is a compile error.
|
|
245
|
-
*
|
|
246
|
-
* @param arms - One handler per registered command name.
|
|
247
|
-
* @returns The result of the arm that ran.
|
|
248
|
-
*
|
|
249
|
-
* @example
|
|
250
|
-
* ```ts
|
|
251
|
-
* \@MessageContextMenuRoute('Report Message', 'Quote Message')
|
|
252
|
-
* class MessageTools extends MessageContextMenuHandler<'Report Message' | 'Quote Message'> {
|
|
253
|
-
* async execute() {
|
|
254
|
-
* await this.match({
|
|
255
|
-
* 'Report Message': (message) => this.report(message),
|
|
256
|
-
* 'Quote Message': (message) => this.reply(`> ${message.content}`)
|
|
257
|
-
* });
|
|
258
|
-
* }
|
|
259
|
-
* }
|
|
260
|
-
* ```
|
|
261
|
-
*/
|
|
262
|
-
protected match<Ret>(arms: MessageMenuArms<Names, Ret>): Promise<Ret>;
|
|
263
|
-
}
|
|
264
|
-
//#endregion
|
|
265
|
-
//#region src/handlers/interaction/components/ButtonHandler.d.ts
|
|
266
|
-
/**
|
|
267
|
-
* Base class for a button interaction handler on the HTTP transport.
|
|
268
|
-
*
|
|
269
|
-
* Register the customId definitions this handler decodes with `@ButtonRoute`, list the same ones in the
|
|
270
|
-
* generic, then read `this.params` for a single route or `this.match` for several. Reply through the
|
|
271
|
-
* handler members, or rewrite the source message with `this.update`. Passing different definitions to the
|
|
272
|
-
* decorator and the generic is a compile error.
|
|
273
|
-
*
|
|
274
|
-
* @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof ApproveId]`.
|
|
275
|
-
*/
|
|
276
|
-
declare abstract class ButtonHandler<Defs extends readonly AnyCustomId[]> extends ComponentHandler<APIMessageComponentButtonInteraction, Defs> {
|
|
277
|
-
/** @internal */
|
|
278
|
-
readonly [ComponentKindBrand]?: InteractionKind.Button;
|
|
279
|
-
}
|
|
280
|
-
//#endregion
|
|
281
|
-
//#region src/handlers/interaction/components/ModalHandler.d.ts
|
|
282
|
-
/**
|
|
283
|
-
* Base class for a modal submit handler on the HTTP transport.
|
|
284
|
-
*
|
|
285
|
-
* Register the customId definitions this handler decodes with `@ModalRoute` and list the same ones in the
|
|
286
|
-
* generic. Read the submitted inputs from `this.fields`. Reply through the handler members. `showModal`
|
|
287
|
-
* fails compilation on this kind, because Discord forbids opening a modal in response to a modal.
|
|
288
|
-
*
|
|
289
|
-
* @typeParam Defs - The customId definitions this handler decodes, e.g. `[typeof ConfigId]`.
|
|
290
|
-
*
|
|
291
|
-
* @example
|
|
292
|
-
* ```ts
|
|
293
|
-
* \@ModalRoute(ConfigId)
|
|
294
|
-
* class ConfigModal extends ModalHandler<[typeof ConfigId]> {
|
|
295
|
-
* async execute() {
|
|
296
|
-
* const { guildId } = this.params;
|
|
297
|
-
* const name = this.fields.getTextInputValue('name');
|
|
298
|
-
* await this.reply(`saved ${name} for ${guildId}`);
|
|
299
|
-
* }
|
|
300
|
-
* }
|
|
301
|
-
* ```
|
|
302
|
-
*/
|
|
303
|
-
declare abstract class ModalHandler<Defs extends readonly AnyCustomId[]> extends ComponentHandler<APIModalSubmitInteraction, Defs> {
|
|
304
|
-
/** @internal */
|
|
305
|
-
readonly [ComponentKindBrand]?: InteractionKind.Modal;
|
|
306
|
-
private reader?;
|
|
307
|
-
/** The fields this modal submitted, read by custom id. */
|
|
308
|
-
protected get fields(): ModalFields;
|
|
309
|
-
/** Rewrite the message this modal was opened from. Throws when a command opened the modal. */
|
|
310
|
-
protected update(response: ReplyResponse | string): Promise<SentMessage>;
|
|
311
|
-
/** Acknowledge the submit without changing the source message. Throws when a command opened the modal. */
|
|
312
|
-
protected deferUpdate(): Promise<void>;
|
|
313
|
-
private ensureSourceMessage;
|
|
314
|
-
}
|
|
315
|
-
//#endregion
|
|
316
|
-
//#region src/subscribers/index.d.ts
|
|
317
|
-
/**
|
|
318
|
-
* Base class for an HTTP subscriber, binding `this.core` to the HTTP {@link Core}.
|
|
319
|
-
*
|
|
320
|
-
* @typeParam KeyOfSubscribers - The subscription key this handler receives
|
|
321
|
-
*/
|
|
322
|
-
declare abstract class Subscriber$1<KeyOfSubscribers extends SubscriptionKey> extends Subscriber<KeyOfSubscribers, Core> {}
|
|
323
|
-
/**
|
|
324
|
-
* Base class for an HTTP subscriber that delivers its event to a Discord webhook, binding
|
|
325
|
-
* `this.core` to the HTTP {@link Core}.
|
|
326
|
-
*
|
|
327
|
-
* @typeParam KeyOfSubscribers - The subscription key this reporter receives
|
|
328
|
-
*/
|
|
329
|
-
declare abstract class WebhookLog$1<KeyOfSubscribers extends SubscriptionKey> extends WebhookLog<KeyOfSubscribers, Core> {}
|
|
330
|
-
//#endregion
|
|
331
|
-
//#region src/pagination/PageContext.d.ts
|
|
332
|
-
/**
|
|
333
|
-
* The context passed to a source loader. The raw payload carries a guild id with no guild object, so a
|
|
334
|
-
* loader that requires guild data fetches it through `core.rest`.
|
|
335
|
-
*/
|
|
336
|
-
interface PageContext {
|
|
337
|
-
/** The interaction that triggered this load (a command or a nav click). */
|
|
338
|
-
interaction: Repliables;
|
|
339
|
-
/** The acting user, always present. */
|
|
340
|
-
user: APIUser;
|
|
341
|
-
/** The guild id, or `null` in a DM. */
|
|
342
|
-
guildId: string | null;
|
|
343
|
-
core: Core;
|
|
344
|
-
}
|
|
345
|
-
//#endregion
|
|
346
|
-
//#region src/pagination/Paginator.d.ts
|
|
347
|
-
type PaginatorHandlerCtor<Prefix extends string> = new (...args: ConstructorParameters<typeof ButtonHandler>) => ButtonHandler<[PageCursor<Prefix>]> & {
|
|
348
|
-
execute(): Promise<void>;
|
|
349
|
-
};
|
|
350
|
-
/**
|
|
351
|
-
* A restart-proof paginator. Each nav button's customId encodes its full target page, so clicks are
|
|
352
|
-
* idempotent and survive a restart. A persistent `@ButtonRoute` on `Handler` dispatches the clicks.
|
|
353
|
-
*
|
|
354
|
-
* @typeParam Item - The item type, inferred from the source.
|
|
355
|
-
* @typeParam Prefix - The route prefix, inferred from `config.prefix`.
|
|
356
|
-
*
|
|
357
|
-
* @example
|
|
358
|
-
* ```ts
|
|
359
|
-
* export const Bans = new Paginator({
|
|
360
|
-
* prefix: 'bans',
|
|
361
|
-
* source: new ArraySource((ctx) => loadBans(ctx.guildId), { perPage: 10 }),
|
|
362
|
-
* renderItem: (ban) => ban.user.username
|
|
363
|
-
* });
|
|
364
|
-
*
|
|
365
|
-
* \@ButtonRoute(Bans.cursor)
|
|
366
|
-
* export class BansNav extends Bans.Handler {}
|
|
367
|
-
* ```
|
|
368
|
-
*/
|
|
369
|
-
declare class Paginator<Item, const Prefix extends string> extends PaginatorBase<Item, Prefix, PageContext> {
|
|
370
|
-
/** The nav handler base. Extend it with an empty body and decorate it, `@ButtonRoute(p.cursor)`. */
|
|
371
|
-
readonly Handler: PaginatorHandlerCtor<Prefix>;
|
|
372
|
-
constructor(config: PaginatorConfig<Item, Prefix, PageContext>);
|
|
373
|
-
/**
|
|
374
|
-
* Render a page as a {@link ReplyResponse} without sending anything.
|
|
375
|
-
*
|
|
376
|
-
* @param handler - The handler rendering the page, normally `this`.
|
|
377
|
-
* @param n - The zero-based page.
|
|
378
|
-
*/
|
|
379
|
-
page(handler: RepliableHandler$1<Repliables>, n: number): Promise<ReplyResponse>;
|
|
380
|
-
/**
|
|
381
|
-
* Send a page through the handler's sender. The sender picks reply, edit, or followUp from its ack state.
|
|
382
|
-
*
|
|
383
|
-
* @param handler - The handler starting the paginator, normally `this`.
|
|
384
|
-
* @param n - The zero-based page to open on.
|
|
385
|
-
*/
|
|
386
|
-
start(handler: RepliableHandler$1<Repliables>, n?: number): Promise<SentMessage>;
|
|
387
|
-
}
|
|
388
|
-
//#endregion
|
|
389
|
-
//#region src/pagination/sources.d.ts
|
|
390
|
-
/**
|
|
391
|
-
* The one method a paginator calls on a source, once per click. Implement it for a source neither shipped
|
|
392
|
-
* one covers.
|
|
393
|
-
*
|
|
394
|
-
* @typeParam Item - The item type the source pages over.
|
|
395
|
-
*/
|
|
396
|
-
type PageSource<Item> = PageSourceBase<Item, PageContext>;
|
|
397
|
-
/**
|
|
398
|
-
* A source for a bounded list you can load whole. It loads the full list on every click, then slices the
|
|
399
|
-
* page, so the real total is known (a real last button, "Page X of Y"). Cache inside your loader if the
|
|
400
|
-
* load is expensive.
|
|
401
|
-
*
|
|
402
|
-
* @typeParam Item - The item type, inferred from the loader's return.
|
|
403
|
-
*/
|
|
404
|
-
declare class ArraySource<Item> extends ArraySourceBase<Item, PageContext> {}
|
|
405
|
-
/**
|
|
406
|
-
* A source for a large or unknown-length set you fetch one page at a time (SQL LIMIT/OFFSET, a paged API).
|
|
407
|
-
* The fetcher receives the page index and the page size and reports whether a next page exists. A cursor
|
|
408
|
-
* source has no cheap total, so `totalPages` is undefined, the last button is omitted, and the indicator
|
|
409
|
-
* reads "Page X".
|
|
410
|
-
*
|
|
411
|
-
* @typeParam Item - The item type, inferred from the fetcher's slice.
|
|
412
|
-
*/
|
|
413
|
-
declare class CursorSource<Item> extends CursorSourceBase<Item, PageContext> {}
|
|
414
|
-
//#endregion
|
|
415
|
-
//#region src/gates/Gate.d.ts
|
|
416
|
-
/**
|
|
417
|
-
* The interaction gate context on the HTTP transport. It extends the scalar {@link GateContextBase} with the
|
|
418
|
-
* raw interaction payload and the user and member the payload carries. A gate reading button fields, inferred
|
|
419
|
-
* from its `ctx` annotation, is rejected on a slash handler.
|
|
420
|
-
*
|
|
421
|
-
* The http transport delivers no role-derived permission sets, so `memberGuildPermissions` and
|
|
422
|
-
* `appGuildPermissions` are absent. A gate requiring `GuildPermissionsContext` (a permission gate with
|
|
423
|
-
* `in: 'guild'`) is a compile error on an http handler.
|
|
424
|
-
*
|
|
425
|
-
* @typeParam Repliable - The interaction type the gate reads, narrowing which handlers accept it.
|
|
426
|
-
*
|
|
427
|
-
* @example
|
|
428
|
-
* ```ts
|
|
429
|
-
* import type { APIMessageComponentButtonInteraction } from 'discord-api-types/v10';
|
|
430
|
-
*
|
|
431
|
-
* // a button-only gate: the Repliable generic narrows which handlers accept it
|
|
432
|
-
* const ButtonGate = defineGate('btn', (ctx: InteractionGateContext<APIMessageComponentButtonInteraction>) => {
|
|
433
|
-
* void ctx.interaction; // APIMessageComponentButtonInteraction
|
|
434
|
-
* });
|
|
435
|
-
* ```
|
|
436
|
-
*/
|
|
437
|
-
interface InteractionGateContext<Repliable extends Repliables = Repliables> extends GateContextBase {
|
|
438
|
-
/** Narrow on this before reading `interaction`. */
|
|
439
|
-
readonly kind: 'interaction';
|
|
440
|
-
readonly core: Core;
|
|
441
|
-
/** The raw interaction payload, which is the reply target. */
|
|
442
|
-
readonly interaction: Repliable;
|
|
443
|
-
/** Every repliable interaction contains a user. */
|
|
444
|
-
readonly user: APIUser;
|
|
445
|
-
/** The invoking member, or null in a DM. */
|
|
446
|
-
readonly member: APIInteractionGuildMember | null;
|
|
447
|
-
}
|
|
448
|
-
//#endregion
|
|
449
|
-
//#region src/gates/matching.d.ts
|
|
450
|
-
type AnyHandlerCtor = abstract new (...args: never[]) => {
|
|
451
|
-
execute(): Promise<void>;
|
|
452
|
-
};
|
|
453
|
-
declare const UngateableBrand: unique symbol;
|
|
454
|
-
interface Ungateable {
|
|
455
|
-
readonly [UngateableBrand]: true;
|
|
456
|
-
}
|
|
457
|
-
type ProvidedContext<TCtor extends AnyHandlerCtor> = InstanceType<TCtor> extends RepliableHandler$1<infer Event> ? InteractionGateContext<Event> : Ungateable;
|
|
458
|
-
type SelectData<Repliable> = Repliable extends APIMessageComponentSelectMenuInteraction ? Repliable['data'] : never;
|
|
459
|
-
type SelectKindName<Data> = Data extends APIMessageStringSelectInteractionData ? 'StringMenu' : Data extends APIMessageUserSelectInteractionData ? 'UserMenu' : Data extends APIMessageRoleSelectInteractionData ? 'RoleMenu' : Data extends APIMessageChannelSelectInteractionData ? 'ChannelMenu' : Data extends APIMessageMentionableSelectInteractionData ? 'MentionableMenu' : 'an interaction';
|
|
460
|
-
type KindName<Ctx> = Ctx extends Ungateable ? 'autocomplete' : Ctx extends GuildPermissionsContext ? 'gateway (guild permissions)' : Ctx extends InteractionGateContext<infer Repliable> ? Repliable extends APIChatInputApplicationCommandInteraction ? 'Slash' : Repliable extends APIMessageApplicationCommandInteraction ? 'MessageContextMenu' : Repliable extends APIUserApplicationCommandInteraction ? 'UserContextMenu' : Repliable extends APIMessageComponentSelectMenuInteraction ? SelectKindName<SelectData<Repliable>> : Repliable extends APIMessageComponentButtonInteraction ? 'Button' : Repliable extends APIModalSubmitInteraction ? 'Modal' : 'an interaction' : 'an agnostic';
|
|
461
|
-
type FitAll<TCtor extends AnyHandlerCtor, Gates extends readonly Gate<GateContextBase>[]> = { [Index in keyof Gates]: GateFitsWith<ProvidedContext<TCtor>, KindName<ProvidedContext<TCtor>>, Gates[Index], KindName<RequiredOf<Gates[Index]>>>; };
|
|
462
|
-
//#endregion
|
|
463
|
-
//#region src/gates/Gated.d.ts
|
|
464
|
-
/**
|
|
465
|
-
* Attaches gates to an HTTP interaction handler. The gates run before `execute`, and a gate refusing stops
|
|
466
|
-
* the handler with the reply or drop the gate threw. Multiple gates are ANDed. A gate
|
|
467
|
-
* that requires a context the handler does not provide (a button gate on a slash handler, a gate on an
|
|
468
|
-
* autocomplete handler, or a `RequirePermissions([...], { in: 'guild' })` gate the http transport cannot
|
|
469
|
-
* satisfy) is a compile error at this line, and the error names the gate and the handler kind. Place it
|
|
470
|
-
* above the route decorator.
|
|
471
|
-
*
|
|
472
|
-
* Combine gates with {@link and} or {@link or} to build a single gate from multiple arms.
|
|
473
|
-
*
|
|
474
|
-
* @example
|
|
475
|
-
* ```ts
|
|
476
|
-
* import { PermissionFlagsBits } from 'discord-api-types/v10';
|
|
477
|
-
*
|
|
478
|
-
* \@Gated(GuildOnly(), RequirePermissions([PermissionFlagsBits.ManageMessages]))
|
|
479
|
-
* \@SlashRoute('purge')
|
|
480
|
-
* class Purge extends SlashHandler<'purge'> {
|
|
481
|
-
* async execute() {
|
|
482
|
-
* // both gates passed, so this runs in a guild with a caller who can moderate this channel
|
|
483
|
-
* }
|
|
484
|
-
* }
|
|
485
|
-
* ```
|
|
486
|
-
*
|
|
487
|
-
* @typeParam Gates - The non-empty tuple of gates to run, in order, against the handler's context.
|
|
488
|
-
* @typeParam TCtor - The decorated handler's constructor, checked against every gate's required context.
|
|
489
|
-
* @param gates - One or more gates to attach, each ANDed so the handler runs only when all pass.
|
|
490
|
-
* @param ctor - The handler class being decorated, rejected at compile time when a gate requires a context it lacks.
|
|
491
|
-
*
|
|
492
|
-
* @see {@link defineGate}
|
|
493
|
-
* @see {@link defineEffectGate}
|
|
494
|
-
* @decorator
|
|
495
|
-
*/
|
|
496
|
-
declare function Gated<const Gates extends NonEmptyTuple<Gate<GateContextBase>>>(...gates: Gates): <TCtor extends AnyHandlerCtor>(ctor: FitAll<TCtor, Gates> extends Gates ? TCtor : FitAll<TCtor, Gates>) => void;
|
|
497
|
-
//#endregion
|
|
498
|
-
//#region src/version.d.ts
|
|
499
|
-
declare const version: string;
|
|
500
|
-
//#endregion
|
|
501
|
-
export { EngineContext as S, InjectedEmojiMap as _, CursorSource as a, SlashOptions$1 as b, PageContext as c, ModalHandler as d, ButtonHandler as f, Emojis as g, SlashHandler as h, ArraySource as i, Subscriber$1 as l, UserContextMenuHandler as m, Gated as n, PageSource as o, MessageContextMenuHandler as p, InteractionGateContext as r, Paginator as s, version as t, WebhookLog$1 as u, ModalFields as v, createSeedcord as x, SelectedMentionables as y };
|
|
502
|
-
//# sourceMappingURL=edge.index-DFszgCJp.d.mts.map
|
package/dist/edge.index.d.mts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { S as EngineContext, _ as InjectedEmojiMap, a as CursorSource, b as SlashOptions, c as PageContext, d as ModalHandler, f as ButtonHandler, g as Emojis, h as SlashHandler, i as ArraySource, l as Subscriber, m as UserContextMenuHandler, n as Gated, o as PageSource, p as MessageContextMenuHandler, r as InteractionGateContext, s as Paginator, t as version, u as WebhookLog, v as ModalFields, x as createSeedcord, y as SelectedMentionables } from "./edge.index-DFszgCJp.mjs";
|
|
2
|
-
import { _ as Core, a as RoleMenuHandler, b as HttpServerConfig, c as UserMenuHandler, d as RepliableHandler, g as AutocompleteHandler, h as SentMessage, i as MentionableMenuHandler, l as ComponentHandler, m as ReplySender, n as InteractionMiddleware, o as SelectMenuHandler, p as InteractionRef, r as ChannelMenuHandler, s as StringMenuHandler, t as Manifest, u as InteractionHandler, v as HttpConfig, y as HttpEdgeConfig } from "./Manifest-D5MEsTmH.mjs";
|
|
3
|
-
export * from "@seedcord/logger";
|
|
4
|
-
export * from "@seedcord/core";
|
|
5
|
-
export * from "@seedcord/errors";
|
|
6
|
-
export * from "@seedcord/rate-limiter";
|
|
7
|
-
export * from "@seedcord/event-emitter";
|
|
8
|
-
export * from "@seedcord/utils";
|
|
9
|
-
export type * from "@seedcord/types";
|
|
10
|
-
export { ArraySource, AutocompleteHandler, ButtonHandler, ChannelMenuHandler, ComponentHandler, type Core, CursorSource, Emojis, type EngineContext, Gated, type HttpConfig, type HttpEdgeConfig, type HttpServerConfig, type InjectedEmojiMap, type InteractionGateContext, InteractionHandler, InteractionMiddleware, type InteractionRef, type Manifest, MentionableMenuHandler, MessageContextMenuHandler, ModalFields, ModalHandler, type PageContext, type PageSource, Paginator, RepliableHandler, ReplySender, RoleMenuHandler, SelectMenuHandler, type SelectedMentionables, type SentMessage, SlashHandler, type SlashOptions, StringMenuHandler, Subscriber, UserContextMenuHandler, UserMenuHandler, WebhookLog, createSeedcord, version };
|
package/dist/edge.index.mjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { A as InteractionHandler, C as createSeedcord, M as RepliableHandler, N as ReplySender, S as ModalFields, _ as MessageContextMenuHandler, a as Paginator, c as ChannelMenuHandler, d as SelectMenuHandler, f as StringMenuHandler, g as ComponentHandler, h as ButtonHandler, i as CursorSource, j as AutocompleteHandler, k as InteractionMiddleware, l as MentionableMenuHandler, m as ModalHandler, n as Gated, o as Subscriber, p as UserMenuHandler, r as ArraySource, s as WebhookLog, t as version, u as RoleMenuHandler, v as UserContextMenuHandler, x as Emojis, y as SlashHandler } from "./edge.index-DCP1BD6f.mjs";
|
|
2
|
-
|
|
3
|
-
export * from "@seedcord/logger"
|
|
4
|
-
|
|
5
|
-
export * from "@seedcord/core"
|
|
6
|
-
|
|
7
|
-
export * from "@seedcord/errors"
|
|
8
|
-
|
|
9
|
-
export * from "@seedcord/rate-limiter"
|
|
10
|
-
|
|
11
|
-
export * from "@seedcord/event-emitter"
|
|
12
|
-
|
|
13
|
-
export * from "@seedcord/utils"
|
|
14
|
-
|
|
15
|
-
export { ArraySource, AutocompleteHandler, ButtonHandler, ChannelMenuHandler, ComponentHandler, CursorSource, Emojis, Gated, InteractionHandler, InteractionMiddleware, MentionableMenuHandler, MessageContextMenuHandler, ModalFields, ModalHandler, Paginator, RepliableHandler, ReplySender, RoleMenuHandler, SelectMenuHandler, SlashHandler, StringMenuHandler, Subscriber, UserContextMenuHandler, UserMenuHandler, WebhookLog, createSeedcord, version };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { t as Manifest } from "./Manifest-D5MEsTmH.mjs";
|
|
2
|
-
//#region src/manifest.index.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* The generated class list. `seedcord build` aliases this module to the emitted file. Reading a class
|
|
5
|
-
* list off the un-built stub throws.
|
|
6
|
-
*/
|
|
7
|
-
export declare const manifest: Manifest;
|
|
8
|
-
//#endregion
|
|
9
|
-
export type { Manifest };
|
|
10
|
-
//# sourceMappingURL=manifest.index.d.mts.map
|
package/dist/manifest.index.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { SeedcordError } from "@seedcord/errors/internal";
|
|
2
|
-
import { SeedcordErrorCode } from "@seedcord/errors";
|
|
3
|
-
|
|
4
|
-
//#region src/manifest.index.ts
|
|
5
|
-
const notGenerated = () => {
|
|
6
|
-
throw new SeedcordError(SeedcordErrorCode.ConfigManifestNotGenerated);
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* The generated class list. `seedcord build` aliases this module to the emitted file. Reading a class
|
|
10
|
-
* list off the un-built stub throws.
|
|
11
|
-
*/
|
|
12
|
-
const manifest = {
|
|
13
|
-
get handlers() {
|
|
14
|
-
return notGenerated();
|
|
15
|
-
},
|
|
16
|
-
get middleware() {
|
|
17
|
-
return notGenerated();
|
|
18
|
-
},
|
|
19
|
-
get subscribers() {
|
|
20
|
-
return notGenerated();
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
export { manifest };
|
|
26
|
-
//# sourceMappingURL=manifest.index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.index.mjs","names":[],"sources":["../src/manifest.index.ts"],"sourcesContent":["import { SeedcordErrorCode } from '@seedcord/errors';\nimport { SeedcordError } from '@seedcord/errors/internal';\n\nimport type { Manifest } from '#src/manifest/Manifest';\n\nexport type { Manifest } from '#src/manifest/Manifest';\n\nconst notGenerated = (): never => {\n throw new SeedcordError(SeedcordErrorCode.ConfigManifestNotGenerated);\n};\n\n/**\n * The generated class list. `seedcord build` aliases this module to the emitted file. Reading a class\n * list off the un-built stub throws.\n */\nexport const manifest: Manifest = {\n get handlers(): never {\n return notGenerated();\n },\n get middleware(): never {\n return notGenerated();\n },\n get subscribers(): never {\n return notGenerated();\n }\n};\n"],"mappings":";;;;AAOA,MAAM,qBAA4B;CAC9B,MAAM,IAAI,cAAc,kBAAkB,0BAA0B;AACxE;;;;;AAMA,MAAa,WAAqB;CAC9B,IAAI,WAAkB;EAClB,OAAO,aAAa;CACxB;CACA,IAAI,aAAoB;EACpB,OAAO,aAAa;CACxB;CACA,IAAI,cAAqB;EACrB,OAAO,aAAa;CACxB;AACJ"}
|