Skip to content

Commit

Permalink
Add a response type for openExternalLink that returns a boolean opene…
Browse files Browse the repository at this point in the history
…d value
  • Loading branch information
HamzaAtDiscord committed Nov 15, 2024
1 parent 2cb879a commit 2faa932
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@discord/embedded-app-sdk",
"version": "1.7.0",
"version": "1.7.1",
"description": "@discord/embedded-app-sdk enables you to build rich, multiplayer experiences inside Discord.",
"author": "Discord",
"license": "MIT",
Expand Down
8 changes: 6 additions & 2 deletions src/commands/openExternalLink.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -11,4 +11,8 @@ export interface OpenExternalLinkInput {
*
*/
export const openExternalLink = (sendCommand: TSendCommand) =>
commandFactory<OpenExternalLinkInput, typeof EmptyResponse>(sendCommand, Commands.OPEN_EXTERNAL_LINK, EmptyResponse);
commandFactory<OpenExternalLinkInput, typeof OpenExternalLinkResponse>(
sendCommand,
Commands.OPEN_EXTERNAL_LINK,
OpenExternalLinkResponse,
);
2 changes: 1 addition & 1 deletion src/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
7 changes: 6 additions & 1 deletion src/schema/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ export const GetChannelPermissionsResponse = zod.object({
permissions: zod.bigint().or(zod.string()),
});

export const OpenExternalLinkResponse = zod.object({
opened: zod.boolean(),
});

export {InitiateImageUploadResponseSchema as InitiateImageUploadResponse};

/**
Expand Down Expand Up @@ -162,8 +166,9 @@ function parseResponseData({cmd, data}: zod.infer<typeof ResponseFrame>) {
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:
Expand Down

0 comments on commit 2faa932

Please sign in to comment.