From 42f4edb31b04ae7b4078e2c3fc27892bd3199029 Mon Sep 17 00:00:00 2001 From: GiorgioBrux <18328525+GiorgioBrux@users.noreply.github.com> Date: Thu, 4 Apr 2024 11:08:05 +0200 Subject: [PATCH] refactor: temp_pm Co-authored-by: codefactor-io --- src/notes/websites/temp_pm.js | 47 ++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/src/notes/websites/temp_pm.js b/src/notes/websites/temp_pm.js index 39049f4..b7d98fa 100644 --- a/src/notes/websites/temp_pm.js +++ b/src/notes/websites/temp_pm.js @@ -1,5 +1,5 @@ const axios = require("axios").default; -const logging = require('../../logging/logging') +const logging = require("../../logging/logging"); const fs = require("fs"); function getData(msg, writeNotes, temp_pm, send_webhook_notes, user_tag) { @@ -15,9 +15,11 @@ function getData(msg, writeNotes, temp_pm, send_webhook_notes, user_tag) { .match(/(?<=
).*?(?=<\/div>)/gs)[0] .replace("
", ""); if (!result || result.length === 0) { - return logging.success(`{rgb(137,96,142) Sniped temp.pm [${requestCode}] - Non-existant/Already destroyed - ${ - msg.guild ? msg.guild.name : "DM" - } from ${msg.author.tag}.}`); + return logging.success( + `{rgb(137,96,142) Sniped temp.pm [${requestCode}] - Non-existant/Already destroyed - ${ + msg.guild ? msg.guild.name : "DM" + } from ${msg.author.tag}.}`, + ); } send_webhook_notes.send_webhook_notes( "temp.pm", @@ -25,7 +27,7 @@ function getData(msg, writeNotes, temp_pm, send_webhook_notes, user_tag) { msg.author.tag, user_tag, result, - msg.url + msg.url, ); if (writeNotes === "true") { @@ -35,24 +37,29 @@ function getData(msg, writeNotes, temp_pm, send_webhook_notes, user_tag) { result, (err) => { if (err) { - logging.success(`{rgb(137,96,142) Sniped temp.pm [${requestCode}] - Couldn't save it to file because of err: ${ - err.message - } - ${msg.guild ? msg.guild.name : "DM"} from ${msg.author.tag}.}`); - } - else { - logging.success(`{rgb(137,96,142) Sniped temp.pm [${requestCode}] - Saved to file ./notes/temp_pm-${requestCode.substring( - 0, - 10 - )}.txt - ${msg.guild ? msg.guild.name : "DM"} from ${ - msg.author.tag - }.}`); + logging.success( + `{rgb(137,96,142) Sniped temp.pm [${requestCode}] - Couldn't save it to file because of err: ${ + err.message + } - ${msg.guild ? msg.guild.name : "DM"} from ${msg.author.tag}.}`, + ); + } else { + logging.success( + `{rgb(137,96,142) Sniped temp.pm [${requestCode}] - Saved to file ./notes/temp_pm-${requestCode.substring( + 0, + 10, + )}.txt - ${msg.guild ? msg.guild.name : "DM"} from ${ + msg.author.tag + }.}`, + ); } - } + }, ); } else { - logging.success(`{rgb(137,96,142) Sniped privnote [${requestCode}] - ${ - msg.guild ? msg.guild.name : "DM" - } from ${msg.author.tag}.}`); + logging.success( + `{rgb(137,96,142) Sniped privnote [${requestCode}] - ${ + msg.guild ? msg.guild.name : "DM" + } from ${msg.author.tag}.}`, + ); } return result.match(global.regex) || []; });