ERRORS BEGONE
This commit is contained in:
parent
fc9a0dc33c
commit
7a6a74d161
4 changed files with 12 additions and 12 deletions
|
@ -10,7 +10,7 @@ module.exports = class {
|
||||||
async run (message) {
|
async run (message) {
|
||||||
if (message.author.bot) return;
|
if (message.author.bot) return;
|
||||||
|
|
||||||
let data = {};
|
const data = {};
|
||||||
data.user = await this.client.db.getUser(message.author.id);
|
data.user = await this.client.db.getUser(message.author.id);
|
||||||
|
|
||||||
const prefixes = [data.user.prefix];
|
const prefixes = [data.user.prefix];
|
||||||
|
|
|
@ -41,7 +41,7 @@ class WoomyClient extends Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function init() {
|
async function init () {
|
||||||
const client = new WoomyClient();
|
const client = new WoomyClient();
|
||||||
|
|
||||||
client.logger.info(`Initializing Woomy v${client.version}`);
|
client.logger.info(`Initializing Woomy v${client.version}`);
|
||||||
|
|
|
@ -5,30 +5,30 @@ const format = require('pg-format');
|
||||||
const { pgCredentials } = require('../../config.json');
|
const { pgCredentials } = require('../../config.json');
|
||||||
|
|
||||||
class Database {
|
class Database {
|
||||||
constructor(client) {
|
constructor (client) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.pool = new Pool(pgCredentials);
|
this.pool = new Pool(pgCredentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGuild (id) {
|
async getGuild (id) {
|
||||||
let res = await this.pool.query('SELECT * FROM guilds WHERE guild_id = $1;', [id]);
|
const res = await this.pool.query('SELECT * FROM guilds WHERE guild_id = $1;', [id]);
|
||||||
return res.rows[0];
|
return res.rows[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMember (guild_id, user_id) {
|
async getMember (guild_id, user_id) {
|
||||||
const key = guild_id + ':' + user_id;
|
const key = guild_id + ':' + user_id;
|
||||||
let res = await this.pool.query('SELECT * FROM members WHERE member_id = $1;', [key]);
|
const res = await this.pool.query('SELECT * FROM members WHERE member_id = $1;', [key]);
|
||||||
return res.rows[0];
|
return res.rows[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUser (id) {
|
async getUser (id) {
|
||||||
let res = await this.pool.query('SELECT * FROM guilds WHERE user_id = $1;', [id]);
|
const res = await this.pool.query('SELECT * FROM guilds WHERE user_id = $1;', [id]);
|
||||||
return res.rows[0];
|
return res.rows[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateGuild (id, column, newValue) {
|
async updateGuild (id, column, newValue) {
|
||||||
const sql = format('UPDATE guilds SET %I = $1 WHERE guild_id = $2;', column);
|
const sql = format('UPDATE guilds SET %I = $1 WHERE guild_id = $2;', column);
|
||||||
let res = await this.pool.query(sql, [newValue, id]);
|
const res = await this.pool.query(sql, [newValue, id]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,11 @@ class Functions {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getLastMessage (channel) {
|
async getLastMessage (channel) {
|
||||||
let messages = await channel.messages.fetch({ limit: 2 });
|
const messages = await channel.messages.fetch({ limit: 2 });
|
||||||
return messages.last().content;
|
return messages.last().content;
|
||||||
}
|
}
|
||||||
|
|
||||||
async awaitReply(message, question, limit = 60000) {
|
async awaitReply (message, question, limit = 60000) {
|
||||||
const filter = (m) => m.author.id === message.author.id;
|
const filter = (m) => m.author.id === message.author.id;
|
||||||
await message.channel.send(question);
|
await message.channel.send(question);
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class Functions {
|
||||||
searchForMembers (guild, query) {
|
searchForMembers (guild, query) {
|
||||||
query = query.toLowerCase();
|
query = query.toLowerCase();
|
||||||
|
|
||||||
let matches = [];
|
const matches = [];
|
||||||
let match;
|
let match;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -67,10 +67,10 @@ class Functions {
|
||||||
findRole (input, message) {
|
findRole (input, message) {
|
||||||
let role;
|
let role;
|
||||||
role = message.guild.roles.cache.find(r => r.name.toLowerCase() === input.toLowerCase());
|
role = message.guild.roles.cache.find(r => r.name.toLowerCase() === input.toLowerCase());
|
||||||
if(!role) {
|
if (!role) {
|
||||||
role = message.guild.roles.cache.get(input.toLowerCase());
|
role = message.guild.roles.cache.get(input.toLowerCase());
|
||||||
}
|
}
|
||||||
if(!role) return;
|
if (!role) return;
|
||||||
return role;
|
return role;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue