From 94c87575b4f5aaa3cb7b5173d73a0987c72ff397 Mon Sep 17 00:00:00 2001 From: RockySouthpaw <55056068+RockySouthpaw@users.noreply.github.com> Date: Thu, 30 Dec 2021 18:18:49 -0500 Subject: [PATCH] fix(Server/misc): adjust marketplace webhook Use same formatting as twitter. Probs should refactor `Promise` Webhook error still exist though. Not sure why. `script:npwd] [NPWD] [discord] [error]: Discord Error: 204 Error - No Content` --- resources/server/misc/discord.ts | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/resources/server/misc/discord.ts b/resources/server/misc/discord.ts index 0f91aa894..52d903e52 100644 --- a/resources/server/misc/discord.ts +++ b/resources/server/misc/discord.ts @@ -93,33 +93,35 @@ export async function reportTweetToDiscord(tweet: Tweet, reportingProfile: Profi } } -export async function reportListingToDiscord( - listing: MarketplaceListing, - reportingProfile: string, -): Promise { - const embedObj = createDiscordMsgObj('MARKETPLACE', 'Received a report for a listing', [ +export async function reportListingToDiscord(listing: MarketplaceListing, reportingProfile: string): Promise { + const guaranteedFields = [ { name: 'Reported By', - value: reportingProfile, - inline: true, + value: `\`\`\`Profile Name: ${reportingProfile}\`\`\``, }, { - name: 'Reported User', - value: `${listing.name} - (${listing.username})`, - inline: true, + name: 'Reported User Data', + value: `\`\`\`Profile Name: ${listing.username}\nProfile ID: ${listing.id}\nUser Identifier: ${listing.identifier}\`\`\``, }, { name: 'Reported Listing Title', - value: listing.title, + value: `\`\`\`Title: ${listing.name}\`\`\``, }, { name: 'Reported Listing Desc.', - value: listing.description, + value: `\`\`\`Description: ${listing.description}\`\`\``, }, - ]); - + ]; + + const finalFields = listing.url ? guaranteedFields.concat( + { + name: 'Reported Image:', + value: listing.url.split(IMAGE_DELIMITER).join('\n'), + }) : guaranteedFields + + const msgObj = createDiscordMsgObj('MARKETPLACE', `Received a report for a listing`, finalFields); try { - await postToWebhook(embedObj); + await postToWebhook(msgObj); } catch (e) { discordLogger.error(e.message); }