Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
DISCORD_TOKEN=
DISCORD_TOKEN=
CHANNEL_HONEY_POT=
1 change: 1 addition & 0 deletions domain/service/channelResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const fallbackChannelIds: Record<ChannelSlug, string> = {
[ChannelSlug.JOBS]: "876826576749215744",
[ChannelSlug.MODERATION]: "987719981443723266",
[ChannelSlug.QUESTIONS]: "1065751368809324634",
[ChannelSlug.HONEY_POT]: "",
};

export default class ChannelResolver {
Expand Down
22 changes: 20 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Client, Events, GatewayIntentBits, GuildMember, Message, Partials } from "discord.js";
import { Client, Events, GatewayIntentBits, Guild, GuildMember, Message, Partials } from "discord.js";
import * as dotenv from "dotenv";
import { CronJob } from "cron";
import SendWelcomeMessageUseCase from "./application/usecases/sendWelcomeMessageUseCase";
Expand All @@ -20,7 +20,7 @@ import CodewarsLeaderboardCommand from "./application/command/codewarsLeaderboar
import DontAskToAskCommand from "./application/command/dontAskToAskCommand";
import OnlyCodeQuestionsCommand from "./application/command/onlyCodeQuestionsCommand";
import AnonymousQuestionCommand from "./application/command/anonymousQuestionCommand";
import { Command } from "./types";
import { ChannelSlug, Command } from "./types";

dotenv.config();

Expand Down Expand Up @@ -62,6 +62,8 @@ const interactionResolver = new InteractionResolver({
questionTrackingService,
});

const honeyPotChannelId = channelResolver.getBySlug(ChannelSlug.HONEY_POT);

const checkForNewPosts = async () => {
loggerService.log("Checking for new posts on content aggregator...");

Expand Down Expand Up @@ -141,6 +143,22 @@ client.on(Events.MessageCreate, async (message: Message) => {
}
});

client.on(Events.MessageCreate, async (message: Message) => {
if (message.channelId !== honeyPotChannelId) return;
if (message.author.bot) return;
if (!message.member) return;
try {
loggerService.log(`Honeypot triggered by ${message.author.username} (${message.author.id})`);

await message.member?.ban({
reason: "Triggered honeypot channel",
deleteMessageSeconds: 60,
});
} catch (error: unknown) {
loggerService.log(error);
}
});

client.on(Events.InteractionCreate, async (interaction) => {
if (interaction.isButton()) {
await interactionResolver.resolveButtonInteraction(interaction);
Expand Down
1 change: 1 addition & 0 deletions types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export enum ChannelSlug {
JOBS = "JOBS",
MODERATION = "MODERATION",
QUESTIONS = "QUESTIONS",
HONEY_POT = "HONEY_POT",
}

export type CommandMessages = {
Expand Down
Loading