From c33b1d84791a8104e72b0421ba388454d0591182 Mon Sep 17 00:00:00 2001 From: ChomeNS Date: Tue, 20 Dec 2022 17:59:45 +0700 Subject: [PATCH] music play autocomplete (quite broken) --- commands/music.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/commands/music.js b/commands/music.js index 70f4b8e..34e118f 100644 --- a/commands/music.js +++ b/commands/music.js @@ -20,8 +20,16 @@ let song async function play (bot, values, discord, channeldc, selector, config) { try { + const songs = await fileList(SONGS_PATH) const filepath = values.join(' ') - const absolutePath = await resolve(filepath) + + const file = songs.filter((song) => song.toLowerCase().includes(filepath))[0] + + let absolutePath + if (!path.isAbsolute(filepath) && + filepath !== '') absolutePath = await resolve(file) + else absolutePath = await resolve(filepath) + song = bot.music.load(await fs.readFile(absolutePath), path.basename(absolutePath)) bot.music.queue.push(song) bot.music.play(song)