fixed borken whatever

This commit is contained in:
array-in-a-matrix 2023-10-29 14:44:15 -04:00
parent 27d46b35a9
commit a1f2ac3a39

View file

@ -33,7 +33,23 @@ const lbCommand = async (roomId, message) => {
};
const countCommand = async (roomId, message) => {
client.replyNotice(roomId, message, `You said linux ${data.count[message["sender"]]} times!`)
let count = data.count[message["sender"]]
if(isNaN(count)){
client.replyNotice(roomId, message, `You did not say linux.`)
return;
};
//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 addCount = async (roomId, message) => {
@ -78,6 +94,14 @@ client.on("room.message", (roomId, event) => {
}
if (event["content"]["body"].match(/l*.i.*n.*u.*x/gi)){
addCount(roomId, event);
//? broken mess i will fix after i eat i think
// client.sendEvent(roomId, "m.reaction" ({
// "m.relates_to": {
// "event_id":event["event_id"],
// "key":data.count[message["sender"]],
// "rel_type": "m.annotation"
// }
// }))
}
})