Minor bug fixes now successful connenct to discord
This commit is contained in:
@@ -15,10 +15,8 @@
|
|||||||
"body-parser": "^1.18.3",
|
"body-parser": "^1.18.3",
|
||||||
"colors": "^1.3.2",
|
"colors": "^1.3.2",
|
||||||
"discord.js": "^11.4.2",
|
"discord.js": "^11.4.2",
|
||||||
"express": "^4.16.4",
|
|
||||||
"moment": "^2.22.2",
|
"moment": "^2.22.2",
|
||||||
"regenerator-runtime": "^0.12.1",
|
"regenerator-runtime": "^0.12.1",
|
||||||
"request": "^2.88.0",
|
|
||||||
"sequelize": "^4.39.1",
|
"sequelize": "^4.39.1",
|
||||||
"sqlite3": "^4.0.2"
|
"sqlite3": "^4.0.2"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,14 @@ let Configuration;
|
|||||||
export class Config {
|
export class Config {
|
||||||
static get Configuration() {return Configuration;}
|
static get Configuration() {return Configuration;}
|
||||||
static get Token() {return Configuration.Token;}
|
static get Token() {return Configuration.Token;}
|
||||||
|
static get NowPlaying() {return Configuration.NowPlaying;}
|
||||||
|
|
||||||
static init() {
|
static init() {
|
||||||
file = './resources/config/config.json';
|
file = './resources/config/config.json';
|
||||||
path = [ './resources/', './resources/config' ]
|
path = [ './resources/', './resources/config' ]
|
||||||
Configuration = {
|
Configuration = {
|
||||||
Token: 'YOUR TOKEN HERE'
|
Token: 'BOT TOKEN HERE',
|
||||||
|
NowPlaying: 'PLAYING GAME HERE'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,6 +26,7 @@ export class Config {
|
|||||||
try {
|
try {
|
||||||
Configuration = JSON.parse(fs.readFileSync(file));
|
Configuration = JSON.parse(fs.readFileSync(file));
|
||||||
if (!Configuration.Token) Logger.panic('Token is missing from config 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');
|
Logger.info('Config loaded successfully');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -7,10 +7,20 @@ export class Events {
|
|||||||
this.client.login(Config.Token);
|
this.client.login(Config.Token);
|
||||||
}
|
}
|
||||||
|
|
||||||
async handle() {
|
async handleEvents() {
|
||||||
this.client.on('ready', () => {
|
this.client.on('ready', () => {this.handleReady()});
|
||||||
Logger.info(`Discord client logged in as ${this.client.user.tag}`);
|
this.client.on('message', async (message) => {this.handleMessage(message)});
|
||||||
Logger.ready();
|
}
|
||||||
});
|
|
||||||
|
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')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,12 +14,10 @@ async function init() {
|
|||||||
Config.load();
|
Config.load();
|
||||||
|
|
||||||
await Database.init();
|
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 client = new Discord.Client();
|
||||||
|
|
||||||
const eventHandler = new Events();
|
const eventHandler = new Events();
|
||||||
await eventHandler.init(client);
|
await eventHandler.init(client);
|
||||||
eventHandler.handle();
|
eventHandler.handleEvents();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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));
|
||||||
|
|
||||||
Reference in New Issue
Block a user