From 5dbcd25eb61a370eb44f615d90ee7724115c55b8 Mon Sep 17 00:00:00 2001 From: Braeden57 Date: Fri, 17 Sep 2021 20:22:21 -0700 Subject: [PATCH] Beta 1.4.3 Optimization --- LPS.js | 11 +++++++---- dev-config.json | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/LPS.js b/LPS.js index e15ab87..aed7fad 100644 --- a/LPS.js +++ b/LPS.js @@ -77,6 +77,7 @@ class Bot { async nameSearch(message, args) { let user = await this.dbo.collection("users").findOne({"user.discord.id":message.author.id}).then(user => user); + if (!user) return message.channel.send(`You are not logged in ${message.author}!`); let data; if (user.user.activeCommunity=='' || user.user.activeCommunity==null) { if (args.length==0) return message.channel.send(`You must provide a **First Name**, **Last Name** and **DOB**(mm/dd/yyyy) ${message.author}!`); @@ -174,8 +175,9 @@ class Bot { } async plateSearch(message, args) { - if (args.length==0) return message.channel.send(`You are missing a **Plate #** ${message.author}`); let user = await this.dbo.collection("users").findOne({"user.discord.id":message.author.id}).then(user => user); + if (!user) return message.channel.send(`You are not logged in ${message.author}!`); + if (args.length==0) return message.channel.send(`You are missing a **Plate #** ${message.author}`); let data = { user: user, query: { @@ -222,10 +224,11 @@ class Bot { async checkStatus(message, args) { if (args.length==0) { let user = await this.dbo.collection("users").findOne({"user.discord.id":message.author.id}).then(user => user); - if (user==null) return message.channel.send(`You are not logged in ${message.author}!`); + if (!user) return message.channel.send(`You are not logged in ${message.author}!`); return message.channel.send(`${message.author}'s status: ${user.user.dispatchStatus} | Set by: ${user.user.dispatchStatusSetBy}`); } else { - let user = await this.dbo.collection("users").findOne({"user.discord.id":message.author.id}).then(user => user); if (user==null) return message.channel.send(`Cannot find **${args[0]}** ${message.author}!`); + let user = await this.dbo.collection("users").findOne({"user.discord.id":message.author.id}).then(user => user); + if (!user) return message.channel.send(`Cannot find **${args[0]}** ${message.author}!`); // This lame line of code to get username without ping on discord const User = client.users.cache.get(args[0].replace('<@!', '').replace('>', '')); return message.channel.send(`${message.author}, **${User.tag}'s** status: ${user.user.dispatchStatus} | Set by: ${user.user.dispatchStatusSetBy}`); @@ -235,7 +238,7 @@ class Bot { async updateStatus(message, args, prefix) { let validStatus=['10-8','10-7','10-6','10-11','10-23','10-97','10-15','10-70','10-80']; let user = await this.dbo.collection("users").findOne({"user.discord.id":message.author.id}).then(user => user); - if (user==null) return message.channel.send(`You are not logged in ${message.author}!`); + if (!user) return message.channel.send(`You are not logged in ${message.author}!`); if (args.length==0) return message.channel.send(`You must provide a new status ${message.author} | To see a list of valid statuses, use command \`${prefix}validStatus\`.`); if (!validStatus.includes(args[0])) return message.channel.send(`**${args[0]}** is a Invalid Status ${message.author}! To see a list of valid statuses, use command \`${prefix}validStatus\`.`); let onDuty=null; diff --git a/dev-config.json b/dev-config.json index 3255120..25a0ed6 100644 --- a/dev-config.json +++ b/dev-config.json @@ -2,7 +2,7 @@ "defaultPrefix": "?", "botID": "860298681047056434", "mongoURI": "mongodb+srv://lps_bot:ktSkHml2BU9EIQ0a@heroku-police-cad-dev.j7aom.mongodb.net/heroku_8pc4g86l?retryWrites=true&w=majority", - "version": "Beta 1.4.2", + "version": "Beta 1.4.3", "socket": "http://localhost:8080", "dbo": "heroku_8pc4g86l" } \ No newline at end of file