Adding ability to save new gifs to the hardcode list

This commit is contained in:
= 2021-06-27 22:19:16 -04:00
parent b64d687802
commit ae6627488a
5 changed files with 24 additions and 4 deletions

View File

@ -2,6 +2,7 @@ module.exports = {
name: "reload-gifs", name: "reload-gifs",
description: "Refresh the hardcoded gif library.", description: "Refresh the hardcoded gif library.",
execute(message, args) { execute(message, args) {
getGifFiles(); const index = require('../index.js');
index.getGifFiles();
} }
} }

16
commands/save-gif.js Normal file
View File

@ -0,0 +1,16 @@
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');
fs.appendFile(`./gifs/${args[0]}.gif`, `module.exports = {\n\tname: '${args[0]}',\n\tembed_url: '${args[1]}'\n}`, function(err) {
if (err) throw err;
console.log('Saved file!');
});
}
}

4
gifs/deeznuts.gif Normal file
View File

@ -0,0 +1,4 @@
module.exports = {
name: 'deeznuts',
embed_url: 'https://giphy.com/embed/z0XEX0BeuPGmY'
}

View File

@ -1,3 +1 @@
module.exports = { module.exports = {\n\tname: '${args[0]}',\n\tembed_url: '${args[1]}'\n}
}

View File

@ -61,6 +61,7 @@ client.on('message', message => {
const args = message.content.slice(prefix.length).trim().split(/ +/); const args = message.content.slice(prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase(); const command = args.shift().toLowerCase();
if (debug) console.log(args);
if (!client.commands.has(command)) return; if (!client.commands.has(command)) return;
try { try {