Skip to content

Commit db923a1

Browse files
authored
Updated untimeout.js
1 parent 2778b67 commit db923a1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/commands/moderation/untimeout.js

+18
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const fs = require("fs");
99
const path = require("path");
1010

1111
const logChannelsPath = path.join(__dirname, "../logChannels.json");
12+
const logsFilePath = path.join(__dirname, "../modlogs.json");
1213

1314
module.exports = {
1415
/**
@@ -102,6 +103,23 @@ module.exports = {
102103
console.error("Log channel not found.");
103104
}
104105
}
106+
107+
let modLogs = {};
108+
if (fs.existsSync(logsFilePath)) {
109+
const data = fs.readFileSync(logsFilePath);
110+
modLogs = JSON.parse(data);
111+
}
112+
113+
if (!modLogs[targetUser.id]) modLogs[targetUser.id] = [];
114+
115+
modLogs[targetUser.id].push({
116+
type: "UnTimeout",
117+
reason: reason,
118+
moderator: interaction.user.id,
119+
timestamp: Math.floor(Date.now() / 1000),
120+
});
121+
122+
fs.writeFileSync(logsFilePath, JSON.stringify(modLogs, null, 2));
105123
} catch (error) {
106124
console.log(`There was an error when untimeoutting: ${error}`);
107125
}

0 commit comments

Comments
 (0)