import { ChannelType, ChatInputCommandInteraction, CommandInteraction, MessageFlags, SlashCommandBuilder } from "discord.js"; import { breadthreadEnsureAutoLock, breadthreadRemoveAutoLock } from "../utilties/breadbot/breadthread"; import { db } from "../breadbot"; import { timeShorthandToSeconds } from "../utilties/time/conversions"; export const enabled: boolean = true export const data = new SlashCommandBuilder() .setName("breadthread") .setDescription("Manages Breadbot's extended thread features") .addSubcommand(subcommand => subcommand .setName("autolock") .setDescription("Enables auto locking of a thread after a period of thread inactivity") .addChannelOption(option => option .setName("channel") .setDescription("The name of the thread you want to autolock") .addChannelTypes( ChannelType.PublicThread, ChannelType.PrivateThread, ChannelType.AnnouncementThread ) .setRequired(true) ) .addBooleanOption(option => option .setName("enable") .setDescription("Enable or disable the auto locking") .setRequired(true) ) .addStringOption(option => option .setName("timeinactive") .setDescription("How long the thread needs to be inactive before locking, default is 3 days") .setRequired(false) ) ) export async function execute(interaction: ChatInputCommandInteraction) { await interaction.deferReply({flags: MessageFlags.Ephemeral}) if(interaction.options.getSubcommand() === "autolock") { if(interaction.options.getBoolean("enable")) { await breadthreadEnsureAutoLock( db, interaction.options.getChannel("channel", true).id, interaction.options.getString("timeinactive") ?? "3d" ) } else { await breadthreadRemoveAutoLock( db, interaction.options.getChannel("channel", true).id ) } await interaction.editReply("Autolock Action OK") } }