Skip to content

Commit 6986ac1

Browse files
authored
Merge branch 'master' into master
2 parents be9a8e0 + 65dc3e5 commit 6986ac1

File tree

4 files changed

+22
-27
lines changed

4 files changed

+22
-27
lines changed

src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { AutoroleModule } from './modules/autorole';
77
import { EtcModule } from './modules/etc';
88
import { HelpChanModule } from './modules/helpchan';
99
import { PlaygroundModule } from './modules/playground';
10-
import { PollModule } from './modules/poll';
1110
import { ReminderModule } from './modules/reminders';
1211
import { RepModule } from './modules/rep';
1312
import { TwoslashModule } from './modules/twoslash';
@@ -29,7 +28,6 @@ for (const mod of [
2928
EtcModule,
3029
HelpChanModule,
3130
PlaygroundModule,
32-
PollModule,
3331
ReminderModule,
3432
RepModule,
3533
TwoslashModule,

src/modules/etc.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { command, default as CookiecordClient, Module } from 'cookiecord';
1+
import {
2+
command,
3+
default as CookiecordClient,
4+
Module,
5+
listener,
6+
} from 'cookiecord';
27
import { Message } from 'discord.js';
38

49
export class EtcModule extends Module {
@@ -25,4 +30,13 @@ export class EtcModule extends Module {
2530
'https://github.com/facebook/create-react-app/pull/8177#issue-353062710',
2631
);
2732
}
33+
34+
@listener({ event: 'message' })
35+
async onMessage(msg: Message) {
36+
if (msg.author.bot || !msg.content.toLowerCase().startsWith('poll:'))
37+
return;
38+
await msg.react('✅');
39+
await msg.react('❌');
40+
await msg.react('🤷');
41+
}
2842
}

src/modules/poll.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/modules/rep.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
} from 'cookiecord';
88
import { GuildMember, Message, MessageEmbed, User } from 'discord.js';
99
import prettyMilliseconds from 'pretty-ms';
10-
import { getDB } from '../db';
1110
import { TS_BLUE } from '../env';
1211

1312
import { RepGive } from '../entities/RepGive';
@@ -17,11 +16,13 @@ export class RepModule extends Module {
1716
constructor(client: CookiecordClient) {
1817
super(client);
1918
}
19+
2020
MAX_REP = 3;
2121

22-
async getOrMakeUser(user: User) {
23-
const db = await getDB();
22+
// all messages have to be fully lowercase
23+
THANKS_REGEX = /(?:thanks|thx|cheers|thanx|ty|tks|tkx)\b/i;
2424

25+
async getOrMakeUser(user: User) {
2526
let ru = await RepUser.findOne(
2627
{ id: user.id },
2728
{ relations: ['got', 'given'] },
@@ -40,11 +41,10 @@ export class RepModule extends Module {
4041
const PARTIAL_GIVE = '🤔';
4142
const NO_GIVE = '❌';
4243

43-
// Check for thanks or thx
44-
const THANKS_REGEX = /(thanks|thx)+/gi;
45-
const exec = THANKS_REGEX.exec(msg.content);
44+
// Check for thanks messages
45+
const isThanks = this.THANKS_REGEX.test(msg.content);
4646

47-
if (msg.author.bot || !exec || !msg.guild) return;
47+
if (msg.author.bot || !isThanks || !msg.guild) return;
4848

4949
const mentionUsers = msg.mentions.users.array();
5050
if (!mentionUsers.length) return;

0 commit comments

Comments
 (0)