Move Things Around

This commit is contained in:
Daniel Odendahl Jr
2017-04-27 15:43:58 +00:00
parent d67b086a00
commit 91a000b220
9 changed files with 29 additions and 35 deletions
+8 -11
View File
@@ -1,23 +1,20 @@
const Sequelize = require('sequelize');
const database = new Sequelize(process.env.DATABASE_URL, { logging: false });
class Database {
module.exports = class Database {
static get db() {
return database;
}
start() {
database.authenticate()
.then(() => console.log('Connection to database has been established successfully.'))
.then(() => console.log('Synchronizing database...'))
.then(() => console.log('[Database] Connection has been established successfully.'))
.then(() => console.log('[Database] Synchronizing...'))
.then(() => database.sync()
.then(() => console.log('Synchronizing database done!'))
.catch(error => console.error(`Error synchronizing the database: ${error}`))
.then(() => console.log('[Database] Synchronizing complete!'))
.catch(err => console.error(`[Database] Error synchronizing: ${err}`))
)
.then(() => console.log('Ready to rock!'))
.catch(err => console.error(`Unable to connect to the database: ${err}`));
.then(() => console.log('[Database] Ready!'))
.catch(err => console.error(`[Database] Unable to connect: ${err}`));
}
}
module.exports = Database;
};
+27
View File
@@ -0,0 +1,27 @@
const request = require('superagent');
module.exports = class Stats {
constructor() {
throw new Error(`The ${this.constructor.name} class may not be instantiated.`);
}
static discordBots(count, userID) {
return request
.post(`https://bots.discord.pw/api/bots/${userID}/stats`)
.set({
'Authorization': process.env.DISCORD_BOTS_KEY
})
.send({
server_count: count
});
}
static carbon(count) {
return request
.post('https://www.carbonitex.net/discord/data/botdata.php')
.send({
key: process.env.CARBON_KEY,
servercount: count
});
}
};