Skip to content

Commit

Permalink
added skiponException and skiponStuck options
Browse files Browse the repository at this point in the history
  • Loading branch information
achiragaming committed Jan 5, 2024
1 parent d61c4db commit 73f738a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/DamonJs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export class DamonJs extends EventEmitter {
super();

this.shoukaku = shoukaku;

if (this.DamonJsOptions.skipOnException === undefined) this.DamonJsOptions.skipOnException = true;
if (this.DamonJsOptions.skipOnStuck === undefined) this.DamonJsOptions.skipOnStuck = true;
if (this.DamonJsOptions.plugins) {
for (const [, plugin] of this.DamonJsOptions.plugins.entries()) {
if (plugin.constructor.name !== 'DamonJsPlugin')
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.5.6';
export const version = '1.5.7';
4 changes: 2 additions & 2 deletions src/Managers/DamonJsPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class DamonJsPlayer {
});

this.player.on('exception', async (data: TrackExceptionEvent) => {
await this.stopTrack();
this.damonjs.DamonJsOptions.skipOnException && (await this.stopTrack());
this.emit(Events.PlayerException, this, data);
});

Expand All @@ -164,7 +164,7 @@ export class DamonJsPlayer {
this.emit(Events.PlayerUpdate, this, this.queue.current, data);
});
this.player.on('stuck', async (data: TrackStuckEvent) => {
await this.stopTrack();
this.damonjs.DamonJsOptions.skipOnStuck && (await this.stopTrack());
this.emit(Events.PlayerStuck, this, data);
});
this.player.on('resumed', async () => {
Expand Down
4 changes: 4 additions & 0 deletions src/Modules/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { DamonJsTrack } from '../Managers/Supports/DamonJsTrack';
import { PlayerUpdate, TrackExceptionEvent, TrackStuckEvent, Utils, WebSocketClosedEvent } from 'shoukaku';
import { Snowflake } from 'discord.js';
export interface DamonJsOptions {
/** Skip the track on exception */
skipOnException?: boolean;
/** Skip the track on stuck */
skipOnStuck?: boolean;
/** Default search engine if no engine was provided. Default to youtube */
defaultSearchEngine: SearchEngines;
/** DamonJs plugins */
Expand Down

0 comments on commit 73f738a

Please sign in to comment.