From c752ee2bf23389cd4a6e95e1c6fac4cad1e26c1b Mon Sep 17 00:00:00 2001 From: Aster Fialla Date: Mon, 23 Feb 2026 11:18:59 -0500 Subject: [PATCH] Revert "adding debounce" cus it's not working This reverts commit 1d27db960c314f2aec020d61c1aa463cd0345615. # Conflicts: # src/bot.js --- src/bot.js | 2 +- src/commands.js | 2 +- src/helpers/importHelper.js | 3 --- src/helpers/memberHelper.js | 4 ++-- src/helpers/utils.js | 2 -- tests/helpers/memberHelper.test.js | 14 +++++++------- 6 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/bot.js b/src/bot.js index 23712e6..33179e0 100644 --- a/src/bot.js +++ b/src/bot.js @@ -84,7 +84,7 @@ export const debounceLogin = utils.debounce(client.login, 60000); (async () => { try { - await debounceLogin(token); + await client.login(token); // await db.check_connection(); } catch (err) { console.error('Login failed:', err); diff --git a/src/commands.js b/src/commands.js index 73497eb..5a7edc1 100644 --- a/src/commands.js +++ b/src/commands.js @@ -54,7 +54,7 @@ cmds.set('import', { if ((message.content.includes('--help') || (args[0] === '' && args.length === 1)) && !attachmentUrl ) { return await message.reply(enums.help.IMPORT); } - return await importHelper.debounceImport(message.author.id, attachmentUrl).then(async (successfullyAdded) => { + return await importHelper.pluralKitImport(message.author.id, attachmentUrl).then(async (successfullyAdded) => { await message.reply(successfullyAdded); }).catch(async (error) => { if (error instanceof AggregateError) { diff --git a/src/helpers/importHelper.js b/src/helpers/importHelper.js index 7e86754..6cb2b15 100644 --- a/src/helpers/importHelper.js +++ b/src/helpers/importHelper.js @@ -1,6 +1,5 @@ import {enums} from "../enums.js"; import {memberHelper} from "./memberHelper.js"; -import {utils} from "./utils.js"; const ih = {}; @@ -41,6 +40,4 @@ ih.pluralKitImport = async function (authorId, attachmentUrl) { }); } -ih.debounceImport = utils.debounce(ih.pluralKitImport, 5000); - export const importHelper = ih; \ No newline at end of file diff --git a/src/helpers/memberHelper.js b/src/helpers/memberHelper.js index 02899b6..21396f5 100644 --- a/src/helpers/memberHelper.js +++ b/src/helpers/memberHelper.js @@ -296,7 +296,7 @@ mh.updateProxy = async function (authorId, memberName, proxy) { mh.updatePropic = async function (authorId, memberName, values, attachmentUrl = null, attachmentExpiration = null) { const imgUrl = values ?? attachmentUrl; // Throws error if invalid - await utils.debounceCheckImageFormat(imgUrl).catch((e) => { throw e }); + await utils.checkImageFormatValidity(imgUrl).catch((e) => { throw e }); return await mh.updateMemberField(authorId, memberName, "propic", imgUrl, attachmentExpiration).catch((e) => { throw e }); } @@ -381,7 +381,7 @@ mh.addFullMember = async function (authorId, memberName, displayName = null, pro let isValidPropic; if (propic && propic.length > 0) { - await utils.debounceCheckImageFormat(propic).then(() => { + await utils.checkImageFormatValidity(propic).then(() => { isValidPropic = true; }).catch((e) => { errors.push(`Tried to set profile picture to \"${propic}\". ${e.message}. ${enums.err.SET_TO_NULL}`); diff --git a/src/helpers/utils.js b/src/helpers/utils.js index 6b79064..a980cbf 100644 --- a/src/helpers/utils.js +++ b/src/helpers/utils.js @@ -26,6 +26,4 @@ u.checkImageFormatValidity = async function (imageUrl) { }); } -u.debounceCheckImageFormat = u.debounce(u.checkImageFormatValidity, 60000); - export const utils = u; diff --git a/tests/helpers/memberHelper.test.js b/tests/helpers/memberHelper.test.js index 583b851..a652032 100644 --- a/tests/helpers/memberHelper.test.js +++ b/tests/helpers/memberHelper.test.js @@ -20,7 +20,7 @@ jest.mock("../../src/helpers/utils.js", () => { return { utils: { - debounceCheckImageFormat: jest.fn().mockResolvedValue(), + checkImageFormatValidity: jest.fn().mockResolvedValue(), } } }); @@ -476,15 +476,15 @@ describe('MemberHelper', () => { [mockMember.propic, null, null, mockMember.propic], [mockMember.propic, attachmentUrl, null, attachmentUrl], [null, attachmentUrl, attachmentExpiration, attachmentUrl] - ])('calls debounceCheckImageFormat and updateMemberField and returns string', async(imgUrl, attachmentUrl, attachmentExpiration, expected) => { + ])('calls checkImageFormatValidity and updateMemberField and returns string', async(imgUrl, attachmentUrl, attachmentExpiration, expected) => { // Arrange jest.spyOn(memberHelper, 'updateMemberField').mockResolvedValue("Updated"); // Act return memberHelper.updatePropic(authorId, mockMember.name, imgUrl, attachmentUrl, attachmentExpiration).then((result) => { expect(result).toEqual("Updated"); - expect(utils.debounceCheckImageFormat).toHaveBeenCalledTimes(1); - expect(utils.debounceCheckImageFormat).toHaveBeenCalledWith(expected); + expect(utils.checkImageFormatValidity).toHaveBeenCalledTimes(1); + expect(utils.checkImageFormatValidity).toHaveBeenCalledWith(expected); expect(memberHelper.updateMemberField).toHaveBeenCalledTimes(1); expect(memberHelper.updateMemberField).toHaveBeenCalledWith(authorId, mockMember.name, "propic", expected, attachmentExpiration); }); @@ -603,7 +603,7 @@ describe('MemberHelper', () => { }) }) - test('if propic, call debounceCheckImageFormat', async () => { + test('if propic, call checkImageFormatValidity', async () => { // Arrange const expectedMemberArgs = { name: mockMember.name, @@ -618,8 +618,8 @@ describe('MemberHelper', () => { return await memberHelper.addFullMember(authorId, mockMember.name, null, null, mockMember.propic).then((res) => { // Assert expect(res).toEqual(expectedReturn); - expect(utils.debounceCheckImageFormat).toHaveBeenCalledWith(mockMember.propic); - expect(utils.debounceCheckImageFormat).toHaveBeenCalledTimes(1); + expect(utils.checkImageFormatValidity).toHaveBeenCalledWith(mockMember.propic); + expect(utils.checkImageFormatValidity).toHaveBeenCalledTimes(1); expect(database.members.create).toHaveBeenCalledWith(expectedMemberArgs); expect(database.members.create).toHaveBeenCalledTimes(1); })