Removed the excessive connecting and closing of the MongoDb databases

This commit is contained in:
ION606
2022-07-31 10:11:55 +03:00
parent 6d8aa991b6
commit 14dd4e002a
10 changed files with 197 additions and 221 deletions
+2 -4
View File
@@ -8,9 +8,8 @@ function handle_dm(message, bot) {
if (!message.content.startsWith('!') || message.content.split(' ')[0] == '!startconvo' || message.content.split(' ')[0] == '!endconvo') {
const member = bot.guilds.cache.get(bot.home_server).members.cache.get(message.author.id);
const client = new MongoClient(bot.mongouri, { useNewUrlParser: true, useUnifiedTopology: true, serverApi: ServerApiVersion.v1 });
client.connect(async (err) => {
if (err) { return console.log(err); }
bot.mongoconnection.then(async (client) => {
// if (err) { return console.log(err); }
const dbo = client.db('main').collection('authorized');
dbo.find({id: message.author}).toArray((err, docs) => {
@@ -24,7 +23,6 @@ function handle_dm(message, bot) {
});
});
client.close();
} else if (message.content.indexOf('!premium') != -1) {
handleInp(bot, message);
} else {