finally fix listing

This commit is contained in:
Chayapak 2023-04-01 13:25:51 +07:00
parent fed86cdbb2
commit 6f5587c232

View file

@ -154,9 +154,11 @@ public class MusicCommand implements Command {
public Component list (CommandContext context, String[] args) {
final String prefix = context.prefix();
final Path _path = Path.of(root.toString(), String.join(" ", args));
final Path _path = Path.of(root.toString(), String.join(" ", Arrays.copyOfRange(args, 1, args.length)));
final Path path = (args.length < 2) ? root : _path;
if (!path.normalize().startsWith(root.toString())) return Component.text("no").color(NamedTextColor.RED);
final String[] filenames = path.toFile().list();
if (filenames == null) return Component.text("Directory doesn't exist").color(NamedTextColor.RED);