Compare commits
No commits in common. "50b55edae355f06d3d45f452cba8260b428ae423" and "62666e2a3f8eeddb954e305b9a5f9e39a4863a30" have entirely different histories.
50b55edae3
...
62666e2a3f
2 changed files with 7 additions and 24 deletions
|
@ -1,5 +1,3 @@
|
|||
// TODO
|
||||
// Switch to 'twitter-api-v2'
|
||||
import { SlashCommandBuilder } from 'discord.js';
|
||||
import Twit from 'twit';
|
||||
|
|
@ -19,10 +19,6 @@ export default {
|
|||
option.setName('quality')
|
||||
.setDescription('Quality of the gif conversion. Default 70. Number between 1 and 100')
|
||||
.setRequired(false))
|
||||
.addIntegerOption(option =>
|
||||
option.setName('fps')
|
||||
.setDescription('Change the speed at which the gif play at. Default 20. Number between 1 and 100.')
|
||||
.setRequired(false))
|
||||
.addBooleanOption(option =>
|
||||
option.setName('noloop')
|
||||
.setDescription('Stop the gif from looping')
|
||||
|
@ -36,23 +32,12 @@ export default {
|
|||
const maxFileSize = await utils.getMaxFileSize(interaction.guild);
|
||||
const url = args.url;
|
||||
let quality = args.quality;
|
||||
if (quality) {
|
||||
if (quality <= 0) {
|
||||
quality = 1;
|
||||
}
|
||||
else if (quality > 100) {
|
||||
quality = 100;
|
||||
}
|
||||
}
|
||||
|
||||
if (args.fps) {
|
||||
if (args.fps <= 0) {
|
||||
args.fps = 1;
|
||||
}
|
||||
else if (args.fps > 100) {
|
||||
args.fps = 100;
|
||||
}
|
||||
}
|
||||
|
||||
if (!await utils.stringIsAValidurl(url)) {
|
||||
console.error(`Not a url!!! ${url}`);
|
||||
|
@ -69,7 +54,7 @@ export default {
|
|||
// Extract every frame for gifski
|
||||
await utils.ffmpeg(['-i', output, `${os.tmpdir()}/frame${interaction.id}%04d.png`]);
|
||||
// Make it look better
|
||||
await gifski(gifskiOutput, `${os.tmpdir()}/frame${interaction.id}*`, quality, args.fps);
|
||||
await gifski(gifskiOutput, `${os.tmpdir()}/frame${interaction.id}*`, quality);
|
||||
// Optimize it
|
||||
await gifsicle(gifskiOutput, gifsicleOutput, args.noloop);
|
||||
|
||||
|
@ -94,10 +79,10 @@ export default {
|
|||
},
|
||||
};
|
||||
|
||||
async function gifski(output, input, quality, fps) {
|
||||
async function gifski(output, input, quality) {
|
||||
return await new Promise((resolve, reject) => {
|
||||
// Shell: true should be fine as no user input is being passed
|
||||
execFile('gifski', ['--quality', quality ? quality : 70, '--fps', fps ? fps : 20, '-o', output, input], { shell: true }, (err, stdout, stderr) => {
|
||||
execFile('gifski', ['--quality', quality ? quality : 70, '-o', output, input], { shell: true }, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
reject(stderr);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue