nodbot/commands/savegif.js
2021-07-01 18:12:21 -04:00

19 lines
612 B
JavaScript

module.exports = {
name: 'savegif',
description: 'Adds a given gif to the hardcoded list.',
execute(message, file) {
const tempArray = file.name.split(' ');
const embedURL = tempArray.shift();
const gifName = tempArray.join(' ');
const fs = require('fs');
fs.appendFile(`./gifs/${gifName}.js`, `module.exports = {\n\tname: '${gifName}',\n\tembed_url: '${embedURL}'\n}`, function(err) {
if (err) throw err;
console.log('Saved file!');
const gif = require(`../gifs/${gifName}.js`);
message.client.gifs.set(gif.name, gif);
});
message.reply('GIF saved as: ' + gifName + '.gif!');
}
}