From 3ce04b881d3d2eefc00ff3168dcc08b1574dd94d Mon Sep 17 00:00:00 2001 From: Braeden57 Date: Tue, 3 Aug 2021 23:57:44 -0700 Subject: [PATCH] Update 1.0.0 Beta --- .gitignore | 3 +++ LPS.js | 41 ++++++++++++++++++++++++++++------------- config.json | 2 +- package.json | 2 +- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 51001a7..362ef31 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ node_modules/* # test file test.js + +# Dev version +dev.js \ No newline at end of file diff --git a/LPS.js b/LPS.js index 1406d7c..268f9c1 100644 --- a/LPS.js +++ b/LPS.js @@ -60,10 +60,10 @@ async function remoteLogout(message) { }); } -async function getUser(message) { +async function getUser(id) { let db = await MongoClient.connect(config.mongoURI,{useUnifiedTopology:true}); let dbo = db.db(config.dbo); - return await dbo.collection("users").findOne({"user.discord.id":message.author.id}).then(user => user); + return await dbo.collection("users").findOne({"user.discord.id":id}).then(user => user); } async function account(message) { @@ -74,10 +74,20 @@ async function account(message) { } async function checkStatus(message, args) { - getUser(message).then(user => { - if (user==null) 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}`); - }); + if (args.length==0) { + getUser(message.author.id).then(user => { + if (user==null) 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 { + getUser(args[0].id).then(user => { + if (user==null) return message.channel.send(`Cannot find **${args[0]}** ${message.author}!`); + // This lame code to get username without ping on discord + let id = args[0].replace('<@!', '').replace('>', ''); + const User = client.users.cache.get(id); + return message.channel.send(`${message.author}, **${User.tag}'s** status: ${user.user.dispatchStatus} | Set by: ${user.user.dispatchStatusSetBy}`); + }); + } } async function updateStatus(message, args, prefix) { @@ -176,7 +186,7 @@ client.on('message', (message) => { let help = new Discord.MessageEmbed() .setColor('#0099ff') .setTitle('**Commands:**') - .setURL('https://www.linespolice-cad.com/') + .setURL('https://discord.gg/jgUW656v2t') .setAuthor('LPS Website Support', 'https://raw.githubusercontent.com/Linesmerrill/police-cad/master/lines-police-server.png', 'https://discord.gg/jgUW656v2t') .setDescription('Lines Police CAD Bot Commands') .addFields( @@ -186,12 +196,10 @@ client.on('message', (message) => { { name: `**${prefix}login** `, value: 'Login to LPS account (DM only command)', inline: true }, { name: `**${prefix}logout**`, value: 'Logs out of your current logged in account', inline: true }, { name: `**${prefix}validStatus**`, value: 'Shows list of valid statuses to updade to', inline: true }, - { name: `**${prefix}checkStatus**`, value: 'Checks your current status', inline: true }, + { name: `**${prefix}checkStatus** `, value: 'Leave user blank to check own status', inline: true }, { name: `**${prefix}updateStatus** `, value: 'Updates your status', inline: true }, { name: `**${prefix}account**`, value: 'returns logged in account', inline: true }, - { name: `**${prefix}penalCodes**`, value: 'Provides Link to penal codes', inline: true }, - { name: `**${prefix}` } - ) + { name: `**${prefix}penalCodes**`, value: 'Provides Link to penal codes', inline: true } ) if (command == 'ping') message.channel.send('Pong!'); if (command == 'help') message.channel.send(help); @@ -207,13 +215,20 @@ client.on('message', (message) => { } if (command == 'logout') remoteLogout(message); if (command == 'validstatus') return message.channel.send(validStatus); - if (command == 'checkstatus') checkStatus(message); + if (command == 'checkstatus') checkStatus(message, args); if (command == 'updatestatus') updateStatus(message, args, prefix); if (command == 'account') account(message); if (command == 'penalcodes') return message.channel.send('https://www.linespolice-cad.com/penal-code'); + // In dev not prod + // if (command == 'namedb') nameSearch(message, args); + // if (command == 'platedb') plateSearch(message, args); + // if (command == 'firearmdb') weaponSearch(message, args); + // if (command == 'createbolo') createBolo(message, args); + // if (command == 'panic') enablePanic(message); + // Dev Commands (not visible in help) - if (command == 'version') return message.channel.send(`**LPS-BOT Version : ${config.version}**`) + if (command == 'version') return message.channel.send(`**LPS-BOT Version : PROD-${config.version}**`) if (command == 'whatisthemeaningoflife') message.channel.send('42'); }); }); diff --git a/config.json b/config.json index 06a25c9..63947de 100644 --- a/config.json +++ b/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 0.6.2", + "version": "Beta 0.6.4", "socket": "https://police-cad-dev.herokuapp.com/", "dbo": "heroku_8pc4g86l" } \ No newline at end of file diff --git a/package.json b/package.json index de3345c..72b71d5 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "LPS.js", "scripts": { "start": "node LPS.js", - "dev": "nodemon LPS.js" + "dev": "nodemon dev.js" }, "author": "Braeden Sowinski", "license": "ISC",