Fix: Further converting ES6 to CJS - Making exports named instead of default (#26)

* adding to git ignore

* making imports named not default to not break all my tests

* adjusted setup for memberhelper test

---------

Co-authored-by: Aster Fialla <asterfialla@gmail.com>
This commit is contained in:
2026-02-28 15:28:27 -05:00
committed by GitHub
parent 39a7115803
commit d14e89e8b2
11 changed files with 50 additions and 43 deletions

View File

@@ -1,5 +1,5 @@
const enums = require("../enums.js");
const memberHelper = require("./memberHelper.js");
const {enums} = require("../enums.js");
const {memberHelper} = require("./memberHelper.js");
const importHelper = {};
@@ -55,4 +55,4 @@ importHelper.pluralKitImport = async function (authorId, attachmentUrl= null) {
return aggregatedText;
}
module.exports = importHelper;
exports.importHelper = importHelper;

View File

@@ -1,8 +1,8 @@
const database = require('../database.js');
const enums = require("../enums.js");
const {database} = require('../database.js');
const {enums} = require("../enums.js");
const {Op} = require("sequelize");
const {EmbedBuilder} = require("@fluxerjs/core");
const utils = require("./utils.js");
const {utils} = require("./utils.js");
const memberHelper = {};
@@ -365,20 +365,21 @@ memberHelper.addFullMember = async function (authorId, memberName, displayName =
}
}
let isValidPropic;
let isValidPropic, expirationWarning;
if (propic && propic.length > 0) {
try {
isValidPropic = await utils.checkImageFormatValidity(propic);
expirationWarning = utils.setExpirationWarning(propic, attachmentExpiration);
if (expirationWarning) {
errors.push(expirationWarning);
}
}
catch(e) {
errors.push(`Tried to set profile picture to \"${propic}\". ${e.message}. ${enums.err.SET_TO_NULL}`);
isValidPropic = false;
}
}
const expirationWarning = utils.setExpirationWarning(propic, attachmentExpiration);
if (expirationWarning) {
errors.push(expirationWarning);
}
const member = await database.members.create({
name: memberName, userid: authorId, displayname: isValidDisplayName ? displayName : null, proxy: isValidProxy ? proxy : null, propic: isValidPropic ? propic : null
});
@@ -516,4 +517,4 @@ memberHelper.getMemberCommandInfo = function() {
}
module.exports = memberHelper;
module.exports.memberHelper = memberHelper;

View File

@@ -1,8 +1,8 @@
const memberHelper = require('./memberHelper.js');
const {memberHelper} = require('./memberHelper.js');
const messageHelper = {};
const msgh = {};
messageHelper.prefix = "pf;"
msgh.prefix = "pf;"
/**
* Parses and slices up message arguments, retaining quoted strings.
@@ -11,8 +11,8 @@ messageHelper.prefix = "pf;"
* @param {string} commandName - The command name.
* @returns {string[]} An array of arguments.
*/
messageHelper.parseCommandArgs = function(content, commandName) {
const message = content.slice(messageHelper.prefix.length + commandName.length).trim();
msgh.parseCommandArgs = function(content, commandName) {
const message = content.slice(msgh.prefix.length + commandName.length).trim();
return message.match(/\\?.|^$/g).reduce((accumulator, chara) => {
if (chara === '\"' || chara === '\'') {
@@ -38,7 +38,7 @@ messageHelper.parseCommandArgs = function(content, commandName) {
* @param {string | null} [attachmentUrl] - The url for an attachment to the message, if any exists.
* @returns {Promise<{model, string, bool}>} The proxy message object.
*/
messageHelper.parseProxyTags = async function (authorId, content, attachmentUrl = null){
msgh.parseProxyTags = async function (authorId, content, attachmentUrl = null){
const members = await memberHelper.getMembersByAuthor(authorId);
// If an author has no members, no sense in searching for proxy
if (members.length === 0) {
@@ -70,7 +70,7 @@ messageHelper.parseProxyTags = async function (authorId, content, attachmentUrl
* @returns {{text: string, file: Buffer<ArrayBuffer> | undefined}} The text and buffer object
*
*/
messageHelper.returnBufferFromText = function (text) {
msgh.returnBufferFromText = function (text) {
if (text.length > 2000) {
const truncated = text.substring(0, 2000);
const restOfText = text.substring(2000);
@@ -80,4 +80,4 @@ messageHelper.returnBufferFromText = function (text) {
return {text: text, file: undefined}
}
module.exports = messageHelper;
module.exports.messageHelper = msgh;

View File

@@ -1,4 +1,4 @@
const enums = require('../enums');
const {enums} = require('../enums');
const utils = {};
@@ -54,4 +54,4 @@ utils.setExpirationWarning = function (imgUrl = null, expirationString = null) {
return null;
}
module.exports = utils;
module.exports.utils = utils;

View File

@@ -93,4 +93,4 @@ webhookHelper.getWebhook = async function(client, channel) {
return channelWebhooks.find((webhook) => webhook.name === name);
}
module.exports = webhookHelper;
module.exports.webhookHelper = webhookHelper;