diff --git a/src/commands/capacity.ts b/src/commands/capacity.ts index 20a2391..77504b3 100644 --- a/src/commands/capacity.ts +++ b/src/commands/capacity.ts @@ -1,4 +1,4 @@ -import { Client, CommandInteraction, ApplicationCommandOptionType, MessageFlags } from 'discord.js' +import { Client, ChatInputCommandInteraction, ApplicationCommandOptionType, MessageFlags } from 'discord.js' import { openConfig, SlashCommand, UserCommand } from '../utils/index.js' export const Capacity: SlashCommand = { @@ -16,14 +16,14 @@ export const Capacity: SlashCommand = { ], // Query for message information and set the style - run: async (client: Client, interaction: CommandInteraction) => { + run: async (client: Client, interaction: ChatInputCommandInteraction) => { // fetch channel and message const channel = await client.channels.fetch(interaction.channelId) if (!channel || !UserCommand.includes(channel.type)) return // set state of bot chat features openConfig(`${interaction.user.username}-config.json`, interaction.commandName, - interaction.options.get('context-capacity')?.value + interaction.options.getNumber('context-capacity') ) interaction.reply({ diff --git a/src/commands/deleteModel.ts b/src/commands/deleteModel.ts index d1517db..5cc7c5b 100644 --- a/src/commands/deleteModel.ts +++ b/src/commands/deleteModel.ts @@ -1,4 +1,4 @@ -import { ApplicationCommandOptionType, Client, CommandInteraction, MessageFlags } from 'discord.js' +import { ApplicationCommandOptionType, ChatInputCommandInteraction, Client, CommandInteraction, MessageFlags } from 'discord.js' import { UserCommand, SlashCommand } from '../utils/index.js' import { ollama } from '../client.js' import { ModelResponse } from 'ollama' @@ -18,11 +18,10 @@ export const DeleteModel: SlashCommand = { ], // Delete Model locally stored - run: async (client: Client, interaction: CommandInteraction) => { + run: async (client: Client, interaction: ChatInputCommandInteraction) => { // defer reply to avoid timeout await interaction.deferReply() - const modelInput: string = interaction.options.get('model-name')!!.value as string - + const modelInput: string = interaction.options.getString('model-name') as string // fetch channel and message const channel = await client.channels.fetch(interaction.channelId) if (!channel || !UserCommand.includes(channel.type)) return diff --git a/src/commands/disable.ts b/src/commands/disable.ts index 6a5cb57..c599de9 100644 --- a/src/commands/disable.ts +++ b/src/commands/disable.ts @@ -1,4 +1,4 @@ -import { Client, CommandInteraction, ApplicationCommandOptionType, MessageFlags } from 'discord.js' +import { Client, ChatInputCommandInteraction, ApplicationCommandOptionType, MessageFlags } from 'discord.js' import { AdminCommand, openConfig, SlashCommand } from '../utils/index.js' export const Disable: SlashCommand = { @@ -16,7 +16,7 @@ export const Disable: SlashCommand = { ], // Query for message information and set the style - run: async (client: Client, interaction: CommandInteraction) => { + run: async (client: Client, interaction: ChatInputCommandInteraction) => { // fetch channel and message const channel = await client.channels.fetch(interaction.channelId) if (!channel || !AdminCommand.includes(channel.type)) return @@ -32,11 +32,11 @@ export const Disable: SlashCommand = { // set state of bot chat features openConfig(`${interaction.guildId}-config.json`, interaction.commandName, - interaction.options.get('enabled')?.value + interaction.options.getBoolean('enabled') ) interaction.reply({ - content: `${client.user?.username} is now **${interaction.options.get('enabled')?.value ? "enabled" : "disabled"}**.`, + content: `${client.user?.username} is now **${interaction.options.getBoolean('enabled') ? "enabled" : "disabled"}**.`, flags: MessageFlags.Ephemeral }) } diff --git a/src/commands/messageStream.ts b/src/commands/messageStream.ts index b66fc8f..b99081b 100644 --- a/src/commands/messageStream.ts +++ b/src/commands/messageStream.ts @@ -1,4 +1,4 @@ -import { ApplicationCommandOptionType, Client, CommandInteraction, MessageFlags } from 'discord.js' +import { ApplicationCommandOptionType, Client, ChatInputCommandInteraction, MessageFlags } from 'discord.js' import { openConfig, SlashCommand, UserCommand } from '../utils/index.js' export const MessageStream: SlashCommand = { @@ -16,18 +16,18 @@ export const MessageStream: SlashCommand = { ], // change preferences based on command - run: async (client: Client, interaction: CommandInteraction) => { + run: async (client: Client, interaction: ChatInputCommandInteraction) => { // verify channel const channel = await client.channels.fetch(interaction.channelId) if (!channel || !UserCommand.includes(channel.type)) return // save value to json and write to it openConfig(`${interaction.user.username}-config.json`, interaction.commandName, - interaction.options.get('stream')?.value + interaction.options.getBoolean('stream') ) interaction.reply({ - content: `Message streaming is now set to: \`${interaction.options.get('stream')?.value}\``, + content: `Message streaming is now set to: \`${interaction.options.getBoolean('stream')}\``, flags: MessageFlags.Ephemeral }) } diff --git a/src/commands/pullModel.ts b/src/commands/pullModel.ts index 2582d3f..7fb912c 100644 --- a/src/commands/pullModel.ts +++ b/src/commands/pullModel.ts @@ -1,4 +1,4 @@ -import { ApplicationCommandOptionType, Client, CommandInteraction, MessageFlags } from "discord.js" +import { ApplicationCommandOptionType, Client, ChatInputCommandInteraction, MessageFlags } from "discord.js" import { ollama } from "../client.js" import { ModelResponse } from "ollama" import { UserCommand, SlashCommand } from "../utils/index.js" @@ -18,10 +18,10 @@ export const PullModel: SlashCommand = { ], // Pull for model from Ollama library - run: async (client: Client, interaction: CommandInteraction) => { + run: async (client: Client, interaction: ChatInputCommandInteraction) => { // defer reply to avoid timeout await interaction.deferReply() - const modelInput: string = interaction.options.get('model-to-pull')!!.value as string + const modelInput: string = interaction.options.getString('model-to-pull') as string // fetch channel and message const channel = await client.channels.fetch(interaction.channelId) diff --git a/src/commands/switchModel.ts b/src/commands/switchModel.ts index ef74b85..eb4b2ef 100644 --- a/src/commands/switchModel.ts +++ b/src/commands/switchModel.ts @@ -1,4 +1,4 @@ -import { ApplicationCommandOptionType, Client, CommandInteraction } from "discord.js" +import { ApplicationCommandOptionType, Client, ChatInputCommandInteraction } from "discord.js" import { ollama } from "../client.js" import { ModelResponse } from "ollama" import { openConfig, UserCommand, SlashCommand } from "../utils/index.js" @@ -18,10 +18,10 @@ export const SwitchModel: SlashCommand = { ], // Switch user preferred model if available in local library - run: async (client: Client, interaction: CommandInteraction) => { + run: async (client: Client, interaction: ChatInputCommandInteraction) => { await interaction.deferReply() - const modelInput: string = interaction.options.get('model-to-use')!!.value as string + const modelInput: string = interaction.options.getString('model-to-use') as string // fetch channel and message const channel = await client.channels.fetch(interaction.channelId) diff --git a/src/utils/commands.ts b/src/utils/commands.ts index 42f119b..978858a 100644 --- a/src/utils/commands.ts +++ b/src/utils/commands.ts @@ -1,4 +1,4 @@ -import { CommandInteraction, ChatInputApplicationCommandData, Client, ApplicationCommandOption } from 'discord.js' +import { ChatInputCommandInteraction, ChatInputApplicationCommandData, Client, ApplicationCommandOption } from 'discord.js' /** * interface for how slash commands should be run @@ -6,7 +6,7 @@ import { CommandInteraction, ChatInputApplicationCommandData, Client, Applicatio export interface SlashCommand extends ChatInputApplicationCommandData { run: ( client: Client, - interaction: CommandInteraction, + interaction: ChatInputCommandInteraction, options?: ApplicationCommandOption[] ) => void }