generated from array-in-a-matrix/matrix-bot-template
remove bloat
This commit is contained in:
parent
472206143b
commit
4aa04ceda2
13
index.js
13
index.js
|
@ -5,7 +5,7 @@ import fs from "fs";
|
|||
const storage = new SimpleFsStorageProvider("storage.json");
|
||||
const client = new MatrixClient(config.homeserver, config.token, storage);
|
||||
|
||||
let lastUpdate, timeoutExists, data;
|
||||
let data;
|
||||
|
||||
const error1 = setTimeout(function () {
|
||||
console.log("\x1b[41m", "ERROR: UNABLE TO CONNECT TO MATRIX SERVER");
|
||||
|
@ -54,15 +54,6 @@ const addCount = async (roomId, message) => {
|
|||
if (data.count[message["sender"]] > data.max.count) {
|
||||
data.max.count++;
|
||||
data.max.username = message["sender"];
|
||||
if (lastUpdate + 5000 < Date.now()) {
|
||||
lastUpdate = Date.now();
|
||||
} else if (!timeoutExists) {
|
||||
setTimeout(() => {
|
||||
lastUpdate = Date.now();
|
||||
timeoutExists = false;
|
||||
}, lastUpdate + 5000 - Date.now());
|
||||
timeoutExists = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -71,8 +62,6 @@ client.start().then(() => {
|
|||
clearTimeout(error1);
|
||||
// console.log(`Logged into ${client.guilds.cache.size} rooms`); // ? this is possible i think idk how tho
|
||||
data = readFromCache();
|
||||
lastUpdate = Date.now();
|
||||
timeoutExists = false;
|
||||
});
|
||||
|
||||
client.on("room.message", (roomId, event) => {
|
||||
|
|
Loading…
Reference in a new issue