summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--commands.ts35
1 files changed, 35 insertions, 0 deletions
diff --git a/commands.ts b/commands.ts
index 2b7f8e7..2f5598f 100644
--- a/commands.ts
+++ b/commands.ts
@@ -81,8 +81,15 @@ export let slashCommands = [
),
handler: removeFromCtf,
},
+ {
+ slashCommand: new SlashCommandBuilder()
+ .setName("solve")
+ .setDescription("Mark this challenge as solved"),
+ handler: solveThread,
+ },
];
+
export let buttonCommands = {
join: {
prefix: "ctf-forum:",
@@ -277,6 +284,34 @@ async function removeFromCtf(interaction: ChatInputCommandInteraction) {
});
}
+async function solveThread(interaction: ChatInputCommandInteraction) {
+ if (!interaction.guild) {
+ await interaction.reply({
+ content: "This command can only be used inside a server.",
+ flags: "Ephemeral",
+ });
+ return;
+ }
+
+ let forum = await getCtfForum(interaction);
+ let channel = interaction.channel;
+
+ if (!channel || !channel.isThread()) {
+ await interaction.reply({
+ content: "This command can only be used inside a CTF forum thread.",
+ flags: "Ephemeral",
+ });
+ return;
+ }
+
+ let unsolvedTag = forum.availableTags?.find(tag => tag.name === "unsolved");
+ if (unsolvedTag && channel.appliedTags.includes(unsolvedTag.id)) {
+ await channel.setAppliedTags(channel.appliedTags.filter(tag => tag !== unsolvedTag.id));
+ }
+
+ await interaction.reply("<:club_mate:889629353934213210> 🎉");
+}
+
async function handleJoinCtfButton(interaction: ButtonInteraction, forumId: string) {
if (!interaction.guild) {
return await interaction.reply({