@seedcord/gateway 0.2.1-next.0 → 0.3.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 +57 -36
- package/dist/index.mjs +60 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import { AnyCustomId, AutocompletableNames, AutocompleteRouteBrand, BaseReplySender, ChoiceValueOf, ComponentDefsBrand, ComponentKindBrand, ContextMenuKindBrand, EntryFor, FocusedField, GateFitsWith, HasComponentDefs, MatchArms, ModalLike, PageCursor, SingleParams, SlashOptions as SlashOptions$1, SlashRouteBrand } from "@seedcord/core/internal";
|
|
3
|
-
import { ArraySource as ArraySource$1, AutocompleteOptions, BaseHandler as BaseHandler$1, Bus,
|
|
2
|
+
import { AnyCustomId, AutocompletableNames, AutocompleteRouteBrand, BaseReplySender, CacheFor, ChoiceValueOf, ComponentDefsBrand, ComponentKindBrand, ContextMenuKindBrand, ContextMenuNamesBrand, EntryFor, FocusedField, GateFitsWith, HasComponentDefs, MatchArms, MenuCacheFor, ModalLike, NamesFor, PageCursor, SingleParams, SlashOptions as SlashOptions$1, SlashRouteBrand } from "@seedcord/core/internal";
|
|
3
|
+
import { ArraySource as ArraySource$1, AutocompleteOptions, BaseHandler as BaseHandler$1, Bus, CoreBase, CursorSource as CursorSource$1, DispatchContext, Gate, GateContextBase, GateNoticeOptions, GuildPermissionsContext, Initializeable, Notice, 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
4
|
import { Logger } from "@seedcord/logger";
|
|
5
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
6
|
import { Plugin as Plugin$1, PluginLifecycleSpec, PluginOptions, PluginOptions as PluginOptions$1 } from "@seedcord/core/plugin";
|
|
@@ -87,6 +87,7 @@ declare class Bot implements Initializeable, HmrAware {
|
|
|
87
87
|
/** @internal */
|
|
88
88
|
readonly [loggerSlot]: Logger;
|
|
89
89
|
private isInitialized;
|
|
90
|
+
private readonly intents;
|
|
90
91
|
private readonly _client;
|
|
91
92
|
private readonly interactions?;
|
|
92
93
|
private readonly events?;
|
|
@@ -706,13 +707,13 @@ interface GatewayLens<Cache extends CacheType> {
|
|
|
706
707
|
* A channel option declared with `addChannelTypes` narrows `getChannel` to the matching channel subtype.
|
|
707
708
|
* Pass the raw `this.event.options` resolver for anything this view does not cover.
|
|
708
709
|
*
|
|
709
|
-
* @typeParam Route - A route key from the generated {@link
|
|
710
|
-
* @typeParam Cache - The interaction cache state
|
|
710
|
+
* @typeParam Route - A route key from the generated {@link SlashRegistry}.
|
|
711
|
+
* @typeParam Cache - The interaction cache state. The command's contexts set it.
|
|
711
712
|
*/
|
|
712
|
-
type SlashOptions<Route extends keyof
|
|
713
|
+
type SlashOptions<Route extends keyof SlashRegistry, Cache extends CacheType = CacheFor<Route>> = SlashOptions$1<Route, GatewayLens<Cache>>;
|
|
713
714
|
//#endregion
|
|
714
715
|
//#region src/handlers/interaction/SlashHandler.d.ts
|
|
715
|
-
type SlashMatchArms<Route extends keyof
|
|
716
|
+
type SlashMatchArms<Route extends keyof SlashRegistry, Cache extends CacheType, Ret> = { [Key in Route]: (options: SlashOptions<Key, Cache>) => Promisable<Ret>; };
|
|
716
717
|
/**
|
|
717
718
|
* Base class for a chat-input (slash) command handler.
|
|
718
719
|
*
|
|
@@ -720,8 +721,8 @@ type SlashMatchArms<Route extends keyof SlashOptionRegistry, Cache extends Cache
|
|
|
720
721
|
* `this.options` for a single command or `this.match` for several. Command authoring stays plain
|
|
721
722
|
* discord.js, `seedcord codegen` reads its `toJSON()` to type these options.
|
|
722
723
|
*
|
|
723
|
-
* @typeParam Route - One or more route keys from {@link
|
|
724
|
-
* @typeParam Cache - The interaction cache state
|
|
724
|
+
* @typeParam Route - One or more route keys from {@link SlashRegistry}, e.g. `'ban'` or `'ban' | 'kick'`.
|
|
725
|
+
* @typeParam Cache - The interaction cache state. The command's contexts set it.
|
|
725
726
|
*
|
|
726
727
|
* @example
|
|
727
728
|
* ```ts
|
|
@@ -734,7 +735,7 @@ type SlashMatchArms<Route extends keyof SlashOptionRegistry, Cache extends Cache
|
|
|
734
735
|
* }
|
|
735
736
|
* ```
|
|
736
737
|
*/
|
|
737
|
-
declare abstract class SlashHandler<Route extends keyof
|
|
738
|
+
declare abstract class SlashHandler<Route extends keyof SlashRegistry, Cache extends CacheType = CacheFor<Route>> extends InteractionHandler<ChatInputCommandInteraction<Cache>> {
|
|
738
739
|
/** @internal */
|
|
739
740
|
readonly [SlashRouteBrand]?: Route;
|
|
740
741
|
/**
|
|
@@ -771,43 +772,63 @@ declare abstract class SlashHandler<Route extends keyof SlashOptionRegistry, Cac
|
|
|
771
772
|
}
|
|
772
773
|
//#endregion
|
|
773
774
|
//#region src/handlers/interaction/ContextMenuHandler.d.ts
|
|
774
|
-
type InteractionFor<Kind extends ContextMenuKind, Cache extends CacheType> = Kind extends ApplicationCommandType.User ? UserContextMenuCommandInteraction<Cache> : MessageContextMenuCommandInteraction<Cache>;
|
|
775
|
-
type TargetFor<Kind extends ContextMenuKind, Cache extends CacheType> = Kind extends ApplicationCommandType.User ? User : Message<BooleanCache<Cache>>;
|
|
776
|
-
type TargetMemberFor<Kind extends ContextMenuKind, Cache extends CacheType> = Kind extends ApplicationCommandType.User ? CacheTypeReducer<Cache, GuildMember, APIInteractionGuildMember> | null : never;
|
|
777
775
|
/**
|
|
778
|
-
* Base class for a context-menu command handler (right-click a user
|
|
776
|
+
* Base class for a user context-menu command handler (right-click a user).
|
|
779
777
|
*
|
|
780
|
-
* Pass the
|
|
781
|
-
*
|
|
782
|
-
* `Message` for a message menu. Context menus carry no options, so a handler registered for several names
|
|
783
|
-
* reads `this.target` uniformly with no per-name branch.
|
|
778
|
+
* Pass the command name(s) as the generic, the same as `@UserContextMenuRoute`. Read the right-clicked
|
|
779
|
+
* user from `this.target` and that same user's guild member from `this.targetMember`.
|
|
784
780
|
*
|
|
785
|
-
* @typeParam
|
|
786
|
-
* @typeParam Cache - The interaction cache state
|
|
781
|
+
* @typeParam Names - One or more command names from the generated user registry.
|
|
782
|
+
* @typeParam Cache - The interaction cache state. The command's contexts set it.
|
|
787
783
|
*
|
|
788
784
|
* @example
|
|
789
785
|
* ```ts
|
|
790
|
-
* \@
|
|
791
|
-
* class
|
|
786
|
+
* \@UserContextMenuRoute('View Profile')
|
|
787
|
+
* class ViewProfile extends UserContextMenuHandler<'View Profile'> {
|
|
788
|
+
* async execute() {
|
|
789
|
+
* const user = this.target;
|
|
790
|
+
* }
|
|
791
|
+
* }
|
|
792
|
+
* ```
|
|
793
|
+
*/
|
|
794
|
+
declare abstract class UserContextMenuHandler<Names extends NamesFor<ApplicationCommandType.User>, Cache extends CacheType = MenuCacheFor<ApplicationCommandType.User, Names>> extends InteractionHandler<UserContextMenuCommandInteraction<Cache>> {
|
|
795
|
+
/** @internal */
|
|
796
|
+
readonly [ContextMenuKindBrand]?: ApplicationCommandType.User;
|
|
797
|
+
/** @internal */
|
|
798
|
+
readonly [ContextMenuNamesBrand]?: Names;
|
|
799
|
+
protected get target(): User;
|
|
800
|
+
/** The right-clicked user's guild member, null outside a guild. */
|
|
801
|
+
protected get targetMember(): CacheTypeReducer<Cache, GuildMember, APIInteractionGuildMember> | null;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Base class for a message context-menu command handler (right-click a message).
|
|
805
|
+
*
|
|
806
|
+
* Pass the command name(s) as the generic, the same as `@MessageContextMenuRoute`. Read the right-clicked
|
|
807
|
+
* message from `this.target`.
|
|
808
|
+
*
|
|
809
|
+
* @typeParam Names - One or more command names from the generated message registry.
|
|
810
|
+
* @typeParam Cache - The interaction cache state. The command's contexts set it.
|
|
811
|
+
*
|
|
812
|
+
* @example
|
|
813
|
+
* ```ts
|
|
814
|
+
* \@MessageContextMenuRoute('Report Message')
|
|
815
|
+
* class ReportMessage extends MessageContextMenuHandler<'Report Message'> {
|
|
792
816
|
* async execute() {
|
|
793
817
|
* const message = this.target;
|
|
794
818
|
* }
|
|
795
819
|
* }
|
|
796
820
|
* ```
|
|
797
821
|
*/
|
|
798
|
-
declare abstract class
|
|
822
|
+
declare abstract class MessageContextMenuHandler<Names extends NamesFor<ApplicationCommandType.Message>, Cache extends CacheType = MenuCacheFor<ApplicationCommandType.Message, Names>> extends InteractionHandler<MessageContextMenuCommandInteraction<Cache>> {
|
|
799
823
|
/** @internal */
|
|
800
|
-
readonly [ContextMenuKindBrand]?:
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
* error since the type is `never` there.
|
|
805
|
-
*/
|
|
806
|
-
protected get targetMember(): TargetMemberFor<Kind, Cache>;
|
|
824
|
+
readonly [ContextMenuKindBrand]?: ApplicationCommandType.Message;
|
|
825
|
+
/** @internal */
|
|
826
|
+
readonly [ContextMenuNamesBrand]?: Names;
|
|
827
|
+
protected get target(): Message<BooleanCache<Cache>>;
|
|
807
828
|
}
|
|
808
829
|
//#endregion
|
|
809
830
|
//#region src/handlers/interaction/AutocompleteHandler.d.ts
|
|
810
|
-
type FocusedArms<Route extends keyof
|
|
831
|
+
type FocusedArms<Route extends keyof SlashRegistry, Ret> = { [Name in AutocompletableNames<Route>]: (value: string, respond: (choices: readonly ApplicationCommandOptionChoiceData<ChoiceValueOf<EntryFor<Route, Name>>>[]) => Promise<void>) => Promisable<Ret>; };
|
|
811
832
|
/**
|
|
812
833
|
* Base class for a Discord autocomplete handler.
|
|
813
834
|
*
|
|
@@ -815,8 +836,8 @@ type FocusedArms<Route extends keyof SlashOptionRegistry, Ret> = { [Name in Auto
|
|
|
815
836
|
* `@AutocompleteRoute`. Branch on the focused field with `this.match`, read already-entered sibling options
|
|
816
837
|
* with `this.options`, and find which command fired with `this.route`.
|
|
817
838
|
*
|
|
818
|
-
* @typeParam Route - One or more route keys from {@link
|
|
819
|
-
* @typeParam Cache - The interaction cache state
|
|
839
|
+
* @typeParam Route - One or more route keys from {@link SlashRegistry}, e.g. `'search'` or `'search' | 'find'`.
|
|
840
|
+
* @typeParam Cache - The interaction cache state. The command's contexts set it.
|
|
820
841
|
*
|
|
821
842
|
* @example
|
|
822
843
|
* ```ts
|
|
@@ -830,7 +851,7 @@ type FocusedArms<Route extends keyof SlashOptionRegistry, Ret> = { [Name in Auto
|
|
|
830
851
|
* }
|
|
831
852
|
* ```
|
|
832
853
|
*/
|
|
833
|
-
declare abstract class AutocompleteHandler<Route extends keyof
|
|
854
|
+
declare abstract class AutocompleteHandler<Route extends keyof SlashRegistry, Cache extends CacheType = CacheFor<Route>> extends BaseHandler<AutocompleteInteraction<Cache>> {
|
|
834
855
|
/** @internal */
|
|
835
856
|
readonly [AutocompleteRouteBrand]?: Route;
|
|
836
857
|
constructor(event: AutocompleteInteraction<Cache>, core: Core, dispatch?: DispatchContext);
|
|
@@ -1404,7 +1425,7 @@ interface PageContext {
|
|
|
1404
1425
|
}
|
|
1405
1426
|
//#endregion
|
|
1406
1427
|
//#region src/pagination/Paginator.d.ts
|
|
1407
|
-
type PaginatorHandlerCtor<Prefix extends string> = new (event: ButtonInteraction<
|
|
1428
|
+
type PaginatorHandlerCtor<Prefix extends string> = new (event: ButtonInteraction<CacheType>, core: Core) => ButtonHandler<[PageCursor<Prefix>], CacheType> & {
|
|
1408
1429
|
execute(): Promise<void>;
|
|
1409
1430
|
};
|
|
1410
1431
|
/**
|
|
@@ -1418,7 +1439,7 @@ type PaginatorHandlerCtor<Prefix extends string> = new (event: ButtonInteraction
|
|
|
1418
1439
|
* ```ts
|
|
1419
1440
|
* export const Bans = new Paginator({
|
|
1420
1441
|
* prefix: 'bans',
|
|
1421
|
-
* source: new ArraySource((ctx) => ctx.guild
|
|
1442
|
+
* source: new ArraySource((ctx) => ctx.guild?.bans.fetch().then((b) => [...b.values()]) ?? [], { perPage: 10 }),
|
|
1422
1443
|
* renderItem: (ban) => ban.user.tag
|
|
1423
1444
|
* });
|
|
1424
1445
|
*
|
|
@@ -1541,5 +1562,5 @@ declare class Seedcord extends Pluggable<'gateway', 'server'> implements Core, S
|
|
|
1541
1562
|
/** Package version */
|
|
1542
1563
|
declare const version: string;
|
|
1543
1564
|
//#endregion
|
|
1544
|
-
export { ArraySource, AssignRoleNoticeOverrides, AutocompleteHandler, BaseHandler, ButtonHandler, type CheckPermissionOptions, ComponentHandler, type ConfirmOptions,
|
|
1565
|
+
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 };
|
|
1545
1566
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { SeedcordErrorCode, paint } from "@seedcord/errors";
|
|
|
5
5
|
import { SeedcordError, SeedcordTypeError, validateDiscordToken } from "@seedcord/errors/internal";
|
|
6
6
|
import { ArraySource as ArraySource$1, BaseHandler as BaseHandler$1, BuilderComponent, Bus, CursorSource as CursorSource$1, CustomId, DispatchContext, Fault, Notice, PaginatorBase, RepliableHandler as RepliableHandler$1, ResolvedEmoji, RowComponent, Silence, Subscriber as Subscriber$1, WebhookLog as WebhookLog$1, assertPermissions, defineGate } from "@seedcord/core";
|
|
7
7
|
import { Logger, LoggerChannelRegistry } from "@seedcord/logger";
|
|
8
|
-
import { ButtonStyle, Client, ComponentType, DiscordAPIError, Events, Guild, GuildMember, Message, MessageFlags, PermissionFlagsBits, RESTJSONErrorCodes, Role, User } from "discord.js";
|
|
8
|
+
import { ButtonStyle, Client, ComponentType, DiscordAPIError, Events, GatewayIntentBits, Guild, GuildMember, IntentsBitField, InteractionContextType, Message, MessageFlags, PermissionFlagsBits, RESTJSONErrorCodes, Role, User } from "discord.js";
|
|
9
9
|
import { ButtonBuilder, TextDisplayBuilder } from "@discordjs/builders";
|
|
10
10
|
import { buildSlashRoute } from "@seedcord/utils/internal";
|
|
11
11
|
import { Plugin as Plugin$1 } from "@seedcord/core/plugin";
|
|
@@ -708,8 +708,8 @@ function slashRouteOf(interaction) {
|
|
|
708
708
|
* `this.options` for a single command or `this.match` for several. Command authoring stays plain
|
|
709
709
|
* discord.js, `seedcord codegen` reads its `toJSON()` to type these options.
|
|
710
710
|
*
|
|
711
|
-
* @typeParam Route - One or more route keys from {@link
|
|
712
|
-
* @typeParam Cache - The interaction cache state
|
|
711
|
+
* @typeParam Route - One or more route keys from {@link SlashRegistry}, e.g. `'ban'` or `'ban' | 'kick'`.
|
|
712
|
+
* @typeParam Cache - The interaction cache state. The command's contexts set it.
|
|
713
713
|
*
|
|
714
714
|
* @example
|
|
715
715
|
* ```ts
|
|
@@ -766,39 +766,57 @@ var SlashHandler = class extends InteractionHandler {
|
|
|
766
766
|
//#endregion
|
|
767
767
|
//#region src/handlers/interaction/ContextMenuHandler.ts
|
|
768
768
|
/**
|
|
769
|
-
* Base class for a context-menu command handler (right-click a user
|
|
769
|
+
* Base class for a user context-menu command handler (right-click a user).
|
|
770
770
|
*
|
|
771
|
-
* Pass the
|
|
772
|
-
*
|
|
773
|
-
* `Message` for a message menu. Context menus carry no options, so a handler registered for several names
|
|
774
|
-
* reads `this.target` uniformly with no per-name branch.
|
|
771
|
+
* Pass the command name(s) as the generic, the same as `@UserContextMenuRoute`. Read the right-clicked
|
|
772
|
+
* user from `this.target` and that same user's guild member from `this.targetMember`.
|
|
775
773
|
*
|
|
776
|
-
* @typeParam
|
|
777
|
-
* @typeParam Cache - The interaction cache state
|
|
774
|
+
* @typeParam Names - One or more command names from the generated user registry.
|
|
775
|
+
* @typeParam Cache - The interaction cache state. The command's contexts set it.
|
|
778
776
|
*
|
|
779
777
|
* @example
|
|
780
778
|
* ```ts
|
|
781
|
-
* \@
|
|
782
|
-
* class
|
|
779
|
+
* \@UserContextMenuRoute('View Profile')
|
|
780
|
+
* class ViewProfile extends UserContextMenuHandler<'View Profile'> {
|
|
783
781
|
* async execute() {
|
|
784
|
-
* const
|
|
782
|
+
* const user = this.target;
|
|
785
783
|
* }
|
|
786
784
|
* }
|
|
787
785
|
* ```
|
|
788
786
|
*/
|
|
789
|
-
var
|
|
787
|
+
var UserContextMenuHandler = class extends InteractionHandler {
|
|
790
788
|
get target() {
|
|
791
|
-
|
|
792
|
-
return "targetUser" in event ? event.targetUser : event.targetMessage;
|
|
789
|
+
return this.event.targetUser;
|
|
793
790
|
}
|
|
794
|
-
/**
|
|
795
|
-
* The invoking guild member, resolved only on user menus. Reading it on a message menu is a compile
|
|
796
|
-
* error since the type is `never` there.
|
|
797
|
-
*/
|
|
791
|
+
/** The right-clicked user's guild member, null outside a guild. */
|
|
798
792
|
get targetMember() {
|
|
799
793
|
return this.event.targetMember;
|
|
800
794
|
}
|
|
801
795
|
};
|
|
796
|
+
/**
|
|
797
|
+
* Base class for a message context-menu command handler (right-click a message).
|
|
798
|
+
*
|
|
799
|
+
* Pass the command name(s) as the generic, the same as `@MessageContextMenuRoute`. Read the right-clicked
|
|
800
|
+
* message from `this.target`.
|
|
801
|
+
*
|
|
802
|
+
* @typeParam Names - One or more command names from the generated message registry.
|
|
803
|
+
* @typeParam Cache - The interaction cache state. The command's contexts set it.
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
* ```ts
|
|
807
|
+
* \@MessageContextMenuRoute('Report Message')
|
|
808
|
+
* class ReportMessage extends MessageContextMenuHandler<'Report Message'> {
|
|
809
|
+
* async execute() {
|
|
810
|
+
* const message = this.target;
|
|
811
|
+
* }
|
|
812
|
+
* }
|
|
813
|
+
* ```
|
|
814
|
+
*/
|
|
815
|
+
var MessageContextMenuHandler = class extends InteractionHandler {
|
|
816
|
+
get target() {
|
|
817
|
+
return this.event.targetMessage;
|
|
818
|
+
}
|
|
819
|
+
};
|
|
802
820
|
|
|
803
821
|
//#endregion
|
|
804
822
|
//#region src/handlers/interaction/AutocompleteHandler.ts
|
|
@@ -809,8 +827,8 @@ var ContextMenuHandler = class extends InteractionHandler {
|
|
|
809
827
|
* `@AutocompleteRoute`. Branch on the focused field with `this.match`, read already-entered sibling options
|
|
810
828
|
* with `this.options`, and find which command fired with `this.route`.
|
|
811
829
|
*
|
|
812
|
-
* @typeParam Route - One or more route keys from {@link
|
|
813
|
-
* @typeParam Cache - The interaction cache state
|
|
830
|
+
* @typeParam Route - One or more route keys from {@link SlashRegistry}, e.g. `'search'` or `'search' | 'find'`.
|
|
831
|
+
* @typeParam Cache - The interaction cache state. The command's contexts set it.
|
|
814
832
|
*
|
|
815
833
|
* @example
|
|
816
834
|
* ```ts
|
|
@@ -1177,7 +1195,7 @@ function contextOf(interaction, core) {
|
|
|
1177
1195
|
* ```ts
|
|
1178
1196
|
* export const Bans = new Paginator({
|
|
1179
1197
|
* prefix: 'bans',
|
|
1180
|
-
* source: new ArraySource((ctx) => ctx.guild
|
|
1198
|
+
* source: new ArraySource((ctx) => ctx.guild?.bans.fetch().then((b) => [...b.values()]) ?? [], { perPage: 10 }),
|
|
1181
1199
|
* renderItem: (ban) => ban.user.tag
|
|
1182
1200
|
* });
|
|
1183
1201
|
*
|
|
@@ -2165,6 +2183,20 @@ var InteractionDispatcher = class {
|
|
|
2165
2183
|
}
|
|
2166
2184
|
};
|
|
2167
2185
|
|
|
2186
|
+
//#endregion
|
|
2187
|
+
//#region src/miscellaneous/assertGuildsIntent.ts
|
|
2188
|
+
function reachesGuilds(command) {
|
|
2189
|
+
const contexts = command.toJSON().contexts;
|
|
2190
|
+
if (!contexts || contexts.length === 0) return true;
|
|
2191
|
+
return contexts.includes(InteractionContextType.Guild);
|
|
2192
|
+
}
|
|
2193
|
+
function assertGuildsIntent(intents, commands) {
|
|
2194
|
+
if ((IntentsBitField.resolve(intents) & GatewayIntentBits.Guilds) !== 0) return;
|
|
2195
|
+
const needing = commands.filter((command) => reachesGuilds(command)).map((command) => command.name);
|
|
2196
|
+
if (needing.length === 0) return;
|
|
2197
|
+
throw new SeedcordError(SeedcordErrorCode.MissingGuildsIntent, [needing.join(", ")]);
|
|
2198
|
+
}
|
|
2199
|
+
|
|
2168
2200
|
//#endregion
|
|
2169
2201
|
//#region \0@oxc-project+runtime@0.142.0/helpers/esm/decorate.js
|
|
2170
2202
|
function __decorate(decorators, target, key, desc) {
|
|
@@ -2189,6 +2221,7 @@ var Bot = class {
|
|
|
2189
2221
|
/** @internal */
|
|
2190
2222
|
[loggerSlot] = this.logger;
|
|
2191
2223
|
isInitialized = false;
|
|
2224
|
+
intents;
|
|
2192
2225
|
_client;
|
|
2193
2226
|
interactions;
|
|
2194
2227
|
events;
|
|
@@ -2202,6 +2235,7 @@ var Bot = class {
|
|
|
2202
2235
|
}
|
|
2203
2236
|
/** @internal */
|
|
2204
2237
|
constructor(core) {
|
|
2238
|
+
this.intents = core.config.bot.clientOptions.intents;
|
|
2205
2239
|
this._client = new Client(core.config.bot.clientOptions);
|
|
2206
2240
|
if (core.config.bot.interactions.path) this.interactions = new InteractionDispatcher(core);
|
|
2207
2241
|
if (core.config.bot.events.path) this.events = new EventDispatcher(core);
|
|
@@ -2252,6 +2286,7 @@ var Bot = class {
|
|
|
2252
2286
|
await this.emojiInjector.init();
|
|
2253
2287
|
if (this.commandRegistry) {
|
|
2254
2288
|
await this.commandRegistry.init();
|
|
2289
|
+
assertGuildsIntent(this.intents, this.commandRegistry.allCommands());
|
|
2255
2290
|
await this.commandRegistry.setCommands();
|
|
2256
2291
|
this.interactions?.warnUnhandledRoutes(this.commandRegistry.routeLeaves());
|
|
2257
2292
|
this.interactions?.warnUnhandledContextMenuRoutes(this.commandRegistry.contextMenuLeaves());
|
|
@@ -2287,7 +2322,7 @@ function botLoggerOf(bot) {
|
|
|
2287
2322
|
//#endregion
|
|
2288
2323
|
//#region src/version.ts
|
|
2289
2324
|
/** Package version */
|
|
2290
|
-
const version = "0.
|
|
2325
|
+
const version = "0.3.0";
|
|
2291
2326
|
|
|
2292
2327
|
//#endregion
|
|
2293
2328
|
//#region src/Seedcord.ts
|
|
@@ -2386,5 +2421,5 @@ var Seedcord = class Seedcord extends Pluggable {
|
|
|
2386
2421
|
};
|
|
2387
2422
|
|
|
2388
2423
|
//#endregion
|
|
2389
|
-
export { ArraySource, AutocompleteHandler, BaseHandler, ButtonHandler, ComponentHandler,
|
|
2424
|
+
export { ArraySource, AutocompleteHandler, BaseHandler, ButtonHandler, ComponentHandler, CursorSource, Emojis, EventHandler, EventMiddleware, Gated, GatewayEmoji, IgnoreBots, InteractionHandler, InteractionMiddleware, MessageContextMenuHandler, Middleware, MiddlewareType, ModalHandler, Nsfw, Paginator, Plugin, RegisterEvent, RepliableHandler, Seedcord, SelectMenuHandler, SlashHandler, Subscriber, UserContextMenuHandler, WebhookLog, checkBotPermissions, checkPermissions, getConfirmation, hasPermsToAssign, version };
|
|
2390
2425
|
//# sourceMappingURL=index.mjs.map
|