diff options
| author | Mathias Magnusson <mathias@magnusson.space> | 2026-01-17 02:13:33 +0100 |
|---|---|---|
| committer | Mathias Magnusson <mathias@magnusson.space> | 2026-01-17 02:16:11 +0100 |
| commit | 47f1cef7c50c06de38d9b24c2579e8f8183dae23 (patch) | |
| tree | 95e25d984149a05edf646c8e1b7e85502643116c | |
| parent | df1015e9bb1a457acc99ac62b89f17146f9092ab (diff) | |
| download | challe-anka-47f1cef7c50c06de38d9b24c2579e8f8183dae23.tar.gz | |
add a /solve command
| -rw-r--r-- | commands.ts | 35 |
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({ |
