forked from embee/woomy
Added a dogfact and carfact command, while also improving index.js so it actually gives reasons for it shitting itself.
This commit is contained in:
parent
cfc3f40dcb
commit
8b2c262c37
3 changed files with 127 additions and 5 deletions
86
index.js
86
index.js
|
@ -6,11 +6,40 @@ const chalk = require('chalk');
|
|||
const DBL = require("dblapi.js");
|
||||
const client = new Discord.Client();
|
||||
|
||||
try {
|
||||
client.config = require('./config');
|
||||
} catch (err) {
|
||||
console.log('Unable to load config.js \n', err);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
try{
|
||||
client.version = require('./version.json');
|
||||
} catch (err) {
|
||||
console.log('Unable to load the version file. \n', err);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
try{
|
||||
client.logger = require('./src/modules/Logger');
|
||||
} catch (err) {
|
||||
console.log('Unable to load the logger. \n', err);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
try{
|
||||
require("./src/modules/functions")(client);
|
||||
} catch (err) {
|
||||
console.log('Unable to load the functions. \n', err);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
try{
|
||||
client.logger.setClient(client);
|
||||
} catch (err) {
|
||||
console.log('Unable to initiate the logger. \n', err);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if(process.env['USER'] != 'container') {
|
||||
client.devmode = true;
|
||||
|
@ -19,12 +48,37 @@ if(process.env['USER'] != 'container') {
|
|||
const dblapi = new DBL(client.config.dblkey, client);
|
||||
}
|
||||
|
||||
try{
|
||||
client.commands = new Enmap();
|
||||
client.aliases = new Enmap();
|
||||
client.settings = new Enmap({name: 'settings'});
|
||||
client.blacklist = new Enmap({name: 'blacklist'});
|
||||
} catch (err) {
|
||||
console.log('Failed to create the commands database. \n', err);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
try{
|
||||
client.aliases = new Enmap();
|
||||
} catch (err) {
|
||||
console.log('Unable to create the aliases database. \n', err);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
try{
|
||||
client.settings = new Enmap({name: 'settings'});
|
||||
} catch (err) {
|
||||
console.log('Unable to make the settings database. \n', err);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
try{
|
||||
client.blacklist = new Enmap({name: 'blacklist'});
|
||||
} catch (err) {
|
||||
console.log('Unable to create the blacklist database. \n', err);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try{
|
||||
const init = async () => {
|
||||
try{
|
||||
const cmdFiles = await readdir("./src/commands/");
|
||||
client.logger.info(`Loading ${cmdFiles.length} commands.`);
|
||||
cmdFiles.forEach(file => {
|
||||
|
@ -36,7 +90,12 @@ const init = async () => {
|
|||
console.log(response);
|
||||
};
|
||||
});
|
||||
} catch (err) {
|
||||
console.log('Unable to load Woomys commands. \n', err);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try{
|
||||
const evtFiles = await readdir("./src/events/");
|
||||
client.logger.info(`Loading ${evtFiles.length} events.`);
|
||||
evtFiles.forEach(file => {
|
||||
|
@ -47,18 +106,35 @@ const init = async () => {
|
|||
const event = require(`./src/events/${file}`);
|
||||
client.on(eventName, event.bind(null, client));
|
||||
});
|
||||
} catch (err) {
|
||||
console.log('Unable to load Woomy events. \n', err);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
try{
|
||||
client.levelCache = {};
|
||||
for (let i = 0; i < client.config.permLevels.length; i++) {
|
||||
const thisLevel = client.config.permLevels[i];
|
||||
client.levelCache[thisLevel.name] = thisLevel.level;
|
||||
};
|
||||
} catch (err) {
|
||||
console.log('Unable to enable the levelCache. \n', err);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
try{
|
||||
if(client.devmode === true) {
|
||||
client.login(client.config.devtoken);
|
||||
} else {
|
||||
client.login(client.config.token);
|
||||
};
|
||||
} catch (err) {
|
||||
console.log('Unable to login to Discord. \n', err);
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
init();
|
||||
init();
|
||||
} catch (err) {
|
||||
console.log('Failed to initiate Woomy. \n', err);
|
||||
process.exit(1);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue