Skip to content

Commit dd2fdba

Browse files
authored
Updated moderate-nickname.js
1 parent cdf2018 commit dd2fdba

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/commands/moderation/moderate-nickname.js

+19-1
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
/**
@@ -33,7 +34,7 @@ module.exports = {
3334
}
3435

3536
const userId = interaction.options.getString("userid");
36-
const reason = interaction.options.getString("reason") || "No reason provided";
37+
const reason = interaction.options.getString("reason") || "N/A";
3738

3839
const user = await client.users.fetch(userId).catch(() => null);
3940
const targetMember = await interaction.guild.members.fetch(userId).catch(() => null);
@@ -90,6 +91,23 @@ module.exports = {
9091
console.error("Log channel not found.");
9192
}
9293
}
94+
95+
let modLogs = {};
96+
if (fs.existsSync(logsFilePath)) {
97+
const data = fs.readFileSync(logsFilePath);
98+
modLogs = JSON.parse(data);
99+
}
100+
101+
if (!modLogs[targetUser.id]) modLogs[targetUser.id] = [];
102+
103+
modLogs[targetUser.id].push({
104+
type: "Moderated-Nickname",
105+
reason: reason,
106+
moderator: interaction.user.id,
107+
timestamp: Math.floor(Date.now() / 1000),
108+
});
109+
110+
fs.writeFileSync(logsFilePath, JSON.stringify(modLogs, null, 2));
93111
} catch (error) {
94112
console.error("Error moderating nickname:", error);
95113
await interaction.reply({

0 commit comments

Comments
 (0)