Skip to content

Commit b175c7a

Browse files
authored
Updated timeout.js
1 parent 211e2d8 commit b175c7a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/commands/moderation/timeout.js

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

1212
const logChannelsPath = path.join(__dirname, "../logChannels.json");
13+
const logsFilePath = path.join(__dirname, "../modlogs.json");
1314

1415
module.exports = {
1516
/**
@@ -125,6 +126,23 @@ module.exports = {
125126
console.error("Log channel not found.");
126127
}
127128
}
129+
130+
let modLogs = {};
131+
if (fs.existsSync(logsFilePath)) {
132+
const data = fs.readFileSync(logsFilePath);
133+
modLogs = JSON.parse(data);
134+
}
135+
136+
if (!modLogs[targetUser.id]) modLogs[targetUser.id] = [];
137+
138+
modLogs[targetUser.id].push({
139+
type: "Timeout",
140+
reason: reason,
141+
moderator: interaction.user.id,
142+
timestamp: Math.floor(Date.now() / 1000),
143+
});
144+
145+
fs.writeFileSync(logsFilePath, JSON.stringify(modLogs, null, 2));
128146
} catch (error) {
129147
console.log(`There was an error when timing out: ${error}`);
130148
}

0 commit comments

Comments
 (0)