Skip to content

Commit e06270e

Browse files
committed
feat: add reopen command
1 parent ea7b573 commit e06270e

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export { default as close } from "./util/close.js";
2+
export { default as reopen } from "./util/reopen.js";
23

34
export { default as walkthrough } from "./util/walkthrough.js";

src/commands/util/close.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { config } from "@lib/config.js";
22

33
import { canUserInteractWithThread, getChannelFromInteraction, isHelpPost } from "@lib/channels.js";
44

5-
import { type ThreadChannel, type ChatInputCommandInteraction, MessageFlags, SlashCommandBuilder } from "discord.js";
5+
import { type ThreadChannel, MessageFlags, SlashCommandBuilder, type ChatInputCommandInteraction } from "discord.js";
66

77
// TODO: find a better way to do this
88
const getStateWord = (close) => close ? "closed" : "reopened";
99
const getStateVerb = (close) => close ? "close" : "reopene";
1010

11-
async function handleIssueState(interaction: ChatInputCommandInteraction, close = true, lock = false) {
11+
export async function handleIssueState(interaction: ChatInputCommandInteraction, close = true, lock = false) {
1212
const threadChannel = await getChannelFromInteraction(interaction) as ThreadChannel;
1313

1414
const stateWord = getStateWord(close);
@@ -56,7 +56,7 @@ async function handleIssueState(interaction: ChatInputCommandInteraction, close
5656
}
5757
}
5858

59-
async function handleIssueStateCommand(interaction: ChatInputCommandInteraction, close: boolean, lock: boolean = false) {
59+
export async function handleIssueStateCommand(interaction: ChatInputCommandInteraction, close: boolean, lock: boolean = false) {
6060
const interactionChannel = await getChannelFromInteraction(interaction);
6161
const stateVerb = getStateVerb(close);
6262

src/commands/util/reopen.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { handleIssueStateCommand } from "./close.js";
2+
3+
import { SlashCommandBuilder, type ChatInputCommandInteraction } from "discord.js";
4+
5+
export default {
6+
data: new SlashCommandBuilder()
7+
.setName("reopen")
8+
.setDescription("Reopens your post"),
9+
10+
execute: (interaction: ChatInputCommandInteraction) => handleIssueStateCommand(interaction, false, false)
11+
};

0 commit comments

Comments
 (0)