mirror of
https://github.com/BluemediaDev/muse.git
synced 2025-01-19 03:18:56 +01:00
Allow skipping multiple tracks
This commit is contained in:
parent
531da56dd0
commit
5d92d4ed54
|
@ -11,7 +11,8 @@ export default class implements Command {
|
||||||
public name = 'skip';
|
public name = 'skip';
|
||||||
public aliases = ['s'];
|
public aliases = ['s'];
|
||||||
public examples = [
|
public examples = [
|
||||||
['skip', 'skips the current song']
|
['skip', 'skips the current song'],
|
||||||
|
['skip 2', 'skips the next 2 songs']
|
||||||
];
|
];
|
||||||
|
|
||||||
public requiresVC = true;
|
public requiresVC = true;
|
||||||
|
@ -22,14 +23,22 @@ export default class implements Command {
|
||||||
this.playerManager = playerManager;
|
this.playerManager = playerManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async execute(msg: Message, _: string []): Promise<void> {
|
public async execute(msg: Message, args: string []): Promise<void> {
|
||||||
|
let numToSkip = 1;
|
||||||
|
|
||||||
|
if (args.length === 1) {
|
||||||
|
if (!Number.isNaN(parseInt(args[0], 10))) {
|
||||||
|
numToSkip = parseInt(args[0], 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const player = this.playerManager.get(msg.guild!.id);
|
const player = this.playerManager.get(msg.guild!.id);
|
||||||
|
|
||||||
const loader = new LoadingMessage(msg.channel as TextChannel);
|
const loader = new LoadingMessage(msg.channel as TextChannel);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await loader.start();
|
await loader.start();
|
||||||
await player.forward();
|
await player.forward(numToSkip);
|
||||||
|
|
||||||
await loader.stop('keep \'er movin\'');
|
await loader.stop('keep \'er movin\'');
|
||||||
} catch (_: unknown) {
|
} catch (_: unknown) {
|
||||||
|
|
|
@ -63,7 +63,7 @@ export default class {
|
||||||
if (isPlaying) {
|
if (isPlaying) {
|
||||||
oldPosition = player.getPosition();
|
oldPosition = player.getPosition();
|
||||||
|
|
||||||
player.manualForward();
|
player.manualForward(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
await player.seek(position);
|
await player.seek(position);
|
||||||
|
|
|
@ -161,8 +161,8 @@ export default class {
|
||||||
this.stopTrackingPosition();
|
this.stopTrackingPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
async forward(): Promise<void> {
|
async forward(skip: number): Promise<void> {
|
||||||
this.manualForward();
|
this.manualForward(skip);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.getCurrent() && this.status !== STATUS.PAUSED) {
|
if (this.getCurrent() && this.status !== STATUS.PAUSED) {
|
||||||
|
@ -177,9 +177,9 @@ export default class {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
manualForward(): void {
|
manualForward(skip: number): void {
|
||||||
if (this.queuePosition < this.queue.length) {
|
if ((this.queuePosition + skip - 1) < this.queue.length) {
|
||||||
this.queuePosition++;
|
this.queuePosition += skip;
|
||||||
this.positionInSeconds = 0;
|
this.positionInSeconds = 0;
|
||||||
this.stopTrackingPosition();
|
this.stopTrackingPosition();
|
||||||
} else {
|
} else {
|
||||||
|
@ -440,7 +440,7 @@ export default class {
|
||||||
private async onVoiceConnectionSpeaking(isSpeaking: boolean): Promise<void> {
|
private async onVoiceConnectionSpeaking(isSpeaking: boolean): Promise<void> {
|
||||||
// Automatically advance queued song at end
|
// Automatically advance queued song at end
|
||||||
if (!isSpeaking && this.status === STATUS.PLAYING) {
|
if (!isSpeaking && this.status === STATUS.PLAYING) {
|
||||||
await this.forward();
|
await this.forward(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue