woomy-v2/bot/util/database.js

40 lines
931 B
JavaScript
Raw Normal View History

2020-10-17 01:16:27 +00:00
const { Pool } = require('pg');
const credentials = require('../../config.json').pgCredentials;
class Database {
constructor(client) {
this.client = client;
this.pool = new Pool({
user: credentials.user,
host: credentials.host,
database: credentials.database,
password: credentials.password,
port: credentials.port
});
this.pool.on('connect', () => {
this.client.logger.info('Connected to Postgres database.')
})
};
async getGuild (id) {
return await this.pool.query('SELECT * FROM guilds WHERE guild_id = $1;', [id]);
};
async getGuildField (id, field) {
let res = await this.pool.query('SELECT $1 FROM guilds WHERE guild_id = $2;', [field, id]);
};
async getMember (guildID, userID) {
};
async getUser (id) {
};
};
module.exports = Database;