我想使用注册命令保存我的不和谐会员数据,请帮帮我!!
bot.js
client.on("message", msg => {
if (msg.content === "!register, ign:<input from member>, level:<input from member>"){
const newProfileSchema = new ProfileSchema({
discordid: "Discord Member Username",
ign: "<input from member>",
level: "<input from member>",
})
}
})
这是架构看起来像Schema.js
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const ProfileSchema = new Schema({
discordid: {
type: String,
required: true
},
ign: {
type: String
},
level: {
type: Number
}
});
module.exports = User = mongoose.model('profile', ProfileSchema);
据我了解,因为您的问题根本不清楚您需要在!register
运行命令时使用 mongoose 将集合添加到您的数据库中。
const ign = args.slice(1).join(" ")
const level = args.slice.... // same thing
const newSchemaprofile = new Schema({
discordid: message.author.id,
ign: ign,
level: level,
}).save();
message.reply({content: 'Your data is saved'})
这是您使用猫鼬保存数据的方式
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句