Parse duration strings for /fseek and /seek (#565)

This commit is contained in:
Max Isom 2022-03-13 18:30:36 -04:00 committed by GitHub
parent 03d5cfffd1
commit 6c00727a4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 58 additions and 13 deletions

View file

@ -5,6 +5,7 @@ import PlayerManager from '../managers/player.js';
import Command from '.';
import {parseTime, prettyTime} from '../utils/time.js';
import {SlashCommandBuilder} from '@discordjs/builders';
import durationStringToSeconds from '../utils/duration-string-to-seconds.js';
@injectable()
export default class implements Command {
@ -13,7 +14,7 @@ export default class implements Command {
.setDescription('seek to a position from beginning of song')
.addStringOption(option =>
option.setName('time')
.setDescription('time to seek')
.setDescription('an interval expression or number of seconds (1m, 30s, 100)')
.setRequired(true),
);
@ -45,7 +46,7 @@ export default class implements Command {
if (time.includes(':')) {
seekTime = parseTime(time);
} else {
seekTime = parseInt(time, 10);
seekTime = durationStringToSeconds(time);
}
if (seekTime > currentSong.length) {