This commit is contained in:
= 2021-06-28 15:29:35 -04:00
parent c5ef82daa0
commit 232244068a
4 changed files with 47 additions and 0 deletions

4
.gitignore vendored
View File

@ -2,6 +2,10 @@
.vscode
.eslintrc.json
# Custom folders
gifs/*
pastas/*
# Logs
logs
*.log

10
commands/get-ext.js Normal file
View File

@ -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]);
}
}

17
commands/save-pasta.js Normal file
View File

@ -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!');
}
}

View File

@ -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;
}