From 0b6644d85d75734caf096a8248fc832fe30425db Mon Sep 17 00:00:00 2001 From: AikooNee <159515125+AikooNee@users.noreply.github.com> Date: Thu, 4 Jul 2024 09:37:32 +0530 Subject: [PATCH 1/3] Update Replay.ts Signed-off-by: AikooNee <159515125+AikooNee@users.noreply.github.com> --- src/commands/music/Replay.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/commands/music/Replay.ts b/src/commands/music/Replay.ts index 4108ece13..97ec788c2 100644 --- a/src/commands/music/Replay.ts +++ b/src/commands/music/Replay.ts @@ -33,12 +33,13 @@ export default class Replay extends Command { const player = client.queue.get(ctx.guild.id); const embed = this.client.embed(); - if (!player.current) { + + if (!player.current?.info.isSeekable) { return await ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.red).setDescription("There is no track currently playing")], + embeds: [embed.setColor(this.client.color.red).setDescription("Cannot replay this track as it is not seekable")], }); } - + player.seek(0); return await ctx.sendMessage({ From b6d6675cfc979fc9186c48e0f2065ab6ca7b90eb Mon Sep 17 00:00:00 2001 From: AikooNee <159515125+AikooNee@users.noreply.github.com> Date: Thu, 4 Jul 2024 09:52:50 +0530 Subject: [PATCH 2/3] Update Seek.ts Signed-off-by: AikooNee <159515125+AikooNee@users.noreply.github.com> --- src/commands/music/Seek.ts | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/commands/music/Seek.ts b/src/commands/music/Seek.ts index 130e35d37..309663f28 100644 --- a/src/commands/music/Seek.ts +++ b/src/commands/music/Seek.ts @@ -27,8 +27,8 @@ export default class Seek extends Command { slashCommand: true, options: [ { - name: "time", - description: "The time to seek to", + name: "duration", + description: "The duration to seek to", type: 3, required: true, }, @@ -38,19 +38,32 @@ export default class Seek extends Command { public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { const player = client.queue.get(ctx.guild.id); + const current = player.current.info; const embed = this.client.embed(); - - const time = client.utils.parseTime(args[0]); - if (!time) { + const duration = client.utils.parseTime(args.join(" ")); + + if (!duration) { return await ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.red).setDescription("Invalid time format.")], + embeds: [embed.setColor(this.client.color.red).setDescription("Invalid time format. Example: seek 1m, seek 1h 30m")], }); } + if (!current.isSeekable) { + return await ctx.sendMessage({ + embeds: [embed.setColor(this.client.color.red).setDescription("This track is not seekable")], + }); + } + + if (duration > current.length) { + return await ctx.sendMessage({ + embeds: [embed.setColor(this.client.color.red).setDescription(`Cannot seek beyond the song duration of ${client.utils.formatTime(current.length)}`)], + }); + } + player.seek(time); return await ctx.sendMessage({ - embeds: [embed.setColor(this.client.color.main).setDescription(`Seeked to ${args[0]}`)], + embeds: [embed.setColor(this.client.color.main).setDescription(`Seeked to ${client.utils.formatTime(duration)}`)], }); } } From f346213942af32c5ec8f5bc22cfdccf33b2e4151 Mon Sep 17 00:00:00 2001 From: AikooNee <159515125+AikooNee@users.noreply.github.com> Date: Thu, 4 Jul 2024 21:43:58 +0530 Subject: [PATCH 3/3] Fix Signed-off-by: AikooNee <159515125+AikooNee@users.noreply.github.com> --- src/commands/music/Seek.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/music/Seek.ts b/src/commands/music/Seek.ts index 309663f28..e81f35c6d 100644 --- a/src/commands/music/Seek.ts +++ b/src/commands/music/Seek.ts @@ -60,7 +60,7 @@ export default class Seek extends Command { }); } - player.seek(time); + player.seek(duration); return await ctx.sendMessage({ embeds: [embed.setColor(this.client.color.main).setDescription(`Seeked to ${client.utils.formatTime(duration)}`)],