diff --git a/packages/interactions/handlers/interactions/pick-role.ts b/packages/interactions/handlers/interactions/pick-role.ts index d0ebe8c..52c0864 100644 --- a/packages/interactions/handlers/interactions/pick-role.ts +++ b/packages/interactions/handlers/interactions/pick-role.ts @@ -1,5 +1,8 @@ import { selectRole } from '@roleypoly/interactions/utils/api'; -import { asyncResponse } from '@roleypoly/interactions/utils/interactions'; +import { + asyncPreflightEphemeral, + asyncResponse, +} from '@roleypoly/interactions/utils/interactions'; import { invalid, mustBeInGuild } from '@roleypoly/interactions/utils/responses'; import { InteractionCallbackType, @@ -78,5 +81,6 @@ export const pickRole = (mode: 'add' | 'remove') => flags: InteractionFlags.EPHEMERAL, }, }; - } + }, + asyncPreflightEphemeral ); diff --git a/packages/interactions/handlers/interactions/pickable-roles.ts b/packages/interactions/handlers/interactions/pickable-roles.ts index 58d57df..a1a253a 100644 --- a/packages/interactions/handlers/interactions/pickable-roles.ts +++ b/packages/interactions/handlers/interactions/pickable-roles.ts @@ -1,6 +1,9 @@ import { getPickableRoles } from '@roleypoly/interactions/utils/api'; import { uiPublicURI } from '@roleypoly/interactions/utils/config'; -import { asyncResponse } from '@roleypoly/interactions/utils/interactions'; +import { + asyncPreflightEphemeral, + asyncResponse, +} from '@roleypoly/interactions/utils/interactions'; import { mustBeInGuild } from '@roleypoly/interactions/utils/responses'; import { CategoryType, @@ -55,5 +58,6 @@ export const pickableRoles = asyncResponse( ], }, }; - } + }, + asyncPreflightEphemeral ); diff --git a/packages/interactions/utils/interactions.ts b/packages/interactions/utils/interactions.ts index c1e5134..d2f1eb4 100644 --- a/packages/interactions/utils/interactions.ts +++ b/packages/interactions/utils/interactions.ts @@ -41,7 +41,10 @@ export type CommandHandler = ( ) => Promise; 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,