Skip to content

Commit 605e106

Browse files
committed
fix(commandkit): event handler parameters to include client and commandkit instance
1 parent 08949cb commit 605e106

File tree

12 files changed

+189
-162
lines changed

12 files changed

+189
-162
lines changed

apps/website/docs/api-reference/ai/interfaces/configure-ai.mdx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ interface ConfigureAI {
2323
messageFilter?: MessageFilter;
2424
selectAiModel: SelectAiModel;
2525
prepareSystemPrompt?: (ctx: AiContext, message: Message) => Promise<string>;
26-
preparePrompt?: (
27-
ctx: AiContext,
28-
message: Message,
26+
preparePrompt?: (
27+
ctx: AiContext,
28+
message: Message,
2929
) => Promise<string | AiMessage>;
3030
onProcessingStart?: (ctx: AiContext, message: Message) => Promise<void>;
3131
onProcessingFinish?: (ctx: AiContext, message: Message) => Promise<void>;
32-
onResult?: (
33-
ctx: AiContext,
34-
message: Message,
35-
result: AIGenerateResult,
32+
onResult?: (
33+
ctx: AiContext,
34+
message: Message,
35+
result: AIGenerateResult,
3636
) => Promise<void>;
3737
onError?: (ctx: AiContext, message: Message, error: Error) => Promise<void>;
3838
}
@@ -49,24 +49,24 @@ Whether to disable the built-in tools. Default is false.
4949

5050
<MemberInfo kind="property" type={`<a href='/docs/next/api-reference/ai/types/message-filter#messagefilter'>MessageFilter</a>`} />
5151

52-
A filter function that determines whether a message should be processed by the AI.
52+
A filter function that determines whether a message should be processed by the AI.
5353
CommandKit invokes this function before processing the message.
5454
### selectAiModel
5555

5656
<MemberInfo kind="property" type={`<a href='/docs/next/api-reference/ai/types/select-ai-model#selectaimodel'>SelectAiModel</a>`} />
5757

58-
A function that selects the AI model to use based on the message.
58+
A function that selects the AI model to use based on the message.
5959
This function should return a promise that resolves to an object containing the model and options.
6060
### prepareSystemPrompt
6161

6262
<MemberInfo kind="property" type={`(ctx: <a href='/docs/next/api-reference/ai/classes/ai-context#aicontext'>AiContext</a>, message: Message) =&#62; Promise&#60;string&#62;`} />
6363

64-
A function that generates a system prompt based on the message.
65-
This function should return a promise that resolves to a string containing the system prompt.
64+
A function that generates a system prompt based on the message.
65+
This function should return a promise that resolves to a string containing the system prompt.
6666
If not provided, a default system prompt will be used.
6767
### preparePrompt
6868

69-
<MemberInfo kind="property" type={`( ctx: <a href='/docs/next/api-reference/ai/classes/ai-context#aicontext'>AiContext</a>, message: Message, ) =&#62; Promise&#60;string | <a href='/docs/next/api-reference/ai/types/ai-message#aimessage'>AiMessage</a>&#62;`} />
69+
<MemberInfo kind="property" type={`( ctx: <a href='/docs/next/api-reference/ai/classes/ai-context#aicontext'>AiContext</a>, message: Message, ) =&#62; Promise&#60;string | <a href='/docs/next/api-reference/ai/types/ai-message#aimessage'>AiMessage</a>&#62;`} />
7070

7171
A function that prepares the prompt for the AI model.
7272
### onProcessingStart
@@ -81,7 +81,7 @@ A function that gets called when the AI starts processing a message.
8181
A function that gets called when the AI finishes processing a message.
8282
### onResult
8383

84-
<MemberInfo kind="property" type={`( ctx: <a href='/docs/next/api-reference/ai/classes/ai-context#aicontext'>AiContext</a>, message: Message, result: <a href='/docs/next/api-reference/ai/types/aigenerate-result#aigenerateresult'>AIGenerateResult</a>, ) =&#62; Promise&#60;void&#62;`} />
84+
<MemberInfo kind="property" type={`( ctx: <a href='/docs/next/api-reference/ai/classes/ai-context#aicontext'>AiContext</a>, message: Message, result: <a href='/docs/next/api-reference/ai/types/aigenerate-result#aigenerateresult'>AIGenerateResult</a>, ) =&#62; Promise&#60;void&#62;`} />
8585

8686
A function that gets called upon receiving the result from the AI model.
8787
### onError

apps/website/docs/api-reference/cache/interfaces/cache-context.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ Context for managing cache operations within an async scope
1919

2020
```ts title="Signature"
2121
interface CacheContext {
22-
params: {
23-
/** Custom name for the cache entry */
24-
name?: string;
25-
/** Time-to-live in milliseconds */
26-
ttl?: number | null;
27-
tags: Set<string>;
22+
params: {
23+
/** Custom name for the cache entry */
24+
name?: string;
25+
/** Time-to-live in milliseconds */
26+
ttl?: number | null;
27+
tags: Set<string>;
2828
};
2929
}
3030
```
@@ -33,7 +33,7 @@ interface CacheContext {
3333

3434
### params
3535

36-
<MemberInfo kind="property" type={`{ /** Custom name for the <a href='/docs/next/api-reference/cache/functions/cache#cache'>cache</a> entry */ name?: string; /** Time-to-live in milliseconds */ ttl?: number | null; tags: Set&#60;string&#62;; }`} />
36+
<MemberInfo kind="property" type={`{ /** Custom name for the <a href='/docs/next/api-reference/cache/functions/cache#cache'>cache</a> entry */ name?: string; /** Time-to-live in milliseconds */ ttl?: number | null; tags: Set&#60;string&#62;; }`} />
3737

3838

3939

apps/website/docs/api-reference/commandkit/interfaces/command-flag-context.mdx

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,34 @@ Context for evaluating command flags in CommandKit.
2121
interface CommandFlagContext {
2222
client: Client<true>;
2323
commandkit: CommandKit;
24-
command: {
25-
/**
26-
* The interaction object if the command was invoked via an interaction.
27-
* This can be a ChatInputCommandInteraction, AutocompleteInteraction, or ContextMenuCommandInteraction.
28-
*/
29-
interaction?:
30-
| ChatInputCommandInteraction
31-
| AutocompleteInteraction
32-
| ContextMenuCommandInteraction;
33-
/**
34-
* The message object if the command was invoked via a message.
35-
*/
36-
message?: Message;
37-
/**
38-
* The guild where the command was invoked, if applicable.
39-
* This will be null for commands invoked in DMs.
40-
*/
41-
guild: Guild | null;
42-
/**
43-
* The channel where the command was invoked.
44-
* This can be a text channel, DM channel, or any other type of text-based channel.
45-
*/
46-
channel: TextBasedChannel | null;
47-
/**
48-
* The loaded command instance that is being executed.
49-
* This contains the command's metadata and logic.
50-
*/
51-
command: LoadedCommand;
24+
command: {
25+
/**
26+
* The interaction object if the command was invoked via an interaction.
27+
* This can be a ChatInputCommandInteraction, AutocompleteInteraction, or ContextMenuCommandInteraction.
28+
*/
29+
interaction?:
30+
| ChatInputCommandInteraction
31+
| AutocompleteInteraction
32+
| ContextMenuCommandInteraction;
33+
/**
34+
* The message object if the command was invoked via a message.
35+
*/
36+
message?: Message;
37+
/**
38+
* The guild where the command was invoked, if applicable.
39+
* This will be null for commands invoked in DMs.
40+
*/
41+
guild: Guild | null;
42+
/**
43+
* The channel where the command was invoked.
44+
* This can be a text channel, DM channel, or any other type of text-based channel.
45+
*/
46+
channel: TextBasedChannel | null;
47+
/**
48+
* The loaded command instance that is being executed.
49+
* This contains the command's metadata and logic.
50+
*/
51+
command: LoadedCommand;
5252
};
5353
event: null;
5454
}
@@ -60,25 +60,25 @@ interface CommandFlagContext {
6060

6161
<MemberInfo kind="property" type={`Client&#60;true&#62;`} />
6262

63-
The Discord client instance.
63+
The Discord client instance.
6464
This is the main entry point for interacting with the Discord API.
6565
### commandkit
6666

6767
<MemberInfo kind="property" type={`<a href='/docs/next/api-reference/commandkit/classes/command-kit#commandkit'>CommandKit</a>`} />
6868

69-
The CommandKit instance, which provides access to the command framework.
69+
The CommandKit instance, which provides access to the command framework.
7070
This includes commands, events, and other features of CommandKit.
7171
### command
7272

73-
<MemberInfo kind="property" type={`{ /** * The interaction object if the command was invoked via an interaction. * This can be a ChatInputCommandInteraction, AutocompleteInteraction, or ContextMenuCommandInteraction. */ interaction?: | ChatInputCommandInteraction | AutocompleteInteraction | ContextMenuCommandInteraction; /** * The message object if the command was invoked via a message. */ message?: Message; /** * The guild where the command was invoked, if applicable. * This will be null for commands invoked in DMs. */ guild: Guild | null; /** * The channel where the command was invoked. * This can be a text channel, DM channel, or any other type of text-based channel. */ channel: TextBasedChannel | null; /** * The loaded command instance that is being executed. * This contains the command's metadata and logic. */ command: <a href='/docs/next/api-reference/commandkit/interfaces/loaded-command#loadedcommand'>LoadedCommand</a>; }`} />
73+
<MemberInfo kind="property" type={`{ /** * The interaction object if the command was invoked via an interaction. * This can be a ChatInputCommandInteraction, AutocompleteInteraction, or ContextMenuCommandInteraction. */ interaction?: | ChatInputCommandInteraction | AutocompleteInteraction | ContextMenuCommandInteraction; /** * The message object if the command was invoked via a message. */ message?: Message; /** * The guild where the command was invoked, if applicable. * This will be null for commands invoked in DMs. */ guild: Guild | null; /** * The channel where the command was invoked. * This can be a text channel, DM channel, or any other type of text-based channel. */ channel: TextBasedChannel | null; /** * The loaded command instance that is being executed. * This contains the command's metadata and logic. */ command: <a href='/docs/next/api-reference/commandkit/interfaces/loaded-command#loadedcommand'>LoadedCommand</a>; }`} />
7474

75-
The command context, which includes information about the command being executed.
75+
The command context, which includes information about the command being executed.
7676
This can include the interaction, message, guild, channel, and the loaded command.
7777
### event
7878

7979
<MemberInfo kind="property" type={`null`} />
8080

81-
The event context is null for command flags, as they are not tied to a specific event.
81+
The event context is null for command flags, as they are not tied to a specific event.
8282
This is used to differentiate between command and event flags.
8383

8484

apps/website/docs/api-reference/commandkit/interfaces/command-kit-compiler-options.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ import MemberDescription from '@site/src/components/MemberDescription';
1919

2020
```ts title="Signature"
2121
interface CommandKitCompilerOptions {
22-
macro?: {
23-
/**
24-
* Whether to enable macro function compilation in development mode.
25-
* @default false
26-
*/
27-
development?: boolean;
22+
macro?: {
23+
/**
24+
* Whether to enable macro function compilation in development mode.
25+
* @default false
26+
*/
27+
development?: boolean;
2828
};
2929
tsdown?: Partial<TsDownOptions>;
3030
disableChunking?: boolean;
@@ -35,14 +35,14 @@ interface CommandKitCompilerOptions {
3535

3636
### macro
3737

38-
<MemberInfo kind="property" type={`{ /** * Whether to enable macro function compilation in development mode. * @default false */ development?: boolean; }`} />
38+
<MemberInfo kind="property" type={`{ /** * Whether to enable macro function compilation in development mode. * @default false */ development?: boolean; }`} />
3939

4040
The macro compiler options to use with CommandKit.
4141
### tsdown
4242

4343
<MemberInfo kind="property" type={`Partial&#60;TsDownOptions&#62;`} />
4444

45-
The tsdown compiler options to use with CommandKit.
45+
The tsdown compiler options to use with CommandKit.
4646
**DO NOT USE THIS UNLESS YOU KNOW WHAT YOU ARE DOING** as it alters the behavior of the build process.
4747
### disableChunking
4848

apps/website/docs/api-reference/commandkit/interfaces/command-kit-config.mdx

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,36 @@ interface CommandKitConfig {
2323
rolldownPlugins?: any[];
2424
entrypoints?: string[];
2525
compilerOptions?: CommandKitCompilerOptions;
26-
typescript?: {
27-
/**
28-
* Whether to ignore type checking during builds.
29-
*/
30-
ignoreBuildErrors?: boolean;
26+
typescript?: {
27+
/**
28+
* Whether to ignore type checking during builds.
29+
*/
30+
ignoreBuildErrors?: boolean;
3131
};
3232
static?: boolean;
3333
env?: Record<string, string>;
3434
distDir?: string;
35-
antiCrashScript?: {
36-
/**
37-
* Whether to enable the anti-crash script in development mode.
38-
* @default true
39-
*/
40-
development?: boolean;
41-
/**
42-
* Whether to enable the anti-crash script in production mode. Usually, you should use other means to handle errors.
43-
* @default false
44-
*/
45-
production?: boolean;
35+
antiCrashScript?: {
36+
/**
37+
* Whether to enable the anti-crash script in development mode.
38+
* @default true
39+
*/
40+
development?: boolean;
41+
/**
42+
* Whether to enable the anti-crash script in production mode. Usually, you should use other means to handle errors.
43+
* @default false
44+
*/
45+
production?: boolean;
4646
};
47-
sourceMap?: {
48-
/**
49-
* Whether to enable source map generation in development mode.
50-
*/
51-
development?: boolean;
52-
/**
53-
* Whether to enable source map generation in production mode.
54-
*/
55-
production?: boolean;
47+
sourceMap?: {
48+
/**
49+
* Whether to enable source map generation in development mode.
50+
*/
51+
development?: boolean;
52+
/**
53+
* Whether to enable source map generation in production mode.
54+
*/
55+
production?: boolean;
5656
};
5757
typedCommands?: boolean;
5858
disablePrefixCommands?: boolean;
@@ -66,7 +66,7 @@ interface CommandKitConfig {
6666

6767
<MemberInfo kind="property" type={`<a href='/docs/next/api-reference/commandkit/types/maybe-array#maybearray'>MaybeArray</a>&#60;<a href='/docs/next/api-reference/commandkit/types/command-kit-plugin#commandkitplugin'>CommandKitPlugin</a>&#62;[] | Array&#60;<a href='/docs/next/api-reference/commandkit/types/command-kit-plugin#commandkitplugin'>CommandKitPlugin</a>&#62;`} />
6868

69-
The plugins to use with CommandKit.
69+
The plugins to use with CommandKit.
7070
Can be a single plugin, an array of plugins, or a nested array of plugins.
7171
### rolldownPlugins
7272

@@ -77,7 +77,7 @@ The rolldown plugins to use with CommandKit.
7777

7878
<MemberInfo kind="property" type={`string[]`} />
7979

80-
The list of additional entrypoints to compile. Eg, `dir` or `dir/index.ts` or `dir/*.ts`, etc.
80+
The list of additional entrypoints to compile. Eg, `dir` or `dir/index.ts` or `dir/*.ts`, etc.
8181
Similarly, negative patterns can be used to exclude files. Eg, `!dir/index.ts` or `!dir/*.ts`, etc.
8282
### compilerOptions
8383

@@ -86,7 +86,7 @@ Similarly, negative patterns can be used to exclude files. Eg, `!dir/index.ts` o
8686
The compiler options to use with CommandKit.
8787
### typescript
8888

89-
<MemberInfo kind="property" type={`{ /** * Whether to ignore type checking during builds. */ ignoreBuildErrors?: boolean; }`} />
89+
<MemberInfo kind="property" type={`{ /** * Whether to ignore type checking during builds. */ ignoreBuildErrors?: boolean; }`} />
9090

9191
The typescript configuration to use with CommandKit.
9292
### static
@@ -106,12 +106,12 @@ Statically define the environment variables to use.
106106
The custom build directory name to use.
107107
### antiCrashScript
108108

109-
<MemberInfo kind="property" type={`{ /** * Whether to enable the anti-crash script in development mode. * @default true */ development?: boolean; /** * Whether to enable the anti-crash script in production mode. Usually, you should use other means to handle errors. * @default false */ production?: boolean; }`} />
109+
<MemberInfo kind="property" type={`{ /** * Whether to enable the anti-crash script in development mode. * @default true */ development?: boolean; /** * Whether to enable the anti-crash script in production mode. Usually, you should use other means to handle errors. * @default false */ production?: boolean; }`} />
110110

111111
The anti-crash script configuration.
112112
### sourceMap
113113

114-
<MemberInfo kind="property" type={`{ /** * Whether to enable source map generation in development mode. */ development?: boolean; /** * Whether to enable source map generation in production mode. */ production?: boolean; }`} />
114+
<MemberInfo kind="property" type={`{ /** * Whether to enable source map generation in development mode. */ development?: boolean; /** * Whether to enable source map generation in production mode. */ production?: boolean; }`} />
115115

116116
Whether or not to enable the source map generation.
117117
### typedCommands

apps/website/docs/api-reference/commandkit/interfaces/context-parameters.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ interface ContextParameters<T extends CommandExecutionMode, Args = Record<string
2222
command: LoadedCommand;
2323
environment?: CommandKitEnvironment;
2424
executionMode: T;
25-
interaction: T extends 'chatInput'
26-
? ChatInputCommandInteraction
27-
: T extends 'messageContextMenu'
28-
? MessageContextMenuCommandInteraction
29-
: T extends 'userContextMenu'
30-
? UserContextMenuCommandInteraction
31-
: T extends 'autocomplete'
32-
? AutocompleteInteraction
25+
interaction: T extends 'chatInput'
26+
? ChatInputCommandInteraction
27+
: T extends 'messageContextMenu'
28+
? MessageContextMenuCommandInteraction
29+
: T extends 'userContextMenu'
30+
? UserContextMenuCommandInteraction
31+
: T extends 'autocomplete'
32+
? AutocompleteInteraction
3333
: never;
3434
message: T extends 'message' ? Message : never;
3535
forwarded?: boolean;
@@ -58,7 +58,7 @@ interface ContextParameters<T extends CommandExecutionMode, Args = Record<string
5858

5959
### interaction
6060

61-
<MemberInfo kind="property" type={`T extends 'chatInput' ? ChatInputCommandInteraction : T extends 'messageContextMenu' ? MessageContextMenuCommandInteraction : T extends 'userContextMenu' ? UserContextMenuCommandInteraction : T extends 'autocomplete' ? AutocompleteInteraction : never`} />
61+
<MemberInfo kind="property" type={`T extends 'chatInput' ? ChatInputCommandInteraction : T extends 'messageContextMenu' ? MessageContextMenuCommandInteraction : T extends 'userContextMenu' ? UserContextMenuCommandInteraction : T extends 'autocomplete' ? AutocompleteInteraction : never`} />
6262

6363

6464
### message

0 commit comments

Comments
 (0)