forked from embee/woomy
72 lines
2.3 KiB
JavaScript
72 lines
2.3 KiB
JavaScript
// Woomy version 2
|
|
// Copyright 2020 mudkipscience
|
|
|
|
// Check node.js version
|
|
if (Number(process.version.slice(1).split('.')[0]) < 12) {
|
|
console.log('NodeJS 12.0.0 or higher is required. Please update NodeJS on your system.')
|
|
process.exit()
|
|
}
|
|
|
|
// Libraries
|
|
const fs = require('fs')
|
|
const colors = require('colors')
|
|
const isDocker = require('is-docker')
|
|
const Discord = require('discord.js')
|
|
const client = new Discord.Client({ disabledEvents: ['TYPING_START'] })
|
|
|
|
client.logger = require('tracer').colorConsole({
|
|
format: [
|
|
'{{timestamp}} | {{title}} | {{file}} | {{message}}',
|
|
{
|
|
debug: `{{timestamp}} | ${'{{title}}'.magenta} | {{file}} | {{message}}`,
|
|
log: `{{timestamp}} | ${'{{title}}'.white} | {{file}} | {{message}}`,
|
|
info: `{{timestamp}} | ${'{{title}}'.cyan} | {{file}} | {{message}}`,
|
|
ready: `{{timestamp}} | ${'{{title}}'.green} | {{file}} | {{message}}`,
|
|
warn: `{{timestamp}} | ${'{{title}}'.yellow} | {{file}} | {{message}}`,
|
|
error: `{{timestamp}} | ${'{{title}}'.red} | {{file}} | {{message}}`,
|
|
fatal: `{{timestamp}} | ${'{{title}}'.red.bold} | {{file}} | {{message}}`
|
|
}
|
|
],
|
|
dateformat: 'yyyy-mm-dd"T"HH:MM:ss',
|
|
methods: ['log', 'debug', 'info', 'ready', 'warn', 'error', 'fatal'],
|
|
filters: [colors.white]
|
|
})
|
|
|
|
// Check to make sure config exists
|
|
if (fs.existsSync('./config.js') === false) {
|
|
client.logger.fatal('The config.js file is missing! Please create a config.js file.')
|
|
process.exit()
|
|
}
|
|
|
|
client.levelCache = {}
|
|
client.commands = new Discord.Collection()
|
|
client.cooldown = new Discord.Collection()
|
|
client.aliases = new Discord.Collection()
|
|
|
|
client.config = require('./config')
|
|
client.mongoose = require('./modules/mongoose')
|
|
require('./modules/functions')(client)
|
|
require('./modules/music')(client)
|
|
require('./modules/commands')(client)
|
|
require('./modules/events')(client)
|
|
|
|
for (let i = 0; i < client.config.permLevels.length; i++) {
|
|
const thisLevel = client.config.permLevels[i]
|
|
client.levelCache[thisLevel.name] = thisLevel.level
|
|
}
|
|
|
|
if (isDocker() === true) {
|
|
client.devmode = true
|
|
client.logger.warn('Running in development mode.')
|
|
} else {
|
|
client.devmode = false
|
|
}
|
|
|
|
console.log(client.mongoose)
|
|
client.mongoose.init()
|
|
|
|
if (client.devmode !== true) {
|
|
client.login(client.config.token)
|
|
} else {
|
|
client.login(client.config.token_dev)
|
|
}
|