/**
 * @file Event Handler
 * @author Sankarsan Kampa (a.k.a k3rn31p4nic)
 * @license GPL-3.0
 */

const fs = xrequire('fs');
const path = xrequire('path');

/**
 * Handles/Loads all the events.
 * @module eventHandler
 * @param {object} Bastion The Bastion Object.
 * @returns {void}
 */
module.exports = Bastion => {
  /* eslint-disable no-sync */
  let events = fs.readdirSync('./events/').
    filter(file => !fs.statSync(path.resolve('./events/', file)).isDirectory()).
    filter(file => file.endsWith('.js'));
  /* eslint-enable no-sync */

  for (let event of events) {
    event = event.replace(/\.js$/i, '');

    if (event === 'ready') {
      Bastion.on(event, () => xrequire('./events', event)(Bastion));
    }
    else {
      Bastion.on(event, xrequire('./events', event));
    }
  }
};

@@ -312,16 +312,113 @@
 on =%3E %7B%0A
+  const DISCORD_EVENTS_PATH = './events/discord/';%0A  const SELF_EVENTS_PATH = './events/self/';%0A%0A
   /* esl
@@ -442,25 +442,32 @@
 nc */%0A  let 
-e
+DiscordE
 vents = fs.r
@@ -477,27 +477,35 @@
 dirSync(
-'./events/'
+DISCORD_EVENTS_PATH
 ).%0A    f
@@ -548,19 +548,209 @@
 lve(
-'./events/'
+DISCORD_EVENTS_PATH, file)).isDirectory()).%0A    filter(file =%3E file.endsWith('.js'));%0A%0A  let SelfEvents = fs.readdirSync(SELF_EVENTS_PATH).%0A    filter(file =%3E !fs.statSync(path.resolve(SELF_EVENTS_PATH
 , fi
@@ -863,17 +863,24 @@
 vent of 
-e
+DiscordE
 vents) %7B
@@ -986,34 +986,43 @@
 =%3E xrequire(
-'./events'
+DISCORD_EVENTS_PATH
 , event)(Bas
@@ -1083,34 +1083,182 @@
 ire(
-'./events', event)
+DISCORD_EVENTS_PATH, event));%0A    %7D%0A  %7D%0A%0A  for (let event of SelfEvents) %7B%0A    event = event.replace(/%5C.js$/i, ''
 );%0A
+%0A
     
-%7D
+Bastion.on(event, xrequire(SELF_EVENTS_PATH, event));
 %0A  %7D

update eventHandler to load events from new location