import { sendInteractionResponse, SlashCommandOptions } from "@wackford/mod.ts"; import { ApplicationCommandOptionTypes } from "@wackford/discordeno.ts"; import { AIs, checkAI } from "../ai/index.ts"; import { db } from "../database.ts"; import { sendInteractionLog } from "../socket.ts"; export default { name: "change", description: "shows the current name and description of the chatbot", options: [ { name: "name", description: "sets the name of the bot to this value", type: ApplicationCommandOptionTypes.String, }, { name: "description", description: "sets the description of the bot to this value", type: ApplicationCommandOptionTypes.String, }, ], execute: async (bot, interaction, args) => { const channelId = interaction?.channelId?.toString() as string; const AI = AIs[channelId]; const newName = args?.name?.value?.toString() ?? undefined; const newDesc = args?.description?.value?.toString() ?? undefined; if (!checkAI(bot, interaction, AI)) return; AI.changeShit({ name: newName, description: newDesc, }); db.change(channelId, { name: newName, description: newDesc, history: [], }); sendInteractionLog( interaction.user.username, "change", `${newName ? newName : "[name not changed]"}, ${ newDesc ? "[check description in panel]" : "[description not changed]" }`, channelId, ); await sendInteractionResponse(bot, interaction, { content: `Name: ${newName ?? "[unchanged]"}\nDescription: ${newDesc ?? "[unchanged]"}`, }); }, } as SlashCommandOptions;