37 lines
1.3 KiB
TypeScript
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
|
|
})
|
|
}
|
|
}
|