nodbot/commands/save-gif.js

20 lines
636 B
JavaScript
Raw Normal View History

module.exports = {
name: 'save-gif',
description: 'Adds a given gif to the hardcoded list.',
execute(message, args) {
if (args.length != 2) {
message.reply('This command requires exactly two arguments, gif name and url. Please try again.');
return;
}
const fs = require('fs');
2021-06-28 03:20:21 +00:00
fs.appendFile(`./gifs/${args[0]}.js`, `module.exports = {\n\tname: '${args[0]}',\n\tembed_url: '${args[1]}'\n}`, function(err) {
if (err) throw err;
console.log('Saved file!');
2021-06-28 03:20:21 +00:00
const gif = require(`../gifs/${args[0]}.js`);
message.client.gifs.set(gif.name, gif);
});
2021-06-28 03:20:21 +00:00
message.reply('GIF saved as: ' + args[0] + '.gif!');
}
}