mirror of
https://github.com/kevinthedang/discord-ollama.git
synced 2026-06-20 13:57:24 -04:00
* fix: upgrade discord.js from 14.18.0 to 14.19.3 Snyk has created this PR to upgrade discord.js from 14.18.0 to 14.19.3. See this package in npm: discord.js See this project in Snyk: https://app.snyk.io/org/jt2m0l3y/project/d8b070a3-e4a3-457a-977b-7eb6a4a48346?utm_source=github&utm_medium=referral&page=upgrade-pr * Update: discordjs to latest * Fix: Broken commands * Fix: Ollama offline failsafes trigger --------- Co-authored-by: snyk-bot <snyk-bot@snyk.io> Co-authored-by: Kevin Dang <kevinthedang_1@outlook.com>
43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
import { Client, ChatInputCommandInteraction, ApplicationCommandOptionType, MessageFlags } from 'discord.js'
|
|
import { AdminCommand, openConfig, SlashCommand } from '../utils/index.js'
|
|
|
|
export const Disable: SlashCommand = {
|
|
name: 'toggle-chat',
|
|
description: 'toggle all chat features. Adminstrator Only.',
|
|
|
|
// set available user options to pass to the command
|
|
options: [
|
|
{
|
|
name: 'enabled',
|
|
description: 'true = enabled, false = disabled',
|
|
type: ApplicationCommandOptionType.Boolean,
|
|
required: true
|
|
}
|
|
],
|
|
|
|
// Query for message information and set the style
|
|
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
|
|
|
|
// check if runner is an admin
|
|
if (!interaction.memberPermissions?.has('Administrator')) {
|
|
interaction.reply({
|
|
content: `${interaction.commandName} is an admin command.\n\nPlease contact an admin to use this command for you.`,
|
|
flags: MessageFlags.Ephemeral
|
|
})
|
|
return
|
|
}
|
|
|
|
// set state of bot chat features
|
|
openConfig(`${interaction.guildId}-config.json`, interaction.commandName,
|
|
interaction.options.getBoolean('enabled')
|
|
)
|
|
|
|
interaction.reply({
|
|
content: `${client.user?.username} is now **${interaction.options.getBoolean('enabled') ? "enabled" : "disabled"}**.`,
|
|
flags: MessageFlags.Ephemeral
|
|
})
|
|
}
|
|
} |