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) {
|
2022-04-20 07:25:40 +01:00
|
|
|
if (CurrentUser.uuid === "bot") throw "Tried to log bot out, WTF???";
|
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
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
|
|
|
|
2022-01-04 03:39:53 +00: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);
|
2022-01-04 03:39:53 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-27 13:09:35 +01:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
// Remove user from user list
|
2022-02-23 05:35:10 +00:00
|
|
|
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]);
|
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
consoleHelper.printBancho(`User logged out, took ${Date.now() - logoutStartTime}ms. [User: ${CurrentUser.username}]`);
|
2020-08-27 13:09:35 +01:00
|
|
|
}
|