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({ diff --git a/src/commands/music/Seek.ts b/src/commands/music/Seek.ts index 130e35d37..e81f35c6d 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")], }); } - player.seek(time); + 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(duration); 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)}`)], }); } }