Skip to content

Commit 405ea59

Browse files
authored
Merge pull request #14 from kdkasad/praise
feat: use role-based opt-in system for ship/checkpoint praise
2 parents 3f30f20 + 97d46f4 commit 405ea59

File tree

4 files changed

+36
-14
lines changed

4 files changed

+36
-14
lines changed

src/events/message_create/auto-thread-channels.ts

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// loosely based on https://github.com/hackclub/scrappy
22
import { setTimeout } from "node:timers/promises";
33
import type { Message } from "discord.js";
4+
import { WACKY_ROLE_ID } from "../../utils/consts";
45

56
const SHIP_CHANNEL_ID = "904896819165814794";
67
const CHECKPOINTS_CHANNEL_ID = "1052236377338683514";
@@ -17,6 +18,7 @@ const CHECKPOINT_RESPONSE_MESSAGES = [
1718
"Awesome update! :D",
1819
"Yay thanks for sharing! :D",
1920
"Yippie!! Keep it up! :D",
21+
"Who up checking they point?",
2022
];
2123

2224
const SHIP_RESPONSE_MESSAGES = [
@@ -32,15 +34,6 @@ const SHIP_RESPONSE_MESSAGES = [
3234
"Boom, nice ship! :D",
3335
];
3436

35-
const CHECKPOINTS_MESSAGE_OPT_IN_USERS = [
36-
"753840846549418024", // kian
37-
];
38-
39-
const SHIP_MESSAGE_OPT_IN_USERS = [
40-
"753840846549418024", // kian
41-
"636701123620634653", // ray
42-
];
43-
4437
export default async function handler(message: Message) {
4538
if (message.author.bot) return;
4639
if (message.channel.isDMBased()) return;
@@ -98,9 +91,7 @@ Cheers! ^•^`;
9891
});
9992

10093
if (message.channelId === CHECKPOINTS_CHANNEL_ID) {
101-
// NOTE: a couple people didn't like this, so it's opt-in.
102-
// can add it back if people come around to it :3
103-
if (CHECKPOINTS_MESSAGE_OPT_IN_USERS.includes(message.author.id)) {
94+
if (message.member?.roles.cache.has(WACKY_ROLE_ID)) {
10495
await Promise.all([
10596
message.react("🎉"),
10697
message.react("✨"),
@@ -117,8 +108,7 @@ Cheers! ^•^`;
117108
}
118109

119110
if (message.channelId === SHIP_CHANNEL_ID) {
120-
// Keep sending messages for some, we still love you Wack Hacker </3
121-
if (SHIP_MESSAGE_OPT_IN_USERS.includes(message.author.id)) {
111+
if (message.member?.roles.cache.has(WACKY_ROLE_ID)) {
122112
await Promise.all([
123113
message.react("🎉"),
124114
message.react("✨"),

src/events/message_create/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import grok from "./grok";
77
import hackNightImages from "./hack-night-images";
88
import voiceMessageTranscription from "./voice-transcription";
99
import welcomer from "./welcomer";
10+
import praise from "./praise";
1011

1112
export const eventType = Events.MessageCreate;
1213
export {
@@ -17,4 +18,5 @@ export {
1718
welcomer,
1819
grok,
1920
hackNightImages,
21+
praise,
2022
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { type Message, TextChannel, ChannelType } from "discord.js";
2+
import { WACKY_ROLE_ID } from "../../utils/consts";
3+
4+
const ENABLE_PATTERN = /wackity\s+hackity\s+praise\s+me/;
5+
const DISABLE_PATTERN = /wackity\s+hackity\s+go\s+away/;
6+
7+
export default async function handler(message: Message) {
8+
if (message.author.bot) return;
9+
if (
10+
!(
11+
message.channel.type == ChannelType.GuildText ||
12+
message.channel.type == ChannelType.PublicThread
13+
)
14+
)
15+
return;
16+
if (message.member === null) return;
17+
18+
try {
19+
if (message.content.match(ENABLE_PATTERN)) {
20+
await message.member!.roles.add(WACKY_ROLE_ID);
21+
await message.react("🥳");
22+
} else if (message.content.match(DISABLE_PATTERN)) {
23+
await message.member!.roles.remove(WACKY_ROLE_ID);
24+
await message.react("🤐");
25+
}
26+
} catch (e) {
27+
console.error(e);
28+
}
29+
}

src/utils/consts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ export const INTERNAL_CATEGORIES = [
1111
"1082077318329143336",
1212
"938975633885782037",
1313
];
14+
export const WACKY_ROLE_ID = "1419119560627458129";

0 commit comments

Comments
 (0)