This repository has been archived by the owner on Jan 28, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
merged reorganise branch
- Loading branch information
1 parent
d8a003d
commit 6d33cc6
Showing
9 changed files
with
52 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
require('colors'); | ||
|
||
const { Client } = require('discord.js'); | ||
const { events } = require('./configurations'); | ||
const { Auth, Utils } = require('./modules'); | ||
const events = require("./events/events.registry"); | ||
const EventHandler = require('./events/EventHandler'); | ||
|
||
const bot = new Client(); | ||
class Bot { | ||
|
||
constructor(token) { | ||
this._token = token; | ||
this._client = new Client(); | ||
this._events = events; | ||
this.load_events(); | ||
} | ||
|
||
load_events() { | ||
const eventHandler = new EventHandler(this._client); | ||
eventHandler.load(); | ||
for (const e of Object.keys(events)) { | ||
this._client.on(e, (...args) => { | ||
eventHandler.onEvent(e, ...args); | ||
eventHandler.logEvent(e); | ||
}); | ||
} | ||
} | ||
|
||
/** | ||
* event handler class is specifically made to handle commands | ||
* i.e. run them, load them in cache etc. If you wish to add | ||
* a command managing functionality checkout EventHandler file. | ||
*/ | ||
const eventHandler = new EventHandler(bot); | ||
// initialise and load all the available command in a cache store | ||
eventHandler.load(); | ||
for (const e of Object.keys(events)) { | ||
bot.on(e, (...args) => { | ||
eventHandler.onEvent(e, ...args); | ||
eventHandler.logEvent(e); | ||
}); | ||
start() { | ||
Utils.createLogFiles(); | ||
this._client.login(Auth.botToken); | ||
} | ||
} | ||
|
||
module.exports = bot; | ||
module.exports = Bot; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
module.exports = { | ||
api_keys: require('./api_keys.json'), | ||
commands: require('./commands'), | ||
config: require('./config.json'), | ||
events: require('./events') | ||
config: require('./config.json') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
disconnect: ['Bot.Disconnect'], | ||
guildBandAdd: [], | ||
guildBanRemove: [], | ||
guildCreate: [], | ||
guildDelete: [], | ||
guildMemberAdd: ['Bot.GuildMemberAdd'], | ||
guildMemberRemove: [], | ||
guildUnavailable: [], | ||
guildUpdate: [], | ||
message: ['Bot.CommandHandler'], | ||
rateLimit: [], | ||
ready: ['Bot.Ready'], | ||
reconnecting: [], | ||
resume: [], | ||
userUpdate: [] | ||
}; | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
module.exports = { | ||
ErrorHandler: require('./ErrorHandler'), | ||
NotifyMaintainer: require('./NotifyMaintainer'), | ||
checkLogFiles: require('./checkLogFiles'), | ||
createLogFiles: require('./createLogFiles'), | ||
timeConversion: require('./timeConversion'), | ||
slug: require('./slug') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
require('colors'); | ||
const bot = require('./bot'); | ||
const { Auth, Utils } = require('./modules'); | ||
|
||
Utils.checkLogFiles(); | ||
bot.login(Auth.botToken); | ||
const bot = new (require('./bot'))(); | ||
bot.start(); |