MongooseError: Query was already executed: Error: Discord.js

MongooseError: Query was already executed: Error: Discord.js

代码

const fetch = require("node-fetch");


client.on('messageCreate', async (message) => {
    const chatbots = require("./All-Commands-Schemas/ChatbotSchema")
    await chatbots.findOne({ guild: message.guild.id }, async (err, data) => {
        if (!data) return;
        if (err) throw err
        const channell = data.channel
        if (message.author.bot || message.channel.type === 'dm') return;

        if (message.channel.id === channell) {
            message.channel.sendTyping();
            await fetch(`http://api.brainshop.ai/get?bid=163&key=rztKzYO&uid=${message.author.id}&msg=${message.content}`)
                .then(cnt => cnt.json())
                .then(data => {
                    message.channel.send(data.cnt);
                })
                .catch(() => {
                    message.channel.send("Couldn't fetch response!");
                })
        };
    });
});

错误

Reason: MongooseError: Query was already executed: chatbots.findOne(

您好,我需要有关上面提供的以下错误和代码的帮助。以下是我的代码版本。

"猫鼬": "^6.1.6", "discord.js": "^13.3.1", “节点”:“16.13.2”, “npm”:“8.1.2”

您不能在同一个查询中使用 await 和 callback,您应该删除 await

chatbots.findOne({ guild: message.guild.id }, async (err, data) => {
//do some thing
}

或回调

const data = awaitchatbots.findOne({ guild: message.guild.id })
//do something