mongooseError:操作"chatbots.findOne()"缓冲在超时10000毫秒后超



我正在制作youtube教程中的discord bothttps://youtu.be/bD75JNQfeYM但是制作youtube教程的人不想回答我的问题我得到一个错误,说

错误:操作chatbots.findOne()缓冲在Timeout.x 的10000ms后超时

这是代码这是聊天宝.js

const fetch = require('node-fetch');
const client = require('../index');
const {
findOne
} = require('../models/chatbot');
const Schema = require('../models/chatbot');
client.on('messageCreate', async (message) => {
if (message.author.bot) return 
await Schema.findOne({
guild: message.guild.id
}, async (err, data) => {
if (!data) return;
if (err) throw err;
const channell = data.channel

if (message.channel.id === channell) {
fetch(`https://api.monkedev.com/fun/chat?msg=${message.content}&uid=${message.author.id}&yr0n57JXpCy7aXlzFmMchuas`) 
.then(response => response.json())
.then(data => {
message.reply(`> ${data.response}`)
}) 
}
})
})

这是聊天机器人的命令

const {
Client,
Message,
MessageEmbed
} = require('discord.js');
const Schema = require('../../models/chatbot')
module.exports = {
name: 'set-chatbot',
/*
* @param {Client} client 
* @param {Message} message 
* @param {String[]} args 
*/
run: async (client, message, args, Discord) => {
const channell = message.mentions.channels.first()
if (!channell) return message.reply('Please tell me a channel!');
Schema.findOne({
guild: message.guild.id
}, async (err, data) => {
if (data) data.delete()
new Schema({
guild: message.guild.id,
channel: channell.id,
}).save();
message.channel.send('Done!')
})
}
}

这种杂酚油

const { mongooseConnectionString } = require("../config.json");
const mongoose = require("mongoose");
module.exports = () => {
if (!mongooseConnectionString) return;
mongoose.connect(mongooseConnectionString, {
useFindAndModify: true,
useUnifiedTopology: true,
});
};

型号

const mongoose = require('mongoose')
const chatbot = new mongoose.Schema({
guild: String,
channel: String
})
module.exports = mongoose.model("chatbot", chatbot);

mongoose.connect(mongoURI, {family: 4},()=>{
console.log('server in connected')
})

最新更新