Skip to content

Commit 949669e

Browse files
authored
Updated ban.js
1 parent e09be55 commit 949669e

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/commands/moderation/ban.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const {
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
/**
@@ -82,8 +83,25 @@ const {
8283
console.error("Log channel not found.");
8384
}
8485
}
86+
87+
let modLogs = {};
88+
if (fs.existsSync(logsFilePath)) {
89+
const data = fs.readFileSync(logsFilePath);
90+
modLogs = JSON.parse(data);
91+
}
92+
93+
if (!modLogs[targetUser.id]) modLogs[targetUser.id] = [];
94+
95+
modLogs[targetUser.id].push({
96+
type: "Ban",
97+
reason: reason,
98+
moderator: interaction.user.id,
99+
timestamp: Math.floor(Date.now() / 1000),
100+
});
101+
102+
fs.writeFileSync(logsFilePath, JSON.stringify(modLogs, null, 2));
85103
} catch (error) {
86-
console.error("Error banning user:", error);
104+
console.error(`Error banning user: ${error}`);
87105
await interaction.editReply("An error occurred while trying to ban the user.");
88106
}
89107
},

0 commit comments

Comments
 (0)