diff --git a/src/constants/channels.ts b/src/constants/channels.ts index 837a4d7e..052c8a87 100644 --- a/src/constants/channels.ts +++ b/src/constants/channels.ts @@ -10,6 +10,7 @@ const LOCAL_CHANNELS: Record = { thanks: "926931785219207301", jobBoard: "925847361996095509", resumeReview: "1166075559172907008", + lookingForGroup: "1166085100493078590", jobsLog: "925847644318879754", events: "950790520811184150", iBuiltThis: "950790520811184150", @@ -30,6 +31,7 @@ const PRODUCTION_CHANNELS = { thanks: "798567961468076072", jobBoard: "103882387330457600", resumeReview: "955507127877791795", + lookingForGroup: "1255898446158757939", jobsLog: "989201828572954694", events: "127442949435817984", iBuiltThis: "312761588778139658", diff --git a/src/features/looking-for-group.ts b/src/features/looking-for-group.ts new file mode 100644 index 00000000..754f7811 --- /dev/null +++ b/src/features/looking-for-group.ts @@ -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), + ), + ], + }); + }); +}; diff --git a/src/index.ts b/src/index.ts index 77926cbe..cda3db81 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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"; @@ -208,6 +209,7 @@ bot.on("ready", () => { deployCommands(bot); jobsMod(bot); resumeResources(bot); + lookingForGroup(bot); voiceActivity(bot); modActivity(bot); debugEventButtonHandler(bot);