2020-03-29 07:45:09 +00:00
|
|
|
// Woomy version 2
|
|
|
|
// Copyright 2020 mudkipscience
|
|
|
|
|
2020-03-30 08:47:55 +00:00
|
|
|
// Check node.js version
|
2020-03-30 16:01:13 +00:00
|
|
|
if (Number(process.version.slice(1).split('.')[0]) < 12) {
|
2020-03-29 07:45:09 +00:00
|
|
|
console.log('NodeJS 12.0.0 or higher is required. Please update NodeJS on your system.')
|
|
|
|
process.exit()
|
|
|
|
}
|
|
|
|
|
2020-03-30 08:47:55 +00:00
|
|
|
// Load environment variables / config
|
2020-03-29 07:45:09 +00:00
|
|
|
const fs = require('fs')
|
2020-03-30 16:01:13 +00:00
|
|
|
const Discord = require('discord.js')
|
|
|
|
const client = new Discord.Client({ disabledEvents: ['TYPING_START'] })
|
2020-03-29 07:45:09 +00:00
|
|
|
|
|
|
|
if (fs.existsSync('./.env') === false) {
|
|
|
|
console.log('.env file not found!')
|
|
|
|
process.exit()
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fs.existsSync('./config.js') === false) {
|
|
|
|
console.log('config file not found!')
|
|
|
|
process.exit()
|
|
|
|
}
|
|
|
|
|
|
|
|
require('dotenv').config()
|
2020-03-30 16:01:13 +00:00
|
|
|
client.config = require('config')
|
2020-03-29 07:45:09 +00:00
|
|
|
|
2020-03-30 16:01:13 +00:00
|
|
|
// Command/alias cache
|
|
|
|
client.commands = new Discord.Collection()
|
|
|
|
client.aliases = new Discord.Collection()
|
2020-03-29 07:45:09 +00:00
|
|
|
|
2020-03-30 08:47:55 +00:00
|
|
|
// Initialization function
|
2020-03-29 07:45:09 +00:00
|
|
|
const init = async () => {
|
2020-03-30 08:52:08 +00:00
|
|
|
// Load modules
|
|
|
|
|
2020-03-30 16:01:13 +00:00
|
|
|
// Load events
|
2020-03-30 08:47:55 +00:00
|
|
|
fs.readdir('./events', (err, files) => {
|
2020-03-30 16:01:13 +00:00
|
|
|
if (err) {}// Prepare variableseturn err
|
2020-03-30 08:47:55 +00:00
|
|
|
files.forEach(file => {
|
|
|
|
client.on(file.substr(0, file.length - 3), require('./events/' + file))
|
2020-03-30 16:01:13 +00:00
|
|
|
})
|
|
|
|
})
|
2020-03-30 08:47:55 +00:00
|
|
|
|
2020-03-30 08:52:08 +00:00
|
|
|
// Load commands
|
|
|
|
|
2020-03-30 16:01:13 +00:00
|
|
|
// Level cache
|
|
|
|
for (let i = 0; i < client.config.permLevels.length; i++) {
|
|
|
|
const currentlevel = client.config.permLevels[i]
|
|
|
|
client.levelCache[currentlevel.name] = currentlevel.level
|
|
|
|
}
|
2020-03-30 08:47:55 +00:00
|
|
|
// Login into Discord
|
2020-03-30 16:01:13 +00:00
|
|
|
client.login(process.env.TOKEN)
|
2020-03-29 07:45:09 +00:00
|
|
|
}
|
|
|
|
|
2020-03-30 16:01:13 +00:00
|
|
|
init()
|