parent
daf66bf496
commit
ad047ffa19
@ -1,35 +1,32 @@ |
||||
const Discord = require('discord.js'); |
||||
const fs = require('fs'); |
||||
const chalk = require('chalk'); |
||||
const ora = require('ora'); |
||||
const gs = require('gradient-string'); |
||||
|
||||
module.exports = client => { |
||||
let commands = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); |
||||
let dirSet = new Map(); |
||||
fs.readdirSync('./commands').filter(file => !file.includes('.')).forEach(dir => fs.readdirSync(`./commands/${dir}`).filter(file => file.endsWith('.js')).forEach(x => {commands.push(x); dirSet.set(x, dir)})); |
||||
let iters = ['command', 'event', 'response']; |
||||
|
||||
//console.log('');
|
||||
//let cora = ora(`${chalk.white("Loading commands into client.")} ${chalk.blue("[")}${chalk.blueBright("0")}${chalk.blue("/")}${chalk.blueBright(`${commands.length}`)}${chalk.blue("]")}`).start();
|
||||
//let num = 0;
|
||||
commands.sort(); |
||||
console.log(`\n${chalk.gray('[BOOT]')} >> ${chalk.blue('Getting Commands...')}\n`); |
||||
for (let commandf of commands) { |
||||
//num++;
|
||||
//cora.text = `${chalk.white("Loading commands into client.")} ${chalk.blue("[")}${chalk.blueBright(`${num}`)}${chalk.blue("/")}${chalk.blueBright(`${commands.length}`)}${chalk.blue("]")}`;
|
||||
if (Object.keys(require.cache).includes(require.resolve(`../commands/${dirSet.has(commandf) ? `${dirSet.get(commandf)}/`: ''}${commandf}`))) {delete require.cache[require.resolve(`../commands/${dirSet.has(commandf) ? `${dirSet.get(commandf)}/`: ''}${commandf}`)];} |
||||
let command = require(`../commands/${dirSet.has(commandf) ? `${dirSet.get(commandf)}/`: ''}${commandf}`); |
||||
const addCommand = (command) => { |
||||
client.commands.set(command.name, command); |
||||
if (command.aliases) {command.aliases.forEach(a => client.aliases.set(a, command.name));} |
||||
console.log(`${chalk.gray('[LOAD]')} >> ${chalk.blueBright('Loaded Command')} ${chalk.white(command.name)} ${chalk.blueBright('with')} ${chalk.white(command.aliases && command.aliases.length ? command.aliases.length : 0)} ${chalk.blueBright('aliases')}`); |
||||
}; |
||||
if (command.commands) {command.commands.forEach(cmd => addCommand(cmd));} |
||||
else {addCommand(command);} |
||||
} |
||||
//cora.stop(); cora.clear();
|
||||
//console.log(`${chalk.gray('[BOOT]')} >> ${chalk.blue('Getting Commands...')}\n`);
|
||||
Array.from(client.commands.values()).forEach(command => { |
||||
//console.log(`${chalk.gray('[LOAD]')} >> ${chalk.blueBright('Loaded Command')} ${chalk.white(command.name)} ${chalk.blueBright('with')} ${chalk.white(command.aliases && command.aliases.length ? command.aliases.length : 0)} ${chalk.blueBright('aliases')}`);
|
||||
module.exports = async client => { |
||||
return new Promise(resolve => { |
||||
let commands = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); |
||||
let dirSet = new Map(); |
||||
fs.readdirSync('./commands').filter(file => !file.includes('.')).forEach(dir => fs.readdirSync(`./commands/${dir}`).filter(file => file.endsWith('.js')).forEach(x => {commands.push(x); dirSet.set(x, dir)})); |
||||
|
||||
commands.sort(); |
||||
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 Commands...')}\n`); |
||||
for (let commandf of commands) { |
||||
if (Object.keys(require.cache).includes(require.resolve(`../commands/${dirSet.has(commandf) ? `${dirSet.get(commandf)}/`: ''}${commandf}`))) {delete require.cache[require.resolve(`../commands/${dirSet.has(commandf) ? `${dirSet.get(commandf)}/`: ''}${commandf}`)];} |
||||
let command = require(`../commands/${dirSet.has(commandf) ? `${dirSet.get(commandf)}/`: ''}${commandf}`); |
||||
const addCommand = (command) => { |
||||
client.commands.set(command.name, command); |
||||
if (command.aliases) {command.aliases.forEach(a => client.aliases.set(a, command.name));} |
||||
log(`${chalk.gray('[LOAD]')} >> ${chalk.blueBright('Loaded Command')} ${chalk.white(command.name)} ${chalk.blueBright('with')} ${chalk.white(command.aliases && command.aliases.length ? command.aliases.length : 0)} ${chalk.blueBright('aliases')}`); |
||||
}; |
||||
if (command.commands) {command.commands.forEach(cmd => addCommand(cmd));} |
||||
else {addCommand(command);} |
||||
} |
||||
log(`\n${chalk.gray('[BOOT]')} >> ${chalk.blue('Loaded all Commands')}`); |
||||
client.misc.cache.spin.success('command', {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))[0]}); |
||||
resolve(0); |
||||
}); |
||||
console.log(`\n${chalk.gray('[BOOT]')} >> ${chalk.blue('Loaded all Commands')}`); |
||||
}; |
@ -1,17 +1,25 @@ |
||||
const fs = require('fs'); |
||||
const moment = require('moment'); |
||||
const chalk = require('chalk'); |
||||
const gs = require('gradient-string'); |
||||
|
||||
module.exports = client => { |
||||
let eventFilter = fs.readdirSync('./events/').filter(x => x.endsWith('.js')); |
||||
console.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)); |
||||
console.log(`${chalk.gray('[LOAD]')} >> ${chalk.blueBright('Loaded Event')} ${chalk.white(evtName)}`); |
||||
} |
||||
console.log(`\n${chalk.gray('[BOOT]')} >> ${chalk.blue('Loaded all Events')}`); |
||||
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')}`); |
||||
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]}); |
||||
resolve(0); |
||||
}); |
||||
}; |
@ -1,16 +1,24 @@ |
||||
const Discord = require('discord.js'); |
||||
const fs = require('fs'); |
||||
const chalk = require('chalk'); |
||||
const gs = require('gradient-string'); |
||||
|
||||
let iters = ['command', 'event', 'response']; |
||||
|
||||
module.exports = client => { |
||||
var responses = fs.readdirSync('./responses').filter(file => file.endsWith('.js')); |
||||
console.log(`\n${chalk.gray('[BOOT]')} >> ${chalk.blue('Getting Responses...')}\n`); |
||||
for (let responsef of responses) { |
||||
if (Object.keys(require.cache).includes(require.resolve(`../responses/${responsef}`))) {delete require.cache[require.resolve(`../responses/${responsef}`)];} |
||||
var response = require(`../responses/${responsef}`); |
||||
client.responses.triggers.push([response.name, response.condition]); |
||||
client.responses.commands.set(response.name, response); |
||||
console.log(`${chalk.gray('[LOAD]')} >> ${chalk.blueBright('Loaded Response')} ${chalk.white(response.name)}`); |
||||
} |
||||
console.log(`\n${chalk.gray('[BOOT]')} >> ${chalk.blue('Loaded all Responses')}`); |
||||
return new Promise(resolve => { |
||||
var responses = fs.readdirSync('./responses').filter(file => file.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 Responses...')}\n`); |
||||
for (let responsef of responses) { |
||||
if (Object.keys(require.cache).includes(require.resolve(`../responses/${responsef}`))) {delete require.cache[require.resolve(`../responses/${responsef}`)];} |
||||
var response = require(`../responses/${responsef}`); |
||||
client.responses.triggers.push([response.name, response.condition]); |
||||
client.responses.commands.set(response.name, response); |
||||
log(`${chalk.gray('[LOAD]')} >> ${chalk.blueBright('Loaded Response')} ${chalk.white(response.name)}`); |
||||
} |
||||
log(`\n${chalk.gray('[BOOT]')} >> ${chalk.blue('Loaded all Responses')}`); |
||||
client.misc.cache.spin.success('response', {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))[2]}); |
||||
resolve(0); |
||||
}); |
||||
}; |
Loading…
Reference in new issue