Minor bug fixes now successful connenct to discord

This commit is contained in:
plane000
2018-10-27 14:27:03 +01:00
parent cdd6c15e28
commit 0c0f69202d
5 changed files with 23 additions and 11 deletions

View File

@@ -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"
}

View File

@@ -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) {

View File

@@ -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')
}
}

View File

@@ -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();
}

View File

@@ -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));