Compare commits

..

2 commits

Author SHA1 Message Date
b095d5ce3a use vxtwitter 2023-12-26 16:39:42 +01:00
da3e0185e1 Quality option 2023-12-26 16:39:34 +01:00
2 changed files with 15 additions and 4 deletions

View file

@ -167,7 +167,7 @@ export default {
const tweetid = tweeted.data.id; const tweetid = tweeted.data.id;
const FunnyWords = ['oppaGangnamStyle', '69', '420', 'cum', 'funnyMan', 'GUCCISmartToilet', 'TwitterForClowns', 'fart', 'ok', 'hi', 'howAreYou', 'WhatsNinePlusTen', '21']; const FunnyWords = ['oppaGangnamStyle', '69', '420', 'cum', 'funnyMan', 'GUCCISmartToilet', 'TwitterForClowns', 'fart', 'ok', 'hi', 'howAreYou', 'WhatsNinePlusTen', '21'];
const TweetLink = `https://twitter.com/${FunnyWords[Math.floor((Math.random() * FunnyWords.length))]}/status/${tweetid}`; const TweetLink = `https://vxtwitter.com/${FunnyWords[Math.floor((Math.random() * FunnyWords.length))]}/status/${tweetid}`;
let channel = await client.channels.resolve(twiChannel); let channel = await client.channels.resolve(twiChannel);
channel.send(TweetLink); channel.send(TweetLink);

View file

@ -15,6 +15,10 @@ export default {
option.setName('url') option.setName('url')
.setDescription('URL of the video you want to convert') .setDescription('URL of the video you want to convert')
.setRequired(true)) .setRequired(true))
.addIntegerOption(option =>
option.setName('quality')
.setDescription('Quality of the gif conversion. Default 70. Number between 1 and 100')
.setRequired(false))
.addBooleanOption(option => .addBooleanOption(option =>
option.setName('noloop') option.setName('noloop')
.setDescription('Stop the gif from looping') .setDescription('Stop the gif from looping')
@ -25,6 +29,13 @@ export default {
await interaction.deferReply({ ephemeral: false }); await interaction.deferReply({ ephemeral: false });
const maxFileSize = await utils.getMaxFileSize(interaction.guild); const maxFileSize = await utils.getMaxFileSize(interaction.guild);
const url = args.url; const url = args.url;
let quality = args.quality;
if (quality <= 0) {
quality = 1;
}
else if (quality > 100) {
quality = 100;
}
if (!await utils.stringIsAValidurl(url)) { if (!await utils.stringIsAValidurl(url)) {
console.error(`Not a url!!! ${url}`); console.error(`Not a url!!! ${url}`);
@ -41,7 +52,7 @@ export default {
// Extract every frame for gifski // Extract every frame for gifski
await utils.ffmpeg(`-i ${output} ${os.tmpdir()}/frame${interaction.id}%04d.png`); await utils.ffmpeg(`-i ${output} ${os.tmpdir()}/frame${interaction.id}%04d.png`);
// Make it look better // Make it look better
await gifski(gifskiOutput, `${os.tmpdir()}/frame${interaction.id}*`); await gifski(gifskiOutput, `${os.tmpdir()}/frame${interaction.id}*`, quality);
// Optimize it // Optimize it
await gifsicle(gifskiOutput, gifsicleOutput, args.noloop); await gifsicle(gifskiOutput, gifsicleOutput, args.noloop);
@ -66,9 +77,9 @@ export default {
}, },
}; };
async function gifski(output, input) { async function gifski(output, input, quality) {
return await new Promise((resolve, reject) => { return await new Promise((resolve, reject) => {
exec(`gifski --quality 70 -o ${output} ${input}`, (err, stdout, stderr) => { exec(`gifski --quality ${quality ? quality : 70} -o ${output} ${input}`, (err, stdout, stderr) => {
if (err) { if (err) {
reject(stderr); reject(stderr);
} }