From 69721aeb79f21836e4637a4d88fc57e8c059bebe Mon Sep 17 00:00:00 2001 From: Danny Miller Date: Wed, 19 Jun 2024 13:22:12 -0400 Subject: [PATCH] better discord formatting --- pages/api/report/index.tsx | 2 +- tests/pages/api/report/report.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/api/report/index.tsx b/pages/api/report/index.tsx index 90f93f234..d2374397b 100644 --- a/pages/api/report/index.tsx +++ b/pages/api/report/index.tsx @@ -94,7 +94,7 @@ export default withAuth({ return res.status(400).json({ error: 'You have already reported this. Please wait for it to be reviewed.' }); } - const content = `User ${userReporting.name} reported a ${reportType} by user ${userBeingReported.name} for reason ${reportReason} with message: ${message}. [Link](${url})`; + const content = `User ${userReporting.name} reported a [${reportType}](${url}) by user ${userBeingReported.name} for reason ${reportReason} with message:\n\`${message}\`.`; await queueDiscordWebhook( DiscordChannel.DevPriv, content); diff --git a/tests/pages/api/report/report.test.ts b/tests/pages/api/report/report.test.ts index 3c7da904e..d9c876272 100644 --- a/tests/pages/api/report/report.test.ts +++ b/tests/pages/api/report/report.test.ts @@ -59,7 +59,7 @@ describe('pages/api/report/index.ts', () => { // Assert that queueDiscordWebhook was called with the expected arguments expect(queueDiscordWebhook).toHaveBeenCalledWith( expect.any(String), - expect.stringContaining('User test reported a Review by user BBB for reason HARASSMENT with message: This is a test report. [Link](https://pathology'), + expect.stringMatching(/User test reported a \[Review\]\(https.*\) by user BBB for reason HARASSMENT with message:\n`This is a test report`./), ); }, }); @@ -116,7 +116,7 @@ describe('pages/api/report/index.ts', () => { // Assert that queueDiscordWebhook was called with the expected arguments expect(queueDiscordWebhook).toHaveBeenCalledWith( expect.any(String), - expect.stringContaining('User Curator reported a Review by user BBB for reason HARASSMENT with message: This is a test report. [Link](https://pathology'), + expect.stringMatching(/User Curator reported a \[Review\]\(https.*\) by user BBB for reason HARASSMENT with message:\n`This is a test report`./), ); }, });