feat: make deferReplyResponse and reply awaitable

This commit is contained in:
MARCROCK22 2025-05-08 21:09:15 -04:00
parent 23c9c2a710
commit 92ab65be7b
2 changed files with 5 additions and 5 deletions

View File

@ -219,8 +219,8 @@ export interface ClientOptions extends BaseClientOptions {
};
commands?: BaseClientOptions['commands'] & {
prefix?: (message: MessageStructure) => Awaitable<string[]>;
deferReplyResponse?: (ctx: CommandContext) => Parameters<Message['write']>[0];
reply?: (ctx: CommandContext) => boolean;
deferReplyResponse?: (ctx: CommandContext) => Awaitable<Parameters<Message['write']>[0]>;
reply?: (ctx: CommandContext) => Awaitable<boolean>;
};
handlePayload?: ShardManagerOptions['handlePayload'];
resharding?: PickPartial<NonNullable<ShardManagerOptions['resharding']>, 'getInfo'>;

View File

@ -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;
}