Skip to content

Commit d3d22db

Browse files
authored
Merge pull request #1 from DjDeveloperr/master
fix imports
2 parents d6199ce + aada090 commit d3d22db

File tree

6 files changed

+38
-19
lines changed

6 files changed

+38
-19
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
node_modules/
22

33
yarn.lock
4-
yarn-error.log
4+
yarn-error.log
5+
6+
.vscode

mod.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export * from "./src/@types/track.d.ts";
2-
export * from "./src/@types/player.d.ts";
1+
export type { Track, TrackInfo, LoadTracksException, LoadTracksResponse, LoadType } from "./src/@types/track.d.ts";
2+
export type { PlayTrack, PlayerEvent, PlayerEventType, PlayerRequest, PlayerState, PlayerUpdate } from "./src/@types/player.d.ts";
33
export * from "./src/api/Socket.ts";
44
export * from "./src/api/Player.ts";
55
export * from "./src/Manager.ts";

src/@types/track.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Severity } from "./misc";
1+
import { Severity } from "./player.d.ts";
22

33
export type LoadType = "TRACK_LOADED" | "PLAYLIST_LOADED" | "SEARCH_RESULT" | "NO_MATCHES" | "LOAD_FAILED"
44

@@ -33,4 +33,4 @@ export interface TrackInfo {
3333
position: number;
3434
title: string;
3535
uri: string;
36-
}
36+
}

src/Manager.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { EventEmitter } from "https://deno.land/[email protected]/node/events.ts";
22
import { WebSocketCloseEvent } from "https://deno.land/[email protected]/ws/mod.ts";
3-
import { soxa } from "https://deno.land/x/soxa/mod.ts"
43
import { Socket, SocketData } from "./api/Socket.ts";
54
import { Player } from "./api/Player.ts";
65

7-
import type { LoadTracksResponse } from "./@types";
6+
import type { LoadTracksResponse } from "./@types/track.d.ts";
87

98
const defaults = {
109
resuming: { key: Math.random().toString(32), timeout: 60000 },
@@ -184,15 +183,17 @@ export class Manager extends EventEmitter {
184183
* @param query The search query.
185184
*/
186185
public async search(query: string): Promise<LoadTracksResponse> {
187-
return new Promise(async (resolve, reject) => {
188-
const socket = this.ideal[0];
189-
if (!socket)
190-
throw new Error("Manager#create(): No available sockets.")
191-
192-
soxa.get(`http${socket.secure ? "s" : ""}://${socket.address}/loadtracks?identifier=${query}`)
193-
.then((r) => resolve(r.data))
194-
.catch(e => reject(e));
186+
const socket = this.ideal[0];
187+
if (!socket)
188+
throw new Error("Manager#create(): No available sockets.")
189+
190+
const resp = await fetch(`http${socket.secure ? "s" : ""}://${socket.address}/loadtracks?identifier=${encodeURIComponent(query ?? '')}`, {
191+
headers: { Authorization: socket.password ?? 'youshallnotpass' },
192+
method: 'GET',
195193
});
194+
195+
const data = await resp.json();
196+
return data;
196197
}
197198
}
198199

@@ -247,7 +248,7 @@ export interface ManagerOptions {
247248
reconnect?: ReconnectOptions;
248249
}
249250

250-
export interface ReconnectOptions {
251+
interface ReconnectOptions {
251252
/**
252253
* The total amount of reconnect tries
253254
*/

src/api/Player.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type {
1212
TrackStartEvent,
1313
TrackStuckEvent,
1414
WebSocketClosedEvent
15-
} from "../@types";
15+
} from "../@types/index.d.ts";
1616

1717
export class Player extends EventEmitter {
1818
/**

src/api/Socket.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,23 @@ import {
99
import { Buffer } from "https://deno.land/[email protected]/node/buffer.ts";
1010

1111
import type { Manager } from "../Manager.ts";
12-
import type { ReconnectOptions } from "../../../lavaclient/src";
12+
13+
export interface ReconnectOptions {
14+
/**
15+
* The total amount of reconnect tries
16+
*/
17+
maxTries?: number;
18+
19+
/**
20+
* Whether or not reconnection's are automatically done.
21+
*/
22+
auto?: boolean;
23+
24+
/**
25+
* The delay between socket reconnection's.
26+
*/
27+
delay?: number;
28+
}
1329

1430
export enum Status {
1531
CONNECTED,
@@ -397,4 +413,4 @@ export interface NodeStats {
397413
nulled?: number;
398414
deficit?: number;
399415
};
400-
}
416+
}

0 commit comments

Comments
 (0)