From 2a67b7616912c8ae5bf7f39712c87a21ffe2d564 Mon Sep 17 00:00:00 2001 From: TheEssem Date: Fri, 10 Jul 2020 12:07:24 -0500 Subject: [PATCH] Migrated database to PostgreSQL, updated packages --- commands/addtweet.js | 9 +- commands/channel.js | 24 +- commands/count.js | 10 +- commands/help.js | 6 +- commands/prefix.js | 8 +- commands/tags.js | 47 ++- commands/warn.js | 16 +- events/guildCreate.js | 9 +- events/messageCreate.js | 12 +- events/ready.js | 89 ++---- package-lock.json | 642 ++++++++++++++++------------------------ package.json | 13 +- readme.md | 4 +- utils/database.js | 37 +-- utils/twitter.js | 6 +- 15 files changed, 362 insertions(+), 570 deletions(-) diff --git a/commands/addtweet.js b/commands/addtweet.js index 40e333e..7d7f402 100644 --- a/commands/addtweet.js +++ b/commands/addtweet.js @@ -1,12 +1,15 @@ -const db = require("../utils/database.js"); +const { writeFile } = require("fs"); +const { promisify } = require("util"); +const tweets = require("../tweets.json"); +const twitter = require("../utils/twitter.js"); exports.run = async (message, args) => { if (message.author.id !== process.env.OWNER) return `${message.author.mention}, only the bot owner can add tweets!`; if (args.length === 0) return `${message.author.mention}, you need to provide some text to add to the tweet database!`; if (args[1] === undefined) return `${message.author.mention}, you need to provide the content you want to add!`; - const tweets = (await db.tweets.find({ enabled: true }).exec())[0]; tweets[args[0]].push(args.slice(1).join(" ")); - await tweets.save(); + twitter.tweets = tweets; + await promisify(writeFile)("../tweets.json", JSON.stringify(tweets, null, 2)); return `${message.author.mention}, the content has been added.`; }; diff --git a/commands/channel.js b/commands/channel.js index 43167cc..8706aa6 100644 --- a/commands/channel.js +++ b/commands/channel.js @@ -4,28 +4,28 @@ exports.run = async (message, args) => { if (!message.member.permission.has("administrator") && message.member.id !== process.env.OWNER) return `${message.author.mention}, you need to be an administrator to enable/disable me!`; if (args.length === 0) return `${message.author.mention}, you need to provide whether I should be enabled or disabled in this channel!`; if (args[0] !== "disable" && args[0] !== "enable") return `${message.author.mention}, that's not a valid option!`; - const guildDB = (await db.guilds.find({id: message.channel.guild.id}).exec())[0]; + const guildDB = await db.query("SELECT * FROM guilds WHERE guild_id = $1", [message.channel.guild.id]); if (args[0].toLowerCase() === "disable") { if (args[1] && args[1].match(/^?$/) && args[1] >= 21154535154122752) { const id = args[1].replace("@", "").replace("#", "").replace("!", "").replace("&", "").replace("<", "").replace(">", ""); - if (guildDB.disabledChannels.includes(id)) return `${message.author.mention}, I'm already disabled in this channel!`; - guildDB.disabledChannels.push(id); + if (guildDB.rows[0].disabled.includes(id)) return `${message.author.mention}, I'm already disabled in this channel!`; + guildDB.rows[0].disabled.push(id); } else { - if (guildDB.disabledChannels.includes(message.channel.id)) return `${message.author.mention}, I'm already disabled in this channel!`; - guildDB.disabledChannels.push(message.channel.id); + if (guildDB.rows[0].disabled.includes(message.channel.id)) return `${message.author.mention}, I'm already disabled in this channel!`; + guildDB.rows[0].disabled.push(message.channel.id); } - await guildDB.save(); - return `${message.author.mention}, I have been disabled in this channel. To re-enable me, just run \`${guildDB.prefix}channel enable\`.`; + await db.query("UPDATE guilds SET disabled = $1 WHERE guild_id = $2", [guildDB.rows[0].disabled, message.channel.guild.id]); + return `${message.author.mention}, I have been disabled in this channel. To re-enable me, just run \`${guildDB.rows[0].prefix}channel enable\`.`; } else if (args[0].toLowerCase() === "enable") { if (args[1] && args[1].match(/^?$/) && args[1] >= 21154535154122752) { const id = args[1].replace("@", "").replace("#", "").replace("!", "").replace("&", "").replace("<", "").replace(">", ""); - if (!guildDB.disabledChannels.includes(id)) return `${message.author.mention}, I'm not disabled in that channel!`; - guildDB.disabledChannels = guildDB.disabledChannels.filter(item => item !== id); + if (!guildDB.rows[0].disabled.includes(id)) return `${message.author.mention}, I'm not disabled in that channel!`; + guildDB.rows[0].disabled = guildDB.rows[0].disabled.filter(item => item !== id); } else { - if (!guildDB.disabledChannels.includes(message.channel.id)) return `${message.author.mention}, I'm not disabled in this channel!`; - guildDB.disabledChannels = guildDB.disabledChannels.filter(item => item !== message.channel.id ); + if (!guildDB.rows[0].disabled.includes(message.channel.id)) return `${message.author.mention}, I'm not disabled in this channel!`; + guildDB.rows[0].disabled = guildDB.rows[0].disabled.filter(item => item !== message.channel.id ); } - await guildDB.save(); + await db.query("UPDATE guilds SET disabled = $1 WHERE guild_id = $2", [guildDB.rows[0].disabled, message.channel.guild.id]); return `${message.author.mention}, I have been re-enabled in this channel.`; } }; diff --git a/commands/count.js b/commands/count.js index d5279c5..c5e051f 100644 --- a/commands/count.js +++ b/commands/count.js @@ -5,13 +5,13 @@ const database = require("../utils/database.js"); exports.run = async (message) => { if (!message.channel.guild.members.get(client.user.id).permission.has("addReactions") && !message.channel.permissionsOf(client.user.id).has("addReactions")) return `${message.author.mention}, I don't have the \`Add Reactions\` permission!`; if (!message.channel.guild.members.get(client.user.id).permission.has("embedLinks") && !message.channel.permissionsOf(client.user.id).has("embedLinks")) return `${message.author.mention}, I don't have the \`Embed Links\` permission!`; - const counts = (await database.global.findOne({}).lean().exec()).cmdCounts; + const counts = await database.query("SELECT * FROM counts"); const countArray = []; - const sortedValues = Object.entries(counts).sort((a, b) => { - return b[1] - a[1]; + const sortedValues = counts.rows.sort((a, b) => { + return b.count - a.count; }); - for (const [key, value] of sortedValues) { - countArray.push(`**${key}**: ${value}`); + for (const { command, count } of sortedValues) { + countArray.push(`**${command}**: ${count}`); } const embeds = []; const groups = countArray.map((item, index) => { diff --git a/commands/help.js b/commands/help.js index df45213..07cacc2 100644 --- a/commands/help.js +++ b/commands/help.js @@ -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 }).lean().exec())[0]; + const guildDB = await database.query("SELECT * FROM guilds WHERE guild_id = $1", [message.channel.guild.id]); const commands = collections.commands; const aliases = collections.aliases; if (args.length !== 0 && (commands.has(args[0].toLowerCase()) || aliases.has(args[0].toLowerCase()))) { @@ -17,7 +17,7 @@ exports.run = async (message, args) => { "name": "esmBot Help", "icon_url": client.user.avatarURL }, - "title": `${guild.prefix}${aliases.has(args[0].toLowerCase()) ? collections.aliases.get(args[0].toLowerCase()) : args[0].toLowerCase()}`, + "title": `${guildDB.rows[0].prefix}${aliases.has(args[0].toLowerCase()) ? collections.aliases.get(args[0].toLowerCase()) : args[0].toLowerCase()}`, "url": "https://projectlounge.pw/esmBot/help.html", "description": info.description, "color": 16711680, @@ -94,7 +94,7 @@ exports.run = async (message, args) => { }, "fields": [{ "name": "Prefix", - "value": guild.prefix + "value": guildDB.rows[0].prefix }, { "name": "Tip", "value": misc.random(tips) diff --git a/commands/prefix.js b/commands/prefix.js index 3550f50..f714295 100644 --- a/commands/prefix.js +++ b/commands/prefix.js @@ -1,14 +1,14 @@ const database = require("../utils/database.js"); exports.run = async (message, args) => { - const guild = (await database.guilds.find({ id: message.channel.guild.id }).exec())[0]; + const guildDB = await database.query("SELECT * FROM guilds WHERE guild_id = $1", [message.channel.guild.id]); if (args.length !== 0) { if (!message.member.permission.has("administrator") && message.member.id !== process.env.OWNER) return `${message.author.mention}, you need to be an administrator to change the bot prefix!`; - guild.set("prefix", args[0]); - await guild.save(); + if (args[0].length > 15) return `${message.author.mention}, that prefix is too long!`; + await database.query("UPDATE guilds SET prefix = $1 WHERE guild_id = $2", [args[0], message.channel.guild.id]); return `The prefix has been changed to ${args[0]}.`; } else { - return `${message.author.mention}, the current prefix is \`${guild.prefix}\`.`; + return `${message.author.mention}, the current prefix is \`${guildDB.rows[0].prefix}\`.`; } }; diff --git a/commands/tags.js b/commands/tags.js index 85d6af5..6288543 100644 --- a/commands/tags.js +++ b/commands/tags.js @@ -5,43 +5,44 @@ const { random } = require("../utils/misc.js"); exports.run = async (message, args) => { if (args.length === 0) return `${message.author.mention}, you need to specify the name of the tag you want to view!`; - const guild = (await database.guilds.find({ id: message.channel.guild.id }).exec())[0]; - const tags = guild.tags; + const guildDB = await database.query("SELECT * FROM guilds WHERE guild_id = $1", [message.channel.guild.id]); + const tags = guildDB.rows[0].tags; const blacklist = ["add", "edit", "remove", "delete", "list", "random"]; switch (args[0].toLowerCase()) { + case "create": case "add": if (args[1] === undefined) return `${message.author.mention}, you need to provide the name of the tag you want to add!`; if (blacklist.includes(args[1].toLowerCase())) return `${message.author.mention}, you can't make a tag with that name!`; - if (tags.has(args[1].toLowerCase())) return `${message.author.mention}, this tag already exists!`; - var result = await setTag(args.slice(2).join(" "), args[1].toLowerCase(), message, guild); + if (tags[args[1].toLowerCase()]) return `${message.author.mention}, this tag already exists!`; + var result = await setTag(args.slice(2).join(" "), args[1].toLowerCase(), message, guildDB); if (result) return result; return `${message.author.mention}, the tag \`${args[1].toLowerCase()}\` has been added!`; case "delete": case "remove": if (args[1] === undefined) return `${message.author.mention}, you need to provide the name of the tag you want to delete!`; - if (!tags.has(args[1].toLowerCase())) return `${message.author.mention}, this tag doesn't exist!`; - if (tags.get(args[1].toLowerCase()).author !== message.author.id && message.author.id !== process.env.OWNER) return `${message.author.mention}, you don't own this tag!`; - tags.set(args[1].toLowerCase(), undefined); - await guild.save(); + if (!tags[args[1].toLowerCase()]) return `${message.author.mention}, this tag doesn't exist!`; + if (tags[args[1].toLowerCase()].author !== message.author.id && message.author.id !== process.env.OWNER) return `${message.author.mention}, you don't own this tag!`; + delete tags[args[1].toLowerCase()]; + await database.query("UPDATE guilds SET tags = $1 WHERE guild_id = $2", [tags, message.channel.guild.id]); return `${message.author.mention}, the tag \`${args[1].toLowerCase()}\` has been deleted!`; case "edit": if (args[1] === undefined) return `${message.author.mention}, you need to provide the name of the tag you want to edit!`; - if (!tags.has(args[1].toLowerCase())) return `${message.author.mention}, this tag doesn't exist!`; - if (tags.get(args[1].toLowerCase()).author !== message.author.id && tags.get(args[1].toLowerCase()).author !== process.env.OWNER) return `${message.author.mention}, you don't own this tag!`; - await setTag(args.slice(2).join(" "), args[1].toLowerCase(), message, guild); + if (!tags[args[1].toLowerCase()]) return `${message.author.mention}, this tag doesn't exist!`; + if (tags[args[1].toLowerCase()].author !== message.author.id && tags[args[1].toLowerCase()].author !== process.env.OWNER) return `${message.author.mention}, you don't own this tag!`; + await setTag(args.slice(2).join(" "), args[1].toLowerCase(), message, guildDB); return `${message.author.mention}, the tag \`${args[1].toLowerCase()}\` has been edited!`; case "own": case "owner": if (args[1] === undefined) return `${message.author.mention}, you need to provide the name of the tag you want to check the owner of!`; - if (!tags.has(args[1].toLowerCase())) return `${message.author.mention}, this tag doesn't exist!`; - return `${message.author.mention}, this tag is owned by **${client.users.get(tags.get(args[1].toLowerCase()).author).username}#${client.users.get(tags.get(args[1].toLowerCase()).author).discriminator}** (\`${tags.get(args[1].toLowerCase()).author}\`).`; + if (!tags[args[1].toLowerCase()]) return `${message.author.mention}, this tag doesn't exist!`; + return `${message.author.mention}, this tag is owned by **${client.users.get(tags[args[1].toLowerCase()].author).username}#${client.users.get(tags[args[1].toLowerCase()].author).discriminator}** (\`${tags[args[1].toLowerCase()].author}\`).`; case "list": if (!message.channel.guild.members.get(client.user.id).permission.has("addReactions") && !message.channel.permissionsOf(client.user.id).has("addReactions")) return `${message.author.mention}, I don't have the \`Add Reactions\` permission!`; if (!message.channel.guild.members.get(client.user.id).permission.has("embedLinks") && !message.channel.permissionsOf(client.user.id).has("embedLinks")) return `${message.author.mention}, I don't have the \`Embed Links\` permission!`; var pageSize = 15; var embeds = []; - var groups = [...tags.keys()].map((item, index) => { - return index % pageSize === 0 ? [...tags.keys()].slice(index, index + pageSize) : null; + var groups = Object.keys(tags).map((item, index) => { + return index % pageSize === 0 ? Object.keys(tags).slice(index, index + pageSize) : null; }).filter((item) => { return item; }); @@ -67,23 +68,21 @@ exports.run = async (message, args) => { case "random": return random([...tags])[1].content; default: - if (!tags.has(args[0].toLowerCase())) return `${message.author.mention}, this tag doesn't exist!`; - return tags.get(args[0].toLowerCase()).content; + if (!tags[args[0].toLowerCase()]) return `${message.author.mention}, this tag doesn't exist!`; + return tags[args[0].toLowerCase()].content; } }; -const setTag = async (content, name, message, guild) => { +const setTag = async (content, name, message, guildDB) => { if ((!content || content.length === 0) && message.attachments.length === 0) return `${message.author.mention}, you need to provide the content of the tag!`; if (message.attachments.length !== 0 && content) { - guild.tags.set(name, { content: `${content} ${message.attachments[0].url}`, author: message.author.id }); - await guild.save(); + guildDB.rows[0].tags[name] = { content: `${content} ${message.attachments[0].url}`, author: message.author.id }; } else if (message.attachments.length !== 0) { - guild.tags.set(name, { content: message.attachments[0].url, author: message.author.id }); - await guild.save(); + guildDB.rows[0].tags[name] = { content: message.attachments[0].url, author: message.author.id }; } else { - guild.tags.set(name, { content: content, author: message.author.id }); - await guild.save(); + guildDB.rows[0].tags[name] = { content: content, author: message.author.id }; } + await database.query("UPDATE guilds SET tags = $1 WHERE guild_id = $2", [guildDB.rows[0].tags, message.channel.guild.id]); return; }; diff --git a/commands/warn.js b/commands/warn.js index 3428c46..03f9933 100644 --- a/commands/warn.js +++ b/commands/warn.js @@ -7,10 +7,8 @@ exports.run = async (message, args) => { const memberCheck = message.mentions.length >= 1 ? message.mentions[0] : client.users.get(args[0]); const member = memberCheck ? memberCheck : client.users.get(args[0].replace(/\D/g, "")); if (member) { - const guild = (await database.guilds.find({ - id: message.channel.guild.id - }).exec())[0]; - const array = guild.warns.get(member.id) ? guild.warns.get(member.id).warns : []; + const guildDB = await database.query("SELECT * FROM guilds WHERE guild_id = $1", [message.channel.guild.id]); + const array = guildDB.rows[0].warns[member.id] ? guildDB.rows[0].warns[member.id] : []; if (args[1].toLowerCase() !== "list") { args.shift(); array.push({ @@ -18,11 +16,8 @@ exports.run = async (message, args) => { time: new Date(), creator: message.author.id }); - guild.warns.set(member.id, { - count: (guild.warns.get(member.id) ? guild.warns.get(member.id).count : 0) + 1, - warns: array - }); - await guild.save(); + guildDB.rows[0].warns[member.id] = array; + await database.query("UPDATE guilds SET warns = $1 WHERE guild_id = $2", [guildDB.rows[0].warns, message.channel.guild.id]); //await message.channel.guild.banMember(member.id, 0, `ban command used by @${message.author.username}#${message.author.discriminator}`); return `Successfully warned ${member.mention} for \`${args.join(" ")}\`.`; } else { @@ -30,7 +25,8 @@ exports.run = async (message, args) => { if (!message.channel.guild.members.get(client.user.id).permission.has("embedLinks") && !message.channel.permissionsOf(client.user.id).has("embedLinks")) return `${message.author.mention}, I don't have the \`Embed Links\` permission!`; const warnArray = []; for (const [i, value] of array.entries()) { - warnArray.push(`**${i + 1}: Added by ${message.channel.guild.members.get(value.creator).username}#${message.channel.guild.members.get(value.creator).discriminator}**: ${value.message} (${value.time.toUTCString()})`); + console.log(value); + warnArray.push(`**${i + 1}: Added by ${message.channel.guild.members.get(value.creator).username}#${message.channel.guild.members.get(value.creator).discriminator}**: ${value.message} (${new Date(value.time).toUTCString()})`); } const pageSize = 15; const embeds = []; diff --git a/events/guildCreate.js b/events/guildCreate.js index 01c2e20..af69ffa 100644 --- a/events/guildCreate.js +++ b/events/guildCreate.js @@ -6,12 +6,5 @@ const client = require("../utils/client.js"); // run when the bot is added to a guild module.exports = async (guild) => { logger.log("info", `[GUILD JOIN] ${guild.name} (${guild.id}) added the bot. Owner: ${client.users.get(guild.ownerID).username}#${client.users.get(guild.ownerID).discriminator} (${guild.ownerID})`); - const guildDB = new db.guilds({ - id: guild.id, - tags: misc.tagDefaults, - prefix: "&", - warns: {}, - disabledChannels: [] - }); - await guildDB.save(); + await db.query("INSERT INTO guilds (guild_id, tags, prefix, warns, disabled) VALUES ($1, $2, $3, $4, $5)", [guild.id, misc.tagDefaults, "&", {}, []]); }; diff --git a/events/messageCreate.js b/events/messageCreate.js index a1dade2..0f19a44 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -16,9 +16,9 @@ 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.findOne({ id: message.channel.guild.id }).lean().exec(); + const guildDB = await database.query("SELECT * FROM guilds WHERE guild_id = $1", [message.channel.guild.id]); const prefixMention = new RegExp(`^<@!?${client.user.id}> `); - const prefix = prefixMention.test(message.content) ? message.content.match(prefixMention)[0] : guildDB.prefix; + const prefix = prefixMention.test(message.content) ? message.content.match(prefixMention)[0] : guildDB.rows[0].prefix; // ignore other stuff if (message.content.startsWith(prefix) === false) return; @@ -30,7 +30,7 @@ module.exports = async (message) => { const command = args.shift().toLowerCase(); // don't run if message is in a disabled channel - if (guildDB.disabledChannels && guildDB.disabledChannels.includes(message.channel.id) && command != "channel") return; + if (guildDB.rows[0].disabled && guildDB.rows[0].disabled.includes(message.channel.id) && command != "channel") return; // check if command exists const cmd = collections.commands.get(command) || collections.commands.get(collections.aliases.get(command)); @@ -39,10 +39,8 @@ module.exports = async (message) => { // actually run the command logger.log("info", `${message.author.username} (${message.author.id}) ran command ${command}`); try { - const global = (await database.global.findOne({}).exec()); - const count = global.cmdCounts.get(collections.aliases.has(command) ? collections.aliases.get(command) : command); - global.cmdCounts.set(collections.aliases.has(command) ? collections.aliases.get(command) : command, parseInt(count) + 1); - await global.save(); + const count = await database.query("SELECT * FROM counts WHERE command = $1", [collections.aliases.has(command) ? collections.aliases.get(command) : command]); + await database.query("UPDATE counts SET count = $1 WHERE command = $2", [count.rows[0].count + 1, collections.aliases.has(command) ? collections.aliases.get(command) : command]); const result = await cmd(message, args, content.replace(command, "").trim()); // we also provide the message content as a parameter for cases where we need more accuracy if (typeof result === "string" || (typeof result === "object" && result.embed)) { await client.createMessage(message.channel.id, result); diff --git a/events/ready.js b/events/ready.js index 3d7e9fe..a374ea8 100644 --- a/events/ready.js +++ b/events/ready.js @@ -57,64 +57,41 @@ module.exports = async () => { // make sure settings/tags exist for (const [id] of client.guilds) { - const guildDB = ( - await database.guilds - .findOne({ - id: id, - }) - .exec() - ); - if (!guildDB) { + const guildDB = await database.query("SELECT * FROM guilds WHERE guild_id = $1", [id]); + if (guildDB.rows.length === 0) { logger.log(`Registering guild database entry for guild ${id}...`); - const newGuild = new database.guilds({ - id: id, - tags: misc.tagDefaults, - prefix: "&", - warns: {}, - disabledChannels: [] - }); - await newGuild.save(); - } else if (guildDB) { - if (!guildDB.warns) { - logger.log(`Creating warn object for guild ${id}...`); - guildDB.set("warns", {}); - await guildDB.save(); - } else if (!guildDB.disabledChannels) { - logger.log(`Creating disabled channels object for guild ${id}...`); - guildDB.set("disabledChannels", []); - await guildDB.save(); - } + await database.query("INSERT INTO guilds (guild_id, tags, prefix, warns, disabled) VALUES ($1, $2, $3, $4, $5)", [id, misc.tagDefaults, "&", {}, []]); } } const job = new cron.CronJob("0 0 * * 0", async () => { logger.log("Deleting stale guild entries in database..."); - const guildDB = (await database.guilds.find({}).exec()); - for (const { id } of guildDB) { - if (!client.guilds.get(id)) { - await database.guilds.deleteMany({ id: id }); - logger.log(`Deleted entry for guild ID ${id}.`); + const guildDB = await database.query("SELECT * FROM guilds"); + for (const { guild_id } of guildDB.rows) { + if (!client.guilds.get(guild_id)) { + await database.query("DELETE FROM guilds WHERE guild_id = $1", [guild_id]); + logger.log(`Deleted entry for guild ID ${guild_id}.`); } } logger.log("Finished deleting stale entries."); }); job.start(); - const global = (await database.global.findOne({}).exec()); - if (!global) { - const countObject = {}; + let counts; + try { + counts = await database.query("SELECT * FROM counts"); + } catch { + counts = { rows: [] }; + } + if (!counts.rows[0]) { for (const command of collections.commands.keys()) { - countObject[command] = 0; + await database.query("INSERT INTO counts (command, count) VALUES ($1, $2)", [command, 0]); } - const newGlobal = new database.global({ - cmdCounts: countObject - }); - await newGlobal.save(); } else { for (const command of collections.commands.keys()) { - if (!global.cmdCounts.has(command)) { - global.cmdCounts.set(command, 0); - await global.save(); + const count = await database.query("SELECT * FROM counts WHERE command = $1", [command]); + if (!count) { + await database.query("INSERT INTO counts (command, count) VALUES ($1, $2)", [command, 0]); } } } @@ -134,14 +111,7 @@ module.exports = async () => { if (twitter !== null && twitter.active === false) { const blocks = await twitter.client.blocks.ids(); const tweet = async () => { - const tweets = ( - await database.tweets - .find({ - enabled: true, - }) - .exec() - )[0]; - const tweetContent = await misc.getTweet(tweets); + const tweetContent = await misc.getTweet(twitter.tweets); try { const info = await twitter.client.statuses.update(tweetContent); logger.log(`Tweet with id ${info.id_str} has been posted.`); @@ -165,24 +135,11 @@ module.exports = async () => { tweet.user.screen_name !== "esmBot_" && !blocks.ids.includes(tweet.user.id_str) ) { - const tweets = ( - await database.tweets - .find({ - enabled: true, - }) - .exec() - )[0]; let tweetContent; - if ( - tweet.text.includes("@this_vid") || - tweet.text.includes("@DownloaderBot") || - tweet.text.includes("@GetVideoBot") || - tweet.text.includes("@DownloaderB0t") || - tweet.text.includes("@thisvid_") - ) { - tweetContent = await misc.getTweet(tweet, true, true); + if (new RegExp(["@this_vid", "@DownloaderBot", "GetVideoBot", "@thisvid_"].join("|")).test(tweet.text)) { + tweetContent = await misc.getTweet(twitter.tweets, true, true); } else { - tweetContent = await misc.getTweet(tweets, true).replace(/{{user}}/gm, `@${tweet.user.screen_name}`); + tweetContent = await misc.getTweet(twitter.tweets, true).replace(/{{user}}/gm, `@${tweet.user.screen_name}`); } const payload = { status: `@${tweet.user.screen_name} ${tweetContent}`, diff --git a/package-lock.json b/package-lock.json index 5e71ae2..011b186 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "esmbot", - "version": "1.3.2", + "version": "1.3.3", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -24,6 +24,16 @@ "js-tokens": "^4.0.0" } }, + "@dabh/diagnostics": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.2.tgz", + "integrity": "sha512-+A1YivoVDNNVCdfozHSR8v/jyuuLTMXwjWuxPFlFlUapXoGc+Gj9mDlTDDfrwl7rXCl2tNZ0kE8sIBO6YOn96Q==", + "requires": { + "colorspace": "1.1.x", + "enabled": "2.0.x", + "kuler": "^2.0.0" + } + }, "@lavacord/eris": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/@lavacord/eris/-/eris-0.0.3.tgz", @@ -59,9 +69,9 @@ "integrity": "sha1-nKUs2jY/aZxpRmwqbM2q2RPqenM=" }, "@types/node": { - "version": "14.0.13", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.13.tgz", - "integrity": "sha512-rouEWBImiRaSJsVA+ITTFM6ZxibuAlTuNOCyxVbwreu6k6+ujs7DfnU9o+PShFhET78pMBl3eH+AGSI5eOTkPA==" + "version": "14.0.20", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.20.tgz", + "integrity": "sha512-MRn/NP3dee8yL5QhbSA6riuwkS+UOcsPUMOIOG3KMUQpuor/2TopdRBu8QaaB4fGU+gz/bzyDWt0FtUbeJ8H1A==" }, "acorn": { "version": "6.4.1", @@ -123,35 +133,6 @@ "requires": { "delegates": "^1.0.0", "readable-stream": "^2.0.6" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } - } } }, "argparse": { @@ -180,12 +161,9 @@ "dev": true }, "async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", - "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", - "requires": { - "lodash": "^4.17.11" - } + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.0.tgz", + "integrity": "sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw==" }, "async-limiter": { "version": "1.0.1", @@ -225,49 +203,6 @@ "file-uri-to-path": "1.0.0" } }, - "bl": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/bl/-/bl-2.2.0.tgz", - "integrity": "sha512-wbgvOpqopSr7uq6fJrLH8EsvYMJf9gzfo2jCsL2eTy75qXPukA4pCgHamOQkZtY5vmfVtjB+P3LNlMHW5CEZXA==", - "requires": { - "readable-stream": "^2.3.5", - "safe-buffer": "^5.1.1" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, - "bluebird": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", - "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==" - }, "boolbase": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", @@ -282,11 +217,6 @@ "concat-map": "0.0.1" } }, - "bson": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.4.tgz", - "integrity": "sha512-S/yKGU1syOMzO86+dGpg2qGoDL0zvzcb262G+gqEy6TgP6rt6z6qxSFX/8X6vLC91P7G7C3nLs0+bvDzmvBA3Q==" - }, "buffer": { "version": "5.4.3", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.4.3.tgz", @@ -325,6 +255,11 @@ "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" }, + "buffer-writer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-2.0.0.tgz", + "integrity": "sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw==" + }, "bufferutil": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.1.tgz", @@ -443,9 +378,9 @@ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" }, "color": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/color/-/color-3.0.0.tgz", - "integrity": "sha512-jCpd5+s0s0t7p3pHQKpnJ0TpQKKdleP71LWcA0aqiljpiuAkOSUFN/dyH8ZwF0hRmFlrIuRhufds1QyEP9EB+w==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/color/-/color-3.1.2.tgz", + "integrity": "sha512-vXTJhHebByxZn3lDvDJYw4lR5+uB3vuoHsuYA5AKuxRVn5wzzIfQKGLBmgdVRHKTJYeK5rvJcHnrd0Li49CFpg==", "requires": { "color-convert": "^1.9.1", "color-string": "^1.5.2" @@ -473,15 +408,10 @@ "simple-swizzle": "^0.2.2" } }, - "colornames": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/colornames/-/colornames-1.1.1.tgz", - "integrity": "sha1-+IiQMGhcfE/54qVZ9Qd+t2qBb5Y=" - }, "colors": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz", - "integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg==" + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", + "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==" }, "colorspace": { "version": "1.1.2", @@ -490,6 +420,17 @@ "requires": { "color": "3.0.x", "text-hex": "1.0.x" + }, + "dependencies": { + "color": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/color/-/color-3.0.0.tgz", + "integrity": "sha512-jCpd5+s0s0t7p3pHQKpnJ0TpQKKdleP71LWcA0aqiljpiuAkOSUFN/dyH8ZwF0hRmFlrIuRhufds1QyEP9EB+w==", + "requires": { + "color-convert": "^1.9.1", + "color-string": "^1.5.2" + } + } } }, "combined-stream": { @@ -646,26 +587,11 @@ "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" }, - "denque": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/denque/-/denque-1.4.1.tgz", - "integrity": "sha512-OfzPuSZKGcgr96rf1oODnfjqBFmr1DVoc/TrItj3Ohe0Ah1C5WX5Baquw/9U9KovnQ88EqmJbD66rKYUQYN1tQ==" - }, "detect-libc": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=" }, - "diagnostics": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/diagnostics/-/diagnostics-1.1.1.tgz", - "integrity": "sha512-8wn1PmdunLJ9Tqbx+Fx/ZEuHfJf4NKSN2ZBj7SJC/OWRWha843+WsTjqMe1B5E3p28jqBlp+mJ2fPVxPyNgYKQ==", - "requires": { - "colorspace": "1.1.x", - "enabled": "1.0.x", - "kuler": "1.0.x" - } - }, "dijkstrajs": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.1.tgz", @@ -729,12 +655,9 @@ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, "enabled": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz", - "integrity": "sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M=", - "requires": { - "env-variable": "0.0.x" - } + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/enabled/-/enabled-2.0.0.tgz", + "integrity": "sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ==" }, "end-of-stream": { "version": "1.4.4", @@ -749,15 +672,10 @@ "resolved": "https://registry.npmjs.org/entities/-/entities-1.1.2.tgz", "integrity": "sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w==" }, - "env-variable": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/env-variable/-/env-variable-0.0.5.tgz", - "integrity": "sha512-zoB603vQReOFvTg5xMl9I1P2PnHsHQQKTEowsKKD7nseUfJq6UWzK+4YtlWUO1nhiQUxe6XMkk+JleSZD1NZFA==" - }, "eris": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/eris/-/eris-0.11.2.tgz", - "integrity": "sha512-OhccRcxrPiNUylTamrjIbZM6itKMLjNrwLIXGvNwQZj4CRVOOz9eUVIqOJULB713x1ezw7HoC8AEsnsMNUneDA==", + "version": "0.13.3", + "resolved": "https://registry.npmjs.org/eris/-/eris-0.13.3.tgz", + "integrity": "sha512-WBtLyknOWZpYZL9yPhez0oKUWvYpunSg43hGxawwjwSf3gFXmbEPYrT8KlmZXtpJnX16eQ7mzIq+MgSh3LarEg==", "requires": { "opusscript": "^0.0.7", "tweetnacl": "^1.0.1", @@ -925,12 +843,6 @@ "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", "dev": true }, - "eventemitter3": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.2.tgz", - "integrity": "sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==", - "optional": true - }, "expand-template": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", @@ -1003,9 +915,9 @@ "dev": true }, "fast-safe-stringify": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.6.tgz", - "integrity": "sha512-q8BZ89jjc+mz08rSxROs8VsrBBcn1SIw1kq9NjolL509tkABRk9io01RAjSaEv1Xb2uFLt8VtRiZbGp5H8iDtg==" + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", + "integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==" }, "fd-slicer": { "version": "1.1.0", @@ -1016,9 +928,9 @@ } }, "fecha": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz", - "integrity": "sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg==" + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.0.tgz", + "integrity": "sha512-aN3pcx/DSmtyoovUudctc8+6Hl4T+hI9GBBHLjA76jdZl7+b1sgh5g4k+u/GL3dTy1/pnYzKp69FpJ0OicE3Wg==" }, "figures": { "version": "2.0.0", @@ -1080,6 +992,11 @@ "integrity": "sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg==", "dev": true }, + "fn.name": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz", + "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==" + }, "follow-redirects": { "version": "1.5.10", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", @@ -1261,6 +1178,18 @@ "entities": "^1.1.1", "inherits": "^2.0.1", "readable-stream": "^3.1.1" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } } }, "https-proxy-agent": { @@ -1397,9 +1326,9 @@ "dev": true }, "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz", + "integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==" }, "is-typedarray": { "version": "1.0.0", @@ -1449,18 +1378,10 @@ "resolved": "https://registry.npmjs.org/jsqr/-/jsqr-1.3.1.tgz", "integrity": "sha512-zCTP6Qd/WwjrpuHFkJuXc5opRdKprUr7eI7+JCCtcetThJt45qptu82MWQ+eET+FtDrMo7+BYjo3iD0XIq1L9Q==" }, - "kareem": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.1.tgz", - "integrity": "sha512-l3hLhffs9zqoDe8zjmb/mAN4B8VT3L56EUvKNqLFVs9YlFA+zx7ke1DO8STAdDyYNkeSo1nKmjuvQeI12So8Xw==" - }, "kuler": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/kuler/-/kuler-1.0.1.tgz", - "integrity": "sha512-J9nVUucG1p/skKul6DU3PUZrhs0LPulNaeUOox0IyXDi8S4CztTHs1gQphhuZmzXG7VOQSf6NJfKuzteQLv9gQ==", - "requires": { - "colornames": "^1.1.1" - } + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz", + "integrity": "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A==" }, "lavacord": { "version": "1.1.9", @@ -1508,13 +1429,13 @@ "integrity": "sha1-JMS/zWsvuji/0FlNsRedjptlZWE=" }, "logform": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/logform/-/logform-2.1.2.tgz", - "integrity": "sha512-+lZh4OpERDBLqjiwDLpAWNQu6KMjnlXH2ByZwCuSqVPJletw0kTWJf5CgSNAUKn1KUkv3m2cUz/LK8zyEy7wzQ==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/logform/-/logform-2.2.0.tgz", + "integrity": "sha512-N0qPlqfypFx7UHNn4B3lzS/b0uLqt2hmuoa+PpuXNYgozdJYAyauF5Ky0BWVjrxDlMWiT3qN4zPq3vVAfZy7Yg==", "requires": { "colors": "^1.2.1", "fast-safe-stringify": "^2.0.4", - "fecha": "^2.3.3", + "fecha": "^4.2.0", "ms": "^2.1.1", "triple-beam": "^1.3.0" } @@ -1528,12 +1449,6 @@ "yallist": "^2.1.2" } }, - "memory-pager": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", - "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", - "optional": true - }, "mime-db": { "version": "1.42.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.42.0.tgz", @@ -1617,9 +1532,9 @@ "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" }, "moment": { - "version": "2.26.0", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.26.0.tgz", - "integrity": "sha512-oIixUO+OamkUkwjhAVE18rAMfRJNsNe/Stid/gwHSOfHrOtw9EhAY2AHvdKZ/k/MggcYELFCJz/Sn2pL8b8JMw==" + "version": "2.27.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.27.0.tgz", + "integrity": "sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ==" }, "moment-duration-format": { "version": "2.3.2", @@ -1634,81 +1549,6 @@ "moment": ">= 2.9.0" } }, - "mongodb": { - "version": "3.5.9", - "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.5.9.tgz", - "integrity": "sha512-vXHBY1CsGYcEPoVWhwgxIBeWqP3dSu9RuRDsoLRPTITrcrgm1f0Ubu1xqF9ozMwv53agmEiZm0YGo+7WL3Nbug==", - "requires": { - "bl": "^2.2.0", - "bson": "^1.1.4", - "denque": "^1.4.1", - "require_optional": "^1.0.1", - "safe-buffer": "^5.1.2", - "saslprep": "^1.0.0" - } - }, - "mongoose": { - "version": "5.9.19", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.9.19.tgz", - "integrity": "sha512-wJ5FR2ykvyd17MRHA6sku/N1CMaC/kf4CnN357htD48RpzJhW60YDkxPSPLbkLg8Woa+i7jYi0glhzC0EcBcRQ==", - "requires": { - "bson": "^1.1.4", - "kareem": "2.3.1", - "mongodb": "3.5.9", - "mongoose-legacy-pluralize": "1.0.2", - "mpath": "0.7.0", - "mquery": "3.2.2", - "ms": "2.1.2", - "regexp-clone": "1.0.0", - "safe-buffer": "5.1.2", - "sift": "7.0.1", - "sliced": "1.0.1" - }, - "dependencies": { - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" - } - } - }, - "mongoose-legacy-pluralize": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/mongoose-legacy-pluralize/-/mongoose-legacy-pluralize-1.0.2.tgz", - "integrity": "sha512-Yo/7qQU4/EyIS8YDFSeenIvXxZN+ld7YdV9LqFVQJzTLye8unujAWPZ4NWKfFA+RNjh+wvTWKY9Z3E5XM6ZZiQ==" - }, - "mpath": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.7.0.tgz", - "integrity": "sha512-Aiq04hILxhz1L+f7sjGyn7IxYzWm1zLNNXcfhDtx04kZ2Gk7uvFdgZ8ts1cWa/6d0TQmag2yR8zSGZUmp0tFNg==" - }, - "mquery": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.2.tgz", - "integrity": "sha512-XB52992COp0KP230I3qloVUbkLUxJIu328HBP2t2EsxSFtf4W1HPSOBWOXf1bqxK4Xbb66lfMJ+Bpfd9/yZE1Q==", - "requires": { - "bluebird": "3.5.1", - "debug": "3.1.0", - "regexp-clone": "^1.0.0", - "safe-buffer": "5.1.2", - "sliced": "1.0.1" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - } - } - }, "ms": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", @@ -1823,9 +1663,12 @@ } }, "one-time": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/one-time/-/one-time-0.0.4.tgz", - "integrity": "sha1-+M33eISCb+Tf+T46nMN7HkSAdC4=" + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/one-time/-/one-time-1.0.0.tgz", + "integrity": "sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g==", + "requires": { + "fn.name": "1.x.x" + } }, "onetime": { "version": "2.0.1", @@ -1908,6 +1751,11 @@ "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" }, + "packet-reader": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/packet-reader/-/packet-reader-1.0.0.tgz", + "integrity": "sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ==" + }, "parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -1957,15 +1805,100 @@ "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=" }, + "pg": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.3.0.tgz", + "integrity": "sha512-jQPKWHWxbI09s/Z9aUvoTbvGgoj98AU7FDCcQ7kdejupn/TcNpx56v2gaOTzXkzOajmOEJEdi9eTh9cA2RVAjQ==", + "requires": { + "buffer-writer": "2.0.0", + "packet-reader": "1.0.0", + "pg-connection-string": "^2.3.0", + "pg-pool": "^3.2.1", + "pg-protocol": "^1.2.5", + "pg-types": "^2.1.0", + "pgpass": "1.x", + "semver": "4.3.2" + }, + "dependencies": { + "semver": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.2.tgz", + "integrity": "sha1-x6BxWKgL7dBSNVt3DYLWZA+AO+c=" + } + } + }, + "pg-connection-string": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.3.0.tgz", + "integrity": "sha512-ukMTJXLI7/hZIwTW7hGMZJ0Lj0S2XQBCJ4Shv4y1zgQ/vqVea+FLhzywvPj0ujSuofu+yA4MYHGZPTsgjBgJ+w==" + }, + "pg-int8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", + "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==" + }, + "pg-pool": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.2.1.tgz", + "integrity": "sha512-BQDPWUeKenVrMMDN9opfns/kZo4lxmSWhIqo+cSAF7+lfi9ZclQbr9vfnlNaPr8wYF3UYjm5X0yPAhbcgqNOdA==" + }, + "pg-protocol": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.2.5.tgz", + "integrity": "sha512-1uYCckkuTfzz/FCefvavRywkowa6M5FohNMF5OjKrqo9PSR8gYc8poVmwwYQaBxhmQdBjhtP514eXy9/Us2xKg==" + }, + "pg-types": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", + "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==", + "requires": { + "pg-int8": "1.0.1", + "postgres-array": "~2.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.4", + "postgres-interval": "^1.1.0" + } + }, + "pgpass": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.2.tgz", + "integrity": "sha1-Knu0G2BltnkH6R2hsHwYR8h3swY=", + "requires": { + "split": "^1.0.0" + } + }, "pngjs": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-3.4.0.tgz", "integrity": "sha512-NCrCHhWmnQklfH4MtJMRjZ2a8c80qXeMlQMv2uVp9ISJMTt562SbGd6n2oq0PaPgKm7Z6pL9E2UlLIhC+SHL3w==" }, + "postgres-array": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", + "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==" + }, + "postgres-bytea": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz", + "integrity": "sha1-AntTPAqokOJtFy1Hz5zOzFIazTU=" + }, + "postgres-date": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.5.tgz", + "integrity": "sha512-pdau6GRPERdAYUQwkBnGKxEfPyhVZXG/JiS44iZWiNdSOWE09N2lUgN6yshuq6fVSon4Pm0VMXd1srUUkLe9iA==" + }, + "postgres-interval": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz", + "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==", + "requires": { + "xtend": "^4.0.0" + } + }, "prebuild-install": { - "version": "5.3.4", - "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.4.tgz", - "integrity": "sha512-AkKN+pf4fSEihjapLEEj8n85YIw/tN6BQqkhzbDc0RvEZGdkpJBGMUYx66AAMcPG2KzmPQS7Cm16an4HVBRRMA==", + "version": "5.3.5", + "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.5.tgz", + "integrity": "sha512-YmMO7dph9CYKi5IR/BzjOJlRzpxGGVo1EsLSUZ0mt/Mq0HWZIHOKHHcHdT69yG54C9m6i45GpItwRHpk0Py7Uw==", "requires": { "detect-libc": "^1.0.3", "expand-template": "^2.0.3", @@ -2115,13 +2048,24 @@ } }, "readable-stream": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.3.0.tgz", - "integrity": "sha512-EsI+s3k3XsW+fU8fQACLN59ky34AZ14LoeVZpYwmZvldCFo0r0gnelwF2TcMjLor/BTL5aDJVBMkss0dthToPw==", + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + } } }, "readable-web-to-node-stream": { @@ -2129,11 +2073,6 @@ "resolved": "https://registry.npmjs.org/readable-web-to-node-stream/-/readable-web-to-node-stream-2.0.0.tgz", "integrity": "sha512-+oZJurc4hXpaaqsN68GoZGQAQIA3qr09Or4fqEsargABnbe5Aau8hFn6ISVleT3cpY/0n/8drn7huyyEvTbghA==" }, - "regexp-clone": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-1.0.0.tgz", - "integrity": "sha512-TuAasHQNamyyJ2hb97IuBEif4qBHGjPHBS64sZwytpLEqtBQ1gPJTnOaQ6qmpET16cK14kkjbazl6+p0RRv0yw==" - }, "regexpp": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", @@ -2150,22 +2089,6 @@ "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==" }, - "require_optional": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz", - "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==", - "requires": { - "resolve-from": "^2.0.0", - "semver": "^5.1.0" - }, - "dependencies": { - "resolve-from": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz", - "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=" - } - } - }, "resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", @@ -2228,15 +2151,6 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, - "saslprep": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz", - "integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==", - "optional": true, - "requires": { - "sparse-bitfield": "^3.0.3" - } - }, "semver": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", @@ -2248,9 +2162,8 @@ "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" }, "sharp": { - "version": "0.25.4", - "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.25.4.tgz", - "integrity": "sha512-umSzJJ1oBwIOfwFFt/fJ7JgCva9FvrEU2cbbm7u/3hSDZhXvkME8WE5qpaJqLIe2Har5msF5UG4CzYlEg5o3BQ==", + "version": "github:deftomat/sharp#f8ebbc8fb9e9b25b572c517640894869ba25a733", + "from": "github:deftomat/sharp", "requires": { "color": "^3.1.2", "detect-libc": "^1.0.3", @@ -2263,15 +2176,6 @@ "tunnel-agent": "^0.6.0" }, "dependencies": { - "color": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/color/-/color-3.1.2.tgz", - "integrity": "sha512-vXTJhHebByxZn3lDvDJYw4lR5+uB3vuoHsuYA5AKuxRVn5wzzIfQKGLBmgdVRHKTJYeK5rvJcHnrd0Li49CFpg==", - "requires": { - "color-convert": "^1.9.1", - "color-string": "^1.5.2" - } - }, "semver": { "version": "7.3.2", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", @@ -2294,11 +2198,6 @@ "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", "dev": true }, - "sift": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/sift/-/sift-7.0.1.tgz", - "integrity": "sha512-oqD7PMJ+uO6jV9EQCl0LrRw1OwsiPsiFQR5AR30heR+4Dl7jBBbDLnNvWiak20tzZlSE1H7RB30SX/1j/YYT7g==" - }, "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", @@ -2353,11 +2252,6 @@ "is-fullwidth-code-point": "^2.0.0" } }, - "sliced": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", - "integrity": "sha1-CzpmK10Ewxd7GSa+qCsD+Dei70E=" - }, "sodium-native": { "version": "2.4.6", "resolved": "https://registry.npmjs.org/sodium-native/-/sodium-native-2.4.6.tgz", @@ -2383,13 +2277,12 @@ } } }, - "sparse-bitfield": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", - "integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=", - "optional": true, + "split": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", + "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", "requires": { - "memory-pager": "^1.0.2" + "through": "2" } }, "sprintf-js": { @@ -2413,9 +2306,9 @@ } }, "string_decoder": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.2.0.tgz", - "integrity": "sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "requires": { "safe-buffer": "~5.1.0" } @@ -2547,9 +2440,9 @@ } }, "tar-stream": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.2.tgz", - "integrity": "sha512-UaF6FoJ32WqALZGOIAApXx+OdxhekNMChu6axLJR85zMMjXKWFGjbIRe+J6P4UnRGg9rAwWvbTT0oI7hD/Un7Q==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.3.tgz", + "integrity": "sha512-Z9yri56Dih8IaK8gncVPx4Wqt86NDmQTSh49XLZgjWpGZL9GK9HKParS2scqHCC4w6X9Gh2jwaU45V47XTKwVA==", "requires": { "bl": "^4.0.1", "end-of-stream": "^1.4.1", @@ -2572,16 +2465,6 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } } } }, @@ -2593,6 +2476,16 @@ "base64-js": "^1.0.2", "ieee754": "^1.1.4" } + }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } } } }, @@ -2610,8 +2503,7 @@ "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" }, "token-types": { "version": "2.0.0", @@ -2642,9 +2534,9 @@ } }, "tweetnacl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.1.tgz", - "integrity": "sha512-kcoMoKTPYnoeS50tzoqjPY3Uv9axeuuFAZY9M/9zFnhoVvRfxz9K29IMPD7jGmt2c8SW7i3gT9WqDl2+nV7p4A==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", + "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==", "optional": true }, "type-check": { @@ -2683,12 +2575,6 @@ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" }, - "uws": { - "version": "10.148.2", - "resolved": "https://registry.npmjs.org/uws/-/uws-10.148.2.tgz", - "integrity": "sha1-8BZSoLS7lByxi7emJI14D9AVAkU=", - "optional": true - }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -2716,57 +2602,40 @@ } }, "winston": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/winston/-/winston-3.2.1.tgz", - "integrity": "sha512-zU6vgnS9dAWCEKg/QYigd6cgMVVNwyTzKs81XZtTFuRwJOcDdBg7AU0mXVyNbs7O5RH2zdv+BdNZUlx7mXPuOw==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/winston/-/winston-3.3.3.tgz", + "integrity": "sha512-oEXTISQnC8VlSAKf1KYSSd7J6IWuRPQqDdo8eoRNaYKLvwSb5+79Z3Yi1lrl6KDpU6/VWaxpakDAtb1oQ4n9aw==", "requires": { - "async": "^2.6.1", - "diagnostics": "^1.1.1", - "is-stream": "^1.1.0", - "logform": "^2.1.1", - "one-time": "0.0.4", - "readable-stream": "^3.1.1", + "@dabh/diagnostics": "^2.0.2", + "async": "^3.1.0", + "is-stream": "^2.0.0", + "logform": "^2.2.0", + "one-time": "^1.0.0", + "readable-stream": "^3.4.0", "stack-trace": "0.0.x", "triple-beam": "^1.3.0", - "winston-transport": "^4.3.0" + "winston-transport": "^4.4.0" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } } }, "winston-transport": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.3.0.tgz", - "integrity": "sha512-B2wPuwUi3vhzn/51Uukcao4dIduEiPOcOt9HJ3QeaXgkJ5Z7UwpBzxS4ZGNHtrxrUvTwemsQiSys0ihOf8Mp1A==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.4.0.tgz", + "integrity": "sha512-Lc7/p3GtqtqPBYYtS6KCN3c77/2QCev51DvcJKbkFPQNoj1sinkGwLGFDxkXY9J6p9+EPnYs+D90uwbnaiURTw==", "requires": { - "readable-stream": "^2.3.6", + "readable-stream": "^2.3.7", "triple-beam": "^1.2.0" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" - }, - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "~5.1.0" - } - } } }, "wordwrap": { @@ -2831,9 +2700,14 @@ } }, "ws": { - "version": "7.2.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.2.1.tgz", - "integrity": "sha512-sucePNSafamSKoOqoNfBd8V0StlkzJKL2ZAhGQinCfNQ+oacw+Pk7lcdAElecBF2VkLNZRiIb5Oi1Q5lVUVt2A==" + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz", + "integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==" + }, + "xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" }, "y18n": { "version": "4.0.0", diff --git a/package.json b/package.json index 061a641..bcc8799 100644 --- a/package.json +++ b/package.json @@ -25,22 +25,23 @@ "dotenv": "^8.2.0", "duckduckgo-images-api": "github:benpbolton/duckduckgo-images-api", "emoji-regex": "^8.0.0", - "eris": "^0.11.2", + "eris": "^0.13.3", "file-type": "^13.1.2", "gm": "github:TheEssem/gm", "jsqr": "^1.3.1", "lavacord": "^1.1.9", - "moment": "^2.26.0", + "moment": "^2.27.0", "moment-duration-format": "^2.3.2", - "mongoose": "^5.9.19", + "node-addon-api": "^3.0.0", "node-emoji": "^1.10.0", "node-fetch": "^2.6.0", "node-tweet": "^0.1.4", + "pg": "^8.3.0", "puppeteer-core": "^2.1.1", "qrcode": "^1.4.4", "retrotext": "github:TheEssem/retrotext", - "sharp": "^0.25.4", - "winston": "^3.2.1" + "sharp": "github:deftomat/sharp", + "winston": "^3.3.3" }, "devDependencies": { "eslint": "^5.15.2", @@ -49,9 +50,7 @@ "optionalDependencies": { "bufferutil": "^4.0.1", "erlpack": "github:abalabahaha/erlpack", - "eventemitter3": "^3.1.2", "sodium-native": "^2.4.6", - "uws": "^10.148.1", "zlib-sync": "^0.1.6" } } diff --git a/readme.md b/readme.md index 889e060..f5664a1 100644 --- a/readme.md +++ b/readme.md @@ -11,12 +11,12 @@ You can invite the bot to your server using this link: https://projectlounge.pw/ A command list can be found [here](https://projectlounge.pw/esmBot/help.html). -If you want to run it locally for testing purposes, you should install ImageMagick (version >=7), FFmpeg, MongoDB, and the Microsoft core fonts: +If you want to run it locally for testing purposes, you should install ImageMagick (version >=7), FFmpeg, PostgreSQL, and the Microsoft core fonts: ```shell # On most Debian/Ubuntu-based distros you will need to build ImageMagick from source instead of installing from apt/similar package managers. # Instructions to do so can be found here: https://imagemagick.org/script/install-source.php -sudo apt-get install imagemagick ffmpeg mongodb ttf-mscorefonts-installer +sudo apt-get install imagemagick ffmpeg postgresql ttf-mscorefonts-installer ``` After that, you should install the rest of the dependencies using npm: diff --git a/utils/database.js b/utils/database.js index 10438b7..10ee9e4 100644 --- a/utils/database.js +++ b/utils/database.js @@ -1,32 +1,9 @@ // database stuff -const mongoose = require("mongoose"); -mongoose.connect(process.env.MONGO, { poolSize: 10, bufferMaxEntries: 0, reconnectTries: 5000, useNewUrlParser: true, useUnifiedTopology: true }); -const guildSchema = new mongoose.Schema({ - id: String, - tags: Map, - prefix: String, - warns: Map, - disabledChannels: [String] +const { Pool } = require("pg"); +const pool = new Pool({ + user: "esmbot", + host: "localhost", + database: "esmbot", + port: 5432 }); -const Guild = mongoose.model("Guild", guildSchema); - -const tweetSchema = new mongoose.Schema({ - tweets: [String], - replies: [String], - media: [String], - phrases: [String], - games: [String], - characters: [String], - download: [String], - enabled: Boolean -}); -const TweetCollection = mongoose.model("TweetCollection", tweetSchema); - -const globalSchema = new mongoose.Schema({ - cmdCounts: Map -}); -const Global = mongoose.model("Global", globalSchema); - -exports.guilds = Guild; -exports.tweets = TweetCollection; -exports.global = Global; \ No newline at end of file +module.exports = pool; \ No newline at end of file diff --git a/utils/twitter.js b/utils/twitter.js index 3068025..94705aa 100644 --- a/utils/twitter.js +++ b/utils/twitter.js @@ -1,5 +1,4 @@ const Twitter = require("node-tweet"); -const database = require("../utils/database.js"); const client = new Twitter({ consumerKey: process.env.TWITTER_KEY, consumerSecret: process.env.CONSUMER_SECRET, @@ -8,7 +7,4 @@ const client = new Twitter({ }); exports.client = client; exports.active = false; -database.tweets.find({ enabled: true }).lean().exec((error, docs) => { - if (error) throw error; - exports.tweets = docs[0]; -}); \ No newline at end of file +exports.tweets = require("../tweets.json"); \ No newline at end of file