diff --git a/bot.js b/bot.js index f46f157..7eb8845 100644 --- a/bot.js +++ b/bot.js @@ -150,6 +150,11 @@ client.on('message', async message => { // Check for youtube play command const ytmatch = message.content.match(/(?<=!play (https?:\/\/)(www\.)?youtu((be\.com\/watch\?v=)|(\.be\/)))[\w-]{11}/); if (ytmatch && message.member.voice.channel) { + const timematch = message.content.match(/t=(\d{1,2}h)?(\d{1,2}m)?\d{1,4}s?(?=$)/); + var timestamp = ''; + if (timematch) { + timestamp = timematch[0]; + } console.log(`!play issued for ${ytmatch[0]} by ${message.author.tag} ${message.author.id}`); // Reconstruct a youtu.be url for the supplied video const yturl = `https://youtu.be/${ytmatch[0]}`; @@ -157,6 +162,7 @@ client.on('message', async message => { const connection = await message.member.voice.channel.join(); // Play the video as requested try { + //TODO: process the timestamp with ffmpeg or whatever const dispatcher = connection.play(await ytdl(yturl), { type: 'opus', volume: 0.60 }); dispatcher.on('start', () => { console.log(`Playing ${yturl}`); }); dispatcher.on('finish', () => { console.log(`Finished ${yturl}`); });