adjusted webhook helper to not query twice for member.

adjusted proxy message to just reply to message w/ attachments with "Attachment sent by" instead of sending error message
This commit is contained in:
Aster Fialla
2026-02-16 12:30:46 -05:00
parent b2fc9f9111
commit 6cd34e9c68
2 changed files with 9 additions and 9 deletions

View File

@@ -55,15 +55,14 @@ msgh.parseProxyTags = async function (authorId, content, attachmentUrl= null){
members.filter(member => member.proxy).forEach(member => {
const splitProxy = member.proxy.split("text");
if(content.startsWith(splitProxy[0]) && content.endsWith(splitProxy[1])) {
if (attachmentUrl) throw new Error(enums.err.ATTACHMENTS_NOT_ALLOWED);
proxyMessage.proxy = member.proxy;
proxyMessage.member = member;
if (attachmentUrl) return proxyMessage.message = enums.misc.ATTACHMENT_SENT_BY;
let escapedPrefix = splitProxy[0].replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
let escapedSuffix = splitProxy[1].replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
console.log(escapedPrefix, escapedSuffix);
escapedPrefix = new RegExp("^" + escapedPrefix);
escapedSuffix = new RegExp(escapedSuffix + "$")
proxyMessage.message = content.replace(escapedPrefix, "").replace(escapedSuffix, "");
console.log(proxyMessage.message);
if (proxyMessage.message.length === 0) throw new Error(enums.err.NO_MESSAGE_SENT_WITH_PROXY);
}
})