import { Schema, model, type Types } from "mongoose"; export interface IChatbotProfile { name: string; avatarURL: string; onlySendSpecified: boolean; messages: { content: string }[]; } export interface IChatbotMessage { content: string; addedBy: string; } export interface IChatbotRepository { _id: Types.ObjectId; name: string; scope: "global" | "local"; guildId?: string; profiles: IChatbotProfile[]; messages: IChatbotMessage[]; } const ChatbotProfileSchema = new Schema({ name: { type: String, required: true }, avatarURL: { type: String, required: true }, onlySendSpecified: { type: Boolean, default: false }, messages: [{ content: { type: String, required: true } }], }); const ChatbotRepositorySchema = new Schema({ name: { type: String, required: true }, scope: { type: String, enum: ["global", "local"], required: true }, guildId: { type: String }, profiles: { type: [ChatbotProfileSchema], default: [] }, messages: [{ content: { type: String, required: true }, addedBy: { type: String, required: true } }], }); ChatbotRepositorySchema.index({ scope: 1, guildId: 1, name: 1 }, { unique: true }); export const ChatbotRepository = model("ChatbotRepository", ChatbotRepositorySchema);