From 92ab65be7bc75624d41da2e980d7152ff095e0b1 Mon Sep 17 00:00:00 2001 From: MARCROCK22 Date: Thu, 8 May 2025 21:09:15 -0400 Subject: [PATCH] feat: make deferReplyResponse and reply awaitable --- src/client/client.ts | 4 ++-- src/commands/applications/chatcontext.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/client.ts b/src/client/client.ts index 346dcf4..c6079a0 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -219,8 +219,8 @@ export interface ClientOptions extends BaseClientOptions { }; commands?: BaseClientOptions['commands'] & { prefix?: (message: MessageStructure) => Awaitable; - deferReplyResponse?: (ctx: CommandContext) => Parameters[0]; - reply?: (ctx: CommandContext) => boolean; + deferReplyResponse?: (ctx: CommandContext) => Awaitable[0]>; + reply?: (ctx: CommandContext) => Awaitable; }; handlePayload?: ShardManagerOptions['handlePayload']; resharding?: PickPartial, 'getInfo'>; diff --git a/src/commands/applications/chatcontext.ts b/src/commands/applications/chatcontext.ts index 82be4c4..ef04fb7 100644 --- a/src/commands/applications/chatcontext.ts +++ b/src/commands/applications/chatcontext.ts @@ -79,7 +79,7 @@ export class CommandContext< if (this.interaction) return this.interaction.write(body, withResponse); const options = (this.client as Client | WorkerClient).options?.commands; return (this.messageResponse = await (this.message! as Message)[ - !this.messageResponse && options?.reply?.(this) ? 'reply' : 'write' + !this.messageResponse && (await options?.reply?.(this)) ? 'reply' : 'write' ](body)) as never; } @@ -97,8 +97,8 @@ export class CommandContext< return this.interaction.deferReply(ephemeral ? MessageFlags.Ephemeral : undefined, withResponse); this.__deferred = true; const options = (this.client as Client | WorkerClient).options?.commands; - return (this.messageResponse = await (this.message! as Message)[options?.reply?.(this) ? 'reply' : 'write']( - options?.deferReplyResponse?.(this) ?? { content: 'Thinking...' }, + return (this.messageResponse = await (this.message! as Message)[(await options?.reply?.(this)) ? 'reply' : 'write']( + (await options?.deferReplyResponse?.(this)) ?? { content: 'Thinking...' }, )) as never; }