Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove commands we don't want to support #13

Merged
merged 5 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/Discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<EventListener, LayoutModeEventListeners> = new Map();

private getTransfer(payload: TSendCommandPayload): Transferable[] | undefined {
switch (payload.cmd) {
case Commands.SUBSCRIBE:
Expand Down
16 changes: 0 additions & 16 deletions src/commands/getSelectedVoiceChannel.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/getVoiceSettings.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand All @@ -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),
Expand Down
21 changes: 0 additions & 21 deletions src/commands/setUserVoiceSettings.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/commands/startPremiumPurchase.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,3 @@ export interface IDiscordSDK {
): Promise<unknown>;
ready(): Promise<void>;
}

export interface LayoutModeEventListeners {
layoutModeListener: EventListener;
pipModeListener: EventListener;
}
39 changes: 0 additions & 39 deletions src/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
5 changes: 0 additions & 5 deletions src/schema/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down
21 changes: 0 additions & 21 deletions src/schema/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -156,11 +143,6 @@ function parseResponseData({cmd, data}: zod.infer<typeof ResponseFrame>) {
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:
Expand All @@ -173,8 +155,6 @@ function parseResponseData({cmd, data}: zod.infer<typeof ResponseFrame>) {
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:
Expand All @@ -183,7 +163,6 @@ function parseResponseData({cmd, data}: zod.infer<typeof ResponseFrame>) {
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:
Expand Down
Loading