From 7a6a74d161bac408f258509d498a2a8bd51f2324 Mon Sep 17 00:00:00 2001 From: Emily J Date: Sat, 17 Oct 2020 16:17:02 +1100 Subject: [PATCH] ERRORS BEGONE --- bot/events/message.js | 2 +- bot/index.js | 2 +- bot/util/database.js | 10 +++++----- bot/util/functions.js | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bot/events/message.js b/bot/events/message.js index e28ecc7..8ce3413 100644 --- a/bot/events/message.js +++ b/bot/events/message.js @@ -10,7 +10,7 @@ module.exports = class { async run (message) { if (message.author.bot) return; - let data = {}; + const data = {}; data.user = await this.client.db.getUser(message.author.id); const prefixes = [data.user.prefix]; diff --git a/bot/index.js b/bot/index.js index 7e5166c..db6edc2 100644 --- a/bot/index.js +++ b/bot/index.js @@ -41,7 +41,7 @@ class WoomyClient extends Client { } } -async function init() { +async function init () { const client = new WoomyClient(); client.logger.info(`Initializing Woomy v${client.version}`); diff --git a/bot/util/database.js b/bot/util/database.js index 4b74da5..a57d39b 100644 --- a/bot/util/database.js +++ b/bot/util/database.js @@ -5,30 +5,30 @@ const format = require('pg-format'); const { pgCredentials } = require('../../config.json'); class Database { - constructor(client) { + constructor (client) { this.client = client; this.pool = new Pool(pgCredentials); } 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]; } async getMember (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]; } 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]; } async updateGuild (id, column, newValue) { 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; } diff --git a/bot/util/functions.js b/bot/util/functions.js index f07d97d..3402303 100644 --- a/bot/util/functions.js +++ b/bot/util/functions.js @@ -18,11 +18,11 @@ class Functions { } async getLastMessage (channel) { - let messages = await channel.messages.fetch({ limit: 2 }); + const messages = await channel.messages.fetch({ limit: 2 }); 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; await message.channel.send(question); @@ -42,7 +42,7 @@ class Functions { searchForMembers (guild, query) { query = query.toLowerCase(); - let matches = []; + const matches = []; let match; try { @@ -67,10 +67,10 @@ class Functions { findRole (input, message) { let role; role = message.guild.roles.cache.find(r => r.name.toLowerCase() === input.toLowerCase()); - if(!role) { + if (!role) { role = message.guild.roles.cache.get(input.toLowerCase()); } - if(!role) return; + if (!role) return; return role; }