Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
0-don committed Dec 27, 2024
2 parents 619a804 + 538a500 commit a9e0c43
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/events/JobCreate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { ArgsOf, Client } from "discordx";
import { Discord, On } from "discordx";
import { JOB_POST_REGEX } from "../lib/helpers.js";
import { DEV_BOARD_CHANNEL } from "../lib/constants.js";

@Discord()
export class MessageCreate {
private readonly JOB_CHANNEL_ID = DEV_BOARD_CHANNEL;

@On({ event: "messageCreate" })
async onMessage([message]: ArgsOf<"messageCreate">, client: Client) {
if (message.channelId !== this.JOB_CHANNEL_ID) return;
if (message.author.bot) return;

if (!JOB_POST_REGEX.test(message.content)) {
await message.delete();

try {
await message.author.send({
content: `Your post in the job board was deleted because it didn't follow the required format`
});
} catch {
console.log(`Couldn't send DM to ${message.author.tag}`);
}
}
}
}
3 changes: 3 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,6 @@ export const LEVEL_MESSAGES = {
"`ansible-playbook promote-to-principal.yml` ${user} deployment complete as ${role}!",
],
};

export const DEV_BOARD_CHANNEL = '1300427846342283436';
export const JOB_BOARD_CHANNEL = '1300427561704226867';
2 changes: 2 additions & 0 deletions src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { ChartConfiguration, ChartDataset } from "chart.js";
import { enUS } from "date-fns/locale";
import { TRANSLATOR } from "./constants.js";

export const JOB_POST_REGEX = /Project Title:[\s\S]*?(?=Project Description:|$)Project Description:[\s\S]*?(?=Required Skills:|$)Required Skills:[\s\S]*?(?=Budget Range:|$)Budget Range:[\s\S]*?(?=Timeline:|$)Timeline:[\s\S]*?(?=Contact Method:|$)Contact Method:[\s\S]*?(?=Additional Details:|$)Additional Details:[\s\S]*$/;

export function placementSuffix(i: number) {
var j = i % 10,
k = i % 100;
Expand Down

0 comments on commit a9e0c43

Please sign in to comment.