mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-16 09:39:09 +00:00
chore: refactor asyncResponse to take a preflight response
This commit is contained in:
parent
26bc74bcbc
commit
76a03c2d2c
3 changed files with 21 additions and 8 deletions
|
@ -41,7 +41,10 @@ export type CommandHandler = (
|
|||
) => Promise<InteractionResponse>;
|
||||
|
||||
export const asyncResponse =
|
||||
(handler: CommandHandler): CommandHandler =>
|
||||
(
|
||||
handler: CommandHandler,
|
||||
preflight?: () => InteractionResponse['data']
|
||||
): CommandHandler =>
|
||||
async (
|
||||
command: InteractionRequestCommand,
|
||||
requestInfo: RequestInfo
|
||||
|
@ -55,12 +58,14 @@ export const asyncResponse =
|
|||
|
||||
return {
|
||||
type: InteractionCallbackType.DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE,
|
||||
data: {
|
||||
flags: InteractionFlags.EPHEMERAL,
|
||||
},
|
||||
data: preflight ? preflight() : undefined,
|
||||
};
|
||||
};
|
||||
|
||||
export const asyncPreflightEphemeral = () => ({
|
||||
flags: InteractionFlags.EPHEMERAL,
|
||||
});
|
||||
|
||||
const updateOriginalMessage = async (
|
||||
appID: string,
|
||||
token: string,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue