You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.4 KiB

import { ApplicationCommandOptionChoice, ApplicationCommandOptionTypes } from "@wackford/discordeno.ts";
import { sendInteractionResponse, SlashCommandOptions } from "@wackford/mod.ts";
import { AIs, changeAI, checkAI } from "../ai/index.ts";
import config from "../config.ts";
import { db } from "../database.ts";
export default {
name: "changeai",
description: "changes the AI",
options: [
{
name: "name",
description: "name of the",
type: ApplicationCommandOptionTypes.String,
required: true,
choices: <ApplicationCommandOptionChoice[]> config.general.ais.map((m) =>
<ApplicationCommandOptionChoice> {
name: m,
value: m,
}
),
},
],
execute: async (bot, interaction, args) => {
const AI = AIs[interaction?.channelId?.toString() as string];
const name = args["name"].value?.toString();
if (!checkAI(bot, interaction, AI)) return;
if (name) {
await changeAI(name, interaction.channelId?.toString() as string);
db.change(interaction?.channelId?.toString() as string, {
history: []
})
}
await sendInteractionResponse(bot, interaction, {
content: `Changed AI to ${name}!`,
});
},
} as SlashCommandOptions;