actually fixed proxy query

This commit is contained in:
Aster Fialla
2026-02-16 10:55:28 -05:00
parent a3c3eb1545
commit 4ea0a777af

View File

@@ -55,6 +55,7 @@ mh.parseMemberCommand = async function(authorId, authorFull, args, attachmentUrl
case 'displayname':
return await mh.updateDisplayName(authorId, args).catch((e) =>{throw e});
case 'proxy':
if (!args[2]) return await mh.getProxyByMember(authorId, args[0]).catch((e) => {throw e});
return await mh.updateProxy(authorId, args).catch((e) =>{throw e});
case 'propic':
return await mh.updatePropic(authorId, args, attachmentUrl, attachmentExpiration).catch((e) =>{throw e});
@@ -154,8 +155,7 @@ mh.updateDisplayName = async function(authorId, args) {
* @throws {RangeError | Error} When an empty proxy was provided, or no proxy exists.
*/
mh.updateProxy = async function(authorId, args) {
console.log(args)
if (args[2] && args[2] === "--help" || !args[2]) {
if (args[2] && args[2] === "--help") {
return enums.help.PROXY;
}
const proxyExists = await mh.checkIfProxyExists(authorId, args[2]).then((proxyExists) => {
@@ -396,6 +396,24 @@ mh.getMemberByName = async function(authorId, memberName) {
return await db.members.findOne({ where: { userid: authorId, name: memberName } });
}
/**
* Gets a member based on the author and proxy tag.
*
* @async
* @param {string} authorId - The author of the message.
* @param {string} memberName - The member's name.
* @returns {Promise<string>} The member object.
* @throws { EmptyResultError } When the member is not found.
*/
mh.getProxyByMember = async function(authorId, memberName) {
return await mh.getMemberByName(authorId, memberName).then((member) => {
if (member) {
return member.dataValues.proxy;
}
throw new EmptyResultError(enums.err.NO_MEMBER);
})
}
/**
* Gets a member based on the author and proxy tag.
*
@@ -429,6 +447,7 @@ mh.getMembersByAuthor = async function(authorId) {
* @throws {Error} When an empty proxy was provided, or no proxy exists.
*/
mh.checkIfProxyExists = async function(authorId, proxy) {
if (proxy) {
const splitProxy = proxy.trim().split("text");
if(splitProxy.length < 2) throw new Error(enums.err.NO_TEXT_FOR_PROXY);
if(!splitProxy[0] && !splitProxy[1]) throw new Error(enums.err.NO_PROXY_WRAPPER);
@@ -439,6 +458,8 @@ mh.checkIfProxyExists = async function(authorId, proxy) {
throw new Error(enums.err.PROXY_EXISTS);
}
}).catch(e =>{throw e});
}
}