From 4a8f33528aeef57890c2f125b576b60e5bd648b8 Mon Sep 17 00:00:00 2001 From: array-in-a-matrix Date: Mon, 6 Nov 2023 13:35:07 -0500 Subject: [PATCH] cleanned up code + fixed message undefined bug --- index.js | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/index.js b/index.js index b39104a..e3a0ac0 100644 --- a/index.js +++ b/index.js @@ -37,19 +37,13 @@ const countCommand = async (roomId, message) => { let count = data.count[message["sender"]] if(isNaN(count)){ - client.replyNotice(roomId, message, `You did not say linux.`) - return; + client.replyNotice(roomId, message, `You did not say linux.`); + } else if(count === 1){ + client.replyNotice(roomId, message, `You said linux 1 time!`); + } else { + client.replyNotice(roomId, message, `You said linux ${count} times!`); }; - //prevent undefined/NaN - switch(count){ - case 1: - client.replyNotice(roomId, message, `You said linux 1 time!`) - break; - default: - client.replyNotice(roomId, message, `You said linux ${count} times!`) - break; - } }; const addReaction = async (roomId, message) => { @@ -77,6 +71,7 @@ const addCount = async (roomId, message) => { }; AutojoinRoomsMixin.setupOnClient(client); +client.addPreprocessor(new RichRepliesPreprocessor(false)); client.start().then(() => { clearTimeout(error1); // console.log(`Logged into ${client.guilds.cache.size} rooms`); // ? this is possible i think idk how tho @@ -94,13 +89,6 @@ client.on("room.message", (roomId, event) => { } if (event["content"]["body"].match(/l*.i.*n.*u.*x/gi)){ addCount(roomId, event); - client.sendEvent(roomId, "m.reaction" ({ - "m.relates_to": { - "event_id":event["event_id"], - "key":data.count[message["sender"]], - "rel_type": "m.annotation" - } - })) } })