diff --git a/.gitignore b/.gitignore index dddcac2..cdc3e4e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,10 @@ .vscode .eslintrc.json +# Custom folders +gifs/* +pastas/* + # Logs logs *.log diff --git a/commands/get-ext.js b/commands/get-ext.js new file mode 100644 index 0000000..34db506 --- /dev/null +++ b/commands/get-ext.js @@ -0,0 +1,10 @@ +module.exports = { + name: "get-ext", + description: "Test function to capture the extension from the content of a message.", + execute(message, args) { + const finalWord = args.pop(); + const file = finalWord.split('.'); + console.log(file); + message.reply('The extension is: ' + file[1] + '\nThe filename is: ' + file[0]); + } +} \ No newline at end of file diff --git a/commands/save-pasta.js b/commands/save-pasta.js new file mode 100644 index 0000000..31aa252 --- /dev/null +++ b/commands/save-pasta.js @@ -0,0 +1,17 @@ +module.exports = { + name: 'save-pasta', + description: 'Adds a given copypasta to the hardcoded list.', + execute(message, args) { + const fs = require('fs'); + const filename = args.shift(); + const pastaText = args.join(' '); + fs.appendFile(`./pasta/${filename}.js`, `module.exports = {\n\tname: '${filename}',\n\tcontent: '${pastaText}'\n}`, function(err) { + if (err) throw err; + console.log('Saved file!'); + const pasta = require(`../pasta/${filename}.js`); + message.client.pastas.set(pasta.name, pasta); + }); + + message.reply('GIF saved as: ' + args[0] + '.gif!'); + } +} \ No newline at end of file diff --git a/functions.js b/functions.js index 53576dc..b886733 100644 --- a/functions.js +++ b/functions.js @@ -2,6 +2,7 @@ const Discord = require('discord.js'); const fs = require('fs'); const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); const gifFiles = fs.readdirSync('./gifs').filter(file => file.endsWith('.js')); +const pastaFiles = fs.readdirSync('./pastas').filter(file => file.endsWith('.js')); const debug = true; module.exports = { @@ -21,6 +22,19 @@ module.exports = { } if (debug) console.log(client.gifs); }, + getPastaFiles(client) { + client.pasta = new Discord.Collection(); + for (const file of pastaFiles) { + const pasta = require(`./pasta/${file}`); + client.pastas.set(pasta.name, pasta); + } + if (debug) console.log(client.pastas); + }, + getExtension(args) { + const finalWord = args.pop(); + const file = finalWord.split('.'); + return file[1]; + }, extCheck(content) { const lastFour = content.slice(-4); switch (lastFour) { @@ -28,6 +42,8 @@ module.exports = { return 'gif'; case '.jpg': return 'jpg'; + case '.pst': + return 'pst'; default: return false; }