You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Natsuki/handle/event.js

25 lines
1.4 KiB

const fs = require('fs');
const moment = require('moment');
const chalk = require('chalk');
3 years ago
const gs = require('gradient-string');
3 years ago
let iters = ['command', 'event', 'response'];
module.exports = async client => {
return new Promise(resolve => {
let eventFilter = fs.readdirSync('./events/').filter(x => x.endsWith('.js'));
const log = client.misc.config.spinners ? (i) => client.misc.cache.spinLog.push(i) : (i) => console.log(i);
log(`\n${chalk.gray('[BOOT]')} >> ${chalk.blue('Getting Events...')}\n`);
for (let file of eventFilter) {
let evtName = file.split('.')[0];
if (Object.keys(require.cache).includes(require.resolve('../events/' + file))) {delete require.cache[require.resolve('../events/' + file)];}
let evt = require('../events/' + file);
client.removeAllListeners(evtName);
client.on(evtName, evt.bind(null, client));
log(`${chalk.gray('[LOAD]')} >> ${chalk.blueBright('Loaded Event')} ${chalk.white(evtName)}`);
}
log(`\n${chalk.gray('[BOOT]')} >> ${chalk.blue('Loaded all Events')}`);
3 years ago
if (client.misc.config.spinners) {client.misc.cache.spin.success('event', {text: iters.map(i => `Loaded ${i.slice(0, 1).toUpperCase()}${i.slice(1)}s`).map(i => client.misc.config.gradients ? gs.instagram(i) : chalk.blue(i))[1]});}
3 years ago
resolve(0);
});
};