Skip to content

Commit

Permalink
Merge pull request #5 from tnfAngel/update-main
Browse files Browse the repository at this point in the history
merge pub-main into main
  • Loading branch information
tnfAngel authored Dec 6, 2023
2 parents fa74831 + 17796fb commit a99ec13
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 26 deletions.
24 changes: 15 additions & 9 deletions src/structures/party/ClientParty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type PartyMemberConfirmation from './PartyMemberConfirmation';
import type ClientPartyMember from './ClientPartyMember';
import type Client from '../../Client';
import type {
PartyData, PartyPrivacy, PartySchema, Playlist,
Island, PartyData, PartyPrivacy, PartySchema,
} from '../../../resources/structs';
import type PartyMember from './PartyMember';
import type Friend from '../friend/Friend';
Expand Down Expand Up @@ -402,30 +402,36 @@ class ClientParty extends Party {

/**
* Updates the party's playlist
* @param playlist The new playlist
* @param mnemonic The new mnemonic (Playlist id or island code, for example: playlist_defaultduo or 1111-1111-1111)
* @param regionId The new region id
* @param version The new version
* @param options Playlist options
* @throws {PartyPermissionError} The client is not the leader of the party
* @throws {EpicgamesAPIError}
*/
public async setPlaylist(playlist: Playlist, regionId?: string) {
public async setPlaylist(mnemonic: string, regionId?: string, version?: number, options?: Omit<Island, 'linkId'>) {
if (!this.me.isLeader) throw new PartyPermissionError();

let regionIdData = this.meta.get('Default:RegionId_s');
if (regionId) {
regionIdData = this.meta.set('Default:RegionId_s', regionId);
}

let data = this.meta.get('Default:PlaylistData_j');
data = this.meta.set('Default:PlaylistData_j', {
let data = this.meta.get('Default:SelectedIsland_j');
data = this.meta.set('Default:SelectedIsland_j', {
...data,
PlaylistData: {
...data.PlaylistData,
...playlist,
SelectedIsland: {
...data.SelectedIsland,
linkId: {
mnemonic,
version: version ?? -1,
},
...options,
},
});

await this.sendPatch({
'Default:PlaylistData_j': data,
'Default:SelectedIsland_j': data,
'Default:RegionId_s': regionIdData,
});
}
Expand Down
7 changes: 0 additions & 7 deletions src/structures/party/Party.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,6 @@ class Party extends Base {
* The currently selected playlist
*/
public get playlist() {
return this.meta.playlist;
}

/**
* The currently selected island
*/
public get island() {
return this.meta.island;
}

Expand Down
4 changes: 2 additions & 2 deletions src/structures/party/PartyMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ class PartyMember extends User {
}

/**
* The member's current island
* The member's current playlist
*/
public get island() {
public get playlist() {
return this.meta.island;
}

Expand Down
9 changes: 1 addition & 8 deletions src/structures/party/PartyMeta.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import Meta from '../../util/Meta';
import type { Island, PartySchema, Playlist } from '../../../resources/structs';
import type { Island, PartySchema } from '../../../resources/structs';

/**
* Represents a party's meta
*/
class PartyMeta extends Meta<PartySchema> {
/**
* The currently selected playlist
*/
public get playlist(): Playlist | undefined {
return this.get('Default:PlaylistData_j')?.PlaylistData;
}

/**
* The currently selected island
*/
Expand Down

0 comments on commit a99ec13

Please sign in to comment.