Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
achiragaming committed Nov 19, 2024
1 parent 1655450 commit c7a6264
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 22 deletions.
19 changes: 10 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "damonjs",
"version": "1.8.5",
"version": "1.8.6",
"preview": false,
"description": "A modified Shoukaku wrapper with enhanced queue support.",
"main": "dist/Index.js",
Expand Down Expand Up @@ -49,7 +49,7 @@
},
"dependencies": {
"events": "^3.3.0",
"shoukaku": "^4.0.1"
"shoukaku": "^4.1.1"
},
"repository": {
"type": "git",
Expand Down
4 changes: 3 additions & 1 deletion src/DamonJs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export class DamonJs extends EventEmitter {

this.exceptions = this.DamonJsOptions.exceptions ? this.DamonJsOptions.exceptions : { max: 3, time: 30 * 1000 };
this.stuck = this.DamonJsOptions.stuck ? this.DamonJsOptions.stuck : { max: 3, time: 30 * 1000 };
this.trackEndSpam = this.DamonJsOptions.trackEndSpam ?this.DamonJsOptions.trackEndSpam : { max: 3, time: 30 * 1000 };
this.trackEndSpam = this.DamonJsOptions.trackEndSpam
? this.DamonJsOptions.trackEndSpam
: { max: 3, time: 30 * 1000 };
this.resolveError = this.DamonJsOptions.resolveError
? this.DamonJsOptions.resolveError
: { max: 3, time: 30 * 1000 };
Expand Down
2 changes: 1 addition & 1 deletion src/Index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export * from './DamonJs';
export { DamonJsTrack, DamonJsQueue, DamonJsPlayer, Plugins };
export * from './Modules/Interfaces';

export const version = '1.8.5';
export const version = '1.8.6';
9 changes: 4 additions & 5 deletions src/Managers/DamonJsPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ export class DamonJsPlayer {
if (this.state === PlayerState.DESTROYED) throw new DamonJsError(1, 'Player is already destroyed');

if (!tracks && !this.queue.totalSize) throw new DamonJsError(1, 'No track is available to play');

if (!options) options = { replaceCurrent: false };
if (!options || typeof options.replaceCurrent !== 'boolean') options = { ...options, replaceCurrent: false };

if (tracks) {
this.queue.splice(this.queue.currentId + 1, options.replaceCurrent && this.queue.current ? 1 : 0, ...tracks);
Expand All @@ -403,9 +402,9 @@ export class DamonJsPlayer {
await this.handleResolveError(current, resolveResult);
throw new DamonJsError(1, `Player ${this.guildId} resolve error: ${resolveResult.message}`);
}
const playOptions = { track: current.encoded, options: {} };
if (options) playOptions.options = { ...options, noReplace: false };
else playOptions.options = { noReplace: false };
let playOptions = { track: { encoded: current.encoded, userData: current.requester ?? {} } };
if (options) playOptions = { ...playOptions, ...options };

const playerResult = await this.player.playTrack(playOptions).catch((e: Error) => e);
if (playerResult instanceof Error) {
await this.handleResolveError(current, playerResult);
Expand Down
3 changes: 2 additions & 1 deletion src/Managers/Supports/DamonJsTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class DamonJsTrack {
public isrc: string | undefined;
public resolvedBySource: boolean = false;
public readonly data: Map<string, any>;
constructor(raw: RawTrack, requester: unknown) {
constructor(private readonly raw: Track, requester: unknown) {
this.damonjs = undefined;
this.data = new Map();
this.encoded = raw.encoded;
Expand Down Expand Up @@ -93,6 +93,7 @@ export class DamonJsTrack {
sourceName: this.sourceName,
},
pluginInfo: this.pluginInfo,
_raw: this.raw,
};
}

Expand Down
8 changes: 6 additions & 2 deletions src/Modules/Interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { DamonJs } from '../DamonJs';
import { DamonJsPlayer } from '../Index';
import { DamonJsPlayer, DamonJsQueue } from '../Index';
import { DamonJsTrack } from '../Managers/Supports/DamonJsTrack';
import {
PlayerUpdate,
Track,
TrackEndEvent,
TrackExceptionEvent,
TrackStuckEvent,
Expand Down Expand Up @@ -73,6 +74,9 @@ export interface DamonJsPlayerOptions {
textId: Snowflake;
volume: number;
data?: [string, any][];
extends?: {
queue?: Utils.Constructor<DamonJsQueue>;
};
}

export interface ResolveOptions {
Expand Down Expand Up @@ -117,6 +121,7 @@ export interface RawTrack {
sourceName: string;
};
pluginInfo: unknown;
_raw: Track;
}

export interface DamonJsEvents {
Expand Down Expand Up @@ -212,7 +217,6 @@ export const SupportedSources = [
];

export interface PlayOptions {
noReplace?: boolean;
pause?: boolean;
startTime?: number;
endTime?: number;
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DamonJsTrack } from '../Managers/Supports/DamonJsTrack';

export class DamonJsUtils {
static convertDamonJsTrackToTrack(track: DamonJsTrack): Track {
const { encoded, info, pluginInfo } = track.getRaw();
const { encoded: encoded, info, pluginInfo } = track.getRaw();
return {
encoded,
info: {
Expand Down

0 comments on commit c7a6264

Please sign in to comment.