Skip to content

Commit 09030d0

Browse files
authored
Merge branch 'master' into patch-4
2 parents e17491c + dd55858 commit 09030d0

File tree

11 files changed

+372
-515
lines changed

11 files changed

+372
-515
lines changed

.env.example

Lines changed: 6 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,13 @@ 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=
23+
HELP_FORUM_OPEN_TAG=Open
24+
HELP_FORUM_RESOLVED_TAG=Resolved
2225

2326
# Time in milliseconds before !helper can be run
2427
TIME_BEFORE_HELPER_PING=

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
# 2022-12-16
2+
3+
- Remove `!close`, update `!helper` to include thread tags.
4+
15
# 2022-11-19
26

7+
- Removed `HELP_CATEGORY`, `GENERAL_HELP_CHANNEL` environment variables.
8+
- Added `HELP_FORUM_CHANNEL`, `HELP_REQUESTS_CHANNEL` environment variables.
9+
- Updated how to get help and how to give help channel content to not use embeds.
310
- Updated to Discord.js 14, removed Cookiecord to prevent future delays in updating versions.
411
- The bot will now react on the configured autorole messages to indicate available roles.
512
- Unhandled rejections will now only be ignored if `NODE_ENV` is set to `production`.

src/bot.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,19 @@ export class Bot {
7474
return botAdmins.includes(user.id);
7575
}
7676

77-
getTrustedMemberError(msg: Message) {
77+
isTrusted(msg: Message) {
7878
if (!msg.guild || !msg.member || !msg.channel.isTextBased()) {
79-
return ":warning: you can't use that command here.";
79+
return false;
8080
}
8181

8282
if (
8383
!msg.member.roles.cache.has(trustedRoleId) &&
8484
!msg.member.permissions.has('ManageMessages')
8585
) {
86-
return ":warning: you don't have permission to use that command.";
86+
return false;
8787
}
88+
89+
return true;
8890
}
8991

9092
async getTargetUser(msg: Message): Promise<User | undefined> {

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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ 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!;
23+
24+
export const helpForumOpenTagName = process.env.HELP_FORUM_OPEN_TAG!;
25+
export const helpForumResolvedTagName = process.env.HELP_FORUM_RESOLVED_TAG!;
2326

2427
export const trustedRoleId = process.env.TRUSTED_ROLE_ID!;
2528

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)