1- import { ChatInputCommandContext , CommandData } from 'commandkit' ;
1+ import {
2+ ChatInputCommandContext ,
3+ CommandData ,
4+ MessageCommandContext ,
5+ } from 'commandkit' ;
26import { database } from '@/database/store.ts' ;
37import { cacheTag } from '@commandkit/cache' ;
4- import { AiConfig , AiContext } from '@commandkit/ai' ;
8+ import { AiConfig } from '@commandkit/ai' ;
59import { z } from 'zod' ;
610
711export const command : CommandData = {
812 name : 'xp' ,
913 description : 'This is an xp command.' ,
1014} ;
1115
12- export const aiConfig : AiConfig = {
16+ export const aiConfig = {
1317 description : 'Get the XP of a user in a guild.' ,
1418 parameters : z . object ( {
1519 guildId : z . string ( ) . describe ( 'The ID of the guild.' ) ,
1620 userId : z . string ( ) . describe ( 'The ID of the user.' ) ,
1721 } ) ,
18- } ;
22+ } satisfies AiConfig ;
1923
2024async function getUserXP ( guildId : string , userId : string ) {
2125 'use cache' ;
@@ -50,7 +54,7 @@ export async function chatInput({ interaction }: ChatInputCommandContext) {
5054 } ) ;
5155}
5256
53- export async function ai ( ctx : AiContext ) {
57+ export async function ai ( ctx : MessageCommandContext ) {
5458 const message = ctx . message ;
5559
5660 if ( ! message . inGuild ( ) ) {
@@ -59,10 +63,9 @@ export async function ai(ctx: AiContext) {
5963 } ;
6064 }
6165
62- const { guildId, userId } = ctx . params as {
63- guildId : string ;
64- userId : string ;
65- } ;
66+ const { guildId, userId } = ctx . ai ?. params as z . infer <
67+ ( typeof aiConfig ) [ 'parameters' ]
68+ > ;
6669
6770 const xp = await getUserXP ( guildId , userId ) ;
6871
0 commit comments