* Add: skeleton suite for command tests (#119) * test naming updated * fix imports, remove old references * added code coverage badge * Add: coverage environment * Fix: Readme hyperlink to coverage workflow * grab coverage pct from env * Update: gist hyperlink * color range on coverage * fix contributing, simplify coverage assessment * lmiit coverage to master, add branch naming conventions --------- Co-authored-by: Kevin Dang <77701718+kevinthedang@users.noreply.github.com>
32 lines
1.3 KiB
TypeScript
32 lines
1.3 KiB
TypeScript
import { ChannelType, Client, CommandInteraction, ApplicationCommandOptionType } from 'discord.js'
|
|
import { openConfig, SlashCommand } from '../utils/index.js'
|
|
|
|
export const Capacity: SlashCommand = {
|
|
name: 'modify-capacity',
|
|
description: 'number of messages bot will hold for context.',
|
|
|
|
// set available user options to pass to the command
|
|
options: [
|
|
{
|
|
name: 'context-capacity',
|
|
description: 'a number to set capacity',
|
|
type: ApplicationCommandOptionType.Number,
|
|
required: true
|
|
}
|
|
],
|
|
|
|
// Query for message information and set the style
|
|
run: async (client: Client, interaction: CommandInteraction) => {
|
|
// fetch channel and message
|
|
const channel = await client.channels.fetch(interaction.channelId)
|
|
if (!channel || channel.type !== (ChannelType.PrivateThread && ChannelType.PublicThread && ChannelType.GuildText)) return
|
|
|
|
// set state of bot chat features
|
|
openConfig(`${interaction.user.username}-config.json`, interaction.commandName, interaction.options.get('context-capacity')?.value)
|
|
|
|
interaction.reply({
|
|
content: `Message History Capacity has been set to \`${interaction.options.get('context-capacity')?.value}\``,
|
|
ephemeral: true
|
|
})
|
|
}
|
|
} |