Use lean() method on read-only database calls

This commit is contained in:
TheEssem 2020-04-24 15:25:27 -05:00
parent 881dfd34d7
commit 88dd0c6172
3 changed files with 3 additions and 3 deletions

View file

@ -6,7 +6,7 @@ const paginator = require("../utils/pagination/pagination.js");
const tips = ["You can change the bot's prefix using the prefix command.", "Image commands also work with images previously posted in that channel.", "You can use the tags commands to save things for later use.", "You can visit https://projectlounge.pw/esmBot/help.html for a web version of this command list.", "You can view a command's aliases by putting the command name after the help command (e.g. help image).", "Parameters wrapped in [] are required, while parameters wrapped in {} are optional."];
exports.run = async (message, args) => {
const guild = (await database.guilds.find({ id: message.channel.guild.id }).exec())[0];
const guild = (await database.guilds.find({ id: message.channel.guild.id }).lean().exec())[0];
const commands = collections.commands;
const aliases = collections.aliases;
if (args.length !== 0 && (commands.has(args[0].toLowerCase()) || aliases.has(args[0].toLowerCase()))) {

View file

@ -16,7 +16,7 @@ module.exports = async (message) => {
if (!message.channel.guild.members.get(client.user.id).permission.has("sendMessages") || !message.channel.permissionsOf(client.user.id).has("sendMessages")) return;
// prefix can be a mention or a set of special characters
const guildDB = (await database.guilds.find({ id: message.channel.guild.id }).exec())[0];
const guildDB = (await database.guilds.find({ id: message.channel.guild.id }).lean().exec())[0];
const prefixMention = new RegExp(`^<@!?${client.user.id}> `);
const prefix = prefixMention.test(message.content) ? message.content.match(prefixMention)[0] : guildDB.prefix;

View file

@ -8,7 +8,7 @@ const client = new Twitter({
});
exports.client = client;
exports.active = false;
database.tweets.find({ enabled: true }, (error, docs) => {
database.tweets.find({ enabled: true }).lean().exec((error, docs) => {
if (error) throw error;
exports.tweets = docs[0];
});