我正在尝试将惩罚模式导入到我的 guild.js 中,但我不知道如何导入。
如你所见,我有惩罚.js,但我需要将惩罚模式包含到guild.js中,因为它依赖于它
const mongoose = require("mongoose");
const punishmentType = Object.freeze({
WARN: "Warn",
BAN: "Ban",
MUTE: "Mute",
});
const punishmentSchema = mongoose.Schema({
userId: String,
type: {
type: String,
enum: Object.values(punishmentType),
},
});
exports.punishmentSchema = punishmentSchema;
exports.Punishment = mongoose.model("Punishment", punishmentSchema);
const mongoose = require("mongoose");
const guild = mongoose.Schema({
id: String,
prefix: String,
punishments: [Punishment],
});
const Guild = mongoose.model("Guild", guild);
module.exports = Guild;
答案 0 :(得分:0)
只是一个普通的require
:
const {Punishment} = require('./Punishments');