mirror of
https://github.com/kevinthedang/discord-ollama.git
synced 2025-12-12 11:56:06 -05:00
33 lines
1.3 KiB
TypeScript
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
|
|
})
|
|
}
|
|
} |