@seedcord/gateway 0.1.0-next.6 → 0.1.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.cjs +16 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +33 -11
- package/dist/index.mjs +16 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyCustomId, AutocompletableNames, BaseReplySender, ChoiceValueOf, EntryFor, FocusedField, GateFitsWith, HasComponentDefs, MatchArms, ModalLike, PageCursor, SingleParams, SlashOptions as SlashOptions$1 } from "@seedcord/core/internal";
|
|
2
2
|
import { ArraySource as ArraySource$1, AutocompleteOptions, BaseHandler, Bus, ContextMenuKind, CoreBase, CursorSource as CursorSource$1, DispatchContext, Gate, GateContextBase, GateNoticeOptions, GuildPermissionsContext, Initializeable, Notice, PaginatorBase, PaginatorConfig, PermissionNoticeOverrides, PermissionScope, RepliableHandler as RepliableHandler$1, RequiredOf, SelectMenuKind, SlashOptionRegistry, Subscriber as Subscriber$1, SubscriptionKey, WebhookLog as WebhookLog$1 } from "@seedcord/core";
|
|
3
3
|
import { Logger } from "@seedcord/logger";
|
|
4
|
-
import { APIInteractionGuildMember, APIModalInteractionResponseCallbackData, AnySelectMenuInteraction, ApplicationCommandOptionChoiceData, ApplicationCommandType, ApplicationEmoji, AutocompleteInteraction, 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";
|
|
4
|
+
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";
|
|
5
5
|
import { Plugin as Plugin$1, PluginLifecycleSpec, PluginOptions, PluginOptions as PluginOptions$1 } from "@seedcord/core/plugin";
|
|
6
6
|
import { CoordinatedShutdown, CoordinatedStartup, Pluggable } from "@seedcord/core/node/internal";
|
|
7
7
|
import { SeedcordBrand, SeedcordInstance } from "@seedcord/types/internal";
|
|
@@ -131,6 +131,28 @@ interface Core extends CoreBase {
|
|
|
131
131
|
readonly config: GatewayConfig;
|
|
132
132
|
}
|
|
133
133
|
//#endregion
|
|
134
|
+
//#region src/interfaces/ReplyResponse.d.ts
|
|
135
|
+
/**
|
|
136
|
+
* Every file form discord.js accepts in a message's `files` field: `AttachmentBuilder`, `Attachment`, a
|
|
137
|
+
* `Buffer`, a node `Stream`, a path or URL string, and an `{ attachment, name }` payload.
|
|
138
|
+
*/
|
|
139
|
+
type GatewayFile = NonNullable<BaseMessageOptions['files']>[number];
|
|
140
|
+
/**
|
|
141
|
+
* A reply that may attach files in any form discord.js accepts, on top of the portable `ReplyFile`. The
|
|
142
|
+
* reply verbs already take this, so name it only to type a variable or a helper's return. A `Notice`
|
|
143
|
+
* render or a paginator page returns the plain `ReplyResponse`, which takes a `ReplyFile` alone.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* // any discord.js file form
|
|
148
|
+
* await this.reply({
|
|
149
|
+
* components: [container],
|
|
150
|
+
* files: [new AttachmentBuilder(createReadStream('./report.pdf'), { name: 'report.pdf' })]
|
|
151
|
+
* });
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
type GatewayReplyResponse = ReplyResponse<GatewayFile>;
|
|
155
|
+
//#endregion
|
|
134
156
|
//#region src/handlers/interactionTypes.d.ts
|
|
135
157
|
type ValidInteractionTypes = ChatInputCommandInteraction | ButtonInteraction | ModalSubmitInteraction | AutocompleteInteraction | AnySelectMenuInteraction | ContextMenuCommandInteraction;
|
|
136
158
|
type ValidNonInteractionKeys = Exclude<keyof ClientEvents, Events.InteractionCreate>;
|
|
@@ -550,16 +572,16 @@ type SentMessage = Message;
|
|
|
550
572
|
* Writes interaction responses through the discord.js interaction. Construction is internal to the repliable
|
|
551
573
|
* handler bases and the dispatcher.
|
|
552
574
|
*/
|
|
553
|
-
declare class ReplySender extends BaseReplySender<SentMessage> {
|
|
575
|
+
declare class ReplySender extends BaseReplySender<SentMessage, GatewayFile> {
|
|
554
576
|
private readonly interaction;
|
|
555
577
|
constructor(interaction: Repliables, routeId: string, bus?: Bus);
|
|
556
|
-
protected writeReply(response:
|
|
578
|
+
protected writeReply(response: GatewayReplyResponse | string, opts?: SendOpts): Promise<SentMessage | undefined>;
|
|
557
579
|
protected writeDefer(opts?: DeferOpts): Promise<void>;
|
|
558
580
|
protected writeDeferUpdate(): Promise<void>;
|
|
559
|
-
protected writeUpdate(response:
|
|
560
|
-
protected writeFollowUp(response:
|
|
561
|
-
protected writeEditOriginal(response:
|
|
562
|
-
protected writeEditTarget(targetId: string, response:
|
|
581
|
+
protected writeUpdate(response: GatewayReplyResponse | string): Promise<SentMessage | undefined>;
|
|
582
|
+
protected writeFollowUp(response: GatewayReplyResponse | string, opts?: SendOpts): Promise<SentMessage>;
|
|
583
|
+
protected writeEditOriginal(response: GatewayReplyResponse | string): Promise<SentMessage>;
|
|
584
|
+
protected writeEditTarget(targetId: string, response: GatewayReplyResponse | string): Promise<SentMessage>;
|
|
563
585
|
protected writeDeleteOriginal(): Promise<void>;
|
|
564
586
|
protected writeDeleteTarget(targetId: string): Promise<void>;
|
|
565
587
|
protected writeModal(data: APIModalInteractionResponseCallbackData): Promise<void>;
|
|
@@ -582,7 +604,7 @@ declare class ReplySender extends BaseReplySender<SentMessage> {
|
|
|
582
604
|
*
|
|
583
605
|
* @typeParam Event - The repliable interaction type this handler processes
|
|
584
606
|
*/
|
|
585
|
-
declare abstract class RepliableHandler<Event extends Repliables> extends RepliableHandler$1<Event, Core, SentMessage, ReplySender> {
|
|
607
|
+
declare abstract class RepliableHandler<Event extends Repliables> extends RepliableHandler$1<Event, Core, SentMessage, GatewayFile, ReplySender> {
|
|
586
608
|
/** @internal */
|
|
587
609
|
getEvent(): Event;
|
|
588
610
|
protected buildSender(event: Event, core: Core, routeId: string): ReplySender;
|
|
@@ -872,7 +894,7 @@ declare abstract class ComponentHandler<Event extends ComponentInteraction, Defs
|
|
|
872
894
|
/** @internal */
|
|
873
895
|
readonly __componentDefs?: Defs;
|
|
874
896
|
/** Rewrite the source message this component interaction came from. */
|
|
875
|
-
protected update(response:
|
|
897
|
+
protected update(response: GatewayReplyResponse | string): Promise<SentMessage>;
|
|
876
898
|
/** Acknowledge the component without changing the source message. */
|
|
877
899
|
protected deferUpdate(): Promise<void>;
|
|
878
900
|
private decoded?;
|
|
@@ -971,7 +993,7 @@ declare abstract class ModalHandler<Defs extends readonly AnyCustomId[], Cache e
|
|
|
971
993
|
/** @internal */
|
|
972
994
|
readonly __component?: 'modal';
|
|
973
995
|
/** Rewrite the message this modal was opened from. Throws when a command opened the modal. */
|
|
974
|
-
protected update(response:
|
|
996
|
+
protected update(response: GatewayReplyResponse | string): Promise<SentMessage>;
|
|
975
997
|
/** Acknowledge the submit without changing the source message. Throws when a command opened the modal. */
|
|
976
998
|
protected deferUpdate(): Promise<void>;
|
|
977
999
|
private ensureSourceMessage;
|
|
@@ -1504,5 +1526,5 @@ declare class Seedcord extends Pluggable<'gateway', 'server'> implements Core, S
|
|
|
1504
1526
|
/** Package version */
|
|
1505
1527
|
declare const version: string;
|
|
1506
1528
|
//#endregion
|
|
1507
|
-
export { ArraySource, AssignRoleNoticeOverrides, AutocompleteHandler, ButtonHandler, type CheckPermissionOptions, type ConfirmOptions, ContextMenuHandler, type Core, CursorSource, type DefaultConfirmOptions, Emojis, type EventGateContext, EventHandler, EventMiddleware, type EventSpec, type EventsConfig, type GateContext, Gated, type GatewayBotConfig, type GatewayConfig, type GatewayPluginOptions, HasPermsToAssignOptions, IgnoreBots, type InjectedEmojiMap, type InteractionGateContext, InteractionHandler, InteractionMiddleware, 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, type ValidEventTypes, type ValidInteractionTypes, type ValidNonInteractionKeys, WebhookLog, checkBotPermissions, checkPermissions, getConfirmation, hasPermsToAssign, version };
|
|
1529
|
+
export { ArraySource, AssignRoleNoticeOverrides, AutocompleteHandler, ButtonHandler, type CheckPermissionOptions, type ConfirmOptions, ContextMenuHandler, type Core, CursorSource, type DefaultConfirmOptions, Emojis, type EventGateContext, EventHandler, EventMiddleware, type EventSpec, type EventsConfig, type GateContext, Gated, type GatewayBotConfig, type GatewayConfig, type GatewayFile, type GatewayPluginOptions, type GatewayReplyResponse, HasPermsToAssignOptions, IgnoreBots, type InjectedEmojiMap, type InteractionGateContext, InteractionHandler, InteractionMiddleware, 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, type ValidEventTypes, type ValidInteractionTypes, type ValidNonInteractionKeys, WebhookLog, checkBotPermissions, checkPermissions, getConfirmation, hasPermsToAssign, version };
|
|
1508
1530
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -531,6 +531,18 @@ var InteractionMiddleware = class extends BaseHandler$1 {
|
|
|
531
531
|
|
|
532
532
|
//#endregion
|
|
533
533
|
//#region src/bot/ReplySender.ts
|
|
534
|
+
function isReplyFile(file) {
|
|
535
|
+
return typeof file === "object" && "data" in file && ArrayBuffer.isView(file.data);
|
|
536
|
+
}
|
|
537
|
+
function toDjsFile(file) {
|
|
538
|
+
if (!isReplyFile(file)) return file;
|
|
539
|
+
return {
|
|
540
|
+
attachment: Buffer.from(file.data),
|
|
541
|
+
name: file.name,
|
|
542
|
+
...file.description !== void 0 && { description: file.description },
|
|
543
|
+
...file.title !== void 0 && { title: file.title }
|
|
544
|
+
};
|
|
545
|
+
}
|
|
534
546
|
function seedState(interaction) {
|
|
535
547
|
if (interaction.deferred && interaction.ephemeral === null) return "deferred-update";
|
|
536
548
|
if (interaction.replied) return "replied";
|
|
@@ -613,7 +625,7 @@ var ReplySender = class extends BaseReplySender {
|
|
|
613
625
|
components: reply.components,
|
|
614
626
|
flags,
|
|
615
627
|
...reply.allowedMentions && { allowedMentions: reply.allowedMentions },
|
|
616
|
-
...reply.files && { files:
|
|
628
|
+
...reply.files && { files: reply.files.map(toDjsFile) }
|
|
617
629
|
};
|
|
618
630
|
}
|
|
619
631
|
editOptions(response) {
|
|
@@ -622,7 +634,7 @@ var ReplySender = class extends BaseReplySender {
|
|
|
622
634
|
components: reply.components,
|
|
623
635
|
flags: MessageFlags.IsComponentsV2,
|
|
624
636
|
...reply.allowedMentions && { allowedMentions: reply.allowedMentions },
|
|
625
|
-
...reply.files && { files:
|
|
637
|
+
...reply.files && { files: reply.files.map(toDjsFile) }
|
|
626
638
|
};
|
|
627
639
|
}
|
|
628
640
|
updateOptions(response) {
|
|
@@ -631,7 +643,7 @@ var ReplySender = class extends BaseReplySender {
|
|
|
631
643
|
components: reply.components,
|
|
632
644
|
flags: MessageFlags.IsComponentsV2,
|
|
633
645
|
...reply.allowedMentions && { allowedMentions: reply.allowedMentions },
|
|
634
|
-
...reply.files && { files:
|
|
646
|
+
...reply.files && { files: reply.files.map(toDjsFile) }
|
|
635
647
|
};
|
|
636
648
|
}
|
|
637
649
|
createdMessage(result) {
|
|
@@ -2351,7 +2363,7 @@ __decorate([Envapt("DISCORD_BOT_TOKEN", { converter: (raw) => validateDiscordTok
|
|
|
2351
2363
|
//#endregion
|
|
2352
2364
|
//#region src/version.ts
|
|
2353
2365
|
/** Package version */
|
|
2354
|
-
const version = "0.1.0
|
|
2366
|
+
const version = "0.1.0";
|
|
2355
2367
|
|
|
2356
2368
|
//#endregion
|
|
2357
2369
|
//#region src/Seedcord.ts
|