Binato/server/Packets/Logout.js

23 lines
792 B
JavaScript
Raw Normal View History

2022-08-26 12:52:00 +01:00
const consoleHelper = require("../../consoleHelper.js"),
Streams = require("../Streams.js");
2020-08-27 13:09:35 +01:00
module.exports = function(CurrentUser) {
if (CurrentUser.uuid === "bot") throw "Tried to log bot out, WTF???";
const logoutStartTime = Date.now();
2020-08-27 13:09:35 +01:00
2022-08-26 12:52:00 +01:00
const streamList = Streams.getStreams();
2020-08-27 13:09:35 +01:00
for (let i = 0; i < streamList.length; i++) {
2022-08-26 12:52:00 +01:00
if (Streams.isUserInStream(streamList[i], CurrentUser.uuid)) {
Streams.removeUserFromStream(streamList[i], CurrentUser.uuid);
}
}
2020-08-27 13:09:35 +01:00
// Remove user from user list
global.users.remove(CurrentUser.uuid);
2020-08-27 13:09:35 +01:00
2022-08-26 12:52:00 +01:00
global.DatabaseHelper.query("UPDATE osu_info SET value = ? WHERE name = 'online_now'", [global.users.getLength() - 1]);
consoleHelper.printBancho(`User logged out, took ${Date.now() - logoutStartTime}ms. [User: ${CurrentUser.username}]`);
2020-08-27 13:09:35 +01:00
}