Skip to content

Commit

Permalink
refactor: temp_pm
Browse files Browse the repository at this point in the history
Co-authored-by: codefactor-io <support@codefactor.io>
  • Loading branch information
GiorgioBrux and code-factor authored Apr 4, 2024
1 parent 0ba3cba commit 42f4edb
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions src/notes/websites/temp_pm.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -15,17 +15,19 @@ function getData(msg, writeNotes, temp_pm, send_webhook_notes, user_tag) {
.match(/(?<=<div class="panel-body panel-message2">).*?(?=<\/div>)/gs)[0]
.replace("<br />", "");
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",
msg.guild ? msg.guild.name : "DMs",
msg.author.tag,
user_tag,
result,
msg.url
msg.url,
);

if (writeNotes === "true") {
Expand All @@ -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) || [];
});
Expand Down

0 comments on commit 42f4edb

Please sign in to comment.