Add comments, basic initialization function to the core
This commit is contained in:
parent
f6f0ad7a94
commit
9a71454ec5
1 changed files with 13 additions and 1 deletions
14
index.js
14
index.js
|
@ -1,11 +1,13 @@
|
||||||
// Woomy version 2
|
// Woomy version 2
|
||||||
// Copyright 2020 mudkipscience
|
// Copyright 2020 mudkipscience
|
||||||
|
|
||||||
|
// Check node.js version
|
||||||
if (Number(process.version.slice(1).split('.')[0]) < 13) {
|
if (Number(process.version.slice(1).split('.')[0]) < 13) {
|
||||||
console.log('NodeJS 12.0.0 or higher is required. Please update NodeJS on your system.')
|
console.log('NodeJS 12.0.0 or higher is required. Please update NodeJS on your system.')
|
||||||
process.exit()
|
process.exit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load environment variables / config
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
|
||||||
if (fs.existsSync('./.env') === false) {
|
if (fs.existsSync('./.env') === false) {
|
||||||
|
@ -20,14 +22,24 @@ if (fs.existsSync('./config.js') === false) {
|
||||||
|
|
||||||
require('dotenv').config()
|
require('dotenv').config()
|
||||||
|
|
||||||
|
// Prepare variables
|
||||||
const Discord = require('discord.js')
|
const Discord = require('discord.js')
|
||||||
const client = new Discord.Client({ disabledEvents: ['TYPING_START'] })
|
const client = new Discord.Client({ disabledEvents: ['TYPING_START'] })
|
||||||
|
|
||||||
client.commands = new Discord.Collection()
|
client.commands = new Discord.Collection()
|
||||||
client.aliases = new Discord.Collection()
|
client.aliases = new Discord.Collection()
|
||||||
|
|
||||||
|
// Initialization function
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
|
// Register events
|
||||||
|
fs.readdir('./events', (err, files) => {
|
||||||
|
files.forEach(file => {
|
||||||
|
client.on(file.substr(0, file.length - 3), require('./events/' + file))
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Login into Discord
|
||||||
|
client.login(process.env.TOKEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
init()
|
init();
|
||||||
|
|
Loading…
Reference in a new issue