diff --git a/src/commands/openExternalLink.ts b/src/commands/openExternalLink.ts index 8c3a2d1..690865f 100644 --- a/src/commands/openExternalLink.ts +++ b/src/commands/openExternalLink.ts @@ -1,5 +1,5 @@ import {Commands} from '../schema/common'; -import {EmptyResponse} from '../schema/responses'; +import {OpenExternalLinkResponse} from '../schema/responses'; import {TSendCommand} from '../schema/types'; import {commandFactory} from '../utils/commandFactory'; @@ -11,4 +11,8 @@ export interface OpenExternalLinkInput { * */ export const openExternalLink = (sendCommand: TSendCommand) => - commandFactory(sendCommand, Commands.OPEN_EXTERNAL_LINK, EmptyResponse); + commandFactory( + sendCommand, + Commands.OPEN_EXTERNAL_LINK, + OpenExternalLinkResponse, + ); diff --git a/src/mock.ts b/src/mock.ts index 58bdf30..03f6329 100644 --- a/src/mock.ts +++ b/src/mock.ts @@ -119,7 +119,7 @@ export const commandsMockDefault: IDiscordSDK['commands'] = { startPurchase: () => Promise.resolve([]), setConfig: () => Promise.resolve({use_interactive_pip: false}), userSettingsGetLocale: () => Promise.resolve({locale: ''}), - openExternalLink: () => Promise.resolve(null), + openExternalLink: () => Promise.resolve({opened: false}), encourageHardwareAcceleration: () => Promise.resolve({enabled: true}), captureLog: () => Promise.resolve(null), setOrientationLockState: () => Promise.resolve(null), diff --git a/src/schema/responses.ts b/src/schema/responses.ts index d3e9b9e..922b289 100644 --- a/src/schema/responses.ts +++ b/src/schema/responses.ts @@ -14,7 +14,7 @@ import { ChannelTypesObject, ReceiveFramePayload, } from './common'; -import {zodCoerceUnhandledValue} from '../utils/zodUtils'; +import {fallbackToDefault, zodCoerceUnhandledValue} from '../utils/zodUtils'; import {Schemas, AuthenticateResponseSchema, InitiateImageUploadResponseSchema} from '../generated/schemas'; import assertUnreachable from '../utils/assertUnreachable'; @@ -106,6 +106,10 @@ export const GetChannelPermissionsResponse = zod.object({ permissions: zod.bigint().or(zod.string()), }); +export const OpenExternalLinkResponse = fallbackToDefault( + zod.object({opened: zod.boolean().or(zod.null())}).default({opened: null}), +); + export {InitiateImageUploadResponseSchema as InitiateImageUploadResponse}; /** @@ -162,8 +166,9 @@ function parseResponseData({cmd, data}: zod.infer) { return SubscribeResponse.parse(data); case Commands.USER_SETTINGS_GET_LOCALE: return UserSettingsGetLocaleResponse.parse(data); - // Empty Responses case Commands.OPEN_EXTERNAL_LINK: + return OpenExternalLinkResponse.parse(data); + // Empty Responses case Commands.SET_ORIENTATION_LOCK_STATE: case Commands.SET_CERTIFIED_DEVICES: case Commands.SEND_ANALYTICS_EVENT: