parent
8a4a7997bc
commit
22c3d6791f
@ -0,0 +1,23 @@ |
|||||||
|
const chalk = require('chalk'); |
||||||
|
const readline = require('readline'); |
||||||
|
|
||||||
|
module.exports = (client) => { |
||||||
|
console.log(`\n${chalk.green('[CONS]')} >> ${chalk.magentaBright(`Type `)}${chalk.white(`"help"`)} ${chalk.magentaBright("for a list of console commands.")}`); |
||||||
|
|
||||||
|
client.misc.rl.on("line", async (line) => { |
||||||
|
if (!line.length) {return;} |
||||||
|
|
||||||
|
readline.moveCursor(process.stdout, 0, -1); |
||||||
|
readline.clearLine(process.stdout, 1); |
||||||
|
|
||||||
|
console.log(""); |
||||||
|
|
||||||
|
const text = line; |
||||||
|
const args = text.split(/\s+/gm); |
||||||
|
const cmd = args.shift().toLowerCase(); |
||||||
|
|
||||||
|
const command = client.executables.get(cmd); |
||||||
|
if (!command) {return console.log(`${chalk.yellow('[CONS]')} >> ${chalk.yellowBright(`Command `)}${chalk.white(`"${cmd}"`)} ${chalk.yellowBright("doesn't exist.")}`);} |
||||||
|
await command.execute(client, text, args, cmd); |
||||||
|
}); |
||||||
|
}; |
@ -0,0 +1,28 @@ |
|||||||
|
const chalk = require('chalk'); |
||||||
|
|
||||||
|
const {Tag} = require('../util/tag'); |
||||||
|
const {TagFilter} = require('../util/tagfilter'); |
||||||
|
|
||||||
|
module.exports = { |
||||||
|
name: "help", |
||||||
|
description: "Displays a list of usable commands.", |
||||||
|
help: "Displays a list of usable commands.", |
||||||
|
usage: "help [command]", |
||||||
|
args: ['list'], |
||||||
|
execute(client, text, args, cmd) { |
||||||
|
const options = args.length ? new TagFilter([new Tag(['l', 'list'], 'list', 'toggle')]).test(args.join(" ")) : {}; |
||||||
|
|
||||||
|
const sp = ' >> '; |
||||||
|
|
||||||
|
if (args[0] || options.cmd) { |
||||||
|
if (!client.executables.has(args[0].toLowerCase())) {return console.log(`${chalk.yellow('[CONS]')} >> ${chalk.yellowBright(`Command `)}${chalk.white(`"${ex.name}"`)} ${chalk.yellowBright("doesn't exist.")}`);} |
||||||
|
const ex = client.executables.get(args[0]); |
||||||
|
return console.log(`${chalk.gray('[CONS]')} >> [${chalk.blue(`HELP`)}] -> ${chalk.blueBright(ex.name)}\n\n${sp}<${chalk.hex('#b57124')(ex.name)}> - ${chalk.greenBright(ex.usage)}\n${sp}${ex.description} > ${chalk.gray(ex.args.length ? `-${ex.args.join(', -')}` : 'No args')}`); |
||||||
|
} else { |
||||||
|
let s = ''; |
||||||
|
s += `${chalk.gray('[CONS]')} >> [${chalk.blue(`HELP`)}] -> ${chalk.blueBright(`Available commands:`)}`; |
||||||
|
Array.from(client.executables.values()).sort((a, b) => a.name > b.name ? 1 : -1).forEach(e => s += `\n\n${sp}<${chalk.hex('#b57124')(e.name)}> - ${chalk.greenBright(e.usage)}\n${sp}${e.description} > ${chalk.gray(e.args.length ? `-${e.args.join(', -')}` : 'No args')}`); |
||||||
|
return console.log(s.slice(0, s.length - 2)); |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,68 @@ |
|||||||
|
const chalk = require('chalk'); |
||||||
|
const fs = require('fs'); |
||||||
|
const ora = require('ora'); |
||||||
|
const Discord = require('discord.js'); |
||||||
|
|
||||||
|
module.exports = { |
||||||
|
name: "reload", |
||||||
|
description: "Reloads the client without restarting it.", |
||||||
|
help: "Reloads client. Use -cmd, -event, -resp, or -exec flags to fine-tune the results.", |
||||||
|
usage: "help [command]", |
||||||
|
args: ['cmd', 'event', 'resp', 'exec'], |
||||||
|
execute(client, text, args, cmd) { |
||||||
|
let timer = new Date().getTime(); |
||||||
|
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)})); |
||||||
|
console.log(`${chalk.gray('[CONS]')} >> [${chalk.blue(`RELOAD`)}] -> Clean (no-argument) reload:`); |
||||||
|
console.log(`${chalk.yellow('[WARN]')} >> ${chalk.gray('Reload:')} ${chalk.white('All commands and events are being reloaded!')}\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(`../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}`); |
||||||
|
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('[PROC]')} >> ${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]; |
||||||
|
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)); |
||||||
|
} |
||||||
|
eventspinner.stop(); eventspinner.clear(); |
||||||
|
console.log(`${chalk.gray('[PROC]')} >> ${chalk.blue('Loaded all Events')}`); |
||||||
|
|
||||||
|
let rspspinner = ora(chalk.blue('Loading Responses')).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}`)];} |
||||||
|
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('[PROC]')} >> ${chalk.blue('Loaded all Responses')}`); |
||||||
|
|
||||||
|
let exespinner = ora(chalk.blue('Loading Console Commands')).start(); |
||||||
|
let executables = fs.readdirSync('./executables').filter(file => file.endsWith('.js')); |
||||||
|
for (let execf of executables) { |
||||||
|
if (Object.keys(require.cache).includes(require.resolve(`../executables/${execf}`))) {delete require.cache[require.resolve(`../executables/${execf}`)];} |
||||||
|
var exec = require(`../executables/${execf}`); |
||||||
|
client.executables.set(exec.name, exec); |
||||||
|
} |
||||||
|
exespinner.stop(); exespinner.clear(); |
||||||
|
console.log(`${chalk.gray('[PROC]')} >> ${chalk.blue('Loaded all Console Commands')}`); |
||||||
|
|
||||||
|
console.log(`\n${chalk.gray('[INFO]')} >> Client refresh successful.`); |
||||||
|
return console.log(`${chalk.gray('[CONS]')} >> ${chalk.greenBright(`Done!`)} Reloaded ${chalk.blue(commands.length)} ${chalk.blueBright(`commands`)}, ${chalk.blue(eventFilter.length)} ${chalk.blueBright(`events`)}, and ${chalk.blue(responses.length)} ${chalk.blueBright(`responses`)} in ${chalk.green(`${new Date().getTime() - timer}ms`)}.`); |
||||||
|
} |
||||||
|
}; |
@ -0,0 +1,14 @@ |
|||||||
|
const fs = require('fs'); |
||||||
|
const chalk = require('chalk'); |
||||||
|
|
||||||
|
module.exports = client => { |
||||||
|
var executables = fs.readdirSync('./executables').filter(file => file.endsWith('.js')); |
||||||
|
console.log(`\n${chalk.gray('[BOOT]')} >> ${chalk.blue('Getting Console Commands...')}\n`); |
||||||
|
for (let execf of executables) { |
||||||
|
if (Object.keys(require.cache).includes(require.resolve(`../executables/${execf}`))) {delete require.cache[require.resolve(`../executables/${execf}`)];} |
||||||
|
var exec = require(`../executables/${execf}`); |
||||||
|
client.executables.set(exec.name, exec); |
||||||
|
console.log(`${chalk.gray('[LOAD]')} >> ${chalk.blueBright('Loaded CMD')} ${chalk.white(exec.name)}`); |
||||||
|
} |
||||||
|
console.log(`\n${chalk.gray('[BOOT]')} >> ${chalk.blue('Loaded all Executables.')}`); |
||||||
|
}; |
Loading…
Reference in new issue