A powerful and extendable Discord bot, with it's own module system :3 thevoid.cafe/projects/voidy
at develop 41 lines 1.3 kB view raw
1import { Schema, model, type Types } from "mongoose"; 2 3export interface IChatbotProfile { 4 name: string; 5 avatarURL: string; 6 onlySendSpecified: boolean; 7 messages: { content: string }[]; 8} 9 10export interface IChatbotMessage { 11 content: string; 12 addedBy: string; 13} 14 15export interface IChatbotRepository { 16 _id: Types.ObjectId; 17 name: string; 18 scope: "global" | "local"; 19 guildId?: string; 20 profiles: IChatbotProfile[]; 21 messages: IChatbotMessage[]; 22} 23 24const ChatbotProfileSchema = new Schema<IChatbotProfile>({ 25 name: { type: String, required: true }, 26 avatarURL: { type: String, required: true }, 27 onlySendSpecified: { type: Boolean, default: false }, 28 messages: [{ content: { type: String, required: true } }], 29}); 30 31const ChatbotRepositorySchema = new Schema<IChatbotRepository>({ 32 name: { type: String, required: true }, 33 scope: { type: String, enum: ["global", "local"], required: true }, 34 guildId: { type: String }, 35 profiles: { type: [ChatbotProfileSchema], default: [] }, 36 messages: [{ content: { type: String, required: true }, addedBy: { type: String, required: true } }], 37}); 38 39ChatbotRepositorySchema.index({ scope: 1, guildId: 1, name: 1 }, { unique: true }); 40 41export const ChatbotRepository = model<IChatbotRepository>("ChatbotRepository", ChatbotRepositorySchema);