1.6.4 Fix multiple responce with socket
This commit is contained in:
1 parent
ad1a9105f4
commit
432921dff0
3 files changed
+21
-13
No files matched your search
@@ -11,8 +11,6 @@ class Bot {
|
|||||||
this.token = token;
|
this.token = token;
|
||||||
this.config = require(config);
|
this.config = require(config);
|
||||||
this.connectMongo();
|
this.connectMongo();
|
||||||
|
|
||||||
this.socket = io.connect(this.config.socket);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async connectMongo() {
|
async connectMongo() {
|
||||||
@@ -108,8 +106,9 @@ class Bot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.socket.emit("bot_name_search", data);
|
const socket = io.connect(this.config.socket);
|
||||||
this.socket.on("bot_name_search_results", results => {
|
socket.emit("bot_name_search", data);
|
||||||
|
socket.on("bot_name_search_results", results => {
|
||||||
|
|
||||||
if (results.user._id==user._id) {
|
if (results.user._id==user._id) {
|
||||||
if (results.civilians.length == 0) {
|
if (results.civilians.length == 0) {
|
||||||
@@ -173,6 +172,7 @@ class Bot {
|
|||||||
message.channel.send(nameResult);
|
message.channel.send(nameResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
socket.disconnect();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,8 +187,9 @@ class Bot {
|
|||||||
activeCommunityID: user.user.activeCommunity
|
activeCommunityID: user.user.activeCommunity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.socket.emit('bot_plate_search', data);
|
const socket = io.connect(this.config.socket);
|
||||||
this.socket.on('bot_plate_search_results', results => {
|
socket.emit('bot_plate_search', data);
|
||||||
|
socket.on('bot_plate_search_results', results => {
|
||||||
|
|
||||||
if (results.user._id==user._id) {
|
if (results.user._id==user._id) {
|
||||||
if (results.vehicles.length == 0) {
|
if (results.vehicles.length == 0) {
|
||||||
@@ -222,6 +223,7 @@ class Bot {
|
|||||||
message.channel.send(plateResult);
|
message.channel.send(plateResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
socket.disconnect();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,8 +238,9 @@ class Bot {
|
|||||||
activeCommunityID: user.user.activeCommunity
|
activeCommunityID: user.user.activeCommunity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.socket.emit('bot_firearm_search', data);
|
const socket = io.connect(this.config.socket);
|
||||||
this.socket.on('bot_firearm_search_results', results => {
|
socket.emit('bot_firearm_search', data);
|
||||||
|
socket.on('bot_firearm_search_results', results => {
|
||||||
if (results.user._id==user._id) {
|
if (results.user._id==user._id) {
|
||||||
if (results.firearms.length==0) {
|
if (results.firearms.length==0) {
|
||||||
return message.channel.send(`No Firearms found ${message.author}`);
|
return message.channel.send(`No Firearms found ${message.author}`);
|
||||||
@@ -262,6 +265,7 @@ class Bot {
|
|||||||
message.channel.send(firearmResult);
|
message.channel.send(firearmResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
socket.disconnect();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,9 +309,11 @@ class Bot {
|
|||||||
onDuty: onDuty,
|
onDuty: onDuty,
|
||||||
updateDuty: updateDuty
|
updateDuty: updateDuty
|
||||||
};
|
};
|
||||||
this.socket.emit('bot_update_status', req);
|
const socket = io.connect(this.config.socket);
|
||||||
this.socket.on('bot_updated_status', (res) => {
|
socket.emit('bot_update_status', req);
|
||||||
|
socket.on('bot_updated_status', (res) => {
|
||||||
message.channel.send(`Succesfully updated status to **${args[0]}** ${message.author}!`);
|
message.channel.send(`Succesfully updated status to **${args[0]}** ${message.author}!`);
|
||||||
|
socket.disconnect();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,7 +328,9 @@ class Bot {
|
|||||||
userUsername: user.user.username,
|
userUsername: user.user.username,
|
||||||
activeCommunity: user.user.activeCommunity
|
activeCommunity: user.user.activeCommunity
|
||||||
}
|
}
|
||||||
this.socket.emit('panic_button_update', myReq);
|
const socket = io.connect(this.config.socket);
|
||||||
|
socket.emit('panic_button_update', myReq);
|
||||||
|
socket.disconnect();
|
||||||
// If panic is enabled, set status to Online (panic off)
|
// If panic is enabled, set status to Online (panic off)
|
||||||
} else if (user.user.dispatchStatus=='Panic') {
|
} else if (user.user.dispatchStatus=='Panic') {
|
||||||
this.updateStatus(message, ['10-41'], null);
|
this.updateStatus(message, ['10-41'], null);
|
||||||
|
|||||||
+1
-1
@@ -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 1.6.1",
|
"version": "Beta 1.6.4",
|
||||||
"socket": "https://police-cad-dev.herokuapp.com/",
|
"socket": "https://police-cad-dev.herokuapp.com/",
|
||||||
"dbo": "heroku_8pc4g86l"
|
"dbo": "heroku_8pc4g86l"
|
||||||
}
|
}
|
||||||
+1
-1
@@ -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 1.6.1",
|
"version": "Beta 1.6.4",
|
||||||
"socket": "http://localhost:8080",
|
"socket": "http://localhost:8080",
|
||||||
"dbo": "heroku_8pc4g86l"
|
"dbo": "heroku_8pc4g86l"
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user