From bb7610d46d09ac39004d2bf348c44a56f63c708c Mon Sep 17 00:00:00 2001 From: Robert Westbury Date: Fri, 2 Oct 2020 19:34:29 +0100 Subject: [PATCH 1/2] Fix rep --- src/modules/rep.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/modules/rep.ts b/src/modules/rep.ts index 0249b025..08883c68 100644 --- a/src/modules/rep.ts +++ b/src/modules/rep.ts @@ -20,7 +20,7 @@ export class RepModule extends Module { MAX_REP = 3; // all messages have to be fully lowercase - THANKS_MESSAGES = ['thanks', 'thx', 'cheers', 'thanx', 'ty', 'tks', 'tkx']; + THANKS_REGEX = /(?:thanks|thx|cheers|thanx|ty|tks|tkx)\b/; async getOrMakeUser(user: User) { let ru = await RepUser.findOne( @@ -42,9 +42,7 @@ export class RepModule extends Module { const NO_GIVE = '❌'; // Check for thanks messages - const isThanks = this.THANKS_MESSAGES.some(s => - msg.content.toLowerCase().includes(s), - ); + const isThanks = this.THANKS_REGEX.test(msg.content.toLowerCase()); if (msg.author.bot || !isThanks || !msg.guild) return; From e4e494d7526b5decea238780971abafcded7183d Mon Sep 17 00:00:00 2001 From: Robert Westbury Date: Fri, 2 Oct 2020 19:44:23 +0100 Subject: [PATCH 2/2] Use regex --- src/modules/rep.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/rep.ts b/src/modules/rep.ts index 08883c68..f4339bf7 100644 --- a/src/modules/rep.ts +++ b/src/modules/rep.ts @@ -20,7 +20,7 @@ export class RepModule extends Module { MAX_REP = 3; // all messages have to be fully lowercase - THANKS_REGEX = /(?:thanks|thx|cheers|thanx|ty|tks|tkx)\b/; + THANKS_REGEX = /(?:thanks|thx|cheers|thanx|ty|tks|tkx)\b/i; async getOrMakeUser(user: User) { let ru = await RepUser.findOne( @@ -42,7 +42,7 @@ export class RepModule extends Module { const NO_GIVE = '❌'; // Check for thanks messages - const isThanks = this.THANKS_REGEX.test(msg.content.toLowerCase()); + const isThanks = this.THANKS_REGEX.test(msg.content); if (msg.author.bot || !isThanks || !msg.guild) return;