const Discord = require('discord.js');
const bot = new Discord.Client({ partials: ['MESSAGE', 'CHANNEL', 'REACTION'] });
const fs = require('fs');
let commands= [];
const cfg = require('./cfg.json');
const { MessageEmbed } = require('discord.js');
module.exports.bot = bot
fs.readdir("./commands",(err, files) => {
if(err) throw err;
files.map(f => require(`./commands/${f}`));
commands = files.filter(f => f.endsWith(".js") && !f.startsWith("i_")).map(f => require(`./commands/${f}`))
});
bot.on("message",async message => {
if(message.author.bot) return;
if(message.mentions.users.first() == bot.user) {
}
let args = message.content.split(" ");
let member = message.mentions.members.first() || message.member;
let cmd = commands.find(c => c.properities.name.includes(args[0].slice(cfg.prefix.length)));
if(cmd) cmd.run(bot,message,member,args.slice(1),commands);
});
bot.login(cfg.token);