mirror of
https://github.com/kevinthedang/discord-ollama.git
synced 2025-12-12 11:56:06 -05:00
Fix: Broken commands
This commit is contained in:
@@ -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'
|
import { openConfig, SlashCommand, UserCommand } from '../utils/index.js'
|
||||||
|
|
||||||
export const Capacity: SlashCommand = {
|
export const Capacity: SlashCommand = {
|
||||||
@@ -16,14 +16,14 @@ export const Capacity: SlashCommand = {
|
|||||||
],
|
],
|
||||||
|
|
||||||
// Query for message information and set the style
|
// Query for message information and set the style
|
||||||
run: async (client: Client, interaction: CommandInteraction) => {
|
run: async (client: Client, interaction: ChatInputCommandInteraction) => {
|
||||||
// fetch channel and message
|
// fetch channel and message
|
||||||
const channel = await client.channels.fetch(interaction.channelId)
|
const channel = await client.channels.fetch(interaction.channelId)
|
||||||
if (!channel || !UserCommand.includes(channel.type)) return
|
if (!channel || !UserCommand.includes(channel.type)) return
|
||||||
|
|
||||||
// set state of bot chat features
|
// set state of bot chat features
|
||||||
openConfig(`${interaction.user.username}-config.json`, interaction.commandName,
|
openConfig(`${interaction.user.username}-config.json`, interaction.commandName,
|
||||||
interaction.options.get('context-capacity')?.value
|
interaction.options.getNumber('context-capacity')
|
||||||
)
|
)
|
||||||
|
|
||||||
interaction.reply({
|
interaction.reply({
|
||||||
|
|||||||
@@ -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 { UserCommand, SlashCommand } from '../utils/index.js'
|
||||||
import { ollama } from '../client.js'
|
import { ollama } from '../client.js'
|
||||||
import { ModelResponse } from 'ollama'
|
import { ModelResponse } from 'ollama'
|
||||||
@@ -18,11 +18,10 @@ export const DeleteModel: SlashCommand = {
|
|||||||
],
|
],
|
||||||
|
|
||||||
// Delete Model locally stored
|
// Delete Model locally stored
|
||||||
run: async (client: Client, interaction: CommandInteraction) => {
|
run: async (client: Client, interaction: ChatInputCommandInteraction) => {
|
||||||
// defer reply to avoid timeout
|
// defer reply to avoid timeout
|
||||||
await interaction.deferReply()
|
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
|
// fetch channel and message
|
||||||
const channel = await client.channels.fetch(interaction.channelId)
|
const channel = await client.channels.fetch(interaction.channelId)
|
||||||
if (!channel || !UserCommand.includes(channel.type)) return
|
if (!channel || !UserCommand.includes(channel.type)) return
|
||||||
|
|||||||
@@ -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'
|
import { AdminCommand, openConfig, SlashCommand } from '../utils/index.js'
|
||||||
|
|
||||||
export const Disable: SlashCommand = {
|
export const Disable: SlashCommand = {
|
||||||
@@ -16,7 +16,7 @@ export const Disable: SlashCommand = {
|
|||||||
],
|
],
|
||||||
|
|
||||||
// Query for message information and set the style
|
// Query for message information and set the style
|
||||||
run: async (client: Client, interaction: CommandInteraction) => {
|
run: async (client: Client, interaction: ChatInputCommandInteraction) => {
|
||||||
// fetch channel and message
|
// fetch channel and message
|
||||||
const channel = await client.channels.fetch(interaction.channelId)
|
const channel = await client.channels.fetch(interaction.channelId)
|
||||||
if (!channel || !AdminCommand.includes(channel.type)) return
|
if (!channel || !AdminCommand.includes(channel.type)) return
|
||||||
@@ -32,11 +32,11 @@ export const Disable: SlashCommand = {
|
|||||||
|
|
||||||
// set state of bot chat features
|
// set state of bot chat features
|
||||||
openConfig(`${interaction.guildId}-config.json`, interaction.commandName,
|
openConfig(`${interaction.guildId}-config.json`, interaction.commandName,
|
||||||
interaction.options.get('enabled')?.value
|
interaction.options.getBoolean('enabled')
|
||||||
)
|
)
|
||||||
|
|
||||||
interaction.reply({
|
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
|
flags: MessageFlags.Ephemeral
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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'
|
import { openConfig, SlashCommand, UserCommand } from '../utils/index.js'
|
||||||
|
|
||||||
export const MessageStream: SlashCommand = {
|
export const MessageStream: SlashCommand = {
|
||||||
@@ -16,18 +16,18 @@ export const MessageStream: SlashCommand = {
|
|||||||
],
|
],
|
||||||
|
|
||||||
// change preferences based on command
|
// change preferences based on command
|
||||||
run: async (client: Client, interaction: CommandInteraction) => {
|
run: async (client: Client, interaction: ChatInputCommandInteraction) => {
|
||||||
// verify channel
|
// verify channel
|
||||||
const channel = await client.channels.fetch(interaction.channelId)
|
const channel = await client.channels.fetch(interaction.channelId)
|
||||||
if (!channel || !UserCommand.includes(channel.type)) return
|
if (!channel || !UserCommand.includes(channel.type)) return
|
||||||
|
|
||||||
// save value to json and write to it
|
// save value to json and write to it
|
||||||
openConfig(`${interaction.user.username}-config.json`, interaction.commandName,
|
openConfig(`${interaction.user.username}-config.json`, interaction.commandName,
|
||||||
interaction.options.get('stream')?.value
|
interaction.options.getBoolean('stream')
|
||||||
)
|
)
|
||||||
|
|
||||||
interaction.reply({
|
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
|
flags: MessageFlags.Ephemeral
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 { ollama } from "../client.js"
|
||||||
import { ModelResponse } from "ollama"
|
import { ModelResponse } from "ollama"
|
||||||
import { UserCommand, SlashCommand } from "../utils/index.js"
|
import { UserCommand, SlashCommand } from "../utils/index.js"
|
||||||
@@ -18,10 +18,10 @@ export const PullModel: SlashCommand = {
|
|||||||
],
|
],
|
||||||
|
|
||||||
// Pull for model from Ollama library
|
// Pull for model from Ollama library
|
||||||
run: async (client: Client, interaction: CommandInteraction) => {
|
run: async (client: Client, interaction: ChatInputCommandInteraction) => {
|
||||||
// defer reply to avoid timeout
|
// defer reply to avoid timeout
|
||||||
await interaction.deferReply()
|
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
|
// fetch channel and message
|
||||||
const channel = await client.channels.fetch(interaction.channelId)
|
const channel = await client.channels.fetch(interaction.channelId)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ApplicationCommandOptionType, Client, CommandInteraction } from "discord.js"
|
import { ApplicationCommandOptionType, Client, ChatInputCommandInteraction } from "discord.js"
|
||||||
import { ollama } from "../client.js"
|
import { ollama } from "../client.js"
|
||||||
import { ModelResponse } from "ollama"
|
import { ModelResponse } from "ollama"
|
||||||
import { openConfig, UserCommand, SlashCommand } from "../utils/index.js"
|
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
|
// Switch user preferred model if available in local library
|
||||||
run: async (client: Client, interaction: CommandInteraction) => {
|
run: async (client: Client, interaction: ChatInputCommandInteraction) => {
|
||||||
await interaction.deferReply()
|
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
|
// fetch channel and message
|
||||||
const channel = await client.channels.fetch(interaction.channelId)
|
const channel = await client.channels.fetch(interaction.channelId)
|
||||||
|
|||||||
@@ -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
|
* interface for how slash commands should be run
|
||||||
@@ -6,7 +6,7 @@ import { CommandInteraction, ChatInputApplicationCommandData, Client, Applicatio
|
|||||||
export interface SlashCommand extends ChatInputApplicationCommandData {
|
export interface SlashCommand extends ChatInputApplicationCommandData {
|
||||||
run: (
|
run: (
|
||||||
client: Client,
|
client: Client,
|
||||||
interaction: CommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
options?: ApplicationCommandOption[]
|
options?: ApplicationCommandOption[]
|
||||||
) => void
|
) => void
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user