mirror of
https://github.com/tiramisulabs/seyfert.git
synced 2025-07-01 20:46:08 +00:00
feat: make deferReplyResponse and reply awaitable
This commit is contained in:
parent
23c9c2a710
commit
92ab65be7b
@ -219,8 +219,8 @@ export interface ClientOptions extends BaseClientOptions {
|
|||||||
};
|
};
|
||||||
commands?: BaseClientOptions['commands'] & {
|
commands?: BaseClientOptions['commands'] & {
|
||||||
prefix?: (message: MessageStructure) => Awaitable<string[]>;
|
prefix?: (message: MessageStructure) => Awaitable<string[]>;
|
||||||
deferReplyResponse?: (ctx: CommandContext) => Parameters<Message['write']>[0];
|
deferReplyResponse?: (ctx: CommandContext) => Awaitable<Parameters<Message['write']>[0]>;
|
||||||
reply?: (ctx: CommandContext) => boolean;
|
reply?: (ctx: CommandContext) => Awaitable<boolean>;
|
||||||
};
|
};
|
||||||
handlePayload?: ShardManagerOptions['handlePayload'];
|
handlePayload?: ShardManagerOptions['handlePayload'];
|
||||||
resharding?: PickPartial<NonNullable<ShardManagerOptions['resharding']>, 'getInfo'>;
|
resharding?: PickPartial<NonNullable<ShardManagerOptions['resharding']>, 'getInfo'>;
|
||||||
|
@ -79,7 +79,7 @@ export class CommandContext<
|
|||||||
if (this.interaction) return this.interaction.write(body, withResponse);
|
if (this.interaction) return this.interaction.write(body, withResponse);
|
||||||
const options = (this.client as Client | WorkerClient).options?.commands;
|
const options = (this.client as Client | WorkerClient).options?.commands;
|
||||||
return (this.messageResponse = await (this.message! as Message)[
|
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;
|
](body)) as never;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,8 +97,8 @@ export class CommandContext<
|
|||||||
return this.interaction.deferReply(ephemeral ? MessageFlags.Ephemeral : undefined, withResponse);
|
return this.interaction.deferReply(ephemeral ? MessageFlags.Ephemeral : undefined, withResponse);
|
||||||
this.__deferred = true;
|
this.__deferred = true;
|
||||||
const options = (this.client as Client | WorkerClient).options?.commands;
|
const options = (this.client as Client | WorkerClient).options?.commands;
|
||||||
return (this.messageResponse = await (this.message! as Message)[options?.reply?.(this) ? 'reply' : 'write'](
|
return (this.messageResponse = await (this.message! as Message)[(await options?.reply?.(this)) ? 'reply' : 'write'](
|
||||||
options?.deferReplyResponse?.(this) ?? { content: 'Thinking...' },
|
(await options?.deferReplyResponse?.(this)) ?? { content: 'Thinking...' },
|
||||||
)) as never;
|
)) as never;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user