Ok that was that way for a reason

This commit is contained in:
Christopher Cookman 2024-07-19 18:29:58 -06:00
parent 29851ceb98
commit 51d6671089
Signed by: ChrisChrome
GPG key ID: A023A26E42C33A42

View file

@ -342,8 +342,17 @@ app.post("/report/:psk", (req, res) => {
], ],
"timestamp": new Date(dataFeilds["UTC Timestamp"]) "timestamp": new Date(dataFeilds["UTC Timestamp"])
} }
], ]
components: [ }
db.run('INSERT INTO reports (channel_id, reporter_id, reported_id, reporter_name, reported_name, reason, time_stamp, server_name, server_endpoint, reported_netid, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [channel.id, dataFeilds["Reporter UserID"].replaceAll("`", ""), dataFeilds["Reported UserID"].replaceAll("`", ""), dataFeilds["Reporter Nickname"], dataFeilds["Reported Nickname"], dataFeilds["Reason"], dataFeilds["Timestamp"], dataFeilds["Server Name"], dataFeilds["Server Endpoint"], dataFeilds["Reported NetID"], "unacknowledged"], (err) => {
channel.send(newMsgData).then(msg => {
db.get('SELECT id FROM reports WHERE channel_id = ? ORDER BY id DESC LIMIT 1', [channel.id], (err, row) => {
if (err) {
console.error(`${colors.red("[ERROR]")} ${colors.red(`An error occurred while handling a report: ${err}`)}`);
return res.status(500).send({ error: "An error occurred while handling the report" });
}
newMsgData.components = [
{ {
type: 1, type: 1,
components: [ components: [
@ -377,15 +386,7 @@ app.post("/report/:psk", (req, res) => {
] ]
} }
] ]
} msg.edit(msgData);
db.run('INSERT INTO reports (channel_id, reporter_id, reported_id, reporter_name, reported_name, reason, time_stamp, server_name, server_endpoint, reported_netid, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [channel.id, dataFeilds["Reporter UserID"].replaceAll("`", ""), dataFeilds["Reported UserID"].replaceAll("`", ""), dataFeilds["Reporter Nickname"], dataFeilds["Reported Nickname"], dataFeilds["Reason"], dataFeilds["Timestamp"], dataFeilds["Server Name"], dataFeilds["Server Endpoint"], dataFeilds["Reported NetID"], "unacknowledged"], (err) => {
channel.send(newMsgData).then(msg => {
db.get('SELECT id FROM reports WHERE channel_id = ? ORDER BY id DESC LIMIT 1', [channel.id], (err, row) => {
if (err) {
console.error(`${colors.red("[ERROR]")} ${colors.red(`An error occurred while handling a report: ${err}`)}`);
return res.status(500).send({ error: "An error occurred while handling the report" });
}
}); });
}); // Always do this just in case db fails }); // Always do this just in case db fails
if (err) { if (err) {