Files
discord-aidolls/src/commands/capacity.ts
Alex de413f90e1
Some checks failed
Builds / Discord-Node-Build (push) Has been cancelled
Builds / Discord-Ollama-Container-Build (push) Has been cancelled
Coverage / Discord-Node-Coverage (push) Has been cancelled
everything is broken yay
2025-05-21 07:18:28 -04:00

37 lines
1.3 KiB
TypeScript

import { Client, CommandInteraction, ApplicationCommandOptionType, MessageFlags } from 'discord.js'
import { openConfig, SlashCommand, UserCommand } from '../utils/index.js'
export const Capacity: SlashCommand = {
name: 'modify-capacity',
description: 'maximum amount messages bot will hold for context.',
options: [
{
name: 'context-capacity',
description: 'number of allowed messages to remember',
type: ApplicationCommandOptionType.Number,
required: true
}
],
run: async (client: Client, interaction: CommandInteraction) => {
const channel = await client.channels.fetch(interaction.channelId)
if (!channel || !UserCommand.includes(channel.type)) return
const capacity = interaction.options.get('context-capacity')?.value
if (typeof capacity !== 'number' || capacity <= 0) {
await interaction.reply({
content: 'Please provide a valid positive number for capacity.',
flags: MessageFlags.Ephemeral
})
return
}
await openConfig(`${interaction.user.id}-config.json`, 'modify-capacity', capacity)
await interaction.reply({
content: `Max message history is now set to \`${capacity}\`.`,
flags: MessageFlags.Ephemeral
})
}
}