Skip to content

Commit 8e83838

Browse files
authored
Merge pull request #165 from tjjfvi/threads
Use a thread based help system
2 parents 1eee34f + 3b0dcdd commit 8e83838

File tree

9 files changed

+394
-849
lines changed

9 files changed

+394
-849
lines changed

.env.example

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,11 @@ DATABASE_URL="localhost:5432/tsc-bot"
1111
# are not given to all server members.
1212
TRUSTED_ROLE_ID=
1313

14-
# Channel ID to direct users toward for an explanation of the help system.
15-
ASK_HELP_CHANNEL=
16-
1714
RULES_CHANNEL=
1815

19-
ASK_CATEGORY=
20-
ONGOING_CATEGORY=
21-
DORMANT_CATEGORY=
22-
23-
ASK_COOLDOWN_ROLE=
24-
25-
CHANNEL_NAMES=list,help,channel,names,here,seperated,by,commas
16+
HELP_CATEGORY=
17+
HOW_TO_GET_HELP_CHANNEL=
18+
GENERAL_HELP_CHANNEL=
2619

27-
# Following variables are in milliseconds
28-
DORMANT_CHANNEL_TIMEOUT=
29-
DORMANT_CHANNEL_LOOP=
30-
ONGOING_EMPTY_TIMEOUT=
20+
# Time in milliseconds before !helper can be run
3121
TIME_BEFORE_HELPER_PING=

src/db.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Connection, createConnection } from 'typeorm';
22
import { dbUrl } from './env';
33
import { RepUser } from './entities/RepUser';
44
import { RepGive } from './entities/RepGive';
5-
import { HelpUser } from './entities/HelpUser';
5+
import { HelpThread } from './entities/HelpThread';
66
import { Snippet } from './entities/Snippet';
77

88
let db: Connection | undefined;
@@ -27,7 +27,7 @@ export async function getDB() {
2727
url: dbUrl,
2828
synchronize: true,
2929
logging: false,
30-
entities: [RepUser, RepGive, HelpUser, Snippet],
30+
entities: [RepUser, RepGive, HelpThread, Snippet],
3131
...extraOpts,
3232
});
3333
console.log('Connected to DB');

src/entities/HelpThread.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { BaseEntity, Column, Entity, PrimaryColumn } from 'typeorm';
2+
3+
@Entity()
4+
export class HelpThread extends BaseEntity {
5+
@PrimaryColumn()
6+
threadId!: string;
7+
8+
@Column()
9+
ownerId!: string;
10+
11+
// When @helper was last pinged
12+
@Column({ nullable: true })
13+
helperTimestamp?: string;
14+
15+
// When the title was last set
16+
@Column({ nullable: true })
17+
titleSetTimestamp?: string;
18+
}

src/entities/HelpUser.ts

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

src/env.ts

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,19 @@ export const autorole = process.env.AUTOROLE!.split(',').map(x => {
1616

1717
export const dbUrl = process.env.DATABASE_URL!;
1818

19-
export const categories = {
20-
ask: process.env.ASK_CATEGORY!,
21-
ongoing: process.env.ONGOING_CATEGORY!,
22-
dormant: process.env.DORMANT_CATEGORY!,
23-
};
24-
25-
export const askCooldownRoleId = process.env.ASK_COOLDOWN_ROLE!;
19+
export const helpCategory = process.env.HELP_CATEGORY!;
20+
export const howToGetHelpChannel = process.env.HOW_TO_GET_HELP_CHANNEL!;
21+
export const generalHelpChannel = process.env.GENERAL_HELP_CHANNEL!;
2622

2723
export const trustedRoleId = process.env.TRUSTED_ROLE_ID!;
28-
export const askHelpChannelId = process.env.ASK_HELP_CHANNEL!;
2924

3025
export const rulesChannelId = process.env.RULES_CHANNEL!;
3126

32-
export const channelNames = process.env.CHANNEL_NAMES!.split(',');
33-
34-
export const dormantChannelTimeout = parseInt(
35-
process.env.DORMANT_CHANNEL_TIMEOUT!,
36-
);
37-
export const dormantChannelTimeoutHours =
38-
dormantChannelTimeout / 60 / 60 / 1000;
39-
export const dormantChannelLoop = parseInt(process.env.DORMANT_CHANNEL_LOOP!);
40-
41-
export const ongoingEmptyTimeout = parseInt(process.env.ONGOING_EMPTY_TIMEOUT!);
27+
export const TS_BLUE = '#007ACC';
28+
export const GREEN = '#3ba55d';
29+
// Picked from Discord's blockquote line
30+
export const BLOCKQUOTE_GREY = '#4f545c';
4231

4332
export const timeBeforeHelperPing = parseInt(
4433
process.env.TIME_BEFORE_HELPER_PING!,
4534
);
46-
47-
export const TS_BLUE = '#007ACC';
48-
export const GREEN = '#77b155';
49-
// Picked from Discord's "hourglass" emoji (in ⌛ | Occupied Help Channels)
50-
export const HOURGLASS_ORANGE = '#ffa647';
51-
// Picked from Discord's :ballot_box_with_check: emoji (☑)
52-
export const BALLOT_BOX_BLUE = '#066696';
53-
// Picked from Discord's blockquote line
54-
export const BLOCKQUOTE_GREY = '#4f545c';

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getDB } from './db';
55

66
import { AutoroleModule } from './modules/autorole';
77
import { EtcModule } from './modules/etc';
8-
import { HelpChanModule } from './modules/helpchan';
8+
import { HelpThreadModule } from './modules/helpthread';
99
import { PlaygroundModule } from './modules/playground';
1010
import { RepModule } from './modules/rep';
1111
import { TwoslashModule } from './modules/twoslash';
@@ -36,7 +36,7 @@ const client = new CookiecordClient(
3636
for (const mod of [
3737
AutoroleModule,
3838
EtcModule,
39-
HelpChanModule,
39+
HelpThreadModule,
4040
PlaygroundModule,
4141
RepModule,
4242
TwoslashModule,

0 commit comments

Comments
 (0)