Update 1.0.0 Beta

This commit is contained in:
SowinskiBraeden committed 2021-08-03 23:57:44 -07:00
1 parent a4a10fded8
commit 3ce04b881d
4 files changed
+30 -12

No files matched your search

+3
View File
@@ -3,3 +3,6 @@ node_modules/*
# test file # test file
test.js test.js
# Dev version
dev.js
+25 -10
View File
@@ -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 db = await MongoClient.connect(config.mongoURI,{useUnifiedTopology:true});
let dbo = db.db(config.dbo); 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) { async function account(message) {
@@ -74,10 +74,20 @@ async function account(message) {
} }
async function checkStatus(message, args) { async function checkStatus(message, args) {
getUser(message).then(user => { if (args.length==0) {
getUser(message.author.id).then(user => {
if (user==null) return message.channel.send(`You are not logged in ${message.author}!`); 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}`); 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) { async function updateStatus(message, args, prefix) {
@@ -176,7 +186,7 @@ client.on('message', (message) => {
let help = new Discord.MessageEmbed() let help = new Discord.MessageEmbed()
.setColor('#0099ff') .setColor('#0099ff')
.setTitle('**Commands:**') .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') .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') .setDescription('Lines Police CAD Bot Commands')
.addFields( .addFields(
@@ -186,12 +196,10 @@ client.on('message', (message) => {
{ name: `**${prefix}login** <email> <password>`, value: 'Login to LPS account (DM only command)', inline: true }, { name: `**${prefix}login** <email> <password>`, 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}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}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** <user>`, value: 'Leave user blank to check own status', inline: true },
{ name: `**${prefix}updateStatus** <status>`, value: 'Updates your status', inline: true }, { name: `**${prefix}updateStatus** <status>`, value: 'Updates your status', inline: true },
{ name: `**${prefix}account**`, value: 'returns logged in account', 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}penalCodes**`, value: 'Provides Link to penal codes', inline: true } )
{ name: `**${prefix}` }
)
if (command == 'ping') message.channel.send('Pong!'); if (command == 'ping') message.channel.send('Pong!');
if (command == 'help') message.channel.send(help); if (command == 'help') message.channel.send(help);
@@ -207,13 +215,20 @@ client.on('message', (message) => {
} }
if (command == 'logout') remoteLogout(message); if (command == 'logout') remoteLogout(message);
if (command == 'validstatus') return message.channel.send(validStatus); 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 == 'updatestatus') updateStatus(message, args, prefix);
if (command == 'account') account(message); if (command == 'account') account(message);
if (command == 'penalcodes') return message.channel.send('https://www.linespolice-cad.com/penal-code'); 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) // 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'); if (command == 'whatisthemeaningoflife') message.channel.send('42');
}); });
}); });
+1 -1
View File
@@ -2,7 +2,7 @@
"defaultPrefix": "?", "defaultPrefix": "?",
"botID": "860298681047056434", "botID": "860298681047056434",
"mongoURI": "mongodb+srv://lps_bot:ktSkHml2BU9EIQ0a@heroku-police-cad-dev.j7aom.mongodb.net/heroku_8pc4g86l?retryWrites=true&w=majority", "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/", "socket": "https://police-cad-dev.herokuapp.com/",
"dbo": "heroku_8pc4g86l" "dbo": "heroku_8pc4g86l"
} }
+1 -1
View File
@@ -5,7 +5,7 @@
"main": "LPS.js", "main": "LPS.js",
"scripts": { "scripts": {
"start": "node LPS.js", "start": "node LPS.js",
"dev": "nodemon LPS.js" "dev": "nodemon dev.js"
}, },
"author": "Braeden Sowinski", "author": "Braeden Sowinski",
"license": "ISC", "license": "ISC",