begin args integration

master
Kit Kasune 3 years ago
parent c3e907725d
commit bb24727716
  1. 31
      bot.js
  2. 4
      package.json

@ -8,6 +8,8 @@ const readline = require('readline');
const {SlashCommand} = require('./util/slash'); const {SlashCommand} = require('./util/slash');
const {SlashManager} = require('./util/slashmanager'); const {SlashManager} = require('./util/slashmanager');
const {SlashCommandBuilder} = require('@discordjs/builders'); const {SlashCommandBuilder} = require('@discordjs/builders');
const {Tag} = require('./util/tag');
const {TagFilter} = require('./util/tagfilter');
const flags = Discord.Intents.FLAGS; const flags = Discord.Intents.FLAGS;
let fl = []; Object.keys(flags).forEach(flag => fl.push(flags[flag])); let fl = []; Object.keys(flags).forEach(flag => fl.push(flags[flag]));
@ -45,7 +47,14 @@ client.misc = {
}, },
loggers: {}, loggers: {},
rl: readline.createInterface({input: process.stdin, output: process.stdout}), rl: readline.createInterface({input: process.stdin, output: process.stdout}),
cooldown: new Discord.Collection() cooldown: new Discord.Collection(),
config: {
nocli: false,
dev: false,
logs: 'normal',
lightstartup: false,
ignorecmds: []
}
}; };
//const config = require('./config.js'); //const config = require('./config.js');
@ -54,6 +63,23 @@ const auth = require('./auth.json');
//client.config = config; //client.config = config;
async function init() { async function init() {
const cliargs = new TagFilter([
new Tag(['cli', 'c', 'nc', 'nocli'], 'nocli', 'toggle'),
new Tag(['dev', 'd', 'development', 'test'], 'dev', 'toggle'),
new Tag(['logs', 'l', 'loglevel', 'll'], 'logs', 'append'),
new Tag(['lightstart', 'lightstartup', 'ls'], 'lightstartup', 'toggle'),
new Tag(['i', 'ignore', 'icmd', 'ignorecmd'], 'ignorecmds', 'listAppend')
]).test(process.argv.slice(2).join(" "));
if (Object.keys(cliargs).length) {
console.log(`${chalk.gray('[ARGS]')} >> ${chalk.gray.bold("Arguments detected.\n")}`);
Object.keys(cliargs).forEach(arg => {
client.misc.config[arg] = cliargs[arg];
console.log(`${chalk.gray('[ARGS]')} >> ${chalk.gray.bold(arg)}${chalk.gray(':')} ${chalk.blue(cliargs[arg])}`);
});
console.log('');
}
let cloginsp = ora(chalk.magentaBright('Connecting Discord client...')).start(); let cloginsp = ora(chalk.magentaBright('Connecting Discord client...')).start();
let pclc = new Date().getTime(); let pclc = new Date().getTime();
await client.login(auth.token); await client.login(auth.token);
@ -89,7 +115,8 @@ async function init() {
['commands', 'aliases', 'executables'].forEach(x => client[x] = new Discord.Collection()); ['commands', 'aliases', 'executables'].forEach(x => client[x] = new Discord.Collection());
client.responses = {triggers: [], commands: new Discord.Collection()}; client.responses = {triggers: [], commands: new Discord.Collection()};
['command', 'event', 'response', 'console'].forEach(x => require(`./handle/${x}`)(client)); ['command', 'event', 'response'].forEach(x => require(`./handle/${x}`)(client));
if (!client.misc.config.nocli) {require('./handle/console')(client);}
client.developers = ["330547934951112705", "673477059904929802"]; client.developers = ["330547934951112705", "673477059904929802"];
client.utils = {}; client.utils = {};

@ -27,6 +27,8 @@
"node": ">=16.0.0" "node": ">=16.0.0"
}, },
"scripts": { "scripts": {
"start": "run" "start": "node bot.js",
"swin": "run",
"dev": "node bot.js -dev"
} }
} }

Loading…
Cancel
Save