diff --git a/LPS.js b/LPS.js index 33f19a2..0fba62a 100644 --- a/LPS.js +++ b/LPS.js @@ -284,7 +284,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', 'Panic']; + let validStatus=['10-8','10-7','10-6','10-11','10-23','10-97','10-15','10-70','10-80', 'Panic', '10-41', '10-42']; 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 must provide a new status ${message.author} | To see a list of valid statuses, use command \`${prefix}validStatus\`.`); @@ -329,11 +329,27 @@ class Bot { activeCommunity: user.user.activeCommunity } const socket = io.connect(this.config.socket); + socket.emit('botping'); socket.emit('panic_button_update', myReq); - socket.disconnect(); + message.channel.send(`Enabled Panic ${message.author}!`); // If panic is enabled, set status to Online (panic off) } else if (user.user.dispatchStatus=='Panic') { - this.updateStatus(message, ['10-41'], null); + let myReq = { + userID: user._id, + communityID: user.user.activeCommunity + }; + const socket = io.connect(this.config.socket); + socket.emit('clear_panic', myReq); + + let myUpdateReq = { + userID: user._id, + status: '10-8', + setBy: 'System', + onDuty: null, + updateDuty: false + }; + socket.emit('update_status', myUpdateReq); + message.channel.send(`Disabled Panic ${message.author} and set status to 10-8.`); } } @@ -412,10 +428,10 @@ class Bot { { 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}namedb `, value: 'Searches in your community for name (dob only required if not in a community)', inline: true }, - { name: `**${prefix}platedb `, value: 'Searches in your community for Vehicles with the given Licence plate #', inline: true }, - { name: `**${prefix}firearmdb `, value: 'Searches for Firearms with the given Serial #', inline: true }, - { name: `**${prefix}panic`, value: 'Enables or disables your panic button', inline: true } + { name: `**${prefix}namedb **`, value: 'Searches in your community for name (dob only required if not in a community)', inline: true }, + { name: `**${prefix}platedb **`, value: 'Searches in your community for Vehicles with the given Licence plate #', inline: true }, + { name: `**${prefix}firearmdb **`, value: 'Searches for Firearms with the given Serial #', inline: true }, + { name: `**${prefix}panic**`, value: 'Enables or disables your panic button', inline: true } ) if (command == 'ping') message.channel.send('Pong!'); @@ -448,8 +464,12 @@ class Bot { if (command == 'version') message.channel.send(`**LPS-BOT Version : ${this.dev}-${this.config.version}**`) if (command == 'whatisthemeaningoflife') message.channel.send('42'); if (command == 'pingserver') { - this.socket.emit('botping', {message:'hello there'}); - this.socket.on('botpong', (data)=>{console.log(data)}); + const socket = io.connect(this.config.socket); + socket.emit('botping', {message:'hello there'}); + socket.on('botpong', (data) => { + console.log(data); + socket.disconnect(); + }); } }); }); diff --git a/config.json b/config.json index 9b19f24..8d64665 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 1.6.4", + "version": "Beta 1.6.5", "socket": "https://police-cad-dev.herokuapp.com/", "dbo": "heroku_8pc4g86l" } \ No newline at end of file diff --git a/dev-config.json b/dev-config.json index ba96251..bb24f58 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.6.4", + "version": "Beta 1.6.5", "socket": "http://localhost:8080", "dbo": "heroku_8pc4g86l" } \ No newline at end of file