@ -40,8 +40,17 @@ class ytpCommand extends Command {
}
}
asyncexec(message,args){
asyncexec(message,args){
letMAX_CLIPS=20;
if(args.pool){
if(args.pool){
returnmessage.channel.send(`here is currently ${fs.readdirSync('./asset/ytp/userVid/').length} videos, you can add yours by doing \`\`${prefix[0]}ytp --add (link or attachment)\`\``);
returnmessage.reply(`Video sucessfully added to the pool! There is now ${length} videos`);
returnmessage.reply(`Video sucessfully added to the pool! There is now ${mp4.length} videos`);
}
}
});
});
}else{
}else{
@ -71,21 +86,36 @@ class ytpCommand extends Command {
}
}
}
}
if(!message.channel.nsfw&&!args.force)returnmessage.channel.send('Please execute this command in an NSFW channel ( Content might not be NSFW but since the video are user submitted better safe than sorry ) OR --force to make the command work outside of nsfw channel BE AWARE THAT IT WON\'T CHANGE THE FINAL RESULT SO NSFW CAN STILL HAPPEN');
if(!message.channel.nsfw&&!args.force)returnmessage.channel.send('Please execute this command in an NSFW channel ( Content might not be NSFW but since the video are user submitted better safe than sorry ) OR --force to make the command work outside of nsfw channel BE AWARE THAT IT WON\'T CHANGE THE FINAL RESULT SO NSFW CAN STILL HAPPEN');
letloadingmsg=awaitmessage.channel.send(`Processing, this can take a **long** time, i'll ping you when i finished <a:loadingmin:527579785212329984>\nSome info: There is currently ${fs.readdirSync('./asset/ytp/userVid/').length} videos, you can add yours by doing \`\`${prefix[0]}ytp --add (link or attachment)\`\``);
// Read userVid folder and only take .mp4
// Read userVid folder and select random vid and only take .mp4
letmp4=[];
letasset=[];
letasset=[];
fs.readdir('./asset/ytp/userVid/',(err,files)=>{
letfiles=fs.readdirSync('./asset/ytp/userVid/');
// Count number of total vid
files.forEach(file=>{
files.forEach(file=>{
if(file.endsWith('.mp4')){
if(file.endsWith('mp4')){
asset.push(`./asset/ytp/userVid/${file}`);
mp4.push(file);
}
}
});
});
// Select random vid depending on the amount of MAX_CLIPS
for(leti=0;i<MAX_CLIPS;i++){
letrandom=Math.floor(Math.random()*files.length);
letvid=`./asset/ytp/userVid/${files[random]}`;
if(files[random].endsWith('mp4')){
if(!asset.includes(vid)){
asset.push(vid);
}
}
}
letloadingmsg=awaitmessage.channel.send(`Processing, this can take a **long** time, i'll ping you when i finished <a:loadingmin:527579785212329984>\nSome info: There is currently ${mp4.length} videos, you can add yours by doing \`\`${prefix[0]}ytp --add (link or attachment)\`\``);
letoptions={
letoptions={
debug:false,// Better set this to false to avoid flood in console
debug:false,// Better set this to false to avoid flood in console
MIN_STREAM_DURATION:Math.floor((Math.random()*2)+1),// Random duration of video clip
MAX_STREAM_DURATION:Math.floor((Math.random()*3)+1),// Random duration of video clip
sources:'./asset/ytp/sources/',
sources:'./asset/ytp/sources/',
sounds:'./asset/ytp/sounds/',
sounds:'./asset/ytp/sounds/',
music:'./asset/ytp/music/',
music:'./asset/ytp/music/',
@ -94,7 +124,7 @@ class ytpCommand extends Command {
sourceList:asset,
sourceList:asset,
outro:'./asset/ytp/outro.mp4',// Need an outro or it won't work
outro:'./asset/ytp/outro.mp4',// Need an outro or it won't work