music play autocomplete (quite broken)

This commit is contained in:
ChomeNS 2022-12-20 17:59:45 +07:00
parent 912ef5e05f
commit c33b1d8479

View file

@ -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)