mirror of
https://github.com/kevinthedang/discord-ollama.git
synced 2025-12-12 11:56:06 -05:00
34 lines
1.3 KiB
TypeScript
34 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 ChannelToggle: SlashCommand = {
|
|
name: 'channel-toggle',
|
|
description: 'toggles channel or thread usage.',
|
|
|
|
// set user option for toggling
|
|
options: [
|
|
{
|
|
name: 'toggle-channel',
|
|
description: 'toggle channel usage, otherwise threads',
|
|
type: ApplicationCommandOptionType.Boolean,
|
|
required: true
|
|
}
|
|
],
|
|
|
|
// Query for chatting preference
|
|
run: async (client: Client, interaction: CommandInteraction) => {
|
|
// fetch channel location
|
|
const channel = await client.channels.fetch(interaction.channelId)
|
|
if (!channel || channel.type !== (ChannelType.PrivateThread && ChannelType.PublicThread && ChannelType.GuildText)) return
|
|
|
|
// set state of bot channel preferences
|
|
openConfig(`${interaction.guildId}-config.json`, interaction.commandName, interaction.options.get('toggle-channel')?.value)
|
|
|
|
interaction.reply({
|
|
content: `Channel Preferences have for Regular Channels set to \`${interaction.options.get('toggle-channel')?.value}\``,
|
|
ephemeral: true
|
|
})
|
|
}
|
|
}
|