Skip to content

Commit

Permalink
rename Devices => DeviceManager
Browse files Browse the repository at this point in the history
  • Loading branch information
Luna-devv committed Sep 8, 2023
1 parent d9e766a commit 5770d39
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Player } from '.';
import { ApiDevice } from '../../../interfaces/player';
import { PlayerDevice } from './Device';

export class PlayerDevices {
export class PlayerDeviceManager {

constructor(
public client: Lunify,
Expand All @@ -14,7 +14,7 @@ export class PlayerDevices {

const res = await this.client.rest.get<{ devices: ApiDevice[] }>('/me/player/devices', {
headers: {
Authorization: this.player.user.oauth.getAuthorization()
Authorization: await this.player.user.oauth.getAuthorization()
}
});

Expand All @@ -38,7 +38,7 @@ export class PlayerDevices {

await this.client.rest.put('/me/player', {
headers: {
Authorization: this.player.user.oauth.getAuthorization()
Authorization: await this.player.user.oauth.getAuthorization()
},
body: {
device_ids: finalDevices
Expand Down
16 changes: 8 additions & 8 deletions src/lib/structures/player/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { Lunify } from '../..';
import { User } from '../user';
import { PlayerDevices } from './Devices';
import { PlayerDeviceManager } from './DeviceManager';

export * from './Device';
export * from './Devices';
export * from './DeviceManager';

export class Player {
public devices: PlayerDevices;
public devices: PlayerDeviceManager;

constructor(
public client: Lunify,
public user: User,
) {
this.devices = new PlayerDevices(this.client, this);
this.devices = new PlayerDeviceManager(this.client, this);
}

/**
Expand All @@ -22,15 +22,15 @@ export class Player {
* player.start('6IRdLKIyS4p7XNiP8r6rsx');
* ```
*/
async play(track: string | string[]) {
async play(trackId: string | string[]) {

const finalTracks: string[] = [];

if (typeof track !== 'string') {
for (const t of track) finalTracks.push('spotify:track:' + t);
if (typeof trackId !== 'string') {
for (const t of trackId) finalTracks.push('spotify:track:' + t);
}
else {
finalTracks.push('spotify:track:' + track);
finalTracks.push('spotify:track:' + trackId);
}

await this.client.rest.put('/me/player/play', {
Expand Down

0 comments on commit 5770d39

Please sign in to comment.