Skip to content

Commit 14e60b4

Browse files
fix(Http, Node): return type of decode method (#28)
1 parent 0ea50e3 commit 14e60b4

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

Diff for: src/base/Node.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import WebSocket = require('ws');
22
import { EventEmitter } from 'events';
33
import Connection, { Options as ConnectionOptions } from '../core/Connection';
4-
import Http, { Track, TrackResponse } from '../core/Http';
4+
import Http, { Track, TrackInfo, TrackResponse } from '../core/Http';
55
import PlayerStore from '../core/PlayerStore';
66

77
export interface VoiceStateUpdate {
@@ -74,9 +74,9 @@ export default abstract class BaseNode extends EventEmitter {
7474
throw new Error('no available http module');
7575
}
7676

77-
public decode(track: string): Promise<Track>;
77+
public decode(track: string): Promise<TrackInfo>;
7878
public decode(tracks: string[]): Promise<Track[]>;
79-
public decode(tracks: string | string[]): Promise<Track | Track[]> {
79+
public decode(tracks: string | string[]): Promise<TrackInfo | Track[]> {
8080
if (this.http) return this.http.decode(tracks);
8181
throw new Error('no available http module');
8282
}

Diff for: src/core/Http.ts

+15-13
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,20 @@ export interface PlaylistInfo {
3939
selectedTrack?: number
4040
}
4141

42+
export interface TrackInfo {
43+
identifier: string;
44+
isSeekable: boolean;
45+
author: string;
46+
length: number;
47+
isStream: boolean;
48+
position: number;
49+
title: string;
50+
uri: string;
51+
}
52+
4253
export interface Track {
4354
track: string;
44-
info: {
45-
identifier: string;
46-
isSeekable: boolean;
47-
author: string;
48-
length: number;
49-
isStream: boolean;
50-
position: number;
51-
title: string;
52-
uri: string;
53-
};
55+
info: TrackInfo;
5456
}
5557

5658
export default class Http {
@@ -77,10 +79,10 @@ export default class Http {
7779
return this.do('GET', url);
7880
}
7981

80-
public decode(track: string): Promise<Track>;
82+
public decode(track: string): Promise<TrackInfo>;
8183
public decode(tracks: string[]): Promise<Track[]>;
82-
public decode(tracks: string | string[]): Promise<Track | Track[]>;
83-
public decode(tracks: string | string[]): Promise<Track | Track[]> {
84+
public decode(tracks: string | string[]): Promise<TrackInfo | Track[]>;
85+
public decode(tracks: string | string[]): Promise<TrackInfo | Track[]> {
8486
const url = this.url();
8587
if (Array.isArray(tracks)) {
8688
url.pathname = '/decodetracks';

0 commit comments

Comments
 (0)