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 61fda9a commit cbfd8ac
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "damonjs",
"version": "1.9.0",
"version": "1.9.1",
"preview": false,
"description": "A modified Shoukaku wrapper with enhanced queue support.",
"main": "dist/Index.js",
Expand Down
9 changes: 9 additions & 0 deletions src/DamonJs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class DamonJs extends EventEmitter {
timeFrame: number;
maxhits: number;
};
skip: boolean;
};
public trackEndSpam: {
rule: {
Expand All @@ -64,6 +65,7 @@ export class DamonJs extends EventEmitter {
timeFrame: number;
maxhits: number;
};
skip: boolean;
};
/** Stuck config until skip stops */
public stuck: {
Expand All @@ -76,6 +78,7 @@ export class DamonJs extends EventEmitter {
timeFrame: number;
maxhits: number;
};
skip: boolean;
};
public resolveError: {
rule: {
Expand All @@ -87,7 +90,9 @@ export class DamonJs extends EventEmitter {
timeFrame: number;
maxhits: number;
};
skip: boolean;
};

/**
* Initialize a DamonJs instance.
* @param DamonJsOptions DamonJsOptions
Expand All @@ -105,24 +110,28 @@ export class DamonJs extends EventEmitter {
: {
rule: { maxhits: 3, timeFrame: 30 * 1000, cooldown: 5 * 1000 },
destroy: { maxhits: 4, timeFrame: 30 * 1000 },
skip: true,
};
this.stuck = this.DamonJsOptions.stuck
? this.DamonJsOptions.stuck
: {
rule: { maxhits: 3, timeFrame: 30 * 1000, cooldown: 5 * 1000 },
destroy: { maxhits: 4, timeFrame: 30 * 1000 },
skip: true,
};
this.trackEndSpam = this.DamonJsOptions.trackEndSpam
? this.DamonJsOptions.trackEndSpam
: {
rule: { maxhits: 3, timeFrame: 30 * 1000, cooldown: 5 * 1000 },
destroy: { maxhits: 4, timeFrame: 30 * 1000 },
skip: true,
};
this.resolveError = this.DamonJsOptions.resolveError
? this.DamonJsOptions.resolveError
: {
rule: { maxhits: 3, timeFrame: 30 * 1000, cooldown: 5 * 1000 },
destroy: { maxhits: 4, timeFrame: 30 * 1000 },
skip: true,
};

if (this.DamonJsOptions.plugins) {
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.9.0';
export const version = '1.9.1';
16 changes: 16 additions & 0 deletions src/Managers/DamonJsPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ export class DamonJsPlayer {
if (!this.queue.current) return;
this.isTrackPlaying = false;
this.emit(Events.PlayerEnd, this, this.queue.current, data);
if (this.damonjs.trackEndSpam.skip) {
await new Promise((resolve) => setTimeout(resolve, 500));
await this.skip();
}
});
}

Expand Down Expand Up @@ -242,6 +246,10 @@ export class DamonJsPlayer {
this.errors.exceptionData.lastExceptionTime = now;
this.isTrackPlaying = false;
this.emit(Events.PlayerException, this, data);
if (this.damonjs.exceptions.skip) {
await new Promise((resolve) => setTimeout(resolve, 500));
await this.skip();
}
});
}

Expand Down Expand Up @@ -271,6 +279,10 @@ export class DamonJsPlayer {
this.errors.stuckData.lastStuckTime = now;
this.isTrackPlaying = false;
this.emit(Events.PlayerStuck, this, data);
if (this.damonjs.stuck.skip) {
await new Promise((resolve) => setTimeout(resolve, 500));
await this.skip();
}
});
}

Expand Down Expand Up @@ -302,6 +314,10 @@ export class DamonJsPlayer {
this.errors.resolveErrorData.lastResolveErrorTime = now;
this.isTrackPlaying = false;
this.emit(Events.PlayerResolveError, this, current, resolveResult.message);
if (this.damonjs.resolveError.skip) {
await new Promise((resolve) => setTimeout(resolve, 500));
await this.skip();
}
});
}

Expand Down
4 changes: 4 additions & 0 deletions src/Modules/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface DamonJsOptions {
timeFrame: number;
maxhits: number;
};
skip: boolean;
};
/** Exception config until skip stops */
exceptions?: {
Expand All @@ -37,6 +38,7 @@ export interface DamonJsOptions {
timeFrame: number;
maxhits: number;
};
skip: boolean;
};
/** Stuck config until skip stops */
stuck?: {
Expand All @@ -49,6 +51,7 @@ export interface DamonJsOptions {
timeFrame: number;
maxhits: number;
};
skip: boolean;
};
resolveError?: {
rule: {
Expand All @@ -60,6 +63,7 @@ export interface DamonJsOptions {
timeFrame: number;
maxhits: number;
};
skip: boolean;
};
/** DamonJs plugins */
plugins?: DamonJsPlugin[];
Expand Down

0 comments on commit cbfd8ac

Please sign in to comment.