Skip to content

Commit

Permalink
Fix: Type mismatch in the <Track>.raw property (#1930)
Browse files Browse the repository at this point in the history
* Fix: track .raw type

* Fix: Building errors in attachment

* Add live property to default YoutubeExtractor
  • Loading branch information
retrouser955 authored Aug 3, 2024
1 parent 8d73011 commit 434d1f2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions packages/discord-player/src/fabric/Track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ export class Track<T = unknown> {
public requestedBy: User | null = null;
public playlist?: Playlist;
public queryType: SearchQueryType | null | undefined = null;
public raw: RawTrackData = {
source: 'arbitrary'
} as RawTrackData;
public raw: any;

Check warning on line 33 in packages/discord-player/src/fabric/Track.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected any. Specify a different type
public extractor: BaseExtractor | null = null;
public readonly id = SnowflakeUtil.generate().toString();
private __metadata: T | null = null;
private __reqMetadataFn: () => Promise<T | null>;
public cleanTitle: string;
public live: boolean = false

/**
* Track constructor
Expand All @@ -59,6 +58,7 @@ export class Track<T = unknown> {
this.__metadata = data.metadata ?? null;
this.__reqMetadataFn = data.requestMetadata || (() => Promise.resolve<T | null>(null));
this.cleanTitle = data.cleanTitle ?? Util.cleanTitle(this.title, this.source);
this.live = data.live ?? false
}

/**
Expand Down
4 changes: 1 addition & 3 deletions packages/extractor/src/extractors/AttachmentExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ export class AttachmentExtractor extends BaseExtractor {

track.extractor = this;

// @ts-expect-error
track.raw.isFile = false;

return { playlist: null, tracks: [track] };
Expand Down Expand Up @@ -180,7 +179,6 @@ export class AttachmentExtractor extends BaseExtractor {

track.extractor = this;

// @ts-expect-error
track.raw.isFile = true;

return { playlist: null, tracks: [track] };
Expand All @@ -196,7 +194,7 @@ export class AttachmentExtractor extends BaseExtractor {

public async stream(info: Track) {
const engine = info.raw.engine as string;
// @ts-expect-error

const isFile = info.raw.isFile as boolean;

if (!engine) throw new Error('Could not find stream source');
Expand Down
12 changes: 8 additions & 4 deletions packages/extractor/src/extractors/YoutubeExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ export class YoutubeExtractor extends BaseExtractor<YoutubeExtractorInit> {
metadata: video,
async requestMetadata() {
return video;
}
},
live: video.live
});

track.extractor = this;
Expand Down Expand Up @@ -153,7 +154,8 @@ export class YoutubeExtractor extends BaseExtractor<YoutubeExtractorInit> {
metadata: video,
async requestMetadata() {
return video;
}
},
live: video.live
});

track.extractor = this;
Expand Down Expand Up @@ -193,7 +195,8 @@ export class YoutubeExtractor extends BaseExtractor<YoutubeExtractorInit> {
metadata: video,
async requestMetadata() {
return video;
}
},
live: video.live
});

track.extractor = this;
Expand Down Expand Up @@ -237,7 +240,8 @@ export class YoutubeExtractor extends BaseExtractor<YoutubeExtractorInit> {
metadata: video,
async requestMetadata() {
return video;
}
},
live: video.live
});

t.extractor = this;
Expand Down

0 comments on commit 434d1f2

Please sign in to comment.