diff --git a/commands/feedback.js b/commands/feedback.js index b2cc776..e231007 100644 --- a/commands/feedback.js +++ b/commands/feedback.js @@ -1,7 +1,9 @@ const client = require("../utils/client.js"); +const regex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/ig; exports.run = async (message, args) => { if (args.length !== 0) { + if (regex.test(args.join(" "))) return `${message.author.mention}, you can't send a message containing a URL. If you want to report an issue, please join the esmBot Support server instead.`; const feedbackChannel = client.guilds.get("592399417676529688").channels.get("592429860769497098"); feedbackChannel.createMessage({ embed: { diff --git a/commands/qrread.js b/commands/qrread.js index ea405a8..70ca085 100644 --- a/commands/qrread.js +++ b/commands/qrread.js @@ -1,5 +1,6 @@ const magick = require("../build/Release/image.node"); const { promisify } = require("util"); +const { clean } = require("../utils/misc.js"); exports.run = async (message) => { const image = await require("../utils/imagedetect.js")(message); @@ -7,7 +8,7 @@ exports.run = async (message) => { message.channel.sendTyping(); const {qrText, missing} = await promisify(magick.qrread)(image.path); if (missing) return `${message.author.mention}, I couldn't find a QR code!`; - return `\`\`\`\n${qrText}\n\`\`\``; + return `\`\`\`\n${await clean(qrText)}\n\`\`\``; }; exports.category = 1; diff --git a/events/messageCreate.js b/events/messageCreate.js index c24d718..7a654ef 100644 --- a/events/messageCreate.js +++ b/events/messageCreate.js @@ -1,5 +1,4 @@ const fs = require("fs"); -const { promisify } = require("util"); const client = require("../utils/client.js"); const database = require("../utils/database.js"); const logger = require("../utils/logger.js"); @@ -47,7 +46,7 @@ module.exports = async (message) => { } else if (typeof result === "object" && result.file) { if (result.file.length > 8388119 && process.env.TEMPDIR !== "") { const filename = `${Math.random().toString(36).substring(2, 15)}.${result.name.split(".")[1]}`; - await promisify(fs.writeFile)(`${process.env.TEMPDIR}/${filename}`, result.file); + await fs.promises.writeFile(`${process.env.TEMPDIR}/${filename}`, result.file); await client.createMessage(message.channel.id, { embed: { color: 16711680, diff --git a/messages.json b/messages.json index 0d8e333..0077e16 100644 --- a/messages.json +++ b/messages.json @@ -111,5 +111,6 @@ "Schmelf?", "Troll", "ay yo the pizza here", - "100 gecs" + "100 gecs", + "with limited resources" ] \ No newline at end of file diff --git a/utils/help.js b/utils/help.js index 28ecdf9..47537dc 100644 --- a/utils/help.js +++ b/utils/help.js @@ -9,6 +9,8 @@ ${process.env.NODE_ENV === "development" ? "\n**You are currently using esmBot D Default prefix is \`&\`. +**Want to help support esmBot's development? Consider donating on Patreon!** https://patreon.com/TheEssem + > Tip: You can get more info about a command by using \`help [command]\`. ## Table of Contents diff --git a/utils/imagedetect.js b/utils/imagedetect.js index 028eb92..89f6e2d 100644 --- a/utils/imagedetect.js +++ b/utils/imagedetect.js @@ -12,7 +12,7 @@ const typeCheck = async (image, image2, gifv = false) => { const controller = new AbortController(); const timeout = setTimeout(() => { controller.abort(); - }, 15000); + }, 25000); try { const imageRequest = await fetch(image, { signal: controller.signal }); const imageBuffer = await imageRequest.buffer(); diff --git a/utils/urlcheck.js b/utils/urlcheck.js index 9cc6a2e..74fd4fa 100644 --- a/utils/urlcheck.js +++ b/utils/urlcheck.js @@ -1,11 +1,11 @@ module.exports = (string) => { - var protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/; - var domainRE = /^[^\s.]+\.\S{2,}$/; - var match = string.match(protocolAndDomainRE); + const protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/; + const domainRE = /^[^\s.]+\.\S{2,}$/; + const match = string.match(protocolAndDomainRE); if (!match) { return false; } - var everythingAfterProtocol = match[1]; + const everythingAfterProtocol = match[1]; if (!everythingAfterProtocol) { return false; }