diff --git a/src/Discord.ts b/src/Discord.ts index 9376e0a1..1050fd4d 100644 --- a/src/Discord.ts +++ b/src/Discord.ts @@ -10,7 +10,7 @@ import {Platform, RPCCloseCodes} from './Constants'; import getDefaultSdkConfiguration from './utils/getDefaultSdkConfiguration'; import {ConsoleLevel, consoleLevels, wrapConsoleMethod} from './utils/console'; import type {TSendCommand, TSendCommandPayload} from './schema/types'; -import {IDiscordSDK, LayoutModeEventListeners, MaybeZodObjectArray, SdkConfiguration} from './interface'; +import {IDiscordSDK, MaybeZodObjectArray, SdkConfiguration} from './interface'; enum Opcodes { HANDSHAKE = 0, @@ -61,13 +61,6 @@ export class DiscordSDK implements IDiscordSDK { } > = new Map(); - /** - * The key is the layout mode listener passed in by the public API for - * subscribeToLayoutModeUpdatesCompat, and the value is the corresponding - * listeners, created by the SDK, for layout mode updates and PIP mode updates. - */ - private layoutModeUpdateListenerMap: Map = new Map(); - private getTransfer(payload: TSendCommandPayload): Transferable[] | undefined { switch (payload.cmd) { case Commands.SUBSCRIBE: diff --git a/src/commands/getSelectedVoiceChannel.ts b/src/commands/getSelectedVoiceChannel.ts deleted file mode 100644 index dbdd33c9..00000000 --- a/src/commands/getSelectedVoiceChannel.ts +++ /dev/null @@ -1,16 +0,0 @@ -import {Commands} from '../schema/common'; -import {GetSelectedVoiceChannelResponse} from '../schema/responses'; -import {TSendCommand} from '../schema/types'; -import {commandFactory} from '../utils/commandFactory'; - -/** - * Prefer using getChannel instead because the selected voice channel - * is not always the same channel that the activity is mounted to e.g. - * for Activities in text channels. - */ -export const getSelectedVoiceChannel = (sendCommand: TSendCommand) => - commandFactory( - sendCommand, - Commands.GET_SELECTED_VOICE_CHANNEL, - GetSelectedVoiceChannelResponse - ); diff --git a/src/commands/getVoiceSettings.ts b/src/commands/getVoiceSettings.ts deleted file mode 100644 index abb2f595..00000000 --- a/src/commands/getVoiceSettings.ts +++ /dev/null @@ -1,10 +0,0 @@ -import {Commands} from '../schema/common'; -import {VoiceSettingsResponse} from '../schema/responses'; -import {TSendCommand} from '../schema/types'; -import {commandFactory} from '../utils/commandFactory'; - -/** - * - */ -export const getVoiceSettings = (sendCommand: TSendCommand) => - commandFactory(sendCommand, Commands.GET_VOICE_SETTINGS, VoiceSettingsResponse); diff --git a/src/commands/index.ts b/src/commands/index.ts index a114cbd8..cda17cbc 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -6,9 +6,7 @@ import {authorize} from './authorize'; import {captureLog} from './captureLog'; import {encourageHardwareAcceleration} from './encourageHardwareAcceleration'; import {getEntitlements} from './getEntitlements'; -import {getSelectedVoiceChannel} from './getSelectedVoiceChannel'; import {getSkus} from './getSkus'; -import {getVoiceSettings} from './getVoiceSettings'; import {getChannelPermissions} from './getChannelPermissions'; import {getPlatformBehaviors} from './getPlatformBehaviors'; import {openExternalLink} from './openExternalLink'; @@ -17,8 +15,6 @@ import {openShareMomentDialog} from './openShareMomentDialog'; import {setActivity, SetActivity} from './setActivity'; import {setConfig} from './setConfig'; import {setOrientationLockState} from './setOrientationLockState'; -import {setUserVoiceSettings} from './setUserVoiceSettings'; -import {startPremiumPurchase} from './startPremiumPurchase'; import {startPurchase} from './startPurchase'; import {userSettingsGetLocale} from './userSettingsGetLocale'; import {initiateImageUpload} from './initiateImageUpload'; @@ -37,17 +33,13 @@ function commands(sendCommand: TSendCommand) { getChannelPermissions: getChannelPermissions(sendCommand), getEntitlements: getEntitlements(sendCommand), getPlatformBehaviors: getPlatformBehaviors(sendCommand), - getSelectedVoiceChannel: getSelectedVoiceChannel(sendCommand), getSkus: getSkus(sendCommand), - getVoiceSettings: getVoiceSettings(sendCommand), openExternalLink: openExternalLink(sendCommand), openInviteDialog: openInviteDialog(sendCommand), openShareMomentDialog: openShareMomentDialog(sendCommand), setActivity: setActivity(sendCommand), setConfig: setConfig(sendCommand), setOrientationLockState: setOrientationLockState(sendCommand), - setUserVoiceSettings: setUserVoiceSettings(sendCommand), - startPremiumPurchase: startPremiumPurchase(sendCommand), startPurchase: startPurchase(sendCommand), userSettingsGetLocale: userSettingsGetLocale(sendCommand), initiateImageUpload: initiateImageUpload(sendCommand), diff --git a/src/commands/setUserVoiceSettings.ts b/src/commands/setUserVoiceSettings.ts deleted file mode 100644 index b8de59d1..00000000 --- a/src/commands/setUserVoiceSettings.ts +++ /dev/null @@ -1,21 +0,0 @@ -import {Commands} from '../schema/common'; -import {SetUserVoiceSettingsResponse} from '../schema/responses'; -import {TSendCommand} from '../schema/types'; -import {commandFactory} from '../utils/commandFactory'; - -export interface SetUserVoiceSettingsInput { - user_id: string; - volume?: number; - mute?: boolean; - pan?: {left: number; right: number}; -} - -/** - * - */ -export const setUserVoiceSettings = (sendCommand: TSendCommand) => - commandFactory( - sendCommand, - Commands.SET_USER_VOICE_SETTINGS, - SetUserVoiceSettingsResponse - ); diff --git a/src/commands/startPremiumPurchase.ts b/src/commands/startPremiumPurchase.ts deleted file mode 100644 index 5706ad4d..00000000 --- a/src/commands/startPremiumPurchase.ts +++ /dev/null @@ -1,10 +0,0 @@ -import {Commands} from '../schema/common'; -import {EmptyResponse} from '../schema/responses'; -import {TSendCommand} from '../schema/types'; -import {commandFactory} from '../utils/commandFactory'; - -/** - * - */ -export const startPremiumPurchase = (sendCommand: TSendCommand) => - commandFactory(sendCommand, Commands.START_PREMIUM_PURCHASE, EmptyResponse); diff --git a/src/interface.ts b/src/interface.ts index 626960b9..083e678c 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -43,8 +43,3 @@ export interface IDiscordSDK { ): Promise; ready(): Promise; } - -export interface LayoutModeEventListeners { - layoutModeListener: EventListener; - pipModeListener: EventListener; -} diff --git a/src/mock.ts b/src/mock.ts index 9d6d5f72..7c2e5674 100644 --- a/src/mock.ts +++ b/src/mock.ts @@ -110,47 +110,8 @@ export const commandsMockDefault: IDiscordSDK['commands'] = { getSkus: () => Promise.resolve({skus: []}), getEntitlements: () => Promise.resolve({entitlements: []}), startPurchase: () => Promise.resolve([]), - startPremiumPurchase: () => Promise.resolve(null), setConfig: () => Promise.resolve({use_interactive_pip: false}), - getSelectedVoiceChannel: () => Promise.resolve(null), userSettingsGetLocale: () => Promise.resolve({locale: ''}), - getVoiceSettings: () => - Promise.resolve({ - input: { - device_id: 'default', - volume: 0, - available_devices: [{id: 'default', name: 'default'}], - }, - output: { - device_id: 'default', - volume: 0, - available_devices: [{id: 'default', name: 'default'}], - }, - mode: { - type: 'VOICE_ACTIVITY', - auto_threshold: false, - threshold: 0, - shortcut: [], - delay: 0, - }, - automatic_gain_control: false, - echo_cancellation: false, - noise_suppression: false, - qos: false, - silence_warning: false, - deaf: false, - mute: false, - }), - setUserVoiceSettings: () => - Promise.resolve({ - user_id: 'user_id', - mute: false, - pan: { - left: 1, - right: 1, - }, - volume: 100, - }), openExternalLink: () => Promise.resolve(null), encourageHardwareAcceleration: () => Promise.resolve({enabled: true}), captureLog: () => Promise.resolve(null), diff --git a/src/schema/common.ts b/src/schema/common.ts index 99d5d90a..d46a06dd 100644 --- a/src/schema/common.ts +++ b/src/schema/common.ts @@ -11,12 +11,8 @@ export enum Commands { GET_GUILD = 'GET_GUILD', GET_CHANNEL = 'GET_CHANNEL', GET_CHANNELS = 'GET_CHANNELS', - SET_USER_VOICE_SETTINGS = 'SET_USER_VOICE_SETTINGS', SELECT_VOICE_CHANNEL = 'SELECT_VOICE_CHANNEL', - GET_SELECTED_VOICE_CHANNEL = 'GET_SELECTED_VOICE_CHANNEL', SELECT_TEXT_CHANNEL = 'SELECT_TEXT_CHANNEL', - GET_VOICE_SETTINGS = 'GET_VOICE_SETTINGS', - SET_VOICE_SETTINGS = 'SET_VOICE_SETTINGS', SUBSCRIBE = 'SUBSCRIBE', UNSUBSCRIBE = 'UNSUBSCRIBE', CAPTURE_SHORTCUT = 'CAPTURE_SHORTCUT', @@ -27,7 +23,6 @@ export enum Commands { GET_SKUS_EMBEDDED = 'GET_SKUS_EMBEDDED', GET_ENTITLEMENTS_EMBEDDED = 'GET_ENTITLEMENTS_EMBEDDED', START_PURCHASE = 'START_PURCHASE', - START_PREMIUM_PURCHASE = 'START_PREMIUM_PURCHASE', SET_CONFIG = 'SET_CONFIG', SEND_ANALYTICS_EVENT = 'SEND_ANALYTICS_EVENT', USER_SETTINGS_GET_LOCALE = 'USER_SETTINGS_GET_LOCALE', diff --git a/src/schema/responses.ts b/src/schema/responses.ts index 63b75589..cbab4533 100644 --- a/src/schema/responses.ts +++ b/src/schema/responses.ts @@ -59,21 +59,8 @@ export const GetChannelsResponse = zod.object({ channels: zod.array(Channel), }); -export const SetUserVoiceSettingsResponse = zod.object({ - user_id: zod.string(), - pan: zod - .object({ - left: zod.number(), - right: zod.number(), - }) - .optional(), - volume: zod.number().optional(), - mute: zod.boolean().optional(), -}); - export const NullableChannelResponse = GetChannelResponse.nullable(); export const SelectVoiceChannelResponse = GetChannelResponse.nullable(); -export const GetSelectedVoiceChannelResponse = GetChannelResponse.nullable(); export const SelectTextChannelResponse = GetChannelResponse.nullable(); export const VoiceSettingsResponse = zod.object({ @@ -156,11 +143,6 @@ function parseResponseData({cmd, data}: zod.infer) { return GetPlatformBehaviorsResponse.parse(data); case Commands.GET_CHANNEL: return GetChannelResponse.parse(data); - case Commands.GET_SELECTED_VOICE_CHANNEL: - return GetSelectedVoiceChannelResponse.parse(data); - case Commands.GET_VOICE_SETTINGS: - case Commands.SET_VOICE_SETTINGS: - return VoiceSettingsResponse.parse(data); case Commands.SELECT_TEXT_CHANNEL: return SelectTextChannelResponse.parse(data); case Commands.SELECT_VOICE_CHANNEL: @@ -173,8 +155,6 @@ function parseResponseData({cmd, data}: zod.infer) { return GetEntitlementsResponse.parse(data); case Commands.SET_CONFIG: return SetConfigResponse.parse(data); - case Commands.SET_USER_VOICE_SETTINGS: - return SetUserVoiceSettingsResponse.parse(data); case Commands.START_PURCHASE: return StartPurchaseResponse.parse(data); case Commands.SUBSCRIBE: @@ -183,7 +163,6 @@ function parseResponseData({cmd, data}: zod.infer) { case Commands.USER_SETTINGS_GET_LOCALE: return UserSettingsGetLocaleResponse.parse(data); // Empty Responses - case Commands.START_PREMIUM_PURCHASE: case Commands.OPEN_EXTERNAL_LINK: case Commands.SET_ORIENTATION_LOCK_STATE: case Commands.SET_CERTIFIED_DEVICES: