Adding ability to save new gifs to the hardcode list
This commit is contained in:
parent
b64d687802
commit
ae6627488a
@ -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
16
commands/save-gif.js
Normal 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
4
gifs/deeznuts.gif
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
module.exports = {
|
||||||
|
name: 'deeznuts',
|
||||||
|
embed_url: 'https://giphy.com/embed/z0XEX0BeuPGmY'
|
||||||
|
}
|
@ -1,3 +1 @@
|
|||||||
module.exports = {
|
module.exports = {\n\tname: '${args[0]}',\n\tembed_url: '${args[1]}'\n}
|
||||||
|
|
||||||
}
|
|
1
index.js
1
index.js
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user