diff --git a/package.json b/package.json index 4633e4e..05b101a 100644 --- a/package.json +++ b/package.json @@ -15,10 +15,8 @@ "body-parser": "^1.18.3", "colors": "^1.3.2", "discord.js": "^11.4.2", - "express": "^4.16.4", "moment": "^2.22.2", "regenerator-runtime": "^0.12.1", - "request": "^2.88.0", "sequelize": "^4.39.1", "sqlite3": "^4.0.2" } diff --git a/src/config.js b/src/config.js index 6fdabc5..760db83 100644 --- a/src/config.js +++ b/src/config.js @@ -9,12 +9,14 @@ let Configuration; export class Config { static get Configuration() {return Configuration;} static get Token() {return Configuration.Token;} + static get NowPlaying() {return Configuration.NowPlaying;} static init() { file = './resources/config/config.json'; path = [ './resources/', './resources/config' ] Configuration = { - Token: 'YOUR TOKEN HERE' + Token: 'BOT TOKEN HERE', + NowPlaying: 'PLAYING GAME HERE' }; } @@ -24,6 +26,7 @@ export class Config { try { Configuration = JSON.parse(fs.readFileSync(file)); if (!Configuration.Token) Logger.panic('Token is missing from config file'); + if (!Configuration.NowPlaying) Logger.panic('NowPlaying is missing from config file'); Logger.info('Config loaded successfully'); } catch (e) { diff --git a/src/events.js b/src/events.js index 9168dec..05c4a06 100644 --- a/src/events.js +++ b/src/events.js @@ -7,10 +7,20 @@ export class Events { this.client.login(Config.Token); } - async handle() { - this.client.on('ready', () => { - Logger.info(`Discord client logged in as ${this.client.user.tag}`); - Logger.ready(); - }); + async handleEvents() { + this.client.on('ready', () => {this.handleReady()}); + this.client.on('message', async (message) => {this.handleMessage(message)}); + } + + async handleReady() { + this.client.user.setPresence('online'); + this.client.user.setActivity(Config.NowPlaying); + Logger.info(`Discord client logged in as ${this.client.user.tag}`); + Logger.ready(); + } + + async handleMessage(...args) { + Logger.info(args[0]); + args[0].channel.send('lol u homo') } } diff --git a/src/index.js b/src/index.js index 512d0f0..8d716e6 100644 --- a/src/index.js +++ b/src/index.js @@ -14,12 +14,10 @@ async function init() { Config.load(); await Database.init(); - // Logger.debug(JSON.stringify(await Database.Guilds.newGuild(1234, "Hello"), null, 4)); - // Logger.debug(JSON.stringify(await Database.Guilds.deleteGuild(1234), null, 4)); const client = new Discord.Client(); const eventHandler = new Events(); await eventHandler.init(client); - eventHandler.handle(); + eventHandler.handleEvents(); } diff --git a/test/index.js b/test/index.js index e69de29..051d8f0 100644 --- a/test/index.js +++ b/test/index.js @@ -0,0 +1,3 @@ + // Logger.debug(JSON.stringify(await Database.Guilds.newGuild(1234, "Hello"), null, 4)); + // Logger.debug(JSON.stringify(await Database.Guilds.deleteGuild(1234), null, 4)); + \ No newline at end of file