forked from Supositware/Haha-Yes
accidently push a WIP version
This commit is contained in:
parent
95c39010db
commit
a2680250ad
1 changed files with 53 additions and 85 deletions
|
@ -10,7 +10,6 @@ class ytpCommand extends Command {
|
||||||
super('ytp', {
|
super('ytp', {
|
||||||
aliases: ['ytp', 'ytpplus', 'ytp+'],
|
aliases: ['ytp', 'ytpplus', 'ytp+'],
|
||||||
category: 'fun',
|
category: 'fun',
|
||||||
clientPermissions: ['SEND_MESSAGES', 'ATTACH_FILES'],
|
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
id: 'add',
|
id: 'add',
|
||||||
|
@ -41,17 +40,8 @@ class ytpCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message, args) {
|
async exec(message, args) {
|
||||||
let MAX_CLIPS = 20;
|
|
||||||
|
|
||||||
if (args.pool) {
|
if (args.pool) {
|
||||||
let mp4 = [];
|
return message.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)\`\``);
|
||||||
fs.readdirSync('./asset/ytp/userVid/').forEach(file => {
|
|
||||||
if (file.endsWith('mp4')) {
|
|
||||||
mp4.push(file);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return message.channel.send(`There is currently ${mp4.length} videos, you can add yours by doing \`\`${prefix[0]}ytp --add (link or attachment)\`\``);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.add) {
|
if (args.add) {
|
||||||
|
@ -64,21 +54,15 @@ class ytpCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
return youtubedl.exec(url, ['--format=mp4', '-o', `./asset/ytp/userVid/${message.id}.mp4`], {}, function(err) {
|
return youtubedl.exec(url, ['-o', `./asset/ytp/userVid/${message.id}.mp4`], {}, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
loadingmsg.delete();
|
loadingmsg.delete();
|
||||||
return message.channel.send('An error has occured, I can\'t download from the link you provided. Is it an mp4?');
|
return message.channel.send('An error has occured, I can\'t download from the link you provided.');
|
||||||
} else {
|
} else {
|
||||||
let mp4 = [];
|
let length = fs.readdirSync('./asset/ytp/userVid/').length;
|
||||||
fs.readdirSync('./asset/ytp/userVid/').forEach(file => {
|
|
||||||
if (file.endsWith('mp4')) {
|
|
||||||
mp4.push(file);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
loadingmsg.delete();
|
loadingmsg.delete();
|
||||||
return message.reply(`Video sucessfully added to the pool! There is now ${mp4.length} videos`);
|
return message.reply(`Video sucessfully added to the pool! There is now ${length} videos`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -87,75 +71,59 @@ class ytpCommand extends Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!message.channel.nsfw && !args.force) return message.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) return message.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');
|
||||||
|
let loadingmsg = await message.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 select random vid and only take .mp4
|
// Read userVid folder and only take .mp4
|
||||||
let mp4 = [];
|
|
||||||
let asset = [];
|
let asset = [];
|
||||||
let files = fs.readdirSync('./asset/ytp/userVid/');
|
fs.readdir('./asset/ytp/userVid/', (err, files) => {
|
||||||
// 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 (let i = 0; i < MAX_CLIPS; i++) {
|
|
||||||
let random = Math.floor(Math.random() * files.length);
|
|
||||||
let vid = `./asset/ytp/userVid/${files[random]}`;
|
|
||||||
if (files[random].endsWith('mp4')) {
|
|
||||||
if (!asset.includes(vid)) {
|
|
||||||
asset.push(vid);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let loadingmsg = await message.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)\`\``);
|
|
||||||
|
|
||||||
|
|
||||||
let options = {
|
|
||||||
debug: true, // Better set this to false to avoid flood in console
|
|
||||||
MAX_STREAM_DURATION: Math.floor((Math.random() * 3) + 1), // Random duration of video clip
|
|
||||||
sources: './asset/ytp/sources/',
|
|
||||||
sounds: './asset/ytp/sounds/',
|
|
||||||
music: './asset/ytp/music/',
|
|
||||||
resources: './asset/ytp/resources/',
|
|
||||||
temp: os.tmpdir(),
|
|
||||||
sourceList: asset,
|
|
||||||
//outro: './asset/ytp/outro.mp4', // Need an outro or it won't work
|
|
||||||
OUTPUT_FILE: `${os.tmpdir()}/${message.id}_YTP.mp4`,
|
|
||||||
MAX_CLIPS: MAX_CLIPS,
|
|
||||||
transitions: true,
|
|
||||||
effects: {
|
|
||||||
effect_RandomSound: true,
|
|
||||||
effect_RandomSoundMute: true,
|
|
||||||
effect_Reverse: true,
|
|
||||||
effect_Chorus: true,
|
|
||||||
effect_Vibrato: true,
|
|
||||||
effect_HighPitch: true,
|
|
||||||
effect_LowPitch: true,
|
|
||||||
effect_SpeedUp: true,
|
|
||||||
effect_SlowDown: true,
|
|
||||||
effect_Dance: true,
|
|
||||||
effect_Squidward: true // Not yet implemented
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
new YTPGenerator().configurateAndGo(options)
|
|
||||||
.then(() => {
|
|
||||||
loadingmsg.delete();
|
|
||||||
return message.reply('Here is your YTP!', {files: [`${os.tmpdir()}/${message.id}_YTP.mp4`]})
|
|
||||||
.catch(err => {
|
|
||||||
console.error(err);
|
|
||||||
return message.channel.send('Whoops, look like the vid might be too big for discord, my bad, please try again');
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.error(err);
|
|
||||||
loadingmsg.delete();
|
|
||||||
return message.reply('Oh no! An error has occured!');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let options = {
|
||||||
|
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
|
||||||
|
sources: './asset/ytp/sources/',
|
||||||
|
sounds: './asset/ytp/sounds/',
|
||||||
|
music: './asset/ytp/music/',
|
||||||
|
resources: './asset/ytp/resources/',
|
||||||
|
temp: os.tmpdir(),
|
||||||
|
sourceList: asset,
|
||||||
|
outro: './asset/ytp/outro.mp4', // Need an outro or it won't work
|
||||||
|
OUTPUT_FILE: `${os.tmpdir()}/${message.id}_YTP.mp4`,
|
||||||
|
MAX_CLIPS: 20,
|
||||||
|
transitions: true,
|
||||||
|
effects: {
|
||||||
|
effect_RandomSound: true,
|
||||||
|
effect_RandomSoundMute: true,
|
||||||
|
effect_Reverse: true,
|
||||||
|
effect_Chorus: true,
|
||||||
|
effect_Vibrato: true,
|
||||||
|
effect_HighPitch: true,
|
||||||
|
effect_LowPitch: true,
|
||||||
|
effect_SpeedUp: true,
|
||||||
|
effect_SlowDown: true,
|
||||||
|
effect_Dance: true,
|
||||||
|
effect_Squidward: false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
new YTPGenerator().configurateAndGo(options)
|
||||||
|
.then(() => {
|
||||||
|
loadingmsg.delete();
|
||||||
|
return message.reply('Here is your YTP!', {files: [`${os.tmpdir()}/${message.id}_YTP.mp4`]})
|
||||||
|
.catch(() => {
|
||||||
|
return message.channel.send('Whoops, look like the vid might be too big for discord, my bad, please try again');
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
loadingmsg.delete();
|
||||||
|
return message.reply('Oh no! An error has occured!');
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue