goto fix mabe

This commit is contained in:
ChomeNS 2023-03-24 20:06:39 +07:00
parent 0ac52da62f
commit 46f8f2529a

View file

@ -235,7 +235,13 @@ public class MusicCommand implements Command {
public Component goTo (CommandContext context, String[] args) {
final Bot bot = context.bot();
final Song currentSong = bot.music().currentSong();
final long milliseconds = Long.getLong(args[0]);
final long milliseconds;
try {
milliseconds = Long.parseLong(args[1]);
} catch (NumberFormatException e) {
return Component.text("Invalid timestamp").color(NamedTextColor.RED);
}
if (currentSong == null) return Component.text("No song is currently playing").color(NamedTextColor.RED);
if (milliseconds < 0 || milliseconds > currentSong.length) return Component.text("Invalid timestamp").color(NamedTextColor.RED);