我一直在使用 rethinkdb,由于它已经过时了,我想切换到 mongodb。在我的prefix
命令下,我不断收到该错误,这是我的代码:
const { Guild } = require('../../models/Guild');
async function prefixCommand (msg, args) {
if (!msg.member.permissions.has('manageGuild') && !this.config.options.devs.includes(msg.author.id)) {
return msg.channel.createMessage('You need `manageGuild` to be able to use this command!');
}
Guild.findOne({ guildID: msg.channel.guild.id }, function(err, doc) {
let prefixConfig;
if (!args[0]) {
return msg.channel.createMessage('Prefix is a required argument!\nUsage: `prefix <prefix>`');
}
if (args.join(' ').length > 32) {
return msg.channel.createMessage(`Your prefix cannot be over 30 characters long! You are ${args.join(' ').length - 32} characters over the limit.`);
}
if (doc.prefix === args.join(' ').toLowerCase()) {
return msg.channel.createMessage(`\`${args[0]}\` is already your current prefix.`);
}
//prefixConfig.prefix = args.join(' ');
doc.prefix = args.join(' ');
doc.save();
//await this.m.updateGuild(msg.channel.guild.id, prefixConfig.prefix);
msg.channel.createMessage(`Prefix has been set to \`${prefixConfig}\``);
});
}
而公会是这样的:
const mongoose = require('mongoose');
const guildSchema = new mongoose.Schema({
guildID: String,
guildName:String,
ownerID: String,
prefix: {
type: String,
default: '>'
}
});
module.exports = mongoose.model('Guild', guildSchema)
我似乎无法弄清楚是什么问题。任何帮助表示赞赏!