Skip to content

Commit

Permalink
Add initial message to #looking-for-group (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
vcarl authored Oct 3, 2024
1 parent a5a531c commit 855e9ee
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/constants/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const LOCAL_CHANNELS: Record<keyof typeof PRODUCTION_CHANNELS, string> = {
thanks: "926931785219207301",
jobBoard: "925847361996095509",
resumeReview: "1166075559172907008",
lookingForGroup: "1166085100493078590",
jobsLog: "925847644318879754",
events: "950790520811184150",
iBuiltThis: "950790520811184150",
Expand All @@ -30,6 +31,7 @@ const PRODUCTION_CHANNELS = {
thanks: "798567961468076072",
jobBoard: "103882387330457600",
resumeReview: "955507127877791795",
lookingForGroup: "1255898446158757939",
jobsLog: "989201828572954694",
events: "127442949435817984",
iBuiltThis: "312761588778139658",
Expand Down
76 changes: 76 additions & 0 deletions src/features/looking-for-group.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import {
Client,
EmbedType,
InteractionType,
ComponentType,
ChannelType,
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
} from "discord.js";
import { CHANNELS } from "../constants/channels";
import { EMBED_COLOR } from "./commands";

const LOCK_POST = "lock-post";

export const lookingForGroup = async (bot: Client) => {
bot.on("interactionCreate", async (interaction) => {
if (
interaction.type !== InteractionType.MessageComponent ||
interaction.componentType !== ComponentType.Button ||
!interaction.channel ||
interaction.channel.type !== ChannelType.PublicThread ||
interaction.channel.parentId !== CHANNELS.lookingForGroup
) {
return;
}

if (interaction.user.id !== interaction.channel.ownerId) {
interaction.reply({
ephemeral: true,
content:
"This is not your thread! These interactions can only be used by the original poster.",
});
return;
}

if (interaction.customId === LOCK_POST) {
await interaction.reply(
"This post has been locked at the request of the post author",
);
await interaction.channel.setLocked(true);
}
});
bot.on("threadCreate", async (thread) => {
console.log("create");
if (thread.parentId !== CHANNELS.lookingForGroup) {
return;
}

await thread.send({
embeds: [
{
title: "Looking For Group",
type: EmbedType.Rich,
description: `Projects in this space must be open source licensed and may not be commercially monetized — this is a place for enthusiastic collaboration, and anyone found to be exploiting in any manner, especially for free labor, will be moderatated as a hostile actor.
Please do not routinely re-post your own skills. This is a forum, not a chat channel, prefer to bump your old post by replying to it (maybe with an update about what you've been working on?)
Reactiflux moderators cannot moderate behavior outside of the public channels. If you suspect someone is taking advantage of your generosity, block and move on. Before you accuse someone of being a bot or scammer, though, consider if there might be a language and cultural barrier.
Post authors: Once you've found collaborators or a project to contribute to, please lock your post to indicate that you're no longer seeking responses 🙏`,
color: EMBED_COLOR,
},
],
components: [
// @ts-expect-error Discord.js types appear to be wrong
new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId(LOCK_POST)
.setLabel("Lock post")
.setStyle(ButtonStyle.Danger),
),
],
});
});
};
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { logger, channelLog } from "./features/log";
// import codeblock from './features/codeblock';
import jobsMod, { resetJobCacheCommand } from "./features/jobs-moderation";
import { resumeResources } from "./features/resume";
import { lookingForGroup } from "./features/looking-for-group";
import autoban from "./features/autoban";
import commands from "./features/commands";
import setupStats from "./features/stats";
Expand Down Expand Up @@ -208,6 +209,7 @@ bot.on("ready", () => {
deployCommands(bot);
jobsMod(bot);
resumeResources(bot);
lookingForGroup(bot);
voiceActivity(bot);
modActivity(bot);
debugEventButtonHandler(bot);
Expand Down

0 comments on commit 855e9ee

Please sign in to comment.