Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions src/events/message_create/praise.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { type Message, TextChannel, ChannelType } from "discord.js";
import { WACKY_ROLE_ID } from "../../utils/consts";

const ENABLE_PATTERN = /wackity\s+hackity\s+praise\s+me/;
const DISABLE_PATTERN = /wackity\s+hackity\s+go\s+away/;
const ENABLE_PATTERNS = [
/wackity\s+hackity\s+praise\s+me/,
/clanke+r+\s+go\s+away/,
];
const DISABLE_PATTERNS = [
/wackity\s+hackity\s+go\s+away/,
/clanke+r+\s+praise\s+me/,
];

export default async function handler(message: Message) {
if (message.author.bot) return;
Expand All @@ -15,15 +21,23 @@ export default async function handler(message: Message) {
return;
if (message.member === null) return;

try {
if (message.content.match(ENABLE_PATTERN)) {
await message.member!.roles.add(WACKY_ROLE_ID);
await message.react("🥳");
} else if (message.content.match(DISABLE_PATTERN)) {
await message.member!.roles.remove(WACKY_ROLE_ID);
await message.react("🤐");
}
} catch (e) {
console.error(e);
}
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the rest of the code uses tabs instead of spaces.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zed reformatted the whole file and I didn't want to commit the style change lines as well :( I'm gonna make a new format commit once this is merged and push straight to main

for (const enable_pattern of ENABLE_PATTERNS) {
if (message.content.match(enable_pattern)) {
await message.member!.roles.add(WACKY_ROLE_ID);
await message.react("🥳");
return;
}
}

for (const disable_pattern of DISABLE_PATTERNS) {
if (message.content.match(disable_pattern)) {
await message.member!.roles.remove(WACKY_ROLE_ID);
await message.react("🤐");
return;
}
}
} catch (e) {
console.error(e);
}
}