Skip to content

Commit 037fc68

Browse files
committed
Move help threads to a forum system
1 parent e250206 commit 037fc68

File tree

9 files changed

+350
-512
lines changed

9 files changed

+350
-512
lines changed

.env.example

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ BOT_ADMINS=123,456
55
AUTOROLE=MSG_ID:ROLE_ID:EMOJI:AUTOREMOVE
66
# Another example: AUTOROLE=738932146978160661:728202487672078368:❌:false,738932146978160661:738936540465725520:✅:true
77

8-
DATABASE_URL="localhost:5432/tsc-bot"
8+
DATABASE_URL="postgres://tscbot:tscbot@localhost:5432/tscbot"
99

1010
# Role given to trusted members, not full moderators, but can use some commands which
1111
# are not given to all server members.
@@ -15,10 +15,11 @@ RULES_CHANNEL=
1515

1616
ROLES_CHANNEL=
1717

18-
HELP_CATEGORY=
1918
HOW_TO_GET_HELP_CHANNEL=
2019
HOW_TO_GIVE_HELP_CHANNEL=
21-
GENERAL_HELP_CHANNEL=
20+
21+
HELP_FORUM_CHANNEL=
22+
HELP_REQUESTS_CHANNEL=
2223

2324
# Time in milliseconds before !helper can be run
2425
TIME_BEFORE_HELPER_PING=

src/entities/HelpThread.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@ export class HelpThread extends BaseEntity {
1212
@Column({ nullable: true })
1313
helperTimestamp?: string;
1414

15-
// When the title was last set
15+
/**
16+
* When the title was last set, exists only for backwards compat
17+
* @deprecated
18+
*/
1619
@Column({ nullable: true })
1720
titleSetTimestamp?: string;
1821

19-
// The id of the original message; nullable for backwards compat
22+
/**
23+
* The id of the original message, exists only for backwards compat
24+
* @deprecated
25+
*/
2026
@Column({ nullable: true })
2127
origMessageId?: string;
2228
}

src/env.ts

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

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

19-
export const helpCategory = process.env.HELP_CATEGORY!;
2019
export const howToGetHelpChannel = process.env.HOW_TO_GET_HELP_CHANNEL!;
2120
export const howToGiveHelpChannel = process.env.HOW_TO_GIVE_HELP_CHANNEL!;
22-
export const generalHelpChannel = process.env.GENERAL_HELP_CHANNEL!;
21+
export const helpForumChannel = process.env.HELP_FORUM_CHANNEL!;
22+
export const helpRequestsChannel = process.env.HELP_REQUESTS_CHANNEL!;
2323

2424
export const trustedRoleId = process.env.TRUSTED_ROLE_ID!;
2525

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { playgroundModule } from './modules/playground';
1313
import { repModule } from './modules/rep';
1414
import { twoslashModule } from './modules/twoslash';
1515
import { snippetModule } from './modules/snippet';
16-
import { helpThreadModule } from './modules/helpthread';
16+
import { helpForumModule } from './modules/helpForum';
1717

1818
const client = new Client({
1919
partials: [
@@ -45,7 +45,7 @@ client.on('ready', async () => {
4545
for (const mod of [
4646
autoroleModule,
4747
etcModule,
48-
helpThreadModule,
48+
helpForumModule,
4949
playgroundModule,
5050
repModule,
5151
twoslashModule,

src/log.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {
2-
Channel,
2+
BaseGuildTextChannel,
33
Client,
4-
GuildChannel,
54
GuildMember,
65
TextChannel,
6+
ThreadChannel,
77
User,
88
} from 'discord.js';
99
import { inspect } from 'util';
@@ -72,7 +72,11 @@ const inspectUser = (user: User) =>
7272
defineCustomUtilInspect(User, inspectUser);
7373
defineCustomUtilInspect(GuildMember, member => inspectUser(member.user));
7474

75-
defineCustomUtilInspect(
76-
GuildChannel,
77-
channel => `#${channel.name}/${(channel as Channel).id}`,
78-
);
75+
const channels: Array<{ prototype: { name: string; id: string } }> = [
76+
BaseGuildTextChannel,
77+
ThreadChannel,
78+
];
79+
80+
for (const ctor of channels) {
81+
defineCustomUtilInspect(ctor, channel => `#${channel.name}/${channel.id}`);
82+
}

0 commit comments

Comments
 (0)