From 9919e8c4b142e453e78d41a3130e1fbb17e38d99 Mon Sep 17 00:00:00 2001 From: Aster Fialla Date: Sat, 14 Feb 2026 22:11:04 -0500 Subject: [PATCH] adjusting attachment arguments to work --- src/helpers/memberHelper.js | 67 ++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/src/helpers/memberHelper.js b/src/helpers/memberHelper.js index add0259..2e6d86f 100644 --- a/src/helpers/memberHelper.js +++ b/src/helpers/memberHelper.js @@ -20,7 +20,7 @@ const commandList = ['--help', 'add', 'remove', 'name', 'list', 'displayName', ' * @returns {Promise | Promise } A message, or an informational embed. * @throws {Error} */ -mh.parseMemberCommand = async function(authorId, authorFull, args, attachmentUrl){ +mh.parseMemberCommand = async function(authorId, authorFull, args, attachmentUrl = null, attachmentExpiration = null){ let member; // checks whether command is in list, otherwise assumes it's a name if(!commandList.includes(args[0])) { @@ -161,51 +161,28 @@ mh.updateProxy = async function(authorId, args) { } } -/** - * Updates the proxy for a member, first checking that no other members attached to the author have the tag. - * - * @param {string} authorId - The author of the message - * @param {string} proxy - The proxy tag. - * @returns {Promise } Whether the proxy exists. - * @throws {Error} When an empty proxy was provided, or no proxy exists. - */ -mh.checkIfProxyExists = async function(authorId, proxy) { - const trimmedProxy = proxy ? proxy.trim() : null; - - if (trimmedProxy == null) throw new RangeError(`Proxy ${enums.err.NO_VALUE}`); - 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); - - await mh.getMembersByAuthor(authorId).then((memberList) => { - const proxyExists = memberList.some(member => member.proxy === proxy); - if (proxyExists) { - throw new Error(enums.err.PROXY_EXISTS); - } - }).catch(e =>{throw e}); - -} /** * Updates the profile pic for a member, based on either the attachment or the args provided. * * @async * @param {string} authorId - The author of the message * @param {string[]} args - The message arguments - * @param {string} attachment - The url of the first attachment in the message + * @param {string} attachmentUrl - The url of the first attachment in the message + * @param {string} attachmentExpiry - The expiration date of the first attachment in the message * @returns {Promise} A successful update. * @throws {Error} When loading the profile picture from a URL doesn't work. */ -mh.updatePropic = async function(authorId, args, attachment) { +mh.updatePropic = async function(authorId, args, attachmentUrl, attachmentExpiry) { if (args[1] && args[1] === "--help") { return enums.help.PROPIC; } let img; const updatedArgs = args; - if (!updatedArgs[1] && !attachment) { + if (!updatedArgs[1] && !attachmentUrl) { return enums.help.PROPIC; - } else if (attachment) { - updatedArgs[2] = attachment.url; - updatedArgs[3] = attachment.expires_at; + } else if (attachmentUrl) { + updatedArgs[2] = attachmentUrl; + updatedArgs[3] = attachmentExpiry; } if (updatedArgs[2]) { img = updatedArgs[2]; @@ -305,7 +282,6 @@ mh.updateMemberField = async function(authorId, args) { // indicates that an attachment was uploaded on Fluxer directly if (columnName === "propic" && args[3]) { - console.log(args); fluxerPropicWarning = mh.setExpirationWarning(args[3]); } return await db.members.update({[columnName]: value}, { where: { name: memberName, userid: authorId } }).then(() => { @@ -387,9 +363,7 @@ mh.getAllMembersInfo = async function(authorId, authorName) { * @throws { EmptyResultError } When the member is not found. */ mh.getMemberByName = async function(authorId, memberName) { - console.log(memberName); return await db.members.findOne({ where: { userid: authorId, name: memberName } }).catch(e => { - console.log(e); throw new EmptyResultError(`Can't get ${memberName}. ${enums.err.NO_MEMBER}: ${e.message}`); }); } @@ -424,4 +398,29 @@ mh.getMembersByAuthor = async function(authorId) { } +/** + * Checks if proxy exists for a member. + * + * @param {string} authorId - The author of the message + * @param {string} proxy - The proxy tag. + * @returns {Promise } Whether the proxy exists. + * @throws {Error} When an empty proxy was provided, or no proxy exists. + */ +mh.checkIfProxyExists = async function(authorId, proxy) { + const trimmedProxy = proxy ? proxy.trim() : null; + + if (trimmedProxy == null) throw new RangeError(`Proxy ${enums.err.NO_VALUE}`); + 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); + + await mh.getMembersByAuthor(authorId).then((memberList) => { + const proxyExists = memberList.some(member => member.proxy === proxy); + if (proxyExists) { + throw new Error(enums.err.PROXY_EXISTS); + } + }).catch(e =>{throw e}); +} + + export const memberHelper = mh; \ No newline at end of file