|
|
|
@ -1,6 +1,8 @@ |
|
|
|
|
const Discord = require('discord.js'); |
|
|
|
|
const fs = require('fs'); |
|
|
|
|
const chalk = require('chalk'); |
|
|
|
|
const ora = require('ora'); |
|
|
|
|
|
|
|
|
|
const UserData = require("../models/user"); |
|
|
|
|
|
|
|
|
|
module.exports = { |
|
|
|
@ -22,19 +24,22 @@ module.exports = { |
|
|
|
|
const tu = await UserData.findOne({uid: message.author.id}); |
|
|
|
|
if (!tu || !tu.developer) {return message.channel.send("You must be a Natsuki developer in order to do this!");} |
|
|
|
|
|
|
|
|
|
var commands = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); |
|
|
|
|
let commands = fs.readdirSync('./commands').filter(file => file.endsWith('.js')); |
|
|
|
|
console.log(`\n${chalk.yellow('[WARN]')} >> ${chalk.gray('Reload:')} ${chalk.white('All commands and events are being reloaded!')}`); |
|
|
|
|
console.log(`${chalk.gray('[INFO]')} >> ${chalk.hex('ff4fd0')(`Developer ${message.author.username} initiated the system refresh`)}\n`); |
|
|
|
|
|
|
|
|
|
let cmdspinner = ora(chalk.blue('Loading Commands')).start(); |
|
|
|
|
['commands', 'aliases'].forEach(x => client[x] = new Discord.Collection()); |
|
|
|
|
for (let commandf of commands) { |
|
|
|
|
if (Object.keys(require.cache).includes(require.resolve(`./${commandf}`))) {delete require.cache[require.resolve(`./${commandf}`)];} |
|
|
|
|
var command = require(`./${commandf}`); |
|
|
|
|
let command = require(`./${commandf}`); |
|
|
|
|
client.commands.set(command.name, command); |
|
|
|
|
if (command.aliases) {command.aliases.forEach(a => client.aliases.set(a, command.name));} |
|
|
|
|
} |
|
|
|
|
cmdspinner.stop(); cmdspinner.clear(); |
|
|
|
|
console.log(`${chalk.gray('[LOG]')} >> ${chalk.blue('Loaded all Commands')}`); |
|
|
|
|
|
|
|
|
|
let eventspinner = ora(chalk.blue('Loading Events')).start(); |
|
|
|
|
let eventFilter = fs.readdirSync('./events/').filter(x => x.endsWith('.js')); |
|
|
|
|
for (let file of eventFilter) { |
|
|
|
|
let evtName = file.split('.')[0]; |
|
|
|
@ -43,16 +48,19 @@ module.exports = { |
|
|
|
|
client.removeAllListeners(evtName); |
|
|
|
|
client.on(evtName, evt.bind(null, client)); |
|
|
|
|
} |
|
|
|
|
eventspinner.stop(); eventspinner.clear(); |
|
|
|
|
console.log(`${chalk.gray('[LOG]')} >> ${chalk.blue('Loaded all Events')}`); |
|
|
|
|
|
|
|
|
|
var responses = fs.readdirSync('./responses').filter(file => file.endsWith('.js')); |
|
|
|
|
let rspspinner = ora(chalk.blue('Loading Commands')).start(); |
|
|
|
|
let responses = fs.readdirSync('./responses').filter(file => file.endsWith('.js')); |
|
|
|
|
client.responses.triggers = []; |
|
|
|
|
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}`); |
|
|
|
|
let response = require(`../responses/${responsef}`); |
|
|
|
|
client.responses.triggers.push([response.name, response.condition]); |
|
|
|
|
client.responses.commands.set(response.name, response); |
|
|
|
|
} |
|
|
|
|
rspspinner.stop(); rspspinner.clear(); |
|
|
|
|
console.log(`${chalk.gray('[LOG]')} >> ${chalk.blue('Loaded all Responses')}`); |
|
|
|
|
|
|
|
|
|
console.log(`\n${chalk.gray('[INFO]')} >> ${chalk.hex('ff4fd0')(`Client refresh successful`)}\n`); |
|
|
|
|