2021-06-28 03:20:21 +00:00
|
|
|
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'));
|
2021-06-28 19:29:35 +00:00
|
|
|
const pastaFiles = fs.readdirSync('./pastas').filter(file => file.endsWith('.js'));
|
2021-06-28 03:20:21 +00:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
getCommandFiles(client) {
|
|
|
|
client.commands = new Discord.Collection();
|
|
|
|
for (const file of commandFiles) {
|
|
|
|
const command = require(`./commands/${file}`);
|
|
|
|
client.commands.set(command.name, command);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getGifFiles(client) {
|
|
|
|
client.gifs = new Discord.Collection();
|
|
|
|
for (const file of gifFiles) {
|
|
|
|
const gif = require(`./gifs/${file}`);
|
|
|
|
client.gifs.set(gif.name, gif);
|
|
|
|
}
|
|
|
|
},
|
2021-06-28 19:29:35 +00:00
|
|
|
getPastaFiles(client) {
|
2021-06-28 22:11:32 +00:00
|
|
|
client.pastas = new Discord.Collection();
|
2021-06-28 19:29:35 +00:00
|
|
|
for (const file of pastaFiles) {
|
2021-06-28 22:11:32 +00:00
|
|
|
const pasta = require(`./pastas/${file}`);
|
2021-06-28 19:29:35 +00:00
|
|
|
client.pastas.set(pasta.name, pasta);
|
|
|
|
}
|
|
|
|
},
|
2021-06-30 22:59:24 +00:00
|
|
|
getFileInfo(content) {
|
2021-07-01 22:12:21 +00:00
|
|
|
// const finalPeriod = content.search(/\.(?:.(?!\\))+$/gim);
|
|
|
|
const finalPeriod = content.lastIndexOf('.');
|
2021-06-30 22:59:24 +00:00
|
|
|
if (finalPeriod < 0) return false;
|
|
|
|
const extension = content.slice(finalPeriod).replace('.','').toLowerCase();
|
|
|
|
const filename = content.slice(0,finalPeriod).toLowerCase();
|
|
|
|
const file = {
|
|
|
|
'name': filename,
|
|
|
|
'extension': extension
|
|
|
|
};
|
2021-06-28 22:11:32 +00:00
|
|
|
return file;
|
2021-06-28 19:29:35 +00:00
|
|
|
},
|
2021-06-30 22:59:24 +00:00
|
|
|
extIsValid(extension) {
|
2021-07-01 22:12:21 +00:00
|
|
|
const extensions = require('./config.json').validExtensions;
|
|
|
|
return extensions.includes(extension);
|
2021-07-06 21:37:29 +00:00
|
|
|
},
|
|
|
|
cleanInput(input) {
|
|
|
|
return input.replace(/'/g, '\\\'').replace(/\n/g, '\\n');
|
|
|
|
},
|
|
|
|
createGifEmbed(data) {
|
|
|
|
return new Discord.MessageEmbed()
|
|
|
|
.setAuthor('NodBot v2 - GIF')
|
|
|
|
.setTitle(data.name)
|
|
|
|
.setImage(data.embed_url)
|
|
|
|
.setTimestamp()
|
|
|
|
.setFooter(data.requestor);
|
2021-06-28 03:20:21 +00:00
|
|
|
}
|
|
|
|
}
|