Files
discord-ollama/src/commands/messageStream.ts
Kevin Dang 060494e883 Adjusted Slash Command Scope (#91)
* Update: Slash Command Scope

* Update: version increment
2024-07-31 06:19:23 -07:00

33 lines
1.3 KiB
TypeScript

import { ApplicationCommandOptionType, ChannelType, Client, CommandInteraction } from 'discord.js'
import { SlashCommand } from '../utils/commands.js'
import { openConfig } from '../utils/index.js'
export const MessageStream: SlashCommand = {
name: 'message-stream',
description: 'change preference on message streaming from ollama. WARNING: can be very slow.',
// user option(s) for setting stream
options: [
{
name: 'stream',
description: 'enable or disable stream preference',
type: ApplicationCommandOptionType.Boolean,
required: true
}
],
// change preferences based on command
run: async (client: Client, interaction: CommandInteraction) => {
// verify channel
const channel = await client.channels.fetch(interaction.channelId)
if (!channel || channel.type !== (ChannelType.PrivateThread && ChannelType.PublicThread && ChannelType.GuildText)) return
// save value to json and write to it
openConfig(`${interaction.user.username}-config.json`, interaction.commandName, interaction.options.get('stream')?.value)
interaction.reply({
content: `Message streaming preferences set to: \`${interaction.options.get('stream')?.value}\``,
ephemeral: true
})
}
}