Send unsanitized content to commands via content parameter, fixed emote command, removed another async promise

This commit is contained in:
TheEssem 2021-03-16 13:24:21 -05:00
parent cb8f939378
commit 74baa29684
3 changed files with 10 additions and 11 deletions

View file

@ -138,7 +138,7 @@ server.listen(8080, () => {
});
const runJob = (job, sock) => {
return new Promise(async (resolve, reject) => {
return new Promise((resolve, reject) => {
log(`Job ${job.uuid} starting...`, job.num);
const object = JSON.parse(job.msg);
@ -148,17 +148,16 @@ const runJob = (job, sock) => {
}
log(`Job ${job.uuid} started`, job.num);
try {
const { buffer, fileExtension } = await run(object);
run(object).then((data) => {
log(`Sending result of job ${job.uuid} back to the bot`, job.num);
jobs[job.uuid].data = buffer;
jobs[job.uuid].ext = fileExtension;
jobs[job.uuid].data = data.buffer;
jobs[job.uuid].ext = data.fileExtension;
sock.write(Buffer.concat([Buffer.from([0x1]), Buffer.from(job.uuid)]), (e) => {
if (e) return reject(e);
return resolve();
});
} catch (e) {
}).catch(e => {
reject(e);
}
});
});
};

View file

@ -1,9 +1,9 @@
const emojiRegex = require("emoji-regex");
exports.run = async (message, args) => {
exports.run = async (message, args, content) => {
if (args.length === 0) return `${message.author.mention}, you need to provide an emoji!`;
if (args[0].match(/^<a?:.+:\d+>$/)) {
return `https://cdn.discordapp.com/emojis/${args[0].replace(/^<(a)?:.+:(\d+)>$/, "$2")}.${args[0].replace(/^<(a)?:.+:(\d+)>$/, "$1") === "a" ? "gif" : "png"}`;
if (content.split(" ")[0].match(/^<a?:.+:\d+>$/)) {
return `https://cdn.discordapp.com/emojis/${content.split(" ")[0].replace(/^<(a)?:.+:(\d+)>$/, "$2")}.${content.split(" ")[0].replace(/^<(a)?:.+:(\d+)>$/, "$1") === "a" ? "gif" : "png"}`;
} else if (args[0].match(emojiRegex)) {
const codePoints = [];
for (const codePoint of args[0]) {

View file

@ -70,7 +70,7 @@ module.exports = async (message) => {
try {
await database.addCount(collections.aliases.has(command) ? collections.aliases.get(command) : command);
const startTime = new Date();
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
const result = await cmd(message, args, message.content.substring(prefix.length).trim().replace(command, "").trim()); // we also provide the message content as a parameter for cases where we need more accuracy
const endTime = new Date();
if (typeof result === "string" || (typeof result === "object" && result.embed)) {
await client.createMessage(message.channel.id, result);