From cd3c46deed49cd9ec383c45fbd187a4cbffacec2 Mon Sep 17 00:00:00 2001 From: array-in-a-matrix Date: Wed, 25 Oct 2023 21:50:21 -0400 Subject: [PATCH] counter error fixed --- example.count.json | 1 + index.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 example.count.json diff --git a/example.count.json b/example.count.json new file mode 100644 index 0000000..a29a98b --- /dev/null +++ b/example.count.json @@ -0,0 +1 @@ +{"count":{},"max":{"username":"","count":0}} \ No newline at end of file diff --git a/index.js b/index.js index 4959640..3e10910 100644 --- a/index.js +++ b/index.js @@ -33,11 +33,11 @@ const lbCommand = async (roomId, message) => { }; const countCommand = async (roomId, message) => { - client.replyNotice(roomId, message, `You said linux ${data.count[message.author.id]} times`) + client.replyNotice(roomId, message, `You said linux ${message["sender"]} times`) }; const addCount = async (roomId, message) => { - if (!(message["sender"] in data.count)) { //! TypeError: Cannot use 'in' operator to search for '@local:domain.tld' in undefined + if (!(message["sender"] in data.count)) { data.count[message["sender"]] = 0; } if (++data.count[message["sender"]] % 10 === 0) {